//scripts



local = String(document.location);



local_split = local.split("?");

local = local_split[0];



var tt = pagina.split('.php');

var rr = tt[0].split('/');



var url ='http://';

for(var i = 0; i < rr.length -1 ; i++){	

	if(rr[i]){

		url += rr[i]+"/";	

	}

}



if(local.indexOf('index') == -1){

	if(!window.name && local != url){

		par = (local_split[1])?"?"+local_split[1]:"";

		window.location = url+'?url='+local_split[0]+par;

	}

}





function wopen(page){

	document.getElementById('overlay').style.display = "block";

	if(!document.all){

		document.getElementById('overlay').style.background = "transparent url(css/img/overlay.gif) repeat 0 0";

	}

	document.getElementById('pop_dom').style.display = "block";

	document.getElementById('pop_dom').style.left = (screen.width - 600)/2 + "px";

	document.getElementById('bt_fechar_pop').style.display = "block";

	document.getElementById('bt_fechar_pop').style.left = (screen.width + 370)/2 + "px";

	parent.decidindo_pop.location = page;

}



function wclose(){

	parent.decidindo_pop.location = "blank.html";

	document.getElementById('overlay').style.display = "none";

	document.getElementById('pop_dom').style.display = "none";

	document.getElementById('bt_fechar_pop').style.display = "none";

}



function wopen1(page){

	document.getElementById('overlay').style.display = "block";

	if(!document.all){

		document.getElementById('overlay').style.background = "transparent url(css/img/overlay.gif) repeat 0 0";

	}

	document.getElementById('pop_dom_qi').style.display = "block";

	document.getElementById('pop_dom_qi').style.left = (screen.width - 700)/2 + "px";

	document.getElementById('bt_fechar_pop_qi').style.display = "block";

	document.getElementById('bt_fechar_pop_qi').style.left = (screen.width + 470)/2 + "px";

	parent.decidindo_pop_qi.location = page;

}



function wclose1(){

	parent.decidindo_pop_qi.location = "blank.html";

	document.getElementById('overlay').style.display = "none";

	document.getElementById('pop_dom_qi').style.display = "none";

	document.getElementById('bt_fechar_pop_qi').style.display = "none";

}



function EnviarComentario(){

	frm = document.formulario;

	

	if(frm.nome.value == ""){

		alert("Por favor preencha o seu nome antes de enviar.");

		frm.nome.focus();

	}

	else{

		if(frm.email.value == "" || frm.email.value.indexOf("@") < 0 || frm.email.value.indexOf(".") < 0){

			alert("Por favor preencha o seu e-mail corretamente.");

			frm.email.focus();

		}

		else{

			if(frm.cidade.value == ""){

				alert("Por favor preencha o campo cidade.");

				frm.cidade.focus();

			}

			else{

				if(frm.estado.value == ""){

					alert("Por favor escolha um estado.");

					frm.estado.focus();

				}

				else{

					if(frm.texto.value == ""){

						alert("Por favor escreva o seu comentário.");

						frm.texto.focus();

					}

					else{

						frm.action = "comentar2.php";

						frm.submit();

					}

				}

			}

		}

	}

}

function EnviarComentarioEN(){

	frm = document.formulario;

	

	if(frm.nome.value == ""){

		alert("Field NAME is obligatory.");

		frm.nome.focus();

	}

	else{

		if(frm.email.value == "" || frm.email.value.indexOf("@") < 0 || frm.email.value.indexOf(".") < 0){

			alert("Email incorrect.");

			frm.email.focus();

		}

		else{

			if(frm.cidade.value == ""){

				alert("Field CITY is obligatory.");

				frm.cidade.focus();

			}

			else{

				if(frm.estado.value == ""){

					alert("Field STATE is obligatory.");

					frm.estado.focus();

				}

				else{

					if(frm.texto.value == ""){

						alert("Field COMMENT is obligatory.");

						frm.texto.focus();

					}

					else{

						frm.action = "comentar2-en.php";

						frm.submit();

					}

				}

			}

		}

	}

}

function EnvieAmigo(){

	frm = document.formulario;

	

	if(frm.nome.value == ""){

		alert("Por favor preencha o seu nome antes de enviar.");

		frm.nome.focus();

	}

	else{

		if(frm.email.value == "" || frm.email.value.indexOf("@") < 0 || frm.email.value.indexOf(".") < 0){

			alert("Por favor preencha o seu e-mail corretamente.");

			frm.email.focus();

		}

		else{

			if(frm.nome_amigo.value == ""){

				alert("Por favor preencha o nome de seu amigo antes de enviar.");

				frm.nome_amigo.focus();

			}

			else{

				if(frm.email_amigo.value == "" || frm.email_amigo.value.indexOf("@") < 0 || frm.email_amigo.value.indexOf(".") < 0){

					alert("Por favor preencha o e-mail do seu amigo corretamente.");

					frm.email_amigo.focus();

				}

				else{

					frm.action = "envie_amigo.php";

					frm.submit();

				}

			}

		}

	}

}





// inicio - dhtmls scrolls

var speed=25;

