$(document).ready(function(){
	// MENU
	$("#superModels").mouseover(function(){
		$("#subMenuProducoes").hide("fast");
		$("#subMenu").show("fast");				
	});
	$("#specialBooking").mouseover(function(){
		$("#subMenuProducoes").hide("fast");
		$("#subMenu").hide("fast");
	});	
	$("#superProducoes").mouseover(function(){
		$("#subMenuProducoes").show("fast");
		$("#subMenu").hide("fast");
	});
	$("#superNews").mouseover(function(){
		$("#subMenuProducoes").hide("fast");
		$("#subMenu").hide("fast");				
	});
	$("#superQuemSomos").mouseover(function(){
		$("#subMenuProducoes").hide("fast");
		$("#subMenu").hide("fast");				
	});
	$("#superQueroSerSuper").mouseover(function(){
		$("#subMenuProducoes").hide("fast");
		$("#subMenu").hide("fast");				
	});
	$("#superContato").mouseover(function(){
		$("#subMenuProducoes").hide("fast");
		$("#subMenu").hide("fast");				
	});	
						   
	// CONTATO
	$("#aMap").click(function(){
		$("#contentContato").hide("normal",function(){
			$("#map").slideDown("normal");
		});
	})
	$("#aClose").click(function(){
		$("#map").hide("normal",function(){
			$("#contentContato").slideDown("normal");
		});					
	});
	
	$.getRand = function(){
		var data = new Date;
		var cache = parseInt(data.getSeconds() * data.getMinutes() / 2);
		return cache;
		
	};
	
	// SUPERnews
	$("#sendNews").click(function(){
		$("#msgNews").html('Aguarde...');
		$.post(
			   "../php/postData.php?cache=" + $.getRand(),
			   {
					nome: $("#nomeNews").val(),
					email:	$("#emailNews").val(),
					type: "newsletter"
			   },
			   function(data){
					data = eval('(' + data + ')');
					if(data.return_code != 0){
						$("#msgNews").html(data.message);
					}else{
						$("#msgNews").html(data.message);
					}
			   });
	});
	
	// BUTTON NAVIGATION MODELS
	var cont = 0;
	$("#nextPhoto").click(function(){
		if(cont < parseInt($("#contentFotos > div").length)-2){
			$("#loaderPhotos").html("Carregando...");
			$("#nextPhoto").hide();
			$($("#contentFotos > div")[cont]).fadeOut("fast");
			cont++;
			$($("#contentFotos > div")[cont]).fadeOut("fast",function(){
				cont++;	
				$($("#contentFotos > div")[cont]).fadeIn("fast",function(){
					cont++;						
					$($("#contentFotos > div")[cont]).fadeIn("fast",function(){
						cont--;	
						$("#loaderPhotos").html("");
						
						if(cont != parseInt($("#contentFotos > div").length)-2)
							$("#nextPhoto").show();

						if(cont != 0)
							$("#prevPhoto").show();
					});
				});
															   
			});
		}
    });

	$("#prevPhoto").click(function(){
		if(cont != 0){
			$("#loaderPhotos").html("Carregando...");
			$("#prevPhoto").hide();
			cont++;
			$($("#contentFotos > div")[cont]).fadeOut("fast");
			cont--;
			$($("#contentFotos > div")[cont]).fadeOut("fast",function(){
				cont--;
				$($("#contentFotos > div")[cont]).fadeIn("fast");
				cont--;
				$($("#contentFotos > div")[cont]).fadeIn("fast");
				$("#loaderPhotos").html("");
				
				if(cont != 0)
					$("#prevPhoto").show();
					
				if(cont != parseInt($("#contentFotos > div").length)-2)
					$("#nextPhoto").show();					
			 });
		}
    });

	// Select combo from models
	$("#selectModel").change(function(){
		if($(this).val() != '00'){
			$("#formSelectModel").submit();	
		}
	});

	
});

