/* 
 Data    		 : 24/08/2005
 Produto     : Sistema de controle de vagas
 Programador : Rodrigo
 Pagina      : inc_funções.js
 Empresa     : MediaLine
 Descrições  : Remove todas as sessões ativas do sistema.
 Funções     : função validaForm - Verifica todo e qualquer campo obrigatório de qualquer formulário ou não.
               variaveis : form - Nome do formulário a ser varrido pelo codigo.

 Observações :
*/

function MediaLine(){
	this.valida    			= validaForm;
	this.EnviaForm  		= EnviaForm;
	this.Check      		= validaCheck;
	this.CheckAtiva 		= validaCheckAtiva;
	this.Telefone   		= maskTelefone;
	this.Cep       			= maskCEP;
	this.Datam      		= maskData;
	this.Datas			 		= validaData;
	this.formatDouble		=	formataValor;
	this.contagem   		= Contagem;
	this.menu       		= menu;
	this.carrega    		= carrega;
	this.limpa      		= limpa;
	this.cpf        		= validaCpf;
	this.cnpj			 			= validaCnpj;
	
	function validaCheckAtiva(x){
		var ret = false;
		if (selecionoucheck(x)){
			ret = confirm("Estagiar :\n\nVocê realmente deseja reativar o(s) registro(s) selecionado(s)?");
		}else{
			alert("Estagiar :\n\n Selecione uma opção para reativar.");
			return false;
		}
		return ret;
	}
	
	function validaCheck(x){
		var ret = false;
		if (selecionoucheck(x)){
			ret = confirm("Estagiar :\n\nVocê realmente deseja excluir o(s) registro(s) selecionado(s)?");
		}else{
			alert("Estagiar :\n\n Selecione uma opção para excluir.");
			return false;
		}
		return ret;
	}
	
	function maskCEP( event, obj) {
		tam = obj.value.length;
		if (tam==5) obj.value = obj.value + "-";
	}
	
	function maskData(event,obj){
		tam = obj.value.length;
		if((tam == 2)|(tam == 5)) obj.value = obj.value + "/";
	}

	function formataValor(objeto,tammax,teclapres) {
		var tecla = teclapres.keyCode;
		vr = objeto.value;
		vr = vr.replace( ".", "" );
		vr = vr.replace( ",", "" );
		tam = vr.length;
		if (tam < tammax && tecla != 8) {tam = vr.length + 1 ;}
		if (tecla == 8 ) {tam = tam - 1 ;}
		
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) {
			if ( tam <= 2 ) {
				objeto.value = vr ;
			}else if ( (tam > 2) && (tam <= 5) ) {
				objeto.value = vr.substr(0, tam-2) + ',' + vr.substr(tam-2, tam);
			}else if ( (tam >= 6) && (tam <= 8) ) {
				objeto.value = vr.substr(0, tam-5) + '.' + vr.substr(tam-5, 3) + ',' + vr.substr(tam-2, tam) ;			
			}
		}		
	}
	
	function selecionoucheck(ck){
		for (i = 0; i < ck.length; i++){
			if(ck[i].type=="checkbox"){
				if(ck[i].name=="excluir"){
					if(ck[i].checked){
						return true;
					}
				}
			}
		}
		return false;
	}
	
	function validaForm(form){
		var alerta 	= "";
		var y    		= "";
		var w 			= "";
		var i      	= 0;
  	var frm = eval("document."+form);
		
		for(x=0;frm.length > x;x++){
			if(!(frm.elements[x].name=="")){
  			campo = eval("document.all."+frm.elements[x].name);
			}

			if(frm.elements[x].type == "hidden" | frm.elements[x].type == "text" | frm.elements[x].type == "select-one" | frm.elements[x].type == "select-multiple" | frm.elements[x].type == "textarea" | frm.elements[x].type == "password"){
				if(frm.elements[x].obrigatorio == "sim" & frm.elements[x].value == ""){
					alerta += "- " + frm.elements[x].nome + "\n";
					campo.style.background = "#FFFFCC";
					y = y + "," + campo.name;
				}else if(frm.elements[x].obrigatorio == "sim" & frm.elements[x].value != ""){
					campo.style.background = "#FFFFFF";
				}
				
				if(frm.email){
					if(frm.email.value != ""){
						emailReg  = "^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]{2,64}(\.[a-z0-9-]{2,64})*\.[a-z]{2,50}$";
						var regex = new RegExp(emailReg);
						if(!(regex.test(frm.email.value))){
							alerta   = "- E-mail inválido - " + frm.email.value; y = "";
							frm.email.focus();
						}						
					}
				}
			}
		}
		y = new String(y);w = y.split(",");
		y = eval("document.all."+w[1]);
		(alerta.length > 0)?alert("Preencha corretamente:\n\n" + alerta):frm.submit();
		if(y!=undefined){
			if(!(y.type=="hidden")) y.focus();
		}
		return(false);
	}
	
	function maskTelefone(objeto,tammax,teclapres) {

		var tecla = teclapres.keyCode;
		vr = objeto.value;
		vr = vr.replace( "(", "" );
		vr = vr.replace( ")", "" );
		vr = vr.replace( " ", "" );
		vr = vr.replace( "-", "" );
		vr = vr.substr(0, tammax - 1)
		tam = vr.length;
		if (tam < tammax && tecla != 8) {tam = vr.length + 1;}
		if (tecla == 8) {tam = tam - 1 ;}
		if (tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105) {
			if (tam <= 4) {objeto.value = vr ;}
			if ((tam > 4) && (tam <= 8)) {objeto.value = vr.substr(0,tam-4) + '-' + vr.substr( tam - 4, tam );}
			if ((tam >= 9) && (tam <= 10)) {objeto.value = '(' + vr.substr(0,2) + ') ' + vr.substr(2,tam-6) + '-' + vr.substr(tam-4,tam);}
		}		
	}
	
	function EnviaForm(frm,vlr,alvo){
		var formulario = eval("document."+frm);
		document.all.parametro.value = vlr;
		if(isNaN(vlr)){
			if(formulario.nomes){
				formulario.nomes.value=vlr;
			}
		}
		formulario.action = alvo;
		formulario.submit();
	}
	
} //[FIM DA CLASSE
	
	function Contagem(campo, contador, limite) {
		if (campo.value.length > limite){
			campo.value = campo.value.substring(0,limite);
		}else{
			contador.value = limite - campo.value.length;
		}
	}
	
	function menu(nro, nivel){
		var aba = new Array;
		var len;
		aba[0] = "manutencao";
		aba[1] = "estatistica";
		aba[2] = "mailing";
		aba[3] = "sistema";
		aba[4] = "site";
		
		len = 5
		
		for(i = 0 ; i < len ; i++){
			try{ 
				if(i != nro){
					document.getElementById(aba[i]).style.display="none";
				}else{
					if(document.getElementById(aba[nro]).style.display==""){
						document.getElementById(aba[i]).style.display="none";
						break;
					}
				}
				if(nro == i){
					if(document.getElementById(aba[i])){
						if(document.getElementById(aba[nro]).style.display="none"){
							document.getElementById(aba[nro]).style.display="";
							document.getElementById("menu").src="menu.asp?menu="+aba[nro];
						}else{
							document.getElementById(aba[i]).style.display="none";
						}
					}
				}
			}
			catch(e){}
		}
		
		/*
		for(i = 0 ; i < len ; i++){
			if(i!=nro){
				document.getElementById(aba[i]).style.display="none";
			}else{
				if(document.getElementById(aba[nro]).style.display==""){
					document.getElementById(aba[i]).style.display="none";
					break;
				}
			}
			if(nro == i){
				if(document.getElementById(aba[i])){
					if(document.getElementById(aba[nro]).style.display="none"){
						document.getElementById(aba[nro]).style.display="";
						document.getElementById("menu").src="menu.asp?menu="+aba[nro];
					}else{
						document.getElementById(aba[i]).style.display="none";
					}
				}
			}
		}
		*/
		
	}
	
	function carrega(marca, Texto,el,x){
		objeto = eval("parent.document.all."+el);
		objeto.options[objeto.options.length] = new Option(Texto , marca);
		if(!(x=='')){
			for(i=1;i < objeto.options.length;i++){
				if(marca == x){
					objeto.selectedIndex = i;
				}
			}
		}
	}
	
	function limpa(el,x){
		objeto = eval("parent.document.all."+el);
		for (i = objeto.options.length; i >= 0; i--){
			objeto.options[i] = null;
		}
		if(x){
			objeto.options[objeto.options.length] = new Option('Selecione uma opção','')
			objeto.selectedIndex = -1;
		}else{
			objeto.options[objeto.options.length] = new Option('Nenhum registro localizado','')
		}
	}
	
	function validaCpf(txtCpf){ 
		//alert("asdas");
		var i; 
		s = eval("document.all."+txtCpf);
		var c = s.value.substr(0,9); 
		var dv = s.value.substr(9,2); 
		var d1 = 0; 
		for (i = 0; i < 9; i++){ 
			d1 += c.charAt(i)*(10-i); 
		} 
		if (d1 == 0){ 
			alert("Preencha corretamente :\n\n- CPF inválido");s.focus();
			return false; 
		}
		d1 = 11 - (d1 % 11); 
		if (d1 > 9) d1 = 0; 
		if (dv.charAt(0) != d1){ 
			alert("Preencha corretamente :\n\n- CPF inválido");s.focus();
			return false; 
		} 
		d1 *= 2; 
		for (i = 0; i < 9; i++){ 
			d1 += c.charAt(i)*(11-i); 
		} 
		d1 = 11 - (d1 % 11); 
		if (d1 > 9) d1 = 0; 
		if (dv.charAt(1) != d1){ 
			alert("Preencha corretamente :\n\n- CPF inválido");s.focus();
			return false;
		} 
		return true; 
	} 
	
	function validaCnpj(CNPJ){
		if(Vale = (CNPJ.length <= 14)){
			for(z=0;z<2;z++){
				Soma = 0;
				for(i=(5+z),j=0;j<(12+z);i--,j++){
					Soma += (CNPJ.substr(j, 1) * i);
					if(i == 2) i = 10;
				}
				Fim = (((Soma % 11) < 2) ? 0 : (((Soma % 11) == 10) ? 1 : 11-(Soma % 11)));
				if(!(Vale = (CNPJ.substr((12+z),1) == Fim))){
					alert("Preencha corretamente :\n\n- CNPJ inválido");
					document.all.cnpj.focus();
					break;
				}
			}
			return Vale;
		}
	}

	var reDate1 = /^\d{1,2}\/\d{1,2}\/\d{1,4}$/;	
	var reDate2 = /^[0-3]?\d\/[01]?\d\/(\d{2}|\d{4})$/;
	var reDate3 = /^(0?[1-9]|[12]\d|3[01])\/(0?[1-9]|1[0-2])\/(19|20)?\d{2}$/;
  var reDate4 = /^((0?[1-9]|[12]\d)\/(0?[1-9]|1[0-2])|30\/(0?[13-9]|1[0-2])|31\/(0?[13578]|1[02]))\/(19|20)?\d{2}$/;
  var reDate5 = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;
  var reDate = reDate4;
	
	function validaData(pStr, pFmt){
		eval("reDate = reDate" + pFmt);
		if(pStr == ""){
			return(true);
		}
		if (reDate.test(pStr)){
			if(isdate(pStr)){
				return true;
			}else{
				alert("Preencha corretamente:\n\n"+pStr + " não é uma data válida.");
				return false;
			}
		} else if (pStr != null && pStr != ""){
			alert("Preencha corretamente:\n\n"+pStr + " não é uma data válida.");
			return false;
		}
	}
	
	function validaemail(src) {
		emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[a-zA-Z]$"
		var regex = new RegExp(emailReg);
		return regex.test(src);	
	}
	
	function PopUp(I, W, H){
		lpos = (screen.availWidth/2) - (W/2);
		tpos = (screen.availHeight/2) - (H/2);
		window.open(I,'Estagiar','scrollbars=0,left='+lpos+',top='+tpos+',width='+W+',height='+H).focus();
	}
	
	function PopUpScr(I, W, H){
		lpos = (screen.availWidth/2) - (W/2);
		tpos = (screen.availHeight/2) - (H/2);
		window.open(I,'Estagiar','scrollbars=yes,left='+lpos+',top='+tpos+',width='+W+',height='+H).focus();
	}

	function moveCidade(obj, allOpt){
		var from;
		var to;
		
		if ((obj.name == 'goAll')||(obj.name == 'goSelected')){
			from = document.getElementById('listaCidade');
			to = document.getElementById('idCidade'); 
		}else{
			from = document.getElementById('idCidade');
			to = document.getElementById('listaCidade'); 
		}
		for (i = 0 ; i < from.options.length ; i++){
			if (from.options[i].selected == true || allOpt == true ){
				//Cria uma opção para inserir na select
				opt = document.createElement('Option');
				opt.text = from.options[i].text;
				opt.value = from.options[i].value;
				//Adiciona mais um item no select
				try { // Todos os browsers menos IE
					to.add(opt, null);
				}
				catch(e) { // IE
					to.add(opt);
				}
				from.remove(i);
				i--;
			}
		} //end for

		//Habilita / Desabilita os botôes
		if (from.options.length == 0){
			if ((obj.name == "goAll")||(obj.name == "goSelected")){
				document.all.goAll.disabled = true;
				document.all.goSelected.disabled = true;
				document.all.backAll.disabled = false;
				document.all.backSelected.disabled = false;
			}else{
				document.all.backAll.disabled = true;
				document.all.backSelected.disabled = true;
				document.all.goAll.disabled = false;
				document.all.goSelected.disabled = false;
			}
		}else{
			document.all.goAll.disabled = false;
			document.all.goSelected.disabled = false;
			document.all.backAll.disabled = false;
			document.all.backSelected.disabled = false;
		}
	}
	
	//[ Função antes de alterar
	function moveOption(idOrigem, idDestino, all){
		var from;
		var to;
		
		//[ Captura a origem/destino
		from = document.getElementById(idOrigem);
		to = document.getElementById(idDestino);
		
		//[ Insere os dados no destino
		for (i = 0 ; i < from.options.length ; i++){
			if (all || from.options[i].selected == true){
				//Cria uma opção para inserir na select
				opt = document.createElement('Option');
				opt.text = from.options[i].text;
				opt.value = from.options[i].value;
				
				//Adiciona mais um item no select
				try { // Todos os browsers menos IE
					to.add(opt, null);
				}
				catch(e) { // IE
					to.add(opt);
				}
				
				from.remove(i);
				i--;
			}
		} //end for
	}
	
	function moveCurso(obj, allOpt){
		var from;
		var to;
		
		if ((obj.name == 'goAll')||(obj.name == 'goSelected')){
			from = document.getElementById('listaCurso'); //document.all.listaCurso;
			to = document.getElementById('curso'); //document.all.curso;
		}else{
			from = document.getElementById('curso'); //document.all.curso;
			to = document.getElementById('listaCurso'); //document.all.listaCurso; 
		}
		for (i = 0 ; i < from.options.length ; i++){
			if (from.options[i].selected == true || allOpt == true ){
				//Cria uma opção para inserir na select
				opt = document.createElement('Option');
				opt.text = from.options[i].text;
				opt.value = from.options[i].value;
				//Adiciona mais um item no select
				try { // Todos os browsers menos IE
					to.add(opt, null);
				}
				catch(e) { // IE
					to.add(opt);
				}
				from.remove(i);
				i--;
			}
		} //end for

		//Habilita / Desabilita os botôes
		if (from.options.length == 0){
			if ((obj.name == "goAll")||(obj.name == "goSelected")){
				document.all.goAll.disabled = true;
				document.all.goSelected.disabled = true;
				document.all.backAll.disabled = false;
				document.all.backSelected.disabled = false;
			}else{
				document.all.backAll.disabled = true;
				document.all.backSelected.disabled = true;
				document.all.goAll.disabled = false;
				document.all.goSelected.disabled = false;
			}
		}else{
			document.all.goAll.disabled = false;
			document.all.goSelected.disabled = false;
			document.all.backAll.disabled = false;
			document.all.backSelected.disabled = false;
		}
	}

	function moveCandidato(obj, allOpt){
		var from;
		var to;
		
		if ((obj.name == 'goAll')||(obj.name == 'goSelected')){
			from = document.getElementById('listaCandidato'); //document.all.listaCurso;
			to = document.getElementById('candidato'); //document.all.curso;
		}else{
			from = document.getElementById('candidato'); //document.all.curso;
			to = document.getElementById('listaCandidato'); //document.all.listaCurso; 
		}
		for (i = 0 ; i < from.options.length ; i++){
			if (from.options[i].selected == true || allOpt == true ){
				if (!(document.getElementById('goAll'))) {
					if (to.options.length==1) {
						//alert('to possui tamanho 1')
						opt = document.createElement('Option');
						opt.text = to.options[0].text;
						opt.value = to.options[0].value;
						try { // Todos os browsers menos IE
							from.add(opt, null);
						}
						catch(e) { // IE
							from.add(opt);
							//alert('adicionou o elemento do to no from: ' + opt.text);
						}
						to.remove(0);
						//alert('removeu o elemento do to');
					}
					else {
						if (to.options.length>1) {
							//alert('destino tem vários elementos');
						}
						else {
							//alert('destino não possui elementos');
						}
					}
				}
				//Cria uma opção para inserir na select
				opt = null;
				opt = document.createElement('Option');
				if (from.options.length==1) {
					opt.text = from.options[0].text;
					opt.value = from.options[0].value;
					//alert('from possui 1 elemento: ' + opt.text);
				}
				else {
					if (from.options.length>1) {
						opt.text = from.options[i].text;
						opt.value = from.options[i].value;
						//alert('from possui vários elementos: ' + from.options[i].text);
					}
					else {
						//alert('from não possui elementos');
					}
				}
				//Adiciona mais um item no select
				try { // Todos os browsers menos IE
					to.add(opt, null);
				}
				catch(e) { // IE
					to.add(opt);
					//alert('adicionou no to');
				}
				from.remove(i);
				//alert('removeu do from');
				i--;
			}
		} //end for

		//Habilita / Desabilita os botôes
		/*
		if (from.options.length == 0){
			if ((obj.name == "goAll")||(obj.name == "goSelected")){
				if (obj.name == "goAll") {
					document.all.goAll.disabled = true;
					document.all.backAll.disabled = false;
				}
				document.all.goSelected.disabled = true;
				document.all.backSelected.disabled = false;
			}
			else {
				if (obj.name == "goAll") {
					document.all.backAll.disabled = true;
					document.all.goAll.disabled = false;
				}
				document.all.backSelected.disabled = true;
				document.all.goSelected.disabled = false;
			}
		}
		else {
			if (obj.name == "goAll") {
				document.all.goAll.disabled = false;
				document.all.backAll.disabled = false;
			}
			document.all.goSelected.disabled = false;
			document.all.backSelected.disabled = false;
		}
		*/
	}
	
	function selectAll(opt){
		if (opt.length > 0){
			for (i = 0 ; i < opt.length ; i++){
				opt[i].selected = true;
			}
			return true;
		}
		return false;
	}

	
	function moveInstituicao(obj, allOpt){
		var from;
		var to;

		if ((obj.name == 'goAll')||(obj.name == 'goSelected')){
			from = document.getElementById('listaInstituicao');
			to = document.getElementById('instituicao');
		}else{
			from = document.getElementById('instituicao');
			to = document.getElementById('listaInstituicao');
		}
		
		for (i = 0 ; i < from.options.length ; i++){
			if (from.options(i).selected == true || allOpt == true ){
				//Cria uma opção para inserir na select
				opt = document.createElement('Option');
				opt.text = from.options(i).text;
				opt.value = from.options(i).value;
				//Adiciona mais um item no select
				try { // Todos os browsers menos IE
					to.add(opt, null);
				}
				catch(e) { // IE
					to.add(opt);
				}
				//Remove do select fonte
				from.remove(i);
				i--;
			}
		} //end for
		
		//Habilita / Desabilita os botôes
		if (from.options.length == 0){
			if ((obj.name == 'goAll')||(obj.name == 'goSelected')) {
				document.all.goAll.disabled = true;
				document.all.goSelected.disabled = true;
				document.all.backAll.disabled = false;
				document.all.backSelected.disabled = false;
			}
			else {
				document.all.backAll.disabled = true;
				document.all.backSelected.disabled = true;
				document.all.goAll.disabled = false;
				document.all.goSelected.disabled = false;
			}
		}
		else {
			document.all.goAll.disabled = false;
			document.all.goSelected.disabled = false;
			document.all.backAll.disabled = false;
			document.all.backSelected.disabled = false;
		}
	}

