// JavaScript Document
//detector del navegador
var BrowserDetect = {
	init: function () {
		this.browser = this.searchString(this.dataBrowser) || "An unknown browser";
		this.version = this.searchVersion(navigator.userAgent)
			|| this.searchVersion(navigator.appVersion)
			|| "an unknown version";
		this.OS = this.searchString(this.dataOS) || "an unknown OS";
	},
	searchString: function (data) {
		for (var i=0;i<data.length;i++)	{
			var dataString = data[i].string;
			var dataProp = data[i].prop;
			this.versionSearchString = data[i].versionSearch || data[i].identity;
			if (dataString) {
				if (dataString.indexOf(data[i].subString) != -1)
					return data[i].identity;
			}
			else if (dataProp)
				return data[i].identity;
		}
	},
	searchVersion: function (dataString) {
		var index = dataString.indexOf(this.versionSearchString);
		if (index == -1) return;
		return parseFloat(dataString.substring(index+this.versionSearchString.length+1));
	},
	dataBrowser: [
		{ 	string: navigator.userAgent,
			subString: "OmniWeb",
			versionSearch: "OmniWeb/",
			identity: "OmniWeb"
		},
		{
			string: navigator.vendor,
			subString: "Apple",
			identity: "Safari"
		},
		{
			prop: window.opera,
			identity: "Opera"
		},
		{
			string: navigator.vendor,
			subString: "iCab",
			identity: "iCab"
		},
		{
			string: navigator.vendor,
			subString: "KDE",
			identity: "Konqueror"
		},
		{
			string: navigator.userAgent,
			subString: "Firefox",
			identity: "2"
		},
		{
			string: navigator.vendor,
			subString: "Camino",
			identity: "Camino"
		},
		{		// for newer Netscapes (6+)
			string: navigator.userAgent,
			subString: "Netscape",
			identity: "Netscape"
		},
		{
			string: navigator.userAgent,
			subString: "MSIE",
			identity: "1",
			versionSearch: "MSIE"
		},
		{
			string: navigator.userAgent,
			subString: "Gecko",
			identity: "3",
			versionSearch: "rv"
		},
		{ 		// for older Netscapes (4-)
			string: navigator.userAgent,
			subString: "Mozilla",
			identity: "Netscape",
			versionSearch: "Mozilla"
		}
	],
	dataOS : [
		{
			string: navigator.platform,
			subString: "Win",
			identity: "Windows"
		},
		{
			string: navigator.platform,
			subString: "Mac",
			identity: "Mac"
		},
		{
			string: navigator.platform,
			subString: "Linux",
			identity: "Linux"
		}
	]

};
BrowserDetect.init();
//fin deteccion


//muestro el navegador
function verinav(){
	
var navegador = false;

if (BrowserDetect.browser == 1){ navegador = true;}
 
if (BrowserDetect.browser == 2){ navegador = true;}

if (BrowserDetect.browser == 3){ navegador = true;}

if(navegador == true) {
	//alert("navegador correcto");
	}
else {
	
			var to=document.getElementById('finalizado');
					to.innerHTML="<br><br><img src='imagenes/loading_blue.gif' align='absmiddle'>";
					// Instanciamos el objecto XMLHttpRequest
					ajax = ajaxobj();
					// Abrimos la conexion al script
					ajax.open("POST", "funciones.php?operador=14", true);
					// Indicamos que funcion vigila el cambio de estado
					ajax.onreadystatechange=function() {
						if (ajax.readyState == 4) {
							to.innerHTML=ajax.responseText;
							
						}
					}
					// Enviamos algo para que funcione el proceso
					ajax.send(null);
		}
}

function ajaxobj() 
{
	try 
	{
		_ajaxobj = new ActiveXObject("Msxml2.XMLHTTP");
	} 
	catch (e) 
	{
		try 
		{
			_ajaxobj = new ActiveXObject("Microsoft.XMLHTTP");
		} 
		catch (E) 
		{
			_ajaxobj = false;
		}
	}
	
	if (!_ajaxobj && typeof XMLHttpRequest!='undefined') 
	{
		_ajaxobj = new XMLHttpRequest();
	}
	
	return _ajaxobj;
}

