    function ysm_made_sidebar_height()  {
    $('.right_sub_area_cont').height($('.content_zone').height()) ;
    } 

jQuery(document).ready(function() {



/*
            function gogo_drop_menu()
            {
                $(".down_menu").hide();

                $(".head_box_menu li.main_m_item").hover(function() {

                    $(this).children('.down_menu').fadeIn(200);
                }, function() {
                    $(this).children('.down_menu').fadeOut(200);

                });
            }
*/

function gogo_drop_menu()
    {
        $(".down_menu").hide();

        $(".head_box_menu li.main_m_item").hover(function() {

            $(this).children('.down_menu').fadeIn(200);
        }, function() {
            $(this).children('.down_menu').fadeOut(200);


        });
        $('.down_menu li.page_item').hover(function(){
          $(this).children('ul').fadeIn(200);  ;
		  console.log('fadeIN');
        },
          function(){
            $(this).children('ul').css('display','none');
			console.log('fadeOUT');
          }

         );
    }
    

       

/*-------------------------------------------*/
    function gogo_drop_menu_delayed()
    {
        $(".down_menu").hide();

  $(".head_box_menu li.main_m_item").hover(function() {

            $(this).children('.down_menu').fadeIn(200);
        }, function() {
            $(this).children('.down_menu').fadeOut(200);
        });



   var config = {    
    sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)
    interval: 0, // number = milliseconds for onMouseOver polling interval
    over: function(){ // function = onMouseOver callback (REQUIRED)
    $(this).children('ul').fadeIn(200);
	
    },
    timeout: 500, // number = milliseconds delay before onMouseOut
    out: function(){ // function = onMouseOut callback (REQUIRED)
    $(this).children('ul').css('display','none');
	
   }
  };

  $('.down_menu li.page_item').hoverIntent(config);
    }

    gogo_drop_menu_delayed();
    /*-----------------------------------------------------------------------*/

            var tabs_text = new Array();
            tabs_text["hometab_item_1"] = '<a href="/ways-to-give/donate-now/">Donate Now</a>';
            tabs_text['hometab_item_2'] = '<a href="/volunteers/">Volunteer</a>';
            tabs_text["hometab_item_3"] = '<a href="/programs-ministries/evergreen-centre/">Learn More</a>';
            tabs_text["hometab_item_4"] = '<a href="/programs-ministries/">Learn More</a>';

            $(".home_mask_tab_navi").tabs({fx:{opacity: 'toggle', duration: "600" }}).tabs('rotate', 8000);
            $('.home_mask_tab_navi').bind('tabsselect', function(event, ui) {
                var selected_tab = ui.panel.id;

                $('.home_mask_Youcantoo').html(tabs_text[selected_tab]);

            });



     /*AJAX*/

// AJAX Link
     $('.event_ajax').click(
             function(e)
             {

             $('.event_ajax').removeClass('selected');
              $(this).addClass('selected');
                 past_ev_load(e);


             return false

             }
      );
          $('#ev_event_type').change(
             past_ev_load
      );
     
     
function past_ev_load(e){
$('#event_coll').html("<h6 class='event_loading'>Loading...</h6>") ;
        var ppz = $('.selected.event_ajax').text() ;
        var event_type = $('#ev_event_type').val() ;
         /*alert(ppz);*/
         var data = {
              'event_year': ppz ,
              'event_type': event_type
         };
         $.post($('.event_ajax').attr("href"), data, function(response){



              if(response=="")
              {
                $('#event_coll').html("<h6 class='event_loading'>No events</h6>") ;
              }
             else
              {
                  $('#event_coll').html(response) ;
              }
         });
         return false;
}




     /*---------------------------*/
    
     $('#cont_submit').click(function(){
        $('.wpcf7-form').submit();
         return false;
     });

     $('#submit_comment').click(function(){
        
       $('#commentform').submit();
       return false;
     });

       $(".brown_tabs_navi").tabs({fx:{opacity: 'toggle', duration: "600" }}).tabs('rotate', 8000);
/*---------dialog------------*/

     
       $('#send_friends_dialog').dialog({ modal: true,autoOpen : false,width: 350  });
      $('#send_friends_dialog_error').dialog({ modal: true,autoOpen : false,width: 350,buttons: { "Ok": function() { $(this).dialog("close"); } }  });
       $("#send_fiends_link").click(function(){
           $('#send_friends_dialog').dialog('open');
           return false
       }) ;
     


 

 /*----------------------------------------*/

      var options = {
        target:        '#ysm_friend_mail_responder',   // target element(s) to be updated with server response
        beforeSubmit: function(){
            $('#send_friends_dialog').dialog('close');
            $('#send_friends_dialog_error').dialog('open');
            $('#ysm_friend_mail_responder').html("loading")} ,
        success:       function(){


        }  // post-submit callback

        // other available options:
        //url:       url         // override for form's 'action' attribute
        //type:      type        // 'get' or 'post', override for form's 'method' attribute
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type)
        //clearForm: true        // clear all form fields after successful submit
        /*resetForm: true */       // reset the form after successful submit

        // $.ajax options can be used here too, for example:
        //timeout:   3000
    };

    // bind form using 'ajaxForm'
        $('#ysm_friend_mail').ajaxForm(options);

     $('#send_friends_gogo').click(function(){
          $('#ysm_friend_mail').submit();
         return false;
     });



     /*-----------------------------*/
 /*AJAX FOR VIDEOS*/

          $('.video_ajax').click(
             function(e)
             {

             $('.video_ajax').removeClass('selected');
              $(this).addClass('selected');
                 video_cat_load(e);


             return false

             }


      );


