function validate(){
	var validateModel={
		MANDATORY:1,
		IS_EMAIL:2,
		objectsToValidate:[
			{ID:'title',label:'Title',type:1},
			{ID:'firstName',label:'First Name',type:1},
			{ID:'lastName',label:'Last Name',type:1},
			{ID:'position',label:'Position',type:1},
			{ID:'organisation',label:'Organisation',type:1},
			{ID:'postalAddress',label:'Postal Address',type:1},
			{ID:'city',label:'City',type:1},
			{ID:'state',label:'State',type:1},
			{ID:'emailAddress',label:'eMail Address',type:1},
			{ID:'emailAddress',label:'eMail Address',type:2}
		]
	};
	var val=new validationEngine(validateModel);
	msg=val.executeValidation();
	if (msg!=""){
		alert ("The following errors have occurred:\n\n"+msg);
		return false;
	}
	else{
		return true;
	}
}

function validationEngine(model){
	this.model=model;
	this.msg="";
	this.executeValidation=function(){
		for(var n in this.model.objectsToValidate){
			var node=document.getElementById(this.model.objectsToValidate[n].ID);
			
			switch (this.model.objectsToValidate[n].type){
				case this.model.MANDATORY:
					this.checkMandatory(node,this.model.objectsToValidate[n].label);
					break;
				case this.model.IS_EMAIL:
					this.checkIsEmail(node,this.model.objectsToValidate[n].label);
					break;
			}			
		}
		return this.msg;
	}
	this.checkMandatory=function(node,label){
		if (node.value==""){
			 this.msg+=label + " is mandatory \n";
		}
	}
	this.checkIsEmail=function(node,label){
		str=node.value;
		if (!((str.indexOf(".") > 2) && (str.indexOf("@") > 0))) this.msg+=label + " is not a valid email \n";
	}
}