function TestaNavegador() {
	var nav = 0
	if (/Firefox[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 
		// capture a parcela de x.x e armazene-a como um número
	   var ffversao=new Number(RegExp.$1)
	   //atribua o resultado a variável resultado
	   resultado=("Você estar usando o navegador <b>FireFox "+ffversao+"</b><br />");
	   nav = 1
	}
	//testando se encontrou MSIE x.x
	else if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ 
	   // capture a parcela de x.x e armazene-a como um número
	   var ieversao=new Number(RegExp.$1) 
	   //atribua o resultado a variável resultado
	   resultado=("Você estar usando o navegador <b>Internet Explore "+ieversao+"</b><br />");
	   if(ieversao<7){ //verificando se a versão é inferior ao do IE7
		  //concatenando uma frases e links ao resultado 
		  if(so=="Windows XP"){
			 resultado+="Seu navegador estar completamente desatualizado!!Atualize-o se seu S.O";
			 resultado+="for original:<br />";
			 resultado+='<a href="http://www.baixaki.com.br/download/internet-explorer.htm">';
			 resultado+="Internet Explore 8 para Windows XP</a><br />";
		  }
		  resultado+="Recomendo que instale o navergador Mozilla FireFox:<br />";
		  resultado+='<a href="http://www.baixaki.com.br/download/internet-explorer.htm">';
		  resultado+="Navegador Morzilla FireFox</a><br />";  
	   }
	    nav = 0
	}
	//teste para Opera/x.x ou Opera x.x
	else if (/Opera[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 
	  //capture a parcela de x.x e armazene-a como um número
	  var opversao=new Number(RegExp.$1) 
	  //atribua o resultado a variável resultado
	  resultado=("Você estar usando o navegador <b>Opera "+opversao+"</b><br />");
	  nav = 3
	}
	else if (/Mozilla[\/\s](\d+\.\d+)/.test(navigator.userAgent)){ 
	  //capture a parcela de x.x e armazene-a como um número
	  var opversao=new Number(RegExp.$1) 
	  //atribua o resultado a variável resultado
	  resultado=("Você estar usando o navegador <b>Mozila "+opversao+"</b><br />");
	   nav = 4
	}
	//caso não seja nem destes então atribua o seguinte valor a variável resultado
	else{
	resultado="NÃO DETECTADO!";
	 nav = 5
	}
		//alert(navigator.userAgent)
	return nav
}


var _str = "";
var _timeout = 0;
var win=null;
function NewWindow(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=20}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=no';
win=window.open(mypage,myname,settings);}


function cbboxSearch(sel, e) {
    var i=0, c=true;
    _str = _str + String.fromCharCode(e.keyCode);
    _str = _str.toLowerCase();
    while (c) {
        var textOpt = sel.options[i].text.toLowerCase();
        var strOpt = textOpt.substr(0, (_str.length));
        if (strOpt == _str) {
            sel.options[i].selected = true;
            c = false;
        }
        if (i >= (sel.options.length - 1)) {
            c = false;
        }
        i++;
    }
    clearTimeout(_timeout);
    _timeout = setTimeout("cbboxSearchRestart()", 2000);
}

function cbboxSearchRestart() {
    clearTimeout(_timeout);
    _str = "";
}

function CampoNumerico()
{

  if (parseInt(event.keyCode) < 48 || parseInt(event.keyCode) > 57)
   {
	 event.keyCode = null;
   }
}

function CampoDecimal()
{

  if (parseInt(event.keyCode) < 44 || parseInt(event.keyCode) == 45 || parseInt(event.keyCode) == 46 || parseInt(event.keyCode) == 46 || parseInt(event.keyCode) == 47 || parseInt(event.keyCode) > 57)
  
   {
	 event.keyCode = null;
   }
}

function LimpaCombo(campo) {
var z;
z = campo.length
	for (x=0;x<=z;x++) {
		campo.remove(0);
	}
}
function chamarAjaxCombo(valor,tabela1,tabela2,elemento,nomeDIV, mostrar, selecionar, pg){	
	var nav = 0
	if (valor == 0) {
		
		return false	
	}
	
	
	nav = TestaNavegador()
	
		
	if (nav != 0 && pg != '' ) {
	
		
		if (pg == 'divulgacao.asp') {
			
			var nome = document.form1.nome.value
			var email = document.form1.mail.value
			var agradecimento = document.form1.agradecimento.value
			var divulgacao2 = document.form1.divulgacao2.value
			
			location.href =   pg + '?estadoCod=' + valor + '&nome=' + nome + '&email=' + email + '&agradecimento=' + agradecimento + '&divulgacao2=' + divulgacao2
			
		}else{
			location.href =   pg + '?estadoCod=' + valor + '&estado=' + valor
		}
	}
	
	
	
	
	if (elemento == null ) {
		elemento = document.form3.municipio
	}
	
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<chave>" + valor + "</chave><tabela1>" + tabela1 + "</tabela1><tabela2>" + tabela2 + "</tabela2><mostrar>" + mostrar + "</mostrar>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlCombo.ASP', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;		
	LimpaCombo(elemento);
	objOption = document.createElement("OPTION");
	objOption.text =  "Selecione o(a) "+tabela2
	objOption.value = "0"
	elemento.options.add(objOption)
	lop = 0;
	total = xmlTemp.documentElement.childNodes.length - 1
	
		
	while(lop <= total)
	{
		objOption = document.createElement("OPTION");
		objOption.text =  xmlTemp.getElementsByTagName("descricao")[lop].childNodes[0].nodeValue;
		objOption.value = xmlTemp.getElementsByTagName("codigo")[lop].childNodes[0].nodeValue;
		elemento.options.add(objOption)
		if (selecionar == objOption.value) {
			elemento.options[lop+1].selected = true
		}
		lop++;
	}
	
	if (nomeDIV != '' && nomeDIV != 'nao') {
	
		if (nomeDIV != '' ) {;
			document.getElementById(nomeDIV).style.display = 'block'
		}else{;
			document.getElementById(nomeDIV).style.display = 'none'
	
		}
	
	}
}

function chamarAjaxTexto(valor,tabela1,tabela2,elemento,nomeDIV, mostrar)
{	
	if (elemento == null ) {
		return 
	}
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<chave>" + valor + "</chave><tabela1>" + tabela1 + "</tabela1><tabela2>" + tabela2 + "</tabela2><mostrar>" + mostrar + "</mostrar>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
		
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlCombo.ASP', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;		
	elemento.value= '';
	elemento.value= xmlTemp.getElementsByTagName("descricao")[0].childNodes[0].nodeValue;
	
	if (total > 0){
		if (nomeDIV != 'nao') {
			document.getElementById(nomeDIV).style.display = 'block'
			elemento.disabled = false;
		}
	}
}

