$(document).ready(function(){

	// =====================================================================================
	// App wide
	// =====================================================================================
	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Rollovers
  $("a.rollover").hover(
    function() {
      curr = $(this).find("img").attr("src");
      overlen = curr.length;
      over = curr.substr(0, overlen-4);
      over = over+'_on.png';
      $(this).find("img").attr({ src: over});
    },
    function() {
      $(this).find("img").attr({ src: curr});
    }
  );
	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Rollovers - Preload images
  $("a.rollover").find("img").each(function(i){
    temp = this.src;
    prelen = temp.length;
    pre = temp.substr(0, prelen-4);
    pre = pre+'_on.png';
    preload_image_object = new Image();
    preload_image_object.src = pre;
  });


	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Navbar
	// $("div#navbar ul li ul").hide();
	$("div#navbar ul li").hoverIntent(
	  function () { 
			$(this).children('ul').css("visibility","visible");
	  	$(this).children('ul').slideDown('fast');
		}, 
	  function () {
	  	$(this).children('ul').fadeOut('fast');
	  }
	 );	


	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Accordian On Services Sidebar Nav
	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	
	$("div#sidebarServicesNav div ul.closed").hide(); // Hide sublists
	// $("div.additionalProgramInfoText:first").show();
	//
	$('div#sidebarServicesNav div h3').hover(function() {
	  $(this).addClass('hover');
	}, function() {
	  $(this).removeClass('hover');
	});
	//
	
	$("div#sidebarServicesNav div h3 a").click(function(e){
		if ($(this).parents('div').hasClass('expandable')) {			
			e.preventDefault();
		}
	});
	
	$("div#sidebarServicesNav div h3").click(function(){
	  $(this).toggleClass('active');		
		if ($(this).parents('div').hasClass('expandable')) {			
			$(this).siblings("ul").slideToggle('fast');
		} else {
			var parent_id = $(this).find('a').attr('href');
			window.location = parent_id;
			
			//'/services/view/' + parent_id_array[1];
		  
			//var parent_id = $(this).parent().attr("id");
			//var parent_id_array = parent_id.split("_");
			//window.location = '/services/view/' + parent_id_array[1];
		}
	});
	

	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	// Home Slideshow
	$('div#slideshowPics').cycle({ 
	    fx: 'fade', 
		speed: 1900,     
		pause: 1
	});

	// ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
  // Accordian On Services Sidebar Nav
		//     $('#accordion').accordion({
		// 	active: 0,
		// 	autoHeight: true,
		// 	header: "h3"
		// });
 

});


