<!--SLIDE AREA DE CONTACTOS-->
$(document).ready(function(){
	
	
	//POSICIONAMENTO
	jQuery.event.add(window, "load", resizeFrame);
	jQuery.event.add(window, "load", mostrarFrame);
	jQuery.event.add(window, "resize", resizeFrame);
	
	function mostrarFrame(){
		//$('#menu').show("slide", { direction: "down" }, 1000);
		
		$("#logo").css({display:"block"});
		
		var u = $.url.param("m");
		
		if(u == "galeria"){
			//$('#menu').show('slide', {direction:'down'});
			$('#area_voltar_menu').show('slide', {direction:'down'});
		}else{
			$('#menu').show('slide', {direction:'down'});
		}
		
	}
	
	//alert($.url.param("m"));
	
	function resizeFrame() 
	{
		var h = $(window).height();
		var w = $(window).width();
		wm=w-40;
		/*$("#website").css('height',h);
		$("#website").css('width',w);*/
		
		
		var u = $.url.param("m");
		/*POSICIONAMENTO DA IMAGEM DE FUNDO DOS ESPAÇOS*/
		if(u=="espacos" || u=="contactos"){
			//var imgW = $("#img_fundo_espacos").width();
			//var imgH = $("#img_fundo_espacos").height();
			var imgW = 1328;
			var imgH = 800;
			var r = imgW/imgH;
			
			if(w>h){
				if(w/r>=h){
					$("#img_fundo_espacos").css({width:w});
					$("#img_fundo_espacos").css({height:(w/r)});
				}else{
					$("#img_fundo_espacos").css({height:(h)});
					$("#img_fundo_espacos").css({width:r*h});
				}
			}else{
				$("#img_fundo_espacos").css({width:r*h});
				$("#img_fundo_espacos").css({height:h});
			}
		}
		if(!$('#img_fundo_espacos').is(':visible') ) {
			$("#img_fundo_espacos").css({display:"block"});
		}
		/*POSICIONAMENTO DA IMAGEM DE FUNDO DOS ESPAÇOS*/
		
		
		/*POSICIONAMENTO DA IMAGEM DE FUNDO DAS NOTÍCIAS*/
		if(u=="noticias"){
			//var imgW = $("#img_fundo_espacos").width();
			//var imgH = $("#img_fundo_espacos").height();
			var imgW = 1328;
			var imgH = 800;
			var r = imgW/imgH;
			
			if(w>h){
				if(w/r>=h){
					$("#img_fundo_noticias").css({width:w});
					$("#img_fundo_noticias").css({height:(w/r)});
				}else{
					$("#img_fundo_noticias").css({height:(h)});
					$("#img_fundo_noticias").css({width:r*h});
				}
			}else{
				$("#img_fundo_noticias").css({width:r*h});
				$("#img_fundo_noticias").css({height:h});
			}
		}
		if(!$('#img_fundo_noticias').is(':visible') ) {
			$("#img_fundo_noticias").css({display:"block"});
		}
		/*POSICIONAMENTO DA IMAGEM DE FUNDO DAS NOTÍCIAS*/
		
		
		
		
		
		/*________________________REPOSICIONAMENTOS INTEPENDENTES DA LARGURA DO SITE____________________*/
		$("#menu").css("margin-top",(h-335));
		$("#area_voltar_menu").css("margin-top",(h-40));
		$("#bt_gosto_facebook").css("margin-top",(h-75));
		
		if(w>=1400){
			$("#logo").css({left:"50%"});
			$("#menu").css({left:"50%"});
			$("#area_voltar_menu").css({left:"50%"});
			
		}else{
			$("#logo").css({left:"612px"}); /*por causa do padding-left do css*/
			$("#menu").css({left:(w-350)}); /*por causa do padding-left do css*/
			$("#area_voltar_menu").css({left:(w-350)}); /*por causa do padding-left do css*/
		}		
		
		
		
		//CONTEUDOS EMPRESA
		if(w>1400){
			$("#area_empresa").css("width",(600));
			$("#area_empresa").css("height",(250));
			$("#area_empresa").css("margin-top",(-150));
			$("#area_empresa").css("margin-left",(-300));
		}else{
			$("#area_empresa").css("width",(300));
			$("#area_empresa").css("height",(400));
			$("#area_empresa").css("margin-top",(-100));
			if(w>=960)
				$("#area_empresa").css("margin-left",(-150));
			else
				$("#area_empresa").css("margin-left",(-300));
		}
		
		//alert (w);
	}
	//FIM DO POSICIONAMENTO
	
	
	
	
	
	
	
	
	
	
	
	
	$("#link_form_contacto").click(function(){
		$('#fundo_conteudos_popup').show();
		/*$('#area_contactos').fadeIn('slow', function() {
			// Animation complete.
		});*/
		$('#area_form_contacto').fadeIn("slow", function(){});
	});
	
	
	$("#link_entre_em_contacto").click(function(){
		$('#fundo_conteudos_popup').show();
		/*$('#area_contactos').fadeIn('slow', function() {
			// Animation complete.
		});*/
		$('#area_form_contacto').fadeIn("slow", function(){});
	});
	
	$("#link_email").click(function(){
		$('#fundo_conteudos_popup').show();
		/*$('#area_contactos').fadeIn('slow', function() {
			// Animation complete.
		});*/
		$('#area_form_contacto').fadeIn("slow", function(){});
	});
	
	$("#bt_fechar_form_contacto").click(function(){
		$(this).parent().hide();
		$('#fundo_conteudos_popup').hide();
		/*$('#area_contactos').fadeIn('slow', function() {
			// Animation complete.
		});*/
		//$('#area_espaco_salao_piscina').fadeIn("slow", function(){});
	});
	
	
	
	
	//______________________________________ESPAÇOS
	$("#link_salao_piscina").click(function(){
		$('#fundo_conteudos_popup').show();
		$('#area_espacos_salao_piscina').fadeIn("slow", function(){});
	});
	$("#link_salao_jardim").click(function(){
		$('#fundo_conteudos_popup').show();
		$('#area_espacos_salao_jardim').fadeIn("slow", function(){});
	});
	$("#link_cozinha").click(function(){
		$('#fundo_conteudos_popup').show();
		$('#area_espacos_cozinha').fadeIn("slow", function(){});
	});
	$("#link_jardins").click(function(){
		$('#fundo_conteudos_popup').show();
		$('#area_espacos_jardins').fadeIn("slow", function(){});
	});
	$("#link_espacos_e_lazer").click(function(){
		$('#fundo_conteudos_popup').show();
		$('#area_espacos_espacos_e_lazer').fadeIn("slow", function(){});
	});
	
	
	
	//SALÃO PISCINA
	$('#area_espacos_salao_piscina #seguinte').click(function(){
		$('#area_espacos_salao_piscina #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).next().size()>0){
					$(this).animate({width: 'hide'});
					$(this).next().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO ANTERIOR
						$('#area_espacos_salao_piscina #anterior').show();
					}
				}
				if($(this).next().next().size()<1){
					$('#area_espacos_salao_piscina #seguinte').hide();
				}
				return false;
			}
		 });

	});
	$('#area_espacos_salao_piscina #anterior').click(function(){
		$('#area_espacos_salao_piscina #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).prev().size()>0){
					$(this).animate({width: 'hide'});
					$(this).prev().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO SEGUINTE
						$('#area_espacos_salao_piscina #seguinte').show();
					}
				}
				if($(this).prev().prev().size()<1){
					$('#area_espacos_salao_piscina #anterior').hide();
				}
				return false;
			}
		 });

	});
	
	
	//SALÃO JARDIM
	$('#area_espacos_salao_jardim #seguinte').click(function(){
		$('#area_espacos_salao_jardim #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).next().size()>0){
					$(this).animate({width: 'hide'});
					$(this).next().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO ANTERIOR
						$('#area_espacos_salao_jardim #anterior').show();
					}
				}
				if($(this).next().next().size()<1){
					$('#area_espacos_salao_jardim #seguinte').hide();
				}
				return false;
			}
		 });

	});
	$('#area_espacos_salao_jardim #anterior').click(function(){
		$('#area_espacos_salao_jardim #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).prev().size()>0){
					$(this).animate({width: 'hide'});
					$(this).prev().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO SEGUINTE
						$('#area_espacos_salao_jardim #seguinte').show();
					}
				}
				if($(this).prev().prev().size()<1){
					$('#area_espacos_salao_jardim #anterior').hide();
				}
				return false;
			}
		 });

	});
	
	
	//COZINHA
	$('#area_espacos_cozinha #seguinte').click(function(){
		$('#area_espacos_cozinha #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).next().size()>0){
					$(this).animate({width: 'hide'});
					$(this).next().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO ANTERIOR
						$('#area_espacos_cozinha #anterior').show();
					}
				}
				if($(this).next().next().size()<1){
					$('#area_espacos_cozinha #seguinte').hide();
				}
				return false;
			}
		 });

	});
	$('#area_espacos_cozinha #anterior').click(function(){
		$('#area_espacos_cozinha #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).prev().size()>0){
					$(this).animate({width: 'hide'});
					$(this).prev().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO SEGUINTE
						$('#area_espacos_cozinha #seguinte').show();
					}
				}
				if($(this).prev().prev().size()<1){
					$('#area_espacos_cozinha #anterior').hide();
				}
				return false;
			}
		 });

	});
	
	//JARDINS
	$('#area_espacos_jardins #seguinte').click(function(){
		$('#area_espacos_jardins #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).next().size()>0){
					$(this).animate({width: 'hide'});
					$(this).next().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO ANTERIOR
						$('#area_espacos_jardins #anterior').show();
					}
				}
				if($(this).next().next().size()<1){
					$('#area_espacos_jardins #seguinte').hide();
				}
				return false;
			}
		 });

	});
	$('#area_espacos_jardins #anterior').click(function(){
		$('#area_espacos_jardins #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).prev().size()>0){
					$(this).animate({width: 'hide'});
					$(this).prev().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO SEGUINTE
						$('#area_espacos_jardins #seguinte').show();
					}
				}
				if($(this).prev().prev().size()<1){
					$('#area_espacos_jardins #anterior').hide();
				}
				return false;
			}
		 });

	});
	
	
	//LAZER
	$('#area_espacos_espacos_e_lazer #seguinte').click(function(){
		$('#area_espacos_espacos_e_lazer #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).next().size()>0){
					$(this).animate({width: 'hide'});
					$(this).next().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO ANTERIOR
						$('#area_espacos_espacos_e_lazer #anterior').show();
					}
				}
				if($(this).next().next().size()<1){
					$('#area_espacos_espacos_e_lazer #seguinte').hide();
				}
				return false;
			}
		 });

	});
	$('#area_espacos_espacos_e_lazer #anterior').click(function(){
		$('#area_espacos_espacos_e_lazer #elementos_slide div').each(function (i) {
			if($(this).is(':visible')){
				if($(this).prev().size()>0){
					$(this).animate({width: 'hide'});
					$(this).prev().animate({width: 'show'});
					if($(this).size()>0){ //MOSTRAR O BOTÃO SEGUINTE
						$('#area_espacos_espacos_e_lazer #seguinte').show();
					}
				}
				if($(this).prev().prev().size()<1){
					$('#area_espacos_espacos_e_lazer #anterior').hide();
				}
				return false;
			}
		 });

	});
	
	
	$(".bt_fechar_conteudo").click(function(){
		$(this).parent().hide();
		$('#fundo_conteudos_popup').hide();
		/*$('#area_contactos').fadeIn('slow', function() {
			// Animation complete.
		});*/
		//$('#area_espaco_salao_piscina').fadeIn("slow", function(){});
	});
	
	//______________________________________ESPAÇOS
	
	
	
	
	$("#bt_fechar_cotactos").click(function(){
		$('#fundo_conteudos_popup').hide();
		$('#area_contactos').hide();
	});
	
	$("#bt_fechar_salao_piscina").click(function(){
		$('#fundo_conteudos_popup').hide();
		$('#area_espaco_salao_piscina').hide();
	});
	
	
	
	
	
	
	/*________________MENU________________________*/
	$("#bt_fechar_menu").click(function(){
		$('#menu').hide();
		$('#area_voltar_menu').show('slide', {direction:'down'});
		//$('#area_voltar_menu').show("slide", { direction: "down" }, 1000);
	});
	
	$("#bt_menu").click(function(){
		$('#menu').show('slide', {direction:'down'});
		$('#area_voltar_menu').hide('slide', {direction:'down'});
		
		//$('#area_voltar_menu').hide("slide", { direction: "down" }, 1000);
		//$('#menu').show("slide", { direction: "down" }, 1000);
	});
	/*________________MENU________________________*/


});
<!--SLIDE AREA DE CONTACTOS-->











/*
jQuery Url Plugin
	* Version 1.0
	* 2009-03-22 19:30:05
	* URL: http://ajaxcssblog.com/jquery/url-read-get-variables/
	* Description: jQuery Url Plugin gives the ability to read GET parameters from the actual URL
	* Author: Matthias Jäggli
	* Copyright: Copyright (c) 2009 Matthias Jäggli 
	* Licence: dual, MIT/GPLv2
*/
(function ($) {
	$.url = {};
	$.extend($.url, {
		_params: {},
		init: function(){
			var paramsRaw = "";
			try{
				paramsRaw = 
					(document.location.href.split("?", 2)[1] || "").split("#")[0].split("&") || [];
				for(var i = 0; i< paramsRaw.length; i++){
					var single = paramsRaw[i].split("=");
					if(single[0])
						this._params[single[0]] = unescape(single[1]);
				}
			}
			catch(e){
				alert(e);
			}
		},
		param: function(name){
			return this._params[name] || "";
		},
		paramAll: function(){
			return this._params;
		}
	});
	$.url.init();
})(jQuery);
