// JavaScript Document

function opacidade(id,inicio,final,tempo){
	var speed= Math.round(tempo/100);
	var timer=0;
	if (inicio>final){
		for (i=inicio;i>=final;i--){
			setTimeout("fade('"+id+"',"+i+")",(timer*speed));
			timer++;
		}
	}else if (inicio<final){
		for (i=inicio;i<=final;i++){
			setTimeout("fade('"+id+"',"+i+")",(timer*speed));
			timer++;
		} 
	}
}

function fade(id,opacidade){
	var obj= document.getElementById(id).style;
	obj.opacity=(opacidade/100);
	obj.MozOpacity =(opacidade/100);
	obj.KhtmlOpacity =(opacidade/100);
	obj.filter="alpha(opacity="+opacidade+")";
}
function ValidacaoEmail(emailad){
    var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
    var check=/@[\w\-]+\./;
    var checkend=/\.[a-zA-Z]{2,3}$/;
    if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1)){
        return false;
    }
    else {
        return true;
    }
}
function produtos(q){
	var par= (q)?q:'';
	progresso();
	x_mostra_produtos(par,recebe_dados);
}
function a_empresa(q){
	var par= (q)?q:'';
	progresso();
	x_empresa(par,recebe_dados);
}
function clientes(q){
	var par= (q)?q:'';
	progresso();
	x_clientes(par,recebe_dados);
}
function depoimentos(q){
	var par= (q)?q:'';
	progresso();
	x_depoimentos(par,recebe_dados);
}

function galeria(q){
	var par= (q)?q:'';
	progresso();
	x_galerias(par,recebe_dados);
}
function visualizar_galerias(q){
	var par= (q)?q:'';
	progresso();
	x_visualizar_galerias(par,recebe_dados);
}

function recebe_dados(valor){
	document.getElementById('conteudo').innerHTML = valor;
	png();

	tb_init('a.thickbox, area.thickbox, input.thickbox');//pass where to apply thickbox
	imgLoader = new Image();// preload image
	imgLoader.src = tb_pathToImage;
	
	setTimeout('progresso()',2000);
	
}
function contato(q){
	var par= (q)?q:'';
	progresso();
	x_mostra_contato(par,recebe_dados);
}

function votar(){
	var cod=document.getElementById('enquete').value;
	var enq=document.getElementById('cod_enquete').value;
	progresso();
	x_votar(cod,enq,recebe_enquete);
}
 function recebe_enquete(valor){
	progresso();
	document.getElementById('enquetes').innerHTML = valor;
 }
function listaInteresse(q){
	var par= (q)?q:'';
	progresso();
	x_mostra_lista_interesse(par,recebe_dados);
}

function enviaEmail(q){
	//var session=document.getElementById('session').value; 
	var nome =document.getElementById('nome').value; 
	var assunto =document.getElementById('assunto').value; 
	var comentario =document.getElementById('comentario').value; 
	var endereco =document.getElementById('endereco').value; 
	var cidade =document.getElementById('cidade').value; 
	var estado =document.getElementById('estado').value; 
	var email =document.getElementById('email').value; 
	var ddd =document.getElementById('ddd').value; 
	var telefone =document.getElementById('telefone').value; 

	var res=ValidacaoEmail(email);
	if (res){
		if(nome!=''){
			if(assunto!=''){
					if(comentario!=''){
						progresso();
						x_envia_email(nome,email,endereco,telefone,cidade,estado,assunto,comentario,resposta);			  
						//document.getElementById('session').value=''; 
						document.getElementById('nome').value=''; 
						document.getElementById('assunto').value=''; 
						document.getElementById('comentario').value=''; 
						document.getElementById('endereco').value=''; 
						document.getElementById('cidade').value=''; 
						document.getElementById('estado').value=''; 
						document.getElementById('email').value=''; 
						document.getElementById('ddd').value=''; 
						document.getElementById('telefone').value=''; 
					}else{
						alert ('o campo comentario não pode estar vazio');	
					}
			}else{
				alert ('o campo assunto não pode estar vazio');	
			}
		}else{
		alert ('o campo nome não pode estar vazio');	
		}
	}else{
		if(nome==''){
			alert ('o nome não pode estar vazio\n e o email esta incorreto ou vazio');	
		}else{
			alert ('o email esta incorreto ou vazio');	
		}
	}
}
 function resposta(valor){
	progresso();
	alert(valor);
 }

