<!--//hide me
// -----------------------------------------------------------------
function IsEmailOk(theForm)
{
 var email1 = theForm.txtCorreo.value;
 var email2 = theForm.txtRepiteCorreo.value;
  if (email1 != email2) 
  {
   alert ("La confirmación del e-mail no coincide con el registrado,\n por favor vuelve a teclearlo");
   theForm.txtRepiteCorreo.value = "";
   theForm.txtRepiteCorreo.focus();
   return (false);
  }
  else
  {  return (true);
  }
}

// Function    : IsEmailValid
// Language    : JavaScript
// Description : Checks if given email address is of valid syntax
// Copyright   : (c) 1998 Shawn Dorman
// http://www.goodnet.com/~sdorman/web/IsEmailValid.html
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 09/04/1996 Original write
// 1.1 09/30/1998 CHG: Use standard header format
// -----------------------------------------------------------------
// Source: Webmonkey Code Library
// (http://www.hotwired.com/webmonkey/javascript/code_library/)
// -----------------------------------------------------------------

function IsEmailValid(FormName,ElemName)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var AtSym    = Temp.value.indexOf('@')
var Period   = Temp.value.lastIndexOf('.')
var Space    = Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   // Array is from 0 to length-1
if ( (AtSym < 1) ||         // '@' cannot be in first position
     (Period <= AtSym+1) || //Must be atleast 1 valid char btwn '@' and '.'
     (Period == Length ) || // Must be atleast one valid char after '.'
     (Space  != -1) )       // No empty spaces permitted
    {       
      alert("La dirección de correo electrónico es inválida")
         {
		    Temp.value = "";
          Temp.focus();             
          return false;
        }
  }                         
return true;
}                       

//-->


function IsCPOkk(theForm,ElemName)
{
  var Temp = document.forms[theForm].elements[ElemName];
  
  var checkOKCP = "0123456789";
  var checkStrCP = Temp.value;
  var allValid = true;
  if (checkStrCP.length != 5)
  { 
    alert ("El código postal debe de tener 5 dígitos");
    Temp.value="";
    Temp.focus();
    return false;
  } 
  else
  {
    for (i = 0;  i < checkStrCP.length;  i++)
    {
      ch = checkStrCP.charAt(i);
      for (j = 0;  j < checkOKCP.length;  j++)
        if (ch == checkOKCP.charAt(j))
        {
          break;
		}
      if (j == checkOKCP.length)
      {
          allValid = false;
          break;
      }
    }
    if (!allValid)
    {
      alert("Sólo puedes teclear números en el Código Postal");
      Temp.value="";
      Temp.focus();
      return false;
    }
  }
}

//**********************************************************************
// Empresa: Sitios Interactivos de Comercio E. S. A. de C. V.
// Nombre: EspaciosEnBlanco
// Proposito: Verifica si la cadena sólo contiene espacios en blanco
// Entradas: cadena = variable a examinar
// Salidas: -1 = sólo son espacios en blanco
//			 0 = contiene datos
//**********************************************************************
function EspaciosEnBlanco(theForm,ElemName,NombreCampo)
{	
	var contador = 0;
	var Temp = document.forms[theForm].elements[ElemName];
	var cadena = Temp.value;
	
	for (var i=0;i<cadena.length;i++)
		{
			if (cadena.substring(i,i+1) == " ")
				contador = contador + 1;
		}
	if (contador == cadena.length)
	{
		alert("Favor de no dejar espacios en blanco en el campo " + NombreCampo);
		Temp.value = "";
		Temp.focus();
		return -1;
	}
	else
		return 0;
}


//**********************************************************************
// Empresa: Sitios Interactivos de Comercio E. S. A. de C. V.
// Nombre: EspaciosEnBlanco
// Proposito: Verifica si la cadena sólo contiene espacios en blanco
// Entradas: Campo - Idenficador a examinar
//		     NombreCampo - Nombre del identificador a examinar
// Salidas: -1 = sólo son espacios en blanco
//			 0 = contiene datos
//**********************************************************************
function EspaciosEnBlancoCampo(Campo,NombreCampo)
{	
	var contador = 0;
	var cadena =Campo;
	
	for (var i=0;i<cadena.length;i++)
		{
			if (cadena.substring(i,i+1) == " ")
				contador = contador + 1;
		}
	if (contador == cadena.length)
	{
		alert("Favor de no dejar espacios en blanco en el campo " + NombreCampo);
		return -1;
	}
	else
		return 0;
}

