jQuery.fn.fadeToggle = function(speed, easing, callback) {
    return this.animate({opacity: 'toggle'}, speed, easing, callback);
};
 jQuery.fn.fadeSliderToggle = function(settings) {
 	/* Damn you jQuery opacity:'toggle' that dosen't work!~!!!*/
 	 settings = jQuery.extend({
		speed:500,
		easing : "swing"
	}, settings)
	
	caller = this
 	if($(caller).css("display") == "none"){
 		$(caller).animate({
 			opacity: 1,
 			height: 'toggle'
 		}, settings.speed, settings.easing);
	}else{
		$(caller).animate({
 			opacity: 0,
 			height: 'toggle'
 		}, settings.speed, settings.easing);
	}
}; 


function theRotator() {
	//Set the opacity of all images to 0
	$('div.rotating-images ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	$('div.rotating-images ul li:first').css({opacity: 1.0});
		
	//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
	setInterval('rotate()',4000);
	
}

function rotate() {	
	//Get the first image
	var current = ($('div.rotating-images ul li.show')?  $('div.rotating-images ul li.show') : $('div.rotating-images ul li:first'));

	//Get next image, when it reaches the end, rotate it back to the first image
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div.rotating-images ul li:first') :current.next()) : $('div.rotating-images ul li:first'));	
	
	//Set the fade in effect for the next image, the show class has higher z-index
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);

	//Hide the current image
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
	
};

$(document).ready(function(){
		theRotator();
    
	
		/*$("#sub-header li ul").hide(); // Hide all sub menus
		$("#sub-header li a.current").parent().find("ul").fadeSliderToggle("slow"); // Slide down the current menu item's sub menu
		
		$("#sub-header  li a.nav-top-item").hover( // When a top menu item is clicked...
			function () {
				$(this).parent().siblings().find("ul").slideUp("slow"); // Slide up all sub menus except the one clicked
				$(this).next().fadeSliderToggle("normal"); // Slide down the clicked sub menu
				return false;
			}
		);
		
		$("#sub-header li a.no-submenu").click( // When a menu item with no sub menu is clicked...
			function () {
				window.location.href=(this.href); // Just open the link instead of a sub menu
				return false;
			}
		); 
	
		$("#sub-header ul li a.nav-top-item").hover(
			function () {
				//$(this).stop().animate({ paddingRight: "15px" }, 200);
				if($(this).attr('class')!="current")
					$("#sub-header ul li a.current").css('color', "#C0C0C0");
			}, 
			function () {
				//$(this).stop().animate({ paddingRight: "0" });
				$("#sub-header ul li a.current").css('color', "#FF8E17");
			}
		);*/

		var current = "healthcare";
		$("div#content").css('height',$('div#content div.healthcare').height());
		$("div.divisions a").mouseover(function(){
			if(!($(this).attr('class')==current))
			{
			$("div#content div.healthcare").css('display','none');
			
			$("div#content div." + $(this).attr('class')).css('display','block');
			/*$("div#content div."+current).css('display','none');
			current = $(this).attr('class');*/
			}
		});
		$("div.divisions a").mouseout(function(){
			$("div#content div." + $(this).attr('class')).css('display','none');
			$("div#content div.healthcare").css('display','block');
		});
});
  
  
  