function web_master(q){
	var par= (q)?q:'';
	progresso();
	x_mostra_webmaster(par,recebe_dados);
}
function envia_webMaster(q){
	//var session=document.getElementById('session').value; 
	var nome =document.getElementById('nome').value; 
	var assunto =document.getElementById('assunto').value; 
	var comentario =document.getElementById('comentario').value; 
	var email =document.getElementById('email').value; 
	var res=ValidacaoEmail(email);
	if (res){
		if(nome!=''){
			if(assunto!=''){
					if(comentario!=''){
						progresso();
						x_envia_web_master(nome,email,assunto,comentario,resposta);			  
						//document.getElementById('session').value=''; 
						document.getElementById('nome').value=''; 
						document.getElementById('assunto').value=''; 
						document.getElementById('comentario').value=''; 
						document.getElementById('email').value=''; 
					}else{
						alert ('o campo comentario não pode estar vazio');	
					}
			}else{
				alert ('o campo assunto não pode estar vazio');	
			}
		}else{
		alert ('o campo nome não pode estar vazio');	
		}
	}else{
		if(nome==''){
			alert ('o nome não pode estar vazio\n e o email esta incorreto ou vazio');	
		}else{
			alert ('o email esta incorreto ou vazio');	
		}
	}
}
function enviaListaInteresse(q){
	//var session=document.getElementById('session').value; 
	var nome =document.getElementById('nome').value; 
	var razao =document.getElementById('razao').value; 
	var cpfCnpg =document.getElementById('cpfCnpg').value; 
	var endereco =document.getElementById('endereco').value; 
	var bairro =document.getElementById('bairro').value;
	var cidade =document.getElementById('cidade').value; 
	var estado =document.getElementById('estado').value; 
	var cep =document.getElementById('cep').value; 
	var email =document.getElementById('email').value; 
	var telefone =document.getElementById('ddd').value+document.getElementById('telefone').value; 
	var res=ValidacaoEmail(email);
	if (res){
		if(nome!= ''){
			progresso();
			x_envia_lista(nome,email,telefone,endereco,razao,cpfCnpg,cidade,estado,bairro,cep,resposta);
			//document.getElementById('session').value=''; 
			document.getElementById('nome').value=''; 
			document.getElementById('razao').value=''; 
			document.getElementById('cpfCnpg').value=''; 
			document.getElementById('endereco').value=''; 
			document.getElementById('bairro').value='';
			document.getElementById('cidade').value=''; 
			document.getElementById('estado').value=''; 
			document.getElementById('cep').value=''; 
			document.getElementById('email').value=''; 
			document.getElementById('ddd').value='';
			document.getElementById('telefone').value=''; 
	}else{
		alert ('o campo nome não pode estar vazio');	
		}
	}else{
		if(nome==''){
			alert ('o nome não pode estar vazio\n e o email esta incorreto ou vazio');	
		}else{
			alert ('o email esta incorreto ou vazio');	
		}
	}
}
function progresso(){
	var ns = (navigator.appName.indexOf("Netscape") != -1);
	var x = ns ? innerWidth : document.body.clientWidth;
	var tam= 235+((Number(x) - 760) /2);

	if (document.getElementById('progresso').style.display=='none'){
		//fade('tudo',30);
		document.getElementById('progresso').style.left =tam+'px';
		$('#progresso').show("slow");
	}else{
		//fade('tudo',100);
		$('#progresso').hide("slow");			
	}
}


function png(){
	if (typeof document.body.style.maxHeight != "undefined") {
	
	} else {
		for(var i=0; i<document.images.length; i++){
			  var img = document.images[i]
			  var imgName = img.src.toUpperCase()
			  if (imgName.substring(imgName.length-3, imgName.length) == "PNG"){
				 var imgID = (img.id) ? "id='" + img.id + "' " : ""
				 var imgClass = (img.className) ? "class='" + img.className + "' " : ""
				 var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' "
				 var imgStyle = "display:inline-block;" + img.style.cssText 
				 if (img.align == "left") imgStyle = "float:left;" + imgStyle
				 if (img.align == "right") imgStyle = "float:right;" + imgStyle
				 if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle
				 var strNewHTML = "<span " + imgID + imgClass + imgTitle
				 + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";"
				 + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader"
				 + "(src=\'" + img.src + "\', sizingMethod=\'scale\');\"></span>" 
				 img.outerHTML = strNewHTML
				 i = i-1
			  }
		}
	}
}

