// JavaScript Document

  $(document).ready(function(){
							 
		
  		// *************************
  		// Function Change Language 	
		// *************************
		
		$("#flag_eng").click(function() {
									   
				$("#menu_pt").hide(0);		
				$("#menu_de").hide(0);		
				$("#menu_fr").hide(0);	
				$("#menu_eng").slideDown("slow");
				
 				$("#ContentLoader").load('data_hotel_en.html');	
				
				});
				
		$("#flag_pt").click(function() {
									   
				$("#menu_pt").slideDown("slow");	
				$("#menu_eng").hide(0);		
				$("#menu_fr").hide(0);	
				$("#menu_de").hide(0);
				
 				$("#ContentLoader").load('data_hotel.html');	
				
		});
		
		$("#flag_fr").click(function() {
									   
				$("#menu_pt").hide(0);		
				$("#menu_eng").hide(0);		
				$("#menu_fr").slideDown("slow");	
				$("#menu_de").hide(0);
				
 				$("#ContentLoader").load('data_hotel_fr.html');	
				
		});
		
		$("#flag_de").click(function() {
									   
				$("#menu_de").slideDown("slow");	
				$("#menu_pt").hide(0);		
				$("#menu_fr").hide(0);	
				$("#menu_eng").hide(0);	
				
 				$("#ContentLoader").load('data_hotel_de.html');	
				
		});
		
  		// *****************************************
  		// SWAP Header Image
		// *****************************************
		// Função para trocar a foto de fundo.
		// Serve para fazer um "catch" ao evento e enviar
		// os parametros para a função SwapThis, que irá então
		// proceder á troca da imagem
		
		 $("#navlist > li > a").click(function () { 
		
		 getid = $(this).attr("id");
		 geturl = $(this).attr("href");
		 
		 $(this).SwapThis(getid,geturl);
		 
		 //alert(geturl);
		 		
		});
		
  		// *************************
  		// Function Swap Header	
		// *************************
		$.fn.SwapThis = function(opt1,opt2){
		
			$("#swapheader").animate({ width: "100%",opacity: 0.8, marginLeft:"0px",  borderWidth: "0px"}, 400 );
			
			$.fn.TestFn = function(){alert("ok")};
			
			swapresult = "Imgs/header_"+opt2+".jpg";
			swapresult = swapresult.replace("#","");
	 		$("#swapheader").attr("src",swapresult);
			
			$("#swapheader").animate({ width: "100%",opacity: 0.8,  marginLeft: "0px", fontSize: "3em",  borderWidth: "0px"}, 400 );
		}
		
		 $(this).SwapThis("empty","bemvindo");
		 
		 //alert("inside");

		 
		 
  		// *****************************************
  		// SWAP BckGround Image
		// *****************************************
		 $("#navlist > li > a").click(function () { 
												
		 getid = $(this).attr("id");
		 
		getrel = $(this).attr("rel"); 

		if (!getrel) 
		geturl = $(this).attr("href"); 
		else
		geturl = $(this).attr("rel"); 
		 
		 $(this).SwapBck(getid,geturl);
		 
		 //alert(getrel);

		});
	

  		// *******************************
  		// Function Swap Background Image
		// *******************************
		
		$.fn.SwapBck = function(opt1,opt2){
		
		swapresult = "Imgs/Bck_"+opt2+".jpg";
		swapresult = swapresult.replace("#","");
		
		$("#swapimg").animate({opacity: 0.0},600, function()
		{
		$(this).attr("src",swapresult);
		});
		

		$("swapimg")
		.load(
		function(){
		$("#swapimg").animate({opacity: 0},100 );
		$("#swapimg").animate({opacity: 1},600 );
		}
		);
		
		
	 	 //$("#swapimg").attr("src",swapresult);
		 //alert(swapresult);
		
		};
		 
		 
		 
		 
  		// *****************************************
  		// SWAP BckGround Image / Chamada Genérica
		// *****************************************
		 $("#InternLink > a").click(function () {
												
		 getid = $(this).attr("id");
		 geturl = $(this).attr("href");
		 
		 alert(getid);
		 alert(geturl);
		 
		 //$(this).SwapBck(getid,geturl);
		 
		});
		 

		 
			// *****************************************
			// Content Loader
			// *****************************************
			
			$(".LinkHolder").click(function () { 
			
				
				urlSpaceName = "data_"
				urlExtension = ".html"
			  	urlgetitem   = $(this).attr("href");
				urlgetitem   = urlgetitem.replace("#","");
				UrlBuild     = urlSpaceName + urlgetitem + urlExtension
				
				//alert (UrlBuild);	
						
			 $("#ContentLoader").load(UrlBuild);
			 
			 pageTracker._trackPageview(UrlBuild);
			 
			
			});	
			
		 });