function consulta_usu (Form, op) {
	

	var cedula = "";
	var clave = "";
	var respuesta = "";
		
	if (op == 6) {
		cedula = document.getElementById('cedula').value;
		clave = document.getElementById('clave').value;
	}
	if (op == 1) {
		cedula = Form.cedula.value;
	}
	if (op == 4) {
		cedula = Form.cedula.value;
		respuesta = Form.respuesta.value;
	}
	if (op == 15) {
		cedula = Form.cedula.value;
		respuesta = Form.respuesta.value;
	}
	
	var foco = "";
	var hay = false;
	
	if (op == 6){
	
			if (document.getElementById('cedula').value =='')
			{
				
				document.getElementById('alert_cedula').style.display = "";
				if  (hay == false){hay = true; foco = 'cedula';}
			}
			if (document.getElementById('clave').value =='')
			{
				
				document.getElementById('alert_clave').style.display = "";
				if  (hay == false){hay = true; foco = 'clave';}
			}
	}
	
	if (op == 1){
	
			if (Form.cedula.value =='')
			{
				document.getElementById('alert_cedula').style.display = "";
				if  (hay == false){hay = true; foco = 'cedula';}
			}
	}
	
	if (hay == true)
	{
		document.getElementById(foco).focus();
		return false;
	}
	
	else {
		
			if (op ==6){ 
			var to=document.getElementById("espere");
			}
			if (op ==1){ 
			var to=document.getElementById("olvido");
			}
			if (op ==4){ 
			var to=document.getElementById("pregunta");
			}
			if (op ==15){ 
			var to=document.getElementById("pregunta_act");
			}
			
			to.innerHTML="<br><br><img src='imagenes/loading_blue.gif' align='absmiddle'>";
			// Instanciamos el objecto XMLHttpRequest
			ajax = ajaxobj();
			// Abrimos la conexion al script
			if (op ==6){
				ajax.open("POST", "procesos.php?operador="+op+"&cedula="+cedula+"&clave="+clave, true);
				}
			if (op ==1){
				ajax.open("POST", "procesos.php?operador="+op+"&cedula="+cedula, true);
				}
			if (op ==4){ 
				ajax.open("POST", "procesos.php?operador="+op+"&cedula="+cedula+"&respuesta="+respuesta, true);
				}
			if (op ==15){ 
			ajax.open("POST", "procesos.php?operador="+op+"&cedula="+cedula+"&respuesta="+respuesta, true);
			}
			//ajax.open("POST", "procesos.php?operador="+op+"&cedula="+cedula+"&clave="+clave+"&respuesta="+respuesta, true);
			// Indicamos que funcion vigila el cambio de estado
			ajax.onreadystatechange=function() {
				if (ajax.readyState == 4) {
					to.innerHTML=ajax.responseText;
					/*if (ajax.responseText=="")
						location.href="index.php?olvido=1";*/
				}
			}
			// Enviamos algo para que funcione el proceso
			ajax.send(null);
			
				
		}
	}

function salir()
{
	location.href="salir.php";
}


function validclave(Form)
{
	var longitud = Form.clave.value.length;
	
	
	var foco = "";
	var hay = false;
	
	if (trim(Form.clave.value)=='')
	{
		document.getElementById('alert_clave').style.display = "";
		if  (hay == false){hay = true; foco = 'clave';}
	}
	if (trim(Form.confirmar.value)=='')
	{
		document.getElementById('alert_confirmar').style.display = "";
		if  (hay == false){hay = true; foco = 'confirmar';}
	}
	if (trim(Form.clave.value)!= trim(Form.confirmar.value))
	{
		
		alert ("No coindiden la confirmacion de la clave, por favor rectifique");
		document.getElementById('alert_clave').style.display = "";
		document.getElementById('alert_confirmar').style.display = "";
		document.getElementById('clave').value = "";
		document.getElementById('confirmar').value = "";
		if  (hay == false){hay = true; foco = 'clave';}
	}
	if (trim(longitud)<6)
	{	
		alert ("La clave debe ser minimo de 6 caracteres");
		document.getElementById('alert_clave').style.display = "";
		document.getElementById('alert_confirmar').style.display = "";
		document.getElementById('clave').value = "";
		document.getElementById('confirmar').value = "";
		if  (hay == false){hay = true; foco = 'clave';}
	}
	

	if (hay == true)
	{
		document.getElementById('alertgen').style.display = "";
		document.getElementById(foco).focus();
		return false;
	}
	
	
	else {
		
			var cedula = Form.cedula.value;	
			var clave = Form.clave.value;
			var activacion = Form.activacion.value;
		
				var to=document.getElementById('olvido');
					to.innerHTML="<br><br><img src='imagenes/loading_blue.gif' align='absmiddle'>";
					// Instanciamos el objecto XMLHttpRequest
					ajax = ajaxobj();
					// Abrimos la conexion al script
					ajax.open("POST", "procesos.php?operador=5&clave="+clave+"&cedula="+cedula+"&activacion="+activacion, true);
					// Indicamos que funcion vigila el cambio de estado
					ajax.onreadystatechange=function() {
						if (ajax.readyState == 4) {
							to.innerHTML=ajax.responseText;
							
						}
					}
					// Enviamos algo para que funcione el proceso
					ajax.send(null);
		}
			
	
	
	}


