<!-- hide JS code
var radio=""; //for checking radio button 
function validateForm(myform)  // validate user input
{
    var form_name=myform.name; 

     if (form_name.search(/AppRequest/i)>=0)
     {
        var firm=myform.SuiteFirm; 
        var msg="Please select a Suite/Firm:";
        if (!validateSelect(firm,msg))
          {
            return false;
          }

        var spec=myform.Specialty; 
        var msg="Please select a specialty:";
        if (!validateSelect(spec,msg))
          {
            return false;
          }
 
        var rgroup=myform.AppType;
        if (!validRadio(rgroup))
           {
             rgroup[0].focus(); 
             return false;
           }       
     } 
    
     if (form_name.search(/RefillRequest/i)>=0) 
     {

       if (isBlank(myform.num.value))    // DOB valid?  
        {
         alert("Please tell us how many medications you would like to refill?");
         myform.num.focus();
         return false;
        }

     }

      if (isBlank(myform.FirstName.value))  // first name valid?
      {
          alert("Please enter your first name:");
          myform.FirstName.focus();
          return false;
      }

      if (isBlank(myform.LastName.value))  // last name valid?
      {
          alert("Please enter your last name:");
          myform.LastName.focus();
          return false;
      }


      if (isBlank(myform.Address.value)) // address valid?
      {
        alert("Please enter your address:"); 
        myform.Address.focus();
        return false;
      }
     

      if (isBlank(myform.CityStateZip.value))    // City/State/Zip valid?  
      {
         alert("Please enter City, State and Zip code:");
         myform.CityStateZip.focus();
         return false;
      }
 

      if (isBlank(myform.Phone.value))    // Phone valid?  
      {
         alert("Please enter your phone number:");
         myform.Phone.focus();
         return false;
      }

     if (isBlank(myform.DOB.value))    // DOB valid?  
        {
         alert("Please enter your date of birth (DOB):");
         myform.DOB.focus();
         return false;
        }


     if (form_name.search(/RefillRequest/i)>=0) 
     {

      if (isBlank(myform.PharmName.value))    // DOB valid?  
        {
         alert("Please enter Pharmacy Name:");
         myform.PharmName.focus();
         return false;
        }

       if (isBlank(myform.PharmAddress.value))    //  valid?  
        {
         alert("Please enter Pharmacy Address:");
         myform.PharmAddress.focus();
         return false;
        }

      if (isBlank(myform.PharmPhone.value))    // DOB valid?  
        {
         alert("Please enter Pharmacy Phone Number:");
         myform.PharmPhone.focus();
         return false;
        }

       var cnt=myform.num.value;
       var medname="medname_";
       var dosage="dosage_";
       var frequency="frequency_";  
//       alert ('cnt:'+cnt);
       for (var i = 1; i <=cnt ; i++)
         {           
           var med_name=medname.concat(i);
//           alert ('Med_name:' +med_name);
           var med_msg="Please enter medication name:";
           
           if (!validMed(myform,med_name,med_msg)){
              return false; 
           }
           var dos=dosage.concat(i);

           var dos_msg="Please enter medication dosage:";
           
           if (!validMed(myform,dos,dos_msg)){
              return false; 
           }

           var freq=frequency.concat(i);
           var freq_msg="Please enter medication frequency:";
           
           if (!validMed(myform,freq,freq_msg)){
              return false; 
           }

        }
  
     }   
/*
      if (!validateEmail(myform.email.value))    // Email valid?  
      {
         myform.email.focus()
         return false
      }


      if (isBlank(myform.hs_college_name.value))    // School valid?  
      {
         alert("Please enter your school name:");
         myform.hs_college_name.focus();
         return false;
      }

      if (!validateEvent(myform))  // Seen valid?
      {
         return false
      }
*/
      return true
}


function validMed(myform,input_name,msg)
{
    var item=myform.elements;
    for (var i=0; i<item.length; i++)
    {  
//       alert("please select for "+item[i].name+".");     
       if (item[i].name==input_name) //find the proper field name
         {
          if (isBlank(item[i].value)) //check if only the first item on the list is selected which starts with "Select..."
          {
             alert(msg); 
             item[i].focus();
             return false; 
          }
       }                  
    }
    return true;

}

function validateText(text,msg) // valid the Text field
  {
  if (isBlank(text))               // text field blank?
    {
    alert(msg);
    return false
    }
  return true
  }

