$(function() {
		   
var clicked = 0;

function moveUp1(){  $("#title1").animate({top: '0px'},300); }
function moveUp2(){  $("#title2").animate({top: '0px'},300); }
function moveUp3(){  $("#title3").animate({top: '0px'},300); }
function moveUp4(){  $("#title4").animate({top: '0px'},300); }
function moveUp5(){  $("#title5").animate({top: '0px'},300); }


		   
var cn1 = $('#tab1').attr('class');
var cn2 = $('#tab2').attr('class');
var cn3 = $('#tab3').attr('class');
var cn4 = $('#tab4').attr('class');
var cn5 = $('#tab5').attr('class');

function rollover1(){
	              $("#tab1").removeClass(cn1);
				  $("#tab1").addClass('menuItm1sel');
				  }
					
function rollout1(){
	
	              if(clicked == 1) return;
	              $("#tab1").removeClass('menuItm1sel');
				  $("#tab1").addClass(cn1);
				}


function rollover2(){
	              $("#tab2").removeClass(cn2);
				  $("#tab2").addClass('menuItm1sel');
				  }
					
function rollout2(){
	
	              if(clicked == 2) return;
	              $("#tab2").removeClass('menuItm1sel');
				  $("#tab2").addClass(cn2);
				}


function rollover3(){
	              $("#tab3").removeClass(cn3);
				  $("#tab3").addClass('menuItm2sel');
				  }
					
function rollout3(){
	
	              if(clicked == 3) return;
	              $("#tab3").removeClass('menuItm2sel');
				  $("#tab3").addClass(cn3);
				}




function rollover4(){
	
	              $("#tab4").removeClass(cn4);
				  $("#tab4").addClass('menuItm1sel');
				  }
					
function rollout4(){
	
	              if(clicked == 4) return;
	              $("#tab4").removeClass('menuItm1sel');
				  $("#tab4").addClass(cn4);
				}


function rollover5(){
	              $("#tab5").removeClass(cn5);
				  $("#tab5").addClass('menuItm1sel');
				  }
					
function rollout5(){
	
	              if(clicked == 5) return;
	              $("#tab5").removeClass('menuItm1sel');
				  $("#tab5").addClass(cn5);
				}



$("#t1").hover(function(e) { 
						  rollover1(); 
						  
						   }, function (e) {  
						   rollout1();
						   
						   });




$("#txtmenu1").hover(function(e) { 
							  
							  rollover1();
							  
							  }, function (e) {
							  
							  rollout1();
							  
							  });



$("#t2").hover(function(e) { 
						    
							rollover2();
							
							}, function (e) {
							
							rollout2();
							
							});

$("#txtmenu2").hover(function(e) { 
							  
							rollover2(); }, function (e) {  rollout2(); });


$("#t3").hover(function(e) { rollover3(); }, function (e) {  rollout3(); });
$("#txtmenu3").hover(function(e) { rollover3(); }, function (e) {  rollout3(); });

/*
$("#t4").hover(function(e) { rollover4(); }, function (e) {  rollout4(); });
$("#txtmenu4").hover(function(e) { rollover4(); }, function (e) {  rollout4(); });
*/
$("#t5").hover(function(e) { rollover5(); }, function (e) {  rollout5(); });
$("#txtmenu5").hover(function(e) { rollover5(); }, function (e) {  rollout5(); });



$("#t1").click(function(e) {  goto(1); });
$("#t2").click(function(e) {  goto(2); });
$("#t3").click(function(e) {  goto(3); });
//$("#t4").click(function(e) {  goto(4); });
$("#t5").click(function(e) {  goto(5); });

$("#txtmenu1").click(function(e) {  goto(1); });
$("#txtmenu2").click(function(e) {  goto(2); });
$("#txtmenu3").click(function(e) {  goto(3); });
$("#txtmenu4").click(function(e) {  goto(4); });
$("#txtmenu5").click(function(e) {  goto(5); });




function goto(id){
	clicked = id;
    $("#t1").css({'z-index' : '1'});
	$("#t2").css({'z-index' : '1'});
	$("#t3").css({'z-index' : '1'});
	$("#t4").css({'z-index' : '1'});
	$("#t5").css({'z-index' : '1'});

    $("#t"+id).css({'z-index' : '2'});


     $("#t1").animate({'margin-left': '0px'},500);
	 $("#t2").animate({'margin-left': '0px'},500);
	 $("#t3").animate({'margin-left': '0px'},500);
	 $("#t4").animate({'margin-left': '0px'},500);
	 $("#t5").animate({'margin-left': '0px'},500);
	 
	
	   setTimeout(
	  function() 
	  {
		// $("#title"+id).animate({top: '0px'},300);
		 redirect(id);
		  }, 300);
	 
	  
	 
}

links = ["index.php","showcase.php","who_we_are.php","what_we_do.php","blog.php","contact_us.php"];
function redirect(id){
 setTimeout(
	  function() 
	  {
		window.location=links[id];
		  }, 500);
	
}

function align(){
	 $("#t1").animate({'margin-left': '0px'},500);
	 $("#t2").animate({'margin-left': '177px'},500);
	 $("#t3").animate({'margin-left': '353px'},500);
	 $("#t4").animate({'margin-left': '529px'},500);
	 $("#t5").animate({'margin-left': '704px'},500);
	
}





align();



});

