tms = new Array()
zindex = 100
function or(n){
	zindex += 1
    if(typeof(tms[n])!="undefined")clearTimeout(tms[n])
    document.getElementById("s"+n).style.display="block";
	document.getElementById("s"+n).style.zIndex=zindex;
}
function ot(n){
	tms[n]=setTimeout('document.getElementById("s'+n+'").style.display="none"',500);
}

function hD(n){
	tms[n]=setTimeout('document.getElementById("'+n+'").style.display="none"',100);
	return false;
}
function sD(n){
	tms[n]=setTimeout('document.getElementById("'+n+'").style.display="block"',100);
	return false;
}

try{
    xmlhttp = new XMLHttpRequest();
}catch(ee){
    try{
        xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    }catch(e){
        try{
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }catch(E){
            xmlhttp = false;
        }
    }
}
//Fila de conexões
fila=[]
ifila=0

//Carrega via XMLHTTP a url recebida e coloca seu valor
//no objeto com o id recebido
function ajaxHTML(id,url,t){
    //Carregando...
	if(t==0){
    document.getElementById(id).innerHTML='<div class="carregando">Carregando...</div>'
	}else if(t==2){
	document.getElementById('optCarrega').text='Carregando...'
	}else{
	
	}
	
    //Adiciona à fila
    fila[fila.length]=[id,url]
    //Se não há conexões pendentes, executa
    if((ifila+1)==fila.length)ajaxRun(t)
}

//Executa a próxima conexão da fila
function ajaxRun(t){
    //Abre a conexão
	if(t==0 || t == 2){
	    xmlhttp.open("GET",fila[ifila][1],true);
	}else{
		xmlhttp.open("POST", fila[ifila][1], true);
	    xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	}
    //Função para tratamento do retorno
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            //Mostra o HTML recebido
			if(t==0){
            retorno=unescape(xmlhttp.responseText.replace(/\+/g," "))
			document.getElementById(fila[ifila][0]).innerHTML=retorno
			}else if(t==2){
			retorno = unescape(xmlhttp.responseText.replace(/\+/g," "))
			//define e limpa o combo
			var cbo;
			cbo = document.getElementById('unidades');
			cbo.length = 1
			if(retorno != 'N/A'){
            retorno = new String(retorno)
			retorno2 = retorno.split("|")
			var xfor = retorno2.length-1
			//adiciona opçoes
			var oOption;
			for(i=0;i<=xfor;i++){
				retorno3 = new String(retorno2[i]);
				retorno4 = retorno3.split(";");
				oOption = document.createElement('OPTION');
				oOption.text = retorno4[0];
				oOption.value = retorno4[1];
				cbo.options.add(oOption);
			}
			document.getElementById('optCarrega').text='Selecione a Unidade'
			}else{
			document.getElementById('optCarrega').text='Nenhuma Unidade Encontrada'
			}
			
			}
            //Roda o próximo
            ifila++
            if(ifila<fila.length)setTimeout("ajaxRun()",20)
        }
    }
    //Executa
    xmlhttp.send(null)
}


atual=0

function carrega(n,p,t){
    //Carrega o HTML
	//t = 1 = xml
	//t = 0 = texto
	if(t==0){
    ajaxHTML(n,'pagina.asp?n='+p,t);
	}else{
	ajaxHTML(n,p,t);
	}
	return false;
}

//Fila de conexões
bfila=[]
bifila=0

function cepajaxHTML(id,url){
    //Carregando...
	endereco.value='Procurando...';
	endereco.disabled=true;
	bairro.value='Procurando...';
	bairro.disabled=true;
	cidade.value='Procurando...';
	cidade.disabled=true;
	estado.disabled=true;
	cep.disabled=true;

    //Adiciona à fila
    bfila[bfila.length]=[id,url]
    //Se não há conexões pendentes, executa
    if((bifila+1)==bfila.length)cepajaxRun()
}