// -----------------------------------------------------------------
// Function 	 : ValidaFecha
// Language 	 : JavaScript
// Description : Valida la fecha 
// -----------------------------------------------------------------
function ValidaFecha(theForm,ElemName1,ElemName2,ElemName3)
{	
	var Temp = document.forms[theForm].elements[ElemName1];
	var dia = Temp.selectedIndex;
	dia = Temp.options[dia].value;
	
	Temp = document.forms[theForm].elements[ElemName2];
	var mes = Temp.selectedIndex;
	mes = Temp.options[mes].value;
	
	Temp = document.forms[theForm].elements[ElemName3];
	var anio = Temp.selectedIndex;
	anio = Temp.options[anio].value;
	
	var msgError = "";
	var Error = false;	
	
	var fechactual = new Date();
	var mesActual = fechactual.getMonth() + 1; // Porque el primer mes cuenta como 0
	var anioActual = fechactual.getFullYear();
	var diaActual = fechactual.getDate(); 
	
	// Meses de 31 dias 
	if( ( mes == 1 || mes== 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12) && dia > 31) 
		Error = true;			

	// Meses de 30 dias 
	if((mes == 4 || mes == 6 || mes == 9 || mes == 11)	&& dia > 30)
		Error = true;			

	// Febrero y bisiestos. 
	if( mes == 2 && ( dia > 29 ||( dia == 29 && ((anio % 400 != 0) && ((anio % 4 != 0) || (anio % 100 == 0)))))) 
		Error = true;			
		
	if (Error)	
		msgError = msgError + "- El número de días no corresponden al mes \n";	
	else
	{
		// Si el año es el actual 
		if(anio == anioActual)
		{
			// Mes debe ser menor al actual
			if(mes > mesActual)
			{
				Error = true;
				msgError = msgError + "- El mes debe ser menor o igual al actual\n";
			}
			
			// Si el mes es el mismo entonces, verifica si el día es mayor al actual
			if(mes == mesActual)
			{
				if (dia > diaActual)
				{
					Error = true;
					msgError = msgError + "- El día debe ser menor o igual al actual\n";
				}
			}
		}
	}
	
	// Verifica el mensaje de error que se despliega
	if (Error)
	{		
		msgError = "Dato Erroneo:\n\n" + msgError + "\nPor favor corrija"
		alert (msgError);
		return (false);
	}
	else 
	 {
	 return (true);
	 }
}

// --------------------------------------------------------------------------------
// Function 	 : ValidaFechaAMasDiasDelActual
// Language 	 : JavaScript
// Description : Valida la fecha, pero permite seleccionar un día más al actual
// --------------------------------------------------------------------------------
function ValidaFechaAMasDiasDelActual(theForm,ElemName1,ElemName2,ElemName3,NumeroDias)
{	
	var Temp = document.forms[theForm].elements[ElemName1];
	var dia = Temp.selectedIndex;
	dia = Temp.options[dia].value;
	
	Temp = document.forms[theForm].elements[ElemName2];
	var mes = Temp.selectedIndex;
	mes = Temp.options[mes].value;
	
	Temp = document.forms[theForm].elements[ElemName3];
	var anio = Temp.selectedIndex;
	anio = Temp.options[anio].value;
	
	var msgError = "";
	var Error = false;	
	
	var fechactual = new Date();
	var mesActual = fechactual.getMonth() + 1; // Porque el primer mes cuenta como 0
	var anioActual = fechactual.getFullYear();
	var diaActual = fechactual.getDate(); 
	
	// Meses de 31 dias 
	if( ( mes == 1 || mes== 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12) && dia > 31) 
		Error = true;			

	// Meses de 30 dias 
	if((mes == 4 || mes == 6 || mes == 9 || mes == 11)	&& dia > 30)
		Error = true;			

	// Febrero y bisiestos. 
	if( mes == 2 && ( dia > 29 ||( dia == 29 && ((anio % 400 != 0) && ((anio % 4 != 0) || (anio % 100 == 0)))))) 
		Error = true;			
		
	if (Error)	
		msgError = msgError + "- El número de días no corresponden al mes \n";	
	else
	{
		// Si el año es el actual 
		if(anio == anioActual)
		{
			// Mes debe ser menor al actual
			if(mes > mesActual)
			{
				Error = true;
				msgError = msgError + "- El mes debe ser menor o igual al actual\n";
			}
			
			// Si el mes es el mismo entonces, verifica si el día es mayor al actual
			if(mes == mesActual)
			{
				// Válido seleccionar un día más al actual
				diaActual = diaActual+1;
				
				if (dia > diaActual)
				{
					Error = true;
					msgError = msgError + "- El día debe ser menor, igual o con un día más al actual\n";
				}
			}
		}
	}
	
	// Verifica el mensaje de error que se despliega
	if (Error)
	{		
		msgError = "Dato Erroneo:\n\n" + msgError + "\nPor favor corrija"
		alert (msgError);
		return (false);
	}
	else 
	 {
	 return (true);
	 }
}



function IsFieldValid(FormName,ElemName,ElemDesc)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var Value    = Temp.value;
var checkOK = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyzáéíóúÁÉÍÓÚñ ";
var allValid = true;
var chant;

  if (Value == "")
  {
   alert(ElemDesc+" no valido(a). Se aceptan unicamente letras y espacios simples.");
   document.forms[FormName].elements[ElemName].focus();
   return (false);
  }

  for (i = 0;  i < Value.length;  i++)
  {
    ch = 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 == " ") && (chant == " "))
    {
      allValid = false;
      break;    
    }
    if ((Value.length == 1) && (ch == " "))
    {
      allValid = false;
      break;    
    }    
    chant = ch;
  }
  if (!allValid)
  {
    alert(ElemDesc+" no valido(a). Se aceptan unicamente letras y espacios.");
    document.forms[FormName].elements[ElemName].value="";
    document.forms[FormName].elements[ElemName].focus();
    return (false);
  }                
return true;
}  

