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 selectStyle(tit){ /* altera o arquivo css*/
 var s=document.getElementsByTagName("link")
    for(var i=0;i<s.length;i++)
   if(s[i].type=="text/css")s[i].disabled=s[i].title!=tit
 }
 
 function getWordKey(wordKey){
 	 var c=document.getElementById("conteudo01_right")
      c.innerHTML='<IMG SRC="images/load.gif" >Buscando...';
      c.style.border='10px';
 	  c.innerHTML= wordKey;
 }
 
function envia_contato(nome,email,assunto,msg){
var envia = true;
var campoObrigatorio = "Campo(s) obrigatório(s):\n";
if(nome == ""){
	campoObrigatorio += "Nome \n";
    document.getElementById("nome").style.border="1px red solid ";
	envia = false;
}
if(email == ""){
	campoObrigatorio += "Email \n";
    document.getElementById("email").style.border="1px red solid ";
	envia = false;
}

if(assunto == ""){
	campoObrigatorio += "Assunto \n";
    document.getElementById("assunto").style.border="1px red solid ";
	envia = false;
} 

if(msg == ""){
	campoObrigatorio += "Mensagem \n";
    document.getElementById("mensagem").style.border="1px red solid ";
	envia = false;
}

	if(envia){
		  xmlhttp.open("GET", "envia_contato.php?nome="+nome+"&email="+email+"&assunto="+assunto+"&mensagem="+msg+"",true);
		  xmlhttp.onreadystatechange = function() {
		   if (xmlhttp.readyState < 4) {
		   var c = document.getElementById("msg1");
			   c.innerHTML='<IMG SRC="images/load.gif" >Enviando...';
			   c.style.border='10px';
		   }
			if (xmlhttp.readyState == 4) {
				 var texto = xmlhttp.responseText;
				 var conteudo=document.getElementById("msg1");
					  conteudo.innerHTML= texto;
					 document.getElementById("nome").value="";
					 document.getElementById("nome").style.background="#C6C6C6";
					 document.getElementById("email").value="";
					 document.getElementById("email").style.background="#C6C6C6";
					 document.getElementById("mensagem").value="";
					 document.getElementById("mensagem").style.background="#C6C6C6";
					 document.getElementById("assunto").style.background="#C6C6C6";
					 alert('Dados enviados com sucesso!');
		   }
		}  
		xmlhttp.send(null)
	}else{
		alert(campoObrigatorio);		
	}//fim do if que testa o envio
}

 function envia_enquete(id,opt){
 
 if(document.getElementById("opt01").checked == true){
	var opt01 = 1;
	var opt02 = 0;
 }else{
	var opt01 = 0;
	var opt02 = 1;
 }
      xmlhttp.open("GET", "envia_enquete.php?id="+id+"&opt01="+opt01+"&opt02="+opt02+"",true);
      xmlhttp.onreadystatechange = function() {
       if (xmlhttp.readyState < 4) {
       var c = document.getElementById("status");
	       c.innerHTML='<IMG SRC="images/load.gif" >Enviando...';
           c.style.marginTop='10px';
	   }
        if (xmlhttp.readyState == 4) {
             var texto = xmlhttp.responseText;
             document.getElementById('idEnquete').innerHTML= texto;
             document.getElementById("status").style.display = "none";
       }
	}  
    xmlhttp.send(null)
  }
  

function atualizaLink(id){ /**passa o id do menu */

	document.getElementById("prod").style.background="#f6f6f6";
	document.getElementById("consult").style.background="#f6f6f6";
	document.getElementById("criaSite").style.background="#f6f6f6";
	document.getElementById("contato").style.background="#f6f6f6";
	document.getElementById("links").style.background="#f6f6f6";
	
	document.getElementById("prod").style.borderBottom='1px solid #8b795e';
	document.getElementById("consult").style.borderBottom='1px solid #8b795e';
	document.getElementById("criaSite").style.borderBottom='1px solid #8b795e';
	document.getElementById("contato").style.borderBottom='1px solid #8b795e';
	document.getElementById("links").style.borderBottom='1px solid #8b795e';
	
	document.getElementById("prod").style.fontSize='11px';
	document.getElementById("prod").style.borderRight='1px solid #8b795e';
	document.getElementById("consult").style.fontSize='11px';
	document.getElementById("consult").style.borderRight='1px solid #8b795e';
	document.getElementById("criaSite").style.fontSize='11px';
	document.getElementById("criaSite").style.borderRight='1px solid #8b795e';
	document.getElementById("contato").style.fontSize='11px';
	document.getElementById("contato").style.borderRight='1px solid #8b795e';
	document.getElementById("links").style.fontSize='11px';
	document.getElementById("links").style.borderRight='1px solid #8b795e';

	document.getElementById("prod").style.color='#1F4676';
	document.getElementById("consult").style.color='#1F4676';
	document.getElementById("criaSite").style.color='#1F4676';
	document.getElementById("contato").style.color='#1F4676';
	document.getElementById("links").style.color='#1F4676';

    document.getElementById(id).style.background      = '#B6B6B6';
	document.getElementById(id).style.borderBottom    = '2px solid #FFCC00';
	document.getElementById(id).style.backgroundImage = 'url(images/fundo.jpg)';
	document.getElementById(id).style.backgroundRepeat= 'repeat';
	document.getElementById(id).style.color		 	  = '#5E5E5E';
	document.getElementById(id).style.fontSize	 	  = '12px';
	document.getElementById(id).style.borderRight 	  = '2px solid #000';
}

