arrEtiquetasGral=new Array();

for(i=0;i<=30;i++) arrEtiquetasGral[i]=new Array(2);

arrEtiquetasGral[0][0]="no válida";
arrEtiquetasGral[0][1]="invalid";


arrEtiquetasGral[1][0]="Fecha";
arrEtiquetasGral[1][1]="Date";



function trmPdd(pIdma){
	nIndice=fncMssEt(pIdma);
    if (!document.frmForma.bAcepta.checked){
        alert(arrEtiquetas[16][nIndice]);
        document.frmForma.bAcepta.focus();
        return;
    }
   document.frmForma.action='45pd39875.php';
   document.frmForma.submit();
}


function altaUsuario(pIdma){
	
	nIndice=fncMssEt(pIdma);

    sInsertar=strTrim(document.frmForma.sInsertar.value);
    if (sInsertar=="1"){
        if (usrInvld(pIdma)){
            return;
        }
        sPass=strTrim(document.frmForma.sPass.value);
        sConPass=strTrim(document.frmForma.sConPass.value);
        if (sConPass==""){
            alert(arrEtiquetas[14][nIndice]);
            document.frmForma.sConPass.value="";
            document.frmForma.sConPass.focus();            
            return;
        }

        if (sPass!=sConPass){
            alert(arrEtiquetas[15][nIndice]);
            document.frmForma.sPass.value="";
            document.frmForma.sConPass.value="";
            document.frmForma.sPass.focus();            
            return;
        }

    }
    sNom=strTrim(document.frmForma.sNom.value);
    sCorreo=strTrim(document.frmForma.sCorreo.value);
    sTel=strTrim(document.frmForma.sTel.value);
    sDir=strTrim(document.frmForma.sDir.value);
    sCol=strTrim(document.frmForma.sCol.value);
    sCP=strTrim(document.frmForma.sCP.value);
    sDel=strTrim(document.frmForma.sDel.value);
    id_pais=strTrim(document.frmForma.id_pais.value);
    id_estado=strTrim(document.frmForma.id_estado.value);
    if (sNom==""){
         alert(arrEtiquetas[5][nIndice]);
         document.frmForma.sNom.value="";
         document.frmForma.sNom.focus();            
         return;
    }   

	if (!Esmail(sCorreo)){
         	alert(arrEtiquetas[6][nIndice]);
;
		document.frmForma.sCorreo.focus();
		return false;
	}

    if (sTel==""){

         alert(arrEtiquetas[7][nIndice]);
         document.frmForma.sTel.value="";
         document.frmForma.sTel.focus();            
         return;
    }  

    if (sDir==""){

         alert(arrEtiquetas[8][nIndice]);
         document.frmForma.sDir.value="";
         document.frmForma.sDir.focus();            
         return;
    }

    if (sCol==""){

         alert(arrEtiquetas[9][nIndice]);
         document.frmForma.sCol.value="";
         document.frmForma.sCol.focus();            
         return;
    }

    if (sCP==""){

         alert(arrEtiquetas[10][nIndice]);
         document.frmForma.sCP.value="";
         document.frmForma.sCP.focus();            
         return;
    }
    if (sDel==""){

         alert(arrEtiquetas[11][nIndice]);
         document.frmForma.sDel.value="";
         document.frmForma.sDel.focus();            
         return;
    }    
    

    if (id_pais=="0"){
         alert(arrEtiquetas[12][nIndice]);
         document.frmForma.id_pais.focus();            
         return;
    }
    
    if (id_estado=="0"&&id_pais=="1"){
         alert(arrEtiquetas[13][nIndice]);
         document.frmForma.id_estado.focus();            
         return;
    }

    
   document.frmForma.action='rgtusr.php';
   document.frmForma.submit();
    
}


function fncMssEt(pIdma){
	
	if (pIdma=="")
		return 0;
	else
		return 1; 

}


function enviaDatos(pIdma,pCodigo)
{

	
	nIndice=fncMssEt(pIdma);


    nCan=strTrim(document.frmProd["Cod_"+pCodigo].value);
    if (nCan==""){
        alert(arrEtiquetas[0][nIndice]);
        document.frmProd["Cod_"+pCodigo].value="";
        document.frmProd["Cod_"+pCodigo].focus();
        return;
    }


    if (nCan!=parseInt(document.frmProd["Cod_"+pCodigo].value)){
        alert(arrEtiquetas[0][nIndice]);
        document.frmProd["Cod_"+pCodigo].value="";
        document.frmProd["Cod_"+pCodigo].focus();
        return;
    }
   
   document.frmProd.cantidad.value=parseInt(document.frmProd["Cod_"+pCodigo].value);
   document.frmProd.id.value=pCodigo;
   document.frmProd.submit();
   
}


