////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	var apertou = 0;

function fx_keydown(){
	if (document.all)
	{
		var tecla = event.keyCode;
	}
	else if(document.layers)
	{
		var tecla = e.which;
	}

	if(tecla==18){
		apertou = 1;
	}

	if(apertou==1 && tecla==37){
		return false;
	}
}

function fx_keyup(){
	if (document.all)
	{
		var tecla = event.keyCode;
	}
	else if(document.layers)
	{
		var tecla = e.which;
	}
	if(tecla==18){
		apertou = 0;
	}
		if(apertou==1 && tecla==37){
			return false;
		}
}

function click() {
	if (document.all)
	{
		var tecla = event.keyCode;
	}
	else if(document.layers)
	{
		var tecla = e.which;
	}

	if(event.button==2){
		//alert('Instituto Ethos. Todos os direitos reservados.');
		//return false;
	}
}

document.onmousedown=click
document.onmouseup=click
document.onkeydown=fx_keydown
document.onkeyup=fx_keyup

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////




    	var newwindow;
//**********************************************************************************************		
	idioma = "1"
	hoje = new Date()
	dia = hoje.getDate()
	dias = hoje.getDay()
	mes = hoje.getMonth()
	ano = "2004"
	if (dia < 10)
		dia = "0" + dia
	if (ano < 2000)
		ano = "19" + ano
	function CriaArray (n){
	this.length = n }

		function escreveData()
		{

		if (idioma == "1"){
			NomeDia = new CriaArray(7)
				NomeDia[0] = "Domingo"
				NomeDia[1] = "Segunda-feira"
				NomeDia[2] = "Terça-feira"
				NomeDia[3] = "Quarta-feira"
				NomeDia[4] = "Quinta-feira"
				NomeDia[5] = "Sexta-feira"
				NomeDia[6] = "Sábado"

			 NomeMes = new CriaArray(12)
				NomeMes[0] = "Janeiro"
				NomeMes[1] = "Fevereiro"
				NomeMes[2] = "Março"
				NomeMes[3] = "Abril"
				NomeMes[4] = "Maio"
				NomeMes[5] = "Junho"
				NomeMes[6] = "Julho"
				NomeMes[7] = "Agosto"
				NomeMes[8] = "Setembro"
				NomeMes[9] = "Outubro"
				NomeMes[10] = "Novembro"
				NomeMes[11] = "Dezembro"
		}

		if (idioma == "2"){
			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"
		}

		if (idioma == "3"){
			NomeDia = new CriaArray(7)
				NomeDia[0] = "Domingo"
				NomeDia[1] = "Lunes"
				NomeDia[2] = "Martes"
				NomeDia[3] = "Miércoles"
				NomeDia[4] = "Jueves"
				NomeDia[5] = "Viernes"
				NomeDia[6] = "Sabado"

			 NomeMes = new CriaArray(12)
				NomeMes[0] = "Enero"
				NomeMes[1] = "Febrero"
				NomeMes[2] = "Marzo"
				NomeMes[3] = "Abril"
				NomeMes[4] = "Mayo"
				NomeMes[5] = "Junio"
				NomeMes[6] = "Julio"
				NomeMes[7] = "Agosto"
				NomeMes[8] = "Septiembre"
				NomeMes[9] = "Octubre"
				NomeMes[10] = "Noviembre"
				NomeMes[11] = "Diciembre"
		}


			if (idioma == "1"){
			document.write ("<b>" + NomeDia[dias] + ", " + dia + " de " + NomeMes[mes]+ " de " + ano + "</b>")}
			if (idioma == "2"){
			document.write ("<b>" + NomeDia[dias] + ", " + NomeMes[mes] + " " + dia + ", "  + ano + "</b>")}
			if (idioma == "3"){
			document.write ("<b>" + NomeDia[dias] + ", " + dia + " de " + NomeMes[mes]+ " de " + ano + "</b>")}
		}


//**********************************************************************************************	


/*		  function abre(){
		    largura = screen.width;
		    altura = screen.height;
		    XX =(largura-595)/2;
		    YY = (altura-410)/2;
		    janela = window.open ('local.asp','instancia','width=595,height=410,left='+XX+',top='+YY+',scrollbars=yes,status=no,resizable=yes');
		    janela.focus?();
		  }*/

//**********************************************************************************************	

		function openWin (url,name,w,h)
		{	
			if(newwindow)
			{
				newwindow.close();
				newwindow = null;
			}
			
			largura = screen.width;
			altura  = screen.height;
			XX =(largura-w)/2;
			YY =(altura-h)/2;
			action ="";
			newwindow = window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height='+h+',width='+w+',left='+XX+',top='+YY);
		}
		
//**********************************************************************************************			

		function openWinNoScroll (url,name,w,h)
		{	
		    largura = screen.width;
		    altura = screen.height;
		    XX =(largura-w)/2;
		    YY =(altura-h)/2;
			action ="";
			newwindow = window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height='+h+',width='+w+',left='+XX+',top='+YY);
		}
		
		function openWinNoScrollFull (url,name)
		{	
			newwindow = window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,height=768,width=1024,left=0,top=0');
		}


		function openWinScrollFull (url,name)
		{	
			newwindow = window.open(url,name,'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,height=768,width=1024,left=0,top=0');
		}

	
//**********************************************************************************************			
		
		// Rollover nas Tables (TDs)

		// USAR DENTRO DO TD onMouseOut="mOut(this,'#ffffff')" onMouseOver="mOvr(this,'#FDCC0A')"  onClick="mClk(this)

		function mOvr(src,clrOver) {
		 if (!src.contains(event.fromElement)) {
			src.style.cursor = 'default';
			src.bgColor = clrOver;
		 }
		}

		function mOut(src,clrIn) {
		 if (!src.contains(event.toElement)) {
		  src.style.cursor = 'default';
		  src.bgColor = clrIn;
		 }
		}

		function mClk(src) {
		 if(event.srcElement.tagName=='TD'){
		  src.children.tags('A')[0].click();
		 }
		}
		
		//TROCA IMAGEM
		//<a href="../site/cadastro_curriculo" onmouseover="troca(cad, 'ebot22.gif');" onmouseout="troca(cad, 'ebot2.gif');"><img src="../site/imagens/ebot2.gif" border="0" name="cad" alt="Cadastro"></a>
		function troca(name, nova)
		{
			c = new Array();
			c[1] = new Image();
			c[1].src = "../site/imagens/" + nova;
			name.src = c[1].src;
		}

		
