try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}

function criarXMLHttpRequest()
{
   try{ return new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){}
   try{ return new ActiveXObject("Microsoft.XMLHTTP"); }catch(e){}
   try{ return new XMLHttpRequest(); }catch(e){}
   //alert("XMLHttpRequest not supported");
   return null;
}
var XHR_criado = criarXMLHttpRequest();


function limpaRepres(){
   document.getElementById('nome').value="";	
   document.getElementById('empresa').value="";	
   document.getElementById('cidade').value="";	
   document.getElementById('estado').value="";	
   document.getElementById('telefone').value="";	
   document.getElementById('email').value="";	
}

function limpaContato(){
   document.getElementById('msg').value="";	
   document.getElementById('nome').value="";	
   document.getElementById('telefone').value="";	
   document.getElementById('email').value="";	
}

function limpaContatoAss(){
   document.getElementById('msg').value="";	
   document.getElementById('nome').value="";	
   document.getElementById('telefone').value="";	
   document.getElementById('email').value="";	
}

function limpaRepresA(){
   document.getElementById('msg').value      ="";	
   document.getElementById('nome').value     ="";	
   document.getElementById('telefone').value ="";	
   document.getElementById('email').value    ="";	
   document.getElementById('cnpj').value     ="";	
   document.getElementById('cidade').value   ="";	
}

function mOverLink(src){
  src.style.cursor = "pointer";
  src.style.textDecoration = "underline";
}
function mOutLink(src){
  src.style.cursor = "default";
  src.style.textDecoration = "none";
}

function mOverLinkEmpresa(src){
  src.style.cursor = "pointer";
  src.style.textDecoration = "underline";
  src.style.color = "#0B8492";
}
function mOutLinkEmpresa(src){
  src.style.cursor = "default";
  src.style.textDecoration = "none";
  src.style.color = "#808285";
}

function mOverLinks(src){
  src.style.textDecoration = "underline";
  src.style.color = "#E72028";
}
function mOutLinks(src){
  src.style.textDecoration = "none";
  src.style.color= "#FFF";
}


function mOverMenu(img){
  document.getElementById("menu_img").src = "img/"+img;
}
function mOutMenu(img){
  document.getElementById("menu_img").src = "img/"+img;
}

function mOverMenul(img){
  document.getElementById("menu_imgl").src = "img/"+img;
}
function mOutMenul(img){
  document.getElementById("menu_imgl").src = "img/"+img;
}

function TrocaImagem(nome, id){
  document.getElementById("telha_g").src = "img/"+nome;
  document.getElementById("a_telha_g").href = "img/"+nome;
  document.getElementById("nome_telha").innerHTML = id;
}

function EnviarEmailContato()  {
	
	var erro = 0;
	var cor_erro = "#FCC";

    var estado   = document.getElementById('estado');
    var nome     = document.getElementById('nome');
	var cidade   = document.getElementById('cidade');
	var telefone = document.getElementById('telefone');
	var email    = document.getElementById('email');

    if(estado.value == "XX") {
       document.getElementById('estado_div').innerHTML = '<font color="red">Estado deve ser preenchido!</font>';
	   estado.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('estado_div').innerHTML = ' ';
	   estado.style.backgroundColor = "#FFFFFF";
    }

    if(nome.value == "") {
       document.getElementById('nome_div').innerHTML = '<font color="red">Nome deve ser preenchido!</font>';
	   nome.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('nome_div').innerHTML = ' ';
	   nome.style.backgroundColor = "#FFFFFF";
    }

    //Validar E-mail
	if (email.value != "") {
		if (email.value.length > 0) {
		   if (email.value.indexOf('@')==-1 || email.value.indexOf('.')==-1 ) {
			   document.getElementById('email_div').innerHTML = '<font color="red">E-mail Incorreto, deve conter os seguintes caracteres: "@" e "."!</font>';
			   email.style.backgroundColor = cor_erro;
			   erro++;
		   } else  {
			   document.getElementById('email_div').innerHTML = ' ';
			   email.style.backgroundColor = "#FFFFFF";
		   }
		}
	} else {
       document.getElementById('email_div').innerHTML = '<font color="red">E-mail deve ser preenchido!</font>';
	   email.style.backgroundColor = cor_erro;
	   erro++;
	}

    if(cidade.value == "") {
       document.getElementById('cidade_div').innerHTML = '<font color="red">Cidade deve ser preenchido!</font>';
	   cidade.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('cidade_div').innerHTML = ' ';
	   cidade.style.backgroundColor = "#FFFFFF";
    }

    if(telefone.value == "") {
       document.getElementById('telefone_div').innerHTML = '<font color="red">Telefone deve ser preenchido!</font>';
	   telefone.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('telefone_div').innerHTML = ' ';
	   telefone.style.backgroundColor = "#FFFFFF";
    }

	if(erro==0) {
	  document.getElementById('contato_form').submit();
	}
}


