$(document).ready(function(){

	hide_all = function(){
		$("#home_black,#rub_al_khali_black,.arabic-coming-soon,#black .close").hide();
		$("#black .close").animate({marginTop:'600px'},1);
	}
	close_fast = function(){
		hide_all();
		$("#black").animate({height:'0'}, 300); 
	}
	close_slow = function(){
		hide_all();
		$("#black").animate({height:'0'}, 800); 
	}
	home_open = function(){
		hide_all();		
		$("#black").animate({height:'425px'}, 1000); 
		$("#home_black").delay(1000).fadeIn("slow"); 
		$("#black .close").delay(800).show().animate({marginTop:'-32px'},1000);
	}
	arabic_open = function(){
		hide_all();
		$("#black").animate({height:'425px'}, 1000); 
		$(".arabic-coming-soon").delay(1000).fadeIn("slow"); 
		$("#black .close").delay(800).show().animate({marginTop:'-32px'},1000);
	}
	rak_open = function(){
		hide_all();
		$("#black").animate({height:'425px'}, 1000); 
		$("#rub_al_khali_black").delay(1000).fadeIn("slow"); 
		$("#black .close").delay(800).show().animate({marginTop:'-32px'},1000);
	}

	$("ul.topnav li a").mouseover(function() { 
		$(this).parent().find("ul.subnav").stop('true', 'true').slideDown('fast').show(); 
		$(this).parent().hover(function() {
		}, function(){
			$(this).parent().find("ul.subnav").slideUp('slow');
			$(this).removeClass("subhover");
		});
	}).hover(function() {
		$(this).parent().addClass("subhover");
	});
	
	
	$(".arabic a").click(function() {arabic_open(); });
	$("#logo a,.creative-agency a").click(function(){ home_open(); });
	$("#nav a, #top a").click(function(){ close_fast(); });	
	$("#black .close").click(function(){ close_slow(); });
	
	$("#header #logo a").mouseover(function(){
		$(".back-home").animate({marginLeft:'160px'},{queue:false,duration:400})	
	});
	$("#header #logo a").mouseout(function(){
		$(".back-home").animate({marginLeft:'70px'},{queue:false,duration:300})	
	});
	
	$(".back-to-creative-approach a").click(function() { 
		$('html, body').animate({scrollTop: '170px'}, 600); return false;
	});
	
	var elem = location.href.split('#');
	if (elem[1] == 'home') { home_open(); }
	if (elem[1] == 'arabic') { arabic_open(); }
	if (elem[1] == 'rub_al_khali') { rak_open(); }
	if (elem[1] == 'list') { 
		$('html, body').animate({scrollTop: '780px'}, 400); return false;
	}
	
});

//if (elem.length > 1) {$('.'+elem[1]+'-black').show();}
// http://www.noupe.com/tutorial/drop-down-menu-jquery-css.html