function selecionaItem(obj,indice)
{
	document.forms[0].CodigoModelo[indice].checked = true;

	for(j=0;j<tbl.rows.length;j++)
	{
		
		for (i=0;i<tbl.rows[j].cells.length;i++)
		{
			if (j==0)
			{
				color = '#FFE3A3'
			}
			else
			{
				color = '#FF9900'
			}
			if (i==indice)
			{
				tbl.rows[j].cells[indice].style.backgroundColor = color;
			}
			else
			{
				tbl.rows[j].cells[i].style.backgroundColor = '#FFFFFF';
			}
		}
	}
}

function selecionaItemTab(obj,indice)
{
	
	var continua = 1;
	
	for(y=0;y<document.forms[0].CodigoModelo.length;y++)
	{
		if(document.forms[0].CodigoModelo[y].checked)
		{
			continua = 0;
		}
	}
	
	if(continua==1)
	{
		for(j=0;j<tbl.rows.length;j++)
		{
			
			for (i=0;i<tbl.rows[j].cells.length;i++)
			{
				if (j==0)
				{
					color = '#FFE3A3'
				}
				else
				{
					color = '#FF9900'
				}
				if (i==indice)
				{
					tbl.rows[j].cells[indice].style.backgroundColor = color;
				}
				else
				{
					tbl.rows[j].cells[i].style.backgroundColor = '#FFFFFF';
				}
			}
		}	
	}
	
/*	document.forms[0].selecionado.value = obj.value;
	for(j=1;j<tbl.rows.length - 1;j++)
		for (i=0;i<tbl.rows[j].cells.length;i++) 
			if (j==indice + 1)
				tbl.rows[j].cells[i].style.backgroundColor = '#e1e1e1';
			else
				tbl.rows[j].cells[i].style.backgroundColor = '';*/
}
		
function adicionar(obj, obj1)
{
	if(obj.selectedIndex>=0)
	{
		var elemento = document.createElement("OPTION");
		elemento.value = obj.options[obj.selectedIndex].value;
		elemento.text  = obj.options[obj.selectedIndex].text;
		obj1.add(elemento);
		obj.remove(obj.selectedIndex);
	}
}

/////////////////////////////////////////////////////////////////////////////////////////////
var Menu_ID    = 0;

function adicionartexto(obj, obj1)
{
	Menu_ID =  Menu_ID + 1
	//if(obj.selectedIndex>=0)
	//{
		var elemento = document.createElement("OPTION");
		elemento.value = '0.' + Menu_ID;
		elemento.text  = obj.value;
		obj1.add(elemento);
		alert(elemento.value);
		//obj.remove(obj.selectedIndex);
	//}
}

function adicionarSubItem(obj, obj1)
{
	ramificacao = '';

	if(obj1.selectedIndex>=0)
	{
		Menu_ID =  Menu_ID + 1
		
		nivelArray =Split(obj1.options[obj1.selectedIndex].value,'.');
		
		nivel  = parseInt(nivelArray[0]) + 1;
				
		var elemento = document.createElement("OPTION");
		elemento.value = nivel +'.' + Menu_ID + '.' +  parseInt(nivelArray[1]);

		for(i=0;i<nivel;i++)
		{
			ramificacao = ramificacao + '...';
		}
		
		elemento.text  = ramificacao + obj.value;
		obj1.add(elemento);
		//obj1.select[] = obj1.length;
		
	}
	else
	{
		alert('Para Adicionar um Sub-Item, selecione um Item.');
		return false;
	}

}


var contador = - 1;
	
function ordenaMenu(){

	var f = document.GeradorMenu;
	var ate = 0;
	
	for(y=0;y<f.MainMenu.length;y++){
		nivelArray=Split(f.MainMenu[y].value,'.');
		if(parseInt(nivelArray[0])==0){
			ate = ate + 1;
		}
	
	}
	
	for(i=1;i<=ate;i++){
		for(y=0;y<f.MainMenu.length;y++){
			nivelArray=Split(f.MainMenu[y].value,'.');
			if(parseInt(nivelArray[1])==i){

			if(contador<f.MainMenu.length-1){
				contador = contador+1;				
			}
										
				a  = f.MainMenu[y].value;
				at = f.MainMenu[y].text;

				try{
				b  = f.MainMenu[contador].value;
				bt = f.MainMenu[contador].text;
				f.MainMenu[contador].value = a;
				f.MainMenu[contador].text  = at;
				}
				catch(e){
					return true;
				}
				
				f.MainMenu[y].value = b;
				f.MainMenu[y].text = bt;
				
				y = aaaaa(parseInt(nivelArray[1]),y);
		
			}
		}
	}
	contador = - 1;
}


function aaaaa(g,a){

	
	var f = document.GeradorMenu;
	//alert('procurando filhos de ' + g);
	for(j=0;j<f.MainMenu.length;j++){
		nivelArray2 =Split(f.MainMenu[j].value,'.');
		if(parseInt(nivelArray2[2])==g){

			if(contador<f.MainMenu.length-1){
				contador = contador+1;				
			}

			a  = f.MainMenu[j].value;
			at = f.MainMenu[j].text;

			try{
				b  = f.MainMenu[contador].value;
				bt = f.MainMenu[contador].text;
				f.MainMenu[contador].value = a;
				f.MainMenu[contador].text  = at;
			}
			catch(e){
				return true;
			}
			
			f.MainMenu[j].value = b;
			f.MainMenu[j].text = bt;
			j = bbbbb(parseInt(nivelArray2[1]),j);
		}
	}
	return a;
}


function bbbbb(g,a){

	
	var f = document.GeradorMenu;
	//alert('procurando filhos de ' + g);
	for(j=0;j<f.MainMenu.length;j++){
		nivelArray2 =Split(f.MainMenu[j].value,'.');
		if(parseInt(nivelArray2[2])==g){

			if(contador<f.MainMenu.length-1){
				contador = contador+1;				
			}

			a  = f.MainMenu[j].value;
			at = f.MainMenu[j].text;

			try{
				b  = f.MainMenu[contador].value;
				bt = f.MainMenu[contador].text;
				f.MainMenu[contador].value = a;
				f.MainMenu[contador].text  = at;
			}
			catch(e){
				return true;
			}
			
			f.MainMenu[j].value = b;
			f.MainMenu[j].text = bt;
			j = aaaaa(parseInt(nivelArray2[1]),j);
		}
	}
	return a;
}