function mostraConteudo(pag,id){/**metodo que retorna a pagina requisitada*/
 var c=document.getElementById("conteudo01_right")
	atualizaLink(id);

      c.innerHTML = "";
      xmlhttp.open("GET", "load_conteudo.php?pag="+pag+"",true);
      xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
      xmlhttp.onreadystatechange=function() {
       if (xmlhttp.readyState < 4) {
       var c=document.getElementById("conteudo01_right")
           c.innerHTML='<IMG SRC="images/pleasewait.gif" >';
           c.style.border='10px';
       }
       if (xmlhttp.readyState == 4) {
            var texto = xmlhttp.responseText;
            var conteudo=document.getElementById("conteudo01_right");
			conteudo.innerHTML = "";
			conteudo.innerHTML= texto;
        }
	}  
    xmlhttp.send(null)
}

function showProduto(detalhe,position,width){

var conteudo=detalhe;
var alt = position;
var width = width;

         document.getElementById("detalheProduto").innerHTML  = "";
		 document.getElementById("detalheProduto").style.background = "#CCCCCC";
 		 document.getElementById("detalheProduto").style.backgroundImage = "url(images/fundoTexto.jpg)";
         document.getElementById("detalheProduto").style.border = "1px solid #FFCC00";
		 document.getElementById("detalheProduto").style.borderTop = "10px solid #FFCC00";
         document.getElementById("detalheProduto").style.color = "#000";
         document.getElementById("detalheProduto").style.marginLeft = width;
         document.getElementById("detalheProduto").style.marginTop = alt;
         document.getElementById("detalheProduto").style.position = "absolute";
		 document.getElementById("detalheProduto").style.padding= "2px";
         document.getElementById("detalheProduto").style.width = "200px";
         document.getElementById("detalheProduto").style.height = "110px";
         document.getElementById("detalheProduto").style.index = 2000;
         document.getElementById("detalheProduto").innerHTML   = conteudo;
}
function hideProduto(){
         document.getElementById("detalheProduto").innerHTML  = "";
         document.getElementById("detalheProduto").style.border="none";
         document.getElementById("detalheProduto").style.width="0px";
         document.getElementById("detalheProduto").style.height="0px";
         document.getElementById("detalheProduto").style.background="#FFF";
         document.getElementById("detalheProduto").style.index=2000;
}

function mostraLayOut(){
	document.getElementById("layout").innerHTML  = "";
	document.getElementById("layout").innerHTML  = "<a href=\"javascript:javascript:hideLayOut()\">Lay-Out</a>";
	document.getElementById("layout").innerHTML += "<a style=\"margin-left:3px; color:#000\" href=\"javascript:selectStyle('default_padrao')\">::Default</a>";
	document.getElementById("layout").innerHTML += "<a style=\"margin-left:3px; color:#000\" href=\"javascript:selectStyle('alternativo1')\">::Opção 01</a>";
	document.getElementById("layout").innerHTML += "<a style=\"margin-left:3px; color:#000\" href=\"javascript:selectStyle('alternativo2')\">::Opção 02</a>";
	document.getElementById("layout").innerHTML += "<a style=\"margin-left:3px; color:#000\" href=\"javascript:selectStyle('alternativo3')\">::Opção 03</a>";

}
function hideLayOut(n){
	document.getElementById("layout").innerHTML  = "";
	document.getElementById("layout").innerHTML  = "<a href=\"javascript:mostraLayOut()\">Lay-Out</a>";
}