function SelectGeralSimples(valor,metodo,combo, div) {;

	if (valor == '' ){
		return false
	}
	
	if (tabela == '' ){
		return false
	}
	
	if (combo == '' ){
		return false
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<valor>" + valor + "</valor>";
	sxml = sxml + "<metodo>" + metodo + "</metodo>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
		
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	
	xmlhttp.Open("POST",'../../plataforma/includes/novo_xmlCombo', false);	xmlhttp.Send(xmldoc);
	
	var xmlTemp = xmlhttp.responseXML;	

	if (div != '' ) {;
		document.getElementById(div).style.display = 'block'
	}else{;
		document.getElementById(div).style.display = 'none'

	}

}

function AtualizaMunicipio() {

total = document.formUfsSelect.iIdMun.length - 1;
lop=1 ;
x=0;
	while(lop <= total)
	
	{
		
		
		
		nome= document.formUfsSelect.iIdMun[lop].text
		codigo= document.formUfsSelect.iIdMun[lop].value
		
			
		if (nome != '' && codigo != '' ) {
		
			var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
			xmldoc.async = false;
			var sxml;	
			sxml = "<ROOT>";
			sxml = sxml + "<nome>" + nome + "</nome>";
			sxml = sxml + "<codigo>" + codigo + "</codigo>";
			sxml = sxml + "</ROOT>";
			sxml = sxml.replace("&","&amp;");
			xmldoc.loadXML(sxml);
			
			var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		
			xmlhttp.Open("POST",'../../plataforma/includes/xmlMunicipio.asp', false);
			xmlhttp.Send(xmldoc);
			var xmlTemp = xmlhttp.responseXML;	
			
			cod= xmlTemp.getElementsByTagName("codigo")[0].childNodes[0].nodeValue;
			
			if (cod == '0' ) {
				alert(nome);
				x= x + 1
			}
		}
		lop++;
	}
	
    alert(x)

}

function PegaCodigoIBGE_CNM(codigo) {
	    
	document.form1.ibge.value = 0
	document.form1.cnm.value = 0
		
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<codigo>" + codigo + "</codigo>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
			
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		
	xmlhttp.Open("POST",'../../plataforma/includes/xmlMunicipio2.asp', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;	
	document.form1.ibge.value = xmlTemp.getElementsByTagName("ibge")[0].childNodes[0].nodeValue;
	document.form1.cnm.value = xmlTemp.getElementsByTagName("cnm")[0].childNodes[0].nodeValue;
	//document.form1.imagem.value = xmlTemp.getElementsByTagName("imagem")[0].childNodes[0].nodeValue;
	//document.getElementById('foto').src='municipioFoto.asp?imagem=' + imagem
	
			
}

function getCheckedValue(radioObj) {
	
   if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";

	
}

function EscolheOpcaoMunicipio(opcao) {
	
	if (opcao == '1'){
		if (parent.document.form1.ibge.value != '' || parent.document.form1.ibge.value != '0' ) {
			document.getElementById('div1').src='http://www.ibge.gov.br/cidadesat/xtras/perfil.php?codmun='+ parent.document.form1.ibge.value + '&r=2' ;
		}else{
			alert('escolha o estado e município');
			parent.document.form1.municipio.focus();
		}
	}else if (opcao == '2') {
		if (parent.document.form1.cnm.value != '' || parent.document.form1.cnm.value != '0' ) {
			document.getElementById('div1').src='http://www.cnm.org.br/dado_geral/mumain.asp?iIdMun='+ parent.document.form1.cnm.value  ;
		}else{
			alert('escolha o estado e município');
			parent.document.form1.municipio.focus();
		}
	}else if (opcao == '3') {
		if (parent.document.form1.ibge.value != '' || parent.document.form1.ibge.value != '0' ) {
			document.getElementById('div1').src='http://cnes.datasus.gov.br/Lista_Es_Municipio.asp?VEstado=29&VCodMunicipio='+ parent.document.form1.ibge.value  ;
		}else{
			alert('escolha o estado e município');
			parent.document.form1.municipio.focus();
		}
	}else if (opcao == '4') {
		if (parent.document.form1.ibge.value != '' || parent.document.form1.ibge.value != '0' ) {
			if (parent.document.form1.estado.value == "1" ) {
				document.form1.uf.value = 'AC'
			}else if (parent.document.form1.estado.value == "2" ) {
				document.form1.uf.value = 'AL'    
			}else if (parent.document.form1.estado.value == "3" ) {
				document.form1.uf.value = 'AM'   
			}else if (parent.document.form1.estado.value == "4" ) {
				document.form1.uf.value = 'AM'   
            }else if (parent.document.form1.estado.value == "5" ) {
				document.form1.uf.value = 'BA'       
            }else if (parent.document.form1.estado.value == "6" ) {
				document.form1.uf.value = 'CE'          
            }else if (parent.document.form1.estado.value == "7" ) {
				document.form1.uf.value = 'DF'         
            }else if (parent.document.form1.estado.value == "8" ) {
				document.form1.uf.value = 'ES'     
            }else if (parent.document.form1.estado.value == "9" ) {
				document.form1.uf.value = 'GO'         
            }else if (parent.document.form1.estado.value == "10" ) {
				document.form1.uf.value = 'MA'         
            }else if (parent.document.form1.estado.value == "11" ) {
				document.form1.uf.value = 'MG'         
            }else if (parent.document.form1.estado.value == "12" ) {
				document.form1.uf.value = 'MS'        
            }else if (parent.document.form1.estado.value == "13" ) {
				document.form1.uf.value = 'MT'        
            }else if (parent.document.form1.estado.value == "14" ) {
				document.form1.uf.value = 'PA' 
			}else if (parent.document.form1.estado.value == "15" ) {
				document.form1.uf.value = 'PB'   
            }else if (parent.document.form1.estado.value == "16" ) {
				document.form1.uf.value = 'PE'    
			}else if (parent.document.form1.estado.value == "17" ) {
				document.form1.uf.value = 'PI'   
            }else if (parent.document.form1.estado.value == "18" ) {
				document.form1.uf.value = 'PR'   
            }else if (parent.document.form1.estado.value == "19" ) {
				document.form1.uf.value = 'RJ'          
			}else if (parent.document.form1.estado.value == "20" ) {
				document.form1.uf.value = 'RN'                     
			}else if (parent.document.form1.estado.value == "21" ) {
				document.form1.uf.value = 'RO'                     
            }else if (parent.document.form1.estado.value == "22" ) {
				document.form1.uf.value = 'RR'        
            }else if (parent.document.form1.estado.value == "23" ) {
				document.form1.uf.value = 'RS'         
            }else if (parent.document.form1.estado.value == "24" ) {
				document.form1.uf.value = 'SC'        
            }else if (parent.document.form1.estado.value == "25" ) {
				document.form1.uf.value = 'SE'         
            }else if (parent.document.form1.estado.value == "26" ) {
				document.form1.uf.value = 'SP'         
			}else if (parent.document.form1.estado.value == "27" ) {
				document.form1.uf.value = 'TO'                     
			}
			
			//document.getElementById('div1').src='http://www.tse.gov.br/sieeeleitoradoweb/eleitorado/sexo_grau/redireciona.jsp?uf=BA' ;
			//document.getElementById('div1').src='http://www.tse.gov.br/sieeeleitoradoweb/eleitorado/sexo_faixa_etaria/resultado.jsp'
			//document.getElementById('div1').src='http://www.tse.gov.br/sieeeleitoradoweb/eleitorado/sexo_faixa_etaria/redireciona.jsp?tipo_pesquisa=UF'
			//document.getElementById('div1').src='http://www.tse.gov.br/sieeeleitoradoweb/eleitorado/sexo_faixa_etaria/resultado.jsp'
			//http://www.tse.gov.br/internet/eleicoes/2006/result_vot_blank.htm
			//document.getElementById('div1').src='municipio_tse.asp?' + parent.document.form1.municipio.value + '&nome2=' + nome2
			
			document.getElementById('div1').src='http://www.tse.gov.br/internet/eleicoes/distr_etaria_blank.htm' 
		}else{
			alert('escolha o estado e município');
			parent.document.form1.municipio.focus();
		}
		
	}else if (opcao == '5') {
		obj= parent.document.form1.municipio;
		nome2=  obj.options[obj.selectedIndex].text;
		document.getElementById('div1').src='municipio3.asp?municipio=' + parent.document.form1.municipio.value + '&nome2=' + nome2
		
	}else if (opcao == '6') {
		obj= parent.document.form1.municipio;
		nome2=  obj.options[obj.selectedIndex].text;
		document.getElementById('div1').src='http://www.stn.fazenda.gov.br/estados_municipios/municipios.asp'
	}else if (opcao == '7') {
		document.getElementById('div1').src='http://tabnet.datasus.gov.br/tabdata/cadernos/cadernosmap.htm?saude=http%3A%2F%2Ftabnet.datasus.gov.br%2Ftabdata%2Fcadernos%2Fcadernosmap.htm&botaook=OK&obj=http%3A%2F%2Ftabnet.datasus.gov.br%2Ftabdata%2Fcadernos%2Fcadernosmap.htm'
	}else if (opcao == '8') {
		obj= parent.document.form1.municipio;
		nome2=  obj.options[obj.selectedIndex].text;
		document.getElementById('div1').src='municipio4.asp?municipio=' + parent.document.form1.municipio.value + '&nome2=' + nome2
		
	}else if (opcao == '99') {
		obj= parent.document.form1.municipio;
		nome2=  obj.options[obj.selectedIndex].text;
		document.getElementById('div1').src='formatar2.asp?municipio=' + parent.document.form1.municipio.value + '&nome2=' + nome2

	}

}

function CalculaAmostra() {
	
	N = document.form1.NN.value;
	Eo = document.form1.Eo.value;
	
	Eo =  Eo/ 100 *  Eo/100;
	no =  1 / Eo;
	no = Math.round(no);
	document.form1.no.value = no;
	
	n1= eval(N) * eval(document.form1.no.value) ;
	n2= eval(N) + eval(document.form1.no.value);
	n= n1/n2;
	n = Math.round(n);
	
	document.form1.a.value = n;

}

function CalculaErroAmostral() {
	
	no = document.form1.a.value ;
		
	e2 = Math.sqrt(1,2);
	e3=  Math.sqrt(eval(no),2);
	
	e4=  (e2/e3) *100;
	
	//e4 = Math.ceil(e4);
	e4= e4.toString();	
	document.form1.e2.value= e4.substring(0,3);

}

function CalculaEntrevista() {
	
	if (document.form1.senha.value == '' || document.form1.senha.value != 'WIN' ) {
		
		e = eval(document.form1.entrevista.value);
		valor= 0;
		
		for(var i = 1; i < e; i++) {
			
			if ( i >= 1 && i <= 10 ) {
				
				valor= valor + 0.5
				
			}else if ( i >= 11 && i <= 20 ) {
				
				valor= valor + 0.55
				
			}else if ( i >= 21 && i <= 30 ) {
				
				valor= valor + 0.60
				
			}else if ( i >= 31 && i <= 40 ) {
				
				valor= valor + 0.65
				
			}else if ( i >= 41 && i <= 50 ) {
				
				valor= valor + 0.70
			
			}else if ( i >= 51 && i <= 60 ) {
				
				valor= valor + 0.75
				
			}else if ( i >= 61 && i <= 70 ) {
				
				valor= valor + 0.80
				
			}else if ( i >= 71 && i <= 80 ) {
				
				valor= valor + 0.85
				
			}else if ( i >= 81 && i <= 90 ) {
				
				valor= valor + 0.90
			
			}else if ( i >= 91 && i <= 100 ) {
				
				valor= valor + 0.95
				
			}else if ( i >= 101 && i <= 110 ) {
	
				valor= valor + 1.00
				
			}else if ( i >= 111 && i <= 120 ) {
				
				valor= valor + 1.05
				
			}else if ( i >= 121 && i <= 130 ) {
				
				valor= valor + 1.10
				
			}else if ( i >= 131 && i <= 140 ) {
				
				valor= valor + 1.15
				
			}else if ( i >= 141 && i <= 150 ) {
				
				valor= valor +  1.20
			
			
			}
			
		}
		
		valor= Math.round(valor)
		
		document.form1.valor.value=  valor;
		
	}else{
		
		alert('Senha inválida');
		
		document.form1.senha.focus();
		
	}
	

}

function CadastraPopulacao() {
	
	ibge= document.form1.ibge.value;
	populacao= document.form1.pop2007.value;
	
	if (ibge == '') {
	
		alert('informe o municipio') ;
		
		parent.document.form1.estado.focus();
		
		return false
		
	}
	
	if (populacao == '' || populacao == 0) {
	
		alert('informe a populacao') ;
		
		document.form1.pop2007.focus();
		
		return false
		
	}
	
	if (document.form1.senha.value == '' || document.form1.senha.value != 'WIN' ) {
		
		alert('informe a senha') ;
		
		document.form1.senha.focus();
		
		return false
		
	}
	
	
	populacao = populacao.replace('.' , '' )
	
	populacao = populacao.replace('.' , '' )
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<ibge>" + ibge + "</ibge>";
	sxml = sxml + "<populacao>" + populacao + "</populacao>";

	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
			
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		
	xmlhttp.Open("POST",'../../plataforma/includes/xmlMunicipio3.asp', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;	
			
	if (xmlTemp.getElementsByTagName("ibge")[0].childNodes[0].nodeValue == '0') {;
	
		alert('Registro atualizado com sucesso!')
	}
	
	obj= parent.document.form1.municipio;
	nome2=  obj.options[obj.selectedIndex].text;
	parent.document.getElementById('div1').src='municipio2.asp?ibge=' + document.form1.ibge.value + '&nome2=' + nome2

	
	
}

function CampoDecimal()
{

  if (parseInt(event.keyCode) < 44 || parseInt(event.keyCode) == 45 || parseInt(event.keyCode) == 46 || parseInt(event.keyCode) == 46 || parseInt(event.keyCode) == 47 || parseInt(event.keyCode) > 57)
  
   {
	 event.keyCode = null;
   }
}

function CampoNumerico()
{

  if (parseInt(event.keyCode) < 48 || parseInt(event.keyCode) > 57)
   {
	 event.keyCode = null;
   }
}

function CadastraPesquisa() {
	
	municipio = document.form1.nome.value;
	exposto= document.form1.NN.value;
	amostrainicial= document.form1.no.value;
	amostrafinal= document.form1.a.value;
	erroamostral= document.form1.Eo.value;
	
	nomePesquisa= document.form1.nomePesquisa.value;
	tipopesquisa= document.form1.tipopesquisa.value;
	empresa= document.form1.empresa.value;
	cliente= document.form1.cliente.value;
	usuario= document.form1.usuario.value;
	datainicial= document.form1.datainicial.value;
	datafinal= document.form1.datafinal.value;
	
	//
	
	apresentacao= document.form1.apresentacao.value;
	objeto= document.form1.objeto.value;
	metodologia= document.form1.metodologia.value;
	localizacao= document.form1.localizacao.value;
	universo= document.form1.universo.value;
	amostra= document.form1.amostra.value;
	variaveis= document.form1.variaveis.value;
	coleta= document.form1.coleta.value;
	qualidade= document.form1.qualidade.value;
	conclusao= document.form1.conclusao.value;
	registro= document.form1.registro.value;
	ordem= document.form1.ordem.value;
	
	//
	
	publicar= document.form1.publicar.checked;
	enquete= document.form1.enquete.checked;
	telemarketing= document.form1.telemarketing.checked;
	destaque= document.form1.destaque.checked;
	prova= document.form1.prova.checked;
	criterio= document.form1.criterio.checked;
	site= document.form1.site.checked;
	
	z = document.form1.tabelas.value;
	y=0
	cString= ""
	cString2= ""
	
	
	if (municipio == '') { 
	
		alert('Escolha o município');
		
		parent.document.form1.municipio.focus();
		
		return false;
		
	}

	if (exposto == '') { 
	
		alert('Informe o número de expostos para a pesquisa');
		
		document.form1.NN.focus();
		
		return false;
		
	}
	
	if (amostrainicial == '') { 
	
		alert('Informe a amostra inicial para a pesquisa');
		
		document.form1.no.focus();
		
		return false;
		
	}
	
	if (amostrafinal == '') { 
	
		alert('Informe a amostra final para a pesquisa');
		
		document.form1.a.focus();
		
		return false;
		
	}
	
	if (erroamostral == '') { 
	
		alert('Informe o erro amostral para a pesquisa');
		
		document.form1.Eo.focus();
		
		return false;
		
	}
	
	if (nomePesquisa == '') { 
	
		alert('Informe o nome  para a pesquisa');
		
		document.form1.nomePesquisa.focus();
		
		return false;
		
	}
	
	if (tipopesquisa == '0') { 
	
		alert('Informe o tipo de pesquisa  para a pesquisa');
		
		document.form1.tipopesquisa.focus();
		
		return false;
		
	}
	
	if (empresa == '0') { 
	
		alert('Informe a empresa  para a pesquisa');
		
		document.form1.empresa.focus();
		
		return false;
		
	}
	
	if (cliente == '0') { 
	
		alert('Informe o cliente  para a pesquisa');
		
		document.form1.cliente.focus();
		
		return false;
		
	}
	
	if (usuario == '0') { 
	
		alert('Informe o usuario  para a pesquisa');
		
		document.form1.usuario.focus();
		
		return false;
		
	}
	
	if (datainicial != '') { 
	
		if ( validaData(document.form1.datainicial,datainicial) == false ) {
		
			document.form1.datainicial.focus();
		
			return false;
		}
		
	}
	
	if (datafinal != '') { 
	
		if ( validaData(document.form1.datafinal,datafinal) == false ) {
			
					
			document.form1.datafinal.focus();
		
			return false;
		}
		
	}
	
	
	if (ordem == '0') { 
	
		alert('Informe a ordem  para a pesquisa');
		
		document.form1.ordem.focus();
		
		return false;
		
	}
	
	if (publicar == true) { 
	
		publicar = 1
		
	}else{
		
		publicar = 0
	
		
	}
	
	alert(publicar)
	

	
	if (enquete == true) { 
	
		enquete = 1
		
	}else{
		
		enquete = 0
	
		
	}
	
	if (telemarketing == true) { 
	
		telemarketing = 1
		
	}else{
		
		telemarketing = 0
	
		
	}
	
	if (destaque == true) { 
	
		destaque = 1
		
	}else{
		
		destaque = 0
	
		
	}
	
	if (prova == true) { 
	
		prova = 1
		
	}else{
		
		prova = 0
	
		
	}

	if (criterio == true) { 
	
		criterio = 1
		
	}else{
		
		criterio = 0
	
		
	}
	
	if (site == true) { 
	
		site = 1
		
	}else{
		
		site = 0
	
		
	}
	
	for (x=1;x<=z;x++) {
		
		y++
		s = eval('document.form1.T' + y.toString() + '.checked')
		t = eval('document.form1.T' + y.toString() + '.value')
		o = eval('document.form1.O' + y.toString() + '.value')
		
		if (s == true) {
			//cString = cString + t + "/" + o +  ";"
			cString = cString + t +   ","
			cString2 = cString2 + o +   ","
		}
	}
	
	if (y== 0 ) {
		
		alert('Você não informou nenhuma pergunta sociológica');
			
		document.form1.datafinal.focus();
		
		return false;
		
	}
		

	
	
	if (!confirm('Deseja incluir uma nova pesquisa para o municipio de '+ municipio)) {
		
		return false
	}
	
	
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<municipio>" + municipio + "</municipio>";
	sxml = sxml + "<exposto>" + exposto + "</exposto>";
	sxml = sxml + "<amostrainicial>" + amostrainicial + "</amostrainicial>";
	sxml = sxml + "<amostrafinal>" + amostrafinal + "</amostrafinal>";
	sxml = sxml + "<erroamostral>" + erroamostral + "</erroamostral>";
			
	sxml = sxml + "<nomePesquisa>" + nomePesquisa + "</nomePesquisa>";
	sxml = sxml + "<tipopesquisa>" + tipopesquisa + "</tipopesquisa>";
	sxml = sxml + "<empresa>" + empresa + "</empresa>";
	sxml = sxml + "<cliente>" + cliente + "</cliente>";
	sxml = sxml + "<usuario>" + usuario + "</usuario>";
	sxml = sxml + "<datainicial>" + datainicial + "</datainicial>";
	sxml = sxml + "<datafinal>" + datafinal + "</datafinal>";
	sxml = sxml + "<cString>" + cString + "</cString>";
	sxml = sxml + "<cString2>" + cString2 + "</cString2>";
	
	sxml = sxml + "<apresentacao>" +apresentacao+ "</apresentacao>";
	sxml = sxml + "<objeto>" +objeto+ "</objeto>";;
	sxml = sxml + "<metodologia>" +metodologia+ "</metodologia>";
	sxml = sxml + "<localizacao>" +localizacao+ "</localizacao>";
	sxml = sxml + "<universo>" +universo+ "</universo>";
	sxml = sxml + "<amostra>" +amostra+ "</amostra>";
	sxml = sxml + "<variaveis>" +variaveis+ "</variaveis>";
	sxml = sxml + "<coleta>" +coleta+ "</coleta>";;
	sxml = sxml + "<qualidade>" +qualidade+ "</qualidade>";
	sxml = sxml + "<conclusao>" +conclusao+ "</conclusao>";
	sxml = sxml + "<registro>" +registro+ "</registro>";
	
	//
	
	sxml = sxml + "<publicar>" +publicar+ "</publicar>";
	sxml = sxml + "<enquete>" +enquete+ "</enquete>";
	sxml = sxml + "<telemarketing>" +telemarketing+ "</telemarketing>";
	sxml = sxml + "<destaque>" +destaque+ "</destaque>";
	sxml = sxml + "<prova>" +prova+ "</prova>";
	sxml = sxml + "<criterio>" +criterio+ "</criterio>";
	sxml = sxml + "<site>" +site+ "</site>";
	sxml = sxml + "<ordem>" +ordem+ "</ordem>";

	
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
			
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		
	xmlhttp.Open("POST",'../../plataforma/includes/xmlPesquisa.asp', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;	
	
		
	if (xmlTemp.getElementsByTagName("pesquisa")[0].childNodes[0].nodeValue != '0') {;
	
		alert('Pesquisa criada com sucesso! ' +  xmlTemp.getElementsByTagName("pesquisa")[0].childNodes[0].nodeValue)
		
		ChamarPesquisa(xmlTemp.getElementsByTagName("pesquisa")[0].childNodes[0].nodeValue)
		
		ChamarAjaxTabela('pesquisa', document.form1.pesquisa, 1, xmlTemp.getElementsByTagName("pesquisa")[0].childNodes[0].nodeValue)
	}
	
}
function ChamarAjaxTabelaSociologica(tabela, elemento, nomeDIV, ordem) {
	
		
	if (elemento == null ) {
		return 
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<tabela>" +tabela + "</tabela>";
	sxml = sxml + "<ordem>" + ordem + "</ordem>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlSociologica.ASP', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;		
	LimpaCombo(elemento);
	objOption = document.createElement("OPTION");
	objOption.text =  "Desmarque para nao incluir"
	objOption.value = "0"
	elemento.options.add(objOption)
	lop = 0;
	total = xmlTemp.documentElement.childNodes.length - 1
	
	while(lop <= total)
	{
		
		objOption = document.createElement("OPTION");
		objOption.text =  xmlTemp.getElementsByTagName("descricao")[lop].childNodes[0].nodeValue;
		objOption.value = xmlTemp.getElementsByTagName("codigo")[lop].childNodes[0].nodeValue;
		elemento.options.add(objOption)
		elemento.options[lop+1].selected = true
		pergunta= xmlTemp.getElementsByTagName("pergunta")[lop].childNodes[0].nodeValue

		lop++;
	}
	

	if (total > 0){
		if (nomeDIV != 'nao') {
			document.getElementById(nomeDIV).style.display = 'none'
			document.getElementById(nomeDIV).style.display = 'block'
			elemento.disabled = false;
			
		}
	}
	
	//obj= document.form1.sociologica_pergunta;
	//document.form1.texto.value= pergunta //obj.options[obj.selectedIndex].text;
}
	
function CadastraPerguntaSociologica() {
	
	pesquisa = document.form1.pesquisa.value;
	pergunta= document.form1.texto.value;
	len= document.form1.opcaosociologica.length ;
	obj= document.form1.opcaosociologica;
	document.form1.pesquisaCod.value = pesquisa
	
	ordem= document.form1.ordem.value;
	qualitativa = document.form1.qualitativa.checked;
	obrigatorio= document.form1.obrigatorio.checked;
	sociologica= document.form1.sociologica.checked;
	cceb= document.form1.cceb.checked;
	cruzamento=document.form1.cruzamento.checked;
	
	if (qualitativa == true) {
		
		qualitativa = 1;
		
	}else{
		
		qualitativa = 0;
		
	}
	
	if (obrigatorio == true) {
		
		obrigatorio = 1;
		
	}else{
		
		obrigatorio = 0;
		
	}
	
	if (sociologica == true) {
		
		sociologica = 1;
		
	}else{
		
		sociologica = 0;
		
	}
	
	if (cceb == true) {
		
		cceb = 1;
		
	}else{
		
		cceb = 0;
		
	}
	
	if (cruzamento == true) {
		
		cruzamento = 1;
		
	}else{
		
		cruzamento = 0;
		
	}
	
	
	
	if (pesquisa == '' ) {
		
		alert('Selecione a pesquisa');
		
		return false
	}
	
	if (pergunta == '' ) {
		
		alert('Selecione a pergunta');
		
		return false
	}
	
	
	
	opcoes= '';
	for(var i = 1; i < len; i++) {
		if(obj[i].selected) {
			opcoes = opcoes + obj.options[i].text + ','
			
		}
	}
	len= opcoes.length
	opcoes = opcoes.substring(0, len - 1)
	
	if (opcoes == '' ) {
		
		alert('Selecione pelo menos uma opcao');
		
		return false
		
	}

	if (!confirm('Deseja incluir pergunta sociologica ? ')) {
		
		return false
	}
	
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	

	sxml = sxml + "<pesquisa>" + pesquisa + "</pesquisa>";
	sxml = sxml + "<pergunta>" + pergunta + "</pergunta>";
	sxml = sxml + "<opcoes>"   + opcoes   + "</opcoes>";
	sxml = sxml + "<ordem>"   + ordem   + "</ordem>";
	sxml = sxml + "<qualitativa>"   + qualitativa   + "</qualitativa>";
	sxml = sxml + "<obrigatorio>"   + obrigatorio   + "</obrigatorio>";
	sxml = sxml + "<sociologica>"   + sociologica   + "</sociologica>";
	sxml = sxml + "<cceb>"   + cceb   + "</cceb>";
	sxml = sxml + "<cruzamento>"   + cruzamento   + "</cruzamento>";
	
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
			
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		
	xmlhttp.Open("POST",'../../plataforma/includes/xmlIncluirSociologica.asp', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;	
			
	if (xmlTemp.getElementsByTagName("pergunta")[0].childNodes[0].nodeValue != '0') {;
	
		alert('Pergunta e opcoes criadas  com sucesso!')
		
		document.form1.ordem.value= eval(ordem) + 1
	}
	
	chamarAjaxCombo(pesquisa,'pesquisa','pergunta',document.form1.pergunta,'perguntaDIV', '1')
}

function SelecionaEstatistica(pesquisa, estatistica ) {
	
		document.form1.estatistica.value= estatistica;
						
		if (document.form1.estatistica.value !=  '' ) {
		
			//location.href = '../plataforma/questionario4.asp?pesquisaCod=' + pesquisa +   '&param=pesq&estatistica=' + estatistica 
			document.getElementById('questionario').src='../plataforma/questionario4a.asp?pesquisaCod=' + pesquisa +   '&param=pesq&estatistica=' + estatistica 
		
		}
				
	
}

function SelecionaQualidade(pesquisa, estatistica ) {
	
		document.form1.estatistica.value= estatistica;
						
		if (document.form1.estatistica.value !=  '' ) {
		
			//location.href = '../plataforma/questionario4.asp?pesquisaCod=' + pesquisa +   '&param=pesq&estatistica=' + estatistica 
			document.getElementById('questionario').src='../plataforma/questionario4c.asp?pesquisaCod=' + pesquisa +   '&param=pesq&estatistica=' + estatistica 
		
		}
				
	
}
function CadastrarSubOpcao(pesquisa, pergunta, opcao, pesquisaNome, estatistica, usuario, controle, elemento) {
	
	so= opcao.toString()
	
	nome = eval('document.form1.S' + so + '.value' ) ;
	
		
	if (nome == '' ) {
		
		alert('Informe o nome da subopcao');
		
		return false
	}
	
	if (pesquisa == '' ) {
		
		alert('Selecione a pesquisa');
		
		return false
	}
	
	if (pergunta == '' ) {
		
		alert('Selecione a pergunta');
		
		return false
	}	
	
	if (opcao == '' ) {
		
		alert('Selecione a pergunta');
		
		return false
	}	
	
	if (!confirm('Deseja incluir uma subopcao para esta opcao ? ')) {
		
		return false
	}
	// verificação da busca
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";

	sxml = sxml + "<nome>" + nome + "</nome>";
	sxml = sxml + "<pesquisa>" + pesquisa + "</pesquisa>";
	sxml = sxml + "<pergunta>" + pergunta + "</pergunta>";
	sxml = sxml + "<opcao>"   + opcao   + "</opcao>";
	
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
			
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		
	xmlhttp.Open("POST",'../../plataforma/includes/xmlSubOpcao3.asp', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;	
			
	if (xmlTemp.getElementsByTagName("codigo")[0].childNodes[0].nodeValue == '0') {;
	
		alert('ATENÇÃO: SubOpcao solicitada já existe!') ;
		
		if (!confirm('Deseja incluir a subopção para esta opção mesmo assim ? ')) {
		
			return false
		}
		
	}
	
		
	// inclusao
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";

	sxml = sxml + "<nome>" + nome + "</nome>";
	sxml = sxml + "<pesquisa>" + pesquisa + "</pesquisa>";
	sxml = sxml + "<pergunta>" + pergunta + "</pergunta>";
	sxml = sxml + "<opcao>"   + opcao   + "</opcao>";
	
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
			
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		
	xmlhttp.Open("POST",'../../plataforma/includes/xmlSubOpcao.asp', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;	
			
	if (xmlTemp.getElementsByTagName("descricao")[0].childNodes[0].nodeValue != '0') {;
	
		alert('SubOpcao criada com sucesso!') ;
			
		document.form1.estatistica.value= estatistica;
		
		document.form1.pesquisaNome.value= pesquisaNome;	
		
		document.form1.usuario.value= usuario;
		
		document.form1.controle.value = controle;
		
		elemento = eval(elemento);
		
		if (elemento != null) {
		
			// seleção
			var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
			xmldoc.async = false;
			var sxml;	
			sxml = "<ROOT>";
		
			sxml = sxml + "<pesquisa>" + pesquisa + "</pesquisa>";
			sxml = sxml + "<pergunta>" + pergunta + "</pergunta>";
			sxml = sxml + "<opcao>"   + opcao   + "</opcao>";
			
			sxml = sxml + "</ROOT>";
			sxml = sxml.replace("&","&amp;");
			xmldoc.loadXML(sxml);
					
			var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				
			xmlhttp.Open("POST",'../../plataforma/includes/xmlSubOpcao2.asp', false);
			xmlhttp.Send(xmldoc);
			var xmlTemp = xmlhttp.responseXML;	
			
			
			
			
			LimpaCombo(elemento);
			objOption = document.createElement("OPTION");
			objOption.text =  "Selecione a sub-opção "
			objOption.value = "0"
			elemento.options.add(objOption)
			lop = 0;
			total = xmlTemp.documentElement.childNodes.length - 1
			while(lop <= total)
			{
				objOption = document.createElement("OPTION");
				objOption.text =  xmlTemp.getElementsByTagName("descricao")[lop].childNodes[0].nodeValue;
				objOption.value = xmlTemp.getElementsByTagName("codigo")[lop].childNodes[0].nodeValue;
				elemento.options.add(objOption)
				nome2 = xmlTemp.getElementsByTagName("descricao")[lop].childNodes[0].nodeValue .replace(/^\s+|\s+$/g,"");
				nome= nome.replace(/^\s+|\s+$/g,"");
				if ( nome2 == nome ) {
					elemento.options[lop + 1].selected = true
					//elemento.value= nome2
				}
				lop++;
			}
		
		}else {
				
			if (document.form1.estatistica.value !=  '' ) {
			
				location.href = '../plataforma/questionario4a.asp?pesquisaCod=' + pesquisa +  '&pesquisaNome=' +  pesquisaNome + '&logo=0' + '&param=pesq&estatistica=' + estatistica + '&usuario=' + usuario +  '&controle=' + controle
				
			}else{
				
				location.href = '../plataforma/questionario4a.asp?pesquisaCod=' + pesquisa +  "&pesquisaNome=" +  pesquisaNome + "&logo=0" 
				
			}
		
		}
	}
	
	eval('document.form1.S' + so + '.focus()' ) ;
}

function SelecionaEstatisticaPergunta(pesquisa, pergunta) {
	

						
		if (pergunta !=  '' ) {
		
			location.href = '../plataforma/questionario4.asp?pesquisaCod=' + pesquisa +   '&param=perg&pergunta=' + pergunta 
			
		
		}
				
	
}

function CopiaResposta(resposta, subopcao) {
	
	subopcao.value = resposta.value
	
}

function CadastraPesquisaSelecionada() {
	
	municipio = document.form1.nome.value;
	exposto= document.form1.NN.value;
	amostrainicial= document.form1.no.value;
	amostrafinal= document.form1.a.value;
	erroamostral= document.form1.Eo.value;
	pesquisa= document.form1.pesquisa.value;
	
	if (municipio == '') { 
	
		alert('Escolha o município');
		
		parent.document.form1.municipio.focus();
		
		return false;
		
	}

	if (exposto == '') { 
	
		alert('Informe o número de expostos para a pesquisa');
		
		document.form1.NN.focus();
		
		return false;
		
	}
	
	if (amostrainicial == '') { 
	
		alert('Informe a amostra inicial para a pesquisa');
		
		document.form1.no.focus();
		
		return false;
		
	}
	
	if (amostrafinal == '') { 
	
		alert('Informe a amostra final para a pesquisa');
		
		document.form1.a.focus();
		
		return false;
		
	}
	
	if (erroamostral == '') { 
	
		alert('Informe o erro amostral para a pesquisa');
		
		document.form1.Eo.focus();
		
		return false;
		
	}
	
	if (pesquisa == '') { 
	
		alert('Informe a pesquisa de base para a nova');
		
		document.form1.pesquisa.focus();
		
		return false;
		
	}
	
	if (!confirm('Deseja incluir uma nova pesquisa para o municipio de '+ municipio)) {
		
		return false
	}
	
	
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<municipio>" + municipio + "</municipio>";
	sxml = sxml + "<exposto>" + exposto + "</exposto>";
	sxml = sxml + "<amostrainicial>" + amostrainicial + "</amostrainicial>";
	sxml = sxml + "<amostrafinal>" + amostrafinal + "</amostrafinal>";
	sxml = sxml + "<erroamostral>" + erroamostral + "</erroamostral>";
	sxml = sxml + "<erroamostral>" + erroamostral + "</erroamostral>";
	sxml = sxml + "<pesquisa>" + pesquisa + "</pesquisa>";

	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
			
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		
	xmlhttp.Open("POST",'../../plataforma/includes/xmlPesquisa2.asp', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;	
			
	if (xmlTemp.getElementsByTagName("pesquisa")[0].childNodes[0].nodeValue > '0' ) {;
	
		alert('Pesquisa criada com sucesso com o numero:' + xmlTemp.getElementsByTagName("pesquisa")[0].childNodes[0].nodeValue )
	}
	
}

function CadastraEntrevistador() {
	
	
	
	nome= document.form3.nome.value
	
	if (nome == '') {
		
		alert('Nome nao pode ser em branco')
		
		document.form3.nome.focus()
		
		return false
		
	}
	
	sexo= document.form3.sexo.value
	
	if (sexo == '0') {
		
		alert('Selecione o Sexo')
		
		document.form3.sexo.focus()
		
		return false
		
	}
	
	dia= document.form3.dia.value
	
		
	if (dia == '0') {
		
		alert('Selecione o dia de aniversario')
		
		document.form3.dia.focus()
		
		return false
		
	}
	
	mes= document.form3.mes.value
	
	if (mes == '0') {
		
		alert('Selecione o mes de aniversario')
		
		document.form3.mes.focus()
		
		return false
		
	}
	
	ano= document.form3.ano.value
	
	if (ano == '0') {
		
		alert('Selecione o ano de aniversario')
		
		document.form3.ano.focus()
		
		return false
		
	}
	
	valor = dia + '/' + mes + '/' + ano
	campo = document.form3.dia
	
	lRet= validaData(campo,valor)
	
	if (lRet == false) {
		
		return false
		
	}
	
	nacionalidade= document.form3.nacionalidade.value
	
	if (nacionalidade == '0') {
		
		alert('Selecione a nacionalidade')
		
		document.form3.nacionalidade.focus()
		
		return false
		
	}
	
	
	
	cpf= document.form3.cpf.value
	
	if (cpf == '') {
		
		alert('CPF nao pode ser em branco')
		
		document.form1.cpf.focus()
		
		return false
		
	}
	
		
	
	lRetorno = validaCPF(cpf)
	
	if (lRetorno == false) {
		
		alert('CPF incorreto')
		
		document.form1.cpf.focus()
		
		return false
	}
	
	civil= document.form3.civil.value
	
	if (civil == '0') {
		
		alert('Selecione o estado civil')
		
		document.form3.civil.focus()
		
		return false
		
	}
	
	
		
	filho= document.form3.filho.value
	
	if (filho == '0') {
		
		alert('Selecione o número de filhos')
		
		document.form3.filho.focus()
		
		return false
		
	}
	
	escolaridade= document.form3.escolaridade.value
	
	if (escolaridade == '0') {
		
		alert('Selecione o grau de instrução')
		
		document.form3.escolaridade.focus()
		
		return false
		
	}
	
	endereco= document.form3.endereco.value
	
	if (endereco == '') {
		
		alert('Informe o endereco')
		
		document.form3.endereco.focus()
		
		return false
		
	}
		
	numero= document.form3.numero.value
	
	if (numero == '') {
		
		alert('Informe o numero do endereco')
		
		document.form3.numero.focus()
		
		return false
		
	}
	
	bairro= document.form3.bairro.value
	
	if (bairro == '') {
		
		alert('Informe o endereco')
		
		document.form3.bairro.focus()
		
		return false
		
	}
	
	telefone1= document.form3.telefone1.value

	telefone2= document.form3.telefone2.value
	
	if (telefone2 == '') {
		
		alert('Informe o telefone celular')
		
		document.form3.telefone2.focus()
		
		return false
		
	}
	
	email= document.form3.email.value
	
	if (email == '') {
		
		alert('Informe o email')
		
		document.form3.email.focus()
		
		return false
		
	}
	
	lRet= checkMail(email)
	
	if (lRet == false) {
		
		alert('Email invalido')
		
		document.form3.email.focus()
		
		return false
		
	}
	
	estado= document.form3.estado.value
	
	if (estado == '') {
		
		alert('Informe o estado')
		
		document.form3.estado.focus()
		
		return false
		
	}
	
	municipio= document.form3.municipio.value
	
	if (municipio == '') {
		
		alert('Informe o municipio')
		
		document.form3.municipio.focus()
		
		return false
		
	}
	
	cep= document.form3.cep.value
	
	if (cep == '') {
		
		alert('Informe o cep')
		
		document.form3.cep.focus()
		
		return false
		
	}
	
	
		
	filiacao= document.form3.filiacao.value
	
	if (filiacao == '0') {
		
		alert('Selecione a filiacao')
		
		document.form3.filiacao.focus()
		
		return false
		
	}
	
	amigo= document.form3.amigo.value
	
	if (amigo == '0') {
		
		alert('Selecione se tem amigo atuando como politico')
		
		document.form3.amigo.focus()
		
		return false
		
	}
	
		
	
	ingles= document.form3.ingles.value
	
	if (ingles == '0') {
		
		alert('Selecione se fala ingles')
		
		document.form3.ingles.focus()
		
		return false
		
	}
	
	espanhol= document.form3.espanhol.value
	
	if (espanhol == '0') {
		
		alert('Selecione se fala espanhol')
		
		document.form3.espanhol.focus()
		
		return false
		
	}
	
	informatica= document.form3.informatica.value
	
	if (informatica == '0') {
		
		alert('Selecione se tem curso de informatica')
		
		document.form3.informatica.focus()
		
		return false
		
	}
	
	viagem= document.form3.viagem.value
	
	if (viagem == '0') {
		
		alert('Selecione se pode viajar')
		
		document.form3.viagem.focus()
		
		return false
		
	}
	
	
	
	comportamento= document.form3.comportamento.value
	sustento= document.form3.sustento.value
	esporte= document.form3.esporte.value
	doenca= document.form3.doenca.value
	curriculo= document.form3.curriculo.value
	//imagem= foto2.document.form5.imagem.value // foto2 é o nome do DIV ANIMAL
	imagem=''
		
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<nome>" + nome + "</nome>"
	sxml = sxml + "<sexo>" + sexo + "</sexo>"
	sxml = sxml + "<dia>" + dia + "</dia>"
	sxml = sxml + "<mes>" + mes + "</mes>"
	sxml = sxml + "<ano>" + ano + "</ano>"
	sxml = sxml + "<nacionalidade>" + nacionalidade + "</nacionalidade>"
	sxml = sxml + "<cpf>" + cpf + "</cpf>"
	sxml = sxml + "<civil>" + civil + "</civil>"
	sxml = sxml + "<filho>" + filho + "</filho>"
	sxml = sxml + "<escolaridade>" + escolaridade + "</escolaridade>"
	sxml = sxml + "<endereco>" + endereco + "</endereco>"
	sxml = sxml + "<numero>" + numero + "</numero>"
	sxml = sxml + "<bairro>" + bairro + "</bairro>"
	sxml = sxml + "<telefone1>" + telefone1 + "</telefone1>"
	sxml = sxml + "<telefone2>" + telefone2 + "</telefone2>"
	sxml = sxml + "<email>" + email + "</email>"
	sxml = sxml + "<estado>" + estado + "</estado>"
	sxml = sxml + "<municipio>" + municipio + "</municipio>"
	sxml = sxml + "<cep>" + cep + "</cep>"
	sxml = sxml + "<filiacao>" + filiacao + "</filiacao>"
	sxml = sxml + "<amigo>" + amigo + "</amigo>"
	sxml = sxml + "<ingles>" + ingles + "</ingles>"
	sxml = sxml + "<espanhol>" + espanhol + "</espanhol>"
	sxml = sxml + "<informatica>" + informatica + "</informatica>"
	sxml = sxml + "<viagem>" + viagem + "</viagem>"
	sxml = sxml + "<comportamento>" + comportamento + "</comportamento>"
	sxml = sxml + "<sustento>" + sustento + "</sustento>"
	sxml = sxml + "<esporte>" + esporte + "</esporte>"
	sxml = sxml + "<doenca>" + doenca + "</doenca>"
	sxml = sxml + "<curriculo>" + curriculo + "</curriculo>"
	sxml = sxml + "<imagem>" + imagem + "</imagem>"


	
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlEntrevistador.ASP', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;		
	
	entrevistador =  xmlTemp.getElementsByTagName("entrevistador")[0].childNodes[0].nodeValue;
	cadastro =  xmlTemp.getElementsByTagName("cadastro")[0].childNodes[0].nodeValue;

		
	if (cadastro == 0 ) {
		
		document.form3.entrevistador.value = entrevistador

		alert('Seu cadastro foi enviado com sucesso! \n A confirmacao foi enviada para o email informado. \n O proximo passo sera enviar sua foto.' )
		
		window.open('foto_entrevistador.asp?entrevistador=' + entrevistador ,'Drtex','500','300','yes','center');return false
		
	}else{
		
		alert('Entrevistador ja existe. CPF ' + cpf + ' ja cadastrado!')
		
		window.open('foto_entrevistador.asp?entrevistador=' + entrevistador ,'Drtex','500','300','yes','center');return false
		
	}
	
}

function validaCPF(cpf) {
                 
                 erro = new String;
                 if (cpf.length < 11) erro += "Sao necessarios 11 digitos para verificacao do CPF! \n\n"; 
                 var nonNumbers = /\D/;
                 if (nonNumbers.test(cpf)) erro += "A verificacao de CPF suporta apenas numeros! \n\n"; 
                 if (cpf == "00000000000" || cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999"){
                         erro += "Numero de CPF invalido!"
               }
               var a = [];
               var b = new Number;
               var c = 11;
               for (i=0; i<11; i++){
                       a[i] = cpf.charAt(i);
                       if (i < 9) b += (a[i] * --c);
               }
               if ((x = b % 11) < 2) { a[9] = 0 } else { a[9] = 11-x }
               b = 0;
               c = 11;
               for (y=0; y<10; y++) b += (a[y] * c--); 
               if ((x = b % 11) < 2) { a[10] = 0; } else { a[10] = 11-x; }
               if ((cpf.charAt(9) != a[9]) || (cpf.charAt(10) != a[10])){
                       erro +="Digito verificador com problema!";
               }
               if (erro.length > 0){
                       alert(erro);
                       return false;
               }
               return true;
       }

function checkMail(mail){
      var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
	  //var er = new RegExp("^[\\w\\.=-]+@[\\w\\.-]+\\.[\\w\\.-]{2,4}$");
        
	if(er.test(mail)){ 
	
		if (mail.match(/^[a-zA-Z0-9]{1}([\._a-zA-Z0-9-]+)(\.[_a-zA-Z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+){1,3}$/)) {
	
			
			return true;
			
		}else{
		
			return false;
		}
		
	}else{
		
		return false;	
	}
    
	
}


function SelecionaTextoCombo(sel, campo) {

	campo.value = sel;
	

}

function SelecionaCep(cep) {
	
	fechar = 1
		
	if (cep == '' || cep == 0 ) {
			
		fechar = 0
		
		cep=0 
			
	}
		
	window.open('cep.asp?cep=' + cep + '&fechar=' + fechar,'Drtex','400','200','yes','center');return false
	
}

function validaData(campo,valor) {
	var date=valor;
	var ardt=new Array;
	var ExpReg=new RegExp("(0[1-9]|[12][0-9]|3[01])/(0[1-9]|1[012])/[12][0-9]{3}");
	ardt=date.split("/");
	erro=false;
	if ( date.search(ExpReg)==-1){
		erro = true;
		}
	else if (((ardt[1]==4)||(ardt[1]==6)||(ardt[1]==9)||(ardt[1]==11))&&(ardt[0]>30))
		erro = true;
	else if ( ardt[1]==2) {
		if ((ardt[0]>28)&&((ardt[2]%4)!=0))
			erro = true;
		if ((ardt[0]>29)&&((ardt[2]%4)==0))
			erro = true;
	}
	if (erro) {
		alert("\"" + valor + "\" nao e uma data valida!!!");
		campo.focus();
		//campo.value = "";
		return false;
	}
	return true;
}

function AtualizaEntrevistador(entrevistador) {
	
	z= entrevistador.toString()
	
	a = eval('document.form1.A' + z + '.checked')
	
	if (a == false) {
		
		a = 0
		
	}else{
		
		a = 1
		
	}
	
	s = eval('document.form1.S' + z + '.checked')
	
	if (s == false) {
		
		s = 0
		
	}else{
		
		s = 1
		
	}
	
	c = eval('document.form1.C' + z + '.checked')
	
	if (c == false) {
		
		c = 0
		
	}else{
		
		c = 1
		
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	
	sxml = sxml + "<entrevistador>" + entrevistador + "</entrevistador>"
	sxml = sxml + "<ativo>" + a + "</ativo>"
	sxml = sxml + "<selecionado>" + s + "</selecionado>"
	sxml = sxml + "<coordenador>" + c + "</coordenador>"
	
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlEntrevistador2.ASP', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;		
	
	alert('Registro alterado com sucesso')
	
	
}

function ChamarPesquisa(pesquisa) {
	
	
	document.getElementById('div2').src='questionario_formatar.asp?pesquisaCod=' + pesquisa
	
	return true
}

function MostraFoto(entrevistador) {
	
	window.open('../foto_entrevistador.asp?entrevistador=' + entrevistador ,'Drtex','500','300','yes','center');return false
	
}

function MudaImagem(imagem, diretorio) {
	
	cadastro= document.form1.cadastro.checked
	tabela= document.form1.tabela.value
	cod= document.form1.cod.value
	
	
	if (cadastro == true) {
		
		var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
		xmldoc.async = false;
		var sxml;	
		sxml = "<ROOT>";
		sxml = sxml + "<tabela>" + tabela + "</tabela>";
		sxml = sxml + "<cod>" + cod + "</cod>";
		sxml = sxml + "<imagem>" + imagem + "</imagem>";

		sxml = sxml + "</ROOT>";
		sxml = sxml.replace("&","&amp;");
		xmldoc.loadXML(sxml);
				
		var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			
		xmlhttp.Open("POST",'../../plataforma/includes/xmlImagem.asp', false);
		xmlhttp.Send(xmldoc);
		var xmlTemp = xmlhttp.responseXML;	
		alert('Registro alterado com sucesso')
		document.getElementById('imagem_capturar').src='imagem.asp?cod=' + cod + '&tabela=' + tabela + '&atualizar=1' 
		
	}
		
   document.getElementById('imagem_original').src='imagem_original.asp?imagem=' + imagem + '&diretorio=' + diretorio 
	
}

function CarregaArquivo(tipo, tabela, cod, diretorio) {
	
	if (tipo != 0 ) {
	
		location.href = '../plataforma/imagem_configurar.asp?tipo=' + tipo + '&tabela=' + tabela + '&cod=' + cod + '&diretorio=' + diretorio 
		
		
	}
}


function MostraFotoNova() {
	
	// tabela
	tabela = document.form1.tabela.value
	cod = document.form1.cod.value
	diretorio = document.form1.diretorio.value
	
	// imagem
	escala= document.form1.escala.value
	altura= document.form1.altura.value
	largura= document.form1.largura.value
	brilho= document.form1.brilho.value
	contraste= document.form1.contraste.value
	vermelho= document.form1.vermelho.value
	verde= document.form1.verde.value
	azul= document.form1.azul.value
	preto_branco= document.form1.preto_branco.checked
	escala_256= document.form1.escala_256.checked
	polarizacao_azul= document.form1.polarizacao_azul.checked
	
	// texto
	nome= document.form1.nome.value
	nome= nome.replace("É","&Eacute;");
	fonte_tamanho = document.form1.fonte_tamanho.value
	fonte_tipo = document.form1.fonte_tipo.value
	fonte_fundo= document.form1.fonte_fundo.checked
	fonte_cor_fundo= document.form1.fonte_cor_fundo.value
	fonte_cor_letra= document.form1.fonte_cor_letra.value
	fonte_negrito= document.form1.fonte_negrito.checked
	fonte_italico= document.form1.fonte_italico.checked
	fonte_sublinhado= document.form1.fonte_sublinhado.checked
	fonte_riscado= document.form1.fonte_riscado.checked
	fonte_x= document.form1.fonte_x.value
	fonte_y= document.form1.fonte_y.value
	fonte_angulo= document.form1.fonte_angulo.value
	fonte_pular_linha= document.form1.fonte_pular_linha.checked
	
	// retangulo
	
	retangulo_imagem= document.form1.retangulo_imagem.checked
	retangulo_x1= document.form1.retangulo_x1.value
	retangulo_x2= document.form1.retangulo_x2.value
	retangulo_y1= document.form1.retangulo_y1.value
	retangulo_y2= document.form1.retangulo_y2.value
	retangulo_borda = document.form1.retangulo_borda.value
	retangulo_fundo = document.form1.retangulo_fundo.value
	retangulo_cor_fundo = document.form1.retangulo_cor_fundo.value
	retangulo_cor_borda = document.form1.retangulo_cor_borda.value
	
	

	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<tabela>" + tabela + "</tabela>";
	sxml = sxml + "<cod>" + cod + "</cod>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlImagem2.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	imagem=  xmlTemp.getElementsByTagName("imagem")[0].childNodes[0].nodeValue;
	
	if (imagem == "0") {
		
		alert('Nao existe imagem arquivada')
		
		return false
		
	} 
	
	
	
	document.getElementById('imagem_nova').src='imagem_nova.asp?diretorio=' + diretorio + '&tabela=' + tabela + '&cod=' + cod + '&imagem=' + imagem + '&escala=' + escala + '&altura=' + altura + '&largura=' + largura   +  '&nome=' + nome + '&brilho=' + brilho + '&contraste=' + contraste + '&vermelho=' + vermelho  + '&verde=' + verde + '&azul=' + azul + '&preto_branco=' + preto_branco + '&escala_256=' + escala_256 + '&polarizacao_azul=' + polarizacao_azul + '&fonte_tamanho=' + fonte_tamanho + '&fonte_tipo=' + fonte_tipo + '&fonte_fundo=' + fonte_fundo + '&fonte_cor_fundo=' + fonte_cor_fundo + '&fonte_cor_letra=' + fonte_cor_letra + '&fonte_negrito=' + fonte_negrito + '&fonte_italico=' + fonte_italico + '&fonte_sublinhado=' + fonte_sublinhado + '&fonte_riscado=' + fonte_riscado + '&fonte_x=' + fonte_x + '&fonte_y=' + fonte_y + '&fonte_angulo=' + fonte_angulo + '&fonte_pular_linha=' + fonte_pular_linha + '&retangulo_imagem=' + retangulo_imagem + '&retangulo_x1=' + retangulo_x1 + '&retangulo_x2=' + retangulo_x2 + '&retangulo_y1=' + retangulo_y1 + '&retangulo_y2=' + retangulo_y2 + '&retangulo_borda=' + retangulo_borda + '&retangulo_fundo=' + retangulo_fundo  + '&retangulo_cor_fundo=' + retangulo_cor_fundo + '&retangulo_cor_borda=' + retangulo_cor_borda
	
	 
	
}

function openModal(pUrl, pWidth, pHeight) {
	if (window.showModalDialog) {
		return window.showModalDialog(pUrl, window,
		  "dialogWidth:" + pWidth + "px;dialogHeight:" + pHeight + "px");
	} else {
		try {
			netscape.security.PrivilegeManager.enablePrivilege(
			  "UniversalBrowserWrite");
			window.open(pUrl, "wndModal", "width=" + pWidth
			  + ",height=" + pHeight + ",resizable=no,modal=yes");
			return true;
		}
		catch (e) {
			alert("Script não confiável, não é possível abrir janela modal.");
			return false;
		}
	}
}

function  InformaCor(cor) {
	
	
	parent.document.form1.fonte_cor_fundo.value = cor
}

function CalculaMedidasPercentual() {
	
document.form1.altura.value= Math.round(document.form1.altura.value * document.form1.escala.value / 100)
document.form1.largura.value= Math.round(document.form1.largura.value * document.form1.escala.value / 100)

}

function getPosicaoElemento(elemID){
	
	// onde elemID é o id do objeto que quero detectar a posicao no meu caso a imagem.   
	var offsetTrail = document.getElementById(elemID);   
	var i = 0;  
	var offsetLeft = 0;   
	var offsetTop = 0;   
	while (offsetTrail || i>1) {     
	offsetLeft += offsetTrail.offsetLeft;     
	offsetTop += offsetTrail.offsetTop;       
	offsetTrail = offsetTrail.offsetParent;   
	}   
	if (navigator.userAgent.indexOf("Mac") != -1 &&   typeof document.body.leftMargin != "undefined") {    
	offsetLeft += document.body.leftMargin;      
	offsetTop += document.body.topMargin;    } 
	 return {left:offsetLeft, top:offsetTop};  
	 alert(offsetLeft+"----"+offsetTop);
} 
 
function PreencheCoordenadasAssociadoTexto() {
	
	if (document.form1.retangulo_imagem.checked == true ) {
		document.form1.retangulo_x1.value= document.form1.fonte_x.value
		document.form1.retangulo_y1.value= document.form1.fonte_y.value
	
	}
	
}

function MostraFotoPublicacao() {
	
	// tabela
	tabela = document.form1.tabela.value
	cod = document.form1.cod.value
	
	document.getElementById('imagem_nova').src='imagem_publicacao.asp?tabela=' + tabela + '&cod=' + cod 
	
	
}

function SelecionarTodosEmail(selecionados) {
	
	var n= 0;
	var i= 0;
	acao= document.form1.todos.checked
		
	avetor = selecionados.split('/');
	n= avetor.length - 1
	while (i < n) {
		
		
		str = eval('document.form1.C' + avetor[i].toString() )
		
		str.checked = acao
		
		i++
		
	}
		
}

function SelecionaEstado(uf) {
	
	
	parent.document.form1.uf.value= uf
	est=0
	
	if (parent.document.form1.uf.value == 'AC' ) {
		parent.document.form1.estado.options[1].selected = true
		est = 1
	}else if (parent.document.form1.uf.value == 'AL' ) {
		parent.document.form1.estado.options[2].selected = true   
		est = 2
	}else if (parent.document.form1.uf.value == 'AM'  ) {
		parent.document.form1.estado.options[3].selected = true
		est = 3
	}else if (parent.document.form1.uf.value == 'AM' ) {
		parent.document.form1.estado.options[4].selected = true
		est = 4
    }else if (parent.document.form1.uf.value == 'BA') {
		parent.document.form1.estado.options[5].selected = true
		est = 5
   	}else if (parent.document.form1.uf.value == 'CE') {
		parent.document.form1.estado.options[6].selected = true
		est = 6
    }else if (parent.document.form1.uf.value == 'DF' ) {
		parent.document.form1.estado.options[7].selected = true
		est = 7
    }else if (parent.document.form1.uf.value == 'ES' ) {
		parent.document.form1.estado.options[8].selected = true
		est = 8
    }else if (parent.document.form1.uf.value == 'GO' ) {
		parent.document.form1.estado.options[9].selected = true 
		est = 9
    }else if (parent.document.form1.uf.value == 'MA'  ) {
		parent.document.form1.estado.options[10].selected = true
		est = 10
     }else if (parent.document.form1.uf.value == 'MG' ) {
		 parent.document.form1.estado.options[11].selected = true
		 est = 11
     }else if (parent.document.form1.uf.value == 'MS' ) {
		 parent.document.form1.estado.options[12].selected = true
		 est = 12
     }else if (parent.document.form1.uf.value == 'MT' ) {
	    parent.document.form1.estado.options[13].selected = true
		est = 13
     }else if (parent.document.form1.uf.value == 'PA'  ) {
		parent.document.form1.estado.options[14].selected = true
		est = 14
	 }else if (parent.document.form1.uf.value == 'PB' ) {
	  	parent.document.form1.estado.options[15].selected = true
		est = 15
     }else if (parent.document.form1.uf.value == 'PE') {
		parent.document.form1.estado.options[16].selected = true
		est = 16
	 }else if (parent.document.form1.uf.value == 'PI' ) {
		parent.document.form1.estado.options[17].selected = true
		est = 17
     }else if (parent.document.form1.uf.value == 'PR'  ) {
		parent.document.form1.estado.options[18].selected = true
		est = 18
     }else if (parent.document.form1.uf.value == 'RJ' ) {
		parent.document.form1.estado.options[19].selected = true   
		est = 19
	 }else if (parent.document.form1.uf.value == 'RN' ) {
		parent.document.form1.estado.options[20].selected = true 
		est = 20
	 }else if (parent.document.form1.uf.value == 'RO' ) {
		parent.document.form1.estado.options[21].selected = true     
		est = 21
     }else if (parent.document.form1.uf.value == 'RR')    {
		parent.document.form1.estado.options[22].selected = true
		est = 22
     }else if (parent.document.form1.uf.value == 'RS' ) {
		parent.document.form1.estado.options[23].selected = true
		est = 23
     }else if (parent.document.form1.uf.value == 'SC')  {
		parent.document.form1.estado.options[24].selected = true
		est = 24
     }else if (parent.document.form1.uf.value == 'SE'  ) {
		parent.document.form1.estado.options[25].selected = true
		est = 25
     }else if (parent.document.form1.uf.value == 'SP'  ) {
		parent.document.form1.estado.options[26].selected = true 
		est = 26
	 }else if (parent.document.form1.uf.value == 'TO' ) {
	    parent.document.form1.estado.options[27].selected = true 
		est = 27
	 }
			
	
	parent.chamarAjaxCombo(est,'estado','municipio',parent.document.form1.municipio,'municipioDIV', '1')		
	
}

function ChamarAjaxTabela(tabela,elemento, ordem, selecionar){	

	
	if (elemento == null ) {
		return false
	}
	
		
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<tabela>" + tabela + "</tabela>";
	sxml = sxml + "<ordem>" + ordem + "</ordem>";

	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");

	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlTabela.ASP', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;		
	LimpaCombo(elemento);
	objOption = document.createElement("OPTION");
	objOption.text =  "Selecione o(a) "+tabela
	objOption.value = "0"
	elemento.options.add(objOption)
	lop = 0;
	total = xmlTemp.documentElement.childNodes.length - 1
	while(lop <= total)
	{
		objOption = document.createElement("OPTION");
		objOption.text =  xmlTemp.getElementsByTagName("descricao")[lop].childNodes[0].nodeValue;
		objOption.value = xmlTemp.getElementsByTagName("codigo")[lop].childNodes[0].nodeValue;
		elemento.options.add(objOption)
		if (selecionar == objOption.value) {
			elemento.options[lop+1].selected = true
		}
		
		lop++;
	}
	

	
	
}

function CadastrarOrdemOpcao(opcao) {
	
	ordem = eval('document.form1.PP' + opcao.toString() + '.value' )
	
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<opcao>" + opcao + "</opcao>";
	sxml = sxml + "<ordem>" + ordem + "</ordem>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlOpcao.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	opcao=  xmlTemp.getElementsByTagName("opcao")[0].childNodes[0].nodeValue;
	
	
	if (opcao >  "0") {
		
		alert('Ordem da opcao atualizada com sucesso')
		
				
	} 
	
	
}

function GerarAutorizacao() {
	
	var grupodivulgacao = document.form1.grupodivulgacao.value // tipo 5 na procedure
	var estado = document.form1.estado.value // tipo 3 na procedure
	var municipio = document.form1.municipio.value // 8 na prodeure
	var tipo = 0
	var pesquisa = document.form1.pesquisaCod.value
	var nome = document.form1.nome.value
	var email2 = document.form1.email2.value
	var basetotal = 0
	var autorizados = 0
	var quantidade = 0
	var divulgacao = 0
	var cVetor = ''
	var n= 0
	
	// tipo 1 - grupo, estado e municipio
	// tipo 2 - grupo, estado
	// tipo 3 - estado
	// tipo 4 - estado e municipio
	// tipo 5 - grupo
	// tipo 6 - like nome
	// tipo 7 - like emial
	
	if (grupodivulgacao == 0 & estado == 0 && municipio == 0 ) {
		
		alert('Escolha pelo menos Grupo Divulgacao ou Estado')
		
		return false
		
	}
	
	if (grupodivulgacao != 0 & estado != 0 && municipio != 0 ) {
		
		tipo = 1
		
	}
	
	
	if (grupodivulgacao != 0 & estado != 0 && municipio == 0 ) {
		
		tipo = 2
		
	}
	
	if (grupodivulgacao == 0 & estado != 0 && municipio == 0 ) {
		
		tipo = 3
		
	}
	
	if (grupodivulgacao == 0 & estado != 0 && municipio != 0 ) {
		
		tipo = 4
		
	}
	
	if (grupodivulgacao != 0 & estado == 0 && municipio == 0 ) {
		
		tipo = 5
		
	}
	
	quantidade = document.form1.quantidade.value
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<grupodivulgacao>" + grupodivulgacao + "</grupodivulgacao>";
	sxml = sxml + "<estado>" + estado + "</estado>";
	sxml = sxml + "<municipio>" + municipio + "</municipio>";
	sxml = sxml + "<nome>" + nome + "</nome>";
	sxml = sxml + "<email2>" + email2 + "</email2>";
	sxml = sxml + "<pesquisa>" + pesquisa + "</pesquisa>";
	sxml = sxml + "<tipo>" + tipo + "</tipo>";
	sxml = sxml + "<quantidade>" + quantidade + "</quantidade>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlAutorizacao.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	lop = 0;
	total = xmlTemp.documentElement.childNodes.length - 1
	
	
	
	while(lop <= total)
	{
		
		divulgacao =  xmlTemp.getElementsByTagName("divulgacao")[lop].childNodes[0].nodeValue;
			
		lop++;
		
		var t=setTimeout(lop,5000);

		document.form1.basetotal.value = lop
	}
		
	
	
}

function EnviarEmailAutorizados() {
	
	var pesquisa = document.form1.pesquisaCod.value
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<pesquisa>" + pesquisa + "</pesquisa>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");

	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlAutorizacao2.ASP', false);
	xmlhttp.Send(xmldoc);
	var xmlTemp = xmlhttp.responseXML;		
	lop = 0;
	total = xmlTemp.documentElement.childNodes.length - 1
	while(lop <= total)
	{
		
		nome =  xmlTemp.getElementsByTagName("nome")[lop].childNodes[0].nodeValue;
		email = xmlTemp.getElementsByTagName("email")[lop].childNodes[0].nodeValue;
		
		lop++;
		
		document.form1.enviados.value = lop
	}
	

	alert('Fim do Processo')
	
	
}

function ChamaWins() {
	
	email= document.form3.email2.value
	
	if (email == '') {
		
		alert('Informe o email')
		
		document.form3.email2.focus()
		
		return false
		
	}
	
	lRet= checkMail(email)
	
	if (lRet == false) {
		
		alert('Email invalido')
		
		document.form3.email2.focus()
		
		return false
		
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<email>" + email + "</email>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlWins.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var mensagem=  xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	var pesquisa=  xmlTemp.getElementsByTagName("pesquisa")[0].childNodes[0].nodeValue;
	var entrevistador=  xmlTemp.getElementsByTagName("entrevistador")[0].childNodes[0].nodeValue;
	var email=  xmlTemp.getElementsByTagName("email")[0].childNodes[0].nodeValue;
	var postagem=  xmlTemp.getElementsByTagName("postagem")[0].childNodes[0].nodeValue;
	var comentario=  xmlTemp.getElementsByTagName("comentario")[0].childNodes[0].nodeValue;
	
	document.form3.pesquisa.value = pesquisa
	document.form3.entrevistador.value = entrevistador
	document.form3.email.value = email
	document.form3.postagem.value = postagem
	document.form3.comentario.value = comentario
	document.form3.total.value = parseInt(pesquisa) + parseInt(comentario) + parseInt(entrevistador) + parseInt(email) + parseInt(postagem) 
	
	alert(mensagem)
	
}

function OpcaoBuscaBlog() {
	var opcaobusca =  getCheckedValue(document.form1.opcaobusca)	
	var busca = ''
	
	if (opcaobusca == 4 ) {
		
		busca = document.form1.busca.value
		
		if (busca == '' ) {
			
			alert('Informe a busca')
						
			document.form1.busca.focus()
			
			return false
		}
	}

	location.href = 'blogRestrito.asp?loginblog=1&opcaobusca=' + opcaobusca + '&busca=' + busca 
	
	
}

function MostraNoticiaPostada(postagem) {
	var nomedivulgacao = '';
	var estadodivulgacao = '';
	var municipiodivulgacao= '';
	var loginblog = 1;
	var opcaobusca =  getCheckedValue(document.form1.opcaobusca);	
	var marcador = eval('document.form1.marcador' + postagem.toString() + '.value');
	
	
	var radioObj = parent.parent.document.form1.marcador;
	var radioLength = radioObj.length;
			
	for(var i = 0; i < radioLength; i++) {;
		if(radioObj[i].value == marcador ) {;
			radioObj[i].checked = true;
		};
	};
	
	var pagina = 'blogCadastroNoticias.asp?municipio='+ parent.parent.document.form1.municipio.value + '&nomedivulgacao=' + nomedivulgacao + '&estadodivulgacao=' + estadodivulgacao + '&municipiodivulgacao=' + municipiodivulgacao + '&loginblog=' + loginblog + '&opcaobusca=' + opcaobusca + '&postagem=' + postagem;
	
	
	
	parent.location.href = pagina
	
	
	
	
}


function Menu(opcao, opcaobusca) {
	var pagina = ''
	
	if (opcao == 1) {
		
		var divulgacao = document.form1.divulgacao.value
		var loginblog = document.form1.loginblog.value
		
		if (opcaobusca == '' || opcaobusca == null ) {
		 	opcaobusca = 1
		}
		
		if (divulgacao == '0' || divulgacao == '') {
			
			alert('Login nao realizado')
			
			document.getElementById('divsenha').style.display = 'block';
			
			document.form1.email.focus()
			
			return false
			
		}
		
		var nomedivulgacao = document.form1.nomedivulgacao.value
		var estadodivulgacao = document.form1.estadodivulgacao.value
		var municipiodivulgacao = document.form1.municipiodivulgacao.value
		var postagem = document.form1.postagem.value
		
		pagina = 'blogCadastroNoticias.asp?municipio='+ document.form1.municipio.value + '&nomedivulgacao=' + nomedivulgacao + '&estadodivulgacao=' + estadodivulgacao + '&municipiodivulgacao=' + municipiodivulgacao + '&loginblog=' + loginblog + '&opcaobusca=' + opcaobusca + '&postagem=' + postagem
		
		
		
	}
	else if (opcao == 2) {
		
		pagina = 'blogCadastro.asp?municipio='+ document.form1.municipio.value 
		
	}
	else if (opcao == 3) {
		
		pagina = 'blogMunicipio2.asp?municipio='+ document.form1.municipio.value 
		
		if (document.form1.municipio.value == 0 ) {
		
			alert('Escolha seu estado e municipio')
			
			document.form1.estado.focus()
			
			return false
			
		}
		
		//http://selo.cptec.inpe.br/IBGE/cidade/291360
		//http://www.ibge.gov.br/cidadesat/historicos_cidades/historico_conteudo.php?codmun=291360
	}
	else if (opcao == 4) {
		
		pagina = 'blogEstatistica.asp?municipio='+ document.form1.municipio.value 
		
	}
	else if (opcao == 5) {
		
		pagina = 'blogQuemSomos.asp?municipio='+ document.form1.municipio.value 
	}	
	else if (opcao == 6) {
		
		pagina = 'blogNoticias.asp?municipio='+ document.form1.municipio.value 
	}
	else if (opcao == 7) {
		
		pagina = 'blogNoticias.asp?municipio='+ document.form1.municipio.value 
	}
	else if (opcao == 8) {
		
		pagina = 'blogPublicidade2.asp?municipio='+ document.form1.municipio.value 
	}
	else if (opcao == 9) {
		
		pagina = 'blogPesquisa.asp?municipio='+ document.form1.municipio.value 
		
		if (document.form1.municipio.value == 0 ) {
		
			alert('Escolha seu estado e municipio')
			
			document.form1.estado.focus()
			
			return false
			
		}
	}
	else if (opcao == 10) {
		
		pagina = 'blogWins.asp'
	}
	
	document.getElementById('divgeral').style.display = 'block'
	document.getElementById('div1').src=pagina 
}

function EnviarCadastroBlog() {
	var nome = document.form1.nome.value
	var email = document.form1.email.value
	var estado = document.form1.estado.value
	var municipio = document.form1.municipio.value
	
	if (nome == '') {
		
		alert('Nome em branco')
		
		document.form1.nome.focus()
		
		return false
		
	}
	
	lRet= checkMail(email)
	
	if (lRet == false) {
		
		alert('Email invalido')
		
		document.form1.email.focus()
		
		return false
		
	}
	
	if (estado == '0') {
		
		alert('Estado em branco')
		
		document.form1.estado.focus()
		
		return false
		
	}
	
	if (municipio == '0') {
		
		alert('Estado em branco')
		
		document.form1.municipio.focus()
		
		return false
		
			
	}
	
	var nav = 0
	
	nav = TestaNavegador()
	
		
	if (nav != 0  ) {
	
		location.href =  'blogCadastro.asp?nome=' + nome + '&email=' + email + '&estado=' + estado + '&municipio=' + municipio +  '&nav=' + nav
		
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<nome>" + nome + "</nome>";
	sxml = sxml + "<email>" + email + "</email>";
	sxml = sxml + "<estado>" + estado + "</estado>";
	sxml = sxml + "<municipio>" + municipio + "</municipio>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog01.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	mensagem=  xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	
	alert(mensagem)
	
}

function LogarBlog() {
	var email = document.form1.email.value
	var senha = document.form1.senha.value
	var div = 'divlogin'
	
	lRet= checkMail(email)
	
	if (lRet == false) {
		
		alert('Email invalido')
		
		document.form1.email.focus()
		
		return false
		
	}
	
	if (senha == '' || senha == 'senha') {
		
		alert('Senha em branco')
		
		document.form1.senha.focus()
		
		return false
		
	}
	
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<email>" + email + "</email>";
	sxml = sxml + "<senha>" + senha + "</senha>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog02.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var mensagem=  xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	var nome=  xmlTemp.getElementsByTagName("nome")[0].childNodes[0].nodeValue;
	var codigo=  xmlTemp.getElementsByTagName("codigo")[0].childNodes[0].nodeValue;
	var estado=  xmlTemp.getElementsByTagName("estado")[0].childNodes[0].nodeValue;
	var municipio=  xmlTemp.getElementsByTagName("municipio")[0].childNodes[0].nodeValue;
	var uf=  xmlTemp.getElementsByTagName("uf")[0].childNodes[0].nodeValue;
	var loginblog=  xmlTemp.getElementsByTagName("loginblog")[0].childNodes[0].nodeValue;
	
	
	if (codigo > 0 ) {;
		document.getElementById(div).style.display = 'block'
		document.form1.textologin.value = mensagem
		document.form1.divulgacao.value = codigo
		document.form1.estado.value = estado
		document.form1.municipio.value = municipio
		document.form1.uf.value = uf
		document.form1.loginblog.value = loginblog
		document.form1.fotoestado.src = 'imagens/' + uf + '.jpg'
		
		chamarAjaxCombo(estado,'estado','municipio',document.form1.municipio,'municipioDIV', '1')
		document.form1.municipio.value = municipio
		document.form1.nomedivulgacao.value = nome
		document.form1.municipiodivulgacao.value = document.form1.municipio.options[document.form1.municipio.selectedIndex].text
		document.form1.estadodivulgacao.value = document.form1.estado.options[document.form1.estado.selectedIndex].text
		PegaCodigoIBGE_CNM(document.form1.municipio.value)
		Menu(1)

	}else{;
		document.getElementById(div).style.display = 'none'
		document.form1.textologin.value = ''
		document.form1.divulgacao.value = 0
		document.form1.estado.value = 0
		document.form1.municipio.value = 0
		document.form1.uf.value = 0
		document.form1.loginblog.value = 0
		alert(email + ': ' + mensagem)

	}
	
	

}

function EsqueceuSenhaBlog() {
	var email = document.form1.email.value
	var div = 'divlogin'
	
	lRet= checkMail(email)
	
	if (lRet == false) {
		
		alert('Email invalido')
		
		document.form1.email.focus()
		
		return false
		
	}
	
	var nav = 0
	
	nav = TestaNavegador()
	
		
	if (nav != 0  ) {
	
		location.href =   'winblog.asp?email=' + email
		
	}
		
		
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<email>" + email + "</email>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog03.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var mensagem=  xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	
	alert(mensagem)
}

function EnviarNoticiaBlog(loginblog) {
	var topicodivulgacao = document.form1.topicodivulgacao.value
	var textodivulgacao = document.form1.textodivulgacao.value
	var divulgacao = parent.document.form1.divulgacao.value
	var estado = parent.document.form1.estado.value
	var municipio = parent.document.form1.municipio.value
	var marcador =getCheckedValue(parent.document.form1.marcador)
	var responsabilidade =document.form1.responsabilidade.checked
	var email = parent.document.form1.email.value
	var usuario = document.form1.nomedivulgacao.value
	var postagem = document.form1.postagem.value
	var textoimagemdivulgacao = document.form1.textoimagemdivulgacao.value
	if (loginblog == 1) {
		var liberar = document.form1.liberar.checked
	}else{
		var liberar = false
	}
	
	if (postagem == '' ) {
		
		postagem = 0
		
	}
	
	if (responsabilidade == false ) {
		
		alert('Sem a responsabilidade nao sera possivel postar a noticia')
		
		return false
		
	}
	
	if (liberar == false ) {
		
		liberar = 0
		
	}else{
	
		liberar = 1
		
	}
	
	responsabilidade = 1
	
	if (topicodivulgacao == '') {
		
		alert('Informe o topico')
		
		document.form1.topicodivulgacao.focus()
		
		document.form1.topicodivulgacao.style.visibility = 'visible'
		document.form1.topicodivulgacao.style.backgroundColor='#FFFF6F'
		
		return false
		
		
	}
	
	if (textodivulgacao == '') {
		
		alert('Informe o texto')
		
		document.form1.textodivulgacao.focus()
		
		document.form1.textodivulgacao.style.visibility = 'visible'
		document.form1.textodivulgacao.style.backgroundColor='#FFFF6F'
		
		return false
		
		
	}
	
	if (divulgacao == '' || divulgacao == '0') {
		
		alert('Voce nao foi logado')
		
		document.form1.textodivulgacao.focus()
		
		return false
		
		
	}
	
	if (estado == '' || estado == '0') {
		
		alert('Escolha o estado')
		
		document.form1.estado.focus()
		
		document.form1.estado.style.visibility = 'visible'
		document.form1.estado.style.backgroundColor='#FFFF6F'
		
		
		return false
		
		
	}
	
	if (municipio == '' || municipio == '0') {
		
		alert('Escolha o municipio')
		
		document.form1.municipio.focus()
		
		document.form1.municipio.style.visibility = 'visible'
		document.form1.municipio.style.backgroundColor='#FFFF6F'
		
		return false
		
		
	}
	
	if (marcador == '' || marcador == '0') {
		
		alert('Escolha o marcador')
		
		return false
		
		
	}
	
	if (postagem == 0 ) {
		
		var pergunta = 'Deseja Postar esta Noticia?'
		
	}else{
		
		var pergunta = 'Deseja Alterar esta Noticia?'
		var divulgacao = document.form1.divulgacao.value
		var estado = document.form1.estado.value
		var municipio = document.form1.municipio.value
	}
	
	
	if (confirm(pergunta) == false) {
		
		return false
		
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<divulgacao>" + divulgacao + "</divulgacao>";
	sxml = sxml + "<estado>" + estado + "</estado>";
	sxml = sxml + "<municipio>" + municipio + "</municipio>";
	sxml = sxml + "<marcador>" + marcador + "</marcador>";
	sxml = sxml + "<responsabilidade>" + responsabilidade + "</responsabilidade>";
	sxml = sxml + "<nome>" + topicodivulgacao + "</nome>";
	sxml = sxml + "<texto>" + textodivulgacao + "</texto>";
	sxml = sxml + "<email>" + email + "</email>";
	sxml = sxml + "<usuario>" + usuario + "</usuario>";
	sxml = sxml + "<textoimagemdivulgacao>" + textoimagemdivulgacao + "</textoimagemdivulgacao>";
	sxml = sxml + "<liberar>" + liberar + "</liberar>";
	sxml = sxml + "<postagem>" + postagem + "</postagem>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog04.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var mensagem=  xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	var codigo=  xmlTemp.getElementsByTagName("codigo")[0].childNodes[0].nodeValue;
	
	document.form1.postagem.value = codigo
	parent.document.form1.postagem.value = codigo
	alert(mensagem)
	
	if (codigo > 0 ) {
		
		document.getElementById('divimagem').style.display = 'block'
		
	}
	
}

function EnviarImagemBlog() {
	var postagem = document.form1.postagem.value
	
	if (postagem > 0 ) {
	
		var pagina = 'http://www.winpesquisa.com.br/plataforma/imagem.asp?cod=' + postagem + '&tabela=postagem&externo=1'
		document.getElementById('imagem').src=pagina 
		document.getElementById('divimagem').style.display = 'block'
		//document.getElementById('imagem').style.display = 'block';
		document.getElementById('imagem').style.display = 'block'
	}else{
		
		alert('Primeiro envie a noticia')
		document.form1.topicodivulgacao.focus()
	}
}

function NovaNoticiaBlog() {
	
	document.form1.postagem.value = 0
	document.form1.topicodivulgacao.value= ''
	document.form1.textodivulgacao.value= ''
	document.form1.textoimagemdivulgacao.value= ''
	document.getElementById('imagem').style.display = 'none'
}

function EnviarComentarioBlog(postagem) {
	var nome = eval('document.form1.nomecomentario' + postagem.toString() + '.value')
	var email = eval('document.form1.emailcomentario' + postagem.toString() + '.value')
	var texto = eval('document.form1.textocomentario' + postagem.toString() + '.value')
	var responsabilidade = eval('document.form1.responsabilidadecomentario' + postagem.toString() + '.checked')
	var divulgacao = parent.document.form1.divulgacao.value
	var comentario = 0
	var ipcomputador = 0
	var liberar = 0
	
	if (divulgacao == '' ) {
	
		divulgacao = 0
	}
	
	if (responsabilidade == false) {
		
		alert('Sem responsabilidade nao se pode fazer comentario')
		
		return false
	}
	
	responsabilidade = 1
	
	if (nome == '' ) {
		alert('Nome em branco')
		var obj = eval('document.form1.nomecomentario' + postagem.toString() )
		obj.visibility = 'visible'
		obj.backgroundColor='#FFFF6F'
		obj.focus()
		return false
	}
	
	if (email == '' ) {
		alert('Email em branco')
		var obj = eval('document.form1.emailcomentario' + postagem.toString() )
		obj.focus()
		obj.visibility = 'visible'
		obj.backgroundColor='#FFFF6F'
		
		
		return false
	}
	
	
	
	lRet= checkMail(email)
	
	if (lRet == false) {
		
		alert('Email invalido')
		
	
		var obj = eval('document.form1.emailcomentario' + postagem.toString() )
		obj.focus()
		obj.visibility = 'visible'
		obj.backgroundColor='#FFFF6F'
		
		return false
		
	}
	
	if (texto == '' ) {
		alert('Texto em branco')
		var obj = eval('document.form1.textocomentario' + postagem.toString() )
		obj.focus()
		obj.visibility = 'visible'
		obj.backgroundColor='#FFFF6F'
		return false
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<postagem>" + postagem + "</postagem>";
	sxml = sxml + "<divulgacao>" + divulgacao + "</divulgacao>";
	sxml = sxml + "<nome>" + nome + "</nome>";
	sxml = sxml + "<email>" + email + "</email>";
	sxml = sxml + "<responsabilidade>" + responsabilidade + "</responsabilidade>";
	sxml = sxml + "<texto>" + texto + "</texto>";
	sxml = sxml + "<ipcomputador>" + ipcomputador + "</ipcomputador>";
	sxml = sxml + "<liberar>" + liberar + "</liberar>";
	sxml = sxml + "<comentario>" + comentario + "</comentario>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog05.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var mensagem=  xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	var codigo=  xmlTemp.getElementsByTagName("codigo")[0].childNodes[0].nodeValue;
	
	
	alert(mensagem)
}
function LeiaMaisNoticiaBlog(postagem) {
	
	
	pg ='blogPostagem.asp?postagem=' + postagem
			
	NewWindow(pg,'GoodDoctor','800','600','yes','center');return false
}

function AcessoCometariosBlog(postagem) {
	
	
	pg ='blogComentario.asp?postagem=' + postagem + '&opcaobusca=1' 
			
	NewWindow(pg,'GoodDoctor','600','400','yes','center');return false
	
}

function OpcaoBuscaComentario(postagem, unico) {
	var opcaobusca =getCheckedValue(document.form1.opcaobusca)
	var busca = document.form1.busca.value
	
	if (busca == '' && opcaobusca == 4){
		
		alert('Informe a busaca')
		
		document.form1.busca.focus()
		
		return false
	}
	
	
	
	pg ='blogComentario.asp?postagem=' + postagem + '&opcaobusca=' + opcaobusca + '&busca=' + busca
			
	location.href = pg
	
}

function MostrarComentario(comentario) {
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<comentario>" + comentario + "</comentario>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog06.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var nome=  xmlTemp.getElementsByTagName("nome")[0].childNodes[0].nodeValue;
	var email=  xmlTemp.getElementsByTagName("email")[0].childNodes[0].nodeValue;
	var texto=  xmlTemp.getElementsByTagName("texto")[0].childNodes[0].nodeValue;
	var divulgacao=  xmlTemp.getElementsByTagName("divulgacao")[0].childNodes[0].nodeValue;
	var liberar=  xmlTemp.getElementsByTagName("liberar")[0].childNodes[0].nodeValue;
	var postagem=  xmlTemp.getElementsByTagName("postagem")[0].childNodes[0].nodeValue;
	var ipcomputador=  xmlTemp.getElementsByTagName("ipcomputador")[0].childNodes[0].nodeValue;
	
	
	document.form1.nome.value = nome
	document.form1.email.value = email
	document.form1.texto.value = texto
	document.form1.divulgacao.value = divulgacao
	document.form1.comentario.value = comentario
	document.form1.postagem.value = postagem
	document.form1.ipcomputador.value = ipcomputador
	
	if (liberar == 1 ) {
		
		document.form1.liberar.checked = true
	}else{
		
		document.form1.liberar.checked = false
	}
	
	
}

function AlterarComentarioBlog() {
	var nome = document.form1.nome.value
	var email = document.form1.email.value
	var texto =document.form1.texto.value 
	var liberar =document.form1.liberar.checked 
	var comentario =document.form1.comentario.value 
	var postagem =document.form1.postagem.value 
	var divulgacao =document.form1.divulgacao.value
	var ipcomputador =document.form1.ipcomputador.value 
	var responsabilidade = 1
	
	
	if (liberar == true) {
		
		liberar = 1
	}else{
		
		liberar =0
		
	}
		
	if (nome == '' ) {
		alert('Nome em branco')
		var obj = document.form1.nome
		obj.visibility = 'visible'
		obj.backgroundColor='#FFFF6F'
		obj.focus()
		return false
	}
	
	if (email == '' ) {
		alert('Email em branco')
		var obj = document.form1.email
		obj.focus()
		obj.visibility = 'visible'
		obj.backgroundColor='#FFFF6F'
		
		return false
	}
	
	lRet= checkMail(email)
	
	if (lRet == false) {
		
		alert('Email invalido')
		
		var obj = document.form1.email
		obj.focus()
		obj.visibility = 'visible'
		obj.backgroundColor='#FFFF6F'
		
		return false
		
	}
	
	if (texto == '' ) {
		alert('Texto em branco')
		var obj = document.form1.texto
		obj.focus()
		obj.visibility = 'visible'
		obj.backgroundColor='#FFFF6F'
		return false
	}
	ipcomputador ='0000000'
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<postagem>" + postagem + "</postagem>";
	sxml = sxml + "<divulgacao>" + divulgacao + "</divulgacao>";
	sxml = sxml + "<nome>" + nome + "</nome>";
	sxml = sxml + "<email>" + email + "</email>";
	sxml = sxml + "<responsabilidade>" + responsabilidade + "</responsabilidade>";
	sxml = sxml + "<ipcomputador>" + ipcomputador + "</ipcomputador>";
	sxml = sxml + "<texto>" + texto + "</texto>";
	sxml = sxml + "<liberar>" + liberar + "</liberar>";
	sxml = sxml + "<comentario>" + comentario + "</comentario>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog05.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var mensagem=  xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	alert(mensagem)	
}

function BuscaGeral() {
	var buscageral= document.form1.buscageral.value
	var opcao =  getCheckedValue(document.form1.opcao)
	var estado = document.form1.estado.value
	var municipio = document.form1.municipio.value
	var marcador = getCheckedValue(document.form1.marcador)
	
	if (opcao == '1') {
		if (buscageral == '') {
			
			alert('Informe a palavra para a busca')
			
			document.form1.buscageral.focus()
			
			return false
		}
	}else if (opcao == '2'){
		
		if (marcador == 0 || marcador == '' ) {
			
			alert('Escolha o marcador a direita')
			
			document.form1.buscageral.focus()
			
			return false
			
		}
	}else if (opcao == '3'){
	
		if (estado == '' || estado == '0') {
			
			alert('Escolha o estado a direita abaixo')
			
			document.form1.estado.focus()
			
			return false
			
		}
	}else if (opcao == '4'){
		
		
		if (municipio == '' || municipio == '0') {
			
			alert('Escolha o municipio a direita abaixo')
			
			document.form1.municipio.focus()
			
			return false
			
		}
	}
	
	if (marcador == '' ) {
		marcador = 0
	}
	if (estado == '' ) {
		estado = 0
	}
	if (municipio == '' ) {
		municipio = 0
	}

	pagina = 'blogNoticias.asp?municipio='+ municipio + '&buscageral=' + buscageral + '&opcao=' + opcao + '&marcador=' + marcador + '&estado=' + estado 
	
	document.getElementById('divgeral').style.display = 'block'
	document.getElementById('div1').src=pagina 
}

function AbrirComentario(postagem) {
	var div = 'comentario' + postagem.toString()
	var obj = eval('document.form1.nomecomentario' + postagem.toString())
	var obj2 = eval('document.form1.emailcomentario' + postagem.toString())
	var obj3 = eval('document.form1.textocomentario' + postagem.toString())
	document.getElementById(div).style.display = 'block'
	
	obj.value = parent.document.form1.nomedivulgacao.value
	obj2.value = parent.document.form1.email.value
	obj3.visibility = 'visible'
	obj3.backgroundColor='#FFFF6F'
	obj3.focus()
}

function MostrarFoto(largura, altura, imagem) {
	
	var pg ='blogFoto.asp?imagem=' + imagem + '&altura=' + altura + '&largura=' + largura
	var largura = parseInt(largura) +20
	var altura = parseInt(altura) + 20
	NewWindow(pg,'WINBLOG', largura  , altura,'yes','center');return false

}

function AbrirPublicidade() {
	
	var pg ='blogPublicidade.asp'
	
	NewWindow(pg,'WINBLOG', '600'  , '400','yes','center');return false

}

function AbrirEmail() {
	
	var pg ='blogEmail.asp'
	
	NewWindow(pg,'WINBLOG', '600'  , '400','yes','center');return false

}
function EnviarPublicidade() {
	var nome = document.form1.nome.value
	var posicao = document.form1.posicao.value
	var altura = document.form1.altura.value
	var ativo = document.form1.ativo.checked
	var siteurl = document.form1.siteurl.value
	var contato = document.form1.contato.value
	var email = document.form1.email.value
	var telefone = document.form1.telefone.value
	var celular = document.form1.celular.value
	var publicidade = document.form1.publicidade.value
	
	if (nome == '') {
		
		alert('Informe o nome')
		
		document.form1.nome.focus()
		
		return false
		
	}
	
	if (posicao == '') {
		
		alert('Informe a posicao')
		
		document.form1.posicao.focus()
		
		return false
		
	}
	
	if (altura == '') {
		
		alert('Informe a altura')
		
		document.form1.altura.focus()
		
		return false
		
	}
	
	if (ativo == true) {
		
		ativo = 1
		
	}else{
		
		ativo = 0
		
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<nome>" + nome + "</nome>";
	sxml = sxml + "<posicao>" + posicao + "</posicao>";
	sxml = sxml + "<altura>" + altura + "</altura>";
	sxml = sxml + "<ativo>" + ativo + "</ativo>";
	sxml = sxml + "<siteurl>" + siteurl + "</siteurl>";
	sxml = sxml + "<contato>" + contato + "</contato>";
	sxml = sxml + "<email>" + email + "</email>";
	sxml = sxml + "<telefone>" + telefone + "</telefone>";
	sxml = sxml + "<celular>" + celular + "</celular>";
	sxml = sxml + "<publicidade>" + publicidade + "</publicidade>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog07.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var mensagem=  xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	var codigo=  xmlTemp.getElementsByTagName("codigo")[0].childNodes[0].nodeValue;
	document.form1.publicidade.value = codigo
	alert(mensagem)	
}

function SelecionaPublicidade(publicidade) {
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<publicidade>" + publicidade + "</publicidade>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog08.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var nome = xmlTemp.getElementsByTagName("nome")[0].childNodes[0].nodeValue;
	var posicao = xmlTemp.getElementsByTagName("posicao")[0].childNodes[0].nodeValue;
	var altura =xmlTemp.getElementsByTagName("altura")[0].childNodes[0].nodeValue;
	var ativo = xmlTemp.getElementsByTagName("ativo")[0].childNodes[0].nodeValue;
	var siteurl = xmlTemp.getElementsByTagName("siteurl")[0].childNodes[0].nodeValue;
	var contato = xmlTemp.getElementsByTagName("contato")[0].childNodes[0].nodeValue;
	var email = xmlTemp.getElementsByTagName("email")[0].childNodes[0].nodeValue;
	var telefone =xmlTemp.getElementsByTagName("telefone")[0].childNodes[0].nodeValue;
	var celular = xmlTemp.getElementsByTagName("celular")[0].childNodes[0].nodeValue;
	
	
	if (nome == 0) {
		nome = ''
	}
	
	if (posicao == 0) {
		posicao = ''
	}
	
	if (altura == 0) {
		altura = ''
	}
	
	if (siteurl == 0) {
		siteurl = ''
	}
	
	if (contato == 0) {
		contato = ''
	}
	
	if (email == 0) {
		email = ''
	}
	
	if (telefone == 0) {
		telefone = ''
	}
	
	if (celular == 0) {
		celular = ''
	}
	
	document.form1.nome.value= nome
	document.form1.posicao.value= posicao
	document.form1.altura.value= altura
	if (ativo == 1) {
		document.form1.ativo.checked= true
	}else{
		document.form1.ativo.checked= false
	}
	document.form1.siteurl.value= siteurl
	document.form1.contato.value= contato
	document.form1.email.value= email
	document.form1.telefone.value= telefone
	document.form1.celular.value= celular
	document.form1.publicidade.value= publicidade
}

function EnviarImagemPublicidade() {
	var publicidade = document.form1.publicidade.value
	
	if (publicidade > 0 ) {
	
		var pagina = 'http://www.winpesquisa.com.br/plataforma/imagem.asp?cod=' + publicidade + '&tabela=publicidade&externo=1'
		document.getElementById('imagem').src=pagina 
		document.getElementById('divimagem').style.display = 'block'
		//document.getElementById('imagem').style.display = 'block';
		document.getElementById('imagem').style.display = 'block'
	}else{
		
		alert('Primeiro envie a publicidade')
		document.form1.none.focus()
	}
}
function NovaPublicidadeBlog() {
	document.form1.nome.value= ''
	document.form1.posicao.value= ''
	document.form1.altura.value= ''
	document.form1.ativo.checked= false
	document.form1.siteurl.value= ''
	document.form1.contato.value= ''
	document.form1.email.value= ''
	document.form1.telefone.value= ''
	document.form1.celular.value= ''
	document.form1.publicidade.value= 0	
	
}

function OpcaoBuscaEmailBlog() {
	var opcaobusca =getCheckedValue(document.form1.opcaobusca)
	var busca = document.form1.busca.value
	var estado = document.form1.estado.value
	var municipio = document.form1.municipio.value
	var grupodivulgacao  = document.form1.grupodivulgacao.value
	var conviteblog = document.form1.conviteblog.value
	var limite = document.form1.limite.value
	
	
	if ( opcaobusca ==1 ){
		
		if ( estado == '0' || estado == '') {
			
			alert('Informe o Estado')
			
			document.form1.estado.focus()
			
			return false
		}
	}
	
	else if ( opcaobusca ==2 ){
		
		if (municipio == '0' || municipio == '' ){
		
			alert('Informe o Municipio')
			
			document.form1.municipio.focus()
			
			return false
		}
	}
	
	else if ( opcaobusca == 3 ){
		
		if (grupodivulgacao == '0' || grupodivulgacao == '') {
			alert('Informe o Grupo de Divulgacao')
			
			document.form1.grupodivulgacao.focus()
			
			return false
		}
	}
	
	else if ( opcaobusca == 4  ){
		
		if ( busca == '') {
			alert('Informe a busaca')
			
			document.form1.busca.focus()
			
			return false
		}
	}
	
	if (limite == '') {
		
		limite = 1
		
	}
	
	pg ='blogEmail2.asp?opcaobusca=' + opcaobusca + '&busca=' + busca + '&estado=' + estado + '&municipio=' + municipio + '&grupodivulgacao=' + grupodivulgacao + '&conviteblog=' + conviteblog
	+ '&limite=' + limite		
	document.getElementById('divemail').src=pg 
	
}

function EnviarEmailBlog() {
	var selecionados= document.form1.selecionados.value
	var n= 0;
	var i= 0;
	var acodigo= ""
	
	
	avetor = selecionados.split('/');
	n= avetor.length - 1
	while (i < n) {
		
		
		var str = eval('document.form1.C' + avetor[i].toString() )
		
		if (str.checked == true ) {
			
			acodigo = acodigo + str.value + ';'
			
		}
		
		i++
		
	}
	
	if (acodigo == '') {
		
		alert('Nenhum email selecionado')
		
		return false
		
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<acodigo>" + acodigo + "</acodigo>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog09.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var mensagem = xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	alert(mensagem)
	
	parent.OpcaoBuscaEmailBlog()
	
}

function ExcluirEmailBlog() {
	var email = document.form1.email.value
	
	if (email == '') {
		
		alert('Informe o email que quer excluir')
		
		document.form1.email.focus()
		
		return false
	}
	
	if (confirm('Tem certeza que deseja excluir este email') == false){
		
		document.form1.email.focus()
		
		return false
	}
	
	var xmldoc = new ActiveXObject("Microsoft.XMLDOM");
	xmldoc.async = false;
	var sxml;	
	sxml = "<ROOT>";
	sxml = sxml + "<email>" + email + "</email>";
	sxml = sxml + "</ROOT>";
	sxml = sxml.replace("&","&amp;");
	xmldoc.loadXML(sxml);
	var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	xmlhttp.Open("POST",'../../plataforma/includes/xmlBlog10.asp', false);
	xmlhttp.Send(xmldoc);                          
	var xmlTemp = xmlhttp.responseXML;
	var mensagem = xmlTemp.getElementsByTagName("mensagem")[0].childNodes[0].nodeValue;
	alert(mensagem)
}



function AbreLeiaMais(postagem) {
	var div = 'divleiamais'  + postagem.toString()
	var div2 = 'divleiamenos'  + postagem.toString()
	
	document.getElementById(div).style.display = 'block'
	document.getElementById(div2).style.display = 'none'
	var ancora = eval('document.form1.A' + postagem.toString())
	ancora.focus()
	//ancora.visibility = 'visible'
	//ancora.style.backgroundColor='#FFFF6F'
}
function FechaLeiaMais(postagem) {
	var div = 'divleiamais'  + postagem.toString()
	var div2 = 'divleiamenos'  + postagem.toString()
	document.getElementById(div).style.display = 'none'
	document.getElementById(div2).style.display = 'block'
	//var ancora = eval('document.form1.F' + postagem.toString())
	//ancora.focus()
	//ancora.visibility = 'visible'
}

function AbrirCriterio() {
	
	var pg ='criterio2.asp'
	
	NewWindow(pg,'WINBLOG', '600'  , '400','yes','center');return false

}

function EnviaPesquisa(municipio) {
	var sexo = getCheckedValue(document.form1.SEXO)
	var idade = getCheckedValue(document.form1.IDADE)
	var escolaridade = getCheckedValue(document.form1.ESCOLARIDADE)
	var trabalho = getCheckedValue(document.form1.TRABALHO)
	var classe = getCheckedValue(document.form1.CLASSE)
	var religiao = getCheckedValue(document.form1.RELIGIAO)
	var avaliacaom = getCheckedValue(document.form1.AVALIACAOM)
	var avaliacaoe = getCheckedValue(document.form1.AVALIACAOE)
	var avaliacaof = getCheckedValue(document.form1.AVALIACAOF)
	var futuro = getCheckedValue(document.form1.FUTURO)
	
	if (sexo == ''){
		
		alert('Escolha o sexo')
		
		return false
		
	}

	if (idade == ''){
		
		alert('Escolha a idade')
		
		return false
		
	}
	
	if (escolaridade == ''){
		
		alert('Escolha a escolaridade')
		
		return false
		
	}
	
	if (trabalho == ''){
		
		alert('Escolha o trabalho')
		
		return false
		
	}
	
	if (classe == ''){
		
		alert('Escolha a classe')
		
		return false
		
	}
	
	if (religiao == ''){
		
		alert('Escolha a religiao')
		
		return false
		
	}
	
	if (avaliacaom == ''){
		
		alert('Escolha a avaliacao municipal')
		
		return false
		
	}
	
	if (avaliacaoe == ''){
		
		alert('Escolha a avaliacao estadual')
		
		return false
		
	}
	
	if (avaliacaof == ''){
		
		alert('Escolha a avaliacao federeal')
		
		return false
		
	}
	
	if (futuro == ''){
		
		alert('Escolha o futuro')
		
		return false
		
	}
	
 	var pg = 'blogPesquisa.asp?enviar=sim&municipio=' + municipio + '&sexo=' + sexo + '&idade=' + idade + '&escolaridade=' + escolaridade + '&trabalho=' + trabalho + '&classe=' + classe + '&religiao=' + religiao + '&avaliacaom=' + avaliacaom + '&avaliacaoe=' + avaliacaoe + '&avaliacaof=' + avaliacaof + '&futuro=' + futuro
	
	location.href = pg
 
}

function EmailBody(z) {
	
	var pg ='pop2.asp?z=' +z.toString()
	
	NewWindow(pg,'WINBLOG', '800'  , '600','yes','center');return false
}

function AcessarEmail() {
	var emailpop= 	document.form1.emailpop.value
	var validos = document.form1.validos.checked
	var opcao= 	getCheckedValue(document.form1.opcao)
	
	if (validos == true ) {
		validos = 1
	}else{
		validos = 0
	}
	
	if (opcao == 1) {
	
		pg ='blogpop2.asp?emailpop=' + emailpop	+ '&validos=' + validos	
		
	}else{
		
		pg ='blogpop4.asp?emailpop=' + emailpop	+ '&validos=' + validos	
	}
	
	document.getElementById('divemailpop').src=pg 
	
}