//funcion trim en javascript
function TrimRight( str ) {
var resultStr = "";
var i = 0;
// Return immediately if an invalid value was passed in
if (str+"" == "undefined" || str == null) 
return null;
// Make sure the argument is a string
str += "";

if (str.length == 0) 
resultStr = "";
else {
// Loop through string starting at the end as long as there
// are spaces.
i = str.length - 1;
while ((i >= 0) && (str.charAt(i) == " "))
i--;

// When the loop is done, we're sitting at the last non-space char,
// so return that char plus all previous chars of the string.
resultStr = str.substring(0, i + 1);
}

return resultStr; 
}

function TrimLeft( str ) {
	var resultStr = "";
	var i = len = 0;

	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str == null)	
		return null;

	// Make sure the argument is a string
	str += "";

	if (str.length == 0) 
		resultStr = "";
	else {	
  		// Loop through string starting at the beginning as long as there
  		// are spaces.
//	  	len = str.length - 1;
		len = str.length;
		
  		while ((i <= len) && (str.charAt(i) == " "))
			i++;

   	// When the loop is done, we're sitting at the first non-space char,
 		// so return that char plus the remaining chars of the string.
  		resultStr = str.substring(i, len);
  	}

  	return resultStr;
}

function trim( str ) {
var resultStr = "";

resultStr = TrimLeft(str);
resultStr = TrimRight(resultStr);

return resultStr;
}
//fin de funcion trim

function primera_vez(Form){

	var cedula = document.getElementById('cedula').value;
	var clave = document.getElementById('clave').value;
	
	 
	location.href="index.php?primera_vez=1";
	
	
	} 
	
function finalizar(){
	
		location.href="index.php";
}

function olvido(){

		location.href="index.php?olvido=1";

}
function denuncia(cedula){
		location.href="index.php?denuncia=1&cedula="+cedula;

}
	
function solo_numero(evt){
// NOTE: Backspace = 8, Enter = 13, '0' = 48, '9' = 57
var nav4 = window.Event ? true : false;
var key = nav4 ? evt.which : evt.keyCode;
return (key <= 13 || (key >= 48 && key <= 57));
}