//valida a data
function isdate(Data){
	var dma = -1;
	var data = Array(3);
	var ch = Data.charAt(0); 
	for(i=0; i < Data.length && (( ch >= '0' && ch <= '9' ) || ( ch == '/' && i != 0 ) ); ){
		data[++dma] = '';
		if(ch!='/' && i != 0) return false;
		if(i != 0 ) ch = Data.charAt(++i);
		if(ch=='0') ch = Data.charAt(++i);
		while( ch >= '0' && ch <= '9' ){
			data[dma] += ch;
			ch = Data.charAt(++i);
		} 
	}
	if(ch!='') return false;
	if(data[0] == '' || isNaN(data[0]) || parseInt(data[0]) < 1) return false;
	if(data[1] == '' || isNaN(data[1]) || parseInt(data[1]) < 1 || parseInt(data[1]) > 12) return false;
	if(data[2] == '' || isNaN(data[2]) || ((parseInt(data[2]) < 0 || parseInt(data[2]) > 99 ) && (parseInt(data[2]) < 1900 || parseInt(data[2]) > 9999))) return false;
	if(data[2] < 50) data[2] = parseInt(data[2]) + 2000;
	else if(data[2] < 100) data[2] = parseInt(data[2]) + 1900;
	switch(parseInt(data[1])){
		case 2: { if(((parseInt(data[2])%4!=0 || (parseInt(data[2])%100==0 && parseInt(data[2])%400!=0)) && parseInt(data[0]) > 28) || parseInt(data[0]) > 29 ) return false; break; }
		case 4: case 6: case 9: case 11: { if(parseInt(data[0]) > 30) return false; break;}
		default: { if(parseInt(data[0]) > 31) return false;}
	}
	return true;
}

