$(function(){
	$('#search').bind('keypress',function(e){
		if((e.keyCode || e.which) == 13)
		{
			var q = $("#search").val();
			document.location = 'index.php?a=search&search=' + q;
		}
	});
	
    $("#home").click(
      function (e) {
          window.clearTimeout(cid);
          $("#provenresults_title").css('display', 'none');
          $("#newsevents_title").css('display', 'none');
          $("#lossprevention_title").css('display', 'none');
          $("#trustedsolutions_title").css('display', 'none');
          $("#home_title").css('display', 'block');
          setDefault();
          $("#home").parent().css('background-color','#528111');
          $("#home").children().css('background-color','#528111');
          //$('#trustedsolutions_title').fadeIn('fast');
      }
    );
    
	$("#trustedsolutions").click(
	  function (e) {
        window.clearTimeout(cid);
	  	$("#provenresults_title").css('display', 'none');
	  	$("#newsevents_title").css('display', 'none');
	  	$("#lossprevention_title").css('display', 'none');
	  	$("#home_title").css('display', 'none');
	  	$("#trustedsolutions_title").css('display', 'block');
        setDefault();
          $("#trustedsolutions").parent().css('background-color','#528111');
          $("#trustedsolutions").children().css('background-color','#528111');
	  	//$('#trustedsolutions_title').fadeIn('fast');
	  }
	);
	
	$("#provenresults").click(
	  function (e) {
      window.clearTimeout(cid);
	  	$("#newsevents_title").css('display', 'none');
	  	$("#lossprevention_title").css('display', 'none');
	  	$('#trustedsolutions_title').css('display', 'none');
	  	$("#home_title").css('display', 'none');
	  	$("#provenresults_title").css('display', 'block');
        setDefault();
        $("#provenresults").parent().css('background-color','#528111');
        $("#provenresults").children().css('background-color','#528111');
        //$("#provenresults_title").fadeIn('fast');
	  }
	);
	
	$("#newsevents").click(
	  function (e) {
      window.clearTimeout(cid);
	  	$("#provenresults_title").css('display', 'none');
	  	$("#lossprevention_title").css('display', 'none');
	  	$('#trustedsolutions_title').css('display', 'none');
	  	$("#home_title").css('display', 'none');
	  	$("#newsevents_title").css('display', 'block');
        setDefault();
        $("#newsevents").parent().css('background-color','#528111');
        $("#newsevents").children().css('background-color','#528111');
	  	//$("#newsevents_title").fadeIn('fast');
	  }
	);
	
	$("#lossprevention").click(
	  function (e) {
      window.clearTimeout(cid);
	  	$("#provenresults_title").css('display', 'none');
	  	$("#newsevents_title").css('display', 'none');
	  	$('#trustedsolutions_title').css('display', 'none');
	  	$("#home_title").css('display', 'none');
	  	$("#lossprevention_title").css('display', 'block');
        setDefault();
        $("#lossprevention").parent().css('background-color','#528111');
        $("#lossprevention").children().css('background-color','#528111');
	  	//$("#lossprevention_title").fadeIn('fast');
	  }
	);
	

	
	/*var lastTItem=$('#lossprevention_title');
	
	var lastTTarget;
	
	$("#trustedsolutions").hover(
	  function (e) {
	  	lastTItem.fadeOut('slow', function() {
	    	//$("#loss-prevention").css('display', 'none');
	    	$('#trustedsolutions_title').fadeIn('slow'); 
		}); 
		lastTItem = $($(e.currentTarget).attr('id') + '_title');
		alert($(e.currentTarget).attr('id') + '_title');
	  }
	);
	
	$("#provenresults").hover(
	  function (e) {
	  	alert(lastTItem.attr('id'))
	  	lastTItem.fadeOut('slow', function() {
	    	//$("#trusted-solutions").css('display', 'none');
	    	$("#provenresults_title").fadeIn('slow'); 
		});
		lastTItem = $($(e.currentTarget).attr('id') + '_title');
	  }
	);
	
	$("#newsevents").hover(
	  function (e) {
	  	lastTItem.fadeOut('slow', function() {
	    	//$("#trusted-solutions").css('display', 'none');
	    	$("#newsevents_title").fadeIn('slow'); 
	    	
		}); 
		lastTItem = $($(e.currentTarget).attr('id') + '_title');
	  }
	);
	
	$("#lossprevention").hover(
	  function (e) {
	  	lastTItem.fadeOut('slow', function() {
	    	//$("#trusted-solutions").css('display', 'none');
	    	$('#lossprevention_title').fadeIn('slow'); 
	    	
		}); 
		lastTItem = $($(e.currentTarget).attr('id') + '_title');
	  }
	);*/
	
});

document.i;
document.cid;
i=1

function setDefault(){
$("#home").parent().css('background-color','#21437B');
$("#home").children().css('background-color','#21437B');
$("#trustedsolutions").parent().css('background-color','#21437B');
$("#trustedsolutions").children().css('background-color','#21437B');
$("#provenresults").parent().css('background-color','#21437B');
$("#provenresults").children().css('background-color','#21437B');
$("#newsevents").parent().css('background-color','#21437B');
$("#newsevents").children().css('background-color','#21437B');
$("#lossprevention").parent().css('background-color','#21437B');
$("#lossprevention").children().css('background-color','#21437B');
}

function slides(){
          $("#provenresults_title").css('display', 'none');
          $("#newsevents_title").css('display', 'none');
          $('#trustedsolutions_title').css('display', 'none');
          $("#home_title").css('display', 'none');
          $("#lossprevention_title").css('display', 'none');          

  setDefault();          
          
if(i==1){
$("#home_title").css('display', 'block');  
$("#home").parent().css('background-color','#528111');
$("#home").children().css('background-color','#528111');
}
else if(i==2){
$('#trustedsolutions_title').css('display', 'block');
$("#trustedsolutions").parent().css('background-color','#528111');
$("#trustedsolutions").children().css('background-color','#528111');
}
else if(i==3){
$("#provenresults_title").css('display', 'block');
$("#provenresults").parent().css('background-color','#528111');
$("#provenresults").children().css('background-color','#528111');
}
else if(i==4){
$("#newsevents_title").css('display', 'block');
$("#newsevents").parent().css('background-color','#528111');
$("#newsevents").children().css('background-color','#528111');
}
else if(i==5){
$("#lossprevention_title").css('display', 'block');
$("#lossprevention").parent().css('background-color','#528111');
$("#lossprevention").children().css('background-color','#528111');
}

if(i<5){
i++;
}else{
i=1;
}
cid=window.setTimeout(slides,4000); 
}
cid=window.setTimeout(slides,4000);    