function validreg(Form){
	
	document.getElementById('alert_cedula').style.display = "none";
	document.getElementById('alert_clave').style.display = "none";
	document.getElementById('alert_confirmar').style.display = "none";
	document.getElementById('alert_fecha_nac').style.display = "none";
	document.getElementById('alert_correo').style.display = "none";
	document.getElementById('alert_cbosecreta').style.display = "none";
	document.getElementById('alert_respuesta').style.display = "none";
	document.getElementById('alert_respcapchat').style.display = "none";
	
	var cedula = Form.cedula.value;
	var clave = Form.clave.value;
	var confirmar = Form.confirmar.value;
	var fecha_nac = Form.fecha_nac.value;
	var correo = Form.correo.value;
	var cbosecreta = Form.cbosecreta.value;
	var respuesta = Form.respuesta.value;
	var captcha_code = Form.captcha_code.value;
	
	
	var  long_clave = clave.length;
	var  long_confirmar = clave.length;
	var  long_fecha_nac = fecha_nac.length;
	
	var foco = "";
	var hay = false;

	if (trim(Form.cedula.value)=='')
	{
		document.getElementById('alert_cedula').style.display = "";
		if  (hay == false){hay = true; foco = 'cedula';}
	}
	if (trim(Form.clave.value)=='')
	{
		document.getElementById('alert_clave').style.display = "";
		if  (hay == false){hay = true; foco = 'clave';}
	}
	if (trim(Form.confirmar.value)=='')
	{
		document.getElementById('alert_confirmar').style.display = "";
		if  (hay == false){hay = true; foco = 'confirmar';}
	}
	if (trim(Form.clave.value)!= trim(Form.confirmar.value))
	{
		
		alert ("No coindiden la confirmacion de la clave, por favor rectifique");
		document.getElementById('alert_clave').style.display = "";
		document.getElementById('alert_confirmar').style.display = "";
		document.getElementById('clave').value = "";
		document.getElementById('confirmar').value = "";
		if  (hay == false){hay = true; foco = 'clave';}
	}
	if (trim(Form.fecha_nac.value)=='')
	{
		document.getElementById('alert_fecha_nac').style.display = "";
		if  (hay == false){hay = true; foco = 'fecha_nac';}
	}
    if (trim(Form.correo.value)=='')
	{
		document.getElementById('alert_correo').style.display = "";
		if  (hay == false){hay = true; foco = 'correo';}
	}
	if (Form.cbosecreta.options[Form.cbosecreta.selectedIndex].value=="0")
	{
		document.getElementById('alert_cbosecreta').style.display = "";
		if  (hay == false){hay = true; foco = 'cbosecreta';}
	}
	if (trim(Form.respuesta.value)=='')
	{
		document.getElementById('alert_respuesta').style.display = "";
		if  (hay == false){hay = true; foco = 'respuesta';}
	}
	if (trim(Form.captcha_code.value)=='')
	{
		document.getElementById('alert_respcapchat').style.display = "";
		if  (hay == false){hay = true; foco = 'captcha_code';}
	}
	if (long_clave < 6){
		if (long_clave > 0) {alert("La clave es muy corta");}
		document.getElementById('clave').value = "";
		document.getElementById('confirmar').value = "";
		document.getElementById('alert_clave').style.display = "";
		document.getElementById('alert_confirmar').style.display = "";
		if  (hay == false){hay = true; foco = 'clave';}
	}
	if (long_fecha_nac < 10){
		if (long_fecha_nac > 0) {alert("La fecha es incorrecta");}
		document.getElementById('fecha_nac').value = "";
		document.getElementById('alert_fecha_nac').style.display = "";
		if  (hay == false){hay = true; foco = 'clave';}
	}
	
	if (hay == true)
	{	
		document.getElementById('alertgen').style.display = "";
		document.getElementById(foco).focus();
		return false;
	}
	
	
	else
		{
			
			var to=document.getElementById("registro");
			
				to.innerHTML="<br><br><img src='imagenes/loading_blue.gif' align='absmiddle'>";
				// Instanciamos el objecto XMLHttpRequest
				ajax = ajaxobj();
				// Abrimos la conexion al script
						
				ajax.open("POST", "procesos.php?operador=2&cedula="+cedula+"&clave="+clave+"&confirmar="+confirmar+"&fecha_nac="+fecha_nac+"&correo="+correo+"&cbosecreta="+cbosecreta+"&respuesta="+respuesta+'&captcha_code='+captcha_code, true);
				// Indicamos que funcion vigila el cambio de estado
				ajax.onreadystatechange=function() {
					if (ajax.readyState == 4) {
						to.innerHTML=ajax.responseText;
						/*if (ajax.responseText=="")
							location.href="index.php?olvido=1";*/
					}
				}
				// Enviamos algo para que funcione el proceso
				ajax.send(null);
	
		}
	
}