function IsChar(theForm, theField)
{
  var Temp     = document.forms[theForm].elements[theField];
  
  if (Temp.value != "")
  {
	var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz";
	var checkStr = Temp.value;
	var allValid = true;
	var LongStr = checkStr.length;

	for (i = 0;  i < checkStr.length;  i++)
	{
	  ch = checkStr.charAt(i);
		    for (j = 0;  j < checkOK.length;  j++)
	      if (ch == checkOK.charAt(j))
	        break;
		}
	if (j == checkOK.length)
	 {
	        allValid = false;
	  }
	 
	  if (!allValid) 
	  {
	    alert("Sólo puedes teclear letras en este campo");
	    Temp.value="";
	    Temp.focus();
	    return false;
	  } 
  }
}

function IsCharsDir(theForm, theField)
{
  var Temp     = document.forms[theForm].elements[theField];
  
  if (Temp.value != "")
  {
	
	var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz1234567890 ";
	var checkStr = Temp.value;
	var allValid = true;
	var LongStr = checkStr.length;
	
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
	}
	if (j == checkOK.length)
	 {
	        allValid = false;
	  }
	 
	  if (!allValid) 
	  {
	    alert("Sólo puedes teclear letras y numeros en este campo");
	    Temp.value="";
	    Temp.focus();
	    return false;
	  } 
	}
}

function IsCharsDirPunto(theForm, theField)
{
  var Temp     = document.forms[theForm].elements[theField];
  
  if (Temp.value != "")
  {
	
	var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz1234567890. ";
	var checkStr = Temp.value;
	var allValid = true;
	var LongStr = checkStr.length;
	
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
	}
	if (j == checkOK.length)
	 {
	        allValid = false;
	  }
	 
	  if (!allValid) 
	  {
	    alert("Sólo puedes teclear letras y numeros en este campo");
	    Temp.value="";
	    Temp.focus();
	    return false;
	  } 
	}
}


function IsCharsDirGuiones(theForm, theField, theElemDesc)
{
  var Temp     = document.forms[theForm].elements[theField];
  
  if (Temp.value != "")
  {
	
	var checkOK = "ABCDEFGHIJKLMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz1234567890-";
	var checkStr = Temp.value;
	var allValid = true;
	var LongStr = checkStr.length;
	
	for (i = 0;  i < checkStr.length;  i++)
	{
		ch = checkStr.charAt(i);
		
		for (j = 0;  j < checkOK.length;  j++)
			if (ch == checkOK.charAt(j))
				break;
	}
	if (j == checkOK.length)
	 {
	        allValid = false;
	  }
	 
	  if (!allValid) 
	  {
	    alert(theElemDesc + " no válido(a). Se aceptan únicamente caracteres alfanuméricos.");
	    Temp.value="";
	    Temp.focus();
	    return false;
	  } 
	}
}

function IsFieldValid2(FormName,ElemName,ElemDesc)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var Value    = Temp.value;
var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
var allValid = true;
var chant;

  if (Value == "")
  {
   alert(ElemDesc+" no válido(a). Se aceptan únicamente caracteres alfanuméricos.");
   document.forms[FormName].elements[ElemName].focus();
   return (false);
  }

  for (i = 0;  i < Value.length;  i++)
  {
    ch = 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 == " ") && (chant == " "))
    {
      allValid = false;
      break;    
    }
    if ((Value.length == 1) && (ch == " "))
    {
      allValid = false;
      break;    
    }    
    chant = ch;
  }
  if (!allValid)
  {
    alert(ElemDesc+" no valido(a). Se aceptan unicamente caracteres alfanumericos.");
    document.forms[FormName].elements[ElemName].value="";
    document.forms[FormName].elements[ElemName].focus();
    return (false);
  }                
return true;
}  

function IsAlfanumericoConGuion(FormName,ElemName,ElemDesc)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var Value    = Temp.value;
var checkOK = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-";
var allValid = true;
var w = 0;

  if (Value == "")
  {
   alert(ElemDesc+" no valido(a). Se aceptan unicamente caracteres alfanumericos.");
   document.forms[FormName].elements[ElemName].focus();
   return (false);
  }

  for (i = 0;  i < Value.length;  i++)
  {
    ch = Value.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
      break;
    if (j == checkOK.length)
    {
      allValid = false;
      break;
    }	
    if ((Value.length == 1) && (ch == "-"))
    {
      allValid = false;
      break;    
    }   
    
    if (ch == "-") 
		w = w + 1;   
  }
  
  if ((i==w)||(w >= 2))
     allValid = false;
  
  if (!allValid)
  {
    alert(ElemDesc+" no valido(a). Se aceptan unicamente caracteres alfanumericos y un sólo guión.");
    document.forms[FormName].elements[ElemName].value="";
    document.forms[FormName].elements[ElemName].focus();
    return (false);
  }                
return true;
}  

function IsRFCOk(theForm,ElemName)
{
  var Temp = document.forms[theForm].elements[ElemName];
  
  var checkOKCP = "0123456789ABCDEFGHIJLKMNÑOPQRSTUVWXYZabcdefghijklmnñopqrstuvwxyz";
  var checkStrCP = Temp.value;
  var allValid = true;
  if (checkStrCP.length < 12)
  { 
    alert ("El RFC debe tener mínimo 12 caracteres");
    Temp.value="";
    Temp.focus();
    return false;
  } 
  else
  {
    for (i = 0;  i < checkStrCP.length;  i++)
    {
      ch = checkStrCP.charAt(i);
      for (j = 0;  j < checkOKCP.length;  j++)
        if (ch == checkOKCP.charAt(j))
        {
          break;
		}
      if (j == checkOKCP.length)
      {
          allValid = false;
          break;
      }
    }
    if (!allValid)
    {
      alert("Sólo puedes teclear caracteres alfanuméricos en el RFC");
      Temp.value="";
      Temp.focus();
      return false;
    }
  }
}

