/*****************************************************
Please do not change any of these functions unless you
are competent in Javascript. Changes made to the code in this
page that require fixing by SiriusPro will result in
fee paying work.
*****************************************************/

function isblank(s){
	for(var i=0; i<s.length; i++){
		var c=s.charAt(i);
		if((c!=' ') && (c!='') && (c!='\n')) return false;
	}
	return true;
}

function cverify(f){
	var name=f.mailname.value;
	var addr=f.mailaddress.value;
	var teln=f.mailphone.value;
	var mobn=f.mailmobile.value;
	var subj=f.mailsubject.value;
	var mess=f.mailmessage.value;
	var errs="";
	var msg="";
	if ((name==null) || (name=="") || isblank(name)){
		errs+="\n Please input your name";
	}
	if (((addr==null) || (addr=="") || isblank(addr)) && ((teln==null) || (teln=="") || isblank(teln)) && ((mobn==null) || (mobn=="") || isblank(mobn))){
		errs+="\n Please input either your email address, your telephone number or your mobile";
	}
	//stop the hackers	
	if(addr==name || addr==teln || addr==mobn || addr==subj || teln==subj){
		errs+="\n Please check your inputs - it seems that some are wrong";
	}
	if(addr){
	//check if email is from domain
		if(addr.indexOf("@")== -1) errs+="\n Invalid email address";
		else{
			var md=addr.split("@");
			var mmd=md[1].split(".");
			var maildom=mmd[0];
			md=location.href.split(".")
			var hrefdom=md[1];
			if(maildom==hrefdom) errs+="\n Hacking attempt failed!!!!";
		}
	}
	if ((subj==null) || (subj=="") || isblank(subj)){
		errs+="\n Please input a message subject";
	}
	if ((mess==null) || (mess=="") || isblank(mess) || mess=="Type Your Message Here"){
		errs+="\n Please input your message";
	}
	if(!errs){
		return true;
	}else{
		msg ="_____________________________________________________\n\n";
		msg+="The form was not submitted because of the following error(s).\n";
		msg+="Please correct the error(s) and re-submit.\n";
		msg+="_____________________________________________________\n\n";
		msg+=errs;
		alert(msg);
		return false;
	}
}