var URL = "vision_hearing_help.html"


function isEmpty(s)
{
   return((s == null) || (s.length == 0));
}

function isBlank(s)
{
   var i;
   if (isEmpty(s))
   {
      return true;
   }for (i = 0; i < s.length; i++)
   {
      var c = s.charAt(i);
      if ((c != ' ') && (c != '\n') && (c != '\t'))
      {
         return false;
      }
   }
   return true;
}
function warnEmpty (theField, s)
{
   theField.focus();
   alert( "The " + s + " field can not be empty.  Also white spaces are not allowed in the " + s + " field.");
   return false;
}
function checkRequired(theField, s)
{
   v = theField[theField.selectedIndex].value;
   if (isEmpty(v))
   {
      alert(s);
      location.hash = theField.name;
      theField.focus();
      return false;
   }
   if (isBlank(v))
   {
      return warnEmpty (theField, s);
   } else
   {
      return true;
   }
}

function checkHospAffil(plan, hospital)
{
   var PlanType = plan[plan.selectedIndex].value;
   if (PlanType != "PPOCB")
   {
      alert( "Hospital affiliations are only available for Community Blue and Blue Preferred PPO providers." );
      hospital.selectedIndex = 0;
      hospital.focus();
      return false;
   }
   return true
}
function isBcnOrPos(b,theField)
{
   if (theField.value == null || theField.value.length == 0)
   {
      return false;
   }
   var PlanType = b.elements["planType"].value;
   if ((PlanType == "03") || (PlanType == "04") || (PlanType == "05") || (PlanType == "06") || (PlanType == "15"))
   {
      return true;
   }
   alert("This option is for BCN or POS plans only.\n\nPlease select either a BCN or a POS plan before selecting this.");
   theField.value = "";
   return false;
}

function verifyPlansAndSelections(theForm)
{
if ((PlanType != "TVPP") && (PlanType != "TVXX") && (PlanType != "THPP") && (PlanType != "THDO"))
   {
      for (i=0; i<theForm.length; i++)
      {
         if (theForm.elements[i].name == "provType")
         {
            theForm.elements[i].checked = false;
         }
      }
   }
}

function verifyDistance(theForm)
{
   var street = theForm.elements["streetAdd"].value;
   var city = theForm.elements["city"].value;
   var zip = theForm.elements["zipCode"].value;
   var dis = theForm.elements["distance"].value;
   if (dis != null && dis.length > 0)
   {
      if (city != null && city.length > 0)
      {
         return true;
      } else if (zip != null && zip.length > 0 )
      {
         return true;
      } else
      {
         var state = theForm.elements["state"].value;
         alert ("To locate a provider near you,\nyou will need to fill in either zip code or city.\n\nThe more information that you fill in, the more accurate the results will be.");
         if (street == null || street.length == 0)
         {
            theForm.elements["streetAdd"].focus();
         }
         if (city == null || city.length == 0)
         {
            theForm.elements["city"].focus();
         }
         if (state == null || state.length == 0)
         {
            theForm.elements["state"].focus();
         }
         if (zip == null || zip.length == 0)
         {
            theForm.elements["zipCode"].focus();
         }
         return false;
      }
   }
   return true;
}
function checkState(theField)
{
   if (theField.value != null && theField.value.length > 0)
   {
      var val = theField.value;
      if (!(val == "MI" || val == "mi" || val == "Mi" || val == "mI"))
      {
         alert( "Most of our providers practice in the state of Michigan." );
      }
   }
}
function verify(form)
{
   
   return(verifyDistance(form));
}
function providerBcnId(planType, pNum)
{
   var pType = planType[planType.selectedIndex].value;
   if ((pType != "03") && (pType != "04") && (pType != "05") && (pType != "06") && (pType != "15") &&(pNum.value != ""))
   {
      alert("This selection is for Blue Care Network and POS providers only.");
      pNum.value = "";
      pNum.focus();
      return false;
   }
   return true;
}
function validateValues(validChar, msg, field)
{
   var buff = field.value;
   for (var i=0; i<buff.length; i++)
   {
      if (validChar.indexOf(buff.substring(i, i+1)) == "-1")
      {
         alert(msg);
         field.value = "";
         field.focus();
         return false;
      }
   }
   return true;
}
function validateNumbers(field)
{
   return validateValues("1234567890. ","Only numeric characters are allowed in this field",field);
}
function validateLetters(field)
{
   return validateValues("abcdefghijklmnopqrstuvwxyzABCDEGFGHIJKLMNOPQRSTUVWXYZ,.'- ","Only alpha characters are allowed in this field",field);
}
function validateAlphaNum(field)
{
   return validateValues("abcdefghijklmnopqrstuvwxyzABCDEGFGHIJKLMNOPQRSTUVWXYZ1234567890.-,' ","Only alpha characters are allowed in this field",field);
}
function validatePNum(field)
{
   return validateValues("Pp0123456789 ","Provider number can only be made of a \"P\" followed by 5 numeric digits",field);
}
function helppage()
{
   var windowprops = "location=no,menubars=yes,toolbars=no,resizable=yes,scrollbars=yes,left=" + (.63 * screen.width) + ",top=" + (.15 * screen.height) + ",width=" + (.33 * screen.width) + ",height=" + (.75 * screen.height);
   popup = window.open(URL,'windowpopup',windowprops);
   if (popup.window.focus)
   {
      popup.focus();
   }
}
function onmouseover(me,pic)
{
   me.src=pic;
}
function onMouseOff(me,pic)
{
   me.src=pic;
}
function submitMe(f)
{

   if (verify(f))
   {
      document.forms['Search'].submit();
   }
   //document.forms['Search'].submit();
}