// -----------------------------------------------------------------
// Function 	 : ValidaDatosTel
// Language 	 : JavaScript
// Description : Valida los datos tipo teléfono, fax o lada
// Copyright	 : (c) 2000 ILW 
// -----------------------------------------------------------------

function ValidaDatosTel(theForm,ElemName,ElemDesc)
{  
  var Temp = document.forms[theForm].elements[ElemName];
  
  if (Temp.value == "")
  {
   alert("Debes teclear un número en el campo "+ElemDesc);
   Temp.focus();
   return (false);
  }
  var checkOK = "0123456789 -()-";
  var checkStr = Temp.value;
  var allValid = true;
  for (i = 0;  i < checkStr.length;  i++)
  {
    ch = checkStr.charAt(i);
    for (j = 0;  j < checkOK.length;  j++)
      if (ch == checkOK.charAt(j))
      break;
    if (j == checkOK.length)
    {
    allValid = false;
      break;
    }
  }
  if (!allValid)
  {
    alert("Sólo puedes teclear números, espacios en blanco \y los caracteres \"()-\" en el campo "+ElemDesc);
    Temp.value="";
    Temp.focus();
    return (false);
  }
}

function IsDigit(theForm, ElemName)
{
  var Temp     = document.forms[theForm].elements[ElemName];
  var checkOK = "0123456789";
  var checkStr = Temp.value;
  var allValid = true;  
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
        {
          break;
	}
      if (j == checkOK.length)
      {
          allValid = false;
          break;
      }
    }
    if (!allValid)
    {
      alert("Sólo puede teclear números");
      Temp.value="";
      Temp.focus();
      return false;
    }  
}

function IsDigitDecimal(theForm, ElemName)
{
  var Temp     = document.forms[theForm].elements[ElemName];
  var checkOK = "0123456789.";
  var checkStr = Temp.value;
  var allValid = true;  
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
        {
          break;
	}
      if (j == checkOK.length)
      {
          allValid = false;
          break;
      }
    }
    if (!allValid)
    {
      alert("Sólo puede teclear números");
      Temp.value="";
      Temp.focus();
      return false;
    }  
}

function checkMaxLength (textarea, evt, maxLength) {
  if (textarea.selected && evt.shiftKey)
    // ignore shift click for select
    return true;
  var allowKey = false;
  if (textarea.selected && textarea.selectedLength > 0)
    allowKey = true;
  else {
    var keyCode =
      document.layers ? evt.which : evt.keyCode;
    if (keyCode < 32 && keyCode != 13)

      allowKey = true;

    else
      allowKey = textarea.value.length < maxLength;
  }
  textarea.selected = false;

  return allowKey;
}

function storeSelection (field) {
  if (document.all) {
    field.selected = true;

    field.selectedLength =
      field.createTextRange ?
        document.selection.createRange().text.length : 1;
  }
}

function ChecaValor(theForm, ElemName, NombreCampo)
	{
	  
	  var Temp = document.forms[theForm].elements[ElemName];
			  
	  if (Temp.value >32767)
	  {
		alert ("El valor del campo "+ NombreCampo + " sobrepasa el permitido")
		Temp.value="";
		Temp.focus();
		return false;
	  }
	  else
		return true;
	}


// -----------------------------------------------------------------
// Function 	 : PonCursor
// Language 	 : JavaScript
// Description : Pone el cursor en la caja de texto indicada al cargarse la pagina
// Copyright	 : (c) 2000 ILW 
// -----------------------------------------------------------------

function PonCursor(elCampo,theForm)
{
 document.forms[theForm].elements[elCampo].focus();
}


// -----------------------------------------------------------------
// Function 	 : IsNumTarjetaValid
// Language 	 : JavaScript
// Description : revisa que el numero de la tarjeta de credito sea
//               valido: solo numeros y entre 15 y 16 digitos. 
//							 Acepta espacios en blanco
// Copyright	 : (c) 2000 ILW 
// -----------------------------------------------------------------
function IsNumTarjetaValid(theForm)
{
  var checkOKTC = "0123456789 ";
  var checkStrTC = theForm.cNumTarjeta.value;
  var allValid = true;
  var NumDigitos = 0;
  var LongStrTC = checkStrTC.length


  if (LongStrTC < 15)
  { 
    alert ("El número de tarjeta debe de tener al menos 15 dígitos");
    theForm.cNumTarjeta.value="";
    theForm.cNumTarjeta.focus();
    return false;
  } 
  else
  {
    for (i = 0;  i < checkStrTC.length;  i++)
    {
      ch = checkStrTC.charAt(i);
	  if (ch != " ") NumDigitos = NumDigitos + 1;
      for (j = 0;  j < checkOKTC.length;  j++)
        if (ch == checkOKTC.charAt(j))
        {
          break;
		}
      if (j == checkOKTC.length)
      {
          allValid = false;
          break;
      }
	  
    }
    if (!allValid) 
    {
      alert("Sólo puedes teclear números para el Número de Tarjeta");
      theForm.cNumTarjeta.value="";
      theForm.cNumTarjeta.focus();
      return false;
    } 
    if (NumDigitos > 16) 
    {
      alert("El Número de Tarjeta puede tener máximo 16 dígitos");
      theForm.cNumTarjeta.value="";
      theForm.cNumTarjeta.focus();
      return false;
    } 
	if (NumDigitos < 15)
	{
	  alert("El Número de Tarjeta debe tener mínimo 15 dígitos");
      theForm.cNumTarjeta.value="";
      theForm.cNumTarjeta.focus();
      return false;
    } 
  }
}

