function pichl1(path){
  if (path) {
    document.getElementById("im1").src=path+"/images/welcome_hl.gif";
    document.getElementById("sp1").src=path+"/images/spbg1.gif";
  } else {
    document.getElementById("im1").src="/images/welcome_hl.gif";
    document.getElementById("sp1").src="/images/spbg1.gif";
  }
}
function pic1(path){
  if (path) {
    document.getElementById("im1").src=path+"/images/welcome.gif";
    document.getElementById("sp1").src=path+"/images/spbg.gif";
  } else {
    document.getElementById("im1").src="/images/welcome.gif";
    document.getElementById("sp1").src="/images/spbg.gif";
  }
}

function pichl2(path){
  if (path) {
    document.getElementById("im2").src=path+"/images/reason_hl.gif";
    document.getElementById("sp1").src=path+"/images/spbg1.gif";
    document.getElementById("sp2").src=path+"/images/spbg1.gif";
  } else {
    document.getElementById("im2").src="/images/reason_hl.gif";
    document.getElementById("sp1").src="/images/spbg1.gif";
    document.getElementById("sp2").src="/images/spbg1.gif";
  }
}
function pic2(path){
  if (path) {
    document.getElementById("im2").src=path+"/images/reason.gif";
    document.getElementById("sp1").src=path+"/images/spbg.gif";
    document.getElementById("sp2").src=path+"/images/spbg.gif";
  } else {
    document.getElementById("im2").src="/images/reason.gif";
    document.getElementById("sp1").src="/images/spbg.gif";
    document.getElementById("sp2").src="/images/spbg.gif";
  }
}

function pichl3(path){
  if (path) {
    document.getElementById("im3").src=path+"/images/hipaa_hl.gif";
    document.getElementById("sp2").src=path+"/images/spbg1.gif";
    document.getElementById("sp3").src=path+"/images/spbg1.gif";
  } else {
    document.getElementById("im3").src="/images/hipaa_hl.gif";
    document.getElementById("sp2").src="/images/spbg1.gif";
    document.getElementById("sp3").src="/images/spbg1.gif";
  }
}
function pic3(path){
  if (path) {
    document.getElementById("im3").src=path+"/images/hipaa.gif";
    document.getElementById("sp2").src=path+"/images/spbg.gif";
    document.getElementById("sp3").src=path+"/images/spbg.gif";
  } else {
    document.getElementById("im3").src="/images/hipaa.gif";
    document.getElementById("sp2").src="/images/spbg.gif";
    document.getElementById("sp3").src="/images/spbg.gif";
  }
}

function pichl4(path){
  if (path) {
    document.getElementById("im4").src=path+"/images/faq_hl.gif";
    document.getElementById("sp3").src=path+"/images/spbg1.gif";
    document.getElementById("sp4").src=path+"/images/spbg1.gif";
  } else {
    document.getElementById("im4").src="/images/faq_hl.gif";
    document.getElementById("sp3").src="/images/spbg1.gif";
    document.getElementById("sp4").src="/images/spbg1.gif";
  }
}
function pic4(path){
  if (path) {
    document.getElementById("im4").src=path+"/images/faq.gif";
    document.getElementById("sp3").src=path+"/images/spbg.gif";
    document.getElementById("sp4").src=path+"/images/spbg.gif";
  } else {
    document.getElementById("im4").src="/images/faq.gif";
    document.getElementById("sp3").src="/images/spbg.gif";
    document.getElementById("sp4").src="/images/spbg.gif";
  }
}

function pichl5(path){
  if (path) {
    document.getElementById("im5").src=path+"/images/price_hl.gif";
    document.getElementById("sp4").src=path+"/images/spbg1.gif";
    document.getElementById("sp5").src=path+"/images/spbg1.gif";
  } else {
    document.getElementById("im5").src="/images/price_hl.gif";
    document.getElementById("sp4").src="/images/spbg1.gif";
    document.getElementById("sp5").src="/images/spbg1.gif";
  }
}
function pic5(path){
  if (path) {
    document.getElementById("im5").src=path+"/images/price.gif";
    document.getElementById("sp4").src=path+"/images/spbg.gif";
    document.getElementById("sp5").src=path+"/images/spbg.gif";
  } else {
    document.getElementById("im5").src="/images/price.gif";
    document.getElementById("sp4").src="/images/spbg.gif";
    document.getElementById("sp5").src="/images/spbg.gif";
  }
}

