<!--

function showMsg(msgTitle, msgMain, buttons) {
	document.getElementById('msgTitlebar').innerHTML = msgTitle;
	document.getElementById('msgBody').innerHTML = msgMain;
	
	if(buttons == 'buttonOK') {
		document.getElementById('msgBody').innerHTML += '<br /><br /><input type="button" name="hideMsg" value="OK" onclick="hideMsg()" />';
	}
	document.getElementById('msgBox').style.display = 'block';
}

function hideMsg() {
	document.getElementById('msgBox').style.display = 'none';
}

function testIsValidObject(objToTest) {
	if (objToTest == null || objToTest == undefined) {
		return false;
	}
	return true;
}

function clearMsg() {
	GetQuote.postCode.value = '';
}

function checkPCode() {
	var postCode = document.GetQuote.postCode;
	var distance = document.GetQuote.distance;
	var measurement = document.GetQuote.measurement;
	var distanceSel = false;
	
	// Check if one of the distances was selected
	for(var i=0;i<distance.length;i++) {
		if(distance[i].checked) {
			distanceSel = true;
		}
	}
	
	if((postCode.value.length > 0) && (measurement.options[measurement.selectedIndex].value.length > 0) && (distanceSel == true)) {
		if(postCode.value.match(/([A-Z]{1,2}[0-9][A-Z0-9]?) {0,1}([0-9][ABD-HJLNP-UW-Z]{2})/i)) {
			checkLocation();
		}
	}
}