function EnviarEmailContatoAss()  {
	
	var erro = 0;
	var cor_erro = "#FCC";

    var msg       = document.getElementById('msg_ass');
    var nome      = document.getElementById('nome_ass');
	var estado    = document.getElementById('estado_ass');
	var email     = document.getElementById('email_ass');
    var nome_loja = document.getElementById('nome_loja_ass');
    var produto   = document.getElementById('produto_ass');
    var telefone  = document.getElementById('telefone_ass');
	
    if(telefone.value == "") {
       document.getElementById('telefone_ass_div').innerHTML = '<font color="red">Telefone deve ser preenchido!</font>';
	   telefone.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('telefone_ass_div').innerHTML = ' ';
	   telefone.style.backgroundColor = "#FFFFFF";
    }
	
    if(msg.value == "") {
       document.getElementById('msg_ass_div').innerHTML = '<font color="red">Mensagem deve ser preenchida!</font>';
	   msg.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('msg_ass_div').innerHTML = ' ';
	   msg.style.backgroundColor = "#FFFFFF";
    }

    if(nome.value == "") {
       document.getElementById('nome_ass_div').innerHTML = '<font color="red">Nome deve ser preenchido!</font>';
	   nome.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('nome_ass_div').innerHTML = ' ';
	   nome.style.backgroundColor = "#FFFFFF";
    }

    //Validar E-mail
	if (email.value != "") {
		if (email.value.length > 0) {
		   if (email.value.indexOf('@')==-1 || email.value.indexOf('.')==-1 ) {
			   document.getElementById('email_ass_div').innerHTML = '<font color="red">E-mail Incorreto, deve conter os seguintes caracteres: "@" e "."!</font>';
			   email.style.backgroundColor = cor_erro;
			   erro++;
		   } else  {
			   document.getElementById('email_ass_div').innerHTML = ' ';
			   email.style.backgroundColor = "#FFFFFF";
		   }
		}
	} else {
       document.getElementById('email_ass_div').innerHTML = '<font color="red">E-mail deve ser preenchido!</font>';
	   email.style.backgroundColor = cor_erro;
	   erro++;
	}

    if(estado.value == "XX") {
       document.getElementById('estado_ass_div').innerHTML = '<font color="red">Estado deve ser preenchido!</font>';
	   estado.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('estado_ass_div').innerHTML = ' ';
	   estado.style.backgroundColor = "#FFFFFF";
    }

    if(nome_loja.value == "") {
       document.getElementById('nome_loja_ass_div').innerHTML = '<font color="red">Nome da loja deve ser preenchido!</font>';
	   nome_loja.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('nome_loja_ass_div').innerHTML = ' ';
	   nome_loja.style.backgroundColor = "#FFFFFF";
    }

    if(produto.value == "") {
       document.getElementById('produto_ass_div').innerHTML = '<font color="red">Produto com defeito deve ser preenchido!</font>';
	   produto.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('produto_ass_div').innerHTML = ' ';
	   produto.style.backgroundColor = "#FFFFFF";
    }
	
	if(erro==0) {
	  document.getElementById('ass_form').submit();
	}
}

