$(document).ready(
	function() {
		$("#top_menu ul li.about_spacer").animate({width:'0px'}, 400);
		$("#top_menu ul li.about").animate({opacity: 1}, 400);
		
		$("#top_menu ul li.works_spacer").delay(300).animate({width:'0px'}, 400);
		$("#top_menu ul li.works").delay(300).animate({opacity: 1}, 400);
		
		$("#top_menu ul li.services_spacer").delay(600).animate({width:'0px'}, 400);
		$("#top_menu ul li.services").delay(600).animate({opacity: 1}, 400);
		
		$("#top_menu ul li.contact_spacer").delay(900).animate({width:'0px'}, 400);
		$("#top_menu ul li.contact").delay(900).animate({opacity: 1}, 400);
		
		$("#header .menu .main_menu ul li a").addClass("js");
		$("#header .menu .main_menu ul li a").hover(
      		function () {
        		$(this).stop(true,true).animate({backgroundPosition:"(0 0)"}, 300);
        		$(this).animate({backgroundPosition:"(0 -5px)"}, 150);
      		}, 
      		function () {
        		$(this).animate({backgroundPosition:"(0 -149px)"}, 300);
      		}
    	);
	}
);


$(
	function(){
		$("#Logo a").click(
			function(event){
				//$("#header .menu .main_menu ul li a").parent(). // <li>
				//siblings().removeClass('selected');
				$toLoad = $(this).attr('href');
				
				if($("#header").css('height') == '200px'){
					$("#header").animate({height:'395px'}, 500);
					$("#header").animate({height:'400px'}, 150);
					setTimeout(function(){window.location = $toLoad}, 700);
					event.preventDefault();
				}
			}
		);
	}
);


$(
	function(){
		$("#header .menu .main_menu ul li a").click(
			function(event){
				//$(this).parent().addClass('selected'); // <li>
				//siblings().removeClass('selected');
				// Get the url of the link
				$toLoad = $(this).attr('href');
			
				// Do some stuff
				if($("#header").css('height') == '400px'){
					$("#header").stop(true,true).animate({height:'195px'}, 400);
					$("#header").animate({height:'200px'}, 150);
					
					$("#header .banner").animate({opacity: 0}, 300);
					
					$("#top_menu ul li.about_spacer").animate({width:'5px'}, 250);
					$("#top_menu ul li.about").animate({opacity: 0}, 250);
					
					$("#top_menu ul li.works_spacer").delay(125).animate({width:'5px'}, 250);
					$("#top_menu ul li.works").delay(125).animate({opacity: 0}, 250);
					
					$("#top_menu ul li.services_spacer").delay(250).animate({width:'5px'}, 250);
					$("#top_menu ul li.services").delay(250).animate({opacity: 0}, 250);
					
					$("#top_menu ul li.contact_spacer").delay(375).animate({width:'5px'}, 250);
					$("#top_menu ul li.contact").delay(375).animate({opacity: 0}, 250);
					
					$("#footer").fadeOut("slow");
					setTimeout(function(){window.location = $toLoad}, 600);
					event.preventDefault();
				}
				
			}
		);
	}
);

$(
	function(){
		$("#top_menu .submenu ul li a").click(
			function(event){
				//$(this).parent().addClass('selected'); // <li>
				//siblings().removeClass('selected');
				// Get the url of the link
				$toLoad = $(this).attr('href');
			
				// Do some stuff
				if($("#header").css('height') == '400px'){
					$("#header").stop(true,true).animate({height:'195px'}, 400);
					$("#header").animate({height:'200px'}, 150);
					
					$("#header .banner").animate({opacity: 0}, 300);
					
					$("#top_menu ul li.about_spacer").animate({width:'5px'}, 250);
					$("#top_menu ul li.about").animate({opacity: 0}, 250);
					
					$("#top_menu ul li.works_spacer").delay(125).animate({width:'5px'}, 250);
					$("#top_menu ul li.works").delay(125).animate({opacity: 0}, 250);
					
					$("#top_menu ul li.services_spacer").delay(250).animate({width:'5px'}, 250);
					$("#top_menu ul li.services").delay(250).animate({opacity: 0}, 250);
		
					$("#top_menu ul li.contact_spacer").delay(375).animate({width:'5px'}, 250);
					$("#top_menu ul li.contact").delay(375).animate({opacity: 0}, 250);
					
					$("#footer").fadeOut("slow");
					setTimeout(function(){window.location = $toLoad}, 600);
					event.preventDefault();
				}
				
			}
		);
	}
);

