// Furgao Cambe
jQuery(document).ready(function(){ 
	$('#menu a').mouseenter(function(){ 
		$(this).children("span.b").animate({
			height: '55'}, 300);
	}).mouseleave(function(){ 
		$(this).children("span.b").animate({
			height: '-55'}, 200);
	});
	$('#tool a').mouseenter(function(){ 
		$(this).children("span.ba").animate({
			width: '311'}, 300);
	}).mouseleave(function(){ 
		$(this).children("span.ba").animate({
			width: '1'}, 400);
	});
    $('#tool_slider').nivoSlider({
        effect:'boxRain', // Specify sets like: 'fold,fade,sliceDown'
        slices:15, // For slice animations
        boxCols: 8, // For box animations
        boxRows: 4, // For box animations
        animSpeed:500, // Slide transition speed
        pauseTime:3000, // How long each slide will show
        startSlide:0, // Set starting Slide (0 index)
        directionNav:false, // Next & Prev navigation
        directionNavHide:false, // Only show on hover
        controlNav:false, // 1,2,3... navigation
        controlNavThumbs:false, // Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, // Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', // Replace this with...
        keyboardNav:false, // Use left & right arrows
        pauseOnHover:true, // Stop animation while hovering
        manualAdvance:false, // Force manual transitions
        captionOpacity:0.8, // Universal caption opacity
        beforeChange: function(){}, // Triggers before a slide transition
        afterChange: function(){}, // Triggers after a slide transition
        slideshowEnd: function(){}, // Triggers after all slides have been shown
        lastSlide: function(){}, // Triggers when last slide is shown
        afterLoad: function(){} // Triggers when slider has loaded
    });
	/* Form Newsletter */
	$("#container_content_o").css("opacity",0);
	//$("#container_content_o").css("display","none");
	$("#enviar_news").removeAttr("disabled"); 
	var options_news = { 
		success:respostaLogin
	}
	$('#form_news').validate( {
		rules: {
			nome_n: {
				required: true,
				minlength: 3
			},
			email_n: {
				required: true,
				email: true,
				minlength: 3
			}
		},
		messages: {
			nome_n: {
				required: "Por favor, informe seu nome",
				minlength: "Seu nome parece estar incorreto"
			},
			email_n: {
				email: "E-mail parece estar incorreto",
				required: "Por favor, informe sua e-mail",
				minlength: "Seu e-mail parece estar incorreto"
			}
		},
		submitHandler: function(form) {
			$('#enviar_news').attr("disabled","disabled");
			$('#enviar_news').attr("value","Enviando");	
			$(form).attr("action","/sistema/cadastra_newsletter.php");
			$(form).ajaxSubmit(options_news); 
		}
	 });

});
function respostaLogin(responseText, statusText, xhr, $form)  { 
	if(responseText == '1'){
		obrigado();
	} else {
		$("#container_content_o").html = "Estamos enfrentando problemas com nossa base de dados, desculpe-nos tente mais tarde.";
		obrigado();
	}
} 

function obrigado(){
  $("#container_content_o").animate({ 
	opacity: 1,
	width: 445,
	height: 170
  }, 1500 );
  $("#container_content").animate({ 
	opacity: 0
  }, 1500 );
}
/* Seminovos - Detalhe */
function mudaFoto(srci){
	$('#f_p').attr('src', '');
	var isrc = $(srci).find('img');
	isrc= $(isrc).attr('src');
	var srca = isrc.split("-");
	var srcn = 	615 +'-' + 400 + '-'+srca[2]+ '-'+srca[3];
	$('#f_p').attr('src', '/img/'+srcn);
}