// -----------------------------------------------------------------
// Function 	 : IsCSCValid
// Language 	 : JavaScript
// Description : Valida CSS 
// Copyright	 : (c) 2000 ILW 
// -----------------------------------------------------------------
function IsCSCValid(theForm)
{
  var checkOKTC = "0123456789 ";
  var checkStrTC = theForm.cCSC.value;
  var allValid = true;
  var NumDigitos = 0;
  var LongStrTC = checkStrTC.length
  var checkNumTC = theForm.iTipoTarjeta.value;


  /*if (LongStrTC < 3)
  { 
    alert ("El código de seguridad de la tarjeta debe de tener al menos 3 dígitos");
    theForm.cCSC.value="";
    theForm.cCSC.focus();
    return false;
  } 
  else
  {*/
    
    for (i = 0;  i < checkStrTC.length;  i++)
    {
      ch = checkStrTC.charAt(i);
	  if (ch != " ") NumDigitos = NumDigitos + 1;
      for (j = 0;  j < checkOKTC.length;  j++)
        if (ch == checkOKTC.charAt(j))
        {
          break;
		}
      if (j == checkOKTC.length)
      {
          allValid = false;
          break;
      }
	  
    }
    if (!allValid) 
    {
      alert("Sólo puedes teclear números para el código de seguridad de la tarjeta");
      theForm.cCSC.value="";
      theForm.cCSC.focus();
      return false;
    } 

    /*if (NumDigitos > 4) 
    {
      alert("El código de seguridad de la tarjeta puede tener máximo 4 dígitos");
      theForm.cCSC.value="";
      theForm.cCSC.focus();
      return false;
    } 
	if (NumDigitos < 3)
	{
	  alert("El código de seguridad de la tarjeta debe tener mínimo 3 dígitos");
      theForm.cCSC.value="";
      theForm.cCSC.focus();
      return false;
    }*/
    
    //Tarjeta de crédito tipo Visa o MasterdCard
    if ((checkNumTC == 1 || checkNumTC == 2) && (NumDigitos != 3))
    {
		alert("El código de seguridad de la tarjeta debe tener 3 dígitos");
		theForm.cCSC.value="";
		theForm.cCSC.focus();
		return false;	
    }
    
    //Tarjeta de crédito tipo American Express
    if ((checkNumTC == 0) && (NumDigitos != 4))
    {
		alert("El código de seguridad de la tarjeta debe tener 4 dígitos");
		theForm.cCSC.value="";
		theForm.cCSC.focus();
		return false;	
    }
    
  //}
}


// -----------------------------------------------------------------
// Function 	 : ValidaFechaCaducidad
// Language 	 : JavaScript
// Description : checa que la fecha de caducidad de la tc registrada
//               sea mayor que el mes y el año actual
// Copyright	 : (c) 2000 ILW 
// -----------------------------------------------------------------

function ValidaFechaCaducidad(theForm)
{
 var anioSelect = theForm.iAnioVence.selectedIndex; 
 var anioCaduca = theForm.iAnioVence.options[anioSelect].text;
 
 var mesCaduca =  theForm.iMesVence.selectedIndex;
 var laFecha = new Date();
 var MesActual = laFecha.getMonth();
 var AnioActual = laFecha.getYear();
   
 if (AnioActual > anioCaduca) 
 {
	alert ("La fecha de caducidad de la tarjeta de crédito no es válida, por favor corrígela");
	return (false);
 }
 else
 {
	if (AnioActual == anioCaduca)
	{
		if (MesActual > mesCaduca)
		{
			alert ("La fecha de caducidad de la tarjeta de crédito no es válida, por favor corrígela");
			return (false);
		}
		else
			 return (true);
	}
	else
		return (true);	
 } 
}

// -------------------------------------------------------------------
// Function 	 : popUp
// Language 	 : JavaScript
// Description : Abre la ventana para mostrar información relacionada
//				 con el Verisign
// Copyright	 : (c) 2000 ILW 
// -------------------------------------------------------------------
function popUp(url) 
{
	sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1,width=555,height=530');
	self.name = "mainWin"; 
}


// -------------------------------------------------------------------
// Function 	 : openWin
// Language 	 : JavaScript
// Description : Abre la ventana para mostrar información relacionada
//				 con ayuda del cotizador en línea
// Copyright	 : (c) 2000 ILW 
// -------------------------------------------------------------------

function openWin(value,wval,hval) 
	{
	window.open(value,'popup','resizable=no,width=' + wval + ',height=' + hval + ',status=no,location=no,toolbar=no,menubar=no,scrollbars=yes');
	}	


// -------------------------------------------------------------------
// Function 	 : IsRealOk
// Language 	 : JavaScript
// Description : Valida que solo se tecleen valores numericos reales
// Copyright	 : (c) 2000 ILW 
// -------------------------------------------------------------------