function isBlank(testStr) // check if a field is blank
  {
  if (testStr.length == 0)                     // nothing entered?
    return true
  for (var i = 0; i <= testStr.length-1; i++)  // all spaces?
    if (testStr.charAt(i) != " ")
      return false
  return true
  }


function validateEmail(email) // Check if email is valid, not use here
  {
  if (isBlank(email))                       // email blank?
    {
    alert("Please enter your valid email address. A vaild email address should be in the format of emailname@somewhere.com")
    return false
    }
  var atsignPos = email.indexOf("@", 0)     // check for @
  if (atsignPos == -1)  
    {
    alert("Please enter a valid email address with an @:")
    return false
    }
  if (email.indexOf(".", atsignPos) == -1)  // check for . after @      
    {
    alert("Please enter a valid email domain after the @:")
    return false
    }
  return true
  }


function validRadio(radiogroup)
{
    var itemchecked=false;
    for (var j=0; j<radiogroup.length; j++){
            if (radiogroup[j].checked){
                if (j==0){ // check if Seen is yes or no, assign to the global variable radio
                    radio="yes";
                }else if (j==1){ // Seen is no
                    radio="no"
                }
                itemchecked=true;
                break
            }
     }
     if(!itemchecked) { // if nothing is checked for Seen radio button
//      alert("Please choose an answer for "+el[i].name+".");
        alert("Please tell us what you would like to do by checking the proper radio button:")   
        return false;
     }
     return true;
}

function validateEvent(form) //check if Seen radio button is checked, working properly
  {
  var el=form.elements;
  for (var i=0; i<el.length; i++){
      if (el[i].type=="radio"){
         var radiogroup=  el[el[i].name];
         var itemchecked=false;
         for (var j=0; j<radiogroup.length; j++){
            if (radiogroup[j].checked){
                if (j==0){ // check if Seen is yes or no, assign to the global variable radio
                    radio="yes";
                }else if (j==1){ // Seen is no
                    radio="no"
                }
                itemchecked=true;
                break
            }
         }
   if(!itemchecked) { // if nothing is checked for Seen radio button
//    alert("Please choose an answer for "+el[i].name+".");
    alert("Please select the event you would like to attend:")   
   if(el[i].focus)
     el[i].focus();
     return false;
   }
  }
 }
 return true;
}   

function validateSelect(item,msg) //check if a selection is valid, working properly
{
     if (item.selectedIndex==0) //check if only the first item on the list is selected which starts with "Select..."
          {
             alert(msg); 
             item.focus();
             return false; 
          }
     return true;   
}   


function populate(o)
 {
	d=document.getElementById('de');
	if(!d){return;}			
	   var mitems=new Array();
	   mitems['Select Suite/Firm']=['Select Suite/Firm First'];
	   mitems['Suite/Firm A']=['Select Specialty','Dermatology','Coumadin Clinic','General Medicine','Behavioral Health'];
	   mitems['Suite/Firm B']=['Select Specialty','General Medicine','Geriatrics', 'Behavioral Health'];
	   mitems['Suite/Firm C']=['Select Specialty','Nephrology','Gastroenterology','Rheumatology','Pulmonology'];
	   d.options.length=0;
	   cur=mitems[o.options[o.selectedIndex].value];
	   if(!cur){return;}
	   d.options.length=cur.length;
	   for(var i=0;i<cur.length;i++)
	       {
		   d.options[i].text=cur[i];
		   d.options[i].value=cur[i];
	       }
 }

function showphone(o)
 {
//	d=document.getElementById('ph');
//        d=o; 
//	if(!d){return;}			
	   var pitems=new Array();
	   pitems['General Medicine']=['315.464.5240'];
	   pitems['Dermatology']=['315.464.3833'];
	   pitems['Coumadin Clinic']=['315.464.5240'];
	   pitems['Behavioral Health']=['315.464.5240'];
	   pitems['Geriatrics']=['315.464.6100'];
	   pitems['Nephrology']=['315.464.3834'];
	   pitems['Pulmonology']=['315.464.3835'];
	   pitems['Rheumatology']=['315.464.3836'];
	   pitems['Gastroenterology']=['315.464.5788. Please note that appointment scheduling is only for patients seen in Firm C by GI Fellows'];
	   cur=pitems[o.options[o.selectedIndex].value];
	   if(!cur){return;}
           alert('Warning: this site is not for any emergency appointment request. For a medical emergency, please call 911. To request an urgent appointment, please Call '+cur+ '.');           
//           parent.document.write('<p>Please Call '+cur+ '.</p>');
 }

// end JS hide -->
