function gerarSWF($arquivo,$largura,$altura){
	document.writeln('<object type="application/x-shockwave-flash" data="'+ $arquivo +'" width="'+ $largura +'" height="'+ $altura +'">');
    document.writeln('<param name="movie" value="' + $arquivo + '" />');
    document.writeln('<param name="menu" value="false" />');
    document.writeln('<param name="quality" value="high" />');
	document.writeln('<param name="wmode" value="transparent" />');
	document.writeln('<embed quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" ></embed>');
    document.writeln('</object>');
}

function imgOver(estado,id, code){
	//estado = onmouseover/onmouseout
	//id = identificação
	//code = somente para botão detalhes de produtos
	switch (id){
		case "falcan":
			if (estado == "over"){
				document.getElementById(id).src = "img/falcanOver.gif";
			}else{
				document.getElementById(id).src = "img/falcanOut.gif";
			}
		break
		case "ver":
			if (estado == "over"){
				document.getElementById(id).src = "img/verOver.gif";
			}else{
				document.getElementById(id).src = "img/verOut.gif";
			}
		break
		case "mais":
		case "mais2":
			if (estado == "over"){
				document.getElementById(id).src = "img/maisOver.gif";
			}else{
				document.getElementById(id).src = "img/maisOut.gif";
			}
		break
		case "tb":
			if (estado == "over"){
				document.getElementById(id).src = "img/trabalheconoscoOver.gif";
			}else{
				document.getElementById(id).src = "img/trabalheconosco.gif";
			}
		break
		case "todos":
			if (estado == "over"){
				document.getElementById(id).src = "img/todosOver.gif";
			}else{
				document.getElementById(id).src = "img/todosOut.gif";
			}
		break
		case "detalhes":
			if (estado == "over"){
				document.getElementById(id+code).src = "img/detalhesOver.gif";
			}else{
				document.getElementById(id+code).src = "img/detalhesOut.gif";
			}
		break
		case "pgback":
			if (estado == "over"){
				document.getElementById(id).src = "img/backOver.gif";
			}else{
				document.getElementById(id).src = "img/back.gif";
			}
		break
		case "pgnext":
			if (estado == "over"){
				document.getElementById(id).src = "img/nextOver.gif";
			}else{
				document.getElementById(id).src = "img/next.gif";
			}
		break
		case "voltar":
			if (estado == "over"){
				document.getElementById(id).src = "img/voltarOver.gif";
			}else{
				document.getElementById(id).src = "img/voltarOut.gif";
			}
		break
		case "send":
			if (estado == "over"){
				document.getElementById(id).src = "img/sendOver.gif";
			}else{
				document.getElementById(id).src = "img/sendOut.gif";
			}
		break
		case "revista":
			if (estado == "over"){
				document.getElementById(id).src = "img/revistaOver.gif";
			}else{
				document.getElementById(id).src = "img/revistaOut.gif";
			}
		break
		case "mais3":
			if (estado == "over"){
				document.getElementById(id+code).src = "img/maisOver2.gif";
			}else{
				document.getElementById(id+code).src = "img/maisOut2.gif";
			}
		break
		case "btIndique":
			if (estado == "over"){
				document.getElementById(id).src = "img/indiqueOver.gif";
			}else{
				document.getElementById(id).src = "img/indiqueOut.gif";
			}
		break
		case "volta":
			if (estado == "over"){
				document.getElementById(id).src = "img/btvoltarover.gif";
			}else{
				document.getElementById(id).src = "img/btvoltarout.gif";
			}
		break
		case "sobe":
			if (estado == "over"){
				document.getElementById(id).src = "img/sobeOver.gif";
			}else{
				document.getElementById(id).src = "img/sobeOut.gif";
			}
		break
	}
}

function assunto(valor){
	if(valor == "abre"){
		document.getElementById('assunto').style.display = "block";
	}else{
		document.getElementById('assuntoOverflow').innerHTML = valor;
		document.getElementById('assunto').style.display = "none";
		document.getElementById('assunto_hidden').value = valor;
	}
	if (valor == "Trabalhe Conosco"){
		document.getElementById('curriculo').style.display = "block";
	}else{
		document.getElementById('curriculo').style.display = "none";
	}
}
function assuntoCont(valor){	
	var mudar = document.getElementById('assuntoOverflow');
	if(valor == "abre"){
		document.getElementById('assunto').style.display = "block";
		mudar.setAttribute('onclick', 'assuntoCont("fecha")');
	}else if (valor == "fecha"){
		document.getElementById('assunto').style.display = "none";
		document.getElementById('assunto_hidden').value = valor;
		mudar.setAttribute('onclick', 'assuntoCont("abre")');
	}else{
		document.getElementById('assuntoOverflow').innerHTML = valor;
		document.getElementById('assunto').style.display = "none";
		document.getElementById('assunto_hidden').value = valor;
	}
	
}


function assuntoRevista(valor,edicao){
	var mudar = document.getElementById('revistaOverflow');
	if(valor == "abre"){
		document.getElementById('assuntoRevista').style.display = "block";
		mudar.setAttribute('onclick', 'assuntoRevista("fecha")');
	}else if (valor == "fecha"){
		document.getElementById('assuntoRevista').style.display = "none";
		mudar.setAttribute('onclick', 'assuntoRevista("abre")');
	}else{
		pagina(edicao);
		document.getElementById('revistaOverflow').innerHTML = valor;
		document.getElementById('assuntoRevista').style.display = "none";
		mudar.setAttribute('onclick', 'assuntoRevista("abre")');		
	}	
}
function assuntoRevistaPDF(valor){
	var mudar = document.getElementById('revistaOverflowPDF');
	if(valor == "abre"){
		document.getElementById('assuntoRevistaPDF').style.display = "block";
		mudar.setAttribute('onclick', 'assuntoRevistaPDF("fecha")');
	}else if (valor == "fecha"){
		document.getElementById('assuntoRevistaPDF').style.display = "none";
		mudar.setAttribute('onclick', 'assuntoRevistaPDF("abre")');
	}else{
		document.getElementById('revistaOverflowPDF').innerHTML = valor;
		document.getElementById('assuntoRevistaPDF').style.display = "none";
		mudar.setAttribute('onclick', 'assuntoRevistaPDF("abre")');
	}	
}