function ordenaMenulixo()
{

	var a, b, at, bt;
	var contador = -1;
	
	f = document.GeradorMenu;

	for(i=0;i<f.MainMenu.length;i++)
	{

		for(y=0;y<f.MainMenu.length;y++)
			{
			nivelArray=Split(f.MainMenu[y].value,'.');
			
			if(parseInt(nivelArray[1])==i)
			{
					contador = contador + 1;
					a  = f.MainMenu[i].value;
					at = f.MainMenu[i].text;
					b  = f.MainMenu[contador].value;
					bt = f.MainMenu[contador].text;
	
					f.MainMenu[contador].value = a;
					f.MainMenu[contador].text  = at;
					f.MainMenu[i].value = b;
					f.MainMenu[i].text = bt;
	
					for(j=0;j<f.MainMenu.length;j++)
					{
							nivelArray2 =Split(f.MainMenu[j].value,'.');
							if(parseInt(nivelArray2[3])==i)
							{
								contador = contador + 1;
								a  = f.MainMenu[j].value;
								at = f.MainMenu[j].text;
								b  = f.MainMenu[contador].value;
								bt = f.MainMenu[contador].text;
				
								f.MainMenu[contador].value = a;
								f.MainMenu[contador].text  = at;
								f.MainMenu[j].value = b;
								f.MainMenu[j].text = bt;
							}
					}
			}

		}
	}
}



/////////////////////////////////////////////////////////////////////////////////////////////	

function Split(s,separador){
   var ss;
   // Split at each space character.
   ss = s.split(separador);
   return(ss);
}


function ordenarCima(obj)
{
	if(obj.selectedIndex>=0)
	{
		if(obj.selectedIndex!=0)
		{
			var elemento = document.createElement("OPTION");
			elemento.value = obj.options[obj.selectedIndex].value;
			elemento.text = obj.options[obj.selectedIndex].text;
			
			var elementoant = document.createElement("OPTION");
			elementoant.value = obj.options[obj.selectedIndex-1].value;
			elementoant.text = obj.options[obj.selectedIndex-1].text;
			
			obj.options[obj.selectedIndex].value = elementoant.value;
			obj.options[obj.selectedIndex].text = elementoant.text;
			obj.options[obj.selectedIndex-1].value =elemento.value;
			obj.options[obj.selectedIndex-1].text = elemento.text;
			obj.selectedIndex =obj.selectedIndex-1;
		}
	}
}	
  
function ordenarBaixo(obj)
{

	if(obj.selectedIndex>=0)
	{
		if(obj.selectedIndex!=obj.length-1)
		{
			var elemento = document.createElement("OPTION");
			elemento.value = obj.options[obj.selectedIndex].value;
			elemento.text = obj.options[obj.selectedIndex].text;
			
			var elementop = document.createElement("OPTION");
			elementop.value = obj.options[obj.selectedIndex+1].value;
			elementop.text = obj.options[obj.selectedIndex+1].text;
	
			obj.options[obj.selectedIndex].value =elementop.value;
			obj.options[obj.selectedIndex].text = elementop.text;
			obj.options[obj.selectedIndex+1].value = elemento.value;
			obj.options[obj.selectedIndex+1].text = elemento.text;
			obj.selectedIndex =obj.selectedIndex+1;
		}
	}
}	 
//**********************************************************************************************	

//onkeyUp="return FormataData(event,this)" onkeyDown="return SomenteNumeros();" onBlur="ValidaData1(this);"
function ValidaData1(campo)
{
	if(campo.value){
		if(!isDate(campo.value))
		{
			alert('Data Inválida');
			campo.focus();
			campo.select();
			return false;
		}
	}
}

function ValidaData(campo, obrigatorio)
{
	//exemplo
	// onBlur="ValidaData(this,false);"
	
	if(obrigatorio==true)
	{
		if(!isDate(campo.value))
		{
			alert('Data Inválida');
			campo.focus();
			return false;
		}	
	}
	else
	{
		if(campo.value.length>0)
		{
			if(!isDate(campo.value))
			{
				alert('Data Inválida');
				campo.focus();
				return false;
			}	
		}
	
	
	}

}


//DATA
//onkeyUp="return FormataData(event,this)" onkeyDown="return SomenteNumeros();" onBlur="ValidaData(this,false);"


function isDate(ptexto) {
   //ptexto = trim(ptexto);
   if (ptexto.length !=10) {
      return false;
   }
   
   var dia = parseInt(ptexto.substring(0,2),10);
   var mes = parseInt(ptexto.substring(3,5),10);
   var ano = parseInt(ptexto.substring(6,10),10);
   
   if (isNaN(dia) || isNaN(mes) || isNaN(ano)) {
      return false;
   }
   
   if (mes<1 || mes >12) return false;
   
   if (ptexto.substring(2,3) != "/") return false;
   
   if (dia<1 || dia > 31) return false;
   
   if (ptexto.substring(5,6) != "/") return false;
   
   if (ano<=1000) return false;
   
   if (mes==4 || mes==6 || mes==9 || mes==11) {
      if (dia==31) return false;
   }
   
   if (mes==2) {
      var g = parseInt(ano/4,10);
      if (isNaN(g)) {
         return false;
      }
      if (dia>29) return false;
      if (dia==29 && ((ano/4)!=parseInt(ano/4,10))) return false;
   }
  
   return true;
} 

//**********************************************************************************************	

	//Função aplicada nos forms que possuem pais e estado
	//Não permite selecionar o estado se o Pais não for Brasil
	function TrocaEstado()
	{
		if (document.forms[0].Pais_ID.value!="1")
		{
			document.forms[0].Estado_ID.value="";
		}
	}

	
	