function digitos(digit){
	digit.keyCode = ((digit.keyCode < 48 && digit.keyCode != 13) || (digit.keyCode > 57))?0:digit.keyCode;
}

function digitosSemEnter(digit){
	digit.keyCode = ((digit.keyCode < 48) || (digit.keyCode > 57))?0:digit.keyCode;
}

function semEnter(digit){
	digit.keyCode = (digit.keyCode==13 )?0:digit.keyCode;
}

function submeteEstagiario(acao,frm,pagina){
	frm.action = pagina;
	if (acao==0){
		frm.target = '_parent';
	}else if (acao==1){
		frm.onsubmit = '';
		frm.target = '_blank';
	}
}

	function validarCPF(StrCPF){
		
		StrCPF = StrCPF.replace( ".", "" );
		StrCPF = StrCPF.replace( ".", "" );
		StrCPF = StrCPF.replace( "-", "" );
		
		var sStr = StrCPF.slice(0,1)
		var indStr = 1
		var trocou = false;
		
		while (indStr < StrCPF.length){
		if(sStr != StrCPF.substr(indStr,1)){
		trocou = true;
		}
		indStr++;
		}
		
		if (!trocou){
		return false
		}
		
		x = 0;
		soma = 0;
		dig1 = 0;
		dig2 = 0;
		texto = "";
		StrCPF1="";
		len = StrCPF.length;
		x = len -1;
		
		for (var i=0; i <= len - 3; i++){
			y = StrCPF.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 ;
		StrCPF1 = StrCPF.substring(0,len - 2) + dig1 ;
		x = 11; soma=0;
		
		for (var i=0; i <= len - 2; i++){
			soma = soma + (StrCPF1.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) == StrCPF.substring(len,len-2)){
			return true;
		} else {
			return false;
		}
	}
	
	function isDate(Data){
  var dma = -1;
  var data = Array(3);
  var ch = Data.charAt(0);
  for(i=0; i < Data.length && (( ch >= '0' && ch <= '9' ) || ( ch == '/' && i != 0 ) ); ){
    data[++dma] = '';
    if(ch!='/' && i != 0) return false;
    if(i != 0 ) ch = Data.charAt(++i);
    if(ch=='0') ch = Data.charAt(++i);
    while( ch >= '0' && ch <= '9' ){
      data[dma] += ch;
      ch = Data.charAt(++i);
    }
  }
  if(ch!='') return false;
  if(data[0] == '' || isNaN(data[0]) || parseInt(data[0]) < 1) return false;
  if(data[1] == '' || isNaN(data[1]) || parseInt(data[1]) < 1 || parseInt(data[1]) > 12) return false;
  if(data[2] == '' || isNaN(data[2]) || ((parseInt(data[2]) < 0 || parseInt(data[2]) > 99 ) && (parseInt(data[2]) < 1900 || parseInt(data[2]) > 9999))) return false;
  if(data[2] < 50) data[2] = parseInt(data[2]) + 2000;
  else if(data[2] < 100) data[2] = parseInt(data[2]) + 1900;
  switch(parseInt(data[1])){
    case 2: { if(((parseInt(data[2])%4!=0 || (parseInt(data[2])%100==0 && parseInt(data[2])%400!=0)) && parseInt(data[0]) > 28) || parseInt(data[0]) > 29 ) return false; break; }
    case 4: case 6: case 9: case 11: { if(parseInt(data[0]) > 30) return false; break;}
    default: { if(parseInt(data[0]) > 31) return false;}
  }
  return true;
}