function checkQuote() {
	var postCode = document.GetQuote.postCode;
	var distance = document.GetQuote.distance;
	var measurement = document.GetQuote.measurement;
	var distanceSel = false;
	
	var msg = document.GetQuote.msg;
	var msgDefault = document.GetQuote.msgDefault;
	var custName = document.GetQuote.custName;
	var email = document.GetQuote.email;
	var tel = document.GetQuote.tel;
	
	var error = false;
	
	var iform = window.frames["orgList"].document.companyList;

	var errMsg = '';
	
	var orgsChecked = false;
	var companiesChecked = false;
	var selOrgs = '';
	var selCompanies = '';
	
	// Check if one of the disatances was selected
	for(var i=0;i<distance.length;i++) {
		if(distance[i].checked) {
			distanceSel = true;
		}
	}
	
	if(postCode.value.length == 0) {
		errMsg += 'The post code cannot be empty.\n';
		postCode.focus();
		//postCode.focus();
		error = true;
	}
	else if(!postCode.value.match(/([A-Z]{1,2}[0-9][A-Z0-9]?) {0,1}([0-9][ABD-HJLNP-UW-Z]{2})/i)) {
		errMsg += 'The post code "' + postCode.value + '" does not appear to be valid. Please re-enter it.\n';
		postCode.focus();
		//postCode.focus();
		error = true;
	}
	else if (distanceSel == false) {
		errMsg += 'Please select a radius from your post code of "' + postCode.value + '" within which you would like to search.\n';
		error = true;
	}
	
	if(measurement.options[measurement.selectedIndex].value.length == 0) {
		errMsg += 'The unit of measurement for the radius of  "' + distance.value + '" has not been selected.\n';
		postCode.focus();
		//postCode.focus();
		error = true;
	}
	
	// Trim leading \n\r tags which get added causing the strings not to match
	msg = msg.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	msgDefault = msgDefault.value.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	if(!error == true) {
		if(!testIsValidObject(iform.elements["orgs[]"])) {
			errMsg += 'You must enter your post code and select a distance to show the list of companies first\n'; 
			error = true;
		}
		else if(!testIsValidObject(iform.elements["companies[]"])) {
			errMsg += 'You must enter your post code and select a distance to show the list of companies first\n'; 
			error = true;
		}
	}
	
	if(!error == true) {
		//If more than one org selected
		if(iform.elements["orgs[]"].length){
			for(i=0; i<iform.elements["orgs[]"].length; i++) {
				if (iform.elements["orgs[]"][i].checked == true) {
					//window.alert("text " + iform .elements["orgs[]"][i].value + " text!");
					//return false;
					orgsChecked = true;
					if(!selOrgs == '') {
						selOrgs = selOrgs + ', ' + iform .elements["orgs[]"][i].value;
					}
					else {
						selOrgs = selOrgs + iform .elements["orgs[]"][i].value;
					}
				}
			  
			}
		}
		//If only one selected
		else {
			if (iform.elements["orgs[]"].checked == true) {
				//window.alert("text " + iform.elements["orgs[]"].value + " text ONE!");
				//return false;
				orgsChecked = true;
				selOrgs = iform.elements["orgs[]"].value;
			}
		}
		//If more than one company selected
		if(iform.elements["companies[]"].length) {
			for(i=0; i<iform.elements["companies[]"].length; i++) {
				if (iform.elements["companies[]"][i].checked == true) {
					//window.alert("text " + iform .elements["orgs[]"][i].value + " text!");
					//return false;
					companiesChecked = true;
					if(!selCompanies == '') {
						selCompanies = selCompanies + ', ' + iform .elements["companies[]"][i].value;
					}
					else {
						selCompanies = selCompanies + iform .elements["companies[]"][i].value;
					}
				}
			  
			}
		}
		//If only one selected
		else {
			if (iform.elements["companies[]"].checked == true) {
				//window.alert("text " + iform.elements["orgs[]"].value + " text ONE!");
				//return false;
				companiesChecked = true;
				selCompanies = selCompanies + iform .elements["companies[]"].value;
			}
		}
		
		if ((orgsChecked == false) && (companiesChecked == false)) {
			errMsg += 'You must either tick one or more organisations or one or more companies from the left menu\n.'; 
			error = true;
		}
		else if(!postCode.value.match(/([A-Z]{1,2}[0-9][A-Z0-9]?) {0,1}([0-9][ABD-HJLNP-UW-Z]{2})/i)) {
			errMsg += 'The post code "' + postCode.value + '" does not appear to be valid. Please re-enter it.\n';
			error = true;
		}
		/*else if (distance.value == null) {
			errMsg += 'The distance from your location cannot be left blank.\nPlease select a distance using the radio buttons.\n';
			error = true;
		}*/
		else if (measurement.value == null) {
			errMsg += 'The unit of measurement cannot be blank.\nPlease select either miles or kilometres.\n';
			error = true;
		}
		else if (msg.length == 0) {
			errMsg += 'The message cannot be empty.\nYou need to enter a message before pressing the send button.\n';
			error = true;
		}
		else if (msg == msgDefault){
			errMsg += 'The message cannot be empty.\nThe message shown is an example only and if you click in the box it will disappear.\n';
			error = true;
		}
		else if (custName.value.length == 0){
			errMsg += 'Please enter your name in the box provided so that the companies will know how to address you when they reply.\n';
			error = true;
		}
		else if (email.value.length > 0) {
			if (!emailCheck(email.value)) {
				error = true;
			}
		}
		else if (tel.value.length > 0) {
			if (!isTel(tel.value)) {
				errMsg += 'The telephone number you have entered does not appear to be valid.\nPlease ensure you include your area code\n';
				error = true;
			}
		}
		else if ((tel.value.length == 0) && (email.value.length == 0)){
			errMsg += 'Your telephone number and email address cannot both be blank.\nPlease enter either a valid email address or contact number.\n';
			error = true;
		}
	}
	
	if(!error == true) {
		document.GetQuote.orgs.value = selOrgs;
		document.GetQuote.companies.value = selCompanies;
		document.GetQuote.action = 'index.php';
		document.GetQuote.target = '_parent';
		document.GetQuote.submit();
	}
	else {
		if(errMsg.length > 0) {
			alert(errMsg);
		}
	}
}

