
/**************************************************************
M?scara de entrada. Script creado por Tunait! (21/12/2004)
Si quieres usar este script en tu sitio eres libre de hacerlo con la condici?n de que permanezcan intactas estas l?neas, osea, los cr?ditos.
No autorizo a distribu?r el c?digo en sitios de script sin previa autorizaci?n
Si quieres distribu?rlo, por favor, contacta conmigo.
Ver condiciones de uso en http://javascript.tunait.com/
tunait@yahoo.com
****************************************************************/
var patron = new Array(2,2,4)
var patron2 = new Array(1,3,3,3,3)
var patronRaya = new Array(3,6)
function mascara(d,sep,pat,nums){
if(d.valant != d.value){
	val = d.value
	largo = val.length
	val = val.split(sep)
	val2 = ''
	for(r=0;r<val.length;r++){
		val2 += val[r]
	}
	if(nums){
		for(z=0;z<val2.length;z++){
			if(isNaN(val2.charAt(z))){
				letra = new RegExp(val2.charAt(z),"g")
				val2 = val2.replace(letra,"")
			}
		}
	}
	val = ''
	val3 = new Array()
	for(s=0; s<pat.length; s++){
		val3[s] = val2.substring(0,pat[s])
		val2 = val2.substr(pat[s])
	}
	for(q=0;q<val3.length; q++){
		if(q ==0){
			val = val3[q]
		}
		else{
			if(val3[q] != ""){
				val += sep + val3[q]
				}
		}
	}
	d.value = val
	d.valant = val
	}
}


function textCounter(field, countfield, maxlimit) {
if (field.value.length > maxlimit)
field.value = field.value.substring(0, maxlimit);
else 
countfield = maxlimit - field.value.length;
}


function convertirMayuscula(texto)
 {
 texto.value=texto.value.toUpperCase();
 }
 
/* 
autor guillermo mendoza marcos
comparar fechas que no sea mayor a la actual 
*/ 
function compararFechas(fechaIngresada,fechaActual) {
	
		Data1_arr = fechaIngresada.split('/')
		fechaIngresada = Data1_arr[1] +'/'+ Data1_arr[0] +'/'+ Data1_arr[2] 
		var auxfecIngresada=Date.parse(fechaIngresada);
		var auxfecActual=Date.parse(fechaActual);
		if(auxfecIngresada>=auxfecActual) 
		   return true;
		else return false;
}
 

/*
autor : Guillermo mendoza marcos
valida numero decimal
fieldName: ejemplo. document.form.formulario
valor: ejemplo. document.form.formulario.value
cantEnt: ejemplo. 9 representa la cantidad de enteros
cantDec: ejemplo. 4 representa la cantidad de decimales
*/




function validarDecimal(fieldName,valor,cantEnt,cantDec) {

decallowed = parseInt(cantDec);  // decimales permitidos

	if (isNaN(valor) || valor == "") {
		alert("No es un numero valido.");
		fieldName.select();
		fieldName.focus();
		return false;
	}else{
		alert(valor.length+"---"+parseInt(cantEnt));
		if(valor.length>=parseInt(cantEnt))
		{
			alert ("Porfavor ingrese solo "+cantEnt+" numeros enteros ,gracias");
			fieldName.select();
			fieldName.focus();
			return false;
		}

	if (valor.indexOf('.') == -1) valor += ".";
	dectext = valor.substring(valor.indexOf('.')+1, valor.length);
		if (dectext.length > decallowed)
		{
			alert ("Por favor, entra un n?mero con " + decallowed + " n?meros decimales.");
			fieldName.select();
			fieldName.focus();
			return false;
    	}
		return true;
   	}
}





function setFocusFirstTextInput(form){
	for (i=0;i<form.length;i++){
		var tempobj=form.elements[i];
		//alert(tempobj+" "+tempobj.name+" "+tempobj.type+" "+tempobj.readonly!='true'+" "+tempobj.readonly!='readonly');
		if ((tempobj.type=="text"&&tempobj.disabled!="true")&&(tempobj.readonly!='true'&&tempobj.readonly!='readonly'))
		{
			tempobj.focus();
			break;
		}
	}
}