function IsRealOk(theForm,theReg)
{

  var checkOK = "0123456789.";
  var Temp = document.forms[theForm].elements[theReg]
  checkStr = Temp.value
  var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
        {
          break;
		}
      if (j == checkOK.length)
      {
          allValid = false;
          break;
      }
    }
    if (!allValid)
    {
      alert("Sólo puedes teclear una cantidad");
      Temp.value="";
      Temp.focus();
      return false;
    }  
}

// -------------------------------------------------------------------
// Function 	 : IsEnteroOk
// Language 	 : JavaScript
// Description : Valida que solo se tecleen valores numericos enteros
// Copyright	 : (c) 2000 ILW 
// -------------------------------------------------------------------

function IsEnteroOk(theForm)
{
  var checkOK = "0123456789";
  var checkStr = theForm.Cantidad.value;
  var allValid = true;
    for (i = 0;  i < checkStr.length;  i++)
    {
      ch = checkStr.charAt(i);
      for (j = 0;  j < checkOK.length;  j++)
        if (ch == checkOK.charAt(j))
        {
          break;
		}
      if (j == checkOK.length)
      {
          allValid = false;
          break;
      }
    }
    if (!allValid)
    {
      alert("Sólo puedes teclear números enteros en la cantidad");
      theForm.Cantidad.value=1;
      theForm.Cantidad.focus();
      return false;
    }
  
}


// -----------------------------------------------------------------
// Function 	 : ChecaAsunto
// Language 	 : JavaScript
// Description   : Según el tema que se selecciona, se pregunta por el número
//				   de la operación, y se asigna ya sea el valor de este a un 				
//				   campo del formulario o si no hay número de oper. el valor 0
// Copyright	 : (c) 2000 ILW 
// -----------------------------------------------------------------
function ChecaAsunto(theForm)
{
  var AsuntoValue = theForm.cAsunto.value;  
  var respuesta;
    
  if (AsuntoValue=="Fallas" || AsuntoValue=="Informes" || AsuntoValue=="Envio" || AsuntoValue=="Importacion" || AsuntoValue=="Queja" || AsuntoValue=="Operacion" || AsuntoValue=="Otro")
  {
    respuesta=prompt("Si su mensaje está asociado a una operación, favor de teclear el número de operación","0");           
    theForm.cNumOper.value=respuesta;          
    if ((respuesta==null) || (respuesta==""))
    {
		theForm.cNumOper.value = "0";
	}	
  }
  else{
		theForm.cNumOper.value = "0";} 	 
}

// -------------------------------------------------------------------
// Function 	 : MM_openBrWindow
// Language 	 : JavaScript
// Description : Abre la ventana para mostrar información relacionada
//				 con el Verisign
// Copyright	 : (c) 2000 ILW 
// -------------------------------------------------------------------

function MM_openBrWindow(theURL,winName,features) 
{	 //v2.0
	window.open(theURL,winName,features);
}


// -------------------------------------------------------------------
// Function 	 : openWinResizable
// Language 	 : JavaScript
// Description : Abre sobre una ventana padre una popup hija y se 
//				 se reajusta el tamaño de la ventana popup
// Copyright	 : (c) 2000 ILW
// Fecha         : 18 Abril 2008
// -------------------------------------------------------------------

function openWinResizable(value,wval,hval) 
{
   // Abre popup hija sobre padre 	
   window.open(value,'popup','resizable=no,status=no,location=no,toolbar=no,menubar=no,scrollbars=yes');
   
   // Se reajusta tamaño de popup hija
   window.resizeTo(wval,hval);	
}


// -----------------------------------------------------------------
// Function 	 : Alerta
// Language 	 : JavaScript
// Description : Checa si en formulario hay campos requeridos en blanco 
// Copyright	 : (c) 2000 ILW 
// -----------------------------------------------------------------

function alerta(theForm)
{
  if (theForm.txtNumeroCliente.value == "")
	 {alert("Si usted tiene un número de cliente, favor de introducirlo");}
	 document.FormaCorreo.txtNumeroCliente.focus();
}