function checkLocation() {
	var postCode = document.GetQuote.postCode;
	var distance = document.GetQuote.distance;
	var measurement = document.GetQuote.measurement;
	
	// Check if one of the disatances was selected
	for(var i=0;i<distance.length;i++) {
		if(distance[i].checked) {
			distanceSel = true;
		}
	}
	

	if((postCode.value.length > 0) && (measurement.options[measurement.selectedIndex].value.length > 0) && (distanceSel == true)) {
		if(postCode.value.match(/([A-Z]{1,2}[0-9][A-Z0-9]?) {0,1}([0-9][ABD-HJLNP-UW-Z]{2})/i)) {
			document.GetQuote.action = 'orgList.php';
			document.GetQuote.target = 'orgList';
			document.GetQuote.submit();
		}
		else {
			alert('The post code "' + postCode.value + '" does not appear to be valid. Please re-enter it.');
			postCode.value = '';
			postCode.focus();
		}
	}
}

function checkAllSub(orgCB, orgNum) {
	boxes = document.getElementsByName('companies[]');
	
	if(orgCB.checked == true) { 
		for (var i=0;i< boxes.length;i++) {
			boxStr =  boxes[i].id;
			idPos = boxStr.indexOf('-');
			boxStrLen = boxStr.length;
			orgID = boxStr.substr(0, idPos);
			companyID = boxStr.substr(idPos + 1, boxStrLen - idPos);
			
			// Only tick boxes within this category
			if(orgID == orgNum) {
				boxes[i].checked = true;
			}
		}
	}
	else {
		for (var i=0;i< boxes.length;i++) {
			boxStr =  boxes[i].id;
			idPos = boxStr.indexOf('-');
			boxStrLen = boxStr.length;
			orgID = boxStr.substr(0, idPos);
			companyID = boxStr.substr(idPos + 1, boxStrLen - idPos);
			
			// Only tick boxes within this category
			if(orgID == orgNum) {
				boxes[i].checked = false;
			}
		}
	}
}

function clearField(f1, fldID) {
	var f2, f1text, f2text;
	
	f2 = document.getElementById(fldID);
	
	f1text = f1.value
	f2text = f2.value
	
	// Trim leading \n\r tags which get added causing the strings not to match
	f1text = f1text.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	f2text = f2text.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	

	if(f1text == f2text) {
		f1.value='';	
	}
}

function checkField(f1, fldID) {
	var f2, f1text, f2text;
	
	f2 = document.getElementById(fldID);
	
	f1text = f1.value
	f2text = f2.value
	
	// Trim leading \n\r tags which get added causing the strings not to match
	f1text = f1text.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	f2text = f2text.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
	
	if(f1text == f2text) {

	}
	else {
		if(f1text == '') {
			f1.value = f2text
		}
	}
}

function validateCompany(f){
	if(f.companyName.value=="") {
		f.companyName.focus();
		alert("The company name cannot be blank!");
		return false;
	}
	else if (isTel(f.tel.value)==false) {
		f.tel.focus();
		alert("Please enter a valid telephone number using only numbers and spaces!");
		return false;
	}
	else if (isTel(f.fax.value)==false) {
		f.fax.focus();
		alert("Please enter a valid fax number using only numbers and spaces!");
		return false;
	}
	else if (f.email.value != "") {
		if (emailCheck(f.email.value)==false) {
			f.email.focus();
			return false;
		}
	}
	else {
		return true;	
	}
}

function validateOffice(f){
	if(f.officeName.value=="") {
		f.officeName.focus();
		alert("The office name cannot be blank!");
		return false;
	}
	else if (isTel(f.tel.value)==false) {
		f.tel.focus();
		alert("Please enter a valid telephone number using only numbers and spaces!");
		return false;
	}
	else if (isTel(f.fax.value)==false) {
		f.fax.focus();
		alert("Please enter a valid fax number using only numbers and spaces!");
		return false;
	}
	else if (f.email.value != "") {
		if (emailCheck(f.email.value)==false) {
			f.email.focus();
			return false;
		}
	}
	else {
		return true;	
	}
}

