Shadowbox.init();
var i=0;
var u=0;
var quanTelas;
var quanTexto;
var timer = 8000;
var tamanhoFonte = 0;



$(document).ready(function() {
	/* MASCARAS */
	$("input[name='telefone']").mask("(99) 9999-9999");
	$("input[name='data-validade'], input[name='data-inicio'], input[name='data-termino'], input[name='data-inicio-reacao'], input[name='data-termino-reacao']").mask("99/99/9999");

	$('#lightbox > div > div ul li > h3, #lightbox > div > div ul li > img').live("click", function(e)
		{ 
			$("#lightbox > div > div ul li").removeClass("selected");								   
			if(!$(this).parent().hasClass("selected")){
					$(this).parent().addClass("selected");
				}	
	});
	$("#menu li img + a").mouseover(function() {
		$(this).animate({opacity: 1}, 500);
	});
	$("#menu li img + a").mouseout(function() {
		$(this).animate({opacity: 0}, 350);
	});
	$("#anim > div div a + a").mouseover(function() {
		$(this).animate({opacity: 1}, 500);
	});
	$("#anim > div div a + a").mouseout(function() {
		$(this).animate({opacity: 0}, 350);
	});
	/* EBIS */
	$("#link").mouseover(function() {
		$("#ebis img").stop();
		$("#ebis img:first-child").animate({top:0, opacity: 0}, 250, function() {
			$(this).animate({top:15, opacity: 1}, 250);
			$("#ebis img + img").animate({top:35, opacity: 1}, 250);																  
		});																	  
	});
	$("#link").mouseout(function() {
		$("#ebis img").stop();
		$("#ebis img + img").animate({top:45, opacity: 0}, 250);						   
		$("#ebis img:first-child").animate({top:0, opacity: 0}, 250, function() {
			$(this).animate({top:15, opacity: 1}, 250);
		});																	  
	});

/* FILTRAR POR */
	$("#menu-produtos ul li:last-child").addClass("last");
	if($("#menu-produtos ul li:last-child").hasClass("selected")) {
		$("#menu-produtos ul li:last-child").removeClass("last");
		$("#menu-produtos ul li:last-child").prev().addClass("last");
	};
	$("#menu-produtos ul li.selected a").attr("href", "javascript:;");
	$("#menu-produtos ul li.selected a").mousedown(function() {
		if(!$(this).parent().parent().hasClass("show")) {
			$(this).parent().parent().addClass("show");
			$("#menu-produtos ul li").slideDown(500);
		}else{
			$(this).parent().parent().removeClass("show");
			$("#menu-produtos ul li").slideUp(500);
			$("#menu-produtos ul li.selected").stop();
		};
	});

/* ANIMACAO */
	quanTelas = ($("#images li").length-1);
	quanTexto = ($("#text div").length-1);

	$('#left').click(function() {
			$('#images li').stop();
			$('#images li').animate({opacity: 0}, 1000);
			if(i == quanTelas){

				$('#images li').eq(quanTelas).animate({opacity: 0}, 1, function() {
					$('#images li').eq(0).animate({opacity: 1}, 1000);
					$('#images li').eq(quanTelas).animate({opacity: 0}, 1000);
				});
				i = 0;
			}
			else{
				$('#images li').eq(i).animate({opacity: 0}, 1, function() {
					$('#images li').eq(i+1).animate({opacity: 1}, 1000);
					$('#images li').eq(i).animate({opacity: 0}, 1000);
					i++;
				});
			}

	});

	$('#right').click(function(){
			$('#images li').stop();
			$('#images li').animate({opacity: 0}, 1000);
			if(i == 0){
				$('#images li').eq(0).animate({opacity: 0}, 1, function() {
					$('#images li').eq(quanTelas).animate({opacity: 1}, 1000);
					$('#images li').eq(0).animate({opacity: 0}, 1000);
				});
				i = quanTelas;
			}else{
				$('#images li').eq(i).animate({opacity: 0}, 1, function() {
					$('#images li').eq(i-1).animate({opacity: 1}, 1000);
					$('#images li').eq(i).animate({opacity: 0}, 1000);
					i--;
				});
			}
	});

	$('#left').click(function() {
		$('#text div').stop();
		$('#text div').animate({left:274, width:250, opacity:0}, 500);
		$('#text div').children("a").animate({opacity:0}, 500);
	if(u == quanTexto){
		$('#text div').eq(0).children("a").animate({opacity:0}, 1);
		$('#text div').eq(quanTexto).animate({left:274, width:250, opacity:0}, 500, function() {
			$("#text div").css("display", "none");
			$('#text div').eq(0).animate({left:274, width:250, opacity:0}, 1);
			$('#text div').eq(0).animate({left:78, width:448, opacity:1}, 500);
			$('#text div').eq(0).children("img + a").animate({opacity:1}, 500);
		});
		u = 0;
	}else{
		$('#text div').eq(u+1).children("a").animate({opacity:0}, 1);
		$('#text div').eq(u).animate({left:274, width:250, opacity:0}, 500, function() {
			$("#text div").css("display", "none");
			$('#text div').eq(u+1).animate({left:274, width:250, opacity:0}, 1);
			$('#text div').eq(u+1).animate({left:78, width:448, opacity:1}, 500);
			$('#text div').eq(u+1).children("img + a").animate({opacity:1}, 500);
			u++;
		});
	}
	});
	$('#right').click(function(){
		$('#text div').stop();
		$('#text div').animate({left:274, width:250, opacity:0}, 500);
		$('#text div').children("a").animate({opacity:0}, 500);
		if(u == 0){
			$('#text div').eq(quanTexto).children("img + a").animate({opacity:0}, 1);
			$('#text div').eq(0).animate({left:274, width:250, opacity:0}, 500, function() {
				$("#text div").css("display", "none");
				$('#text div').eq(quanTexto).animate({left:78, width:448, opacity:1}, 500);
				$('#text div').eq(quanTexto).children("img + a").animate({opacity:1}, 500);
			});
			u = quanTexto;
		}else{
			$('#text div').eq(u-1).children("img + a").animate({opacity:0}, 1);
			$('#text div').eq(u).animate({left:274, width:250, opacity:0}, 500, function() {
				$("#text div").css("display", "none");
				$('#text div').eq(u-1).animate({left:78, width:448, opacity:1}, 500);
				$('#text div').eq(u-1).children("img + a").animate({opacity:1}, 500);
				u--;
			});
		}
	});
	$(".overtext").overText();

	$(".open-lb,.open-comprar,.open-bula, .open-saiba").click(function(e) {
		e.preventDefault();
		var lightbox = $("#lightbox");
		lightbox.addClass("show");
		$("#lightbox").eq(u).css("z-index", "1000");
		$("#ebis").eq(u).css("z-index", "-1");
		
		
		$.get($(this).attr("href"), function(response) {
			lightbox.html(response);
			lightbox.find(".close").click(function(e) {
				e.preventDefault();
				lightbox.empty();
				lightbox.removeClass("show");
				$("#lightbox").eq(u).css("z-index", "0");
				$("#ebis").eq(u).css("z-index", "1000");
			});
		});
	});

	$("#anim").parent().children("div#fonte").remove();
	$("#anim").parent().parent().children("div#bottom").children().children("div#fonte2").remove();

	function fontes() {
		if( tamanhoFonte == -3){
			$("#prod h3 + div ul li h6, #noticias > div:first-child + div > div + div ul li span, #noticias-detalhes > div:first-child + div > div > div:first-child > span").css("font-size", "9px");
			$("#prod h3 + div ul li h5, #representantes h5, #contato > div:first-child + div > div + div > div:first-child > p, #contato > div:first-child + div > div + div > div + div p").css("font-size", "9px");
			$(".texto p, .texto a, .texto ul li, #representantes > div:first-child + div > div + div div + div p, #noticias > div:first-child + div > div + div ul li p").css("font-size", "9px");
			$("#representantes h3, #representantes h4, #contato > div:first-child + div > div + div > div + div h4").css("font-size", "12px");
			$("#empresa > div:first-child + div > div > div:first-child h3, #produtos-detalhes > div:first-child + div > h3 + div h4, #noticias > div:first-child + div > div + div ul li h3, #noticias-detalhes > div:first-child + div > div > div:first-child h3").css("font-size", "15px");
			$("#noticias-detalhes > div:first-child + div > div > div:first-child h4").css("font-size", "16px");
			$("#prod h3, #produtos-detalhes h3").css("font-size", "22px");
		};
		if( tamanhoFonte == -2){
			$("#prod h3 + div ul li h6, #noticias > div:first-child + div > div + div ul li span, #noticias-detalhes > div:first-child + div > div > div:first-child > span").css("font-size", "9px");
			$("#prod h3 + div ul li h5, #representantes h5, #contato > div:first-child + div > div + div > div:first-child > p, #contato > div:first-child + div > div + div > div + div p").css("font-size", "9px");
			$(".texto p, .texto a, .texto ul li, #representantes > div:first-child + div > div + div div + div p, #noticias > div:first-child + div > div + div ul li p").css("font-size", "10px");
			$("#representantes h3, #representantes h4, #contato > div:first-child + div > div + div > div + div h4").css("font-size", "13px");
			$("#empresa > div:first-child + div > div > div:first-child h3, #produtos-detalhes > div:first-child + div > h3 + div h4, #noticias > div:first-child + div > div + div ul li h3, #noticias-detalhes > div:first-child + div > div > div:first-child h3").css("font-size", "18px");
			$("#noticias-detalhes > div:first-child + div > div > div:first-child h4").css("font-size", "19px");
			$("#prod h3, #produtos-detalhes h3").css("font-size", "25px");
		};
		if( tamanhoFonte == -1){
			$("#prod h3 + div ul li h6, #noticias > div:first-child + div > div + div ul li span, #noticias-detalhes > div:first-child + div > div > div:first-child > span").css("font-size", "9px");
			$("#prod h3 + div ul li h5, #representantes h5, #contato > div:first-child + div > div + div > div:first-child > p, #contato > div:first-child + div > div + div > div + div p").css("font-size", "10px");
			$(".texto p, .texto a, .texto ul li, #representantes > div:first-child + div > div + div div + div p, #noticias > div:first-child + div > div + div ul li p").css("font-size", "11px");
			$("#representantes h3, #representantes h4, #contato > div:first-child + div > div + div > div + div h4").css("font-size", "15px");
			$("#empresa > div:first-child + div > div > div:first-child h3, #produtos-detalhes > div:first-child + div > h3 + div h4, #noticias > div:first-child + div > div + div ul li h3, #noticias-detalhes > div:first-child + div > div > div:first-child h3").css("font-size", "22px");
			$("#noticias-detalhes > div:first-child + div > div > div:first-child h4").css("font-size", "22px");
			$("#prod h3, #produtos-detalhes h3").css("font-size", "28px");
		};
		if( tamanhoFonte == 0){
			$("#prod h3 + div ul li h6, #noticias > div:first-child + div > div + div ul li span, #noticias-detalhes > div:first-child + div > div > div:first-child > span").css("font-size", "10px");
			$("#prod h3 + div ul li h5, #representantes h5, #contato > div:first-child + div > div + div > div:first-child > p, #contato > div:first-child + div > div + div > div + div p").css("font-size", "11px");
			$(".texto p, .texto a, .texto ul li, #representantes > div:first-child + div > div + div div + div p, #noticias > div:first-child + div > div + div ul li p").css("font-size", "12px");
			$("#representantes h3, #representantes h4, #contato > div:first-child + div > div + div > div + div h4").css("font-size", "18px");
			$("#empresa > div:first-child + div > div > div:first-child h3, #produtos-detalhes > div:first-child + div > h3 + div h4, #noticias > div:first-child + div > div + div ul li h3, #noticias-detalhes > div:first-child + div > div > div:first-child h3").css("font-size", "25px");
			$("#noticias-detalhes > div:first-child + div > div > div:first-child h4").css("font-size", "26px");
			$("#prod h3, #produtos-detalhes h3").css("font-size", "31px");
		};
		if( tamanhoFonte == 1){
			$("#prod h3 + div ul li h6, #noticias > div:first-child + div > div + div ul li span, #noticias-detalhes > div:first-child + div > div > div:first-child > span").css("font-size", "11px");
			$("#prod h3 + div ul li h5, #representantes h5, #contato > div:first-child + div > div + div > div:first-child > p, #contato > div:first-child + div > div + div > div + div p").css("font-size", "12px");
			$(".texto p, .texto a, .texto ul li, #representantes > div:first-child + div > div + div div + div p, #noticias > div:first-child + div > div + div ul li p").css("font-size", "13px");
			$("#representantes h3, #representantes h4, #contato > div:first-child + div > div + div > div + div h4").css("font-size", "20px");
			$("#empresa > div:first-child + div > div > div:first-child h3, #produtos-detalhes > div:first-child + div > h3 + div h4, #noticias > div:first-child + div > div + div ul li h3, #noticias-detalhes > div:first-child + div > div > div:first-child h3").css("font-size", "28px");
			$("#noticias-detalhes > div:first-child + div > div > div:first-child h4").css("font-size", "30px");
			$("#prod h3, #produtos-detalhes h3").css("font-size", "35px");
		};
		if( tamanhoFonte == 2){
			$("#prod h3 + div ul li h6, #noticias > div:first-child + div > div + div ul li span, #noticias-detalhes > div:first-child + div > div > div:first-child > span").css("font-size", "12px");
			$("#prod h3 + div ul li h5, #representantes h5, #contato > div:first-child + div > div + div > div:first-child > p, #contato > div:first-child + div > div + div > div + div p").css("font-size", "13px");
			$(".texto p, .texto a, .texto ul li, #representantes > div:first-child + div > div + div div + div p, #noticias > div:first-child + div > div + div ul li p").css("font-size", "15px");
			$("#representantes h3, #representantes h4, #contato > div:first-child + div > div + div > div + div h4").css("font-size", "22px");
			$("#empresa > div:first-child + div > div > div:first-child h3, #produtos-detalhes > div:first-child + div > h3 + div h4, #noticias > div:first-child + div > div + div ul li h3, #noticias-detalhes > div:first-child + div > div > div:first-child h3").css("font-size", "31px");
			$("#noticias-detalhes > div:first-child + div > div > div:first-child h4").css("font-size", "33px");
			$("#prod h3, #produtos-detalhes h3").css("font-size", "38px");
		};
		if( tamanhoFonte == 3){
			$("#prod h3 + div ul li h6, #noticias > div:first-child + div > div + div ul li span, #noticias-detalhes > div:first-child + div > div > div:first-child > span").css("font-size", "13px");
			$("#prod h3 + div ul li h5, #representantes h5, #contato > div:first-child + div > div + div > div:first-child > p, #contato > div:first-child + div > div + div > div + div p").css("font-size", "15px");
			$(".texto p, .texto a, .texto ul li, #representantes > div:first-child + div > div + div div + div p, #noticias > div:first-child + div > div + div ul li p").css("font-size", "18px");
			$("#representantes h3, #representantes h4, #contato > div:first-child + div > div + div > div + div h4").css("font-size", "25px");
			$("#empresa > div:first-child + div > div > div:first-child h3, #produtos-detalhes > div:first-child + div > h3 + div h4, #noticias > div:first-child + div > div + div ul li h3, #noticias-detalhes > div:first-child + div > div > div:first-child h3").css("font-size", "35px");
			$("#noticias-detalhes > div:first-child + div > div > div:first-child h4").css("font-size", "38px");
			$("#prod h3, #produtos-detalhes h3").css("font-size", "42px");
		};
	};
	$('.text-more').click(function() {
		tamanhoFonte++;
		fontes();
	});
	$('.text-less').click(function() {
		tamanhoFonte--;
		fontes();
	});
});
function changeleft(){
	$('#images li').stop();
	$('#images li').animate({opacity: 0}, 1000);
	if(i == quanTelas){
			$('#images li').eq(quanTelas).animate({opacity: 0}, 1, function() {
				$('#images li').eq(0).animate({opacity: 1}, 1000);
				$('#images li').eq(quanTelas).animate({opacity: 0}, 1000);
			});
			i = 0;
	}else{
		$('#images li').eq(i).animate({opacity: 0}, 1, function() {
			$('#images li').eq(i+1).animate({opacity: 1}, 1000);
			$('#images li').eq(i).animate({opacity: 0}, 1000);
			i++;
		});
	}
	$('#text div').stop();
	$('#text div').animate({left:274, width:250, opacity:0}, 500);
	$('#text div').children("a").animate({opacity:0}, 500);
	if(u == quanTexto){
		$('#text div').eq(0).children("a").animate({opacity:0}, 1);
		$('#text div').eq(quanTexto).animate({left:274, width:250, opacity:0}, 500, function() {
			$("#text div").css("display", "none");
			$('#text div').eq(0).animate({left:274, width:250, opacity:0}, 1);
			$('#text div').eq(0).animate({left:78, width:448, opacity:1}, 500);
			$('#text div').eq(0).children("img + a").animate({opacity:1}, 500);
		});
		u = 0;
	}else{
		$('#text div').eq(u+1).children("a").animate({opacity:0}, 1);
		$('#text div').eq(u).animate({left:274, width:250, opacity:0}, 500, function() {
			$("#text div").css("display", "none");
			$('#text div').eq(u+1).animate({left:274, width:250, opacity:0}, 1);
			$('#text div').eq(u+1).animate({left:78, width:448, opacity:1}, 500);
			$('#text div').eq(u+1).children("img + a").animate({opacity:1}, 500);
			u++;
		});
	}
	setTimeout("changeleft()", timer);
};

changeleft();
var addthis_config = { ui_click: true };
