//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;

//================================================================================
//Função para abrir pop-up
//================================================================================

 function PopUp(page,win,w,h,t,l,scrolling)
 {
  if (!scrolling) { scrolling='yes' }
  window.open(page,win,'width='+w+',height='+h+',left='+l+',top='+t+',scrollbars='+scrolling+',toolbar=no,location=no,status=no,menubar=no,resizable=no')
 }

 function NovaJanela(page,win)
 {
  window.open(page,win,'width=600,height=500,left=100,top=100,scrollbars=yes,toolbar=yes,location=yes,status=yes,menubar=yes,resizable=yes')
 }

//================================================================================
//Função para checar se o "I Agree" foi corretamente digitado
//================================================================================

function CheckIAgree(Mensagem)
{
  string1 = "I AGREE";
	string2 = "EU CONCORDO";
  string3 = document.forms[0].elements["iagree"].value.toUpperCase();
  if ((string3!=string1) && (string3!=string2))
  {
    alert(Mensagem);
    document.forms[0].elements["iagree"].value = "";
    document.forms[0].elements["iagree"].focus();
  }
}

//=====================================================================================
// 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 VerificarObrigatorios(CamposObrigatorios,Mensagem)
{
	if (CamposObrigatorios != '') {
		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-1;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;
}

function VerificarObrigatorios2(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 = VetorCamposObrigatorios.length;
	for(var J=0;J<(TamanhoVetorCamposObrigatorios - 1);J++)
	{		
		if(document.forms["Formulario"].elements[VetorCamposObrigatorios[J]].value == "")
		{
			alert(Mensagem);
			document.forms["Formulario"].elements[VetorCamposObrigatorios[J]].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[NomeCampo].value = "";
		document.forms["Formulario"].elements[NomeCampoConfirmacao].value = "";
		document.forms["Formulario"].elements[NomeCampo].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();
	}
}

function VerificarCamposNumericosTamanho(NomeCampo,Tamanho,Mensagem)
{
	ExpressaoRegular = /\D/;
	ValorCampo = document.forms["Formulario"].elements[NomeCampo].value;
	if (ExpressaoRegular.exec(ValorCampo) || (ValorCampo.length != Tamanho))
	{
		alert(Mensagem);
		document.forms["Formulario"].elements[NomeCampo].value = "";
		document.forms["Formulario"].elements[NomeCampo].focus();
	}
}

//=====================================================================================
// Script para verificar se o usuário digitou um valor aceito para a comissao.
// VerificarComissao(NomeCampo, Percentual, Mensagem)
// NomeCampo - nome do campos no formulário.
// Mensagem - mensagem do alert
//=====================================================================================

function VerificarComissao(NomeCampo,Percentual,Mensagem)
{
	ExpressaoRegular = /\D/;
	ValorCampo = document.forms["Formulario"].elements[NomeCampo].value;
	if ((ValorCampo < Percentual) || (ExpressaoRegular.exec(ValorCampo))) {		
		alert(Mensagem);		
		document.forms["Formulario"].elements[NomeCampo].focus();	
		document.forms["Formulario"].elements[NomeCampo].value = "";
	}
}

//=====================================================================================
// 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(VerificarObrigatorios2(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)
{
	ExpReg = /\d/;
	NomeCampoDia = "D" + NomeCampo;
	NomeCampoMes = "M" + NomeCampo;
	NomeCampoAno = "A" + NomeCampo;
	Dia = "";
	Mes = "";
	Ano = "";
	DataInvalida = 0;

	if(tipo!="D3") {
		Dia = document.forms["Formulario"].elements[NomeCampoDia].value;
		if (Dia != "" && !ExpReg.test(Dia)) {
			DataInvalida = 1;
		}
	}

	Mes = document.forms["Formulario"].elements[NomeCampoMes].value;

	if(tipo!="D2") {
		Ano = document.forms["Formulario"].elements[NomeCampoAno].value;
		if (Ano != "" && !ExpReg.test(Ano)) {
			DataInvalida = 1;
		}
	}		
	
	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; 
       }        
   }      
}

//=====================================================================================
//AbrirJanelaAnuncio(Arquivo)
//=====================================================================================
function AbrirJanelaAnuncio(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=0,scrollbars=1,left=10,top=50,width=715,height=450');
       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=0,scrollbars=1,left=10,top=50,width=715,height=450');        
       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 = "";
	}
}

