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){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	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){//by Renan Henrique

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(tipo,div){//by Renan Henrique
	
	var fundo = document.getElementById('over');	
	var div2 = document.getElementById(div);
	
	fundo.style.display='none';
	div2.style.display='none';

}

function Inicializa(){//by Renan Henrique
	document.write("<div id='over'></div>");
}
Inicializa();//by Renan Henrique


function vertamanho(div){//by Renan Henrique
var fundo = document.getElementById('over');
	if(fundo.style.display=='block'){	
		abrelight(div,'200');
	}
}
function abredoc(cod){
	window.open('/colegioalternativo/home/download_now.php?cod='+cod);
}

function clickRematricula(){
	document.getElementById('rematricula').style.display='block';
	document.getElementById('novamatricula').style.display='none';
}
function clickNovaMatricula(){
	document.getElementById('rematricula').style.display='none';
	document.getElementById('novamatricula').style.display='block';
}
function mandaValores(tipo){
	if(tipo=='pai'){
		document.getElementById('fone_cel_resp_financeiro').value=document.getElementById('fone_cel_pai').value;
		document.getElementById('data_nasc_resp_financeiro').value=document.getElementById('data_nasc_pai').value;
		document.getElementById('nome_resp_financeiro').value=document.getElementById('nome_pai').value;
	}else if(tipo=='mae'){
		document.getElementById('fone_cel_resp_financeiro').value=document.getElementById('fone_cel_mae').value;
		document.getElementById('data_nasc_resp_financeiro').value=document.getElementById('data_nasc_mae').value;
		document.getElementById('nome_resp_financeiro').value=document.getElementById('nome_mae').value;
	}

}

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 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 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 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+"/";
}
}


function validate(theForm){
	if (theForm.nome_aluno.value == ""){
	   alert("Digite o nome do Aluno!");
	   theForm.nome_aluno.focus();
	   return (false);
	}
	if (theForm.data_nasc_aluno.value == ""){
	   alert("Digite a data de nascimento do Aluno!");
	   theForm.data_nasc_aluno.focus();
	   return (false);
	}
	if (theForm.naturalidade_aluno.value == ""){
	   alert("Digite a naturalidade do Aluno!");
	   theForm.naturalidade_aluno.focus();
	   return (false);
	}
	if (theForm.nacionalidade_aluno.value == ""){
	   alert("Digite a nacionalidade do Aluno!");
	   theForm.nacionalidade_aluno.focus();
	   return (false);
	}
	if (theForm.endereco_aluno.value == ""){
	   alert("Digite o Endereço do Aluno!");
	   theForm.endereco_aluno.focus();
	   return (false);
	}
	if (theForm.num_endereco_aluno.value == ""){
	   alert("Digite o numero do Endereço do Aluno!");
	   theForm.num_endereco_aluno.focus();
	   return (false);
	}
	if (theForm.fone_cel_aluno.value == ""){
	   alert("Digite o Telefone/Celular do Aluno!");
	   theForm.fone_cel_aluno.focus();
	   return (false);
	}
	if (theForm.bairro_aluno.value == ""){
	   alert("Digite o Bairro do Aluno!");
	   theForm.bairro_aluno.focus();
	   return (false);
	}
	if (theForm.cidade_aluno.value == ""){
	   alert("Digite a Cidade do Aluno!");
	   theForm.cidade_aluno.focus();
	   return (false);
	}
	if (theForm.cep_aluno.value == ""){
	   alert("Digite o CEP do Aluno!");
	   theForm.cep_aluno.focus();
	   return (false);
	}
	if (theForm.nome_pai.value == ""){
	   alert("Digite o nome do pai do Aluno!");
	   theForm.nome_pai.focus();
	   return (false);
	}
	if (theForm.fone_cel_pai.value == ""){
	   alert("Digite o Telefone/Celular do pai do Aluno!");
	   theForm.fone_cel_pai.focus();
	   return (false);
	}
	if (theForm.data_nasc_pai.value == ""){
	   alert("Digite a data de nascimento do pai do Aluno!");
	   theForm.data_nasc_pai.focus();
	   return (false);
	}
	
	if (theForm.nome_mae.value == ""){
	   alert("Digite o nome da mãe do Aluno!");
	   theForm.nome_mae.focus();
	   return (false);
	}
	if (theForm.fone_cel_mae.value == ""){
	   alert("Digite o Telefone/Celular da mãe do Aluno!");
	   theForm.fone_cel_mae.focus();
	   return (false);
	}
	if (theForm.data_nasc_mae.value == ""){
	   alert("Digite a data de nascimento da mãe do Aluno!");
	   theForm.data_nasc_mae.focus();
	   return (false);
	}
	
	if (theForm.resp_finan.value == ""){
	   alert("Selecione quem será/é o Responsável Financeiro do Aluno!");
	   return (false);
	}
	if (theForm.est_civil_resp_financeiro.value == ""){
	   alert("Digite o estado civil do responsável financeiro do Aluno!");
	   theForm.est_civil_resp_financeiro.focus();
	   return (false);
	}
	if (theForm.cpf_resp_financeiro.value == ""){
	   alert("Digite o CPF do responsável financeiro do Aluno!");
	   theForm.cpf_resp_financeiro.focus();
	   return (false);
	}
	if (theForm.naturalidade_resp_financeiro.value == ""){
	   alert("Digite a naturalidade do responsável financeiro do Aluno!");
	   theForm.naturalidade_resp_financeiro.focus();
	   return (false);
	}
	if (theForm.nacionalidade_resp_financeiro.value == ""){
	   alert("Digite a nacionalidade do responsável financeiro do Aluno!");
	   theForm.nacionalidade_resp_financeiro.focus();
	   return (false);
	}
	if (theForm.rg_resp_financeiro.value == ""){
	   alert("Digite o RG do responsável financeiro do Aluno!");
	   theForm.rg_resp_financeiro.focus();
	   return (false);
	}

	if(confirm("Todos os dados estão corretos?")){
		return true;
	}else{	
		return false;
	}
}
