function validateForm(form) {

		if (form.title.selectedIndex == 0) {
			alert("Please indicate your title."); 
			form.title.focus( );
			return false;				
		}
		
		if (form.fname.value == "") { 
			alert("Please enter your first name."); 
			form.fname.focus( ); 
			return false; //
		}
		
		if (form.sname.value == "") { 
			alert("Please enter your surname."); 
			form.sname.focus( ); 
			return false; //
		}
		
		if (form.dtel.value == "") { 
			alert("Please enter your daytime telephone number."); 
			form.dtel.focus( ); 
			return false;
		}
		else {
			if (!IsNumeric(form.dtel.value)) { 
			alert('Please enter your daytime telephone number in a valid format.') 
			form.dtel.focus(); 
			return false; 
			} 
		}

		if (form.etel.value == "") { 
			alert("Please enter your evening telephone number."); 
			form.etel.focus( ); 
			return false;
		}
		else {
			if (!IsNumeric(form.etel.value)) { 
			alert('Please enter your evening telephone number in a valid format.') 
			form.etel.focus(); 
			return false; 
			} 
		}
		
		if (form.mtel.value != "") { 
			if (!IsNumeric(form.mtel.value)) { 
				alert('Please enter your mobile telephone number in a valid format.') 
				form.mtel.focus(); 
				return false; 
			} 
		}

		if (form.email.value == "") { 
			alert('Please enter your email address.') 
			form.email.focus(); 
			return false; 
		}
		else {
			if (emailCheck(form.email.value) == false) {
				form.email.focus(); 
				return false;
			}
		}
		
		if (form.address1.value == "") {
			alert("Please enter the first line of your address."); 
			form.address1.focus( );
			return false; 
		}
		
		if (form.towncity.value == "") { 
			alert("Please enter the name of your town or city name."); 
			form.towncity.focus( );
			return false;
		}
		
		if (form.postcode.value == "") { 
			alert("Please enter your postcode."); 
			form.postcode.focus( );
			return false;
		}
		
		if (form.fdate.value == "") { 
			alert("Please select your arrival time."); 
			form.fdate.focus( );
			return false;
		}
		else {
			if(!isDate(form.fdate.value)) { 
			alert("Please enter the start date for the lease in a valid format."); 
			form.fdate.focus( );
			return false;
			}
		}
		
		if (form.tdate.value == "") { 
			alert("Please select your departure time."); 
			form.tdate.focus( );
			return false;
		}
		else {
			if(!isDate(form.tdate.value)) { 
			alert("Please enter the finish date for the lease in a valid format."); 
			form.tdate.focus( );
			return false;
			}
		}
		
		if (form.advertsource.value == 0) { 
			alert('Please indicate where you heard about us.') 
			form.advertsource.focus(); 
			return false; 
		}							
	}
		
	function IsNumeric(sText)
		{
			var ValidChars = "()0123456789 ";
			var IsNumber=true;
			var Char;
	 
			for (i = 0; i < sText.length && IsNumber == true; i++) 
					{ 
						Char = sText.charAt(i); 
						if (ValidChars.indexOf(Char) == -1) 
						{
							IsNumber = false;
						}
					}
			return IsNumber;			   
		}
	
	function isDate(DateToCheck){
		if(DateToCheck==""){return true;}
		var m_strDate = FormatDate(DateToCheck);
		if(m_strDate==""){
		return false;
		}
		var m_arrDate = m_strDate.split("/");
		var m_DAY = m_arrDate[0];
		var m_MONTH = m_arrDate[1];
		var m_YEAR = m_arrDate[2];
		if(m_YEAR.length > 4){return false;}
		m_strDate = m_MONTH + "/" + m_DAY + "/" + m_YEAR;
		var testDate=new Date(m_strDate);
		if(testDate.getMonth()+1==m_MONTH){
		return true;
		} 
		else{
		return false;
		}
		}//end function
					
		function FormatDate(DateToFormat,FormatAs){
		if(DateToFormat==""){return"";}
		if(!FormatAs){FormatAs="dd/mm/yyyy";}
		
		var strReturnDate;
		FormatAs = FormatAs.toLowerCase();
		DateToFormat = DateToFormat.toLowerCase();
		var arrDate
		var arrMonths = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
		var strMONTH;
		var Separator;
		
		while(DateToFormat.indexOf("st")>-1){
		DateToFormat = DateToFormat.replace("st","");
		}
		
		while(DateToFormat.indexOf("nd")>-1){
		DateToFormat = DateToFormat.replace("nd","");
		}
		
		while(DateToFormat.indexOf("rd")>-1){
		DateToFormat = DateToFormat.replace("rd","");
		}
		
		while(DateToFormat.indexOf("th")>-1){
		DateToFormat = DateToFormat.replace("th","");
		}
		
		if(DateToFormat.indexOf(".")>-1){
		Separator = ".";
		}
		
		if(DateToFormat.indexOf("-")>-1){
		Separator = "-";
		}
		
		
		if(DateToFormat.indexOf("/")>-1){
		Separator = "/";
		}
		
		if(DateToFormat.indexOf(" ")>-1){
		Separator = " ";
		}
		
		arrDate = DateToFormat.split(Separator);
		DateToFormat = "";
			for(var iSD = 0;iSD < arrDate.length;iSD++){
				if(arrDate[iSD]!=""){
				DateToFormat += arrDate[iSD] + Separator;
				}
			}
		DateToFormat = DateToFormat.substring(0,DateToFormat.length-1);
		arrDate = DateToFormat.split(Separator);
		
		if(arrDate.length < 3){
		return "";
		}
		
		var DAY = arrDate[0];
		var MONTH = arrDate[1];
		var YEAR = arrDate[2];
		
		
		
		
		if(parseFloat(arrDate[1]) > 12){
		DAY = arrDate[1];
		MONTH = arrDate[0];
		}
		
		if(parseFloat(DAY) && DAY.toString().length==4){
		YEAR = arrDate[0];
		DAY = arrDate[2];
		MONTH = arrDate[1];
		}
		
		
		for(var iSD = 0;iSD < arrMonths.length;iSD++){
		var ShortMonth = arrMonths[iSD].substring(0,3).toLowerCase();
		var MonthPosition = DateToFormat.indexOf(ShortMonth);
			if(MonthPosition > -1){
			MONTH = iSD + 1;
				if(MonthPosition == 0){
				DAY = arrDate[1];
				YEAR = arrDate[2];
				}
			break;
			}
		}
		
		var strTemp = YEAR.toString();
		if(strTemp.length==2){
		
			if(parseFloat(YEAR)>40){
			YEAR = "19" + YEAR;
			}
			else{
			YEAR = "20" + YEAR;
			}
		
		}
		
		
			if(parseInt(MONTH)< 10 && MONTH.toString().length < 2){
			MONTH = "0" + MONTH;
			}
			if(parseInt(DAY)< 10 && DAY.toString().length < 2){
			DAY = "0" + DAY;
			}
			switch (FormatAs){
			case "dd/mm/yyyy":
			return DAY + "/" + MONTH + "/" + YEAR;
			case "mm/dd/yyyy":
			return MONTH + "/" + DAY + "/" + YEAR;
			case "dd/mmm/yyyy":
			return DAY + " " + arrMonths[MONTH -1].substring(0,3) + " " + YEAR;
			case "mmm/dd/yyyy":
			return arrMonths[MONTH -1].substring(0,3) + " " + DAY + " " + YEAR;
			case "dd/mmmm/yyyy":
			return DAY + " " + arrMonths[MONTH -1] + " " + YEAR;	
			case "mmmm/dd/yyyy":
			return arrMonths[MONTH -1] + " " + DAY + " " + YEAR;
			}
		
		return DAY + "/" + strMONTH + "/" + YEAR;;
		
		} //End Function
	
	
		function emailCheck (emailStr) {
		/* The following pattern is used to check if the entered e-mail address
		fits the user@domain format.  It also is used to separate the username
		from the domain. */
		var emailPat=/^(.+)@(.+)$/
		/* The following string represents the pattern for matching all special
		characters.  We don't want to allow special characters in the address. 
		These characters include ( ) < > @ , ; : \ " . [ ]    */
		var specialChars="\\(\\)<>@,;:\\\\\\\"\\.\\[\\]"
		/* The following string represents the range of characters allowed in a 
		username or domainname.  It really states which chars aren't allowed. */
		var validChars="\[^\\s" + specialChars + "\]"
		/* The following pattern applies if the "user" is a quoted string (in
		which case, there are no rules about which characters are allowed
		and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
		is a legal e-mail address. */
		var quotedUser="(\"[^\"]*\")"
		/* The following pattern applies for domains that are IP addresses,
		rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
		e-mail address. NOTE: The square brackets are required. */
		var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/
		/* The following string represents an atom (basically a series of
		non-special characters.) */
		var atom=validChars + '+'
		/* The following string represents one word in the typical username.
		For example, in john.doe@somewhere.com, john and doe are words.
		Basically, a word is either an atom or quoted string. */
		var word="(" + atom + "|" + quotedUser + ")"
		// The following pattern describes the structure of the user
		var userPat=new RegExp("^" + word + "(\\." + word + ")*$")
		/* The following pattern describes the structure of a normal symbolic
		domain, as opposed to ipDomainPat, shown above. */
		var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$")
	
	
		/* Finally, let's start trying to figure out if the supplied address is
		valid. */
	
		/* Begin with the coarse pattern to simply break up user@domain into
		different pieces that are easy to analyze. */
		var matchArray=emailStr.match(emailPat)
		if (matchArray==null) {
		/* Too many/few @'s or something; basically, this address doesn't
			even fit the general mould of a valid e-mail address. */
			alert("Email address seems incorrect (check @ and .'s)")
			return false
		}
		var user=matchArray[1]
		var domain=matchArray[2]
	
		// See if "user" is valid 
		if (user.match(userPat)==null) {
			// user is not valid
			alert("The email address doesn't seem to be valid.")
			return false
		}
	
		/* if the e-mail address is at an IP address (as opposed to a symbolic
		host name) make sure the IP address is valid. */
		var IPArray=domain.match(ipDomainPat)
		if (IPArray!=null) {
			// this is an IP address
			for (var i=1;i<=4;i++) {
				if (IPArray[i]>255) {
					alert("Destination IP address is invalid!")
				return false
				}
			}
			return true
		}
	
		// Domain is symbolic name
		var domainArray=domain.match(domainPat)
		if (domainArray==null) {
			alert("The domain name doesn't seem to be valid.")
			return false
		}
	
		/* domain name seems valid, but now make sure that it ends in a
		three-letter word (like com, edu, gov) or a two-letter word,
		representing country (uk, nl), and that there's a hostname preceding 
		the domain or country. */
	
		/* Now we need to break up the domain to get a count of how many atoms
		it consists of. */
		var atomPat=new RegExp(atom,"g")
		var domArr=domain.match(atomPat)
		var len=domArr.length
		if (domArr[domArr.length-1].length<2 || 
			domArr[domArr.length-1].length>3) {
		// the address must end in a two letter or three letter word.
		alert("The address must end in a three-letter domain, or two letter country.")
		return false
		}
	
		// Make sure there's a host name preceding the domain.
		if (len<2) {
		var errStr="This address is missing a hostname!"
		alert(errStr)
		return false
		}
	
		// If we've gotten this far, everything's valid!
		return true;
		}