function valida_denuncia(Form){
	
	document.getElementById('alert_cedula').style.display = "none";
	document.getElementById('alert_confirmar').style.display = "none";
	document.getElementById('alert_correo').style.display = "none";
	document.getElementById('alert_cbosecreta').style.display = "none";
	document.getElementById('alert_respuesta').style.display = "none";
	document.getElementById('alert_respcapchat').style.display = "none";
	
	var cedula = Form.cedula.value;
	var confirmar = Form.confirmar.value;
	var correo = Form.correo.value;
	var cbosecreta = Form.cbosecreta.value;
	var respuesta = Form.respuesta.value;
	var captcha_code = Form.captcha_code.value;
	
		
	var foco = "";
	var hay = false;

	if (trim(Form.cedula.value)=='')
	{
		document.getElementById('alert_cedula').style.display = "";
		if  (hay == false){hay = true; foco = 'cedula';}
	}
	if (trim(Form.confirmar.value)=='')
	{
		document.getElementById('alert_confirmar').style.display = "";
		if  (hay == false){hay = true; foco = 'confirmar';}
	}
	if (trim(Form.cedula.value)!= trim(Form.confirmar.value))
	{
		alert ("No coindiden la confirmacion de la cedula, por favor rectifique");
		document.getElementById('alert_confirmar').style.display = "";
		document.getElementById('confirmar').value = "";
		if  (hay == false){hay = true; foco = 'confirmar';}
	}
    if (trim(Form.correo.value)=='')
	{
		document.getElementById('alert_correo').style.display = "";
		if  (hay == false){hay = true; foco = 'correo';}
	}
	if (Form.cbosecreta.options[Form.cbosecreta.selectedIndex].value=="0")
	{
		document.getElementById('alert_cbosecreta').style.display = "";
		if  (hay == false){hay = true; foco = 'cbosecreta';}
	}
	if (trim(Form.respuesta.value)=='')
	{
		document.getElementById('alert_respuesta').style.display = "";
		if  (hay == false){hay = true; foco = 'respuesta';}
	}
	if (trim(Form.captcha_code.value)=='')
	{
		document.getElementById('alert_respcapchat').style.display = "";
		if  (hay == false){hay = true; foco = 'captcha_code';}
	}
	
	if (hay == true)
	{	
		document.getElementById('alertgen').style.display = "";
		document.getElementById(foco).focus();
		return false;
	}
	
	
	else
		{
			
			var to=document.getElementById("registro");
			
				to.innerHTML="<br><br><img src='imagenes/loading_blue.gif' align='absmiddle'>";
				// Instanciamos el objecto XMLHttpRequest
				ajax = ajaxobj();
				// Abrimos la conexion al script
						
				ajax.open("POST", "procesos.php?operador=9&cedula="+cedula+"&confirmar="+confirmar+"&correo="+correo+"&cbosecreta="+cbosecreta+"&respuesta="+respuesta+'&captcha_code='+captcha_code, true);
				// Indicamos que funcion vigila el cambio de estado
				ajax.onreadystatechange=function() {
					if (ajax.readyState == 4) {
						to.innerHTML=ajax.responseText;
						/*if (ajax.responseText=="")
							location.href="index.php?olvido=1";*/
					}
				}
				// Enviamos algo para que funcione el proceso
				ajax.send(null);
	
		}
	
}

function exite_usu(Form, op, usu)
{
	var cedula = trim(document.getElementById("cedula").value);
	
	if (cedula != ""){
		
	var to=document.getElementById("check_cedula");
			
				to.innerHTML="<img src='imagenes/loading.gif' align='absmiddle'>";
				// Instanciamos el objecto XMLHttpRequest
				ajax = ajaxobj();
				// Abrimos la conexion al script
				ajax.open("POST", "funciones.php?operador="+op+"&cedula="+cedula, true);
				// Indicamos que funcion vigila el cambio de estado
				ajax.onreadystatechange=function() {
					if (ajax.readyState == 4) {
						to.innerHTML=ajax.responseText;
												
					} 
					
				}
				// Enviamos algo para que funcione el proceso
				ajax.send(null);
				
				}
	else{
				var to=document.getElementById("check_cedula");
			
				to.innerHTML="<img src='imagenes/loading.gif' align='absmiddle'>";
				// Instanciamos el objecto XMLHttpRequest
				ajax = ajaxobj();
				// Abrimos la conexion al script
				ajax.open("POST", "funciones.php?operador="+op+"&cedula=0", true);
				// Indicamos que funcion vigila el cambio de estado
				ajax.onreadystatechange=function() {
					if (ajax.readyState == 4) {
						to.innerHTML=ajax.responseText;
												
					} 
					
				}
				// Enviamos algo para que funcione el proceso
				ajax.send(null);
				
				
		}
}
 

function seguro(frase)
{
	return confirm("ż" + frase + "\n\nSi (Aceptar) / No (Cancelar)");
}
	
