/* 	======================================================
*	Author		: Cornelius Dito 
*	Web Design 	: Wulan	
*	Project		: Lambada Website
*	Powered by	: Dewata Production Indonesia
*	=====================================================*/
function validateReg(){ 
	
	var theForm = document.forms["registration"];
	var coff = document.forms["registration"].coff;
	var class_pty = document.forms["registration"].class_pty;
	//alert(class_pty);
	var emailRE = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	var passwordRE = /^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$/;
	var userRE0 = new RegExp("http://");
	var errMsg = "";
	var setfocus = "";
	
 	if (!theForm.check_term.checked){
		errMsg = "Vous n’avez pas accepté nos conditions de vente!";
		setfocus = "['check_term']";
	}
 	
	if (theForm.jewelry.value == ""){
		errMsg = "Attention!\nQuel type de bijoux recherchez-vous?";
		setfocus = "['jewelry']";
	}
	
	if (theForm.companyfield.value == ""){
		errMsg = "Attention!\nDans quel secteur votre  compagnie exerce-t-elle son activité?";
		setfocus = "['companyfield']";
	}	
	
	if (!class_pty[0].checked && !class_pty[1].checked && !class_pty[2].checked && !class_pty[3].checked && !class_pty[4].checked && !class_pty[5].checked){
		errMsg = "SVP choisissez une classification pour votre entreprise!";
		setfocus = "['check_term']";
	}
	
	if (theForm.txt_ship_country.value == ""){
		errMsg = "Attention!\nSaisissez votre pays de livraison!";
		setfocus = "['txt_ship_country']";
	}
	
	if (theForm.txt_ship_zip.value == ""){
		errMsg = "Attention!\nSVP saisissez votre code postal de livraison!";
		setfocus = "['txt_ship_zip']";
	}
	
	if (theForm.txt_ship_city.value == ""){
		errMsg = "Attention!\nSVP saisissez votre ville de livraison!";
		setfocus = "['txt_ship_city']";
	}
	
	if (theForm.txt_ship_address1.value == ""){
		errMsg = "Attention!\nSVP saisissez votre adresse de livraison!";
		setfocus = "['txt_ship_address1']";
	}
	
	if (theForm.txt_bill_country.value == ""){
		errMsg = "Attention!\nSaisissez votre pays de facturation!";
		setfocus = "['txt_bill_country']";
	}
	
	if (theForm.txt_bill_zip.value == ""){
		errMsg = "Attention!\nSVP saisissez votre code postal de facturation!";
		setfocus = "['txt_bill_zip']";
	}
	
	if (theForm.txt_bill_city.value == ""){
		errMsg = "Attention!\nPSVP saisissez votre pays de facturation!";
		setfocus = "['txt_bill_city']";
	}
	
	if (theForm.txt_bill_address1.value == ""){
		errMsg = "Attention!\nSVP saisissez votre adresse de facturation!";
		setfocus = "['txt_bill_address1']";
	}

	if (theForm.txt_position.value == "" && theForm.txt_position2.value == "" && theForm.txt_position3.value == "" && theForm.txt_position4.value == "" && theForm.txt_position5.value == ""){
		errMsg = "Attention!\nSVP saisissez votre position dans de compagnie!";
		setfocus = "['c_owner']";
	}	
	//alert ('tes');
	/*if (theForm.txt_phone_mobile.value == ""){
		errMsg = "Attention!\nSVP saisissez votre numéro de téléphone portable!";
		setfocus = "['txt_phone_mobile']";
	}*/	
	
	if (theForm.txt_phone.value == ""){
		errMsg = "Attention!\nSVP saisissez votre numéro de téléphone!";
		setfocus = "['txt_phone']";
	}	
	
	if (theForm.txt_company.value == ""){
		errMsg = "Attention!\nSVP saisissez votre nom de compagnie!";
		setfocus = "['txt_company']";
	}

	/*if (!passwordRE.test(theForm.txt_password_r.value)){
		errMsg = "Attention!\nVotre mot de passe non sécurisés,SVP changer votre mot de passe!";
		setfocus = "['txt_password_r']";
	}
	
	if (!passwordRE.test(theForm.txt_password.value)){
		errMsg = "Attention!\nVotre mot de passe non sécurisés,SVP changer votre mot de passe!";
		setfocus = "['txt_password']";
	}*/

	if (theForm.txt_password.value != theForm.txt_password_r.value){
		errMsg = "Attention!\nMot de passe et confirmez le mot de passe doit être la même!";
		setfocus = "['txt_email_r']";
	}
	
	if (theForm.txt_password_r.value == ""){
		errMsg = "Attention!\nMot de passe et confirmez le mot de passe doit être la même";
		setfocus = "['txt_password_r']";
	}
	
	if (theForm.txt_password.value == ""){
		errMsg = "Attention!\nSVP saisissez votre mot de passe!";
		setfocus = "['txt_password']";
	}
	
	if (theForm.txt_email.value != theForm.txt_email_r.value){
		errMsg = "Attention!\nSVP saisissez votre 2ème adresse email!";
		setfocus = "['txt_email_r']";
	}
	
	if (!emailRE.test(theForm.txt_email_r.value)){
		errMsg = "Attention!\nSVP saisissez votre 2ème adresse email!";
		setfocus = "['txt_email_r']";
	}
	
	if (!emailRE.test(theForm.txt_email.value)){
		errMsg = "Attention!\nSVP vérifiez votre adresse email!";
		setfocus = "['txt_email']";
	}
	
	if (theForm.txt_email_r.value == ""){
		errMsg = "Attention!\nSVP saisissez votre 2ème adresse email!";
		setfocus = "['txt_email_r']";
	}
	
	if (theForm.txt_email.value == ""){
		errMsg = "Attention!\nSVP saisissez votre adresse email!";
		setfocus = "['txt_email']";
	}


	if (theForm.txt_last.value == ""){
		errMsg = "Attention!\nSVP saisissez votre nom!";
		setfocus = "['txt_last']";
	}

	if (theForm.txt_first.value == ""){
		errMsg = "Attention!\nSVP saisissez votre prénom!";
		setfocus = "['txt_first']";
	}

	if (theForm.txt_gender.value == ""){
		errMsg = "SVP selectionnez votre civilité!";
		setfocus = "['male']";
	}
	
	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}

	
	else theForm.submit();
}


