function MM_findObj(n, d) { //v3.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); return x;
}

/* Functions that swaps images. */
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 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 fwLoadMenus() {
  if (window.fw_menu_0) return;
  window.fw_menu_0 = new Menu("root",116,19,"Arial, Helvetica, sans-serif",12,"#497381","#497381","#e3efd6","#c5dcce");
  fw_menu_0.addMenuItem("About Us","location='about.htm'");
  fw_menu_0.addMenuItem("Testimonial","location='testimonial.htm'");
  fw_menu_0.addMenuItem("Map - Directions","location='map.htm'");
  fw_menu_0.addMenuItem("Office Tour","location='tour.htm'");
  fw_menu_0.addMenuItem("Dr. Bender's CV","location='drcv.htm'");
   fw_menu_0.hideOnMouseOut=true;
  window.fw_menu_1 = new Menu("root",139,19,"Arial, Helvetica, sans-serif",12,"#497381","#497381","#e3efd6","#c5dcce");
  fw_menu_1.addMenuItem("What's New","location='whatsnew.htm'");
  fw_menu_1.addMenuItem("Newsletter","location='newsletter.htm'");
  fw_menu_1.addMenuItem("Educational Seminars","location='seminars.htm'");
  fw_menu_1.addMenuItem("Register On-line","location='registration.htm'");
   fw_menu_1.hideOnMouseOut=true;
  window.fw_menu_2 = new Menu("root",140,19,"Arial, Helvetica, sans-serif",12,"#497381","#497381","#e3efd6","#c5dcce");
  fw_menu_2.addMenuItem("Chiropractic Care","location='care.htm'");
  fw_menu_2.addMenuItem("Nerve Chart","location='nervechart.htm'");
  fw_menu_2.addMenuItem("Health Questionnaires","location='medquest.htm'");
  fw_menu_2.addMenuItem("Lower Back","location='lowerback.htm'");
  fw_menu_2.addMenuItem("Headaches","location='headaches.htm'");
  fw_menu_2.addMenuItem("Arthritis","location='arthritis.htm'");
  fw_menu_2.addMenuItem("Neck Pain","location='neckpain.htm'");
  fw_menu_2.addMenuItem("Whiplash","location='whiplash.htm'");
  fw_menu_2.addMenuItem("Extremities","location='extremities.htm'");
  fw_menu_2.addMenuItem("Carpal Tunnel","location='carpaltunnel.htm'");
  fw_menu_2.addMenuItem("Disc","location='disc.htm'");
  fw_menu_2.addMenuItem("Sciatica","location='sciatica.htm'");
  fw_menu_2.addMenuItem("Pregnancy","location='pregnancy.htm'");
  fw_menu_2.addMenuItem("Depression ","location='depression.htm'");
  fw_menu_2.addMenuItem("Irritable Bowel Syndrome ","location='irritablebowel.htm'");
  fw_menu_2.addMenuItem("Fibromyalgia","location='fibromyalgia.htm'");
  fw_menu_2.addMenuItem("Vertigo","location='vertigo.htm'");
  fw_menu_2.addMenuItem("Incontinence ","location='incontinence.htm'");
  fw_menu_2.addMenuItem("Tremors ","location='tremors.htm'");
  fw_menu_2.addMenuItem("Weight Loss ","location='weightloss.htm'");						
  fw_menu_2.hideOnMouseOut=true;
  window.fw_menu_3 = new Menu("root",148,19,"Arial, Helvetica, sans-serif",12,"#497381","#497381","#e3efd6","#c5dcce");
  fw_menu_3.addMenuItem("Caring For You","location='caring.htm'");
  fw_menu_3.addMenuItem("Family Care","location='family.htm'");
  fw_menu_3.addMenuItem("Worker's Compensation","location='workerscomp.htm'");
  fw_menu_3.addMenuItem("Wellness Services","location='wellness.htm'");
  fw_menu_3.addMenuItem("Nutrition Counseling","location='nutrition.htm'");
  fw_menu_3.addMenuItem("Pain Control Therapy","location='paincontrol.htm'");
  fw_menu_3.addMenuItem("Specialized Lab Tests","location='specializedlab.htm'");
  fw_menu_3.addMenuItem("Other","location='other.htm'");
   fw_menu_3.hideOnMouseOut=true;

  fw_menu_3.writeMenus();
} // fwLoadMenus()

