// JavaScript Document
function validate() {
	//leave the below 34 lines as is
	function is_int(what){
		var i;
		for (i=0; i<what.length; i++){   
			var c = what.charAt(i);
			if ((c < "0") || (c > "9")){
				return false;
			}
		}
		return true;
	}
	function is_float(what){
		var i;
		for (i=0; i<what.length; i++){   
			var c = what.charAt(i);
			if (!((c>='0'&&c<='9') || (c=='.'))){
				return false;
			}
		}
		return true;
	}
	function is_phone(what){
		var i;
		for (i=0; i<what.length; i++){   
			var c = what.charAt(i);
			if (!((c>='0'&&c<='9') || (c==' ') || (c=='+') || (c=='(') || (c==')') )){
				return false;
			}
		}
		return true;
	}
	var allesgut = true;
	var msg = '';
	
	
	//change the name on the end of this line to the name of the form to check
	var frm=document.orderform1;

	//the below 4 lines validate that some text has been entered -> just change the
	//element name (frm.elementname.value where elementname is the name of the input tag)
	//and make the message text pertinent. Only for "textarea" or "input type=text"
	if(frm.realname.value.length == 0){
		msg = msg+"Please enter a Name.\n";
		allesgut = false;
	}
	
	//as above
	if(frm.delivery_address.value.length == 0){
		msg = msg+"Please enter a Delivery Address.\n";
		allesgut = false;
	}
	
	
	//the below 10 lines validate an email field, first checking if it exists
	//then checking it looks like an email address. Copy. If email field is
	//not called "email" change frm.email.value to frm.whateveryoucalledthefield.value
	if(frm.email.value.length == 0){
		msg = msg+"Please enter an email address.\n";
		allesgut = false;
	}else{
		var email_checkchar1=frm.email.value.indexOf("@");
		var email_checkchar2=frm.email.value.lastIndexOf(".");
		if(email_checkchar1==-1 || email_checkchar2==-1 || email_checkchar2 < email_checkchar1){
			msg = msg+"The email address you entered does not appear to be valid.\n";
			allesgut = false;
		}
	}

	//the below 8 lines checks a phone number. If phone field is not called "phone"
	//change frm.phone.value to frm.whateveryoucalledthefield.value
	if(frm.phone.value.length==0){
		msg = msg+"Please enter a contact telephone number.\n";
		allesgut = false;
	}else{
		if(!(is_phone(frm.phone.value))){
			msg = msg+"The telephone number you entered does not appear to be valid.\n";
			allesgut = false;
		}
	}
	
	
	//leave this bit as is
	if (allesgut == false) {
		alert(msg);
		return false;
	}
}