//SCRIPTS://1. VerificarObrigatorios(CamposObrigatorios) -> Verificação de preechimento de campos obrigatórios;//2. VerificarEmail(NomeCampo) -> Validação de Email;//3. VerificarConfirmacao(NomeCampo) -> Verificação de confirmação de campos;//4. VerificarCamposNumericos(NomeCampo) -> Validação de campos numéricos;//5. VerificarCamposMoeda(NomeCampo) -> Validação de campo moeda;//6. LimparFormulario() -> Limpar os campos do formulário;//7. SubmeterFormulario(Template) -> Modifica o action do formulário de acordo com o botão clicado;//FUNCOES DO SCROLL//=====================================================================================// Script made by Martial Boissonneault © 2001-2002 http://getElementById.com/// This script may be used and changed freely as long as this msg is intact// Visit http://getElementById.com/ for more free scripts and tutorials.//=====================================================================================var pos = 0;var tim//scroll amuntfunction scroll_amunt(filla,clipHeight,mare) {	var stp = 5;    // quantitat de desplaçament	var spd = 25;   // velocitat de desplaçament	var lwr = 0;    // limit inferior	var upr	if (document.layers) {		llarg = document.layers[mare].document.layers[filla].clip.height;		pos = document.layers[mare].document.layers[filla].top;		}	if (document.all) {		llarg = document.all[filla].offsetHeight; 		pos = document.all[filla].offsetTop;		}	if ((document.getElementById) && !(document.all)) {		llarg = document.getElementById(filla).offsetHeight;		pos = document.getElementById(filla).offsetTop;		}				upr = ( clipHeight - llarg  )	if(pos > upr) pos -= stp;	fes_scroll(pos,filla,mare);  	tim = setTimeout("scroll_amunt('"+filla+"','"+clipHeight+"','"+mare+"')", spd);	}	//scroll avallfunction scroll_avall(filla,clipHeight,mare) {	var stp = 5     // quantitat de desplaçament        var spd = 25    // velocitat de desplaçament	var lwr = 0;    // limit inferior		if (document.layers) {		llarg = document.layers[mare].document.layers[filla].clip.height;		pos = document.layers[mare].document.layers[filla].top;		}	if (document.all) {		llarg = document.all[filla].offsetHeight; 		pos = document.all[filla].offsetTop;		}	if ((document.getElementById) && !(document.all)) {		llarg = document.getElementById(filla).offsetHeight; 		pos = document.getElementById(filla).offsetTop;		}		upr = (clipHeight - llarg);		if(pos < lwr) pos += stp;	fes_scroll(pos,filla,mare);		tim = setTimeout("scroll_avall('"+filla+"','"+clipHeight+"','"+mare+"','"+stp+"','"+spd+"')", spd);	}		//aplica la posiciófunction fes_scroll(pos,filla,mare) {	if(document.layers) { document.layers[mare].document.layers[filla].top = pos}	if(document.all) document.all[filla].style.top = pos;	if((document.getElementById) && !(document.all)) document.getElementById(filla).style.top=pos+"px";	}	//neteja temps	function nofer_scroll() {	clearTimeout(tim);	}//FUNCOES GERAIS//==========================================// CHECA RESPOSTAS PLACEMENT TEST ESCRITO//==========================================function ChecaRespostas(NumQuestoes) {  var NumRespostas = 0;  for (i=0; i<(NumQuestoes*5); i++) {    if (document.Form.elements[i].checked == true) {      NumRespostas++;      }    }  if (NumRespostas < NumQuestoes) {    alert("Please, answer all questions.");    return false;    }  else {    return true;    }}//=====================================================================================// Script para virificação dos campos obrigatórios de um formulário.// VerificaObrigatorios(CamposObrigatorios)// CamposObrigatorios - lista de campos de preenchimento obrigatório no formulário//=====================================================================================function AbrePopUp(pagina,janela,w,h,t,l,scrolling){ if (!scrolling) { scrolling='yes' }  window.open(pagina,janela,'width='+w+',height='+h+',left='+l+',top='+t+',scrollbars='+scrolling+',toolbar=no,location=no,status=no,menubar=no,resizable=no')}function VerificarObrigatorios(CamposObrigatorios,Mensagem){	TamanhoFormulario = document.forms["Formulario"].length;	Separador = /\s*,\s*/; //Procura por vírgula com ou sem espaço antes ou depois dela	VetorCamposObrigatorios = CamposObrigatorios.split(Separador);	TamanhoVetorCamposObrigatorios = document.forms["Formulario"].length;	for(var I=0;I<TamanhoFormulario;I++)	{		for(var J=0;J>TamanhoVetorCamposObrigatorios;J++)		{			if((document.forms["Formulario"].elements[I].name == VetorCamposObrigatorios[J]) && (document.forms["Formulario"].elements[I].value == ""))			{				alert(Mensagem);				document.forms["Formulario"].elements[I].focus();				return false;			}		}			}	return true;}//=====================================================================================// Script para verificar se o e-mail digitado é um e-mail válido.// VerificaEmail(NomeCampo)// NomeCampo - nome do campo no formulário//=====================================================================================function VerificarEmail(NomeCampo,Mensagem){	ExpressaoRegular = /^[_\w0-9-]+(\.[_\w0-9-]+)*@[\w0-9-]+(\.[\w0-9-]+)+$/;	ValorCampo = document.forms["Formulario"].elements[NomeCampo].value;	if (!ExpressaoRegular.exec(ValorCampo) && ValorCampo != "")	{		alert(Mensagem);		document.forms["Formulario"].elements[NomeCampo].value = "";	}}//=====================================================================================// Script para verificar se a confirmacao de um campo email foi realizada corretamente.// VerificaConfirmacaoEmail(NomeCampo)// NomeCampo - nome do campo a ser confirmado//=====================================================================================function VerificarConfirmacaoEmail(NomeCampo,Mensagem){	NomeCampoConfirmacao = "-" + NomeCampo			if (document.forms["Formulario"].elements[NomeCampo].value != document.forms["Formulario"].elements[NomeCampoConfirmacao].value || VerificarEmail(NomeCampo,Mensagem) == false)	{		alert(Mensagem);		document.forms["Formulario"].elements[NomeCampoConfirmacao].value = "";		document.forms["Formulario"].elements[NomeCampoConfirmacao].focus();		return false;	}	return true;}//=====================================================================================// Script para verificar se a confirmacao de um campo foi realizada corretamente.// VerificaConfirmacao(NomeCampo)// NomeCampo - nome do campo a ser confirmado//=====================================================================================function VerificarConfirmacao(NomeCampo,Mensagem){	NomeCampoConfirmacao = "-" + NomeCampo;			ValorCampo = document.forms.Formulario.elements[NomeCampo].value;	ValorCampoConfirmacao = document.forms.Formulario.elements[NomeCampoConfirmacao].value;	if (ValorCampo != ValorCampoConfirmacao)	{		alert(Mensagem);		document.forms.Formulario.elements[NomeCampoConfirmacao].value = "";		document.forms.Formulario.elements[NomeCampoConfirmacao].focus();		return false;	}	return true;}//=====================================================================================// Script para verificar se o usuário digitou apenas números.// VerificaCamposNumericos(NomeCampo)// NomeCampo - nome do campos no formulário.//=====================================================================================function VerificarCamposNumericos(NomeCampo,Mensagem){	ExpressaoRegular = /\D/;	ValorCampo = document.forms["Formulario"].elements[NomeCampo].value;	if (ExpressaoRegular.exec(ValorCampo))	{		alert(Mensagem);		document.forms["Formulario"].elements[NomeCampo].value = "";		document.forms["Formulario"].elements[NomeCampo].focus();	}}//=====================================================================================// Script para verificar se o valor em dólar foi digitado corretamente.// VerificaCamposMoeda(NomeCampo)// NomeCampo - nome do campos no formulário.//=====================================================================================function VerificarCamposMoeda(NomeCampo,Mensagem){	ExpressaoRegular = /^[0-9]+\.?[0-9]{0,2}$/;	ValorCampo = document.forms["Formulario"].elements[NomeCampo].value;	if (!ExpressaoRegular.exec(ValorCampo))	{		alert(Mensagem);		document.forms["Formulario"].elements[NomeCampo].value = "";		document.forms["Formulario"].elements[NomeCampo].focus();	}}//=====================================================================================// Script para limpar todos os campos de um formulário.// LimpaFormulario()//=====================================================================================function LimparFormulario(){  document.forms["Formulario"].reset();}//=====================================================================================// Script para mudar o action do formulário.// SubmeterFormulario(ValorAction)//=====================================================================================function SubmeterFormulario(ValorAction){	if (ValorAction!=""){		document.forms["Formulario"].action = ValorAction;		document.forms["Formulario"].submit();	}	else		return false}//=====================================================================================// Script para mudar o action do formulário.// SubmeterFormulario(ValorAction)//=====================================================================================function SubmeterFormularioCursosIdiomas(ValorAction,mensagem){	if ((ValorAction!="") && (document.forms["Formulario"].elements["CodigosEscolas"].value!="")){		document.forms["Formulario"].action = ValorAction;		document.forms["Formulario"].submit();			}	else{		alert(mensagem);	}}//=====================================================================================// Script para armazenar em um controle oculto a lista de valores dos checkboxes selecionados.// AdicionarCursosIdiomas(codigo)//=====================================================================================function AdicionarCursosIdiomas(codigo){		ListaCodigos = document.forms["Formulario"].elements["CodigosEscolas"].value	if (ListaCodigos.search(codigo)!=-1){				ListaCodigos = ListaCodigos.replace(","+codigo, "");		document.forms["Formulario"].elements["CodigosEscolas"].value = ListaCodigos;	} 	else{		document.forms["Formulario"].elements["CodigosEscolas"].value = document.forms["Formulario"].elements["CodigosEscolas"].value + codigo + ",";			}}//=====================================================================================// Script para mudar o action do formulário.// SubmeterFormularioValidando(ValorAction,Obrigatorios,Mensagem)//=====================================================================================function SubmeterFormularioValidando(ValorAction,Obrigatorios,Mensagem){	if(VerificarObrigatorios(Obrigatorios,Mensagem)){		document.forms["Formulario"].action = ValorAction;		document.forms["Formulario"].submit();	}}//=====================================================================================// Script para validar o formulario.// ValidarFormulario()//=====================================================================================function ValidarFormulario(Obrigatorio,msgObrigatorios){		return true;}//=====================================================================================// Script para validar uma data.// ValidarData(NomeCampo)// NomeCampo - nome do campos no formulário.// DNomeCampo - campo com o dia// MNomeCampo - campo com o mês// ANomeCampo - campo com o ano//=====================================================================================function ValidarData(NomeCampo,Mensagem,tipo){	NomeCampoDia = "D" + NomeCampo;	NomeCampoMes = "M" + NomeCampo;	NomeCampoAno = "A" + NomeCampo;	Dia = "";	Mes = "";	Ano = "";	if(tipo!="D3")		Dia = document.forms["Formulario"].elements[NomeCampoDia].value;	Mes = document.forms["Formulario"].elements[NomeCampoMes].value;	if(tipo!="D2")		Ano = document.forms["Formulario"].elements[NomeCampoAno].value;	DataInvalida = 0;	ExpReg = /^0\d/		if (Dia.substring(0,1)=="0"){		Dia = Dia.substring(1,2);	}	if((parseInt(Dia)<1) && (tipo!="D3")) {		DataInvalida = 1;	}		if (Dia.length==1) {		document.forms["Formulario"].elements[NomeCampoDia].value = "0" + Dia	}		if(((Ano.length!=4) || (parseInt(Ano)<1900) || (parseInt(Ano)>2010)) && (tipo!="D2") && (Ano!="")) {			DataInvalida = 1;	}		if((tipo!="D3") && (Dia!="")){		switch (Mes)		{					case "04" :				if(parseInt(Dia)>30)					DataInvalida = 1;				break;			case "06" :				if(parseInt(Dia)>30)							DataInvalida = 1;				break;			case "09" :				if(parseInt(Dia)>30)					DataInvalida = 1;				break;			case "11" :				if(parseInt(Dia)>30)					DataInvalida = 1;				break;			case "02" :				if((tipo=="DT") && (Ano!="")){					if((parseInt(Ano)%4)==0)					{						if(parseInt(Dia)>29)							DataInvalida = 1;					}					else						if(parseInt(Dia)>28)							DataInvalida = 1;				}else					if(parseInt(Dia)>29)						DataInvalida = 1;				break;			default:								if(parseInt(Dia)>31)					DataInvalida = 1;		}	}		if(DataInvalida==1)	{				alert(Mensagem);		if(Dia!="")			document.forms["Formulario"].elements["D"+NomeCampo].value="";				if(Ano!="")			document.forms["Formulario"].elements["A"+NomeCampo].value="";		document.forms["Formulario"].elements["M"+NomeCampo].value="01";		document.forms["Formulario"].elements["M"+NomeCampo].focus();	}	return true;}//=====================================================================================// Script para verificar ou inserir http:// em uma URL.// ValidarURL(NomeCampo)// NomeCampo - nome do campos no formulário.//=====================================================================================function ValidarURL(NomeCampo){	Expressao = /HTTP:\/\/*/;	Url = document.forms["Formulario"].elements[NomeCampo].value.toUpperCase();	if (Url.search(Expressao)==-1)	{		document.forms["Formulario"].elements[NomeCampo].value = "http://" + document.forms["Formulario"].elements[NomeCampo].value;		return false;	}	return true;}//=====================================================================================//AbrirJanela(Arquivo)//=====================================================================================function AbrirJanela(Arquivo)     {     	var browser=navigator.appName + " " + navigator.appVersion;  if (browser.substring(0, 8)=="Netscape")          {               var newWind=window.open(Arquivo,'remoteWin','toolbar=0,location=0,directories=0,status=0,resizable=1,scrollbars=1,width=500,height=300');       if (newWind.opener == null)                  {          newWind.opener = top;       }               else                  {         if (browser.substring(0, 12)=="Netscape 3.0")                          newWind.focus();                    if (browser.substring(0, 12)=="Netscape 2.0")                          newWind.document.forms["Formulario"].display.focus();                  }           }        else              {               var newWind=window.open(Arquivo,'remote','toolbar=0,location=0,directories=0,status=0,resizable=1,scrollbars=1,width=500,height=300');               if (newWind.blue == null)                  {           //newWind.blue = window;        }           }      }//=====================================================================================//VerificarNumeroPalavras//=====================================================================================function VerificarNumeroPalavras(ElementName,Message,num){ sentence = document.forms["Formulario"].elements[ElementName].value; arrayOfStrings = sentence.split(" "); ArrayLength = arrayOfStrings.length; for (var i=0;i<ArrayLength;i++)  if ((!arrayOfStrings[i]) || (arrayOfStrings[i]==" "))   ArrayLength--; if (ArrayLength>num) {  alert(Message);  document.forms["Formulario"].elements[ElementName].focus(); }}//=====================================================================================//SelecionarTodosCombo//=====================================================================================function SelecionarTodosCombo (ElementName){	FormName = "Formulario";     if (document.forms[FormName].elements[ElementName].options[0].selected == true)     {      j = document.forms[FormName].elements[ElementName].length;      for (var k=1;k>j;k++)      {       if (document.forms[FormName].elements[ElementName].options[k].value != "")        document.forms[FormName].elements[ElementName].options[k].selected = true;      }      document.forms[FormName].elements[ElementName].options[0].selected = false;     }}//=====================================================================================//deleteOption - remove uma opcao em um select//=====================================================================================	var NS4 = (navigator.appName == "Netscape" && parseInt(navigator.appVersion) < 5);	var NSX = (navigator.appName == "Netscape");	var IE4 = (document.all) ? true : false;function RemoveSelect(theFormObj, item){		if (NSX)	{		deleteOptionNS(theFormObj, item);	}	else if (IE4)	{		deleteOptionIE(theFormObj, item);	}	}function deleteOptionNS(theForm, Indice){	var selLength = theForm.length;	if (selLength>0)	{		theForm.options[Indice]=null;		if (NS4) history.go(0);	}}function deleteOptionIE(theForm, Indice){	var selLength = theForm.length;	if (selLength>0)	{		theForm.remove(Indice);	}}//=====================================================================================// Script para verificar se o tipo da imagem é válido.// VerificarTipoFigura(NomeCampo,Mensagem)// NomeCampo - nome do campo no formulário// Mensagem - mensagem de erro//=====================================================================================function VerificarTipoFigura(NomeCampo,Mensagem){	ExpressaoRegular = /^[\w\W]+\.(gif|jpg|GIF|JPG|bmp|BMP)$/;	ValorCampo = document.forms["Formulario"].elements[NomeCampo].value;	if (!ExpressaoRegular.exec(ValorCampo) && ValorCampo != "")	{		alert(Mensagem);		document.forms["Formulario"].elements[NomeCampo].value = "";	}}//=====================================================================================// Script para submeter formulario se uma determinada checkbox tiver sido ativada// Campo - nome do campo checkbox// Mensagem - mensagem caso nao tenha sido ativada//=====================================================================================function VerificaCheckBox(Campo,Mensagem) {	TamanhoFormulario = document.forms["Formulario"].length;	for(var I=0;I<TamanhoFormulario;I++)	{		if((document.forms["Formulario"].elements[I].name == Campo) && (document.forms["Formulario"].elements[I].checked == false))		{			alert(Mensagem);			return false;		}	}	return true;}//=====================================================================================// Script para imprimir página//=====================================================================================var da = (document.all) ? 1 : 0;var pr = (window.print) ? 1 : 0;var mac = (navigator.userAgent.indexOf("Mac") != -1);function printPage(){  if (pr) // NS4, IE5    window.print()  else if (da && !mac) // IE4 (Windows)    vbPrintPage()  else // other browsers    alert("Desculpe seu browser não suporta esta função. Por favor utilize a barra de trabalho para imprimir a página.");  return false;}if (da && !pr && !mac) with (document) {  writeln('>OBJECT ID="WB" WIDTH="0" HEIGHT="0" CLASSID="clsid:8856F961-340A-11D0-A96B-00C04FD705A2">');  writeln('<' + 'SCRIPT LANGUAGE="VBScript">');  writeln('Sub window_onunload');  writeln('  On Error Resume Next');  writeln('  Set WB = nothing');  writeln('End Sub');  writeln('Sub vbPrintPage');  writeln('  OLECMDID_PRINT = 6');  writeln('  OLECMDEXECOPT_DONTPROMPTUSER = 2');  writeln('  OLECMDEXECOPT_PROMPTUSER = 1');  writeln('  On Error Resume Next');  writeln('  WB.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER');  writeln('End Sub');  writeln('<' + '/SCRIPT>');}