$(document).ready(function(){
   var x = 0;
   //jQuery('a[rel*=facebox]').facebox();
   
   /*$('.mn-slide li .active').click(function(){
		$(this).slideUp('slow');
		$(this).removeClass('active');
		$(this).addClass('closed');
   });
   
   $('.mn-slide li .closed').click(function(){
      
     $('.mn-slide li').each(function(){
         
        $(this).find('span').removeClass('active');  
        $(this).parent().find('ul').slideUp('fast');
        $('.tit span img').attr('src','img/marc-mais.gif');
         
     });
     $(this).parent().find('ul').slideToggle('slow');
     $(this).toggleClass('active');
     $(this).parent().find('img').attr('src','img/marc-menos.gif');
     
   });//End click
	*/
	
	//news();	
	
	$(".mn-slide .tit span.polimero").click(function(){
	
		if ($(this).hasClass("active") == true){
			$("span.polimero").removeClass("active");
			$("span.polimero").parent().find("ul").slideUp("slow");
			$(this).find("img:first").attr("src", "img/marc-mais.gif");
		} else {
			$(this).parent().find("ul:first").slideDown("slow");
			$(this).addClass("active");
			$(this).find("img").attr("src", "img/marc-menos.gif");
		}
	
	})
	
	$('.mn-slide li span.cat').click(function(){
			
		if ( $(this).hasClass("active") == true ){
			$(this).removeClass('active');
			$(this).find("img:first").attr("src", "img/marc-mais.gif");
			$(this).parent().find("ul:first").slideUp('slow');
		} else {
			$('.mn-slide li span.cat').parent().find("ul.sub").slideUp('slow');
			$('.mn-slide li span.cat img').attr("src", "img/marc-mais.gif");
			$('.mn-slide li span.cat').removeClass('active');
			$(this).addClass('active');
			$(this).find("img").attr("src", "img/marc-menos.gif");
			$(this).parent().find("ul:first").slideDown('slow');
			$(".sub").removeClass("activeSub");
			$(".sub").find("img").attr("src", "img/marc-mais.gif");
		}
		
	})

	$(".subCat").click(function(){
		
		$("ul.prod").slideUp("slow");
		if ($(this).hasClass("activeSub") == true){
			$(".sub .activeSub").removeClass("activeSub");
			$(this).find("img:first").attr("src", "img/marc-mais.gif");
		} else {
			$(".subCat").find("img").attr("src", "img/marc-mais.gif");
			$(this).parent().find("ul.prod:first").slideDown("slow");
			$(this).find("img:first").attr("src", "img/marc-menos.gif");
			$(this).addClass("activeSub");
		}
	})

	
   $('#lista-topo li a').click(function(){
      
     $('#lista-topo li').each(function(){
         
        $(this).parent().find('ul').slideUp('fast');
         
     });
     $(this).parent().find('ul').slideToggle('fast');
     
   });//End click  
   
   $('.verLocalizacao').click(function(){
		
		$(this).parent().parent().parent().find('.localizacaoDist').slideDown('slow');
		
	});
   
   $('.vejaMais').click(function(){
		
		$('#tabelaConteudo').slideToggle('slow');
		
	});
   
	function news(){
	
		var intervalo = window.setInterval(function() {
		
			$(".newActive").fadeOut('slow',function(){
				trocaNews();										
			});
			//moveNews();
			
		}, 6000);
		
		window.setTimeout(function() {
			clearInterval(intervalo);
		}, 30000000);
		
		
		
	}
	
	function moveNews(){
	
		
	
	}
	
	function trocaNews(){
		
		x++;
		//alert(x);
		if (x>5){
			x = 0;
		}
		
		$(".newActive").removeClass("newActive");
		$("dt.dt"+x).addClass("newActive");
		$("dd.dd"+x).addClass("newActive");
		$(".newActive").fadeIn("slow");
	}
	
	$("#nl-submit").click(function(){
		cadastraNewsletter();
	});
	function cadastraNewsletter() {
		var nome = $("#nl-nome").val();
		var email = $("#nl-email").val();
		$(".avisoNews").html('Aguarde ...');
		$.ajax({
			type: "POST",
			url: "mailz_cad.php",
			data: "nome="+nome+"+&email="+email,
			cache: false,
			success: function(html){
				$(".avisoNews").empty();
				$(".avisoNews").append(html);
			}
		});	
	}
   
});