function Verify(formType) {

	var FormGood=true;
	var MissingMessage='The Following Fields Must Be Filled In or Corrected:\n';
	var msg ='';
	var emailmatch='';
    
	
    if (document.forms['FORM'].Name.value=='' ) {
		FormGood=false;
		MissingMessage+='Name\n';
		}
    else if (!testName(document.forms['FORM'].Name)){
		FormGood=false;
		msg+='Name is invalid.\n';
		}

    if ( document.forms['FORM'].Email.value=='' ) {
		FormGood=false;
		MissingMessage+='E-Mail\n';
		}
	else if (!testEmail(document.forms['FORM'].Email)){
        FormGood=false;		
		msg+='The email address is invalid: '+ document.forms['FORM'].Email.value + '\n';
		}

	if ( document.forms['FORM'].Email2.value=='' ) {
		FormGood=false;
		MissingMessage+='Confirm E-Mail\n';
		}
	else if (!testEmail(document.forms['FORM'].Email2)){
		FormGood=false;
		msg+='The confirmed email address is invalid: '+ document.forms['FORM'].Email2.value + '\n';
		}
		
    if ((document.forms['FORM'].Email.value!='') && (document.forms['FORM'].Email2.value!='')) {
		if(document.forms['FORM'].Email2.value != document.forms['FORM'].Email.value){
			FormGood=false;
			emailmatch ='\nE-Mail addresses do not match.\n';
		}
        }
	if ( document.forms['FORM'].Phone.value=='' ) {
		FormGood=false;
		MissingMessage+='Phone\n';
		}
	//else if (!validateUSPhone(document.forms['FORM'].Phone)){
	    
		//FormGood=false;
		//msg+='The phone number should be (999)999-9999 or (999) 999-9999: '+ document.forms['FORM'].Phone.value + '\n';
    	//	}
    if (((formType == "Candida") || (formType == "Gluten")) || (formType == "Hypoglycemia")){

	if ( document.forms['FORM'].Age.value=='' ) {
		FormGood=false;
		MissingMessage+='Age\n';
	}
    else if ( !testNumber(document.forms['FORM'].Age) ) {
	    FormGood=false;
		msg+='Age should be numeric.\n';
		}	

	if ( document.forms['FORM'].Sex.value=='' ) {
		
		FormGood=false;
		MissingMessage+='Sex\n';
		}
	
//	else if  (!testSex(document.forms['FORM'].Sex)){
//				FormGood=false;
//				msg+="Sex should be 'M' or 'F'.\n";
//			}
	
	if ( document.forms['FORM'].Weight.value=='' ) {
		FormGood=false;
		MissingMessage+='Weight\n';
		}
    else if ( !testNumber(document.forms['FORM'].Weight) ) {
		FormGood=false;
		msg+='Weight should be numeric.\n';
		}

	if ( document.forms['FORM'].Height.value=='' ) {
		FormGood=false;
		MissingMessage+='Height\n';
		}
    else if ( !testNumber(document.forms['FORM'].Height) ) {
		FormGood=false;
		msg+='Height should be numeric.\n';
		}

	}//end if formType		

	if (FormGood==true){
        document.forms['FORM'].submit();
	}
    else{
		alert( MissingMessage+msg+emailmatch);
		if(emailmatch!=''){
	
    		document.forms['FORM'].Email.value='';
			document.forms['FORM'].Email2.value='';
			document.forms['FORM'].Email.focus();
		}

		return false;

	}

} //End Verify

	
function testSex(src) {
    if ((src.value == "M") || (src.value =="F")){
        return true;
    }
    else
    {
        return false;
    }

}// end testSex
function testEmail(src) {

     var emailReg ="^[\\w-\.]{1,}\@([\\da-zA-Z-]{1,}\.){1,}[\\da-zA-Z-]{2,3}$";

     var regex = new RegExp(emailReg);

     return regex.test(src.value);

  }
function validateUSPhone(src) {
    
    var regex  = /^\([1-9]\d{2}\)\s?\d{3}\-\d{4}$/;
    return regex.test(src.value);
}  // End function validateUSPhone(src)


function testNumber(src) {

var allValid = true
var checkNumber = "0123456789"
var numberCheck
			
			numberCheck = src.value
	        for (i = 0;  i < numberCheck.length;  i++)
	        {
                ch = numberCheck.charAt(i);
				        for (j = 0;  j < checkNumber.length;  j++)
                        if (ch == checkNumber.charAt(j))
                                break;
                        if (j == checkNumber.length)
                        {
                                allValid = false;
                                break;
                        }
	        }
	        if (!allValid)
	        {
		     return false;
	        } else
			{
			return true;
			}

}


function testName(src)
{
var checkName = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ .,-"
var nameCheck
var allValid = true
            
	        nameCheck = src.value
	        
	        for (i = 0;  i < nameCheck.length;  i++)
	        {
                
                ch = nameCheck.charAt(i);
                
                for (j = 0;  j < checkName.length;  j++)
                {
                    
                    if (ch == checkName.charAt(j)) {
                            break;
                        }
                    if (j == (checkName.length - 1))
                    {       allValid = false;
                            break;
                    }
                }
	        }
	        if (!allValid)
	        {
             return false;
	        }else
			{
			return true;
			}

}