function EnviarEmailRepresA()  {
	
	var erro = 0;
	var cor_erro = "#FCC";

    var estado   = document.getElementById('estado');
    var nome     = document.getElementById('nome');
	var cidade   = document.getElementById('cidade');
	var telefone = document.getElementById('telefone');
	var email    = document.getElementById('email');
	var cnpj     = document.getElementById('cnpj');

    if(estado.value == "XX") {
       document.getElementById('estado_div').innerHTML = '<font color="red">Estado deve ser preenchido!</font>';
	   estado.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('estado_div').innerHTML = ' ';
	   estado.style.backgroundColor = "#FFFFFF";
    }

    if(nome.value == "") {
       document.getElementById('nome_div').innerHTML = '<font color="red">Nome deve ser preenchido!</font>';
	   nome.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('nome_div').innerHTML = ' ';
	   nome.style.backgroundColor = "#FFFFFF";
    }

    if(cnpj.value == "") {
       document.getElementById('cnpj_div').innerHTML = '<font color="red">CNPJ deve ser preenchido!</font>';
	   cnpj.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('cnpj_div').innerHTML = ' ';
	   cnpj.style.backgroundColor = "#FFFFFF";
    }

    //Validar E-mail
	if (email.value != "") {
		if (email.value.length > 0) {
		   if (email.value.indexOf('@')==-1 || email.value.indexOf('.')==-1 ) {
			   document.getElementById('email_div').innerHTML = '<font color="red">E-mail Incorreto, deve conter os seguintes caracteres: "@" e "."!</font>';
			   email.style.backgroundColor = cor_erro;
			   erro++;
		   } else  {
			   document.getElementById('email_div').innerHTML = ' ';
			   email.style.backgroundColor = "#FFFFFF";
		   }
		}
	} else {
       document.getElementById('email_div').innerHTML = '<font color="red">E-mail deve ser preenchido!</font>';
	   email.style.backgroundColor = cor_erro;
	   erro++;
	}

    if(cidade.value == "") {
       document.getElementById('cidade_div').innerHTML = '<font color="red">Cidade deve ser preenchido!</font>';
	   cidade.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('cidade_div').innerHTML = ' ';
	   cidade.style.backgroundColor = "#FFFFFF";
    }

    if(telefone.value == "") {
       document.getElementById('telefone_div').innerHTML = '<font color="red">Telefone deve ser preenchido!</font>';
	   telefone.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('telefone_div').innerHTML = ' ';
	   telefone.style.backgroundColor = "#FFFFFF";
    }

	if(erro==0) {
	  document.getElementById('repres_a_form').submit();
	}
}