//Executa a próxima conexão da fila
function cepajaxRun(){
    //Abre a conexão
    xmlhttp.open("GET",bfila[bifila][1],true);
    //Função para tratamento do retorno
    xmlhttp.onreadystatechange=function() {
        if (xmlhttp.readyState==4){
            //Mostra o HTML recebido
            retorno= xmlhttp.responseXML.documentElement.getElementsByTagName('cep')
			//rua, bairro, cidade, estado
			endereco.value=retorno[0].getAttribute('rua');
			bairro.value=retorno[0].getAttribute('bairro');
			cidade.value=retorno[0].getAttribute('cidade');
			cidadeid.value=retorno[0].getAttribute('codcidade');
			estado.value=retorno[0].getAttribute('estado');
			//libera campos para digitação
			cep.disabled=false;
			endereco.disabled=false;
			bairro.disabled=false;
			cidade.disabled=false;
			estado.disabled=false;
			numero.focus();
            //Roda o próximo
            bifila++
            if(bifila<bfila.length)setTimeout("cepajaxRun()",20)
        }
	}
    //Executa
    xmlhttp.send(null)
}

function buscacep(c){
	cepajaxHTML('endereco','preenchecep.asp?cep='+c);
}

xlnome = []
xlnome[0] = "Nome"
xlnome[1] = "Nombre"
xlnome[2] = "Name"
xldatanasc = []
xldatanasc[0] = "Data de Nascimento"
xldatanasc[1] = "Fetcha de Nascimiento"
xldatanasc[2] = "Birth Date"
xlemail = []
xlemail[0] = "Email"
xlemail[1] = "Correo Eletronico"
xlemail[2] = "E-mail"
xlsexo = []
xlsexo[0] = "Sexo"
xlsexo[1] = "Sexo"
xlsexo[2] = "Gender"
xlgrauinst = []
xlgrauinst[0] = "Grau de Instrução"
xlgrauinst[1] = "Grau de Instrução"
xlgrauinst[2] = "Grau de Instrução"
xlestadcivil = []
xlestadcivil[0] = "Estado Civil"
xlestadcivil[1] = "Estado Civil"
xlestadcivil[2] = "Estado Civil"
xlcep = []
xlcep[0] = "CEP"
xlcep[1] = "Codigo Postal"
xlcep[2] = "Zip Code"
xlendereco = []
xlendereco[0] = "Endereço"
xlendereco[1] = "Calle"
xlendereco[2] = "Adress"
xlnumero = []
xlnumero[0] = "Número"
xlnumero[1] = "Número"
xlnumero[2] = "Number"
xlcomplemento = []
xlcomplemento[0] = "Complemento"
xlcomplemento[1] = "Complemento"
xlcomplemento[2] = "Complemento"
xlbairro = []
xlbairro[0] = "Bairro"
xlbairro[1] = "Bairro"
xlbairro[2] = "Bairro"
xlcidade = []
xlcidade[0] = "Cidade"
xlcidade[1] = "Cidade"
xlcidade[2] = "Cidade"
xlestado = []
xlestado[0] = "Estado"
xlestado[1] = "Estado"
xlestado[2] = "Estado"
xlegdadoscomuns = []
xlegdadoscomuns[0] = "Dados Comuns"
xlegdadoscomuns[1] = "Dados Comuns"
xlegdadoscomuns[2] = "Dados Comuns"
xlegendereco = []
xlegendereco[0] = "Endereço"
xlegendereco[1] = "Dirección"
xlegendereco[2] = "Adress"
xlegdadoscontato = []
xlegdadoscontato[0] = "Dados de Contato"
xlegdadoscontato[1] = "Dados de Contato"
xlegdadoscontato[2] = "Contact Information"
xltela = []
xltela[0] = "Tel Res"
xltela[1] = "Tel Res"
xltela[2] = "Tel Res"
xltelb = []
xltelb[0] = "Tel Com"
xltelb[1] = "Tel Com"
xltelb[2] = "Tel Com"
xltelc = []
xltelc[0] = "Tel Cel"
xltelc[1] = "Tel Cel"
xltelc[2] = "Tel Cel"
xlpais = []
xlpais[0] = "Pais"
xlpais[1] = "Pais"
xlpais[2] = "Country"
xlinteresse = []
xlinteresse[0] = "Tenho uma escola e gostaria de integrar a rede BIT Company."
xlinteresse[1] = "Tenho uma escola e gostaria de integrar a rede BIT Company."
xlinteresse[2] = "Tenho uma escola e gostaria de integrar a rede BIT Company."
//xl = []
//xl[0] = ""
//xl[1] = ""
//xl[2] = ""

strCamposObrigatorios = "nome,email,datanasc"

