

function doBusca(tuf, tipo)
{
	
	var putaqpariu = document.getElementById("barbadas_regiao")
	var tuamae = document.getElementById("lblcont1")
	var aquelavaca = document.getElementById("lblcont2")

	if (putaqpariu.options[putaqpariu.selectedIndex].text == "Brasil") {
		tuamae.innerHTML = ""
		tuamae.innerHTML = "Pa&iacute;s*"
		aquelavaca.innerHTML = ""
		aquelavaca.innerHTML = "Estado*"
	}
	else {
		tuamae.innerHTML = ""
		tuamae.innerHTML = "Continente*"
		aquelavaca.innerHTML = ""
		aquelavaca.innerHTML = "Pa&iacute;s*"
	}

    //limpa o select
    var c=document.getElementById("barbadas_subregiao")
    while(c.options.length>0)c.options[0]=null
    c.options[0]=new Option(" -- Aguarde ... -- "," -- Aguarde ... -- ")
	//alert(tuf);
    //Monta a url com a uf
	var codigo = tuf;
	var tipo = tipo;

    xmlhttp.open("GET", "barbadas_restrita_busca.php?cod="+codigo+"&tipo="+tipo,true);

    xmlhttp.onreadystatechange=function() 
	{
        if (xmlhttp.readyState==4)
		{
            //limpa o select
            var c=document.getElementById("barbadas_subregiao")
            while(c.options.length>0)c.options[0]=null
            //Transforma a lista de cidades JSON em Javascript
            var aSubregioes=eval((xmlhttp.responseText))
            //popula o select com a lista de cidades obtida
            for(var i=0;i<aSubregioes.length;i++)
			{
                aSubregioes[i]=unescape(aSubregioes[i])
				var nome = aSubregioes[i].split("*");
				//alert(nome[0]);
				//alert(nome[1]);
                c.options[c.options.length]=new Option(nome[0],nome[1])
            }
			//alert(tuf)
		/*	if(tuf == codigo[1])
			{
				document.cadastro.prof_local.disabled = 'true';
			}
		*/	
				
			/*if(DESC.value != "")
			{
				document.busca.local.style.display = 'block';
				document.busca.submit.style.display = 'block';
				document.getElementById("lotacao").style.display = 'block';
			}
			else
			{
				document.busca.local.style.display = 'none';
				document.busca.submit.style.display = 'none';
				document.getElementById("lotacao").style.display = 'none';
			}
			document.getElementById("selecionar").style.display = 'none';
			//esconde o 'selecionar' */
        }
    }

    xmlhttp.send(null)
}

function doBuscaCP(tuf,tipo)
{

	var putaqpariu = document.getElementById("cp_regiao")
	var tuamae = document.getElementById("lblcont1")
	var aquelavaca = document.getElementById("lblcont2")

	if (putaqpariu.options[putaqpariu.selectedIndex].text == "Brasil") {
		tuamae.innerHTML = ""
		tuamae.innerHTML = "Pa&iacute;s*"
		aquelavaca.innerHTML = ""
		aquelavaca.innerHTML = "Estado*"
	}
	else {
		tuamae.innerHTML = ""
		tuamae.innerHTML = "Continente*"
		aquelavaca.innerHTML = ""
		aquelavaca.innerHTML = "Pa&iacute;s*"
	}

	//limpa o select
    var c=document.getElementById("cp_subregiao")
    while(c.options.length>0)c.options[0]=null
    c.options[0]=new Option(" -- Aguarde ... -- "," -- Aguarde ... -- ")
	//alert(tuf);
    //Monta a url com a uf
	var codigo = tuf;
	var tipocp = tipo;

    xmlhttp.open("GET", "cp_restrita_busca.php?cod="+codigo+"&tipo="+tipocp,true);

    xmlhttp.onreadystatechange=function() 
	{
        if (xmlhttp.readyState==4)
		{
            //limpa o select
            var c=document.getElementById("cp_subregiao")
            while(c.options.length>0)c.options[0]=null
            //Transforma a lista de cidades JSON em Javascript
            var aSubregioes=eval((xmlhttp.responseText))
            //popula o select com a lista de cidades obtida

            for(var i=0;i<aSubregioes.length;i++)
			{
                aSubregioes[i]=unescape(aSubregioes[i])
				var nome = aSubregioes[i].split("*");
				//alert(nome[0]);
				//alert(nome[1]);
                c.options[c.options.length]=new Option(nome[0],nome[1])
            }
			//alert(tuf)
		/*	if(tuf == codigo[1])
			{
				document.cadastro.prof_local.disabled = 'true';
			}
		*/	
				
			/*if(DESC.value != "")
			{
				document.busca.local.style.display = 'block';
				document.busca.submit.style.display = 'block';
				document.getElementById("lotacao").style.display = 'block';
			}
			else
			{
				document.busca.local.style.display = 'none';
				document.busca.submit.style.display = 'none';
				document.getElementById("lotacao").style.display = 'none';
			}
			document.getElementById("selecionar").style.display = 'none';
			//esconde o 'selecionar' */
        }
    }

    xmlhttp.send(null)
}