function EnviarEmailRepresB()  {
	
	var erro = 0;
	var cor_erro = "#FCC";

    var msg       = document.getElementById('msg_ass');
    var nome      = document.getElementById('nome_ass');
	var estado    = document.getElementById('estado_ass');
	var email     = document.getElementById('email_ass');
    var telefone  = document.getElementById('telefone_ass');
    var curriculo = document.getElementById('curriculo_ass');
	
    if(telefone.value == "") {
       document.getElementById('telefone_ass_div').innerHTML = '<font color="red">Telefone deve ser preenchido!</font>';
	   telefone.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('telefone_ass_div').innerHTML = ' ';
	   telefone.style.backgroundColor = "#FFFFFF";
    }
	
    if(msg.value == "") {
       document.getElementById('msg_ass_div').innerHTML = '<font color="red">Mensagem deve ser preenchida!</font>';
	   msg.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('msg_ass_div').innerHTML = ' ';
	   msg.style.backgroundColor = "#FFFFFF";
    }

    if(nome.value == "") {
       document.getElementById('nome_ass_div').innerHTML = '<font color="red">Nome deve ser preenchido!</font>';
	   nome.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('nome_ass_div').innerHTML = ' ';
	   nome.style.backgroundColor = "#FFFFFF";
    }

    //Validar E-mail
	if (email.value != "") {
		if (email.value.length > 0) {
		   if (email.value.indexOf('@')==-1 || email.value.indexOf('.')==-1 ) {
			   document.getElementById('email_ass_div').innerHTML = '<font color="red">E-mail Incorreto, deve conter os seguintes caracteres: "@" e "."!</font>';
			   email.style.backgroundColor = cor_erro;
			   erro++;
		   } else  {
			   document.getElementById('email_ass_div').innerHTML = ' ';
			   email.style.backgroundColor = "#FFFFFF";
		   }
		}
	} else {
       document.getElementById('email_ass_div').innerHTML = '<font color="red">E-mail deve ser preenchido!</font>';
	   email.style.backgroundColor = cor_erro;
	   erro++;
	}

    if(estado.value == "XX") {
       document.getElementById('estado_ass_div').innerHTML = '<font color="red">Estado deve ser preenchido!</font>';
	   estado.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('estado_ass_div').innerHTML = ' ';
	   estado.style.backgroundColor = "#FFFFFF";
    }

    if(curriculo.value == "") {
       document.getElementById('curriculo_ass_div').innerHTML = '<font color="red"Currículo com defeito deve ser preenchido!</font>';
	   curriculo.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('curriculo_ass_div').innerHTML = ' ';
	   curriculo.style.backgroundColor = "#FFFFFF";
    }
	
	if(erro==0) {
	  document.getElementById('repres_b_form').submit();
	}
}

function EnviarEmailProd()  {
	
	var erro = 0;
	
    var nome         = document.getElementById('nome');
    var produto      = document.getElementById('produto');
    var telefone     = document.getElementById('telefone');
	var email        = document.getElementById('email');
	var comentarios  = document.getElementById('comentarios');

    // Validar Nome
    if(nome.value == "") {
       document.getElementById('nome_div').innerHTML = 'Nome deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('nome_div').innerHTML = ' ';
    }

    // Validar Produto
    if(produto.value == "") {
       document.getElementById('produto_div').innerHTML = 'Produto deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('produto_div').innerHTML = ' ';
    }

    // Validar Telefone
    if(telefone.value == "") {
       document.getElementById('telefone_div').innerHTML = 'Telefone deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('telefone_div').innerHTML = ' ';
    }

    //Validar E-mail
	if (email.value != "") {
		if (email.value.length > 0) {
		   if (email.value.indexOf('@')==-1 || email.value.indexOf('.')==-1 ) {
			   document.getElementById('email_div').innerHTML = 'E-mail Incorreto, deve conter os seguintes caracteres: "@" e "."!';
			   erro++;
		   } else  {
			   document.getElementById('email_div').innerHTML = ' ';
		   }
		}
	} else {
       document.getElementById('email_div').innerHTML = 'E-mail deve ser preenchido!';
	   erro++;
	}

    // Validar Comentario
    if(comentarios.value == "") {
       document.getElementById('comentarios_div').innerHTML = 'Coment&aacute;rio deve ser preenchido!';
	   erro++;
    } else {
       document.getElementById('comentarios_div').innerHTML = ' ';
    }

	if(erro==0) {
	  document.getElementById('contato_form').submit();
	}
}

function mask_telefone(e) {
    e.value=e.value.replace(/\D/g,'').replace(/^(\d{4})(\d)/,'$1-$2')
}
function mask_ddd_telefone(e) {
    e.value=e.value.replace(/\D/g,'').replace(/^(\d\d)(\d)/g,'($1) $2').replace(/(\d{4})(\d)/,'$1-$2')
}

function comboTamanho(url,senda,send,tag) {
    variavel = send;
    variavela = senda;
    var send = document.getElementById(send).value;
    var senda = document.getElementById(senda).value;
    XHR_criado.open("post",url,true);
    XHR_criado.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    XHR_criado.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
    XHR_criado.onreadystatechange = SaidaHttpPOSTx;
    XHR_criado.send(variavel+"="+send+"&"+variavela+"="+senda);
    function SaidaHttpPOSTx() {
      if(XHR_criado.readyState!=4) {
	    document.getElementById(tag).innerHTML= "carregando...";
	  }
	  if(XHR_criado.readyState==4) {
	    document.getElementById(tag).innerHTML= XHR_criado.responseText;
      }
    }
}