function PreencheCampo(la){
	if(la=="")la=0;
	form = document.getElementById('frmCadastro');
	labels = form.getElementsByTagName('LABEL');
	legendas = form.getElementsByTagName('LEGEND');
	for(i=0;i<labels.length;i++){
		if(eval('x'+labels[i].id) != ''){
			eval("document.getElementById('"+labels[i].id+"').innerHTML=x"+labels[i].id+"["+la+"];");
		}
	}
	for(i=0;i<legendas.length;i++){
		if(eval('x'+legendas[i].id) != ''){
			eval("document.getElementById('"+legendas[i].id+"').innerHTML=x"+legendas[i].id+"["+la+"];")
		}
	}
	strCampos = strCamposObrigatorios.split(",");
	for(i=0;i<strCampos.length;i++){
		eval("document.getElementById('l"+strCampos[i]+"').innerHTML = document.getElementById('l"+strCampos[i]+"').innerHTML+'*'");
	}
}

function SetaCacheUnidades(t){
		var contorig = document.getElementById('prinCB');
		var cache = document.getElementById('prinCBB');
		if(t==1){
		contorig.innerHTML = cache.innerHTML;
		}else{
		cache.innerHTML = contorig.innerHTML;
		};
}
function SetaCacheFranquias(t){
		var contorig = document.getElementById('prinBpB');
		var cache = document.getElementById('prinCBB');
		if(t==1){
		contorig.innerHTML = cache.innerHTML;
		}else{
		cache.innerHTML = contorig.innerHTML;
		};
}
function SetaCache(o,d){
		var contorig = document.getElementById(o);
		var cache = document.getElementById(d);
		cache.innerHTML = contorig.innerHTML;
}

function AbrePopups(URL,janela,largura,altura,scrolls,status,toolbar,menubar,resizable,fullscreen) {

if (scrolls==''){
alert(janela);
myscrolls = 'no';
}else{
myscrolls = scrolls;
}
//status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no'
if(status==''){
mystatus = 'no';
}else{
mystatus = status;
}
if(toolbar==''){
mytoolbar = 'no';
}else{
mytoolbar = toolbar;
}
if(menubar==''){
mymenubar = 'no';
}else{
mymenubar = menubar;
}
if(resizable==''){
myresizable = 'no';
}else{
myresizable = resizable;
}
if(fullscreen==''){
myfullscreen = 'no';
}else{
myfullscreen = fullscreen;
}



var width = largura;
var height = altura;
var aw = screen.availWidth;
var ah = screen.availHeight;
var myleft = (aw - width)/2;
var mytop = (ah - height)/2;
if (myleft < 0){
myleft = 0;
}

if(mytop < 0){
mytop = 0;
}

   window.open(URL,janela, 'width='+width+', height='+height+', top='+mytop+', left='+myleft+', scrollbars='+myscrolls+', status='+mystatus+', toolbar='+mytoolbar+', location=no, directories=no, menubar='+mymenubar+', resizable='+myresizable+', fullscreen='+myfullscreen);

}
function PreencheCidades(uf){
	var cbo;
	cbo = document.getElementById('cidade');
	cbo.disabled = true;
	document.getElementById('optCarrega').text = "Aguarde..."
    //Abre a conexão
    xmlhttp.open("GET","buscacidades.asp?uf="+uf,true);
    //Função para tratamento do retorno
    xmlhttp.onreadystatechange=function(){
        if (xmlhttp.readyState==4){
            //Mostra o HTML recebido
			retorno = xmlhttp.responseXML.documentElement.getElementsByTagName('cidade')
			//define e limpa o combo
			cbo.length = 1;
			if(retorno.length != 0){
			//adiciona opçoes
			var oOption;
			for(i=0;i<retorno.length;i++){
				oOption = document.createElement('OPTION');
				oOption.text = retorno[i].getAttribute('cidade');
				oOption.value = retorno[i].getAttribute('cod');
				cbo.options.add(oOption);
			}
			document.getElementById('optCarrega').text='Clique aqui para selecionar a Cidade'
			}else{
			document.getElementById('optCarrega').text='Nenhuma Unidade Encontrada'
			}
			cbo.disabled = false;			
        }
    }
    //Executa
    xmlhttp.send(null)
}


function bloqElementos(tag){
	var elemento = document.getElementsByTagName(tag);
	for(i=0;i<elemento.length;i++){
		elemento[i].disabled = true;
		elemento[i].style.background='#eaeaea';
	}
}
function unbloqElementos(tag){
	var elemento = document.getElementsByTagName(tag);
	for(i=0;i<elemento.length;i++){
		elemento[i].disabled = false;
		elemento[i].style.background='#ffffff';
	}
}