var URL = "vision_hearing_help.html"

function verifyProviderAndSelections(theForm)
{
   if ((document.Search.planType[0].checked) || (document.Search.planType[1].checked))
   {
      chooseSearchForVision(theForm);
   }else if (document.Search.planType[2].checked)
	{
      chooseSearchForHearing(theForm); 
   }
}

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 isBcn(b)
{
   var PlanType = b[b.selectedIndex].value;
   if ((PlanType == "03") || (PlanType == "04") || (PlanType == "05") || (PlanType == "06") || (PlanType == "15"))
   {
      return true;
   }
   alert( "This option is for Blue Care Network and Point of Service only.\n\nPlease select a BCN plan or POS before selecting this." );
   return false;
}
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)
{
   if (document.Search.planType[2].checked)
   {
      var selectedVal=document.Search.specialty.options[document.Search.specialty.selectedIndex].value;
      if ((selectedVal == "OT") || (selectedVal == "OO") || (selectedVal == "OI")) {
         alert("Please select the specialty for hearing.");
         chooseHearing(form);
         return false;
      }
   }
   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();
}


function chooseSearchForVision(inForm)


	{

      	inForm.specialty.options[0] = new Option ("", "" );
        inForm.specialty.options[1] = new Option ("Ophthalmology", "OT" );
		inForm.specialty.options[2] = new Option ("Optometrist", "OO");
		inForm.specialty.options[3] = new Option ("Opticians", "OI");
		return;
	}

function chooseSearchForHearing(inForm)


	{

		inForm.specialty.options[0] = new Option ("", "");
		inForm.specialty.options[1] = new Option ("Otorhinolaryngology", "OH");
		inForm.specialty.options[2] = new Option ("Audiologist", "AU");
		inForm.specialty.options[3] = new Option ("Hearing Aid Dealers", "HE");
		return;

	}


function checkValue()
		
	{
				
		if ((document.Search.planType[0].checked) || (document.Search.planType[1].checked))

		{

			document.Search.specialty.options[0] = new Option ("", "" );
       		document.Search.specialty.options[1] = new Option ("Ophthalmology", "OT" );
			document.Search.specialty.options[2] = new Option ("Optometrist", "OO");
			document.Search.specialty.options[3] = new Option ("Opticians", "OI");
			return;
		}

			else if ((document.Search.planType[2].checked) || (document.Search.planType[3].checked))

		{

			document.Search.specialty.options[0] = new Option ("", "");
			document.Search.specialty.options[1] = new Option ("Otorhinolaryngology", "OH");
			document.Search.specialty.options[2] = new Option ("Audiologist", "AU");
			document.Search.specialty.options[3] = new Option ("Hearing Aid Dealers", "HE");
			return;

		}

	}   
function chooseHearing(inForm)


	{

		inForm.specialty.options[0] = new Option ("", "");
		inForm.specialty.options[1] = new Option ("Otorhinolaryngology", "OH");
		inForm.specialty.options[2] = new Option ("Audiologist", "AU");
		inForm.specialty.options[3] = new Option ("Hearing Aid Dealers", "HE");
      return false;
  }

