$(document).ready(function(){

	$("#feature .featureImage").hide();
	$("#feature .pics").show();

var t = setTimeout;

function goCycle(myNum) {
	$('#feature .pics').cycle({ 
	    fx: 'fade',  
 	    before: showInfo, 
	    timeout: 5000, 
	    delay: 2000, 
	    startingSlide: myNum
	    
	});
	clearTimeout(t);
}


function showInfo() {
	if (this.alt == "security") {
		switchInfo(1);
	} else if (this.alt == "research") {
		switchInfo(2);
	} else if (this.alt == "commercial") {
		switchInfo(3);
	}
}

function switchInfo(n) {
	$("#feature .col1 .panel, #feature .col2 .panel, #feature .col3 .panel").fadeOut("fast");
	$("#feature .col1 h2, #feature .col2 h2, #feature .col3 h2").removeClass();
	$("#feature .col"+n+" h2").addClass("active");
	$("#feature .col"+n+" .panel").fadeIn("slow");
}


$("#feature .col1").hover(
	function () {
		$('#feature .pics').cycle({ 
		    timeout: 0, 
		    startingSlide: 0
		});
		switchInfo(1);
		clearTimeout(t);
	},
	function () {
		t = setTimeout(function() {
			goCycle(1)
		}, 2000); 
	}
);
$("#feature .col2").hover(
	function () {
		$('#feature .pics').cycle({   
		    timeout: 0, 
		    startingSlide: 1  
		});
		switchInfo(2);
		clearTimeout(t);
	},
	function () {
		t = setTimeout(function() {
			goCycle(2)
		}, 2000);   
	}
);
$("#feature .col3").hover(
	function () {
		$('#feature .pics').cycle({  
		    timeout: 0, 
		    startingSlide: 2  
		});
		switchInfo(3);
		clearTimeout(t);
	},
	function () {
		t = setTimeout(function() {
			goCycle(0)
		}, 2000); 
	}
);


goCycle();

if ($("#contact_form").length > 0) {
        $("#contact_form").validate();
}


$('.partnersList .details .head').click(function() {
	$(this).next().toggle('slow');
        $(this).text($(this).text() == 'More details' ? 'Hide details' : 'More details');
	return false;
}).next().hide();

$('.products ul.detailsList li .head').click(function() {
	$(this).next().toggle('slow');
        $(this).text($(this).text() == 'View all' ? 'Hide all' : 'View all');
	return false;
}).next().hide();

});
