stuHover = function() {
	var cssRule;
	var newSelector;
	for (var i = 0; i < document.styleSheets.length; i++)
		for (var x = 0; x < document.styleSheets[i].rules.length ; x++)
			{
			cssRule = document.styleSheets[i].rules[x];
			if (cssRule.selectorText.indexOf("LI:hover") != -1)
			{
				 newSelector = cssRule.selectorText.replace(/LI:hover/gi, "LI.iehover");
				document.styleSheets[i].addRule(newSelector , cssRule.style.cssText);
			}
		}
	var getElm = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<getElm.length; i++) {
		getElm[i].onmouseover=function() {
			this.className+=" iehover";
		}
		getElm[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" iehover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", stuHover);

jQuery = jQuery.noConflict();
	jQuery(document).ready(function(){
		jQuery("#7").css("border-right", 'none');
		jQuery("#7").css("width", '162px');
		jQuery("#7 a").css("padding-right", '62px');
		jQuery(".child4 a").css("padding-right", '10px');
		jQuery("#2 a").css("background-position", "110px 15px");
		jQuery("#3 a").css("background-position", "122px 15px");
		jQuery("#4 a").css("background-position", "150px 15px");
		jQuery("#7 a").css("background-position", "110px 15px");
		jQuery("#1 a").css("background-image", "none");
		jQuery("#5 a").css("background-image", "none");
		jQuery("#6 a").css("background-image", "none");
		//jQuery("#7 a").css("background-image", "none");
			
		jQuery("#2 a").mouseover(function()
		{
			if(jQuery("#ch1").css("display")!='block')
				{
					jQuery("#ch1").css("display","block"); 
				}
				jQuery("#ch4").css("display","none"); 
				jQuery("#ch2").css("display","none"); 
				jQuery("#ch3").css("display","none")
		});
		
		jQuery("#ch1").mouseover(function()
		{
			if(jQuery("#ch1").css("display")!='block')
				{
					jQuery("#ch1").css("display","block"); 
				}	
				jQuery("#ch4").css("display","none"); 
				jQuery("#ch2").css("display","none"); 
				jQuery("#ch3").css("display","none")
		});
		
		/*jQuery("#ch1").mouseout(function()
										 {
											 jQuery("#ch1").css("display","none");
										});*/
		jQuery("#2 a").mouseout(function()
										 {
											 jQuery("#ch1").css("display","none")
										});
		
		jQuery("#3 a").mouseover(function(){jQuery("#ch2").css("display","block"); jQuery("#ch4").css("display","none"); jQuery("#ch1").css("display","none"); jQuery("#ch3").css("display","none")});
		jQuery("#ch2").mouseover(function(){jQuery("#ch2").css("display","block"); jQuery("#ch4").css("display","none"); jQuery("#ch1").css("display","none"); jQuery("#ch3").css("display","none")});
		/*jQuery("#ch2").mouseout(function(){jQuery("#ch2").css("display","none")});*/
		jQuery("#3 a").mouseout(function(){jQuery("#ch2").css("display","none")});
		
		jQuery("#4 a").mouseover(function(){jQuery("#ch3").css("display","block"); jQuery("#ch4").css("display","none"); jQuery("#ch2").css("display","none"); jQuery("#ch1").css("display","none")});
		jQuery("#ch3").mouseover(function(){jQuery("#ch3").css("display","block"); jQuery("#ch4").css("display","none"); jQuery("#ch2").css("display","none"); jQuery("#ch1").css("display","none")});
		/*jQuery("#ch3").mouseout(function(){jQuery("#ch3").css("display","none")});*/
		jQuery("#4 a").mouseout(function(){jQuery("#ch3").css("display","none")});
		
		jQuery("#7 a").mouseover(function(){jQuery("#ch4").css("display","block"); jQuery("#ch3").css("display","none"); jQuery("#ch2").css("display","none"); jQuery("#ch1").css("display","none")});
		jQuery("#ch4").mouseover(function(){jQuery("#ch4").css("display","block"); jQuery("#ch3").css("display","none"); jQuery("#ch2").css("display","none"); jQuery("#ch1").css("display","none")});
		/*jQuery("#ch4").mouseout(function(){jQuery("#ch4").css("display","none")});*/
		jQuery("#7 a").mouseout(function(){jQuery("#ch4").css("display","none")});
	});

function theRotator() {
	//Set the opacity of all images to 0
	jQuery('div#client ul li').css({opacity: 0.0});
	
	//Get the first image and display it (gets set to full opacity)
	jQuery('div#client 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()',6000);
	
}

function rotate() {	
	//Get the first image
	var current = (jQuery('div#client ul li.show')?  jQuery('div#client ul li.show') : jQuery('div#client 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')) ? jQuery('div#client ul li:first') :current.next()) : jQuery('div#client 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');
	
};

jQuery(document).ready(function() {		
	//Load the slideshow
	theRotator();
});