/* Scroll */
	
var scrollInt;
var scrTime, scrSt, scrDist, scrDur, scrInt;	
function replaceAnchorLinks(){
	var anchors, i, targ, targarr;	
	if (!document.getElementById)
		return;
		anchors = document.getElementsByTagName("a");		
	for (i=0;i<anchors.length;i++){
		if ( anchors[i].href.indexOf("#") != -1 && anchors[i].href.indexOf( document.URL ) != -1 ){
			targ = anchors[i].href.substring( anchors[i].href.indexOf("#")+1 );				
			targarr = document.getElementsByName( targ );		
			if (targarr.length){
				anchors[i].className = (targarr[0].offsetTop < anchors[i].offsetTop) ? "up" : "down";
				anchors[i].id = "__" + targ;	// save target as id with prefix (used in onclick function below)
				anchors[i].onmousedown = function () { scrollToAnchor( this.id.substring( 2 ) ); return false; };
				anchors[i].href = "javascript:;";			// rewrite href
			}
		}			
	}
}

/*	SCROLL FUNCTIONS  */
	
function scrollPage(){
		scrTime += scrInt;
		if (scrTime < scrDur) {
			window.scrollTo( 0, easeInOut(scrTime,scrSt,scrDist,scrDur) );
		}else{
			window.scrollTo( 0, scrSt+scrDist );
			clearInterval(scrollInt);
		}
	}	
function scrollToAnchor(aname){
	var anchors, i, ele;
	if (!document.getElementById)
		return;
		anchors = document.getElementsByTagName("a");
		for (i=0;i<anchors.length;i++) {
			if (anchors[i].name == aname) {
				ele = anchors[i];
				i = anchors.length;
			}
		}
	if (window.scrollY)
		scrSt = window.scrollY;
	else if (document.documentElement.scrollTop)
		scrSt = document.documentElement.scrollTop;
	else
		scrSt = document.body.scrollTop;
		scrDist = ele.offsetTop - scrSt;
		scrDur = 500;
		scrTime = 0;
		scrInt = 10;
		clearInterval(scrollInt);
		scrollInt = setInterval( scrollPage, scrInt );
	}
	function easeInOut(t,b,c,d)	{
		return c/2 * (1 - Math.cos(Math.PI*t/d)) + b;
	}	
	if (window.attachEvent){
		window.attachEvent("onload", replaceAnchorLinks);
	}else{
		window.onload = replaceAnchorLinks;
	}

function abreIndica(){
	document.getElementById('dados_indica').style.display = "block";	
}
function fechaIndica(){
	document.getElementById('dados_indica').style.display = "none";	
}

function pagina(valor){	
	ajax = ajaxInit();
	if(ajax){
		ajax.open("GET", "revista.php?edicao="+valor, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
					document.getElementById('revista1').innerHTML = ajax.responseText;					
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
	document.getElementById('revista1').style.display = "block";
	document.getElementById('bgrevista').style.display = "block";	
}
function fechaTudo(){
	document.getElementById('revista1').style.display = "none";
	document.getElementById('bgrevista').style.display = "none";	
}
function menuProdutos(img,est){
	if (est == "over"){
		document.getElementById("btn"+img).src = "img/"+img+"Over.gif";
	}else{
		document.getElementById("btn"+img).src = "img/"+img+"Out.gif";
	}
}



function newsletter(email){	
	ajax = ajaxInit();
	if(ajax){
		ajax.open("GET", "newsletter_cad.php?email="+email, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
					alert(ajax.responseText);
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function indica(form){	
	ajax = ajaxInit();
	if(ajax){
		valores = RetornaValores(form);
		ajax.open("GET", "indica_envia.php?"+valores, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
					alert(ajax.responseText);
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function contato(form){	
	ajax = ajaxInit();
	if(ajax){
		valores = RetornaValores(form);
		ajax.open("GET", "faleconosco_envia.php?"+valores, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
					alert(ajax.responseText);
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function trabalhe(form){	
	ajax = ajaxInit();
	if(ajax){
		valores = RetornaValores(form);
		ajax.open("GET", "trabalhe_envia.php?"+valores, true);
		ajax.onreadystatechange = function(){
	    	if(ajax.readyState == 4){
	    		if(ajax.status == 200){		    			
					alert(ajax.responseText);
	       		}else{
	         		alert(ajax.statusText);
	       		}
	     	}		     	
	   	}
		ajax.send(null);
	}
}

function overflow(valor, larg, marg){	
		document.getElementById('imagens').innerHTML = "<a href='javascript:void(0);' onclick='fechaIMG();' class='fecharIMG'>fechar</a><img src='" + valor + "' >";
		document.getElementById('imagens').style.display = "block";
		document.getElementById('bgrevista').style.display = "block";		
}
function fechaIMG(){
	document.getElementById('imagens').style.display = "none";
	document.getElementById('bgrevista').style.display = "none";		
}
