/*
	*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
	LIBRERIAS JAVASCRIPT
	Autor: Andrés Ijelman
	Fecha Creación: 21 de Junio de 2006.
	Fecha Modificación: 24 de Abril de 2007 por Juan Roperto.
	*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
*/
	//ESTA FUNCION CONFIRMA PARA ELIMINAR Y LE PASA PARAMETROS AL FORM Y DESPUES LO ENVIA
function frmParamConf (frmName,param) {
	c = confirm ("Confirma que desea eliminar permanentemente el elemento?");
	if (c) {
		document[frmName].action = document[frmName].action + "&" + param;
		document[frmName].submit();
	}
}
	
//ESTA FUNCION REDIRECCION A OTRA PAGINA
function redirect (destino) {
	if ((destino != "") && (destino != "-1")) location.href = destino;
}

//ESTA FUNCION CONFIRMA PARA ELIMINAR Y REDIRECCIONA OTRA PAGINA
function redirectConf (destino) {
	c = confirm ("Confirma que desea eliminar permanentemente el elemento?");
	if ((destino != "") && (destino != "-1") && c) location.href = destino;
}

/*recibe nº de pagina y el form*/
function pagina (p, frmName) {
		document[frmName].pagina.value=p;
		document[frmName].submit();
		}
/*cambia pagina y parametoro*/
function paginaFront (p, frmName, accion) {
		document[frmName].action = "index.php?" + accion ; 
		document[frmName].pagina.value=p;
		document[frmName].submit();
		}

/*recibe nº de pagina y el form y parametros adicionales*/
function paginaParam (p, frmName, params) {
		document[frmName].pagina.value=p;
		document[frmName].action = document[frmName].action + "&" + params;
		document[frmName].submit();
		}

function size (t, frmName) {
		document[frmName].size.value=t;
		document[frmName].submit();
		}

//ESTA FUNCION LE PASA PARAMETROS AL FORM Y DESPUES LO ENVIA
function frmParam (frmName,param) {
	document[frmName].action = document[frmName].action + "&" + param;
	document[frmName].submit();
}

function enviar (dest, frmName) {
	document[frmName].action = "index.php?acc=" + dest;
	document[frmName].submit();
}



//ESTA FUNCION VALIDA SI UN INPUT ES NUMERICO O NO
function checkNumeric(objName,minval, maxval,comma,period,hyphen){
	var numberfield = objName;
	if (chkNumeric(objName,minval,maxval,comma,period,hyphen) == false)
	{
		numberfield.select();
		numberfield.focus();
		return false;
	}
	else
	{
		return true;
	}
}

function chkNumeric(objName,minval,maxval,comma,period,hyphen){
// only allow 0-9 be entered, plus any values passed
// (can be in any order, and don't have to be comma, period, or hyphen)
// if all numbers allow commas, periods, hyphens or whatever,
// just hard code it here and take out the passed parameters
var checkOK = "0123456789" + comma + period + hyphen;
//var checkOK = "0123456789" + period + hyphen;
var checkStr = objName;
var allValid = true;
var decPoints = 0;
var allNum = "";

	for (i = 0;  i < checkStr.value.length;  i++)
	{
		ch = checkStr.value.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
		break;
	
		if (j == checkOK.length)
		{
			allValid = false;
			break;
		}
		if (ch != ",")
		allNum += ch;
	}

	ultPos = (checkStr.value.length) -1;
	if (ultPos < 0) ultPos = 0;

	if ( checkStr.value.charAt(ultPos) =='.')
			allValid = false;
		
	if (!allValid)
	{
		return (false);
	}
}

function check_email(e) {
	ok = "1234567890qwertyuiop[]asdfghjklzxcvbnm.@-_QWERTYUIOPASDFGHJKLZXCVBNM";
	for(i=0; i < e.length ;i++){
		if(ok.indexOf(e.charAt(i))<0){ 
			return (false);
		}
	}	
	if (document.images) {
		re = /(@.*@)|(\.\.)|(^\.)|(^@)|(@$)|(\.$)|(@\.)/;
		re_two = /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/;
		if (!e.match(re) && e.match(re_two)) {
			return (-1);		
		} 
	}
}

		