//**********************************************************************************************
	function chgdependsel (selelement)
	{

		requiredstate=false;
		selectObj = document.forms[0].CodigoCategoria;
		for(j=1;j<100;j++)
		{
			for (i=0;i<selectObj.length;i++)
			{
				selectObj.options[i] = null;
			}
		}

		newoptarray=ArrayFeiraCategoria;


		for (i=0;i<newoptarray.length;i++)
		{
			if(newoptarray[i][0]==selelement)
			{
				selectObj.options[selectObj.length]= new Option(newoptarray[i][2],newoptarray[i][1]);
				//selectObj.options[0].selected = true;
			}
			else
			{
				if((newoptarray[i][3]=='1'))
				{
				//alert(newoptarray[i][3]);
				selectObj.options[selectObj.length]= new Option(newoptarray[i][2],newoptarray[i][1]);
				}
			}
		}
		//selectObj.options[selectObj.length]= new Option("Todos","0");
		//return;
		//selectObj.options[selectObj.length]= new Option('','0');
		//selectObj.options[selectObj.length]= new Option('Expositor','1');
		//selectObj.options[selectObj.length]= new Option('Visitante','2');
		
		
		document.forms[0].CodigoCategoria.onchange();

		for (i=0;i<ArraySiglaWorking.length;i++)
		{
			if(ArraySiglaWorking[i][0]==selelement)
			{
				selelement = ArraySiglaWorking[i][1];
			}
		}

		requiredstate=false;
		selectObj = document.forms[0].Atividade_ID;
		for(j=1;j<100;j++)
		{
			for (i=0;i<selectObj.length;i++)
			{
				selectObj.options[i] = null;
			}
		}

		newoptarray=ArraySetores;

		for (i=0;i<newoptarray.length;i++)
		{
			if(newoptarray[i][0]==selelement)
			{
				selectObj.options[selectObj.length]= new Option(newoptarray[i][2],newoptarray[i][1]);
				//selectObj.options[0].selected = true;
			}
		}
		//selectObj.options[selectObj.length]= new Option("Todos","0");
		return;

	}

	function MudaCategoria (selelement,selelementText)
	{
	
		if(selelementText!='Visitante')
		{
			document.all.Ativ.style.display = 'none';
			document.all.Ativ1.innerHTML = 'Este campo só se aplica a categoria Visitante.';
			document.forms[0].Atividade_ID.disabled = true;
		}
		else	
		{
			document.all.Ativ.style.display = 'block';
			document.all.Ativ1.innerHTML = '';
			document.forms[0].Atividade_ID.disabled = false;
		}
		
		selectObj = document.forms[0].CodigoSubCategoria;
		for(j=1;j<100;j++)
		{
			for (i=0;i<selectObj.length;i++)
			{
				selectObj.options[i] = null;
			}
		}

		newoptarray=ArraySubCategoria;

		for (i=0;i<newoptarray.length;i++)
		{
			if(newoptarray[i][0]==selelement)
			{
				selectObj.options[selectObj.length]= new Option(newoptarray[i][2],newoptarray[i][1]);
				//selectObj.options[0].selected = true;
			}
		}
		//selectObj.options[selectObj.length]= new Option("Todos","0");
		

		return;
	}

	function MudaCategoria2 (selelement, selelementText)
	{
	
		if(selelementText=='Visitante')  //Visitante
		{
			document.all.TextVisitante.style.display = 'block';
			document.all.TextExpositor.style.display = 'none';
				
			document.all.Visitante.style.display = 'block';
			document.all.Expositor.style.display = 'none';

		//document.all.Ativ.style.display = 'block';
		//document.all.Ativ1.innerHTML = '';
		//document.forms[0].Atividade_ID.disabled = false;	
		}
		else
		{
				if(selelement=='Expositor')
				{
					document.all.TextVisitante.style.display = 'none';
					document.all.TextExpositor.style.display = 'block';
					document.all.Visitante.style.display = 'none';
					document.all.Expositor.style.display = 'block';
					//document.all.Ativ.style.display = 'none';
					//document.all.Ativ1.innerHTML = 'Este só se aplica a categoria Visitante.';
					//document.forms[0].Atividade_ID.disabled = true;
				}
				else
				{
						document.all.TextExpositor.style.display = 'none';
						document.all.Expositor.style.display = 'none';
						document.all.TextVisitante.style.display = 'none';
						document.all.Visitante.style.display = 'none';
				}  
		}
		
		selectObj = document.forms[0].CodigoSubCategoria;
		for(j=1;j<100;j++)
		{
			for (i=0;i<selectObj.length;i++)
			{
				selectObj.options[i] = null;
			}
		}

		newoptarray=ArraySubCategoria;

		for (i=0;i<newoptarray.length;i++)
		{
			if(newoptarray[i][0]==selelement)
			{
				selectObj.options[selectObj.length]= new Option(newoptarray[i][2],newoptarray[i][1]);
				//selectObj.options[0].selected = true;
			}
		}
		//selectObj.options[selectObj.length]= new Option("Todos","0");
		
		return;
	}


//**********************************************************************************************	
	
	
	function ImagemNewsLetterPreview()
	{
		openWin('ImagemNewsLetterPreview.asp?feira_id=' + document.forms[0].Feira_ID.value,'Upload',520,300)
	}

	function AbrirUpload()
	{
		//Upload na pagina
		/*if (document.all.uploadimagem.style.visibility=='hidden')
		{
			document.all.uploadimagem.style.visibility='visible';
		}
		else
		{
			document.all.uploadimagem.style.visibility='hidden';
		}
		*/

		//Upload Popup
		openWin('../moduloUpload/UpPopup.asp','Upload',330,100)
	}

//**********************************************************************************************	