function pichl6(path){
  if(path) {
    document.getElementById("im6").src=path+"/images/contact_hl.gif";
    document.getElementById("sp5").src=path+"/images/spbg1.gif";
    document.getElementById("sp6").src=path+"/images/spbg1.gif";
  } else {
    document.getElementById("im6").src="/images/contact_hl.gif";
    document.getElementById("sp5").src="/images/spbg1.gif";
    document.getElementById("sp6").src="/images/spbg1.gif";
  }
}
function pic6(path){
  if (path) {
    document.getElementById("im6").src=path+"/images/contact.gif";
    document.getElementById("sp5").src=path+"/images/spbg.gif";
    document.getElementById("sp6").src=path+"/images/spbg.gif";
  } else {
    document.getElementById("im6").src="/images/contact.gif";
    document.getElementById("sp5").src="/images/spbg.gif";
    document.getElementById("sp6").src="/images/spbg.gif";
  }
}

function pichl7(path){
  if (path) {
    document.getElementById("im7").src=path+"/images/careers_hl.gif";
    document.getElementById("sp6").src=path+"/images/spbg1.gif";
  } else {
    document.getElementById("im7").src="/images/careers_hl.gif";
    document.getElementById("sp6").src="/images/spbg1.gif";
  }
}
function pic7(path){
  if (path) {
    document.getElementById("im7").src=path+"/images/careers.gif";
    document.getElementById("sp6").src=path+"/images/spbg.gif";
  } else {
    document.getElementById("im7").src="/images/careers.gif";
    document.getElementById("sp6").src="/images/spbg.gif";
  }
}

function viewform(m, w, h, scrol) {
   var scroll = 'yes';
   var settings;
   var LeftPosition;
   var TopPosition;
   var win;

   if (!scrol) scrol = 'no';

   LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
   TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
  
   settings = 'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll;

   if (scrol == 'no') settings = settings + ',resizable=no,maximize=no';
   if (scrol == 'yes') settings = settings + ',resizable=yes,maximize=yes';

   settings = settings + ',status=no,toolbar=no,directories=no,menubar=no,location=no';
		      
   win = window.open(m, 'pre', settings);
   win.name = 'name';
   win.focus();
}