function validateInvoice(f){
	if (isDouble(f.amount.value)==false) {
		f.amount.focus();
		alert("Please enter a valid amount using only numbers and decimals without the £ sign!");
		return false;
	}
	else if (isDate(f.invoiceDate.value)==false) {
		f.invoiceDate.focus();
		return false;
	}
	else {
		return true;	
	}
}

function validateClient(f){
	if(f.titleID.value=="") {
		f.titleID.focus();
		alert("Please select a title for the new client!");
		return false;
	}
	else if(f.foreName.value=="") {
		f.foreName.focus();
		alert("Please enter a valid first name for the client!");
		return false;
	}
	else if(f.surName.value=="") {
		f.surName.focus();
		alert("Please enter a valid surname for the client!");
		return false;
	}
	else if (isTel(f.telWork.value)==false) {
		f.telWork.focus();
		alert("Please enter a valid work telephone number using only numbers and spaces!");
		return false;
	}
	else if (isTel(f.telMob.value)==false) {
		f.telMob.focus();
		alert("Please enter a valid mobile telephone number using only numbers and spaces!");
		return false;
	}
	else if (f.emailAddr.value != "") {
		if (emailCheck(f.emailAddr.value)==false) {
			f.emailAddr.focus();
			return false;
		}
	}
	else {
		return true;	
	}
}

function validateQuote(f){
	if(f.location.value=="") {
		f.location.focus();
		alert("Please enter a valid location!");
		return false;
	}
	else if (isDate(f.quoteDate.value)==false) {
		f.quoteDate.focus();
		return false;
	}
	else if (isDate(f.flagDate.value)==false) {
		f.flagDate.focus();
		return false;
	}
	else if(f.price.value=="") {
		f.price.focus();
		alert("The price cannot be blank!");
		return false;
	}
	else if (isDouble(f.price.value)==false) {
		f.price.focus();
		alert("Please enter a valid price using only decimals and excluding the £ sign!");
		return false;
	}
	else {
		return true;	
	}
}

function validateNote(f){
	if(f.noteText.value=="") {
		f.noteText.focus();
		alert("Please enter the details of the note!");
		return false;
	}
	else if (isDate(f.noteDate.value)==false) {
		f.noteDate.focus();
		return false;
	}
	else {
		return true;	
	}
}

function checkPersonalDetails1(l) 

{

  if((l.anyImplants[0].checked==false) && (l.anyImplants[1].checked==false))

  {

    window.alert("Please select whether or not you have any implants");

    return false;

  }

  else if(l.anyImplants[0].checked==true)

  {

    window.alert("Sorry but we are unable to offer scans to anyone with any implants");

    return false;

  }

  if((l.anyKidneyDisease[0].checked==false) && (l.anyKidneyDisease[1].checked==false))

  {

    window.alert("Please select whether or not you have any kidney disease or renal disorder");

    return false;

  }

  else if(l.anyKidneyDisease[0].checked==true)

  {

    window.alert("Sorry but we are unable to offer scans to anyone with kidney disease or renal disorder");

    return false;

  }

  else if((l.agreeTOS[0].checked==false) && (l.agreeTOS[1].checked==false))

  {

    window.alert("Please select whether or not you agree with the terms of agreement");

    return false;

  }

  else if(l.agreeTOS[1].checked==true)

  {

    window.alert("Sorry but we are unable to offer scans to anyone who does not agree with the terms of agreement");

    return false;

  }

  else

  {

    return true;

  }

}



function checkPersonalDetails2(l) 

