
function popupbann(url,target,w,h) {
	if(w==null) var w = 550;
	if(h==null) var h = 500;
	miPopup = window.open(url,target,'scrollbars=yes,titlebar=yes,top=30,left=30,width='+w+',height='+h);
 miPopup.opener=self; 
}

function ValidaLoguin(form) 
{ 
	if (document.formC.Reg_Mail.value==""){ 
		alert("Please, insert a valid E-mail account"); 
		document.formC.Reg_Mail.focus(); 
		return(false); 
	} 
 
	var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-@."; 
	var checkStr = document.formC.Reg_Mail.value; 
	var allValid = true; 
	var decPoints = 0; 
	var allNum = ""; 
	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; 
	   } 
	   allNum += ch; 
	 } 
 
	 if (!allValid) 
	 { 
	  alert("Please, insert a valid E-mail account"); 
	   document.formC.Reg_Mail.focus(); 
	   return (false); 
	  } 
		TieneArroba = false; 
		for (i = 0;  i < document.formC.Reg_Mail.value.length;  i++) 
		{ 
			if (document.formC.Reg_Mail.value.charAt(i) == "@") 
			{ 
				TieneArroba = true; 
			} 
		} 
		if (!TieneArroba) 
		{ 
			alert("Please, insert a valid E-mail account"); 
			document.formC.Reg_Mail.focus(); 
			return false; 
		} 

	var checkOK2 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890"; 
	var checkStr2 = document.formC.Reg_Pass.value; 
	var allValid2 = true; 
	var decPoints2 = 0; 
	var allNum2 = ""; 
	for (i = 0;  i < checkStr2.length;  i++) 
	 { 
	   for (j = 0;  j < checkOK2.length;  j++) 
	   if (j == checkOK2.length) 
	   { 
	     allValid2 = false; 
	     break; 
	   } 
	 } 

	if (!allValid2) 
	  { 
	  alert("Please, insert your password"); 
	   document.formC.Reg_Pass.focus(); 
	   return (false); 
	  } 
 
	if (document.formC.Reg_Pass.value=="")	{ 
		alert("Please, insert your password."); 
		document.formC.Reg_Pass.focus(); 
		return (false); 
	} 
 }
function ValidaForgot(form) 
{ 
	if (document.formB.Reg_Mail.value==""){ 
		alert("Please, insert a valid E-mail account"); 
		document.formB.Reg_Mail.focus(); 
		return(false); 
	} 
 
	var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-@."; 
	var checkStr = document.formB.Reg_Mail.value; 
	var allValid = true; 
	var decPoints = 0; 
	var allNum = ""; 
	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; 
	   } 
	   allNum += ch; 
	 } 
 
	 if (!allValid) 
	 { 
	  alert("Please, insert a valid E-mail account"); 
	   document.formB.Reg_Mail.focus(); 
	   return (false); 
	  } 
		TieneArroba = false; 
		for (i = 0;  i < document.formB.Reg_Mail.value.length;  i++) 
		{ 
			if (document.formB.Reg_Mail.value.charAt(i) == "@") 
			{ 
				TieneArroba = true; 
			} 
		} 
		if (!TieneArroba) 
		{ 
			alert("Please, insert a valid E-mail account"); 
			document.formB.Reg_Mail.focus(); 
			return false; 
		} 
 }
function Validaequal(form) 
{ 
	if (document.formD.cphn.value=="")	{ 
		alert("Please, insert your Cell Phone."); 
		document.formD.cphn.focus(); 
		return (false); 
	} 
	if (document.formD.cphn.value!=document.formD.cphn2.value)	{ 
		alert("Cell Phones are different."); 
		document.formD.cphn.focus(); 
		return (false); 
	} 
	if (document.formD.cellPreffix.value=="")	{ 
		alert("Please, select the prefix of your mobile."); 
		document.formD.cellPreffix.focus(); 
		return (false); 
	} 
	if (document.formD.cellPreffix.value!=document.formD.cellPreffix2.value)	{ 
		alert("Invalid prefix, please correct it."); 
		document.formD.cellPreffix.focus(); 
		return (false); 
	}
} 
  