// --------------------------------------------------------------------------------
// Function 	 : FechasOk
// Language 	 : JavaScript
// Description : Valida la fecha inicial y final
// --------------------------------------------------------------------------------
function FechasOk(theForm,ElemName1,ElemName2,ElemName3,ElemName4,ElemName5,ElemName6)
{	
	var MsgError = "La Fecha Inicial es incorrecta \n\n";
	var MsgError2 = "La Fecha Final es incorrecta \n\n";
	var Error = false;
	
	var Temp = document.forms[theForm].elements[ElemName1];
	var dia = Temp.selectedIndex;
	dia = Temp.options[dia].value;
	
	Temp = document.forms[theForm].elements[ElemName2];
	var mes = Temp.selectedIndex;
	mes = Temp.options[mes].value;
	
	Temp = document.forms[theForm].elements[ElemName3];
	var anio = Temp.selectedIndex;
	anio = Temp.options[anio].value;
	
	var Temp = document.forms[theForm].elements[ElemName4];
	var dia2 = Temp.selectedIndex;
	dia2 = Temp.options[dia2].value;
	
	Temp = document.forms[theForm].elements[ElemName5];
	var mes2 = Temp.selectedIndex;
	mes2 = Temp.options[mes2].value;
	
	Temp = document.forms[theForm].elements[ElemName6];
	var anio2 = Temp.selectedIndex;
	anio2 = Temp.options[anio2].value;
	
	// Validación Fecha Inicial
	if( dia == "" && mes == "" && anio == "" )
		Error = true;
	else {
		dia = parseInt(dia);
		mes = parseInt(mes);
		anio = parseInt(anio);
		
		if( !isNaN(dia) && !isNaN(mes) && !isNaN(anio) && dia >= 1 && anio >= 1900) 
		{
			// Meses de 31 dias 
			if( ( mes == 1 || mes== 3 || mes == 5 || mes == 7 || mes == 8 || mes == 10 || mes == 12) && dia > 31) 
				Error = true;			

			// Meses de 30 dias 
			if((mes == 4 || mes == 6 || mes == 9 || mes == 11)	&& dia > 30)
				Error = true;			

			// Febrero y bisiestos. 
			if( mes == 2 && ( dia > 29 ||( dia == 29 && ((anio % 400 != 0) && ((anio % 4 != 0) || (anio % 100 == 0)))))) 
				Error = true;			
		
			if (Error)	
				MsgError = MsgError + "- El número de días no corresponden al mes \n";				
		
		}
		else 
			Error = true;
	}	
	
	// Validación Fecha Final
	if (Error)
		alert(MsgError);
	else
	{
		if( dia2 == "" && mes2 == "" && anio2 == "" )
			Error = true;
		else 
		{	
			dia2 = parseInt(dia2);
			mes2 = parseInt(mes2);
			anio2 = parseInt(anio2);
				
			if( !isNaN(dia2) && !isNaN(mes2) && !isNaN(anio2) && dia2 >= 1 && anio2 >= 1900) 
			{
				// Meses de 31 dias 
				if( ( mes2 == 1 || mes2== 3 || mes2 == 5 || mes2 == 7 || mes2 == 8 || mes2 == 10 || mes2 == 12) && dia2 > 31) 
					Error = true;			

				// Meses de 30 dias 
				if((mes2 == 4 || mes2 == 6 || mes2 == 9 || mes2 == 11)	&& dia2 > 30)
					Error = true;			

				// Febrero y bisiestos 
				if( mes2 == 2 && ( dia2 > 29 ||( dia2 == 29 && ((anio2 % 400 != 0) && ((anio2 % 4 != 0) || (anio2 % 100 == 0)))))) 
					Error = true;			
			
				if (Error)	
					MsgError2 = MsgError2 + "- El número de días no corresponden al mes \n";				
			
			}
			else 
				Error = true;
		}	
		
		
		if (Error)
			alert(MsgError2);
		else
		{			
			dia2 = parseInt(dia2);
			mes2 = parseInt(mes2);
			anio2 = parseInt(anio2);
			MsgError = "Fecha incorrecta \n\n";
			
			// Si el año de inicio es igual al final
			if(anio == anio2)
			{
				// Mes inicial debe ser menor al final
				if(mes > mes2)
				{
					Error = true;
					MsgError = MsgError + "- El mes inicial debe ser menor o igual al mes final\n";
				}
					
				// Si el mes es el mismo entonces, verifica si el día inicial es mayor al actual
				if(mes == mes2)
				{		
					if (dia > dia2)
					{
						Error = true;
						MsgError = MsgError + "- El día inicial debe ser menor o igual al día final\n";
					}
				}
			}
			else
			{
				// El año de inicio no debe ser mayor al año final
				if(anio > anio2)
				{
					Error = true;
					MsgError = MsgError + "- El año inicial debe ser menor o igual al final\n";
				}
			}
			
			if (Error)
			{
				alert(MsgError);
				return (false);
			}
			else
				return (true);
		}
	}
}

function hint(s) {
  window.status = (s ? s : '')
  return true
}

//**********************************************************************
// Empresa: Sitios Interactivos de Comercio E. S. A. de C. V.
// Nombre: BloqueaEnter
// Proposito: Bloquea el uso de la tecla Enter
// Entradas: Tecla tecleada desde teclado
//**********************************************************************

function BloqueaEnter(e) 
{
  return (e.keyCode!=13);
}

function checaValidos (textarea, evt) {
  var allowKey = false;
	  
    var keyCode =
      document.layers ? evt.which : evt.keyCode;

	if (((keyCode >= 48) && (keyCode <= 57)) || ((keyCode >= 65) && (keyCode <= 90)) || ((keyCode >= 97) && (keyCode <= 122)) || ((keyCode == 8)) || ((keyCode == 46)) || ((keyCode == 9)) || ((keyCode == 36)))
	{		  
      allowKey = true;			
	}
	else
	{
	  allowKey = false;
	}
		
  return allowKey;
}

// -----------------------------------------------------------------
// Function 	 : NoAtras
// Language 	 : JavaScript
// Description   : Deshabilita el botón Atras del Browser	
// -----------------------------------------------------------------
function NoAtras()
{				
	history.go(1)
}


// -------------------------------------------------------------------
// Function 	 : closeOpenWin
// Language 	 : JavaScript
// Description   : Cierra ventana pop up hija y abre una ventana padre 
//                 nueva con todas las propiedades activas de la ventana 
// Fecha         : 23 Junio 2008
// -------------------------------------------------------------------