{

  if(l.firstName.value=="")

  {

    window.alert("Your first name cannot be blank");

    return false;

  }

  else if(l.surName.value=="")

  {

    window.alert("Your last name cannot be blank");

    return false;

  }

  else if((l.dobD.value=="") || (l.dobM.value=="") || (l.dobY.value==""))

  {

    window.alert("Your Date of Birth cannot be blank");

    return false;

  }

  else if ((l.dobD.value < 1) || (l.dobD.value > 31) || (l.dobM.value < 1) || (l.dobM.value > 12) || (l.dobY.value < 1000) || (l.dobY.value > 3000))

  {

    window.alert("Your Date of Birth is not valid");

    return false;

  }

  else if(l.firstLineAddress.value=="")

  {

    window.alert("The first line of your address cannot be blank");

    return false;

  }

  else if(l.secondLineAddress.value=="")

  {

    window.alert("The second line of your address cannot be blank");

    return false;

  }

  else if(l.postCode.value=="")

  {

    window.alert("Your postcode cannot be blank");

    return false;

  }

  else if(l.contactTel.value=="")

  {

    window.alert("Your contact telephone number cannot be blank");

    return false;

  }

  else if(l.emailAddress.value=="")

  {

    window.alert("Your email address cannot be blank");

    return false;

  }

  else if(l.doctorsName.value=="")

  {

    window.alert("Your doctor's name cannot be blank");

    return false;

  }

  else if(l.firstLineDoctorsAddress.value=="")

  {

    window.alert("The first line of your doctor's address cannot be blank");

    return false;

  }

  else if(l.secondLineDoctorsAddress.value=="")

  {

    window.alert("The second line of your doctor's address cannot be blank");

    return false;

  }

  else if(l.doctorsPostCode.value=="")

  {

    window.alert("Your doctor's postcode cannot be blank");

    return false;

  }

  else if(l.doctorsContactTel.value=="")

  {

    window.alert("Your doctor's contact telephone number cannot be blank");

    return false;

  }

  else if(emailCheck(l.emailAddress.value) == false) {

	return false;

  }

  else if(l.password.value=="")

  {

    window.alert("Your password cannot be blank");

    return false;

  }

  else

  {

    return true;

  }

}



function adminCheckEditClinics(l) 

{

  var exp = /^[0-9]{1,4}$/

  if(l.clinicName.value == "")

  {

    window.alert("You must enter a name for the clinic!");

    return false;

  }

  else if(exp.test(l.sessionCost.value) != true)

  {

    window.alert("You must enter a valid session cost using only numbers!");

    return false;

  }

  else if((l.startBookingTime1.value=="00") && (l.startBookingTime2.value=="00"))

  {

    window.alert("You must select a valid start time for bookings!");

    return false;

  }

  else if((l.endBookingTime1.value=="00") && (l.endBookingTime2.value=="00"))

  {

    window.alert("You must select a valid end time for bookings!");

    return false;

  }

  else if((l.startTime1.value + l.startTime2.value) > (l.endTime1.value + l.endTime2.value))

  {

    window.alert("The start time for bookings is later than the end time. Please correct this before continuing!");

    return false;

  }

  else

  {

    return true;

  }

}



function adminCheckPromotions(l) 

{

  var exp = /^[0-9]{1,4}$/

  if(l.promoCode.value == "")

  {

    window.alert("You must enter a promotional code!");

    return false;

  }

  else if(exp.test(l.deduction.value) != true)

  {

    window.alert("You must enter a valid deduction using only numbers!");

    return false;

  }

  else if((l.startTime1.value=="00") && (l.startTime2.value=="00"))

  {

    window.alert("You must select a valid start time for this promotion!");

    return false;

  }

  else if((l.endTime1.value=="00") && (l.endTime2.value=="00"))

  {

    window.alert("You must select a valid end time for this promotion!");

    return false;

  }

  else if((l.startTime1.value + l.startTime2.value) > (l.endTime1.value + l.endTime2.value))

  {

    window.alert("The start time for this promotion is later than the end time. Please correct this before continuing!");

    return false;

  }

  else

  {

    return true;

  }

}



function setcookie(user, pass)

{

  var username = user;

  var pword = pass;

  var all=username+"/"+pword;

  var user_cookie = "username="+escape(username);

  var pass_cookie = "password="+escape(pword);

  document.cookie = user_cookie;

  document.cookie = pass_cookie;

}

  

