var mylang = "en";

function On(imgName) {
	if (document.images) {
		document[imgName].src = eval(imgName + "on.src");
	}
};

function Off(imgName) {
	if (document.images) {
		document[imgName].src = eval(imgName + "off.src");
	}
};

//This function strips off leading and ending spaces.
function stripSpaces(form_item){
	var mytext = new String("");
	
	mytext = form_item.value;
	while (mytext.charAt(0) == ' ') {
		mytext = mytext.substring(1,mytext.length);
	}
	while (mytext.charAt(mytext.length - 1) == ' ') {
		mytext = mytext.substring(0, (mytext.length - 1));
	}
	form_item.value = mytext;
};

//This function checks that all the required data are input
function extraCheckEntriesEN(){
	var rep_msg;
	var data_miss;
	//var nl;
	var mystr;
	
	//nl = String.fromCharCode(13);
	data_miss = 0;
	rep_msg = "Some required fields have not been filled" + "\n" + "\n";
	if (document.getElementById('login').value + "" == "")
		{
			rep_msg += "  - Please enter your Username" + "\n";
			data_miss = 1;
		}
	if (document.getElementById('pwd').value + "" == "")
		{
			rep_msg += "  - Please enter your password" + "\n";
			data_miss = 1;
		}	
	if (data_miss == 1)
		{ 
			alert(rep_msg);
			return false;
		}
	else
		{		
			return true;
		}
};

//This function checks that all the required data are input
function extraCheckEntriesFR(){
	var rep_msg;
	var data_miss;
	//var nl;
	var mystr;
	
	//nl = String.fromCharCode(13);
	data_miss = 0;
	rep_msg = "Certains champs ont été mal remplis" + "\n" + "\n";
	
	if (document.getElementById('login').value + "" == "")
		{
			rep_msg += "  - Veuillez saisir votre login" + "\n";
			data_miss = 1;
		}
	if (document.getElementById('pwd').value + "" == "")
		{
			rep_msg += "  - Veuillez saisir votre mot de passe" + "\n";
			data_miss = 1;
		}	
	if (data_miss == 1)
		{ 
			alert(rep_msg);
			return false;
		}
	else
		{		
			return true;
		}
};

function doLoginEN() {
	if (extraCheckEntriesEN()) {
		document.forms[0].action = "login.asp"
		document.forms[0].submit();	
	}
};

function doLoginFR() {
	if (extraCheckEntriesFR()) {
		document.forms[0].action = "login.asp"
		document.forms[0].submit();	
	}
};

function checkEmail(mail) {
	if ((mail.indexOf("@") >= 0) && (mail.indexOf(".") >= 0)) {
		return true
	} else {
         	return false
      	}
};
   
function sendNewQuestionEN() {	
	var message = "";
	
	if (document.forms[0].mail.value + "" != "") {
		if (checkEmail(document.forms[0].mail.value + "") == false) {
			message += "Please enter a valid email" + "\n";
		}
	}	
	if (document.forms[0].question.value + "" == "") {
		message += "Please enter a valid question" + "\n";
	}
	if (message != "") {
		alert(message);
	}
	else {
		document.forms[0].action = "faqs.asp"
		document.forms[0].submit();		
	}
};

function sendNewQuestionFR() {
	var message = "";
	
	if (document.ClientLounge.mail.value + "" != "") {
		if (checkEmail(document.forms[0].mail.value) == false) {
			message += "Veuillez saisir un email valide" + "\n";
		}
	}	
	if (document.forms[0].question.value + "" == "") {
		message += "Veuillez saisir une question valide" + "\n";
	}
	if (message != "") {
		alert(message);
	}
	else {
		document.forms[0].action = "faqs.asp"
		document.forms[0].submit();		
	}
};

function checkEmailFR(myItem) {
	if ((myItem.value.search(/[A-Za-z0-9_-]*@[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*/gi) == -1) && (myItem.value + "" != "") || (myItem.value + "" == "")) {
		
		alert("Veuillez vérifier votre adresse email.");		
		myItem.value = "";
		myItem.focus();
		return false;
	} else {
		return true;
	}
};

function SendNewletterFR() {
	if (checkEmailFR(document.forms[0].email)) {
		document.forms[0].action = "subnewsletter.asp";
		document.forms[0].submit();
	}
};

function SendNewletterNFR() {
	if (checkEmailFR(document.forms[0].email)) {
		document.forms[0].action = "../fr/subnewsletter.asp";
		document.forms[0].submit();
	}
};

function checkEmailEN(myItem) {
	if ((myItem.value.search(/[A-Za-z0-9_-]*@[A-Za-z0-9_-]*\.[A-Za-z0-9_-]*/gi) == -1) && (myItem.value + "" != "") || (myItem.value + "" == "")) {
		
		alert("Please check your email address.");		
		myItem.value = "";
		myItem.focus();
		return false;
	} else {
		return true;
	}
};

function SendNewletterEN() {
	if (checkEmailEN(document.forms[0].email)) {
		document.forms[0].action = "subnewsletter.asp";
		document.forms[0].submit();
	}
};

function SendNewletterHEN() {
	if (checkEmailEN(document.forms[0].email)) {
		document.forms[0].action = "en/subnewsletter.asp";
		document.forms[0].submit();
	}
};
