$(document).ready(function(){

	//Menu
	$("#nav li a").hover(function() {
		var pos = $(this).css("backgroundPosition").split(" ")[0];
		$(this).stop().animate( {backgroundPosition: "("+pos+" -23px)"}, 250);
	} , function() {
		var pos = $(this).css("backgroundPosition").split(" ")[0];
		$(this).stop().animate( {backgroundPosition: "("+pos+" 0)"}, 250);
	});
	
	//Menu Unidades
	$("#nav-unidade li a").hover(function() {
		var pos = $(this).css("backgroundPosition").split(" ")[0];
		$(this).stop().animate( {backgroundPosition: "("+pos+" -23px)"}, 250);
	} , function() {
		var pos = $(this).css("backgroundPosition").split(" ")[0];
		$(this).stop().animate( {backgroundPosition: "("+pos+" 0)"}, 250);
	});

	//Preecher imput com a palavra "e-mail:" no form de newsletter
	$("#newsletter #email").val("e-mail:");
	$("#newsletter #email").focus(function(){
		if ( $(this).val() == "e-mail:" )
			$(this).val("");							   
	}).blur(function(){
		if ( $(this).val().trim() == "" )
			$(this).val("e-mail:");
	});
	//Retirar palavra "e-mail:" ao enviar o form
	$("#newsletter").submit(function(){
		$("#newsletter #email").val( $("#newsletter #email").val() == "e-mail:" ? "" : $("#newsletter #email").val() );
	});
	
	//Produtos com transparência :hover
	$(".produtos a").hover(function(){
		$(this).css("opacity","1.0");								
	}, function(){
		$(this).css("opacity","0.8");	
	}).css("opacity","0.8");
	
	//Carro aparecendo
	/*var carro = new Image();
	$(carro).load(function(){
		$("#carro").append(this);
		$("#carro").fadeIn(3000);
	}).attr("src","images/header-carro.png");*/
	
	//Aplicando png fix
	$("#carro").addClass("pngFix");
	$(".ofertas .btn").addClass("pngFix");
	$(".msn .btn").addClass("pngFix");
	
	//Destacando campos requeridos
	$("form .required").parent().find("label").append('<span title="Campo obrigatório." style="color: #E74037; margin-left: 5px;">*</span>');
	//Validando formulario
	$("#orcamento").submit( function(){
		$("label.error").remove();
		var erros = 0;
		$.each( $(".required"), function(){
			if ( $(this).val() == "" ){
				if ( $(this).is("textarea") )
					$(this).after('<label class="error" style="vertical-align: top;">Este campo é de preenchimento obrigatório.</label>');
				else
					$(this).after('<label class="error">Este campo é de preenchimento obrigatório.</label>');		
				erros++;
			}
		} );
		return erros > 0 ? false : true;
	} );
	
	//Area restrita
	$("#areaRestrita-index #login").val("Login");
	$("#areaRestrita-index #login").focus(function(){
		$(this).val( $(this).val() == "Login" ? "" : $(this).val() );
	}).blur(function(){
		$(this).val( $(this).val() == "" ? "Login" : $(this).val() );
	});
	
	$("#areaRestrita-index #senha").val("Senha");
	$("#areaRestrita-index #senha").focus(function(){
		if ( $(this).val() == "Senha" ){
			$(this).val("");
		}
	}).blur(function(){
		if ( $(this).val() == "" ){
			$(this).val("Senha");
		}
	});
	

	
});// document.ready