function usrInvld(pIdma){
	nIndice=fncMssEt(pIdma);
    sUsuario=strTrim(document.frmForma.sUsuario.value);
    sPass=strTrim(document.frmForma.sPass.value);
    if (sUsuario==""){
	alert(arrEtiquetas[1][nIndice]);
        document.frmForma.sUsuario.value="";
        document.frmForma.sUsuario.focus();
        return true;
    }


    if (TieneCaracteresEspecialesClaves(sUsuario)){


	alert(arrEtiquetas[2][nIndice]);
        document.frmForma.sUsuario.value="";
        document.frmForma.sUsuario.focus();
        return true;
    }


    if (sPass==""){

	alert(arrEtiquetas[3][nIndice]);
        document.frmForma.sPass.value="";
        document.frmForma.sPass.focus();
        return true;
    }


    if (TieneCaracteresEspecialesClaves(sPass)){
	alert(arrEtiquetas[4][nIndice]);
        document.frmForma.sPass.value="";
        document.frmForma.sPass.focus();
        return true;
    }
    
    return false;

}

function regUsuario(pIdma,pPag)
{

    if (usrInvld(pIdma)){
        return;
    }
   
   document.frmForma.action=pPag;
   document.frmForma.submit();
   
}


function Existe(pValor)
{
sString = strTrim(pValor)
//alert('sale--' + sString + '--');
if(sString.length>0)
   return true;
else
   return false; 
}
	
	    
function strTrim(pStr)     {
	//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	//:: Esta función quita espacios tanto a la Izquierda como a  ::
	//:: la derecha de una cadena de caracteres, parecida a la    ::
	//:: función de Visual Basic TRIM.                            ::
	//::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
	
	var Len = pStr.length;
	while (pStr.charAt(0)==" ")		{
		pStr = pStr.substring(1);
		}
	Len = pStr.length;
	while (pStr.charAt(Len-1)==" ")		{
		pStr = pStr.substring(0,Len-1);
		Len = pStr.length;
		}
	
	return pStr;
			
}



function TieneCaracteresEspeciales(pDato){

		pDato=pDato.toLowerCase();
		contador=0;
		sValoresPermitidos="'\"<>\\";
		EsteCaracter="";
		for (var i=0; i < pDato.length; i++) {
			EsteCaracter=pDato.substring(i,i+1);
			EsteCaracter=EsteCaracter.toLowerCase();
			if (sValoresPermitidos.indexOf(EsteCaracter) != -1) {
			       alert("No se permiten caracteres especiales:apostrofe('), comillas(\"), mayor(>), menor(<) o diagonal invertida(\\)");

				return true;
			}

		}


}




function abreVentana(pagina,ancho,alto){
		var1="width="+ancho+",height="+alto+",toolbar=0,location=no,directories=no,status=no,menubar=0,scrollbars=1,resizable=1"
      ventana=window.open(pagina,"Acceso", var1)
ventana.focus();
}





