$(function() {
  
  $('#slideshow .tabs').tabs('#slides li', { 
      effect: 'fade', 
      fadeOutSpeed: 'slow', 
      rotate: true 
   }).slideshow({
     autoplay: true,
     interval: 7000
   });

     
	$('#scrollable').scrollable().find('a img[title]').tooltip({ 
      tip: '#slider-tooltip',
      position: 'top, center',
      offset: [-25, 0] 
   });
 
	$('#nav-sub ul > li > ul').hide();
	
	$('#nav-sub ul > li > a').each(function(){
		if ($(this).parent().find('ul').size()) {
			$(this).click(function(){
				return false;
			});
		}
	});

	$('#nav-sub ul > li').each(function(){
		if ($(this).find('ul').size()) {
			$(this).find(':first-child').bind('click',function(){
				$(this).parent().find('ul').slideDown();
			});
		}
	});


  $('#nav-sub').find('a[href="'+window.location.href+'"]').each(function(){
    $(this).parent().addClass('current');
  });

  $('#nav-sub ul ul').find('a[href="'+window.location.href+'"]').each(function(){
    $(this).parents().eq(2).addClass('current');
    $(this).parents().eq(1).css('display', 'block');
    $(this).addClass('on')
  });
  
  $('#home-callouts img[title], #benefits-callout img[title]').tooltip({ 
    tip: '.callout-tooltip', 
    effect: 'fade', 
    fadeOutSpeed: 100, 
    predelay: 300, 
    position: 'bottom center',         
    offset: [0, 0] 
  });


  // grab the value attribute from the option element and send the user there  		
  $('#county-dropdown').change(function(){
    window.location.href = $(this).val();
  }); 


  // newsletter overlay
  $('.button.subscribe a[rel]').overlay();

	// toggle benefits descriptions
	// Roger Glenn 2010-04-06
  $(".benefit_trigger").toggle(
		function(){ 
			// get benefit_id from rel attribute
			var benefit_id = $(this).attr("rel");
			$("#benefit_" + benefit_id).show(); 
			return false;
		},
		function(){ 
			// get benefit_id from rel attribute
			var benefit_id = $(this).attr("rel");
			$("#benefit_" + benefit_id).hide(); 
			return false;
		}
	);
 
}); 