function validacorreo(texto, op){ 
	
	if (texto != "")
	{
    var mailres = true;             
    var cadena = "abcdefghijklmnñopqrstuvwxyzABCDEFGHIJKLMNÑOPQRSTUVWXYZ1234567890@._-"; 
     
    var arroba = texto.indexOf("@",0); 
    if ((texto.lastIndexOf("@")) != arroba) arroba = -1; 
     
    var punto = texto.lastIndexOf("."); 
                 
     for (var contador = 0 ; contador < texto.length ; contador++){ 
        if (cadena.indexOf(texto.substr(contador, 1),0) == -1){ 
            mailres = false; 
            break; 
     } 
    } 
	
    if ((arroba > 1) && (arroba + 1 < punto) && (punto + 2 < (texto.length)) && (mailres == true) && (texto.indexOf("..",0) == -1)) 
     mailres = true; 
    else 
     mailres = false; 
	 
	 if (mailres == false)
	    
		alert("Formato de correo no valido");
    }
	
		if ((mailres == true) && (op == 1)){ 
			var to=document.getElementById("check_correo");
				to.innerHTML="<img src='imagenes/loading.gif' align='absmiddle'>";
				// Instanciamos el objecto XMLHttpRequest
				ajax = ajaxobj();
				// Abrimos la conexion al script
				ajax.open("POST", "funciones.php?operador=7&correo="+texto, true);
				// Indicamos que funcion vigila el cambio de estado
				ajax.onreadystatechange=function() {
					if (ajax.readyState == 4) {
						to.innerHTML=ajax.responseText;
												
					} 
					
				}
				// Enviamos algo para que funcione el proceso
				ajax.send(null);
				
				}
			//mailres = false;
			
			
			
		if ((texto == "") && (op == 1))
			{
				var to=document.getElementById("check_correo");
				to.innerHTML="<img src='imagenes/loading.gif' align='absmiddle'>";
				// Instanciamos el objecto XMLHttpRequest
				ajax = ajaxobj();
				// Abrimos la conexion al script
				ajax.open("POST", "funciones.php?operador=7&correo="+texto, true);
				// Indicamos que funcion vigila el cambio de estado
				ajax.onreadystatechange=function() {
					if (ajax.readyState == 4) {
						to.innerHTML=ajax.responseText;
												
					} 
					
				}
				// Enviamos algo para que funcione el proceso
				ajax.send(null);
			}
		
		
    return mailres; 
}

//validacion de fechas
function IsNumeric(valor) 
{ 
var log=valor.length; var sw="S"; 
for (x=0; x<log; x++) 
{ v1=valor.substr(x,1); 
v2 = parseInt(v1); 
//Compruebo si es un valor numerico 
if (isNaN(v2)) { sw= "N";} 
} 
if (sw=="S") {return true;} else {return false; } 
} 

var primerslap=false; 
var segundoslap=false; 
function formateafecha(fecha) 
{ 
var long = fecha.length; 
var dia; 
var mes; 
var ano; 

if ((long>=2) && (primerslap==false)) { dia=fecha.substr(0,2); 
if ((IsNumeric(dia)==true) && (dia<=31) && (dia!="00")) { fecha=fecha.substr(0,2)+"-"+fecha.substr(3,7); primerslap=true; } 
else { fecha=""; primerslap=false;} 
} 
else 
{ dia=fecha.substr(0,1); 
if (IsNumeric(dia)==false) 
{fecha="";} 
if ((long<=2) && (primerslap=true)) {fecha=fecha.substr(0,1); primerslap=false; } 
} 
if ((long>=5) && (segundoslap==false)) 
{ mes=fecha.substr(3,2); 
if ((IsNumeric(mes)==true) &&(mes<=12) && (mes!="00")) { fecha=fecha.substr(0,5)+"-"+fecha.substr(6,4); segundoslap=true; } 
else { fecha=fecha.substr(0,3);; segundoslap=false;} 
} 
else { if ((long<=5) && (segundoslap=true)) { fecha=fecha.substr(0,4); segundoslap=false; } } 
if (long>=7) 
{ ano=fecha.substr(6,4); 
if (IsNumeric(ano)==false) { fecha=fecha.substr(0,6); } 
else { if (long==10){ if ((ano==0) || (ano<1900) || (ano>2100)) { fecha=fecha.substr(0,6); } } } 
} 

if (long>=10) 
{ 
fecha=fecha.substr(0,10); 
dia=fecha.substr(0,2); 
mes=fecha.substr(3,2); 
ano=fecha.substr(6,4); 
// Ano no viciesto y es febrero y el dia es mayor a 28 
if ( (ano%4 != 0) && (mes ==02) && (dia > 28) ) { fecha=fecha.substr(0,2)+"-";} 
} 
return (fecha); 
} 