$(document).ready(function(){

	var hoverstate = '';

	$('#sectorhome, #sectorhome ul').css('opacity','0');
	$('#sectorhome2, #sectorhome2 ul').css('opacity','0');
	$('#sectorhome3, #sectorhome3 ul').css('opacity','0');
	$('#copy').css('z-index','5');

	$("#systems").mouseover(function(e) {
	    if (hoverstate == 'support') {
			$('#copy').hoverFlow(e.type, { opacity: 0 } , 0);
			$('#copy').css('z-index','-10');
		}
		else {
			$('#copy #banner').hoverFlow(e.type, { opacity: 0 } , 100);
			$('#copy').hoverFlow(e.type, { opacity: 0 } , 250);
		}
		hoverstate = 'systems';
		$('#sectorhome').hoverFlow(e.type, { opacity: 1 } , 250);
		$('#sectorhome ul').hoverFlow(e.type, { opacity: 1 } , 250);
	});
	$("#systems").mouseout(function(e) {
		$('#copy').hoverFlow(e.type, { opacity: 1 } , 250);
		$('#copy #banner').hoverFlow(e.type, { opacity: 1 } , 250);
		$('#copy').css('z-index','10');
		$('#sectorhome').hoverFlow(e.type, { opacity: 0 } , 250);
		$('#sectorhome ul').hoverFlow(e.type, { opacity: 0 } , 250);
	});
	
	$("#support").mouseover(function(e) {
		if (hoverstate == 'systems' || hoverstate == 'software' ) {
			$('#copy').hoverFlow(e.type, { opacity: 0 } , 0);
			$('#copy').css('z-index','-10');
		}
		else {
			$('#copy #banner').hoverFlow(e.type, { opacity: 0 } , 100);
			$('#copy').hoverFlow(e.type, { opacity: 0 } , 250);
		}
		hoverstate = 'support';
		$('#sectorhome2').hoverFlow(e.type, { opacity: 1 } , 250);
		$('#sectorhome2 ul').hoverFlow(e.type, { opacity: 1 } , 250);
	});
	$("#support").mouseout(function(e){
		$('#copy').hoverFlow(e.type, { opacity: 1 } , 250);
		$('#copy #banner').hoverFlow(e.type, { opacity: 1 } , 250);
		$('#copy').css('z-index','10');
		$('#sectorhome2').hoverFlow(e.type, { opacity: 0 } , 250);
		$('#sectorhome2 ul').hoverFlow(e.type, { opacity: 0 } , 250);
	});
	
	$("#software").mouseover(function(e) {
	    if (hoverstate == 'support') {
			$('#copy').hoverFlow(e.type, { opacity: 0 } , 0);
			$('#copy').css('z-index','-10');
		}
		else {
			$('#copy #banner').hoverFlow(e.type, { opacity: 0 } , 100);
			$('#copy').hoverFlow(e.type, { opacity: 0 } , 250);
		}
		hoverstate = 'software';
		$('#sectorhome3').hoverFlow(e.type, { opacity: 1 } , 250);
		$('#sectorhome3 ul').hoverFlow(e.type, { opacity: 1 } , 250);
	});
	$("#software").mouseout(function(e) {
		$('#copy').hoverFlow(e.type, { opacity: 1 } , 250);
		$('#copy #banner').hoverFlow(e.type, { opacity: 1 } , 250);
		$('#copy').css('z-index','10');
		$('#sectorhome3').hoverFlow(e.type, { opacity: 0 } , 250);
		$('#sectorhome3 ul').hoverFlow(e.type, { opacity: 0 } , 250);
	});
	

	
	$("#systemspage").click(function() {
		$('#content').load('/systems/ #copy');
		$('#copy').css('display','none');
		$('#sectorhome, #sectorhome ul').css('opacity','1');
		$('#sectorhome2, #sectorhome2 ul').css('opacity','0');
		$('#sectorhome3, #sectorhome3 ul').css('opacity','0');
		$('#logo h1 a').css('background','url(/images/layout/lineal-systems.png)');
		$('#logo ul li').css('background','url(/images/layout/logobul-purple.gif) right center no-repeat');
		$('#logo ul li#logonav03').css('background','none');
		$('#logo ul li#logonav01 a').css('color','#6d4c84');
		$('#logo ul li#logonav02 a').css('color','#88959d');
		$('#logo ul li#logonav03 a').css('color','#88959d');
		$('#logo ul li#logonav01 a').hover(
		function(){
			$(this).css('color','#9a84a9');
		}, function(){
			$(this).css('color','#6d4c84');
		});
		$('#logo ul li#logonav02 a').hover(
		function(){
			$(this).css('color','#64a3ce');
		}, function(){
			$(this).css('color','#88959d');
		});
		$('#logo ul li#logonav03 a').hover(
		function(){
			$(this).css('color','#e18067');
		}, function(){
			$(this).css('color','#88959d');
		});
		$('#top-bar').css('background','#6d4c84');
		$('#top-nav a').hover(
		function(){
			$(this).css('background-image','url(/images/layout/arrowdown-purple.png)');
		}, function(){
			$(this).css('background-image','none');
		});
		$('#left-nav li#leftnavsmall03 a#softwarepage').css('background-image','url(/images/layout/nav-software.png)');
		$('#topnav02 a, #topnav03 a, #topnav04 a, #topnav05 a').css('background-image','none');

		$('#left-nav li#leftnavsmall01 a span').css('background','url(/images/layout/arrow-systems.png) right center no-repeat');
		$('#left-nav li#leftnavsmall02 a span').css('background','none');
		$('#left-nav li#leftnavsmall03 a span').css('background','none');
	});

	$("#supportpage").click(function() {
		$('#content').load('/support/ #copy');
		$('#copy').css('display','none');
		$('#sectorhome, #sectorhome ul').css('opacity','0');
		$('#sectorhome2, #sectorhome2 ul').css('opacity','1');
		$('#sectorhome3, #sectorhome3 ul').css('opacity','0');
		$('#logo h1 a').css('background','url(/images/layout/lineal-support.png)');
		$('#logo ul li').css('background','url(/images/layout/logobul-blue.gif) right center no-repeat');
		$('#logo ul li#logonav03').css('background','none');
		$('#logo ul li#logonav01 a').css('color','#88959d');
		$('#logo ul li#logonav02 a').css('color','#007db6');
		$('#logo ul li#logonav03 a').css('color','#88959d');
		$('#logo ul li#logonav01 a').hover(
		function(){
			$(this).css('color','#9a84a9');
		}, function(){
			$(this).css('color','#88959d');
		});
		$('#logo ul li#logonav02 a').hover(
		function(){
			$(this).css('color','#64a3ce');
		}, function(){
			$(this).css('color','#007db6');
		});
		$('#logo ul li#logonav03 a').hover(
		function(){
			$(this).css('color','#e18067');
		}, function(){
			$(this).css('color','#88959d');
		});
		$('#top-bar').css('background','#007db6');
		$('#top-nav a').hover(
		function(){
			$(this).css('background-image','url(/images/layout/arrowdown-blue.png)');
		}, function(){
			$(this).css('background-image','none');
		});
		$('#left-nav li#leftnavsmall03 a#softwarepage').css('background-image','url(/images/layout/nav-software.png)');
		$('#topnav02 a, #topnav03 a, #topnav04 a, #topnav05 a').css('background-image','none');
		
		$('#left-nav li#leftnavsmall01 a span').css('background','none');
		$('#left-nav li#leftnavsmall02 a span').css('background','url(/images/layout/arrow-support.png) right center no-repeat');
		$('#left-nav li#leftnavsmall03 a span').css('background','none');
	});

	$("#softwarepage").click(function() {
		$('#content').load('/software/ #copy');
		$('#copy').css('display','none');
		$('#sectorhome, #sectorhome ul').css('opacity','0');
		$('#sectorhome2, #sectorhome2 ul').css('opacity','0');
		$('#sectorhome3, #sectorhome3 ul').css('opacity','1');
		$('#logo h1 a').css('background','url(/images/layout/lineal-software.png)');
		$('#logo ul li').css('background','url(/images/layout/logobul-red.gif) right center no-repeat');
		$('#logo ul li#logonav03').css('background','none');
		$('#logo ul li#logonav01 a').css('color','#88959d');
		$('#logo ul li#logonav02 a').css('color','#88959d');
		$('#logo ul li#logonav03 a').css('color','#d2232a');
		$('#logo ul li#logonav01 a').hover(
		function(){
			$(this).css('color','#9a84a9');
		}, function(){
			$(this).css('color','#88959d');
		});
		$('#logo ul li#logonav02 a').hover(
		function(){
			$(this).css('color','#64a3ce');
		}, function(){
			$(this).css('color','#88959d');
		});
		$('#logo ul li#logonav03 a').hover(
		function(){
			$(this).css('color','#e18067');
		}, function(){
			$(this).css('color','#d2232a');
		});
		$('#top-bar').css('background','#d2232a');
		$('#top-nav a').hover(
		function(){
			$(this).css('background-image','url(/images/layout/arrowdown-red.png)');
		}, function(){
			$(this).css('background-image','none');
		});
		$('#left-nav li#leftnavsmall03 a#softwarepage').css('background-image','url(/images/layout/nav-software2.png)');
		$('#topnav02 a, #topnav03 a, #topnav04 a, #topnav05 a').css('background-image','none');
		
		$('#left-nav li#leftnavsmall01 a span').css('background','none');
		$('#left-nav li#leftnavsmall02 a span').css('background','none');
		$('#left-nav li#leftnavsmall03 a span').css('background','url(/images/layout/arrow-software.png) right center no-repeat');
	});


	$('#usp').innerfade( {
		animationtype: 'fade',
		speed: 750,
		timeout: 5000,
		type: 'random'
	});
});