function ValidaPayment(form) 
{ 
	try {
		if (document.formD.typecc.checked && document.formD.typecc.value=='old') {
			if(document.formD.cardCvv_old.value=='')	{ 
				alert("You have to add a Cvv code."); 
				document.formD.cardCvv_old.focus(); 
				return (false); 
			}
		} else if (document.formD.typecc.checked && document.formD.typecc.value=='new') {
			if(document.formD.avsAddress.value=='')	{ 
				alert("You have to add the address."); 
				document.formD.avsAddress.focus(); 
				return (false); 
			}
			if(document.formD.avsZip.value=='')	{ 
				alert("You have to add the Zip code."); 
				document.formD.avsZip.focus(); 
				return (false); 
			}
			if(document.formD.cardHolder.value=='')	{ 
				alert("You have to add the card holder name."); 
				document.formD.cardHolder.focus(); 
				return (false); 
			}
			if(document.formD.cardNumber.value=='')	{ 
				alert("You have to add the card number."); 
				document.formD.cardNumber.focus(); 
				return (false); 
			}
			if(document.formD.cardCvv.value=='')	{ 
				alert("You have to add a Cvv code."); 
				document.formD.cardCvv.focus(); 
				return (false); 
			}
		}
	} catch (ex) { }
  } 

function ValidaPaymentOC(form) 
{ 
	try {
		if (document.formD.voucherCode.value.length < 15) {
			alert("Please write your voucher code."); 
			document.formD.voucherCode.focus(); 
			return (false); 
		}
	} catch (ex) { }
}
  