/*
autor : Guillermo mendoza marcos
esta funcion permite ingresar solo numeros incluyendo decimales
*/
function escribeNumeroDecimal() {

		if (event.keyCode < 46 || event.keyCode > 57)
			event.returnValue=false;
}

	function numeroPrimaria(){
			if (event.keyCode < 49 || event.keyCode > 54)
			event.returnValue=false;
	}
	
	function numeroSecundaria(){
			if (event.keyCode < 49 || event.keyCode > 53)
			event.returnValue=false;
	}
	
	function digitaSexo(){
			if (event.keyCode ==77)
				event.returnValue=true;
			else if(event.keyCode ==70)
				event.returnValue=true;
			else if(event.keyCode ==102)
				event.returnValue=true;
			else if(event.keyCode ==109)
				event.returnValue=true;
			else event.returnValue=false;
	}
function escribeNumeroDecimalP() {

		if (event.keyCode < 45 || event.keyCode > 57)
			event.returnValue=false;
}

/*
autor : Guillermo mendoza marcos
esta funcion permite ingresar solo numeros
*/
function validarSoloNumeros() {

	if (event.keyCode < 48 || event.keyCode > 57)
		event.returnValue=false;
}



function validarSoloLetras() {
	/*
	if ((event.KeyCode>event.keyCode <65 || (event.keyCode > 90 && event.keyCode < 97 )||event.keyCode >122))
	{
	event.returnValue=false;
	}
	*/
	
		if (event.keyCode == 32 ||(event.keyCode >= 65 && event.keyCode <= 90)||(event.keyCode >= 97 && event.keyCode <= 122))
		event.returnValue=true;
		else event.returnValue=false;
	
}



/*
autor : miguel martinez espichan
valida textfield
textfield: ejemplo. document.form.formulario
mensaje: mesaje para el alert
*/
function validarTexto(textfield,mensaje)
{
	var texto=textfield.value;
	var texto1=texto+'';
	if(trim(texto1)==0)
	{
	alert(mensaje);
	textfield.focus();
	return false;
	}
	else{
	return true;
	}
}

/*
autor : miguel martinez espichan
valida textfield
textfield: ejemplo. document.form.formulario
mensaje: mesaje para el alert
*/
function validarOpcion(select,mensaje,posicion)
{
	var posicionSeleccionada=select.selectedIndex;
	if(posicionSeleccionada==posicion)
	{
	alert(mensaje);
	select.focus();
	return false;
	}
	else{
	return true;
	}
}


//autor : miguel martinez espichan
//valida textfield
//textfield: ejemplo. document.form.formulario
//mensaje: mesaje para el alert

function validarEntero(textfield,mensaje)
{
	var texto=textfield.value;
	var texto1=texto+'';
	if(trim(texto1)==0||!isInteger(texto1))
	{
	alert(mensaje);
	textfield.focus();
	return false;
	}
	else{
	return true;
	}
}


// Acciona un trim sobre la cadena
function trim(strCad) {
	var strCadena = new String(strCad);
	retorno = "";
	retorno2 = "";
	if (strCadena != "") {
		i = strCadena.length;
		while ((i==0) || (strCadena.substring(i-1,i) == " "))
			i--;
		retorno = strCadena.substring(0,i);
		i = 0;
		while ((i==retorno.length) || (strCadena.substring(i,i+1) == " "))
			i++;
		retorno2 = retorno.substring(i,retorno.length);
	}
	if (retorno2 == " ") {
		retorno2 = "";
	}
	return retorno2;
}


function trim(strCad)
{
	return Trim(strCad);
}
// Quita los espacios en blanco