function VerificarTipoVideo(NomeCampo,Mensagem)
{
	ExpressaoRegular = /^[\w\W]+\.(avi|AVI|mpeg|MPEG|mpg|MPG|mov|MOV)$/;
	ValorCampo = document.forms["Formulario"].elements[NomeCampo].value;
	if (!ExpressaoRegular.exec(ValorCampo) && ValorCampo != "")
	{
		alert(Mensagem);
		document.forms["Formulario"].elements[NomeCampo].value = "";
	}
}

function VerificarTipoLogo(NomeCampo,Mensagem)
{
	ExpressaoRegular = /^[\w\W]+\.(jpg|JPG|bmp|BMP|ai|AI|pdf|PDF|psd|PSD|tif|TIF|eps|EPS|cdr|CDR)$/;
	ValorCampo = document.forms["FormLogo"].elements[NomeCampo].value;
	if (!ExpressaoRegular.exec(ValorCampo) && ValorCampo != "")
	{
		alert(Mensagem);
		document.forms["FormLogo"].elements[NomeCampo].value = "";
	} else {
		document.forms["FormLogo"].submit();
	}
}

//=====================================================================================
// 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(CamposObrigatorios,Mensagem) {
	Separador = /\s*,\s*/; //Procura por vírgula com ou sem espaço antes ou depois dela
	VetorCamposObrigatorios = CamposObrigatorios.split(Separador);
	TamanhoVetorCamposObrigatorios = VetorCamposObrigatorios.length;
	for(var J = 0;J < TamanhoVetorCamposObrigatorios; J++)
	{		
		if(document.forms["Formulario"].elements[VetorCamposObrigatorios[J]].checked == false)
		{
			alert(Mensagem);		
			document.forms["Formulario"].elements[VetorCamposObrigatorios[J]].focus();
			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"></OBJECT>');
  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>');
}

//=====================================================================================
//AbrirJanelaVideo(Arquivo)
//=====================================================================================
function AbrirJanelaVideo(Arquivo)     
{     
	var browser=navigator.appName + " " + navigator.appVersion;
  if (browser.substring(0, 8)=="Netscape")        
  {        
       var newWind=window.open(Arquivo,'videoWin','toolbar=0,location=0,directories=0,status=0,resizable=0,scrollbars=0,width=500,height=306');
       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,'video','toolbar=0,location=0,directories=0,status=0,resizable=0,scrollbars=0,width=500,height=306');        
       if (newWind.blue == null)           
       { 
          //newWind.blue = window; 
       }        
   }      
}

//=====================================================================================
//AbrirJanelaDepoimento(Arquivo)
//=====================================================================================
function AbrirJanelaDepoimento(Arquivo)     
{     
	var browser=navigator.appName + " " + navigator.appVersion;
  if (browser.substring(0, 8)=="Netscape")        
  {        
       var newWind=window.open(Arquivo,'depoimentoWin','toolbar=0,location=0,directories=0,status=0,resizable=0,scrollbars=1,left=10,top=50,width=520,height=400');
       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,'depoimento','toolbar=0,location=0,directories=0,status=0,resizable=0,scrollbars=1,left=10,top=50,width=520,height=400');        
       if (newWind.blue == null)           
       { 
          //newWind.blue = window; 
       }        
   }      
}


//=====================================================================================
//AbrirJanelaNoticia(Arquivo)
//=====================================================================================
function AbrirJanelaNoticia(Arquivo)     
{     
	var browser=navigator.appName + " " + navigator.appVersion;
  if (browser.substring(0, 8)=="Netscape")        
  {        
       var newWind=window.open(Arquivo,'depoimentoWin','toolbar=0,location=0,directories=0,status=0,resizable=0,scrollbars=1,left=10,top=50,width=520,height=400');
       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,'depoimento','toolbar=0,location=0,directories=0,status=0,resizable=0,scrollbars=1,left=10,top=50,width=520,height=400');        
       if (newWind.blue == null)           
       { 
          //newWind.blue = window; 
       }        
   }      
}


//=====================================================================================
//AdicionaFavoritos(URLSite,TituloSite)
//=====================================================================================
function AdicionaFavoritos(URLSite,TituloSite) {
	//var URLSite = window.location.href;
	//var TituloSite = document.title;
	if (document.all) window.external.AddFavorite(URLSite,TituloSite);
}