function Validavacios(form,type) 
{ 
	if (document.formA.Reg_Mail.value==""){ 
		alert("Please, insert a valid E-mail account"); 
		document.formA.Reg_Mail.focus(); 
		return(false); 
	} 
 
	var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-@."; 
	var checkStr = document.formA.Reg_Mail.value; 
	var allValid = true; 
	var decPoints = 0; 
	var allNum = ""; 
	var type = type; 
	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; 
	   } 
	   allNum += ch; 
	 } 
 
	 if (!allValid) 
	 { 
	  alert("Please, insert a valid E-mail account"); 
	   document.formA.Reg_Mail.focus(); 
	   return (false); 
	  } 
		TieneArroba = false; 
		for (i = 0;  i < document.formA.Reg_Mail.value.length;  i++) 
		{ 
			if (document.formA.Reg_Mail.value.charAt(i) == "@") 
			{ 
				TieneArroba = true; 
			} 
		} 
		if (!TieneArroba) 
		{ 
			alert("Please, insert a valid E-mail account"); 
			document.formA.Reg_Mail.focus(); 
			return false; 
		} 
 
  if (type==1) {
	if (document.formA.Reg_Mail.value!=document.formA.Reg_Mail_Conf.value)	{ 
		alert("The email addresses are different."); 
		document.formA.Reg_Mail.focus(); 
		return (false); 
	} 

	var password = document.formA.Reg_Pass.value;
	var passed = validatePassword(password, {
	length:   [8, 20],
	lower:    1,
	upper:    0,
	numeric:  1,
	special:  0,
	badWords: ["password", "steven", "levithan"],
	badSequenceLength: 4
	});
	
	if(passed != true) {
		alert("Please, insert a valid password."); 
		document.formA.Reg_Pass.focus(); 
		return (false); 	
	}

 
	if (document.formA.Reg_Pass.value=="")	{ 
		alert("Please, insert your password."); 
		document.formA.Reg_Pass.focus(); 
		return (false); 
	} 
 
	if (document.formA.Reg_Pass.value!=document.formA.Reg_Pass_Conf.value)	{ 
		alert("The passwords are different."); 
		document.formA.Reg_Pass.focus(); 
		return (false); 
	} 
 
  } 
  if (type=='4') {
	if (document.formA.Reg_Pass.value!=document.formA.Reg_Pass_Conf.value)	{ 
		alert("The passwords are different."); 
		document.formA.Reg_Pass.focus(); 
		return (false); 
	} 
 
  } 
  if (type=='2' || type=='4') {
	if (document.formA.Reg_FirstName.value=="")	{ 
		alert("Please, complete your name field."); 
		document.formA.Reg_FirstName.focus(); 
		return (false); 
	} 
 
	if (document.formA.Reg_LastName.value=="")	{ 
		alert("Please, complete your lastname field."); 
		document.formA.Reg_LastName.focus(); 
		return (false); 
	} 
 
	if (document.formA.Reg_Dia_Nac.value=="")	{ 
		alert("Please complete your birth date."); 
		document.formA.Reg_Dia_Nac.focus(); 
		return (false); 
	} 
 
	if (document.formA.Reg_Mes_Nac.value=="")	{ 
		alert("Please complete your birth date."); 
		document.formA.Reg_Mes_Nac.focus(); 
		return (false); 
	} 
 
	if (document.formA.Reg_Anio_Nac.value=="")	{ 
		alert("Please complete your birth date."); 
		document.formA.Reg_Anio_Nac.focus(); 
		return (false); 
	} 
 
	if (!document.formA.Reg_Sexo[0].checked && !document.formA.Reg_Sexo[1].checked)	{ 
		alert("Please select your gender."); 
		document.formA.Reg_Sexo[0].focus(); 
		return (false); 
	} 

 
	if (document.formA.Reg_Loc_ID.value=="")	{ 
		alert("Please complete your City."); 
		document.formA.Reg_Loc_ID.focus(); 
		return (false); 
	} 
 
	if (document.formA.Reg_Address.value=="")	{ 
		alert("Please complete your Address."); 
		document.formA.Reg_Address.focus(); 
		return (false); 
	} 
	
	if (document.formA.Reg_CP.value=="")	{ 
		alert("Please complete your Zip."); 
		document.formA.Reg_CP.focus(); 
		return (false); 
	} 
	 
	if (document.formA.Reg_CellPhone.value=="" || document.formA.Reg_CellPhone.value.length<10)	{ 
		alert("Please, insert your Cell Phone."); 
		document.formA.Reg_CellPhone.focus(); 
		return (false); 
	} 
 
  } 
  if (type=='3') {
  	
  	if (document.formA.Reg_Curr_ID.value==-1)	{ 
		alert("Please, select the currency."); 
		document.formA.Reg_Curr_ID.focus(); 
		return (false); 
	} 
	
	if (document.formA.Reg_SecretA.value=="")	{ 
		alert("Please, insert the secret answer."); 
		document.formA.Reg_SecretA.focus(); 
		return (false); 
	} 
	try { $captcha = document.getElementsByName('recaptcha_response_field')[0] } catch (ex) { $captcha = null }
	if ($captcha) {
		if ($captcha.value=="")	{ 
			alert("You have to complete the secure verification code."); 
			$captcha.focus(); 
			return (false); 
		}
		try {
			document.getElementById("Reg_CaptchaChallenge").value = document.getElementsByName('recaptcha_challenge_field')[0].value;
			document.getElementById("Reg_CaptchaResponse").value = $captcha.value;
		} catch (ex) { }
	}
	if (!document.formA.Reg_Accept.checked)	{ 
		alert("You have to accept terms & conditions."); 
		document.formA.Reg_Accept.focus(); 
		return (false); 
	} 
 
  } 
} 