function video_cat_load(e){
$('#event_coll').html("<h6 class='event_loading'>Loading...</h6>") ;
        var ppz = $('.selected.video_ajax').text() ;

         /*alert(ppz);*/
         var data = {
              'video_cat': ppz 

         };
         $.post($('.event_ajax').attr("href"), data, function(response){



              if(response=="")
              {
                $('#event_coll').html("<h6 class='event_loading'>No events</h6>") ;
              }
             else
              {
                  $('#event_coll').html(response) ;
                  $('#ajax_video_tabs').tabs({fx:{opacity: 'toggle', duration: "100" }});
                 
              }
         });
         return false;
}

    /*dialog newsleater*/

     $('#news_sign_widget').dialog({ autoOpen: false ,  modal: true });

    $('#top_news').click(
            function(){
             $('#news_sign_widget').dialog( 'open' );
                return false;
            }
            );


  });

window.onload = function(){

    ysm_made_sidebar_height() ;


/*
         $("#top_news").tooltip({
          position: "bottom center",
          tip: '.tooltip' ,
          offset: [230,-190] ,
             events: {
    def:      "mouseover,mouseout",
    input:     "focus,blur", 
    widget:    "focus mouseover,blur mouseout",
    tooltip:        "mouseover,mouseout"
}




     }); */

/*    $('.content_zone').change(
            function(){
                alert('change');
            ysm_made_sidebar_height()
           } ) ;*/

    if($('.upload_error').length > 0)
    {
       

          var test_top=$('.upload_error').offset();
           $("html:not(:animated),body:not(:animated)").animate({ scrollTop: test_top.top}, 1100 );



    }
}


    /*-------------------------------------*/
    
function dateConvert(date) {
	date = date.toString();
	var date_year = date.split('.', 3)[2];
	var date_month = date.split('.', 3)[0];
	var date_day = date.split('.', 3)[1];
	
	switch(date_month)
	{
	case '01':
	  date_month = 'January'; break;
	case '02':
	  date_month = 'February'; break;
	case '03':
	  date_month = 'March'; break;
	case '04':
	  date_month = 'April'; break;
	case '05':
	  date_month = 'May'; break;
	case '06':
	  date_month = 'June'; break;
	case '07':
	  date_month = 'July'; break;
	case '08':
	  date_month = 'August'; break;
	case '09':
	  date_month = 'September'; break;
	case '10':
	  date_month = 'October'; break;
	case '11':
	  date_month = 'November'; break;
	case '12':
	  date_month = 'December'; break;
	default:
	  return;
	}
	
	switch(date_day)
	{
	case '01':
	  date_day =  '1st'; break;
	case '02':
	  date_day =  '2nd'; break;
	case '03':
	  date_day =  '3rd'; break;
	case '04':
	  date_day =  '4th'; break;
	case '05':
	  date_day =  '5th'; break;
	case '06':
	  date_day =  '6th'; break;
	case '07':
	  date_day =  '7th'; break;
	case '08':
	  date_day =  '8th'; break;
	case '09':
	  date_day =  '9th'; break;
	default:
	  date_day =  date_day + 'th'; break;
	}
	
	var text_date = date_month + ' ' + date_day + ', ' + date_year;
	
	return text_date;
	
}



function makeTeaser(text,size) {
	text = text.toString();
	text = text.split(' ', size);
	
	var teaser= '';

	for (var i=0;i < size; i++) {
                if(text[i]) teaser = teaser + ' ' + text[i];
	}
	teaser = teaser + '...';
	return teaser;
}


function fixPath(text) {
	text = text.toString();
	text = text.split('/', 100);
	var path='http://';
	
	//http://ysm.enthusiastinc.comwp-content/uploads/2010/01/ysm_about_us_5.jpg
	for (var i=2;i < text.length; i++) {
        if(text[i] == 'ysm.enthusiastinc.comwp-content') path = path + 'ysm.enthusiastinc.com/wp-content';
		else path = path + '/' +text[i];
	}
	return path;
}


