function validateLogin(){ 
	var theForm = document.forms["login"];
	var userRE0 = new RegExp("http://");
	var errMsg = "";
	var setfocus = "";
		
	if (theForm.password.value == ""){
		errMsg = "Attention!\nVeuillez saisir votre mot de passe!";
		setfocus = "['password']";
	}
	if (theForm.username.value == ""){
		errMsg = "Attention!\nSaisissez vos informations de compte!";
		setfocus = "['username']";
	}


	if (errMsg != ""){
		alert(errMsg);
		eval("theForm" + setfocus + ".focus()");
	}

	
	else theForm.submit();
}

function isNumeric1(msg){
	var theForm = document.forms["registration"];
	var numericExpression = /^[0-9]+$/;
	if (theForm.txt_phone.value != ""){
		if(theForm.txt_phone.value.match(numericExpression)){
			return true;
		}else{
			alert(msg);
			theForm.txt_phone.value = "";
			theForm.txt_phone.focus();
			return false;
		}
	}
	
	if (theForm.txt_country_code.value != ""){
		if(theForm.txt_country_code.value.match(numericExpression)){
			return true;
		}else{
			alert(msg);
			theForm.txt_country_code.value = "";
			theForm.txt_country_code.focus();
			return false;
		}
	}
	
	if (theForm.txt_area_code.value != ""){
		if(theForm.txt_area_code.value.match(numericExpression)){
			return true;
		}else{
			alert(msg);
			theForm.txt_area_code.value = "";
			theForm.txt_area_code.focus();
			return false;
		}
	}
	
}

