<!--
// Added -----------------------
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// ----------------------------------

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//========================================================

function LTrim(str) {
     // We don't want to trip JUST spaces, but also tabs,
    // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
      var whitespace = new String(" \t\n\r");

      var s = new String(str);

    if (whitespace.indexOf(s.charAt(0)) != -1) {
          // We have a string with leading blank(s)...
		 var j=0, i = s.length;
      // Iterate from the far left of string until we
      // don't have any more whitespace...
          while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;

 	// Get the substring from the first non-whitespace
     // character to the end of the string...
         s = s.substring(j, i);
         }
           return s;
    } // EOF LTrim()

function RTrim(str)   {
   // We don't want to trip JUST spaces, but also tabs,
    // line feeds, etc.  Add anything else you want to
   // "trim" here in Whitespace
     var whitespace = new String(" \t\n\r");
 	var s = new String(str);

     if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      // We have a string with trailing blank(s)...
		var i = s.length - 1;       // Get length of string
	// Iterate from the far right of string until we
      // don't have any more whitespace...
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
        i--;

	// Get the substring from the front of the string to
	// where the last non-whitespace character is...
         s = s.substring(0, i+1);
    }
	return s;
 }	// eof RTrim()

function Trim(str)	{
	return RTrim(LTrim(str));
}	// EOF Trim()

//================================
function validEmail(email)  {
 invalidChars = " /:,;";

if ((email == "") || (email == " ")) {
  return false;
  } // endif
  
  for (i=0; i<invalidChars.length; i++) {
   badChar = invalidChars.charAt(i);
   if (email.indexOf(badChar,0) > -1) {
    return false;
   } //endif
  } //endfor

	atPos = email.indexOf("@",1)

	if (atPos == -1) {
  	return false;
	} //endif

	if (email.indexOf("@",atPos+1) > -1) {
	 return false;
	 } //endif

	periodPos = email.indexOf(".",atPos)

	if (periodPos == -1) {
	  return false;
  } //endif

	if (periodPos+3 > email.length) {
  	return false;
  } // endif

// if it gets this far...
	return true
} //  =============== End of email check function

function checkForm()	{
	var f = document.myForm;

	// Check that they have asked for some sort of appointment...(This is a Radio Button check)
	appType = -1;
	for(i=0;i<f.radWhatFor.length;i++)	{
		if(f.radWhatFor[i].checked)	{
			appType = i;
		} // end If
	} //end for
	if(appType == -1)	{
		alert("NO APPOINTMENT\n\nPlease select either an Eye or a Contact lens appointment (or both)\n\n    Thank you");
	window.location.href="#type";
		return false;	
	} // end if

// Check they have entered some sort of Date 
	if((!f.chkMon.checked && !f.chkTue.checked && !f.chkWed.checked && !f.chkThu.checked && !f.chkFri.checked && !f.chkSat.checked) && (f.selMonth.value == "none") && (f.selDate.value == "none") && (!f.chkAsap.checked) ) {
	alert("NO DATE\n\nPlease enter a preferred day and/or date for your appointment\n\n    Thank you");
	window.location.href="#date";
	return false;
	} // end if Date selected

// Check they have put in their name
	if (Trim(f.txtName.value).length < 3) {
	  alert("NAME PROBLEM \n\nThere appears to be something wrong with your name. \n\nPlease enter your name (and any other missing details)\n\n    Thank you");
	window.location.href="#name";
	  f.txtName.focus();
	  f.txtName.select();
	  return false; 
	} //endif no Name

// Check that the name does not contain spaces
	//	myVar = 
	if(f.txtName.value.indexOf("&nbsp;") > 0)	{
  alert("NAME PROBLEM \n\nThere appears to be something wrong with your name. \n\nPlease enter your name (and any other missing details)\n\n    Thank you");
	window.location.href="#name";
	  f.txtName.focus();
	  f.txtName.select();
	  return false; 
	} //endif spaces in the name


// Check for a means of contact
	if ((Trim(f.txtPhoneH.value).length < 3) && (Trim(f.txtPhoneW.value).length < 3) && (Trim(f.txtFax.value).length < 3) && (Trim(f.txtEmail.value).length < 3) && (Trim(f.txtAddress.value).length < 3)) {
	  alert("CONTACT PROBLEM \n\nYou do not appear to have given us the means to contact you. \n\nPlease enter either a phone number, fax or email address \n\n    Thank you");
	window.location.href="#name";
	  f.txtPhoneH.focus();
	  f.txtPhoneH.select();
	  return false; 
	} // endif no contact

//Check their chosen means of contact is valid
//radContact
	contactType = -1;
	for(i=0;i<f.radContact.length;i++)	{
		if(f.radContact[i].checked)	{
			contactType = i;
		} // end If
	} //end for
//
	if(contactType == 0)	{	// Email
		if (!validEmail(Trim(f.txtEmail.value))) 	{
		  alert("CONTACT PROBLEM \n\nYou have chosen to be contacted by Email, but there is a problem\nwith your Email Address \n\nPlease enter a valid email address or select a different method of contact\n\n    Thank you");
			window.location.href="#name";
		  f.txtEmail.focus();
		  f.txtEmail.select();
		  return false; 
		} // endif email is invalid
	} // endif if contact is Email
//
	if(contactType == 1)	{	// phone
		if ((Trim(f.txtPhoneH.value).length < 3) && (Trim(f.txtPhoneW.value).length < 3))	{
		  alert("CONTACT PROBLEM \n\nYou have chosen to be contacted by Phone, but have not entered a phone number\n\nPlease enter a phone number or select a different method of contact\n\n    Thank you");
			window.location.href="#name";
		  f.txtPhoneH.focus();
		  f.txtPhoneH.select();
		  return false;
		} // endif both phone numbers are empty
	} // endif contact is either phone
//
	if(contactType == 2)	{	// fax
		if (Trim(f.txtFax.value).length < 3)	{
		  alert("CONTACT PROBLEM \n\nYou have chosen to be contacted by Fax, but have not entered a fax number\n\nPlease enter a fax number or select a different method of contact\n\n    Thank you");
			window.location.href="#name";
		  f.txtFax.focus();
		  f.txtFax.select();
		  return false;
		} // endif fax is empty
	} // endif contact is fax
//
	if(contactType == 3)	{	// post
		if (Trim(f.txtAddress.value).length < 10)	{
			alert("CONTACT PROBLEM \n\nYou have chosen to be contacted by Post, but do not appear to have provided a postal address\n\nPlease enter a postal address or select a different method of contact\n\n    Thank you");
		window.location.href="#name";
		 f.txtAddress.focus();
		 f.txtAddress.select();
		 return false;
		} // endif no address
	} // endif contact by post

	// If it gets this far...
	return true;
} // EOF checkform
//-->