function do_submit() {  
    Stamp = new Date();
    f = 1;
    error = '';                 
    state_index = document.ApplicationForm.get_ref_state.selectedIndex;

    if (document.ApplicationForm.practice_name.value == '') {
        document.ApplicationForm.practice_name.className = 'input red';
        f = 0;
    } else document.ApplicationForm.practice_name.className = 'input';

    if (document.ApplicationForm.office_name.value == '') {
        document.ApplicationForm.office_name.className = 'input red';
        f = 0;
    } else document.ApplicationForm.office_name.className = 'input';

    if (document.ApplicationForm.office_addr.value == '') {
        document.ApplicationForm.office_addr.className = 'input red';
        f = 0;
    } else document.ApplicationForm.office_addr.className = 'input';

    if (document.ApplicationForm.city.value == '') {
        document.ApplicationForm.city.className = 'input red';
        f = 0;
    } else document.ApplicationForm.city.className = 'input';

    if (state_index == 0) {
        document.ApplicationForm.get_ref_state.className = 'input red';
        f = 0;
    } else document.ApplicationForm.get_ref_state.className = 'input';

    if (document.ApplicationForm.zip.value == '') {
        document.ApplicationForm.zip.className = 'input red';
        f = 0;
    } else document.ApplicationForm.zip.className = 'input';

    if (document.ApplicationForm.phone.value == '') {
        document.ApplicationForm.phone.className = 'input red';
        f = 0;
    } else document.ApplicationForm.phone.className = 'input';

    if (document.ApplicationForm.private_line.value == '') {
        document.ApplicationForm.private_line.className = 'input red';
        f = 0;
    } else document.ApplicationForm.private_line.className = 'input';

    if (document.ApplicationForm.fax.value == '') {
        document.ApplicationForm.fax.className = 'input red';
        f = 0;
    } else document.ApplicationForm.fax.className = 'input';

    if (document.ApplicationForm.email.value == '' || !isValidEmail(document.ApplicationForm.email.value)) {
        document.ApplicationForm.email.className = 'input red';
        f = 0;
    } else {
        document.ApplicationForm.email.className = 'input';
    }

    if (document.ApplicationForm.speciality.value == '') {
        document.ApplicationForm.speciality.className = 'input red';
        f = 0;
    } else document.ApplicationForm.phone.className = 'input';
                                                 
    if (document.ApplicationForm.mon_closed.checked == false) { 
        if (document.ApplicationForm.mon_from.value == '') { 
        document.ApplicationForm.mon_from.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.mon_from.className = 'input';
        }
        if (document.ApplicationForm.mon_to.value == '') { 
        document.ApplicationForm.mon_to.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.mon_to.className = 'input';
        }
    } else {
        document.ApplicationForm.mon_from.className = 'input';
        document.ApplicationForm.mon_to.className = 'input';
    }

    if (document.ApplicationForm.tue_closed.checked == false) { 
        if (document.ApplicationForm.tue_from.value == '') { 
        document.ApplicationForm.tue_from.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.tue_from.className = 'input';
        }
        if (document.ApplicationForm.tue_to.value == '') { 
        document.ApplicationForm.tue_to.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.tue_to.className = 'input';
        }
    } else {
        document.ApplicationForm.tue_from.className = 'input';
        document.ApplicationForm.tue_to.className = 'input';
    }

    if (document.ApplicationForm.wed_closed.checked == false) { 
        if (document.ApplicationForm.wed_from.value == '') { 
        document.ApplicationForm.wed_from.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.wed_from.className = 'input';
        }
        if (document.ApplicationForm.wed_to.value == '') { 
        document.ApplicationForm.wed_to.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.wed_to.className = 'input';
        }
    } else {
        document.ApplicationForm.wed_from.className = 'input';
        document.ApplicationForm.wed_to.className = 'input';
    }

    if (document.ApplicationForm.thu_closed.checked == false) { 
        if (document.ApplicationForm.thu_from.value == '') { 
        document.ApplicationForm.thu_from.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.thu_from.className = 'input';
        }
        if (document.ApplicationForm.thu_to.value == '') { 
        document.ApplicationForm.thu_to.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.thu_to.className = 'input';
        }
    } else {
        document.ApplicationForm.thu_from.className = 'input';
        document.ApplicationForm.thu_to.className = 'input';
    }

    if (document.ApplicationForm.fri_closed.checked == false) { 
        if (document.ApplicationForm.fri_from.value == '') { 
        document.ApplicationForm.fri_from.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.fri_from.className = 'input';
        }
        if (document.ApplicationForm.fri_to.value == '') { 
        document.ApplicationForm.fri_to.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.fri_to.className = 'input';
        }
    } else {
        document.ApplicationForm.fri_from.className = 'input';
        document.ApplicationForm.fri_to.className = 'input';
    } 

    if (document.ApplicationForm.sat_closed.checked == false) { 
        if (document.ApplicationForm.sat_from.value == '') { 
        document.ApplicationForm.sat_from.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.sat_from.className = 'input';
        }
        if (document.ApplicationForm.sat_to.value == '') { 
        document.ApplicationForm.sat_to.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.sat_to.className = 'input';
        }
    } else {
        document.ApplicationForm.sat_from.className = 'input';
        document.ApplicationForm.sat_to.className = 'input';
    }

    if (document.ApplicationForm.sun_closed.checked == false) { 
        if (document.ApplicationForm.sun_from.value == '') { 
        document.ApplicationForm.sun_from.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.sun_from.className = 'input';
        }
        if (document.ApplicationForm.sun_to.value == '') { 
        document.ApplicationForm.sun_to.className = 'input red';
        f = 0;
        } else { 
        document.ApplicationForm.sun_to.className = 'input';
        }
    } else {
        document.ApplicationForm.sun_from.className = 'input';
        document.ApplicationForm.sun_to.className = 'input';
    }

    for (var i=1; i<= document.ApplicationForm.get_ref_numbers.selectedIndex; i++) { 
      var phys = 'get_phys_'+i;                
      var phys_home = 'get_phys_home_'+i;
      var phys_cell = 'get_phys_cell_'+i;
      var phys_carrier = 'get_phys_carrier_'+i;
      var phys_addr = 'get_phys_addr_'+i;
      var phys_method = 'get_contact_method_'+i;

      if (document.ApplicationForm.elements[phys].value == '') {
        document.ApplicationForm.elements[phys].className = 'input red';
        f = 0;
      } else {
        document.ApplicationForm.elements[phys].className = 'input';
      }
                                                                    //  alert(document.ApplicationForm.elements[phys_method].selectedIndex);
      if (document.ApplicationForm.elements[phys_method].selectedIndex == 0) {
        if (document.ApplicationForm.elements[phys_cell].value == '') {
          document.ApplicationForm.elements[phys_cell].className = 'input red';
          f = 0;
        } else {
          document.ApplicationForm.elements[phys_cell].className = 'input';
        } 
        if (document.ApplicationForm.elements[phys_carrier].value == '') {
          document.ApplicationForm.elements[phys_carrier].className = 'input red';
          f = 0;
        } else {
          document.ApplicationForm.elements[phys_carrier].className = 'input';
        } 
      }

      if (document.ApplicationForm.elements[phys_method].selectedIndex == 2) {
        if (document.ApplicationForm.elements[phys_addr].value == '' || !isValidEmail(document.ApplicationForm.elements[phys_addr].value)) {
          document.ApplicationForm.elements[phys_addr].className = 'input red';
          f = 0;
        } else {
          document.ApplicationForm.elements[phys_addr].className = 'input';
        } 
      }

      if (document.ApplicationForm.elements[phys_method].selectedIndex == 3 || document.ApplicationForm.elements[phys_method].selectedIndex == 5 || document.ApplicationForm.elements[phys_method].selectedIndex == 6) {
        if (document.ApplicationForm.elements[phys_home].value == '') {
          document.ApplicationForm.elements[phys_home].className = 'input red';
          f = 0;
        } else {
          document.ApplicationForm.elements[phys_home].className = 'input';
        } 
        if (document.ApplicationForm.elements[phys_cell].value == '') {
          document.ApplicationForm.elements[phys_cell].className = 'input red';
          f = 0;
        } else {
          document.ApplicationForm.elements[phys_cell].className = 'input';
        } 
      }

    }

    if (document.ApplicationForm.get_ref_another_practice.value == 'Yes') {            
      for (var i=1; i<= document.ApplicationForm.get_ref_another_practice_amt.selectedIndex+1; i++) {
        var out_phys = 'get_out_phys_'+i;
        var office_phys = 'get_phys_office_'+i;

        if (document.ApplicationForm.elements[out_phys].value == '') {
          document.ApplicationForm.elements[out_phys].className = 'input red';
          f = 0;
        } else {
          document.ApplicationForm.elements[out_phys].className = 'input';
        }

        if (document.ApplicationForm.elements[office_phys].value == '') {
          document.ApplicationForm.elements[office_phys].className = 'input red';
          f = 0;
        } else {
          document.ApplicationForm.elements[office_phys].className = 'input';
        }

      }
    }
                                 

    if (document.ApplicationForm.bil_fname.value == '') {
        document.ApplicationForm.bil_fname.className = 'input red';
        f = 0;
    } else document.ApplicationForm.bil_fname.className = 'input';

    if (document.ApplicationForm.bil_lname.value == '') {
        document.ApplicationForm.bil_lname.className = 'input red';
        f = 0;
    } else document.ApplicationForm.bil_lname.className = 'input';

    if ((document.ApplicationForm.get_cc_type.value == 'MasterCard' && document.ApplicationForm.get_cc_num.value.length != '16') || (document.ApplicationForm.get_cc_type.value == 'Visa' && document.ApplicationForm.get_cc_num.value.length != '16')) {
        document.ApplicationForm.get_cc_num.className = 'input red';
        f = 0;
    } else document.ApplicationForm.get_cc_num.className = 'input';

    if (document.ApplicationForm.get_cc_code.value == '') {
        document.ApplicationForm.get_cc_code.className = 'input red';
        f = 0;
    } else document.ApplicationForm.get_cc_code.className = 'input';

    if (((eval(document.ApplicationForm.get_cc_expire_year.value) + eval(2000)) < (Stamp.getYear()+1900)) || (((eval(document.ApplicationForm.get_cc_expire_year.value)) == (Stamp.getYear() + 1900)) && (eval(document.ApplicationForm.get_cc_expire_month.value) < (Stamp.getMonth()+1) ) )) {
        document.ApplicationForm.get_cc_expire_month.className = 'input red';
        document.ApplicationForm.get_cc_expire_year.className = 'input red';
        f = 0;
    } else {
        document.ApplicationForm.get_cc_expire_month.className = 'input';
        document.ApplicationForm.get_cc_expire_year.className = 'input';
    }

    if (document.ApplicationForm.bil_addr1.value == '') {
        document.ApplicationForm.bil_addr1.className = 'input red';
        f = 0;
    } else document.ApplicationForm.bil_addr1.className = 'input';

    if (document.ApplicationForm.bil_city.value == '') {
        document.ApplicationForm.bil_city.className = 'input red';
        f = 0;
    } else document.ApplicationForm.bil_city.className = 'input';

    if (document.ApplicationForm.get_billing_ref_state.selectedIndex == 0) {
        document.ApplicationForm.get_billing_ref_state.className = 'input red';
        f = 0;
    } else document.ApplicationForm.get_billing_ref_state.className = 'input';

    if (document.ApplicationForm.bil_zip.value == '') {
        document.ApplicationForm.bil_zip.className = 'input red';
        f = 0;
    } else document.ApplicationForm.bil_zip.className = 'input';

    if (!document.ApplicationForm.agree.checked) {
        document.ApplicationForm.agree.className = 'input red';
        f = 0;
        error = error + 'You MUST agree with the License Agreement\n';
    } else document.ApplicationForm.agree.className = 'input';


  //    document.ApplicationForm.submit() ;

     if (f) {document.ApplicationForm.submit();
     
     }
     else {
       if (error) alert(error);
     }
//   return false;

}


function isValidEmail(strEmail){
    validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
    if (strEmail.search(validRegExp) == -1) {
        return false;
    } 
    return true;    
}


 

