jQuery(document).ready(function() {
	mainmenu();
	jQuery('ul#nav ul').css({opacity:"0.94"});
	jQuery('ul#nav ul li a').css({opacity:"1"});
	jQuery('ul#nav ul li').css({opacity:"1"});
	jQuery('ul#nav ul a').css({opacity:"1"});
	
	jQuery(".page-item-2 a:first").attr("href", "#").addClass("nolink");
	jQuery(".page-item-3 a:first").attr("href", "#").addClass("nolink");
	jQuery(".page-item-127 a:first").attr("href", "#").addClass("nolink");
	jQuery(".page-item-123 a:first").attr("href", "#").addClass("nolink");
	
	var refreshIntervalId = setInterval("changeHomeImage()", 5000);	
	
	jQuery("div#panel").hide();
	jQuery("div.panel_button").click(function(){
		jQuery("div#panel").animate({
			height: "135px"
		})
		.animate({
			height: "115px"
		}, "fast");
		jQuery("div.panel_button").toggle();
	});	
	
   jQuery("div#hide_button").click(function(){
		jQuery("div#panel").animate({
			height: "0px"
		}, "fast");
   });
   
   jQuery("#client_form").validate();
   
   //Show Banner
	jQuery("#big div").show(); //Show Banner
	jQuery("#big div").animate({ opacity: 0.85 }, 1 ); //Set Opacity
 
	//Click and Hover events for thumbnail list
	jQuery("#side ul li:first").addClass('active'); 
	jQuery("#side ul li").click(function(){ 
		//Set Variables
		var imgAlt = jQuery(this).find('img').attr("alt"); //Get Alt Tag of Image
		var imgTitle = jQuery(this).find('a').attr("href"); //Get Main Image URL
		var imgDesc = jQuery(this).find('div').html(); 	//Get HTML of block
		var imgDescHeight = jQuery("#big").find('div').height();	//Calculate height of block	
		
		if (jQuery(this).is(".active")) {  //If it's already active, then...
			return false; // Don't click through
		} else {
			//Animate the Teaser				
			jQuery("#big div").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
				jQuery("#big div").html(imgDesc).animate({ opacity: 0.85,marginBottom: "0" }, 700 );
				jQuery("#big img").attr({ src: imgTitle , alt: imgAlt});
			});
		}
		
		jQuery("#side ul li").removeClass('active'); //Remove class of 'active' on all lists
		jQuery(this).addClass('active');  //add class of 'active' on this list only
		return false;
		
	}) .hover(function(){
		jQuery(this).addClass('hover');
		}, function() {
		jQuery(this).removeClass('hover');
	});
			
	//Toggle Teaser
	jQuery("a.collapse").click(function(){
		jQuery("#big div").slideToggle();
		jQuery("a.collapse").toggleClass("show");
	});
   

});		


function mainmenu(){
jQuery(" #nav ul ").css({display: "none"}); // Opera Fix
jQuery(" #nav li").hover(function(){
		jQuery(this).find('ul:first').css({visibility: "visible",display: "none"}).slideDown(400);
		},function(){
		jQuery(this).find('ul:first').css({visibility: "hidden"});
});

jQuery("#nav li:not(.current_page_item,.current_page_parent) ul").hover(
function(){jQuery(this).parents(".page_item").addClass("active-nav");},
function(){jQuery(this).parents(".page_item").removeClass("active-nav");}
);
}

var x = 1;

function changeHomeImage() {
if(x == 0 ) {
	x=1;
	jQuery("div", ".photoSlideshow").each(function() {if (jQuery(this).is(".bannertxt div")); else jQuery(this).hide();});
	
	jQuery('.photoSlideshow div.image1').fadeIn(1000);
} else if(x == 1) {
	x=2;
	
	jQuery('.photoSlideshow div.image2').fadeIn(1000);
	
} else if(x == 2) {
	x=3;
	
	jQuery('.photoSlideshow div.image3').fadeIn(1000);
	
} else if(x == 3) {
	x=4;
	
	jQuery('.photoSlideshow div.image4').fadeIn(1000);	
} else if(x == 4) {
	x=5;
	
	jQuery('.photoSlideshow div.image5').fadeIn(1000);	
} else if(x == 5) {
	x=6;
	
	jQuery('.photoSlideshow div.image6').fadeIn(1000);	
} else if(x == 6) {
	x=7;
	
jQuery('.photoSlideshow div.image7').fadeIn(1000);	
} else if(x == 7) {
	x=8;

jQuery('.photoSlideshow div.image8').fadeIn(1000);	
} else if(x == 8) {
	x=9;
	
jQuery('.photoSlideshow div.image9').fadeIn(1000);	
} else if(x == 9) {
	clearInterval(refreshIntervalId); return false;
} 
}
