	/*Preloader*/
	jQuery.preloadImages = function()
	{
	  for(var i = 0; i<arguments.length; i++)
	  {
	    jQuery("<img>").attr("src", arguments[i]);
	  }
	}
	
	/*AJAX ON/OFF*/
	var ajaxOn=false;
	
	/*ANIMATION SPEED AND HEIGHT*/
	var speed=300;
	var animationHeight=40;
	var defaultHeight=40;
	// has slided?
	
	//animation ended?
	var ended=true;
	
	function getAnimationHeight(){
		var wheight=$(window).height();
		var animate=(wheight-295);
		
		if(animate%2==0){
			animationHeight=animate/2;
		}
		else{
			animationHeight=(animate+1)/2;
		}
	}
	
	function getSwitcherOverlayHeight(){
		var wheight=$(window).height();
		var height=(wheight-80);
		
		return height;
	}
	
	/*OVERLAY*/
	
	function showOverlay(){
		$("#overlay").fadeIn(speed);
	}
	
	function hideOverlay(sp){
		sp = typeof(sp) != 'undefined' ? sp : speed;
		$("#overlay").fadeOut(sp);
	}
	
	/*OVERLAY : END*/
	
	/*FUNCTIONS*/
	
	/*remove elements bg*/
	
	function remBgImg(el){
		$(el).css({
			
			"background-image":"none"	
			
		});
	}
	
	function setBgImg(el,src){
		
		$(el).css({
		    		
		    		"background-image":"url("+src+")"
		    	
		 });
	
	}
	
	/*SWITCH TO AJAX*/
	
	function switchAjaxOnOff(){
		if(ajaxOn==false){
			ajaxOn=true;
			
			addEventsToLinks();
			
			$("#ajaxOnOff").html("ON");
			$(".switchToAjaxOverlay").show();
			setTimeout("fadeOutObj($('.switchToAjaxOverlay'))",800);
		}
		else{
			ajaxOn=false;
			
			$("a").unbind("click",updateContent);
			
			$("#ajaxOnOff").html("OFF");
			$(".switchToAjaxOverlay").show();
			setTimeout("fadeOutObj($('.switchToAjaxOverlay'))",800);
		}
	}
	
	/*fade out element : for fadeOut delay*/
	
	function fadeOutObj(obj){
		obj.fadeOut(speed);
	}
	
	/*PAGE CONTENT UPDATE FUNCTIONS*/
	
	function updateContent(){
		
		var linkClass=$(this).attr("class");
		
		//links from main menu
		if(linkClass.indexOf("menu")>-1){
			getContent($(this).attr("href"),$(this).attr("id"),'content');
			if(linkClass.indexOf("navigation")==-1){
				hoverMainMenuItem($(this));
			}
		}
		if(linkClass.indexOf("sub")>-1){
			
			getContent($(this).attr("href"),$(this).attr("id"),'innerContent');
			
			if(linkClass.indexOf("navigation")>-1){	
				hoverSubMenuItem($(this));
			}
			else{
				hoverSubMenuItem($(this));
			}
		}
		
		return false;
	}
	
	function hoverSubMenuItem(obj){
		$(".sub").removeClass("underlineBold");
		$(obj).addClass("underlineBold");
	}
	
	function hoverMainMenuItem(obj){
		$(".menu").removeClass("mainMenuSelected");
		$(".menu").removeClass("roundedLeftSelected");
		
		if($(obj).hasClass("first")){
			$(obj).addClass("roundedLeftSelected");
		}
		else{
			$(obj).addClass("mainMenuSelected");
		}
	}
	
	function getContent(url,id,place){
		$.post("/API/api.php",{url:url,id:id},function(data){
			
			setContent(data,place);
		
		});
	}
	
	function setContent(data,place){
		
		data=data.split(":seperator:");
		
		$("#naviURLs").html(data[0]);
		$("#"+place).html(data[1]);
		addEventsToLinks();
	}
	
	function addEventsToLinks(){
		$("a").click(updateContent);
	}
	
	/*ANIMATE SLIDEING EFFECT FOR TOP AND BOTTOM*/
	
	
	//animate in
	function animIN(){
		
		//remove top slider bg img
		remBgImg($("#topMenu"));
		//remove bottom slider bg img
		remBgImg($("#footer"));
		
		//hide top menu
		$("#topMenuTable").fadeOut(speed);
		$("#sitesMenu").hide();
		//top slider and top shadow animation
		
		
		$("#topMenu").animate({"height": animationHeight, "opacity": 1}, speed);
		    
		$("#shadowTop").animate({"top": animationHeight, "opacity": 1}, speed);  
		
		
		//bottom slider and bottom shadow animation    
		$("#footer").animate({"height": animationHeight, "opacity": 1}, speed);
		
		$("#shadowBottom").animate({"bottom": animationHeight, "opacity": 1}, speed,function(){
		 
		 
				 //add top slider bg img		    	
				 setBgImg($("#topMenu"),"/css/main/img/top_shadow.jpg");
				 //add bottom slider bg img
				 setBgImg($("#footer"),"/css/main/img/bottom_shadow.jpg");
				 
				 //set height of top menu table
				 $("#topMenuTable").css({"height":animationHeight});
				 //show top menu   	
				 $("#logo").hide();
				$("#oxologo").show();
		
				 $("#topMenuTable").fadeIn(speed);
				 
				 //show intro img
			    	$("#img").fadeIn(speed,function(){
			    		
			    		//hide overlay
			    		hideOverlay();
			   		ended=true;
			   		
			   	});
		   
		});  
	}
	
	//animate out
	function animOUT(){
		
		//hide top menu
		$("#topMenuTable").fadeOut(speed);
		
		//hide intro img
		$("#img").fadeOut(speed,function(){
		
			//slide out top slider and shadow
			$("#topMenu").animate({"height": defaultHeight, "opacity": 1}, speed);
			$("#shadowTop").animate({"top": defaultHeight, "opacity": 1}, speed);  
			
			//slide out bottom slider and shadow
			$("#footer").animate({"height": defaultHeight, "opacity": 1}, speed);
			$("#shadowBottom").animate({"bottom": defaultHeight, "opacity": 1}, speed,function(){
			    	
			    	//set body bg img
			    	//setBgImg($("body"),bgImg)
			    	
			    	//show content
			    	$("#mainWrap").fadeIn(speed);
				
				//set height for top menu table
			    	$("#topMenuTable").css({"height":defaultHeight+"px"});
			    	
			    	$("#oxologo").hide();
				$("#logo").show();
			    	
			    	//show top menu
			    	$("#topMenuTable").fadeIn(speed,function(){
			    		
			    		ended=true;
			    		$("#sitesMenu").show();
			    	
			    	});
			}); 
			
		    });
	}
	
	//slide out trigger
	function slideOUT(){
		animOUT();
		
	}
	
	//slide in trigger
	function slideIN(){
			//hide page content
			$("#mainWrap").fadeOut(speed,function(){
				//remove bg img for body
				//remBgImg($("body"));
				//start slide in animation
				animIN();
				
			});
	}
	
	//start sliding
	function startInOut(){
		//set animation height
		getAnimationHeight();
		
		if(ended==true){
			if(slided==false){
				slideIN();
				slided=true;
				$("#siteSwitch").hide();
				$("#backBullet").hide();
				$("#nextBullet").hide();
				$(".switcherOverlay").hide();
				$(document).unbind('keydown', 'return', function (evt){showSwitcher(true)});
				ended=false;
			}
			else{
				ended=false;
				slideOUT();
				$("#backBullet").show();
				$("#nextBullet").show();
				slided=false;
			}
		}
	}
	
	
	/*SWITCHER*/

	function showSwitcher(go){
		
		if(slided==false){
		go = typeof(go) != 'undefined' ? go : false;
	
		if($(".switcherOverlay").is(':hidden')){
			$(".switcherOverlay").show();
			$(".switcher").removeClass("selSwitcher");
			$("#switcher_1").addClass("selSwitcher");
			$(document).bind('keydown', 'return', function (evt){showSwitcher(true)});
			switcherMouseOver();
		}
		else{
			$(".switcherOverlay").hide();
			$(document).unbind('keydown', 'return', function (evt){showSwitcher(true)});
			if(1==1){
			
				var current=$(".selSwitcher").attr("id");
				var id=current.split("_");
				id=id[1];
				
				if(go){
					window.location='/brand';
				}
				if(id=='2'){
					window.location='/digital';
				}
				if(id=='3'){
					window.location='/media';
				}
			}
		}
		}
	}
	
	function switcherMouseOver(){
		$(".switcher").mouseover(function(){
			$(".switcher").removeClass("selSwitcher");
			$(this).addClass("selSwitcher");
		});
		
		$(document).bind('keydown', 'right', function (evt){toRight()});
		$(document).bind('keydown', 'left', function (evt){toLeft()});
		
		$(".switcher").click(function(){
			$(".switcherOverlay").hide();
			$(document).unbind('keydown', 'return', function (evt){showSwitcher(true)});
			
				var current=$(".selSwitcher").attr("id");
				var id=current.split("_");
				id=id[1];
				
				if(id=='1'){
					window.location='/brand';
				}
				if(id=='2'){
					window.location='/digital';
				}
				if(id=='3'){
					window.location='/media';
				}
		});
	}
	
	function toRight(){
		var current=$(".selSwitcher").attr("id");
		
		current=current.split("_");
		var next=parseInt(current[1])+1;
		if(next>3){
			next=1;
		}
		$(".switcher").removeClass("selSwitcher");
		$("#switcher_"+next).addClass("selSwitcher");
	}
	
	function toLeft(){
		var current=$(".selSwitcher").attr("id");
		current=current.split("_");
		var prev=parseInt(current[1])-1;
		if(prev<1){
			prev=3;
		}
		$(".switcher").removeClass("selSwitcher");
		$("#switcher_"+prev).addClass("selSwitcher");
	}
	
	
	/*CHANGE LNG*/
	
	function chLng(lng){
		$("#lng").val(lng);
		document.changeLng.submit();
	}