$(document).ready(function(){
		//Preload imgs
		$.preloadCssImages();
		// Vars
		mostraimgs=1;
		lingua="pt";
		infoca="Contactos e Moradas";
		infoca2="Clique aqui para ver mais.";
		selprod="Seleccione um produto.";
		acarregar="A carregar dados..."
		tool_esconder="Mostrar/Esconder imagens";
		tool_pt="Portuguese";
		tool_en="English";
		tool_contactos="Contactos";
	    $("#web").hide();

		$('#tinfo').html(selprod);
		$("#tooltip").hide();
		$("#footer").hide();
		$("#info").hide();

		$('#telefone').fadeTo(1, 0.5);
		$('#ptflag').fadeTo(1, 0.5);
		$('#enflag').fadeTo(1, 0.5);
		$('#fecharimgs').fadeTo(1, 0.5);

		$('img.hmenu').imghover({
		suffix: 'h',
		fade: 'true',
		fadeSpeed: 500
		});
		
		// Menu Textos & Footer
		$(function() {
				
				$("#fecharimgs").click(function() {
				if (mostraimgs==1) {
				mostraimgs=0;
				$("#footer").stop(true, true).fadeOut('slow');	
				} else {
				mostraimgs=1;
				$("#footer").stop(true, true).fadeIn('slow');	
				}
				});
			
				$("#ptflag").click(function() {
				// Vars
				lingua="pt";
				infoca="Contactos e Moradas";
				infoca2="Clique aqui para ver mais.";
				selprod="Seleccione um produto.";
				acarregar="A carregar dados..."
				tool_esconder="Mostrar/Esconder imagens";
				tool_contactos="Contactos";
				$('#tinfo').html(selprod);		
				$('#info').html('<img src="images/loading.gif" width="25" height="25" /> '+acarregar);
				$.post("scripts/dados.php", { menu: menusel, lang: lingua},
   				function(data) {
				$("#info").stop(true, true).fadeOut('slow');	
				$("#info").html(data);
				$("#info").stop(true, true).fadeIn('slow');
			  	 });	
				})
				
				$("#enflag").click(function() {
				lingua="en";
				infoca="Contacts and Address's";
				infoca2="Click here to view more.";
				selprod="Select a product.";
				acarregar="Loading data..."
				tool_esconder="Show/Hide imagens";
				tool_contactos="Contacts";
				$('#tinfo').html(selprod);
				$('#info').html('<img src="images/loading.gif" width="25" height="25" /> '+acarregar);

				$.post("scripts/dados.php", { menu: menusel, lang: lingua},
   				function(data) {
				$("#info").stop(true, true).fadeOut('slow');	
				$("#info").html(data);
				$("#info").stop(true, true).fadeIn('slow');
			  	 });	
				})
			
				$("#webfechar").click(function() {		
				$("#web").stop(true, true).fadeOut('slow', function() { $("#web").html(""); });
				})
				
			    //Tooltips
			    $("#fecharimgs").hover(function() {
				$("#tooltip").html(tool_esconder);				
				$('#tooltip').stop(true,true).fadeIn('slow');
				},
				function() {
				$
				$('#tooltip').stop(true,true).fadeOut('slow');		
				})
				
				$("#telefone").hover(function() {
				$("#tooltip").html(tool_contactos);				
				$('#tooltip').stop(true,true).fadeIn('slow');
				},
				function() {
				$
				$('#tooltip').stop(true,true).fadeOut('slow');		
				})


			    $("#enflag").hover(function() {
				$("#tooltip").html(tool_en);				
				$('#tooltip').stop(true,true).fadeIn('slow');
				},
				function() {
				$
				$('#tooltip').stop(true,true).fadeOut('slow');		
				})
				
		        $("#ptflag").hover(function() {
				$("#tooltip").html(tool_pt);				
				$('#tooltip').stop(true,true).fadeIn('slow');
				},
				function() {
				$
				$('#tooltip').stop(true,true).fadeOut('slow');		
				})
				
				// Fades imgs topo
				$("#telefone").hover(function() {				
				$('#telefone').stop(true,true).fadeTo('slow', 1);
				},
				function() {
				$
				$('#telefone').stop(true,true).fadeTo('slow', 0.5);			
				})
				
				$("#ptflag").hover(function() {				
				$('#ptflag').stop(true,true).fadeTo('slow', 1);
				},
				function() {
				$
				$('#ptflag').stop(true,true).fadeTo('slow', 0.5);			
				})
				
				$("#enflag").hover(function() {				
				$('#enflag').stop(true,true).fadeTo('slow', 1);
				},
				function() {
				$
				$('#enflag').stop(true,true).fadeTo('slow', 0.5);			
				})	
					
				$("#fecharimgs").hover(function() {				
				$('#fecharimgs').stop(true,true).fadeTo('slow', 1);
				},
				function() {
				$
				$('#fecharimgs').stop(true,true).fadeTo('slow', 0.5);			
				})		
				
				$("#telefone").click(function() { 
				menusel="contactos";
				$("#footer").stop(true, true).fadeOut('slow');	
				$("#web").stop(true, true).fadeOut('slow');
				$("#info").stop(true, true).fadeOut('slow');					
				$('#tinfo').html(infoca);
				$('#info').html('<img src="images/loading.gif" width="25" height="25" /> '+acarregar);
					$.get( 
					"scripts/dados.php",
					{ menu: "contactos", lang: lingua},
					function(data) {
					$('#info').html(data);
					}
					);

				$("#info").stop(true, true).fadeIn('slow');
				// Img Footer
				$("#footer").css("background-image","url('images/bgs/fcontacts.png')");
				$("#footer").stop(true, true).fadeIn('slow');
				});	
				
			   //on mouse over
				
				$("#fscreen").click(function() { 
				menusel="fscreen";
				$("#footer").stop(true, true).fadeOut('slow');	
				$("#web").stop(true, true).fadeOut('slow');
				$("#info").stop(true, true).fadeOut('slow');					
				$('#tinfo').html("Finger Screen");
				$('#info').html('<img src="images/loading.gif" width="25" height="25" /> '+acarregar);
					$.get( 
					"scripts/dados.php",
					{ menu: "fscreen", lang: lingua},
					function(data) {
					$('#info').html(data)
					}
					);

					

				$("#info").stop(true, true).fadeIn('slow');
				$("#footer").css("background-image","url('images/bgs/fscreen.png')");
				if (mostraimgs==1) {
				$("#footer").stop(true, true).fadeIn('slow');
				}
				});	
				
			
				$("#ftouch").click(function() {
				menusel="ftouch"; 
				$("#footer").stop(true, true).fadeOut('slow');	
				$("#web").stop(true, true).fadeOut('slow');
				$("#info").stop(true, true).fadeOut('slow');
				$('#tinfo').html("Finger Touch");
				$('#info').html('<img src="images/loading.gif" width="25" height="25" />'+acarregar);
				$.get( 
				"scripts/dados.php",
				{ menu: "ftouch", lang: lingua},
				function(data) {
				$('#info').html(data);
				}
				);
				
				
				
				$("#info").stop(true, true).fadeIn('slow');

				$("#footer").css("background-image","url('images/bgs/ftouch.png')");
				if (mostraimgs==1) {
				$("#footer").stop(true, true).fadeIn('slow');
				}				
				});	
				

				$("#fjet").click(function() { 
				menusel="fjet"; 
				$("#footer").stop(true, true).fadeOut('slow');	
				$("#web").stop(true, true).fadeOut('slow');
				$("#info").stop(true, true).fadeOut('slow');
				$('#tinfo').html("Finger Jet");
				$('#info').html('<img src="images/loading.gif" width="25" height="25" /> '+acarregar);
				
				$.get( 
				"scripts/dados.php",
				{ menu: "fjet", lang: lingua},
				function(data) {
				$('#info').html(data);
				}
				);
				
				
				$("#info").stop(true, true).fadeIn('slow');
				$("#footer").css("background-image","url('images/bgs/fjet.png')");
				if (mostraimgs==1) {
				$("#footer").stop(true, true).fadeIn('slow');
				}
				});	
												
						
				//on mouse over	
				$("#fservices").click(function() { 
				menusel="fservices"; 	
				$("#footer").stop(true, true).fadeOut('slow');	
				$("#web").stop(true, true).fadeOut('slow');
				$("#info").stop(true, true).fadeOut('slow');						   
				$('#tinfo').html("Finger Services");
				$('#info').html('<img src="images/loading.gif" width="25" height="25" /> '+acarregar);
				
				$.get( 
				"scripts/dados.php",
				{ menu: "fservices", lang: lingua},
				function(data) {
				$('#info').html(data);
				}
				);
				
				$("#info").stop(true, true).fadeIn('slow');
				$("#footer").css("background-image","url('images/bgs/fservices.png')");
				if (mostraimgs==1) {
				$("#footer").stop(true, true).fadeIn('slow');
				}
				});	
	
		
		});
		
			
			
});

//Get params
function getUrlVars() {
	var vars = {};
	var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) {
		vars[key] = value;
	});
	return vars;
}
//Dock Footer
$(function(){
	positionFooter(); 
	function positionFooter(){
		$("#footer").css({
			position: "absolute",
			top:($(window).scrollTop()+$(window).height()-$("#footer").height())+"px"
			})	
	}
 
	$(window)
		.scroll(positionFooter)
		.resize(positionFooter)
});