function Trim(strCad)
{
	var strCadena = new String(strCad);
	retorno = "";
	retorno2 = "";
	if (strCadena != "")
	{
		i = strCadena.length;
		while ((i==0) || (strCadena.substring(i-1,i) == " "))
			i--;
		retorno = strCadena.substring(0,i);
		i = 0;
		while ((i==retorno.length) || (strCadena.substring(i,i+1) == " "))
			i++;
		retorno2 = retorno.substring(i,retorno.length);
	}
	if (retorno2 == " ")
	{
		retorno2 = "";
	}
	return retorno2;
}


// Validaci?n de Caracteres
function validarCaracter(strCadena){
	var invalido = "'";

	var size = strCadena.length;
	strCadena = trim(strCadena);
	if (strCadena==""){
		return (true);
	}
	else{
		for (i = 0 ; i < size; i++){
			if (strCadena.substring(i,i+1)==invalido) {
				alert("No debe ingresar caracteres inv?lidos (').");
				return (false);
			}
		}
	 	return (true);
	}
}

// Validaci?n de E-Mails
function validarEmail(strCad){
	var strCadena = new String(strCad);
	strCadena = strCadena.toUpperCase();
	valido = "@";
	valido1 = ".";
	noValido = " ";
	if (strCadena=="") return(true);
	else{
		if (strCadena.indexOf (valido) == -1 )
			return(false);
		else
		{
			if (strCadena.indexOf (valido1) == -1 )
				return(false);
			else
			{
				if (strCadena.indexOf (noValido) != -1 )
					return(false);
			}
		}
		var size = strCadena.length;
		var cont1 = 0;
		var cad= new String(strCad);
		var aux="";
		for(i=0;i< size; i++){
			cad = strCadena.substring(i,i+1);
			if(cad==aux && (cad == valido || cad == valido1)) return(false);
			aux = cad;

			if (cad == valido)
				cont1 = cont1 + 1;
		}
		if(cont1 > 1) return(false);
	}
	return(true);
}
// Valida si es vacio
function validarVacio(valor)
{   return ((valor == null) || (valor.length == 0))
}
// Valida que sea un digito
function validarDigito (valor)
{   return ((valor >= "0") && (valor <= "9"))
}
// Validaci?n de Decimales
function validarDecimales (valor){
	var i;
    var dotAppeared;
    dotAppeared = false;
    if (validarVacio(valor))
       if (validarDecimales.arguments.length == 1) return defaultEmptyOK;
       else return (validarDecimales.arguments[1] == true);

    for (i = 0; i < valor.length; i++)
    {
        var c = valor.charAt(i);
        if( i != 0 ) {
            if ( c == "." ) {
                if( !dotAppeared )
                    dotAppeared = true;
                else
                    return false;
            } else
                if (!validarDigito(c)) return false;
        } else {
            if ( c == "." ) {
                if( !dotAppeared )
                    dotAppeared = true;
                else
                    return false;
            } else
                if (!validarDigito(c) && ((c == "-") || (c != "+"))) return false;
        }
    }
    return true;
}

// Validaci?n de N?meros
/*function validarNumeros(valor) {
	var a = valor.split("");
	for (var i in a) {
		if (!a[i].match(/\d/)) {
		   return false;break;
		}
	}
	return true;
}*/

function validarNumeros(valor){
      //intento convertir a entero.
     //si era un entero no le afecta, si no lo era lo intenta convertir
     valor = parseInt(valor)

      //Compruebo si es un valor num?rico
      if (isNaN(valor)) {
            //entonces (no es numero) devuelvo el valor cadena vacia
            return false
      }else{
            //En caso contrario (Si era un n?mero) devuelvo el valor
            return true;
      }
}



// Validaci?n de Alfanum?ricos
function validarAlfaNumericos(valor) {
	var a = valor.split("");
	for (var i in a) {
		if (!a[i].match(/\w/)) {
		   return false;
		}
	}
	return true;
}

// Validaci?n de Alfanum?ricos con espacios
function validarAlfaNumericosEspacios(valor) {
	var a = valor.split("");
	for (var i in a) {
		if (!a[i].match(/\w/) && a[i]!=" " && a[i]!="?" && a[i]!="?") {
		   return false;
		}
	}
	return true;
}