function favMuda(url,send,div_p)
  {
    XHR_criado.open("get",url+send,true);
    XHR_criado.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    XHR_criado.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
    XHR_criado.onreadystatechange = SaidaHttpPOST;
    XHR_criado.send(null);
    function SaidaHttpPOST()
    {
      if(XHR_criado.readyState!=4)
	  {
	    document.getElementById(div_p).innerHTML= "carregando...";
	  }
	  if(XHR_criado.readyState==4)
	  {
	    document.getElementById(div_p).innerHTML= XHR_criado.responseText;
	  }
    }
}

function MudaIdioma(send, prog)
  {
    XHR_criado.open("get","muda_idioma.php?"+send,true);
    XHR_criado.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
    XHR_criado.setRequestHeader('Cache-Control', 'no-store, no-cache, must-revalidate');
    XHR_criado.onreadystatechange = SaidaHttpPOST;
    XHR_criado.send(null);
    function SaidaHttpPOST()
    {
      if(XHR_criado.readyState!=4)
	  {
	    document.getElementById(id_idioma).innerHTML= "carregando...";
	  }
	  if(XHR_criado.readyState==4)
	  {
	    document.location = prog;
	  }
    }
}

function abreCaracTec(id) {
 if (document.getElementById(id).style.display=="block") {
   document.getElementById(id).style.display="none";
 } else {
   document.getElementById(id).style.display="block";
 }
}
function EnviarEmailContatoSac()  {
	
	var erro = 0;
	var cor_erro = "#FFFF99";
    var cor_erro_txt = "#FFFF99";


    var nome     = document.getElementById('sac_nome'); 
    var email    = document.getElementById('sac_email');
    var msg      = document.getElementById('sac_msg');
    var telefone = document.getElementById('sac_telefone');
	
    if(telefone.value == "") {
       document.getElementById('sac_telefone_div').innerHTML = '<font color="'+cor_erro_txt+'">Telefone deve ser preenchido!</font>';
	   telefone.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('sac_telefone_div').innerHTML = ' ';
	   telefone.style.backgroundColor = "#FFFFFF";
    }

    if(msg.value == "") {
       document.getElementById('sac_msg_div').innerHTML = '<font color="'+cor_erro_txt+'">Mensagem deve ser preenchida!</font>';
	   msg.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('sac_msg_div').innerHTML = ' ';
	   msg.style.backgroundColor = "#FFFFFF";
    }

    if(nome.value == "") {
       document.getElementById('sac_nome_div').innerHTML = '<font color="'+cor_erro_txt+'">Nome deve ser preenchido!</font>';
	   nome.style.backgroundColor = cor_erro;
	   erro++;
    } else {
       document.getElementById('sac_nome_div').innerHTML = ' ';
	   nome.style.backgroundColor = "#FFFFFF";
    }

    //Validar E-mail
	if (email.value != "") {
		if (email.value.length > 0) {
		   if (email.value.indexOf('@')==-1 || email.value.indexOf('.')==-1 ) {
			   document.getElementById('sac_email_div').innerHTML = '<font color="'+cor_erro_txt+'">E-mail Incorreto, deve conter os seguintes caracteres: "@" e "."!</font>';
			   email.style.backgroundColor = cor_erro;
			   erro++;
		   } else  {
			   document.getElementById('sac_email_div').innerHTML = ' ';
			   email.style.backgroundColor = "#FFFFFF";
		   }
		}
	} else {
       document.getElementById('sac_email_div').innerHTML = '<font color="'+cor_erro_txt+'">E-mail deve ser preenchido!</font>';
	   email.style.backgroundColor = cor_erro;
	   erro++;
	}

	if(erro==0) {
	  document.getElementById('sac_form').submit();
	}
}
