///////////////////// VALIDACIONES ARIEL MONTANO
function separa_fecha(fecha)
{ 

	var array_fecha = fecha.split("-");
	var ano, mes, dia, fe;
    ano = array_fecha[0]; 
	mes = array_fecha[1]; 
	dia = array_fecha[2]; 
	if(mes=="1" || mes=="01" )
		mes="Enero";
	else if(mes=="2" || mes=="02")
		mes="Febrero";
	else if(mes=="3" || mes=="03")
		mes="Marzo";
	else if(mes=="4" || mes=="04")
		mes="Abril";
	else if(mes=="5" || mes=="05")
		mes="Mayo";
	else if(mes=="6" || mes=="06")
		mes="Junio";
	else if(mes=="7" || mes=="07")
		mes="Julio";
	else if(mes=="8" || mes=="08")
		mes="Agosto";
	else if(mes=="9" || mes=="09")
		mes="Septiembre";
	else if(mes=="10" || mes=="10")
		mes="Octubre";
	else if(mes=="11" || mes=="11")
		mes="Noviembre";
	else if(mes=="12" || mes=="12")
		mes="Diciembre";
	fe= dia + '. ' + mes + '. ' + ano;
	document.write(fe);
}
function contar(name)
{
	n = document.getElementById(name).value.length;
	if (n < 300) {
		document.getElementById(name).rows = 6;
	}
	else if (n > 301 && n < 600) {
		document.getElementById(name).rows = 12;
	}
	else if (n > 601 && n < 900) {
		document.getElementById(name).rows = 18;
	}
	else if (n > 901 && n < 1200) {
		document.getElementById(name).rows = 24;
	}
	else if (n > 1201 && n < 1500) {
		document.getElementById(name).rows = 30;
	}
	else if (n > 1501 && n < 1800) {
		document.getElementById(name).rows = 36;
	}
}
function Abrir_Ventana(el_url) 
{
	var especificaciones="top=100, left=350, toolbar=no,location=yes, status=no,menubar=no,scrollbars=no, resizable=no, width=550,height=400"
	var titulo="ValidacionCertificados"
	window.open(el_url,titulo,especificaciones); 
}
function Descarga_Ventana(el_url) 
{
	var especificaciones="top=1500, left=5000, toolbar=no,location=yes, status=no,menubar=no,scrollbars=no, resizable=no, width=550,height=400"
	var titulo="ValidacionCertificados"
	window.open(el_url,titulo,especificaciones); 
}

function imprimir(){
	if (window.print){
	window.print();
	}
	else{
	alert("Disculpe, su navegador no soporta esta opcion.");
	}
}
function Abrir_Datos(el_url2) 
{
	var especificaciones2="top=100, left=350, toolbar=no,location=yes, status=no,menubar=no,scrollbars=no, resizable=no, width=550,height=680";
	var titulo2="DatosCertificado";
	window.open(el_url2,titulo2,especificaciones2); 
}

function Abrir_visualiza(el_url) 
{
	var especificaciones="top=100, left=200, toolbar=no,location=yes, status=no,menubar=no,scrollbars=yes, resizable=yes, width=750,height=700"
	var titulo="VisualizacionCertificados"
	window.open(el_url,titulo,especificaciones); 
}
function ordena_fecha(f)
{
	alert('fecha ordenada :'+ f);
}
function fecha_actual(){
var mydate=new Date()
var year=mydate.getYear()
if (year < 1000)
year+=1900
var day=mydate.getDay()
var month=mydate.getMonth()
var daym=mydate.getDate()
if (daym<10)
daym="0"+daym
var dayarray=new Array("Domingo","Lunes","Martes","Miercoles","Jueves","Viernes","Sabado")
var montharray=new Array("Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre")
document.write(dayarray[day]+" "+daym+" de "+montharray[month]+" de "+year)
}

function displayItem(key) //funcion para obtener el valor de un QueryString, false si no
{
	if(queryString(key)=='false')
		return false;
	else
		return queryString(key);
}
function PageQueryURL(q)  //subfunciones de displayItem()
{
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q)
	{
		for(var i=0; i < this.q.split("&").length; i++)
		{
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s)
	{
		for(var j=0; j < this.keyValuePairs.length; j++)
		{
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function()
	{
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++)
		{
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
	return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }
}
function queryString(key) //subfunciones de displayItem()
{
	url=document.getElementById('timbre').value;
	//alert(url+'key='+key);
	var page = new PageQueryURL(url);
	//var page = new PageQueryURL(window.location.search);
	//var page = url;
	//alert(page)
	return unescape(page.getValue(key));
	//return true
}
function Trim(TRIM_VALUE) //funcion para eliminar espacios tanto de izq como der del valor
{
	if(TRIM_VALUE.length < 1)
	{
		return"";
	}
	TRIM_VALUE = RTrim(TRIM_VALUE);
	TRIM_VALUE = LTrim(TRIM_VALUE);
	if(TRIM_VALUE=="")
	{
	return "";
	}
	else
	{
	return TRIM_VALUE;
	}
} //End Function

function RTrim(VALUE) //elimina espacios de la derecha del valor
{
	var w_space = String.fromCharCode(32);
	var v_length = VALUE.length;
	var strTemp = "";
	if(v_length < 0){
	return"";
	}
	var iTemp = v_length -1;

	while(iTemp > -1){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
	strTemp = VALUE.substring(0,iTemp +1);
	break;
	}
	iTemp = iTemp-1;

	} //End While
return strTemp;

} //End Function

function LTrim(VALUE) //elimina espacios de la izquierdadel valor
{
	var w_space = String.fromCharCode(32);
	if(v_length < 1){
	return"";
	}
	var v_length = VALUE.length;
	var strTemp = "";

	var iTemp = 0;

	while(iTemp < v_length){
	if(VALUE.charAt(iTemp) == w_space){
	}
	else{
	strTemp = VALUE.substring(iTemp,v_length);
	break;
	}
	iTemp = iTemp + 1;
	} //End While
	return strTemp;
} //End Function



/////////////////////////FIN VALIDACIONES ARIEL MONTANO