// Validaci?n de Selecci?n (Checkboxes)
function validarSeleccion(){
	var seleccionado = false;

	for (i=0; i < document.forms[0].length; i++)
		if (document.forms[0].elements[i].checked) {
			seleccionado = true;
			break;
		}

	if (seleccionado)
		return true;
	else
		return false;
}

// Validaci?n de Selecci?n desde barra de botones (Checkboxes)
function validarSeleccionPadre(){
	var seleccionado = false;

	for (i=0; i < parent.datos.document.forms[0].length; i++)
		if (parent.datos.document.forms[0].elements[i].checked) {
			seleccionado = true;
			break;
		}

	if (seleccionado)
		return true;
	else
		return false;
}


// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;


function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}


function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   }
   return this
}

function dosDigitos(strDigito)
{
	/*
	if(parseInt(strDigito)==0)
	{
	alert("Ingrese un periodo correcto , gracias");
	return false;
	}else
	*/
	 if(!(parseInt(strDigito)>0 && parseInt(strDigito)<13))
	{
	alert("Ingrese un periodo correcto, gracias");
	return false;
	}
	return true;
}

function isAno(a)
{	if (a.length != 4 || parseInt(a)==0 || parseInt(a)<minYear || parseInt(a)>maxYear){
		alert("Por favor ingrese un a?o de 4 digitos entre "+minYear+" y "+maxYear+",gracias");
		return false;
	}
	return true;
}


//autor : Miguel leiva
//esta funcion solo me permite escoger un checkbox.
//uso : para realizar las modificaciones y visualizaciones


function validarUnaSeleccion(){
	var seleccionado = 0;
	var cant =0;
	for (i=0; i < document.forms[0].length; i++)
		if (document.forms[0].elements[i].checked) {
			cant=cant+1;
		}
seleccionado=cant;
	if (seleccionado==1)
	{
		return true;}
	else
	{
		return false;
		}
}

function evaluarEdad(fechaActual,fechaIngresada){
	
	var pos1=fechaActual.indexOf(dtCh)
	var pos2=fechaActual.indexOf(dtCh,pos1+1)
	var strDay=fechaActual.substring(0,pos1)
	var strMonth=fechaActual.substring(pos1+1,pos2)
	var strYear=fechaActual.substring(pos2+1)
	
	var pos11=fechaIngresada.indexOf(dtCh)
	var pos21=fechaIngresada.indexOf(dtCh,pos1+1)
	var strDay1=fechaIngresada.substring(0,pos1)
	var strMonth1=fechaIngresada.substring(pos1+1,pos2)
	var strYear1=fechaIngresada.substring(pos2+1)
	//alert("el dato es"+(parseInt(strYear)-parseInt(strYear1))+"el a?o actual es"+strYear+" y la fecha ingresada es"+strYear1);
	if((parseInt(strYear)-parseInt(strYear1))>=10 && (parseInt(strYear)-parseInt(strYear1))<=55 )
	return false;
	else return true;

	}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("El formato de fecha debe ser : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Por favor ingrese un mes v?lido")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Por favor ingrese un dia v?lido")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Por favor ingrese un a?o de 4 digitos entre "+minYear+" y "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Por favor ingrese una fecha v?lida")
		return false
	}
return true
}


/** igual que isDate pero modificado para SCTR del listado de trabajadores **/

	function isDateFromListado(dtStr,fila){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("El formato de fecha de la fila "+fila+" debe ser : dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Por favor ingrese un mes v?lido en la fecha de la fila "+fila)
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Por favor ingrese un dia v?lido en la fecha de la fila "+fila)
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Por favor ingrese un a?o de 4 digitos entre "+minYear+" y "+maxYear+" en la fila "+fila)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Por favor ingrese una fecha v?lida en la fila "+fila)
		return false
	}
return true
}