function valRangoFec(pIdma,pfecha_ini,pfecha_fin)
{

fecha_ini=pfecha_ini.value;
fecha_fin=pfecha_fin.value;

iDia="";
iMes="";
iAnio="";
iFechaSelIni="";
iFechaSelFin="";


nIndice=fncMssEt(pIdma);

if (fecha_ini==""){
	alert(arrEtiquetasGral[1][nIndice]+" "+arrEtiquetasGral[0][nIndice]);
	pfecha_ini.focus();
	return false;
}


if (fecha_fin==""){
	alert(arrEtiquetasGral[1][nIndice]+" "+arrEtiquetasGral[0][nIndice]);
	pfecha_fin.focus();
	return false;
}


FechaInicArreglo = fecha_ini.split("/");
if (FechaInicArreglo.length!=3){
	alert(arrEtiquetasGral[1][nIndice]+" "+arrEtiquetasGral[0][nIndice]);
	pfecha_ini.focus();
	return false;
}


FechaFinArreglo = fecha_fin.split("/");
if (FechaFinArreglo.length!=3){
	alert(arrEtiquetasGral[1][nIndice]+" "+arrEtiquetasGral[0][nIndice]);
	pfecha_fin.focus();
	return false;
}



if (fecha_ini!=""){

	iDia=strTrim(FechaInicArreglo[0]);
	iMes=strTrim(FechaInicArreglo[1]);
	iAnio=strTrim(FechaInicArreglo[2]);

}
iFechaSelIni=iAnio+iMes+iDia;
if (isNaN(parseInt(iFechaSelIni))){
	alert(arrEtiquetasGral[1][nIndice]+" "+arrEtiquetasGral[0][nIndice]);
	pfecha_ini.focus();
	return false;
}




if (fecha_fin!=""){
	iDia=strTrim(FechaFinArreglo[0]);
	iMes=strTrim(FechaFinArreglo[1]);
	iAnio=strTrim(FechaFinArreglo[2]);
}
iFechaSelFin=iAnio+iMes+iDia;


if (isNaN(parseInt(iFechaSelFin))){
	alert(arrEtiquetasGral[1][nIndice]+" "+arrEtiquetasGral[0][nIndice]);
	pfecha_fin.focus();
	return false;
}







	if (iFechaSelIni>iFechaSelFin){
		alert(arrEtiquetasGral[1][nIndice]+" "+arrEtiquetasGral[0][nIndice]+" : "+arrEtiquetasGral[1][nIndice]+" 1 > " +arrEtiquetasGral[1][nIndice]+" 2 ")
		pfecha_ini.focus();
		return false;
	}

	return true;
}

function NoTieneValoresNumericos(pDato){
		pDato=pDato.toLowerCase();
		contador=0;
		sValoresPermitidos="1234567890";
		EsteCaracter="";
		for (var i=0; i < pDato.length; i++) {
			EsteCaracter=pDato.substring(i,i+1);
			EsteCaracter=EsteCaracter.toLowerCase();
			if (sValoresPermitidos.indexOf(EsteCaracter) == -1) {
				return true;
			}

		}


}


