function Pooopup(pagina, largura, altura) {
	w = screen.width;
	h = screen.height;
	meio_w = w/2;
	meio_h = h/2;

	altura2 = altura/2;
	largura2 = largura/2;
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;

	if(screen.width <= 1024) {
		window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+'');
	} else {
		window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+'');
	}
}
function Dados(valor) {
	try { ajax = new ActiveXObject("Microsoft.XMLHTTP"); } 
	catch(e) { 
		try {ajax = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch(ex) {
			try { ajax = new XMLHttpRequest(); }
			catch(exc) { 
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
         }
      }
	  if(ajax) {
		 document.forms[0].listCidades.options.length = 1;
		 idOpcao  = document.getElementById("opcoes");
	     ajax.open("POST", "cidadesdobrasil/cidades.php", true);
		 ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		 
		 ajax.onreadystatechange = function() {
			if(ajax.readyState == 1) {
			   idOpcao.innerHTML = "Carregando...!";
	        }
            if(ajax.readyState == 4 ) {
			   if(ajax.responseXML) {
			      processXML(ajax.responseXML);
			   } else {
			       //caso não seja um arquivo XML emite a mensagem abaixo
				   idOpcao.innerHTML = "Primeiro selecione o Estado";
			   }
            }
         }
		 //passa o código do estado escolhido
	     var params = "estado="+valor;
         ajax.send(params);
      }
   }
function processXML(obj) {
	//pega a tag cidade
	var dataArray   = obj.getElementsByTagName("cidade");
	//total de elementos contidos na tag cidade
	if(dataArray.length > 0) {
		//percorre o arquivo XML paara extrair os dados
		for(var i = 0 ; i < dataArray.length ; i++) {
			var item = dataArray[i];
			//contéudo dos campos no arquivo XML
			var codigo    =  item.getElementsByTagName("codigo")[0].firstChild.nodeValue;
			var descricao =  item.getElementsByTagName("descricao")[0].firstChild.nodeValue;
			idOpcao.innerHTML = "Selecione uma Cidade!";
			//cria um novo option dinamicamente  
			var novo = document.createElement("option");
			//atribui um ID a esse elemento
			novo.setAttribute("id", "opcoes");
			novo.value = codigo;
			novo.text  = descricao;
			//finalmente adiciona o novo elemento
			document.forms[0].listCidades.options.add(novo);
		}
	} else {
		//caso o XML volte vazio, printa a mensagem abaixo
		idOpcao.innerHTML = "Selecione uma Cidade!";
	}	  
}
function ativar(ativar,avisoidl) { 
	var Aviso = document.getElementById(avisoidl);
	if(ativar == 'sim') {
		Aviso.style.display= 'block';
	} else {
		Aviso.style.display = 'none';
	}
}
function ValidarInscricao(theForm) {
	if(theForm.nomecompleto.value=="") 		{ alert("Digite seu Nome Completo corretamente!"); theForm.nomecompleto.focus(); return (false);  				 }
	if(theForm.cpf.value=="") 		  		{ alert("Digite seu CPF!"); theForm.cpf.focus(); return (false);												 }
	if(theForm.rg.value=="") 		  		{ alert("Digite sua Identidade!"); theForm.rg.focus(); return (false); 											 }
	if(theForm.datadenascimento.value=="") 	{ alert("Digite sua Data de Nascimento!!"); theForm.datadenascimento.focus(); return (false); 					 }
	if(theForm.sexo.value=="0")				{ alert("Selecione seu Sexo!"); theForm.sexo.focus(); return (false); 											 }
	if(theForm.listEstados.value=="0") 		{ alert("Selecione seu Estado!"); theForm.listEstados.focus(); return (false);									 }
	if(theForm.listCidades.value=="0")		{ alert("Selecione sua Cidade!"); theForm.listCidades.focus(); return (false);									 }
	if(theForm.endereco.value=="")			{ alert("Digite seu Endereço!"); theForm.endereco.focus(); return (false);										 }
	if(theForm.bairro.value=="")			{ alert("Digite seu Bairro!"); theForm.bairro.focus(); return (false);											 }
	if(theForm.cep.value=="")				{ alert("Digite seu CEO!"); theForm.cep.focus(); return (false);												 }
	if(theForm.telefone.value=="")			{ alert("Digite seu Telefone!"); theForm.telefone.focus(); return (false);										 }
	if(theForm.celular.value=="")			{ alert("Digite seu Celular!"); theForm.celular.focus(); return (false); 										 }
	if(theForm.email.value=="")				{ alert("Digite seu E-mail!"); theForm.email.focus(); return (false); 											 }
	if(theForm.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) { alert("E-mail inválido!"); theForm.email.focus(); return (false); }
	
	var controle = 0;
	for (i=0;i<document.FormInscricao.elements.length;i++) {
		if (document.FormInscricao.elements[i].type == "radio") {
			if (document.FormInscricao.elements[i].checked == true){
				controle++;
			}
		}
	}
	if(controle <= 0) 						{ alert("Ainda há campos obrigatórios sem preenchimento!"); return (false);										 }
	if(theForm.aceito.checked==false)		{ alert("Preencha o termo de ACEITAÇÃO do Requerimento!"); theForm.aceito.focus(); return (false); 				 }
	return(true);
}
function ValidarFaleConosco(theForm) {
	if (theForm.nome2.value == "") { alert("Digite seu Nome!"); theForm.nome2.focus(); return (false); }
	if (theForm.email.value == "") { alert("Digite seu email!"); theForm.email.focus(); return (false); }
	if (theForm.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) { alert("E-mail inválido!"); theForm.email.focus(); return (false); }
	if (theForm.assunto.value == "") { alert("Digite o Assunto!"); theForm.assunto.focus(); return (false); }
	if (theForm.listEstado.value == "0") { alert("Selecione um Estado!"); theForm.listEstado.focus(); return (false); }
	if (theForm.listCidades.value == "0") { alert("Selecione a Cidade!"); theForm.listCidades.focus(); return (false); }
	if (theForm.mensagem.value == "") { alert("Digite a sua Mensagem!"); theForm.mensagem.focus(); return (false); }
	return (true);
}

function MM_jumpMenu(targ,selObj,restore) {
	eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
	if(restore) selObj.selectedIndex=0;
}
function validate2(theForm) {
	if(theForm.email.value == "") { alert("Digite seu email!"); theForm.email.focus(); return (false); }
	if(theForm.email.value.search(/^\w+((-\w+)|(\.\w+))*\@\w+((\.|-)\w+)*\.\w+$/) == -1) { alert("E-mail inválido!"); theForm.email.focus(); return (false); } 
	return (true);
}
function pesquisar(texto) { 
	url="./areadoacademico/diretorio_resposta.php?texto="+texto
	ajaxGet(url,document.getElementById("resposta"),'true');
}
function Abre(URL){
	var width = 360;
	var height = 255;	
	var left = 99;
	var top = 99;
	window.open(URL, 'Radio_FAIS_Online', 'width='+width+', height='+height+', top='+top+', left='+left+', scrollbars=no, status=no, toolbar=no, location=no, directories=no, menubar=no, resizable=no, fullscreen=no');
}
function getPageSize() {
	var xScroll, yScroll;
	if(window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight) {
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;

	if(self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	if(yScroll < windowHeight) {
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	if(xScroll < windowWidth) {
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

function getPageScroll() {
	var yScroll;
	if(self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function verifica(v) { return((typeof(v)=='undefined' || v.length==0)? false : true); }
function agent(v) { return(Math.max(navigator.userAgent.toLowerCase().indexOf(v),0)); }
function XeYjanela(v) { var z=agent('msie')?Array(document.body.clientHeight,document.body.clientWidth):Array(window.innerHeight,window.innerWidth); return(verifica(v)?z[v]:z);  }

function abrelight(x,tam, tipo) {
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var fundo = document.getElementById('over');
	var div = document.getElementById(x);

	fundo.style.display='block';
	div.style.display='block';
	div.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - tam) / 2) + 'px');
	div.style.left = (((arrayPageSize[0] - 20 - tam) / 2) + 'px');
}

function fechalight(div) {
	var fundo = document.getElementById('over');	
	var div2 = document.getElementById(div);

	fundo.style.display='none';
	div2.style.display='none';
}

function vertamanho() {
	var fundo = document.getElementById('over');
	if(fundo.style.display=='block') {
		abreWebMail();
	}
}

function abreWebMail() {
	scrollTo(0,0);
	var div = 'webmail';
	var altu = 158;
	var larg = 308;
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();

	var fundo = document.getElementById('over');
	var div_get = document.getElementById(div);		

	fundo.style.display='block';
	fundo.style.height = arrayPageSize[1];

	div_get.style.display='block';	
	div_get.style.top = (arrayPageScroll[1] + ((arrayPageSize[3] - 35 - altu) / 2) + 'px');
	div_get.style.left = (((arrayPageSize[0] - 20 - larg) / 2) + 'px');
}

function mascara(o,f) {
	v_obj=o
	v_fun=f
	setTimeout("execmascara()",1)
}

function execmascara() {
	v_obj.value=v_fun(v_obj.value)
}

function leech(v) {
	v=v.replace(/o/gi,"0")
	v=v.replace(/i/gi,"1")
	v=v.replace(/z/gi,"2")
	v=v.replace(/e/gi,"3")
	v=v.replace(/a/gi,"4")
	v=v.replace(/s/gi,"5")
	v=v.replace(/t/gi,"7")
	return v
}

function soNumeros(v) {
	return v.replace(/\D/g,"")
}

function telefone(v) {
	v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
	v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
	v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
	return v
}

function itelefone(v) {
	v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
	v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
	v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
	return v
}

function ddd(v) {
	v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
	v=v.replace(/^(\d\d)(\d)/g,"($1)") //Coloca parênteses em volta dos dois primeiros dígitos
	return v
}

function cpf(v) {
	v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
	v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	//de novo (para o segundo bloco de números)
	v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
	return v
}

function cpfx(v) {
	v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
	v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
	//de novo (para o segundo bloco de números)
	v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
	return v
}

function cep(v) {
	v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
	v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
	return v
}

function icep(v) {
	v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
	v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
	return v
}

function cnpj(v) {
	v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
	v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
	v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
	v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
	v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
	return v
}

function romanos(v) {
	v=v.toUpperCase()             //Maiúsculas
	v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
	//Essa é complicada! Copiei daqui: http://www.diveintopython.org/refactoring/refactoring.html
	while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
	v=v.replace(/.$/,"")
	return v
}

function site(v) {
	//Esse sem comentarios para que você entenda sozinho ;]
	v=v.replace(/^http:\/\/?/,"")
	dominio=v
	caminho=""
	if(v.indexOf("/")>-1)
		dominio=v.split("/")[0]
		caminho=v.replace(/[^\/]*/,"")
		dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
		caminho=caminho.replace(/[^\w\d\+-@:\?&=%\(\)\.]/g,"")
		caminho=caminho.replace(/([\?&])=/,"$1")
		if(caminho!="")dominio=dominio.replace(/\.+$/,"")
			v="http://"+dominio+caminho
	return v
}

function barra(objeto) {
	if (objeto.value.length == 2 || objeto.value.length == 5 ){
		objeto.value = objeto.value+"/";
	}
}