function compareDate(fechamenor, fechamayor){
	var valor = 0

	var pos1=fechamenor.indexOf(dtCh)
	var pos2=fechamenor.indexOf(dtCh,pos1+1)
	var strDayMe=fechamenor.substring(0,pos1)
	var strMonthMe=fechamenor.substring(pos1+1,pos2)
	var strYearMe=fechamenor.substring(pos2+1)

	var pos3=fechamayor.indexOf(dtCh)
	var pos4=fechamayor.indexOf(dtCh,pos3+1)
	var strDayMa=fechamayor.substring(0,pos3)
	var strMonthMa=fechamayor.substring(pos3+1,pos4)
	var strYearMa=fechamayor.substring(pos4+1)

	var fecMenor = strYearMe + strMonthMe + strDayMe
	var fecMayor = strYearMa + strMonthMa + strDayMa

	if (fecMenor == fecMayor) {
	   valor = 0
	} else {
		if (fecMenor < fecMayor) {
		   valor = 1
		} else {
		   valor = -1
		}
	}
	return valor
}

function ValidateForm(){
	var dt=document.frmSample.txtDate
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }


/**
Valida si fecha1 > fecha2
Parametros,: fecha 1, fecha2. Fechas a comparar en formato 'dd/mm/aaaa'
Devuelve true si fecha1 > fecha2, falso en caso contrario.
**/
function fechaMayor(fecha1, fecha2){
	anhoFecha1 = fecha1.substr(6,4);
	mesFecha1 = fecha1.substr(3,2);
	diaFecha1 = fecha1.substr(0,2);
	anhoFecha2 = fecha2.substr(6,4);
	mesFecha2 = fecha2.substr(3,2);
	diaFecha2 = fecha2.substr(0,2);
	//validamos si la fecha 1 es mayor a la fecha 2
	if (eval(anhoFecha1 - anhoFecha2 ) > 0)  {
		return true;
	}
	else
		if (eval(anhoFecha1 - anhoFecha2) == 0)  {
			if (eval(mesFecha1 - mesFecha2) >0) {
				return true;
			}
			else
				if (eval(mesFecha1 - mesFecha2) == 0 ) {
					if (eval(diaFecha1 - diaFecha2) > 0) {
						return true;
					}
				}
	}
	return false;
}

/**
Autor Miguel leiva
Uso : Compara que la fehca Final no pueda ser
	  ni Menor ni Ifual que la Fecha de Inicio
**/
function comparaFecha(fecha11, fecha22){
	fecha1=fecha11.value;
	fecha2=fecha22.value;
    var array_fecha1 = fecha1.split("/");
    var array_fecha2 = fecha2.split("/");

    var ano1;
    ano1 = parseInt(array_fecha1[2]);

    var mes1;
    mes1 = parseInt(array_fecha1[1]);
    var dia1;
    dia1 = parseInt(array_fecha1[0]);

 	var ano2;
    ano2 = parseInt(array_fecha2[2]);
    var mes2;
    mes2 = parseInt(array_fecha2[1]);
    var dia2;
    dia2 = parseInt(array_fecha2[0]);
			if(ano1>ano2){
			alert("El a?o de Vencimiento No puede ser Menor a la A?o de Inicio");
			return true;}
		else if(ano1==ano2 && mes1>mes2){
			alert("El mes de de Vencimiento No puede ser Menor a la Mes de Inicio");
			return true;}
		else if(ano1==ano2 && mes1==mes2 && dia1>=dia2){
			alert("La fecha de Vencimiento No puede ser Menor a la Fecha de Inicio");
			return true;}

			}
function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}


function bloquear(e) {

if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2)){
  alert('Funci?n restringida por el administrador')
  return false;
}
else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2)){
 alert('Funci?n restringida por el administrador');
 return false;
}
}