// Scripts para validacao em todas as telas de Inscricao - Scripts Gerais

	/*
		1. funções para validacao de caracteres
		
		dicionário utilizado
		
		letras
		- 65 até 90 para keyup e keydown
		- 97 até 122 para keypress
		
		números
		- 48 até 57 para keypress
		- 96 até 105 para keydown e keyup
			
		setas
		- 37 até 40 somente para keup e keydown
		
		delete
		- 46 para keyup e keydown
		
		control
		- 17 para keyup e keydown
		
		alt
		- 18 para keyup e keydown
		
		shift
		- 16 para keyup e keydown
		
		backspace
		- 8 para keyup e keydown
		
		espaço
		- 32 para keydown, keyup e keypress
		
		tab
		- 9 para keydown
		
		home
		- 36 para keydown e keyup
		
		end
		- 35 para keydown e keyup
		
		ponto
		- 194 e 190 para keyup e keydown
		- 46 para keypress
		
		virgula
		- 110 e 188 para keyup e keydown
		- 44 para keypress
		
		Arroba (@)
		- 64 para keypress
		
		Traco
		- 189 para keyup e keydown
		
		Underscore
		- 95 para keypress
		
		Dois Pontos
		- 58 para keypress
		
		Barra
		- 193 para keyup e keydown
		- 47 para keypress
		
		& comercial (somente para links)
		- 38 para keypress
		
		? (somente para links)
		- 63 para keypress
		
		% (somente para links)
		- 37 para keypress	
		
	*/
	
	// função para aceitar somente letras
	function SomenteLetras(e)
	{
		// onkeydown="return SomenteLetras()" onkeypress="return SomenteLetras2()"
		
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		
		// tratamento das teclas
		if ( (tecla < 65 || tecla > 90) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function SomenteLetras2(e) // exclusivamente para eventos keypress
	{
		//onkeypress = return SomenteLetras2(2)
	
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 97 || tecla > 122) && (tecla != 32) && (tecla < 65 || tecla > 90))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	// função para validar o conteudo de letras e numeros para emails
	function ValidarEmail(e)
	{
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 65 || tecla > 90) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36) && (tecla != 190) && (tecla != 189) && (tecla != 190) && (tecla != 194))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function ValidarEmail2(e) // exclusivamente para eventos keypress
	{
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 97 || tecla > 122) && (tecla != 64) && (tecla != 95) && (tecla != 45) && (tecla < 65 || tecla > 90) && (tecla != 46))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	// função para validar o conteudo de letras e numeros para emails
	function ValidarLink(e)
	{
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 65 || tecla > 90) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36) && (tecla != 190) && (tecla != 189) && (tecla != 193) && (tecla != 194) && (tecla != 190) && (tecla != 191))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function ValidarLink2(e) // exclusivamente para eventos keypress
	{		
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 97 || tecla > 122) && (tecla != 63) && (tecla != 38) && (tecla != 37) && (tecla != 58) && (tecla != 47) && (tecla != 95) && (tecla != 45) && (tecla != 46) && (tecla < 65 || tecla > 90))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	
	// função para aceitar somente números
	function SomenteNumeros(e)
	{
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	function SomenteNumeros2(e) // exclusivamente para eventos keypress
	{
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	// função para aceitar letras e numeros
	function LetrasNumeros(e)
	{
	 	//onkeydown="return LetrasNumeros()" onkeypress="return LetrasNumeros2()"
	
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 65 || tecla > 90) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36) && (tecla != 13))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function LetrasNumeros2(e) // exclusivamente para evento keypress
	{
	
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 97 || tecla > 122) && (tecla != 32) && (tecla < 65 || tecla > 90) && (tecla != 13))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	// função para aceitar letras e numeros
	function NumerosDecimais(e,campo)
	{
		//onkeydown="return NumerosDecimais()" onkeypress="return NumerosDecimais2()"
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36) && (tecla != 110) && (tecla != 188))
		{
			return false;
		}
		else
		{
			// verifica se a virgula já está presente no campo e não deixa inserir mais uma
			if (tecla == 110 || tecla == 188)
			{
				var posicao =  campo.value.indexOf(',')
				if(posicao >= 0)
				{
					return false;
				}
			}
			
			// verifica se a string do texto começa com zero e não adiciona mais zeros em duplicação no inicio
			if (tecla == 96 || tecla == 48)
			{
				if (campo.value == '0')
				{
					return false;
				}
			}
			
			// verifica se a string começa com zero. se a tecla for numero diferente de zero, apaga o zero e a string passará a começar com o numero informado
			if (tecla != 96 && tecla != 48)
			{
				if (campo == '0')
				{
					campo.value = '';
				}
			}
			
			return true;
		}
	}
	
	// função para aceitar letras e numeros
	function NumerosDecimais2(e) // exclusivamente para eventos keypress
	{
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla != 44))
		{
			return false;
		}
		else
		{
			return true;
		}
	}
	
	function SomenteMoeda(e)
	{
		//Exemplo
		//onkeyDown="return SomenteMoeda();"
	
		// verifica o navegador
		
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		// tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36) && (tecla != 188))
		{
			return false;
		}
		else
		{
			return true;
		}
	}	
	
	// função para formatar a entrada da data de nascimento
	function FormataData(e,campo)
	{
		 //Exemplo
		 //onkeyUp="return FormataData(event,this)"
	
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		//tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36))
		{
			return false;
		}
		
		data_nascimento = campo.value;	
		if ( (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) )
		{
			tamanho_data = data_nascimento.length;
			if (tamanho_data == 2 || tamanho_data == 5)
			{
				campo.value = data_nascimento + '/';
				return false;
			}
		}
	}
	
	function ValidaData()
	{
		nascimento = document.cadastro.nascimento.value;
		window.open('p_validacoes_v1.asp?acao=valida_data&nascimento='+nascimento,'validacoes','')
	}
	


	function VerificaCpfPreenchido()
	{
		var formulario 	= 	document.cadastro;
		var cpf			=	formulario.cpf.value;
		
		if (!cpf)
		{
			if (confirm('O campo CPF é um campo extremamente importante para o seu cadastro.\nSe você já possui o CPF, aconselhamos que preencha este campo.\nDeseja preencher o CPF agora?'))
			{
				formulario.cpf.focus();
				return false;	
			}
		}

	}
	
	function FormataDataNascimentoEsqueciMinhaSenha(e)
	{
	
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}
		
		//tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36))
		{
			return false;
		}
		data_nascimento = document.frmEsqueciMinhaSenha.nascimento.value;	
		if ( (tecla >= 48 && tecla <= 57) || (tecla >= 96 && tecla <= 105) )
		{
			tamanho_data = data_nascimento.length;
			if (tamanho_data == 2 || tamanho_data == 5)
			{
				document.frmEsqueciMinhaSenha.nascimento.value = data_nascimento + '/';
				return false;
			}
		}
	}
	
	

	//função replace em javascript
	function Replace(campo,valorant, valornovo )
	{
	   var r, re;
	   var ss = "" + campo;
	   r = ss.replace(valorant, valornovo);
	   return(r);
	}
	
	
	
 //formatar nº com casas decimais
 function FormatNumber(numero,decimais)
 { 
  if (isNaN(numero)) { return '0,00' };
   if (numero=='') { return '0,00'}; 
 
   var IsNegative=(parseInt(numero)<0);
   if(IsNegative)numero=-numero;
  
  var snum = new String(numero); 
   var sec = snum.split('.'); 
  var whole = parseInt(sec[0]); 
  var result = '';
  if(sec.length > 1)
  {
   var dec = new String(sec[1]); 
   dec = parseInt(dec)/Math.pow(10,parseInt(dec.length-decimais-1));
   Math.round(dec);
   dec = parseInt(dec)/10;
 
   if(IsNegative)
   {
    var x = 0-dec;
    x = Math.round(x);
    dec = - x;
   }
   else
   {
    dec = Math.round(dec);
   }
 
   /*
   * If the number was rounded up from 9 to 10, and it was for 1 'decimal'
   * then we need to add 1 to the 'whole' and set the dec to 0.
   */
   if(decimais==1 && dec==10)
   {
    whole+=1;
    dec="0";
   }
 
   dec = String(whole) + "." + String(dec); 
   var dot = dec.indexOf('.'); 
   if(dot == -1)
   { 
    dec += '.'; 
    dot = dec.indexOf('.'); 
   }
 
   var l=parseInt(dot)+parseInt(decimais);
   while(dec.length <= l) { dec += '0'; } 
   result = dec; 
  } 
  else
  { 
   var dot; 
   var dec = new String(whole); 
   dec += '.'; 
   dot = dec.indexOf('.'); 
   var l=parseInt(dot)+parseInt(decimais);
   while(dec.length <= l) { dec += '0'; } 
   result = dec; 
  } 
  
  if(IsNegative)result="-"+result;
  
  return result; 
 }
	
	
		/*
		for(i=0;i<f.elements.length;i++)
		{
			if(f.elements[i].name!='complemento')
			{
				if(f.elements[i].value=='')
				{
					alert('O campo ' + f.elements[i].required + ' é obrigatório!');
					f.elements[i].focus();
					return false;
				}
			
			}
		}
		*/	
	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Funções de Validação de CEP  ////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

		