var inter=5;

var loop, timer;



function ConstructObject(obj,nest, Container){ 

	nest=(!nest) ? '':'document.'+nest+'.';

	this.el=document.getElementById(obj); 

	this.css=document.getElementById(obj).style; 

	this.scrollHeight = this.el.offsetHeight;

	this.clipHeight = this.el.offsetHeight;

	this.scrollWidth = this.el.offsetWidth;

	this.clipWidth = this.el.offsetWidth;

	this.up=MoveAreaUp;

	this.down=MoveAreaDown; 

	this.left=MoveAreaLeft;

	this.right=MoveAreaRight; 

	this.MoveArea=MoveArea;

	this.objContainer = (!Container)? this : eval(Container);

	this.x;

	this.y;

	this.obj = obj + "Object";

	eval(this.obj + "=this");

	return this;

} 



function MoveArea(x,y){ 

	this.x = x;

	this.y = y; 

	this.css.left=this.x + "px";

	this.css.top=this.y + "px";

} 



function MoveAreaDown(move){ 

	if(this.y>-this.scrollHeight+this.objContainer.clipHeight){ 

		this.MoveArea(0,this.y-move);

		if(loop){

			setTimeout(this.obj+".down("+move+")",speed);

		} 

	}

}



function MoveAreaUp(move){ 

	if(this.y<0){ 

		this.MoveArea(0,this.y-move);

		if(loop){

			setTimeout(this.obj+".up("+move+")",speed);

		}

	}

}



function PerformScroll(speed, objA, objB){ 

	if(initialised){ 

		loop=true; 

		if(speed>0){

			objB.down(speed);

		}

		else{

			objB.up(speed);

		}

	} 

} 



function CeaseScroll(){ 

	loop=false 

	if(timer){

		clearTimeout(timer);

	}

} 



function MoveAreaRight(move){ 

	if(this.x>-this.scrollWidth+this.objContainer.scrollWidth){ 

		this.MoveArea(this.x-move,0);

		if(loop){

			setTimeout(this.obj+".right("+move+")",speed);

		} 

	}

}



function MoveAreaLeft(move){ 

	if(this.x<0){ 

		this.MoveArea(this.x-move,0);

		if(loop){

			setTimeout(this.obj+".left("+move+")",speed);

		}

	}

}



function LateralScroll(speed, objA, objB){ 

	if(initialised){ 

		loop=true; 

		if(speed>0){

			objB.right(speed);

		}

		else{

			objB.left(speed);

		}

	} 

}



var initialised;

// fim - dhtmls scrolls





area = "home";



// muda área

function trocaArea(par){

	area = par;

	//alert(area);

}





// Método a ser executado pelo Flash.

function FlashJavaScript(){

	return area;

}





function enviaFormulario(){

	var frm = document.formulario;

	var checagem = 1;

	var count = frm.elements.length;

	var str_campo = "";

	

	for(i=0; i<frm.elements.length; i++){

		

		if(msg[frm.elements[i].name]){

			if(vld[frm.elements[i].name] == 1){

				checagem = validaCampo(frm.elements[i]);

			}

			else if(vld[frm.elements[i].name] == 2){

				checagem = validaEmail(frm.elements[i]);

			}

			

			if(!checagem){

				str_campo += " - " + msg[frm.elements[i].name] + ";\n";

				count --;

			}

		}

	}

	

	if(count == frm.elements.length){

		frm.action = destino_frm;

		frm.submit();

	}

	else{

		alert('Por favor, preencha corretamente os campos abaixo:\n\n' + str_campo);

	}

}



/*function validaEscolaridade(){

	if(!verificaEscola())

		alert('Preencha o campo escola');

		

	if(!verificaCurso())

		alert('Preencha o campo curso');

		

	if(!verificaSemestre())

		alert('Preencha o campo Semestre');



}



function verificaEscola(){//3

	var frm = document.formulario;

	if(frm.escolaridade.value!=''){

		if(frm.escola.value==''){

			return false;

		}

	}

	return true;

}



function verificaCurso(){//4

	var frm = document.formulario;

	if(frm.escolaridade.selectedIndex >2){

		if(frm.curso.value==''){

			return false;

		}

	}

	return true;

}



function verificaSemestre(){//5

	var frm = document.formulario;

	if(frm.escolaridade.value!=''){

		if(frm.semestre.value==''){

			return false;

		}

	}

	return true;

}*/



function validaCampo(campo){

	return campo.value != "";

}



function validaEmail(campo){

	return (campo.value != "" && campo.value.indexOf("@") > 0 && campo.value.indexOf(".") > 0);

}



function apenasNum(campo){

	campo.value = campo.value.replace(/[^0-9]/g, '');

}



function FormataData(){

	var mes = document.formulario.mes.value;

	var dia = document.formulario.dia.value;

	var ano = document.formulario.ano.value;



	if(mes!="" && dia !="" && ano !=""){

		document.formulario.dt_nascimento.value = dia+"/"+mes+"/"+ano;

	}

	else{

		document.formulario.dt_nascimento.value ="";

	}

}

