function setActiveStyleSheet(title) {
   var i, a, main;
   for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
     if(a.getAttribute("rel").indexOf("style") != -1
        && a.getAttribute("title")) {
       a.disabled = true;
       if(a.getAttribute("title") == title) a.disabled = false;
     }
   }
}



function muda(caminho)
{
var imagem = document.getElementById(caminho);
if(imagem.src=="http://www.guiadaembalagem.com.br/2010/images/"+caminho+".jpg"){
imagem.src="http://www.guiadaembalagem.com.br/2010/images/"+caminho+"2.jpg";
}
else{
imagem.src="http://www.guiadaembalagem.com.br/2010/images/"+caminho+".jpg";
}
}

 function pol()
 {
  window.open('pol.php','jav','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=400,fullscreen=no');
 }
 function normas()
 {
  window.open('normas.php','jav','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=700,height=400,fullscreen=no');
 }




function pegapalavra2(palavra)
{
if (palavra != ""){
try {
ajax = new ActiveXObject("Microsoft.XMLHTTP");
} 
catch(e) {
     try {
     ajax = new ActiveXObject("Msxml2.XMLHTTP");
         }
	     catch(ex) {
            try {
	             ajax = new XMLHttpRequest();
            }
	        catch(exc) {
               alert("Esse browser não tem recursos para uso do Ajax");
               ajax = null;
            }
         }
      }
	
	  if(ajax) {
	  ajax.open("POST", "busca_cadastro.php", true);
	  ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		 ajax.onreadystatechange = function() {
         if(ajax.readyState == 1) {
		 document.getElementById("dica").innerHTML = "<img src='images/icon_wait.gif' /><br />Carregando Sugest&otilde;es";  
	     }
		 

         if(ajax.readyState == 2) {
		 document.getElementById("dica").innerHTML = "<img src='images/icon_wait.gif' /><br />Dificuldades em encontrar alguma sugest&atilde;o - Tente clicar no bot&atilde;o <b>PESQUISAR</b></div>";   
	     }		 
		 
		 
		 if(ajax.readyState == 4 ) {
			  if(ajax.responseXML) {
			    processXML2(ajax.responseXML);
			   }
			   else {
			       //caso não seja um arquivo XML emite a mensagem abaixo
				   document.getElementById("dica").innerHTML = "";
			   }
            }
         }
		 //passa o código do estado escolhido
	     var params = "cadastro="+palavra;
         ajax.send(params);
      }

}
}
function processXML2(obj){
var dataArray   = obj.getElementsByTagName("cadastro");
  if(dataArray.length > 0) {
       for(var i = 0 ; i < dataArray.length ; i++) {
            var item = dataArray[i];
			
			var numero = item.getElementsByTagName("numero")[0].firstChild.nodeValue;
			var Resultado = "";
			
			
			if (numero > 0){
			Resultado = "<strong>Palavras :</strong><br>";
			for (var i = 0; i < numero; i++){

			if(i < (numero-1)){
			Resultado = Resultado + item.getElementsByTagName("titulo")[i].firstChild.nodeValue+" - ";
			}
			else{
			Resultado = Resultado + item.getElementsByTagName("titulo")[i].firstChild.nodeValue+"  ";	
			}


			}
			Resultado = Resultado + "<br /><br />";
			}
			
			var numeroo = item.getElementsByTagName("numeroo")[0].firstChild.nodeValue;
			var Resultado2 = "";
			
			Resultado2 = "";
			if (numeroo > 0){
			Resultado2 = "<strong>Empresas :</strong><br>";
			for (var i = 0; i < numeroo; i++){
			
			if(i < (numeroo-1)){
			Resultado2 = Resultado2 + item.getElementsByTagName("empresa")[i].firstChild.nodeValue+" - ";
			}
			else{
			Resultado2 = Resultado2 + item.getElementsByTagName("empresa")[i].firstChild.nodeValue+"  ";	
			}
			
			}
			}
			
			document.getElementById("dica").innerHTML = Resultado + Resultado2;


		 }
	  }
	  else {
		document.getElementById("dica").innerHTML = "";
	  }	  
   }

function submitform(){
document.form_guia.submit();
}
function submitform2(){
document.form_google.submit();
}



function abre_codigo(codigo){
var width;
var height;
var pag;

if(codigo == 'a1'){
    pag = '1';
}
if(codigo == 'a2'){
	pag = '2';
}
if(codigo == 'a3'){
	pag = '3';
}
if(codigo == 'a4'){
	pag = '4';
}
if(codigo == 'a5'){
	pag = '5';
}
if(codigo == 'b1'){
	pag = '6';
}
if(codigo == 'b2'){
	pag = '7';
}
if(codigo == 'b3'){
	pag = '8';
}
if(codigo == 'b4'){
	pag = '9';
}
if(codigo == 'b5'){
	pag = '10';
}


width = 1000;
height = 50;


window.open('Scripts/noticias_js/codigo/pagina.php?cod_pag='+pag,'jav','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+',fullscreen=no');

}


function abre_modelo(codigo){
var width;
var height;
var pag;

if(codigo == 'a1'){
	width = 1015;
	height = 175;
    pag = '2_5.php';
}
if(codigo == 'a2'){
	width = 835;
	height = 175;
	pag = '2_4.php';
}
if(codigo == 'a3'){
	width = 615;
	height = 175;
	pag = '2_3.php';
}
if(codigo == 'a4'){
	width = 420;
	height = 175;
	pag = '2_2.php';
}
if(codigo == 'a5'){
	width = 360;
	height = 175;
	pag = '2_1.php';
}
if(codigo == 'b1'){
	width = 200;
	height = 545;
	pag = '1_5.php';
}
if(codigo == 'b2'){
	width = 200;
	height = 430;
	pag = '1_4.php';
}
if(codigo == 'b3'){
	width = 200;
	height = 365;
	pag = '1_3.php';
}
if(codigo == 'b4'){
	width = 200;
	height = 295;
	pag = '1_2.php';
}
if(codigo == 'b5'){
	width = 200;
	height = 245;
	pag = '1_1.php';
}


width = width + 100;
height = height + 100;


window.open('Scripts/noticias_js/'+pag,'jav','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width='+width+',height='+height+',fullscreen=no');

}