//=====================================================================================
//Funcoes para ocultar layer
//=====================================================================================
function lib_bwcheck(){ 
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera5=this.agent.indexOf("Opera 5")>-1
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0; 
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
	this.ie=this.ie4||this.ie5||this.ie6
	this.mac=this.agent.indexOf("Mac")>-1
	this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
	// ############### linha adicionada por mim ####################
	this.ns7=(this.ns6 && (this.agent.indexOf('Netscape6') < 0))?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5)
	return this
}

bw=new lib_bwcheck() //Browsercheck object

function lib_message(txt){alert(txt); return false}

function lib_obj(obj,nest){ 
	//if(!bw.bw) return lib_message('Old browser')
	nest=(!nest) ? "":'document.'+nest+'.'
	this.evnt=bw.dom? document.getElementById(obj):
	bw.ie4?document.all[obj]:bw.ns4?eval(nest+"document.layers." +obj):0;	
	if(!this.evnt) return lib_message('The layer does not exist ('+obj+')' 
	+'- \nIf your using Netscape please check the nesting of your tags!')
	this.css=bw.dom||bw.ie4?this.evnt.style:this.evnt; 
	this.ref=bw.dom||bw.ie4?document:this.css.document;
	this.x=parseInt(this.css.left)||this.css.pixelLeft||this.evnt.offsetLeft||0;
	this.y=parseInt(this.css.top)||this.css.pixelTop||this.evnt.offsetTop||0
	this.w=this.evnt.offsetWidth||this.css.clip.width||
	this.ref.width||this.css.pixelWidth||0; 
	this.h=this.evnt.offsetHeight||this.css.clip.height||
	this.ref.height||this.css.pixelHeight||0
	this.c=0 //Clip values
	if((bw.dom || bw.ie4) && this.css.clip) {
	this.c=this.css.clip; this.c=this.c.slice(5,this.c.length-1); 
	this.c=this.c.split(' ');
	for(var i=0;i<4;i++){this.c[i]=parseInt(this.c[i])}
	}
	this.ct=this.css.clip.top||this.c[0]||0; 
	this.cr=this.css.clip.right||this.c[1]||this.w||0
	this.cb=this.css.clip.bottom||this.c[2]||this.h||0; 
	this.cl=this.css.clip.left||this.c[3]||0
	this.obj = obj + "Object"; eval(this.obj + "=this")
	return this
}

lib_obj.prototype.hideIt = function(){this.css.visibility="hidden"
}


//=====================================================================================
//verificaCpf(campocpf, msg)
//=====================================================================================

function verificarCPF(campocpf, msg) {  
  d1 = 0;
  d2 = 0
  digito1 = 0;
  digito2 = 0;
  resto = 0;

  //Retira pontos e hifen
  cpf = new String(campocpf.value);
  while (cpf.search(/\./) != -1) {
    cpf = cpf.replace(".","");    
  }
  while (cpf.search(/\-/) != -1) {
    cpf = cpf.replace("-","");    
  }

  //Verifica se tem 11 digitos
  if (cpf.length != 11) {
    alert(msg);
    campocpf.value = "";
    campocpf.focus();
    return false;
  }

  for (nCount=1; nCount<cpf.length-1; nCount++)
  {
     digitoCPF = cpf.substring(nCount-1,nCount);

     //multiplique a ultima casa por 2 a seguinte por 3 a seguinte por 4 e assim por diante.
     d1 = d1 + ( 11 - nCount ) * digitoCPF;

     //para o segundo digito repita o procedimento incluindo o primeiro digito calculado no passo anterior.
     d2 = d2 + ( 12 - nCount ) * digitoCPF;
  };

  //Primeiro resto da divisão por 11.
  resto = (d1 % 11);

  //Se o resultado for 0 ou 1 o digito é 0 caso contrário o digito é 11 menos o resultado anterior.
  if (resto < 2)
    digito1 = 0;
  else
    digito1 = 11 - resto;

  d2 += 2 * digito1;

  //Segundo resto da divisão por 11.
  resto = (d2 % 11);

  //Se o resultado for 0 ou 1 o digito é 0 caso contrário o digito é 11 menos o resultado anterior.
  if (resto < 2)
    digito2 = 0;
  else
    digito2 = 11 - resto;

  //Digito verificador do CPF que está sendo validado.
  nDigVerific = cpf.substring(cpf.length-2,cpf.length);

  //Concatenando o primeiro resto com o segundo.
  nDigResult = new String(digito1) + new String(digito2);

  //comparar o digito verificador do cpf com o primeiro resto + o segundo resto.
  if (nDigVerific != nDigResult) {
    alert(msg);
    campocpf.value = "";
    campocpf.focus();
    return false;
  }

}


