// *******************Barra de status********************
//AbreJanela

// ******************* Dia - Mês e ANO ******************

function AbreJanela(link,x,y,s,u) {

  var t = (screen.height - y) / 2;
  var e = (screen.width - x) / 2;

  window.open(link,x+y+s,'width=' + x + ',height=' + y + ',scrollbars=' + s + ',toolbar=0,location=0,status=0,menubar=0,resizable=0,left=' + e + ',top=' + t + '');
  if(u==1){
    window.focus();
  }

}
// *****************************************************
// Como usar:
// <a href="javascript:;" onMouseOver="AbreJanela('http://www.terra.com.br',500,400,1,0)">Clique 
// Aqui para abrir em PopUp</a><BR>
// <BR>
// 
// <a href="javascript:;" onclick="AbreJanela('http://www.terra.com.br',500,400,1,1); ">Clique Aqui para abrir em PopUnder</a>
//******************************************************


// *******************Barra de status********************
//defaultStatus="FPP MEDIA"

// ******************* Dia - Mês e ANO ******************

var now = new Date();
var mName = now.getMonth() + 1;
var dName = now.getDay() + 1;
var dayNr = now.getDate();
var yearNr=now.getYear();
if(dName==1) Day = "Domingo";
if(dName==2) Day = "Segunda-feira";
if(dName==3) Day = "Ter&ccedil;a-feira";
if(dName==4) Day = "Quarta-feira";
if(dName==5) Day = "Quinta-feira";
if(dName==6) Day = "Sexta-feira";
if(dName==7) Day = "S&aacute;bado";
if(yearNr < 2000) Year = 1900 + yearNr;
else Year = yearNr;
var todaysDate =(" " + Day + ", " + dayNr + "/" + mName + "/" + " de " +mName);

// *****************************************************
// Como usar:
//******************************************************

function Hoje() { 
ContrRelogio = setTimeout ("Hoje()", 1000) 
Hr = new Date() 
dd = Hr.getDate() 
mm = Hr.getMonth() + 1 
aa = Hr.getYear() 
hh = Hr.getHours() 
min = Hr.getMinutes() 
seg = Hr.getSeconds() 
DataAtual = ((dd < 10) ? "0" + dd + "/" : dd + "/") 
DataAtual += ((mm < 10) ? "0" + mm + "/" + aa : mm + "/" + aa) 
HoraAtual = ((hh < 10) ? "0" + hh + ":" : hh + ":") 
HoraAtual += ((min < 10) ? "0" + min + ":" : min + ":") 
HoraAtual += ((seg < 10) ? "0" + seg : seg) 
document.DataHora.Data.value=DataAtual 
document.DataHora.Hora.value=HoraAtual 
} 
// 
function CriaArray (n) { 
this.length = n } 
// 
NomeDia = new CriaArray(7) 
NomeDia[0] = "sunday" 
NomeDia[1] = "monday" 
NomeDia[2] = "tuesday" 
NomeDia[3] = "wednesday" 
NomeDia[4] = "thursday" 
NomeDia[5] = "friday" 
NomeDia[6] = "saturday" 
// 
NomeMes = new CriaArray(12) 
NomeMes[0] = "january"
NomeMes[1] = "february" 
NomeMes[2] = "march" 
NomeMes[3] = "april" 
NomeMes[4] = "may" 
NomeMes[5] = "june" 
NomeMes[6] = "july" 
NomeMes[7] = "august" 
NomeMes[8] = "september" 
NomeMes[9] = "october" 
NomeMes[10] = "november" 
NomeMes[11] = "december"
// 
Data1 = new Date() 
dia = Data1.getDate() 
dias = Data1.getDay() 
mes = Data1.getMonth() 
ano = Data1.getYear() 
// ******************************************************
// Como usar:
// <script> document.write (NomeDia[dias] + " " + dia + " de " + NomeMes[mes] + " de " + (ano ) ) </script>
// NO INGLÊS: <script> document.write (NomeDia[dias] + ", " + NomeMes[mes] + " " + dia + ", " + (ano ) )</script>
//******************************************************


//******************************************************
// AbrePop
//******************************************************
function AbrePop(link,x,y,s) {

	var t = (screen.height - y) / 2;
	var e = (screen.width - x) / 2;

	d = new Date();
	segundo = d.getSeconds();

	window.open(link,x+y+s+segundo,'width=' + x + ',height=' + y + ',scrollbars=' + s + ',toolbar=0,location=0,status=0,menubar=0,resizable=0,left=' + e + ',top=10');

}


	function ShowMenu(strName){

		if(strName=='mnu_empresa'){

			mnu_empresa.style.visibility='';
			mnu_solucoes.style.visibility='hidden';

		}else if(strName=='mnu_solucoes'){

			mnu_empresa.style.visibility='hidden';
			mnu_solucoes.style.visibility='';

		}

	}

	function HiddenMenu(){

		mnu_empresa.style.visibility='hidden';
		mnu_solucoes.style.visibility='hidden';

	}
//******************************************************
// Como Usar:
//   <A title="Texto explicativo" onclick="AbrePop('pop_up.html', 400, 450, 1);" href="javascript:;"><IMG height=50 src="bt_enviar.gif" width=150 border=0></A>
//******************************************************

//***************** VerificarForm *********************-

	function VerificarForm(){
		
		if(Formulario.FirstName.value=='') { 
			alert('Required field'); 
			Formulario.FirstName.focus();	
			return false;
		}

		if(Formulario.txt_email.value=='' || validarEmail(Formulario.txt_email.value) == false) { 
			alert('Required field'); 
			Formulario.txt_email.focus();	
			return false;
		}

		if(Formulario.LastName.value=='') { 
			alert('Required field');
			Formulario.LastName.focus();	
			return false;
		}

		if(Formulario.Address.value=='') { 
			alert('Required field');
			Formulario.Address.focus();	
			return false;
		}

		if(Formulario.City.value=='') { 
			alert('Required field');
			Formulario.City.focus();	
			return false;
		}

		if(Formulario.Country.value=='') { 
			alert('Required field'); 
			Formulario.Country.focus();	
			return false;
		}

		if(Formulario.DayBirth.value=='') { 
			alert('Required field'); 
			Formulario.DayBirth.focus();	
			return false;

	}
	
		if(Formulario.MonthBirth.value=='') { 
			alert('Required field'); 
			Formulario.MonthBirth.focus();	
			return false;

	}

		if(Formulario.YearBirth.value=='') { 
			alert('Required field'); 
			Formulario.YearBirth.focus();	
			return false;

	}		


	function validarEmail(email){

		var valor = true;

		Result = email.indexOf("@", 0);

		if (Result == -1 || email.length < 6){
			valor = false;
		}else{
			Result2 = email.indexOf(".", Number(Result + 3));
			if (Result2 == -1 || email.length < 6){
				valor = false;
			}
		}

		return valor;

	}

//******************************************************
// Como Usar:
//   <FORM name=form_contato onsubmit="return VerificarForm();" action="" method=post>
//******************************************************

//******************************************************
//
//
//******************************************************

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// -->

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_showHideLayers() { //v3.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v='hide')?'hidden':v; }
    obj.visibility=v; }
}
//******************************************************

<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

//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>');
}