function FormataCEP(e,campo){
//UTILIZAR EM CONJUNTO COM A FUNÇÃO SOMENTE NUMEROS
//Exemplo
//onkeydown="FormataCEP(event,this);return SomenteNumeros();" onkeypress="return SomenteNumeros2();" onblur="FormataCEP2(this);"

	// verifica o navegador
	if (document.all)
	{
		var tecla = event.keyCode;
	}
	else if(document.layers)
	{
		var tecla = e.which;
	}

	//tratamento das teclas
	if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36))
	{
		return false;
	}
	
	data_nascimento = campo.value;	
	if (  (tecla >= 96 && tecla <= 105) )
	{
		tamanho_data = data_nascimento.length;
		if (tamanho_data == 5)
		{
			campo.value = data_nascimento + '-';
			return false;
		}
	}
}

		
function FormataCEP3(e,campo){
//UTILIZAR EM CONJUNTO COM A FUNÇÃO SOMENTE NUMEROS
//Exemplo
//onkeydown="FormataCEP(event,this);return SomenteNumeros();" onkeypress="return SomenteNumeros2();" onblur="FormataCEP2(this);"

	// verifica o navegador
	if (document.all)
	{
		var tecla = event.keyCode;
	}
	else if(document.layers)
	{
		var tecla = e.which;
	}

	//tratamento das teclas
	if ( (tecla < 48 || tecla > 57))
	{
		return false;
	}
	
	data_nascimento = campo.value;	
	if (  (tecla >= 48 && tecla <= 57) )
	{
		tamanho_data = data_nascimento.length;
		if (tamanho_data == 5)
		{
			campo.value = data_nascimento + '-';
			return false;
		}
	}
}

