function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; }	
}
function queryString(key){
var page = new PageQuery(window.location.search); 
return unescape(page.getValue(key)); 
}
function displayItem(key){
if(queryString(key)=='false') 
{
result.innerHTML="you didn't enter a ?name=value querystring item.";
}else{
result.innerHTML+=queryString(key)+"<BR>";
}
}

function CheckMandatoryField(field, fieldname, langcode)
  {
	if(field.value == "")
	{
	  if(langcode == "FR")
	  {
		alert(fieldname + " est obligatoire !");
	  }
	  else if(langcode == "NL")
	  {
		alert(fieldname + " is verplicht !");
	  }
	  else if(langcode == "EN")
	  {
		alert(fieldname + " is mandatory !");
	  }          
	  return false;
	}
	else 
	{
	  return true;
	}
  }

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Invalid email address.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid email address.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid email address.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid email address.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid email address.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid email address.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid email address.")
		    return false
		 }

 		 return true					
	}

    function submitmyform(myform)
		{			
			if(!(CheckMandatoryField(myform.sExplFirstname, 'Firstname','EN'))) return false;
			if(!(CheckMandatoryField(myform.sExplLastname, 'Lastname','EN'))) return false;

			var emailID=document.myform.sExplEmail
			
			if ((emailID.value==null)||(emailID.value=="")){
				alert("Email is mandatory !")
				emailID.focus()
				return false
			}
			if (echeck(emailID.value)==false){
				emailID.focus()
				return false
			}
			return true
		 }								