function closeOpenWin(theURL,wval,hval) 
{
	window.parent.close();
	window.open(theURL,'popup','resizable=yes,width=' + wval + ',height=' + hval + ',status=yes,location=yes,toolbar=yes,menubar=yes,scrollbars=yes');
}	


// ----------------------------------------------------------------------------
// Function 	 : OpenCCs
// Language 	 : JavaScript
// Description   : Permite conexión a callcenter de mlkk a través de hellohelp
//                 para realizar el soporte en línea a los clientes
// ----------------------------------------------------------------------------

function OpenCCs(http,callcenters,hhlang,referer,pwd,rows,cc,un,dni,custid,email) {
     browserVer = parseInt(navigator.appVersion);
     if(browserVer>2 )
	if (callcenters=='1') {	
		hWnd=window.open(http+'userlogin.php?custid='+custid+'&langkey='+hhlang+'&email='+email+'&dni='+dni+'&referer='+referer+'&pwd='+pwd+'&rows='+rows+'&un='+un+'&cc=&EN','','hotkeys=no,screenX=0,screenY=0,left=0,top=0,width=260,height=380,scrollbars=yes');
     } else {
		window.open(http+'fm_userlogin.php?cust_id='+custid+'&langkey='+hhlang+'&email='+email+'&dni='+dni+'&referer='+referer+'&pwd='+pwd+'&rows='+rows+'&un='+un+'&cc='+cc+'&EN','','hotkeys=no,screenX=0,screenY=0,left=0,top=0,width=260,height=380,scrollbars=yes');
     }
}


// ---------------------------------------------------------
// Function 	 : openWinMedidoConBarra
// Language 	 : JavaScript
// Description : SE cierra ventana popup y se abre una nueva
// ---------------------------------------------------------
function openWinMedidoConBarra(value,wval,hval) 
{
	//Se cierra la ventanita
	window.close();
	//Abrimos nueva ventana
	window.open(value,'popup','resizable=yes, width=' + wval + ',height=' + hval + ',status=yes,location=yes,toolbar=yes,menubar=yes,scrollbars=yes');
}

// ---------------------------------------
// Function 	 : OcultarBloque
// Language 	 : JavaScript
// Description : Oculta la capa designada
// ---------------------------------------
function OcultarBloque(bloque) 
{
	var elementos = document.getElementsByName(bloque);
		
	for (k = 0; k< elementos.length; k++) 
	{
		elementos[k].style.display = "none";
	}
}

// ------------------------------------------------------------------------------------
// Código para visualizar imagen alusiva a la categoria sobre la que se posicion cursor 

// Function 	 : nombre
// Language 	 : JavaScript
// Description : Nombre de la capa que
//               oculta imagen que se muestra
//               con onmouseover u onclick.
// ------------------------------------------
function nombre() 
{
	Image_Name = "showpad";
}	

// -------------------------------------------------------
// Function 	 : showImage
// Language 	 : JavaScript
// Description : Muestra imagen con onmouseover u onclick.
// -------------------------------------------------------
function showImage(filename) 
{	    
	nombre();
	document.images[Image_Name].src = filename;
}

// -------------------------------------------------------
// Function 	 : changeImgOut
// Language 	 : JavaScript
// Description : Oculta imagen con onmouseover u onclick.
// -------------------------------------------------------					
function changeImgOut(filename)
{ 						
	nombre();
	document.images[Image_Name].src = filename;
}

// ------------------------------------------------------------------------------------
	

function IsCURPOk(FormName,ElemName)
{
  var Temp = document.forms[FormName].elements[ElemName];
  var checkCURP = Temp.value;
  
  if (Temp.value.length != 18)
  { 
    alert ("El CURP debe de tener 18 dígitos");
    Temp.value="";
    Temp.focus();
    return (false);
  } 
}

// -----------------------------------------------------------------
// Function    : IsWebValid
// Language    : JavaScript
// Description : Checa si el URL es valido
// Copyright   : (c) 1998 Shawn Dorman -> Modificado por Jose Luis Olvera
// http://www.goodnet.com/~sdorman/web/IsWebValid.html
// -----------------------------------------------------------------
// Ver    Date    Description of modification
// --- ---------- --------------------------------------------------
// 1.0 09/04/1996 Original write
// 1.1 09/30/1998 CHG: Use standard header format
// -----------------------------------------------------------------
// Source: Webmonkey Code Library
// (http://www.hotwired.com/webmonkey/javascript/code_library/)
// -----------------------------------------------------------------

function IsWebValid(FormName,ElemName)
{
var EmailOk  = true
var Temp     = document.forms[FormName].elements[ElemName]
var AtSym    = Temp.value.indexOf('www')
var Http     = Temp.value.indexOf('http://')
var BadHttp  = Temp.value.indexOf(' ')
var Period   = Temp.value.lastIndexOf('.')
var Space    = Temp.value.indexOf(' ')
var Length   = Temp.value.length - 1   // Array is from 0 to length-1
if ( 
     //(AtSym < 1) ||         // 'www' cannot be in first position     
     (Period <= AtSym+1) || // Must be atleast 1 valid char btwn 'www' and '.' 
     (Period == Length ) || // Must be atleast one valid char after '.' 
     (Space  != -1) )       // No empty spaces permitted
    {       
      alert(" La dirección de web es inválida !")
         {
	    Temp.value="";
            Temp.focus();             
            return false;
          }
    }                         
return true;
}   

	
//-->