function EditaBodyPortfolio(flag){
	var texto1="<div id=\"bodyPortfolio\">";
	var texto2="<div>";

	var tmp=document.getElementById("bodyPortfolio").innerHTML;
	if(flag=='fecha'){//fecha o quadro
		  document.getElementById("bodyPortfolio").innerHTML="";
		  document.getElementById("bodyPortfolio").innerHTML+="<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
	 return;}
				if(flag==true){
					  document.getElementById("bodyPortfolio").innerHTML = "<textarea name=\"teste\" id=\"IdTextArea\" rows=\"7\" cols=\"20\" value=\"Digite o seu texto\" class=\"form_input\">Digite o seu texto</textarea>";
					  flag="";
				  }else{
					  conteudo = document.getElementById("IdTextArea").value;
   					  if(conteudo.length > tmp.length){
							document.getElementById("bodyPortfolio").innerHTML  = texto1;
							document.getElementById("bodyPortfolio").innerHTML  += conteudo;
							document.getElementById("bodyPortfolio").innerHTML  += texto2;
					  }else{
							tmp2 = tmp.length - conteudo.length;
							tmp2="<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
							document.getElementById("bodyPortfolio").innerHTML  = texto1;
							document.getElementById("bodyPortfolio").innerHTML  += conteudo;
							document.getElementById("bodyPortfolio").innerHTML  += tmp2;
							document.getElementById("bodyPortfolio").innerHTML  += texto2;
					  }                  
				}
		  
}

function EditaBodyParceiros(flag){
var texto1="<div id=\"bodyParceiros\">";
var texto2="<div>";

var tmp=document.getElementById("bodyParceiros").innerHTML;

if(flag=='fecha'){//fecha o quadro
      document.getElementById("bodyParceiros").innerHTML="";
      document.getElementById("bodyParceiros").innerHTML+="<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
 return;}

            if(flag==true){
                  document.getElementById("bodyParceiros").innerHTML = "<textarea name=\"teste\" id=\"IdTextArea\" rows=\"10\" cols=\"30\" value=\"Digite o seu texto\" class=\"form_input\">Digite o seu texto</textarea>";
            }else{
                  conteudo = document.getElementById("IdTextArea").value;
                  if(conteudo.length > tmp.length){
                        document.getElementById("bodyParceiros").innerHTML  = texto1;
                        document.getElementById("bodyParceiros").innerHTML  += conteudo;
                        document.getElementById("bodyParceiros").innerHTML  += texto2;
                  }else{
                        tmp2 = tmp.length - conteudo.length;
                        tmp2="<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
                        document.getElementById("bodyParceiros").innerHTML  = texto1;
                        document.getElementById("bodyParceiros").innerHTML  += conteudo;
                        document.getElementById("bodyParceiros").innerHTML  += tmp2;
                        document.getElementById("bodyParceiros").innerHTML  += texto2;
                  }
            }
}

function EditaBodyServicos(flag){
var texto1="<div id=\"bodyServicos\">";
var texto2="<div>";

var tmp=document.getElementById("bodyServicos").innerHTML;

if(flag =='fecha'){//fecha o quadro
      document.getElementById("bodyServicos").innerHTML="";
      document.getElementById("bodyServicos").innerHTML+="<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
 return;}
            if(flag==true){
                  document.getElementById("bodyServicos").innerHTML = "<textarea name=\"teste\" id=\"IdTextArea\" rows=\"5\" cols=\"20\" value=\"Digite o seu texto\" class=\"form_input\">Digite o seu texto</textarea>";
            }else{
                  conteudo = document.getElementById("IdTextArea").value;
                  if(conteudo.length > tmp.length){
                        document.getElementById("bodyServicos").innerHTML  = texto1;
                        document.getElementById("bodyServicos").innerHTML  += conteudo;
                        document.getElementById("bodyServicos").innerHTML  += texto2;
                  }else{
                        tmp2 = tmp.length - conteudo.length;
                        tmp2="<br /><br /><br /><br /><br /><br /><br /><br /><br /><br />";
                        document.getElementById("bodyServicos").innerHTML  = texto1;
                        document.getElementById("bodyServicos").innerHTML  += conteudo;
                        document.getElementById("bodyServicos").innerHTML  += tmp2;
                        document.getElementById("bodyServicos").innerHTML  += texto2;
                  }
            }
}
function busca(pag, model) {
	xmlhttp.open("GET", "load_busca.php?pagina="+pag+"&modelo="+model,true);
      xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded'); 

    xmlhttp.onreadystatechange=function() {
       if (xmlhttp.readyState <4) {
       var c=document.getElementById("conteudo")
            c.innerHTML="<div style=background-color:#FFCC00;border:2px solid #000>....Carregando</div>";
       }
       if (xmlhttp.readyState==4) {
          var c=document.getElementById("conteudo")
              var aDados= xmlhttp.responseText;
/*				  aDados = aDados.replace(/\+/g," ");
				  aDados = unescape(aDados);*/
       		    c.innerHTML = aDados;
       }
	}  
    xmlhttp.send(null)
}