function FormataCEP2(campo){

	var cep = campo.value;
	var newcep = '';
	var contador = 0;
	
	for(i=0;i<cep.length;i++){
		if(!isNaN(cep.charAt(i))){
			contador = contador + 1;
			newcep = newcep + cep.charAt(i);
			if(contador==5){
				newcep = newcep + '-';
			}
		}
	}

	campo.value = newcep;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Funções de Validação de CNPJ  ////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	/* Exemplo para a chamada da Validaçao
	
	if(!f.CNPJ){
		alert('Digite o CNPJ.')
		f.CNPJ.focus();
		return false;
	}
	if(f.CNPJ.value)
	{
		if(!ValidaCNPJ(f.CNPJ)){
			alert('O CNPJ é Inválido!')
			f.CNPJ.select();
			f.CNPJ.focus();
			return false;
		}
	}

	<input type="text" name="CNPJ" VALUE="" MaxLength="18" class="estilo_formulario_obrigatorio" style="width:100%" onkeyDown="FormataCNPJ(event,this)">

	*/

	// Função para validação do CNPJ
	function ValidaCNPJ(campo)
	{
		cnpj = campo.value;

		// validacao dos numeros informados para o CNPJ ou CGC
		if(cnpj)
		{
			if(!ChecaForm(cnpj,campo))
			{
				return false;
			}
			
			return true;

			function ValChar(ch) 
			{
				if (ch=="0") return 0
				else if (ch=="1") return 1
				else if (ch=="2") return 2
				else if (ch=="3") return 3
				else if (ch=="4") return 4
				else if (ch=="5") return 5
				else if (ch=="6") return 6
				else if (ch=="7") return 7
				else if (ch=="8") return 8
				else if (ch=="9") return 9
				else return 10
			}

			// Verifica se o argumento é um CGC válido de 8 dígitos
			function ChecaCGC8 (CKCGC) 
			{
				var CGC = CKCGC;
				var NewCGC = "";
				
				// Elimina todos os espaços, pontos, barras e traços do CGC
				for (i=0;i<CGC.length;i++) 
				{ 
					if (CGC.charAt(i) != " " && CGC.charAt(i) != "." && CGC.charAt(i) != "/" && CGC.charAt(i) != "-") 
						NewCGC = NewCGC + CGC.charAt(i);
				}

				// Verifica tamanho do CGC
				if (NewCGC.length!=8) 
				{
					return false;
				}
				
				// verifica se todos os caracteres são numéricos
				var Numerico = false;
				var Numeros = "0123456789";
				for (i=0;i<NewCGC.length;i++) 
				{
					Numerico = false;
					for (j=0;j<Numeros.length;j++) 
					{
						if (NewCGC.charAt(i) == Numeros.charAt(j)) 
						{
							Numerico = true;
							break;
						}
					}
					
					if (!Numerico) 
					{
						return false;
					}
				}

				// Calcula os dígitos verificadores
				var s1 = 0;
				aux = 0;
				soma = 0
				for (i=1;i<=8;i++) 
				{
					aux = (ValChar(NewCGC.charAt(i-1)))*((i % 2)+1);
					if (aux>9) 
						aux = aux-9;
					soma = soma + aux;
				}
				
				r1 = soma % 10;
				
				if(r1==0)
				{
					return true;
				}
				else 
				{
					return false;
				}
				
			}

			// Verifica se o argumento é um CGC válido
			function ChecaCGC (CKCGC) 
			{
				var CGC = CKCGC;
				var NewCGC = "";

				// Verifica tamanho do CGC
				if (CGC.length!=14) 
				{
					return false;
				}
			
				// Calcula os dígitos verificadores
				// Guarda os 12 primeiros digitos
				
				var DVCGC = CGC.substring(0,12);
				
				// calcula o primeiro digito verificador
				var s1 = 0;
				for (i=1;i<=4;i++) 
					s1 = s1 + (ValChar(DVCGC.charAt(i-1))*(6-i));
	
				for (i=5;i<=12;i++) 
					s1 = s1 + (ValChar(DVCGC.charAt(i-1))*(14-i));
					
				r1 = s1 % 11;
				if(r1<2) 
					dv1 = 0;
				else 
					dv1 = 11 - r1;
				
				//calcula o segundo digito verificador
				var s2 = dv1*2;
				for (i=1;i<=5;i++) 
					s2 = s2 + (ValChar(DVCGC.charAt(i-1))*(7-i));
	
				for (i=6;i<=12;i++) 
					s2 = s2 + (ValChar(DVCGC.charAt(i-1))*(15-i));
				
				r2 = s2 % 11;
				if (r2<2) 
					dv2=0;
				else 
					dv2 = 11 - r2;
			
				// junta os digitos verificadores
				var DV = "";
				DV = DV + dv1 + dv2;
			
				// guarda os digitos verificadores do CGC digitado (últimas duas posições no string)
				var NewDV = CGC.substring(12,14)
				if (NewDV==DV) //se o DV calculado for igual ao digitado, retorna true
				{ 
					return true
				}
				else 
				{
					return false
				}
				//return true
				
				//alert(CGC)
			}

			function ChecaForm(theField, campo) 
			{
				if(theField.length > 0)
				{
					
					var a = theField;
					var b = "";
					var c = "";
					var d = 0;
					for(cont=0;cont<a.length;cont++)
					{
						if(	a.charAt(cont)=="0" || a.charAt(cont)=="1" || a.charAt(cont)=="2" || a.charAt(cont)=="3" || a.charAt(cont)=="4" || a.charAt(cont)=="5" || a.charAt(cont)=="6" || a.charAt(cont)=="7" || a.charAt(cont)=="8" || a.charAt(cont)=="9")
						{
							b = b + a.charAt(cont);
						}
					}
					a = b;

					// SE NÃO FOR IDENTIFICADO NENHUM NÚMERO - "CNPJ Inválido"
					if(a.length=="")
					{
						return false;
					}

					if (a!="") 
					{
						var checkOK = "0123456789-";
						var checkStr = a;
						var allValid = true;
						var decPoints = 0;
						var allNum = "";
						for (i = 0;  i < checkStr.length;  i++)
						{
							ch = checkStr.charAt(i);
							for (j = 0;  j < checkOK.length;  j++)
								if (ch == checkOK.charAt(j)) break;
							
							if (j == checkOK.length)
							{
								allValid = false;
								break;
							}
							allNum += ch;
						}
			
						if (!allValid)
						{
							return false;
						}
						
						//checa se o campo é CPF válido, retorna true e envia o formulário
						
						if (ChecaCGC(a) || ChecaCGC8(a))
						{
							b = "99.999.999/9999-99";
							for(cont = 0; cont < b.length; cont++)
							{
								numero = b.charAt(cont);
								if(numero == "9")
								{
									if(a.charAt(cont-d)!="")
									{
										c = c + a.charAt(cont-d);
									}
									else
									{
										c = c + "0";
									}
								}
			    				else
			    				{
									c = c + b.charAt(cont);
									d = d + 1;
							    }
							    numero = "";
							}

							//campo.value= c;
							return true;
						}
						else
						{
							return (false);
						}
						
						return true
					}
				}		
			}
		}
	}



	function FormataCNPJ(e,campo)
	{
	 //UTILIZAR EM CONJUNTO COM A FUNÇÃO SOMENTE NUMEROS
	 //Exemplo
	 //onkeyDown="return SomenteNumeros();" onkeyDown="return FormataCNPJ(event,this)"
	
	
	
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}

		//tratamento das teclas
		if ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36))
		{
			return false;
		}
		
		data_nascimento = campo.value;	
		if (  (tecla >= 96 && tecla <= 105) )
		{
			tamanho_data = data_nascimento.length;
			if (tamanho_data == 2)
			{
				campo.value = data_nascimento + '.';
				return false;
			}
			if ( tamanho_data == 6)
			{
				campo.value = data_nascimento + '.';
				return false;
			}

			if (tamanho_data == 10)
			{
				campo.value = data_nascimento + '/';
				return false;
			}
			if (tamanho_data == 15)
			{
				campo.value = data_nascimento + '-';
				return false;
			}

		}
		return true;
	}

function FormataCNPJ3(e,campo)
	{
	 //UTILIZAR EM CONJUNTO COM A FUNÇÃO SOMENTE NUMEROS
	 //Exemplo
	 //onkeyDown="return SomenteNumeros();" onkeyDown="return FormataCNPJ(event,this)"
	
	
		// verifica o navegador
		if (document.all)
		{
			var tecla = event.keyCode;
		}
		else if(document.layers)
		{
			var tecla = e.which;
		}

		//tratamento das teclas
		if ( (tecla < 48 || tecla > 57))
		{
			return false;
		}
		
		data_nascimento = campo.value;	
		if (  (tecla >= 48 && tecla <= 57) )
		{
			tamanho_data = data_nascimento.length;
			if (tamanho_data == 2)
			{
				campo.value = data_nascimento + '.';
				return false;
			}
			if ( tamanho_data == 6)
			{
				campo.value = data_nascimento + '.';
				return false;
			}

			if (tamanho_data == 10)
			{
				campo.value = data_nascimento + '/';
				return false;
			}
			if (tamanho_data == 15)
			{
				campo.value = data_nascimento + '-';
				return false;
			}

		}
		return true;
	}

	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Funções de Validação de CPF  /////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////


	/* Exemplo para a chamada da Validaçao
	
	if(!f.CPF.value){
		alert('Digite o CPF.')
		f.CPF.focus();
		return false;
	}
	if(f.CPF.value)
	{
		if (!ValidaCPF(f.CPF.value))
		{
			f.CPF.select();
			f.CPF.focus();
			return false;
		}
	}

	<input  type="text" name="CPF" VALUE="" MaxLength="14" class="estilo_formulario_obrigatorio" style="width:100%" onkeydown="FormataCPF(event,this);" onblur="FormataCPF2(this);">

	*/