function ValidaActive(form) {
	
	if (document.formA.Reg_Mail.value==""){ 
		alert("Please, insert a valid E-mail account"); 
		document.formA.Reg_Mail.focus(); 
		return(false); 
	} 
 
	var checkOK = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890_-@."; 
	var checkStr = document.formA.Reg_Mail.value; 
	var allValid = true; 
	var decPoints = 0; 
	var allNum = ""; 
	var type = type; 
	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; 
	   } 
	   allNum += ch; 
	 } 
 
	 if (!allValid) 
	 { 
	  alert("Please, insert a valid E-mail account"); 
	   document.formA.Reg_Mail.focus(); 
	   return (false); 
	  } 
		TieneArroba = false; 
		for (i = 0;  i < document.formA.Reg_Mail.value.length;  i++) 
		{ 
			if (document.formA.Reg_Mail.value.charAt(i) == "@") 
			{ 
				TieneArroba = true; 
			} 
		} 
		if (!TieneArroba) 
		{ 
			alert("Please, insert a valid E-mail account"); 
			document.formA.Reg_Mail.focus(); 
			return false; 
		} 
 	
	if (document.formA.Reg_SecretA.value=="")	{ 
		alert("Please, insert the secret answer."); 
		document.formA.Reg_SecretA.focus(); 
		return (false); 
	} 
	if (document.formA.Reg_Captcha.value=="")	{ 
		alert("You have to complete the secure verification code."); 
		document.formA.Reg_Captcha.focus(); 
		return (false); 
	} 
	
}

 function irPagina(pag)
 {
 	document.frmPag.pagina.value	= pag;
 	document.frmPag.action		= location.href;
 	document.frmPag.submit();
 }
 
 
function validatePassword (pw, options) {
	// default options (allows any password)
	var o = {
		lower:    0,
		upper:    0,
		alpha:    0, /* lower + upper */
		numeric:  0,
		special:  0,
		length:   [8, 20],
		custom:   [ /* regexes and/or functions */ ],
		badWords: [],
		badSequenceLength: 0,
		noQwertySequences: false,
		noSequential:      false
	};

	for (var property in options)
		o[property] = options[property];

	var	re = {
			lower:   /[a-z]/g,
			upper:   /[A-Z]/g,
			alpha:   /[A-Z]/gi,
			numeric: /[0-9]/g,
			special: /[\W_]/g
		},
		rule, i;

	// enforce min/max length
	if (pw.length < o.length[0] || pw.length > o.length[1])
		return false;

	// enforce lower/upper/alpha/numeric/special rules
	for (rule in re) {
		if ((pw.match(re[rule]) || []).length < o[rule])
			return false;
	}

	// enforce word ban (case insensitive)
	for (i = 0; i < o.badWords.length; i++) {
		if (pw.toLowerCase().indexOf(o.badWords[i].toLowerCase()) > -1)
			return false;
	}

	// enforce the no sequential, identical characters rule
	if (o.noSequential && /([\S\s])\1/.test(pw))
		return false;

	// enforce alphanumeric/qwerty sequence ban rules
	if (o.badSequenceLength) {
		var	lower   = "abcdefghijklmnopqrstuvwxyz",
			upper   = lower.toUpperCase(),
			numbers = "0123456789",
			qwerty  = "qwertyuiopasdfghjklzxcvbnm",
			start   = o.badSequenceLength - 1,
			seq     = "_" + pw.slice(0, start);
		for (i = start; i < pw.length; i++) {
			seq = seq.slice(1) + pw.charAt(i);
			if (
				lower.indexOf(seq)   > -1 ||
				upper.indexOf(seq)   > -1 ||
				numbers.indexOf(seq) > -1 ||
				(o.noQwertySequences && qwerty.indexOf(seq) > -1)
			) {
				return false;
			}
		}
	}

	// enforce custom regex/function rules
	for (i = 0; i < o.custom.length; i++) {
		rule = o.custom[i];
		if (rule instanceof RegExp) {
			if (!rule.test(pw))
				return false;
		} else if (rule instanceof Function) {
			if (!rule(pw))
				return false;
		}
	}

	// great success!
	return true;
}


