
function validar(prm){
	if(prm.username.value == ''){
		alert("Escriba el USUARIO ");
		prm.username.focus();
		return false;
	}
	
	if(prm.password.value == ''){
		alert("Escriba la CLAVE DE ACCESO");
		prm.password.focus();
		return false;
	}
}


function checkbankstep2(){

by = document.form.byear.value;

if (document.form.byear.value =='' ) {
 alert("Año de Nacimiento Requerido (ej.: 1965)");
return false;
}
if (document.form.byear.value.length != 4 ) {
 alert("Año de nacimiento debe ser de 4 digitos (ej.: 1965)");
return false;
}
if (document.form.byear.value < 1920 ) {
 alert("Año de nacimiento debe de ser manor de 1920");
return false;
}
if (document.form.byear.value > 2004 ) {
 alert("Año de nacimiento debe de ser mayor de 2004");
return false;
}
if(document.form.address.value == ''){
alert("Dirección Requerida");
return false;
	}
if(document.form.city.value == ''){
alert("Ciudad Requerida");
return false;
	}
if(document.form.countrycode.value == ''){
alert("País Requerido");
return false;
	}
if(document.form.telephone.value == ''){
alert("Telefono Requerido");
return false;
	}
if(document.form.telephone.value.length < 6 ){
alert("Teléfono debe de ser más de 6 digitos");
return false;
	}

 for (var i=0; i < form.telephone.value.length; i++)
    {
    	var ch = form.telephone.value.substring(i, i+1);
        if (ch < "0" || ch > "9") 
     {
        alert("Teléfono deben de ser numeros (0 - 9)");
        return false;
	}
   }
	
	
if(document.form.email.value == ''){
alert("eMail Requerido");
return false;
	}

// check for spaces
/*
----- check for spaces which are invalid -----
*/
var sp = form.email.value.indexOf(" ")
if (sp != -1) {
    alert("eMail Invalido")

    form.email.focus();
    return false
   }

/*
----- is there a @ ?-----
*/
var str = form.email.value.indexOf("@")
var c = str+1
if (str == -1) {
    alert("eMail Invalido")
    form.email.focus();
    return false
   }
/*
----- is there a period? -----
*/
var pr = form.email.value.indexOf(".",str)
if (pr == -1) {
    alert("eMail Invalido")
    form.email.focus();
    return false
   }
/*
----- are there at least 2 characters between the @ and . -----
*/

if (pr - str - 1 < 2) {
  alert("eMail Invalido")
   return false
}

/*
----- are there at least 2 characters after the period? -----
*/
var x = form.email.value.length - pr -1
if ( x < 2 ) {
  alert("eMail Invalido")
   return false
}
}


function valpm(prm){
	if(prm.PromoCodeID1.value == ''){
		alert('Escriba el PRIMER segmento de la Tarjeta Prepagada');
		return false;
	}
	
	if(prm.PromoCodeID2.value == ''){
		alert('Escriba el SEGUNDO segmento de la Tarjeta Prepagada');
		return false;
	}
	
	if(prm.PromoCodeID3.value == ''){
		alert('Escriba el TERCERO segmento de la Tarjeta Prepagada');
		return false;
	}
	if(prm.serialno.value == ''){
		alert('Escriba el NUMERO DE SERIE de la Tarjeta Prepagada');
		return false;
	}
	
}

function openwin(param1,param2,param3)
{
	var Win = window.open(param1,param2,param3);
}

function samecc() {
	if(form.ccid.value == ''){
	}
	else{
		gotourl = "pago_tc.cfm?samecc=1&ccid=" + form.ccid.value;
		location.replace(gotourl);
	}
}


function checkbankstep3(){


if(document.form.ccnumber.value == ''){
alert("Numero de Tarjeta Requerido");
return false;
	}
if(document.form.ccnumber.value.length < 15 ){
alert("Numero de Tarjeta debe de ser más de 16 digitos");
return false;
	}

 for (var i=0; i < form.ccnumber.value.length; i++)
    {
    	var ch = form.ccnumber.value.substring(i, i+1);
        if (ch < "0" || ch > "9") 
     {
        alert("Numero de Tarjeta deben de ser numeros (0 - 9)");
        return false;
	}
   }
	
if(document.form.ccnameoncard.value == ''){
alert("Nombre en Tarjeta Requerido");
return false;
	}

if(document.form.ccv.value.length < 3 ){
alert("Numero de Securidad o CCV Requerido\nTres últimos dígitos en la parte trasera de su tarjeta");
return false;
	}
	
	 for (var i=0; i < form.ccv.value.length; i++)
    {
    	var ch = form.ccv.value.substring(i, i+1);
        if (ch < "0" || ch > "9") 
     {
        alert("Numero de Securidad o CCV debe de ser numeros (0 - 9)");
        return false;
	}
   }

///if(document.form.accettac.checked == false){
///alert("Aceptar Terminos y Condiciones de la Tarjeta de Credito Requerido!");
///return false;
///	}
	
 }
 
 
 var cod = 0;
/// valida que el event.keycode sea de una letra aA o de numeros
function validarAlpha(param,obj,nobj){
	varint = obj.value.toString();
	
	if( ((param < 48) || (param > 57)) && (param != 8) && (param != 9) && ((param < 65) || (param > 90)) && ((param  < 97) || (param > 122)))
	{	event.returnValue = false;	}
	
	if((varint.length == 4)){
		if(cod = 0){
			nobj.focus();
			cod = 1;
		}
		else{
			nobj.focus();
			cod = 0;		
		}
	}
	
}

function validarAlpha2(param){
	if( ((param < 48) || (param > 57)) && (param != 8) && (param != 9) && ((param < 65) || (param > 90)) && ((param  < 97) || (param > 122)))
	{	event.returnValue = false;	}
}

/// valida que el event.keycode sea de numeros
function validarNumeros(param){
	if( ((param < 48) || (param > 57)) && (param != 8) && (param != 9)) {event.returnValue = false;}
}


function terms(){
if(document.form.accettac.checked == '' ){
alert("Aceptar terminos y condiciones es necesario para continuar el proceso de pago");
return false;
}
}

function goURL(prm){

	if(prm.value != ""){
		frm.submit();
		return true;
	}
	else
		return false;	
}

function gotoPagefromChart(prm,prm2,prm3){
	frm.action = 'det_accesos.cfm';
	frm.ITEMLABEL.value = prm;
	frm.VALUE.value = prm2;
	frm.rango.value = prm3;
	frm.submit();
}

function pviiW3Cbg(obj, pviiColor) { //v1.1 by Project VII
	obj.style.backgroundColor=pviiColor
}

function validarEmail(param){
	if( ((param < 48) || (param > 57)) && (param != 8) && (param != 9) && (param != 45) && (param != 46) && (param != 64) && (param != 95) && ((param < 65) || (param > 90)) && ((param  < 97) || (param > 122)))
	{	event.returnValue = false;	}
}