function maximize()
{
top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight < screen.availHeight||top.window.outerWidth < screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}}


	var checkflag = "false";
	function check(field) {
		if (checkflag == "false") {
		for (i = 0; i < field.length; i++)
		{field[i].checked = true;}
		checkflag = "true";
		}
		else {
		for (i = 0; i < field.length; i++)
 		{ field[i].checked = false; }
	  		checkflag = "false";
		}
	}
	
	
	function IsAlphaNum( str ) {
	// Return immediately if an invalid value was passed in
	if (str+"" == "undefined" || str+"" == "null" || str+"" == "")
		return false;
	var isValid = true;

	// convert to a string for performing string comparisons.
	str += "";
	// Loop through length of string and test for any alpha numeric
	// characters
	var numero=0;
	var minus=0;
	var mayus=0;
	for (i = 0; i < str.length; i++)
	{
	// Alphanumeric must be between "0"-"9", "A"-"Z", or "a"-"z"
		if ((str.charAt(i) >= "0") && (str.charAt(i) <= "9"))
		{
			numero=1;
		}
		if((str.charAt(i) >= "a") && (str.charAt(i) <= "z")){
			minus=1;
		}
		if((str.charAt(i) >= "A") && (str.charAt(i) <= "Z")){
			mayus=1;
		}
	} // END for

	if(numero==1 && (minus==1||mayus==1))
		isValid=true;
	else isValid=false;

	return isValid;
}

function validaCheck(f){
    var arreglo = f.elements;
    var tot = 0;
	for(var i=0;i<arreglo.length;i++)
	{
		if (arreglo[i].type == "checkbox" && arreglo[i].name != "_checkBoxparam" && arreglo[i].checked == true ){
			tot++;
		}
	}
	if(tot==0) return true;
	return false;
}
	
function seleccionarTodos(f){
    var arreglo = f.elements;
    var i=0;
	var valor;
	try{
		for(i=0;i<arreglo.length;i++)
		{
			if (arreglo[i].type == "checkbox" && arreglo[i].name != "_checkBoxparam" && arreglo[i].checked == true){
				valor = false;
				break;
			}
			else if (arreglo[i].type == "checkbox" && arreglo[i].name != "_checkBoxparam" && arreglo[i].checked == false)
			{
				valor = true;
				break;
			}
		}
		
		for(i=0;i<arreglo.length;i++)
		{
			if (arreglo[i].type == "checkbox" && arreglo[i].name != "_checkBoxparam" && arreglo[i].checked == true){
				arreglo[i].checked = valor;
			}
			else if (arreglo[i].type == "checkbox" && arreglo[i].name != "_checkBoxparam" && arreglo[i].checked == false)
			{
				arreglo[i].checked = valor;
			}
		}
		
	}
	catch(e)
	{
		alert(e.description);
	}
	return true;
}

/*
	Guillermo Mendoza Marcos
	ESTA FUNCION NOS PERMITE DEFINIR COMO SERA NUESTRO NUMERO DECIMAL
	simpleTexto = this.value
	enteros = cantidad de numeros enteros que deseamos
	decimales = cantidad de numeros decimales que deseamos
	textItem = this
*/
    //VARIABLE GLOBAL
    var textoAnterior = '';

    //ESTA FUNCI?N DEFINE LAS REGLAS DEL JUEGO
    function cumpleReglas(simpleTexto,enteros,decimales)
        {
            //EXPRESION REGULAR PARA NUMERO ENTEROS Y DECIMALES
            var expresion = new RegExp("^(|([0-9]{1,"+enteros+"}(\\.([0-9]{1,"+decimales+"})?)?))$");

            //si pasa la prueba, es v?lida
            if(expresion.test(simpleTexto))
                return true;
            return false;
        }//end function checaReglas

    //ESTA FUNCI?N REVISA QUE TODO LO QUE SE ESCRIBA EST? EN ORDEN
    function digitaDecimal(textItem,enteros,decimales)
        {
            //si comienza con un punto, le agregamos un cero
            if(textItem.value.substring(0,1) == '.') 
                textItem.value = '0' + textItem.value;

            //si no cumples las reglas, no te dejo escribir
            if(!cumpleReglas(textItem.value,enteros,decimales))
                textItem.value = textoAnterior;
            else //todo en orden
                textoAnterior = textItem.value;
        }//end function revisaCadena
	