function delcookie()

{

  var user_cookie = "username=";

  var pass_cookie = "password=";

  document.cookie = user_cookie;

  document.cookie = pass_cookie;

}



function noUser()

{      

  window.alert($noUserMsg);

  htmlMsg($noUserMsg);

}



function noPass()

{

  window.alert($noPassMsg);

  htmlMsg($noPassMsg);

}



function noForename()

{

  window.alert($blankForename);

  htmlMsg($blankForename);

}



function noSurname()

{

  window.alert($blankSurname);

  htmlMsg($blankSurname);

}



function noAddress()

{

  window.alert($blankAddress);

  htmlMsg($blankAddress);

}



function passMismatch()

{

  window.alert($passNoMatch);

  htmlMsg($passNoMatch);

}

  

function htmlMsg(msg)

{

  loginError.innerText = msg;

}



function emailCheck (emailStr) {



/* The following variable tells the rest of the function whether or not

to verify that the address ends in a two-letter country or well-known

TLD.  1 means check it, 0 means don't. */



var checkTLD=1;



/* The following is the list of known TLDs that an e-mail address must end with. */



var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;



/* 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("Your email address appears to be incorrect");

return false;

}

var user=matchArray[1];

var domain=matchArray[2];



// Start by checking that only basic ASCII characters are in the strings (0-127).



for (i=0; i<user.length; i++) {

if (user.charCodeAt(i)>127) {

alert("Your email address appears to be incorrect (before the '@')");

return false;

   }

}

for (i=0; i<domain.length; i++) {

if (domain.charCodeAt(i)>127) {

alert("Your email address appears to be incorrect (after the '@')");

return false;

   }

}



// See if "user" is valid 



if (user.match(userPat)==null) {



// user is not valid



alert("Your email address appears to be incorrect (before the '@')");

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.  Check if it's valid.

 

var atomPat=new RegExp("^" + atom + "$");

var domArr=domain.split(".");

var len=domArr.length;

for (i=0;i<len;i++) {

if (domArr[i].search(atomPat)==-1) {

alert("Your email address appears to be incorrect (after the '@')");

return false;

   }

}



/* domain name seems valid, but now make sure that it ends in a

known top-level domain (like com, edu, gov) or a two-letter word,

representing country (uk, nl), and that there's a hostname preceding 

the domain or country. */



if (checkTLD && domArr[domArr.length-1].length!=2 && 

domArr[domArr.length-1].search(knownDomsPat)==-1) {

alert("The email address must end in a well-known domain or two letter " + "country.");

return false;

}



// Make sure there's a host name preceding the domain.



if (len<2) {

alert("The email address is missing a hostname!");

return false;

}



// If we've gotten this far, everything's valid!

return true;

}


/**
 * DHTML date validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */
// Declaring valid date character, minimum year and maximum year
var dtCh= "/";
var minYear=1900;
var maxYear=2100;

function isInteger(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

function isDouble(s){
	var i;
    for (i = 0; i < s.length; i++){   
        // Check that current character is number.
        var c = s.charAt(i);
        if ((((c < "0") || (c > "9")) && (c != "."))) return false;
    }
    // All characters are numbers.
    return true;
}

function isTel(s){
	var i;
	
	if (s.length < 10) {
		return false;
	}
	else {
		for (i = 0; i < s.length; i++){   
			// Check that current character is number.
			var c = s.charAt(i);
			if (((c < "0") || (c > "9")) && (c != " ")) {
				return false;
			}
    	}
		 // All characters are numbers.
   		 return true;
	}
   
}

function stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}
function DaysArray(n) {
	for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strDay=dtStr.substring(0,pos1)
	var strMonth=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("Please enter the date in the following format: dd/mm/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month in the date box")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day in the date box")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear+" in the date box")
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date in the date box")
		return false
	}
return true
}

//  End 

-->