function preencheFotos(param)
{
    //var linha  = document.getElementById("tabela_precos")
	var tabela  = document.getElementById("tabelaNFotos")
	var numLinhas = tabela.rows.length
	var contador = numLinhas/2

	for(var n=1; n<=param; n++) {
		contador++

		var linha = tabela.insertRow(-1)
		var newcell = linha.insertCell(-1)
		newcell.innerHTML = '<span class="texto_restrita_cp">Foto ' + contador + '</span>'
		newcell.align = 'right'
		newcell.width = '80'

		var newcell = linha.insertCell(-1)
		newcell.innerHTML = '<input name="fotos[]" type="file" id="file" size="42">'
		newcell.align = 'left'


		var linha = tabela.insertRow(-1)
		var newcell = linha.insertCell(-1)
		newcell.innerHTML = '<span class="texto_restrita_cp">Legenda ' + contador + '</span>'
		newcell.align = 'right'

		var newcell = linha.insertCell(-1)
		newcell.innerHTML = '<input type="text" name="legenda[]" size="20" class="campo_restrita_cp" />'
		newcell.align = 'left'
		
	}
	
	var qtdFotos  = document.getElementById("qtdfotos")
	qtdFotos.value = contador

}

function limparFotos()
{
		var tabela  = document.getElementById("tabelaNFotos")
		var numLinhas = tabela.rows.length
		
		if (numLinhas > 1) {
			for (var i=1; i<=numLinhas; i++) {
				tabela.deleteRow(-1)
			}
		}

}


function busca_usuario(user, verifica)
{
	if(user == "")
	{
		document.getElementById("flag_status").innerHTML='';
		document.getElementById("flag_status").innerHTML='&nbsp;<img src="img/error.gif">';
		return false;
	}
	
	if(verifica == '')
		verifica = 0;
	else
		verifica = 1;
	//alert(user)
    xmlhttp.open("GET", "cadastro_ver_status.php?user="+user,true);

	
	//setTimeOut('',4000);
    xmlhttp.onreadystatechange=function() 
	{
        if (xmlhttp.readyState==4)
		{
			//alert("teste 1");
            //Transforma a lista de cidades JSON em Javascript
            var resultado = xmlhttp.responseText
            //alert(resultado)
			//popula o select com a lista de cidades obtida
			if((resultado != "Existente") && (user != ""))
			{
				document.getElementById("flag_status").innerHTML='';
				document.getElementById("flag_status").innerHTML='<span style="color:#00CC33">Disponível</span>';
				if(verifica)
					status = 1;
					
			}
			if(resultado != "Nao_existe")
			{
				document.getElementById("flag_status").innerHTML='';
				document.getElementById("flag_status").innerHTML='Usuário não disponível!';
				
				//document.cadastro.usuario.focus();
				if(verifica)
				{
					alert("Usuario Existente!");
					status=0;
				}
			}
			
        }
    }
    xmlhttp.send(null)
	
	//alert("teste 2");
	if(status)
		return true;
	else
		return false;
	
	//return true;
}