function ValidaCPF(cpf)
{

	var novovalor = "";
	for(i=0;i<cpf.length;i++)
	{
		if(cpf.charAt(i)==0 || cpf.charAt(i)==1 || cpf.charAt(i)==2 || cpf.charAt(i)==3 || cpf.charAt(i)==4 || cpf.charAt(i)==5 || cpf.charAt(i)==6 || cpf.charAt(i)== 7 || cpf.charAt(i)==8 || cpf.charAt(i)==9)
		{
			novovalor = novovalor + '' +  cpf.charAt(i);
		}
	}
	
	cpf = novovalor;

	/* Exmplo para chamada
		if(ValidaCPF(f.cpf.value)==false)
		{
			return false;
		}
	*/
	
	// formula para validacao do CPF
	x = 0;
	soma = 0;
	dig1 = 0;
	dig2 = 0;
	texto = "";
	cpf1="";
	len = cpf.length; x = len -1;
	for (var i=0; i <= len - 3; i++)
	{
		y = cpf.substring(i,i+1);
		soma = soma + ( y * x);
		x = x - 1;
		texto = texto + y;
	}

	dig1 = 11 - (soma % 11);
	if (dig1 == 10) dig1=0 ;
	if (dig1 == 11) dig1=0 ;
	cpf1 = cpf.substring(0,len - 2) + dig1 ;
	x = 11; soma=0;

	for (var i=0; i <= len - 2; i++)
	{
		soma = soma + (cpf1.substring(i,i+1) * x);
		x = x - 1;
	}

	dig2= 11 - (soma % 11);
	if (dig2 == 10) dig2=0;
	if (dig2 == 11) dig2=0;
	if ((dig1 + "" + dig2) != cpf.substring(len,len-2))
	{
		alert ("Número do CPF invalido !!!");
		return false;
	}

	if (cpf == '11111111111')
	{
		alert('Preencha o campo CPF corretamente.');
		return false;
	}

	return true;

}	




function FormataCPF(e,campo)
{
 //UTILIZAR EM CONJUNTO COM A FUNÇÃO SOMENTE NUMEROS
 //Exemplo
 //onkeyDown="return SomenteNumeros();" onkeyDown="FormataCPF(event,this)"

	// verifica o navegador
	if (document.all)
	{
		var tecla = event.keyCode;
	}
	else if(document.layers)
	{
		var tecla = e.which;
	}

	//tratamento das teclas
	if( ( (tecla < 48 || tecla > 57) && (tecla < 96 || tecla > 105) && (tecla < 37 || tecla > 40) && (tecla != 17) && (tecla != 18) && (tecla != 8) && (tecla != 9) && (tecla != 32) && (tecla != 46) && (tecla != 35) && (tecla != 36)))
	{
		return false;
	}
	
	data_nascimento = campo.value;	
	if (  (tecla >= 96 && tecla <= 105))
	{
		tamanho_data = data_nascimento.length;
		if (tamanho_data == 3)
		{
			campo.value = data_nascimento + '.';
			return false;
		}
		if ( tamanho_data == 7)
		{
			campo.value = data_nascimento + '.';
			return false;
		}
		if (tamanho_data == 11)
		{
			campo.value = data_nascimento + '-';
			return false;
		}

	}
}

function FormataCPF3(e,campo)
{
 //UTILIZAR EM CONJUNTO COM A FUNÇÃO SOMENTE NUMEROS
 //Exemplo
 //onkeyDown="return SomenteNumeros();" onkeyDown="FormataCPF(event,this)"

	// verifica o navegador
	if (document.all)
	{
		var tecla = event.keyCode;
	}
	else if(document.layers)
	{
		var tecla = e.which;
	}

	//tratamento das teclas
	if ( (tecla < 48 || tecla > 57))
	{
		return false;
	}
	
	data_nascimento = campo.value;	
	if (  (tecla >= 48 && tecla <= 57))
	{
		tamanho_data = data_nascimento.length;
		if (tamanho_data == 3)
		{
			campo.value = data_nascimento + '.';
			return false;
		}
		if ( tamanho_data == 7)
		{
			campo.value = data_nascimento + '.';
			return false;
		}
		if (tamanho_data == 11)
		{
			campo.value = data_nascimento + '-';
			return false;
		}

	}
}

function FormataCPF2(campo){

	var cpf = campo.value;
	var newcpf = '';
	var contador = 0;
	
	for(i=0;i<cpf.length;i++){
		if(cpf.charAt(i)==0 || cpf.charAt(i)==1 || cpf.charAt(i)==2 || cpf.charAt(i)==3 || cpf.charAt(i)==4 || cpf.charAt(i)==5 || cpf.charAt(i)==6 || cpf.charAt(i)== 7 || cpf.charAt(i)==8 || cpf.charAt(i)==9){
			contador = contador + 1;
			newcpf = newcpf + cpf.charAt(i);
			if(contador==3){
				newcpf = newcpf + '.';
			}
			if(contador==6){
				newcpf = newcpf + '.';
			}
			if(contador==9){
				newcpf = newcpf + '-';
			}
		}
	}

	campo.value = newcpf;
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////


function ValidaEmail(campo){
  // validacao do campo E-mail Geral
	var email_geral = campo.value;
	if(campo.value)
	{
		if(!email_geral)
		{
			alert(mesagememailinvalido);
			campo.focus();
			return false;
		}
	  
	  // validacao do conteudo informado no e-mail
	  if (email_geral){
		pos = email_geral.indexOf("@")
		
			if (pos == -1 || pos < 2){
			    alert(mesagememailinvalido);
				campo.focus();
		    	campo.select();
			    return false;
			}
			else{
			    // verifica se existe "." (ponto) no e-mail
		    	pos = email_geral.indexOf(".")
			    if (pos == -1 || pos == 0) 
		    	{
				     alert(mesagememailinvalido);
			    	 campo.focus();
				     campo.select();
				     return false;
		    	}
			    else
		    	{
				     ponto = email_geral.indexOf(".")
			    	 tamanho = email_geral.length;
				     parte = email_geral.substring(ponto,tamanho);
		  
				     // verifica se existe mais de dois caracteres apos o ponto no e-mail
				     if (parte.length < 3){
				      alert(mesagememailinvalido);
				      campo.focus();
				      campo.select();
				      return false;
				     }
		    	}
		   }
	  	}
	}
}  