function isNumeric2(msg){
	var theForm = document.forms["registration"];
	var numericExpression = /^[0-9]+$/;
	if (theForm.txt_phone_fax.value != ""){
		if(theForm.txt_phone_fax.value.match(numericExpression)){
			return true;
		}else{
			alert(msg);
			theForm.txt_phone_fax.value = "";
			theForm.txt_phone_fax.focus();
			return false;
		}
	}
	
	if (theForm.txt_country_fax.value != ""){
		if(theForm.txt_country_fax.value.match(numericExpression)){
			return true;
		}else{
			alert(msg);
			theForm.txt_country_fax.value = "";
			theForm.txt_country_fax.focus();
			return false;
		}
	}
	
	if (theForm.txt_area_fax.value != ""){
		if(theForm.txt_area_fax.value.match(numericExpression)){
			return true;
		}else{
			alert(msg);
			theForm.txt_area_fax.value = "";
			theForm.txt_area_fax.focus();
			return false;
		}
	}
	
}

function isNumeric3(msg){
	var theForm = document.forms["registration"];
	var numericExpression = /^[0-9]+$/;
	if (theForm.txt_phone_mobile.value != ""){
		if(theForm.txt_phone_mobile.value.match(numericExpression)){
			return true;
		}else{
			alert(msg);
			theForm.txt_phone_mobile.value = "";
			theForm.txt_phone_mobile.focus();
			return false;
		}
	}
	
	if (theForm.txt_country_mobile.value != ""){
		if(theForm.txt_country_mobile.value.match(numericExpression)){
			return true;
		}else{
			alert(msg);
			theForm.txt_country_mobile.value = "";
			theForm.txt_country_mobile.focus();
			return false;
		}
	}
	
	if (theForm.txt_area_mobile.value != ""){
		if(theForm.txt_area_mobile.value.match(numericExpression)){
			return true;
		}else{
			alert(msg);
			theForm.txt_area_mobile.value = "";
			theForm.txt_area_mobile.focus();
			return false;
		}
	}
	
}

function passwordChanged1() {
var strength = document.getElementById('strength1');
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");
var pwd = document.getElementById("txt_password");
if (pwd.value.length==0) {
strength.innerHTML = '';
} else if (false == enoughRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:red"><strong>&nbsp;Trop Court!</strong></span>';
} else if (strongRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:green"><strong>&nbsp;Bon!</strong></span>';
} else if (mediumRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:purple"><strong>&nbsp;Moyen!</strong></span>';
} else {
strength.innerHTML = '<span style="color:red"><strong>&nbsp;Très Moyen!</strong></span>';
}
}

function passwordChanged2() {
var strength = document.getElementById('strength2');
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");
var pwd = document.getElementById("txt_password_r");
if (pwd.value.length==0) {
strength.innerHTML = '';
} else if (false == enoughRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:red"><strong>&nbsp;Trop Court!</strong></span>';
} else if (strongRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:green"><strong>&nbsp;Bon!</strong></span>';
} else if (mediumRegex.test(pwd.value)) {
strength.innerHTML = '<span style="color:purple"><strong>&nbsp;Moyen!</strong></span>';
} else {
strength.innerHTML = '<span style="color:red"><strong>&nbsp;Très Moyen!</strong></span>';
}
}


function verifynotify1(field1, field2, result_id, match_html, nomatch_html) {
 this.field1 = field1;
 this.field2 = field2;
 this.result_id = result_id;
 this.match_html = match_html;
 this.nomatch_html = nomatch_html;

 this.check = function() {
   if (!this.result_id) { return false; }
   if (!document.getElementById){ return false; }
   r = document.getElementById(this.result_id);
   if (!r){ return false; }

   if (this.field1.value != "" && this.field1.value == this.field2.value) {
     r.innerHTML = this.match_html;
   } else {
     r.innerHTML = this.nomatch_html;
   }
 }
}


function verifynotify2(field1, field2, result_id, match_html, nomatch_html) {
 this.field1 = field1;
 this.field2 = field2;
 this.result_id = result_id;
 this.match_html = match_html;
 this.nomatch_html = nomatch_html;

 this.check = function() {
   if (!this.result_id) { return false; }
   if (!document.getElementById){ return false; }
   r = document.getElementById(this.result_id);
   if (!r){ return false; }

   if (this.field1.value != "" && this.field1.value == this.field2.value) {
     r.innerHTML = this.match_html;
   } else {
     r.innerHTML = this.nomatch_html;
   }
 }
}



