$(document).ready(function() {
	 $("ul.sf-menu").superfish({
		delay:       1000,
		animation:   {opacity:'show',height:'show'},
		speed:       'fast',
		autoArrows:  false,
		dropShadows: false        
	});
	
	//Automatically horizontally centre the menu
	var fullWidth = 0;
	$(".sf-menu > li").each(function() {
		fullWidth = fullWidth + $(this).width();
	});
	$(".sf-menu").css("padding-left",($("#mainMenu").width() - fullWidth)/2);
	
	//Homepage Feature
	if($("#homeFeature").length) { //If the homefeature exists
		//Set starting slides
		$("#serviceList li:first").addClass("current");
		$("#serviceInfo li:first").fadeIn().addClass("current");
		
		//Control which slides are visible
		$("#serviceList li").click(function() {
			if(!$(this).hasClass("current")) {
				var curr = $(this).index();
				$("#serviceList li").removeClass("current");
				$(this).addClass("current");
				$("#serviceInfo li").fadeOut().removeClass("current");
				$("#serviceInfo li:eq(" + curr + ")").fadeIn().addClass("current");
			}
		});
	}
	
	//Enable form validation if forms exist
	if($("#quickContact").length) {
		$("#quickContact").validationEngine();
	}
	if($("#freeQuote").length) {
		$("#freeQuote").validationEngine();
	}
	if($("#contactUs").length) {
		$("#contactUs").validationEngine();
	}		$('#homeFeature ul.slidey').cycle({fx:'fade',speed:'slow',timeout: 6000,prev:'#prev',next:'#next',pager:'#pager'});

});