function valfecha(valores)
{
	FechaArr = valores.split("/");
	DiaFecha = FechaArr[0];
	MesFecha = FechaArr[1];
	AniFecha = FechaArr[2];

	
	if (isNaN(parseInt(DiaFecha, 10))){
		alert("Por favor proporcione la fecha correcta, el dia esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}
	
	if (isNaN(parseInt(MesFecha, 10))){
		alert("Por favor proporcione la fecha correcta, el mes esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}
	
	if (isNaN(parseInt(AniFecha, 10))){
		alert("Por favor proporcione la fecha correcta, el año esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}


	if(NoTieneValoresNumericos(DiaFecha)){
		alert("Por favor proporcione la fecha correcta, el dia esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}


	if(NoTieneValoresNumericos(MesFecha)){
		alert("Por favor proporcione la fecha correcta, el mes esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}
	

	if(NoTieneValoresNumericos(AniFecha)){
		alert("Por favor proporcione la fecha correcta, el año esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}
	
	
	if ((DiaFecha<=0) || (DiaFecha>31)) {
		alert("Por favor proporcione la fecha correcta, el dia esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}
	
	if ((MesFecha<=0) || (MesFecha>12)) {
		alert("Por favor proporcione la fecha correcta, el mes esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}

	if ((DiaFecha>30)&&((MesFecha==4)||(MesFecha==6)||(MesFecha==9)||(MesFecha==11))){
		alert("Por favor proporcione la fecha correcta, el día esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}
	
	if ((DiaFecha>30)&&((MesFecha==4)||(MesFecha==6)||(MesFecha==9)||(MesFecha==11))){
		alert("Por favor proporcione la fecha correcta, el día esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}
	
	if ((DiaFecha>30)&&((MesFecha==4)||(MesFecha==6)||(MesFecha==9)||(MesFecha==11))){
		alert("Por favor proporcione la fecha correcta, el día esta incorrecto, el formato es: dd/mm/aaaa");
		return false;
	}
	
	if ((AniFecha<1900) || (AniFecha>9000)) {
		alert("Por favor proporcione la fecha correcta, el año tiene que ser mayor a 1900 y solo puede contener 4 dígitos, el formato es: dd/mm/aaaa");
		return false;
	}
	
	if (((AniFecha % 4)!=0)&&(MesFecha==2)&&(DiaFecha>28)) {
			alert("Por favor proporcione la fecha correcta, el día esta incorrecto, el formato es: dd/mm/aaaa");
			return false;
	}
	
	if (((AniFecha % 4)==0)&&(MesFecha==2)&&(DiaFecha>29)) {
			alert("Por favor proporcione la fecha correcta, el día esta incorrecto, el formato es: dd/mm/aaaa");
			return false;
	}
	
	return true;
 }
 
function ExisteComilla(comilla){
		CadenaComilla = new String('\'');
		cadena = new String(comilla);
		var IN90 = '0';
		for (var i=0; i < cadena.length; i++) {
		if (CadenaComilla.indexOf(cadena.charAt(i)) != -1) {
		IN90 = '1';}
		}
		if (IN90 == '1') {
		return true;
		}
		return false;
		}
	

function esCaracterPermitido(pValoresPermitidos,pDato){
		pDato=pDato.toLowerCase();
		contador=0;
		EsteCaracter="";
		for (var i=0; i < pDato.length; i++) {
			EsteCaracter=pDato.substring(i,i+1);
			EsteCaracter=EsteCaracter.toLowerCase();
			if (pValoresPermitidos.indexOf(EsteCaracter) != -1) {
contador ++;
			}

		}

	if (contador==pDato.length)
		return true;
	else
		return false;
}

function Esmail(Dato){

		CadenaNumeros = new String('@');
		CadenaNumeros1 = new String('.');
		CadenaPuntoComa = new String(';');
		sUltimoCaracter="";
		CadenaComa = new String(',');
		var nContadorPuntoComa=0;
		var nContadorArrobas=0;
		var punto;
		var arroba;
		cadena = new String(Dato);
		for (var i=0; i < cadena.length; i++) {
		sUltimoCaracter=cadena.charAt(i);
		if(cadena.charAt(i)==" "){
		return false;
		}
		if(cadena.charAt(i)==","){
		return false;
		}
		if (CadenaNumeros.indexOf(cadena.charAt(i)) != -1) {
		arroba="true";
		nContadorArrobas=nContadorArrobas+1
		}
		if (CadenaNumeros1.indexOf(cadena.charAt(i)) != -1) {
		punto="true";}
		if (CadenaPuntoComa.indexOf(cadena.charAt(i)) != -1) {
		nContadorPuntoComa=nContadorPuntoComa+1;
		}

		}

if(nContadorPuntoComa>0||nContadorArrobas>1){

return false;
}		

if (nContadorPuntoComa==0 && TieneCaracteresEspecialesClaves(sUltimoCaracter)){
return false;

}
		
		if (arroba=="true" && punto=="true") 
			{return true
			}
		return false;
		}

function NotIsNumeric(strValor)
{
        strTmp=strValor;
                if (strTmp=="")
                        return true;
                else
                {
                        for(i=0;i<=strTmp.length-1;i++)
                        {
                                if (isNaN(strTmp.charAt(i)))
                                {
                                        return true;
                                }
                        }
                }
                return false;
}		

function esEMail(pCampo){
	sDato=strTrim(document.frmDatos[pCampo].value);
	if (sDato==""){
		alert("Proporcione el E-mail");
		document.frmDatos[pCampo].focus();
		return false;
	}
	
	if (!Esmail(sDato)){
		alert("E-mail no valido");
		document.frmDatos[pCampo].focus();
		return false;
	}
	return true;
}

function TieneCaracteresEspecialesClaves(pValor){/* Verifica si el parametro indicado tiene caracteres especiales*/
   var objRegExp = /\W/;
   if(objRegExp.test(pValor)){

	   return true;			
}
	return false;		
}
	
function IsBlank(strValor)
{
                strTmp=strValor;
                if (strTmp=="")
                        return true;
                else
                {
                        for(i=0;i<=strTmp.length-1;i++)
                        {
                                if (strTmp.charAt(i)!=" ")
                                {
                                        return false;
                                }
                        }
                }
                return true;
        }


function nameFileInv(pArchivo){

	if (pArchivo==""){
		alert("Por favor seleccione un archivo ");
		return true;
	}

	archivoArreglo=pArchivo.split("\\");

	if (archivoArreglo.length==0){
		alert("Por favor seleccione un archivo ");
		return true;
	}
	archivo=archivoArreglo[archivoArreglo.length-1];

	if(!esCaracterPermitido("1234567890_-abcdefghijklmnopqrstuvwxyz.",archivo)){
      	alert("El nombre del Archivo solo puede tener caracteres alfanumericos y guion bajo (_)")
      	return true;
	}
	return false;
}

function MM_showHideLayers() { //v9.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) 
  with (document) if (getElementById && ((obj=getElementById(args[i]))!=null)) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

