/**
 * Physician Search - Client-side enhancements
 * Allows data entered into search form to be "remembered"
 * 
 * FUNCTION            DESCRIPTION
 * anonymous           Populates form fields with values from cookie
 * logger              Sends key/value pairs of form fields to Perl program
 * fetch_vals          Returns a string of key/value pairs of form fields
 * set_cookie          Sets a cookie of key/value pairs of form fields
 * getRadioValue       Returns the value of the checked radio button in a group
 * check_after_hours   Determines whether or not to show radio buttons
 * check_mhmp_networks Determines whether or not to show Hospital Blue/MHMP network selection drop down
 */



/*
 * Physician Search "Memory"
 * Purpose:         To "remember" last performed search
 * 
 * @version         0.1
 * @author          Brent Knop [CeB]
 * 
 * @uses            fetch_vals()
 * @return          void
 */ 
var notImmune = ["DSBE", "FORD", "NPP", "EMPP", "PPOCB2", "SMMH", "TCN"];
var sleepArr = ["BPP","PPOCB","DCN","DSBE","PPOFB","FORD","NPP","EMPP","MHMP","ICB","MCTW","MESC","MC2","MICH","SSHP","SCN","TCN"];
var indyArr = ["15","PPOCB3", "PPOCB","MESC","MC2","SSHP","MICH","PPOFB","EMPP","MCTW","SCPS","TRIM", "DSBE","FORD", "NPP", "EMPP", "PPOCB2", "TCN"];
var noPsychology = ["PPOCB3"];
var noPsychiatry = ["PPOCB3"];
function inArr(val, arr) {
	for(var i = 0; i < arr.length; i++) {
		//alert(arr[i] + " vs " + val);
		if(arr[i] == val) {
			return true;
		}
	}
	return false;
}

window.onload = function() 
{
  verifyPlansAndSelections(document.Search);
  checkIndex(document.Search);  
  if (document.cookie)
  {    
    var elems = {};
    var str = unescape(document.cookie);
    var arr = str.split(/;\s*/);
	arr = arr.join("&");
	arr = arr.split(/&/);
    for(var i = 0; i < arr.length; i++)
    {
		var a = arr[i].split(/=/);
		if(a[0] == "phys_search") {
		  a.shift();
		}
		elems[a[0]] = a[1];
    }
	
    if (document.Search)
    {
      var f = document.Search;
      for (i = 0; i < f.elements.length; i++)
      {          
        if (elems[f.elements[i].name])
        {                        
          switch (f.elements[i].type)
          {
            case "text" :
              f.elements[i].value = elems[f.elements[i].name];
            break;
            case "select-one" :
              var node = f.elements[i];
              for (var j = 0; j < node.options.length; j++)
              {
                if (node.options[j].value == elems[f.elements[i].name])
                {                    
                  f.elements[i].selectedIndex = j;
                  //if (node.nodeName == "planType") check_after_hours();
                  break;
                }
              }
            break;              
          }            
        }
      }
    }
  }
  check_after_hours();
  check_mhmp_networks();
} // window.onload



var URL = "/home/where_you_can_go_for_care/help.html"
function bcnregionmap()
{
	debug("bcnregionmap");
   var popwidth = 534;
   var popheight = 475;
   var windowprops = "location=no,menubars=yes,toolbars=no,resizable=yes,scrollbars=no,left=" + ((screen.width - popwidth) / 2) + ",top=" + ((screen.height - popheight) / 2) + ",width=" + popwidth + ",height=" + popheight;
   var URL = "bcnregionmap.html";
   bcnregionpopup = window.open(URL,'ProfessionalBCNRegionMap',windowprops);
   if (bcnregionpopup.window.focus)
   {
      bcnregionpopup.focus();
   }
}

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)
{
	debug("isBcn");
   var PlanType = b[b.selectedIndex].value;
   if ((PlanType == "99") || (PlanType == "TRIM") || (PlanType == "MEDA") || (PlanType == "15"))
   {
      chooseSpecialtyForPCP(document.forms['Search']);
      return true;
   }
/*   else if(PlanType == "15")
   {
      chooseSpecialtyForPOSPCP(document.forms['Search']);
   }*/
   alert( "This option is for Point of Service and MESSA Tri Med only.\n\nPlease select a POS or MESSA Tri Med plan before selecting this." );
   return false;
}


function checkHospAffil(plan, hospital)
{
	debug("checkHospAffil");
   var PlanType = plan[plan.selectedIndex].value;
   if (PlanType != "PPOCB" && PlanType != "SSHP" && PlanType != "TCN" && PlanType != "NPP" && PlanType != "DSBE" && PlanType != "99" && PlanType != "MEDA" && PlanType != "15")
   {
      alert( "Hospital affiliations are only available for \"Community Blue \\Blue Preferred PPO\",  \" SOM State Health Plan PPO\",  \"Traditional Care Network\",  \"Ford National PPO Plan\", \" Delphi Salaried BMP EMP\" and \"POS Point of Service\" providers." );
      hospital.selectedIndex = 0;
      hospital.focus();
      return false;
   }
   /*if (PlanType == "99")
   {
       // hospital[hospital.selectedIndex].value = "P" + hospital[hospital.selectedIndex].value;
   }*/
   return true
}
function isBcnOrPos(b,theField)
{
	debug("isBcnOrPos");
   if (theField.value == null || theField.value.length == 0)
   {
      return false;
   }
   var PlanType = b.elements["planType"].value;
   if ((PlanType == "99") || (PlanType == "15") || (PlanType == "MEDA"))
   {
      return true;
   }
   alert("This option is for POS plans only.\n\nPlease select a POS plan before selecting this.");
   theField.value = "";
   return false;
}
function verifyPlansAndSelections(theForm)
{   
  debug("verifyPlansAndSelections");
  /* added by Brent Knop */ 
  check_after_hours();
  /* /added by Brent Knop */  
  check_mhmp_networks();

    
   //var PlanType = theForm.elements["planType"].value;   
   var PlanType = getPlanType(theForm);
   if ((PlanType != "03") && (PlanType != "04") && (PlanType != "05") && (PlanType != "06") && (PlanType != "99") && (PlanType != "15") && (PlanType != "MEDA"))
   {
      for (i=0; i<theForm.length; i++)
      {
         if (theForm.elements[i].name == "provNum")
         {
            theForm.elements[i].value = "";
         }
         if (theForm.elements[i].name == "subProg")
         {
            theForm.elements[i].value = "";
         }
      }
   }
   if ((PlanType != "03") && (PlanType != "04") && (PlanType != "05") && (PlanType != "06") && (PlanType != "99") && (PlanType != "MEDA"))
   {
      for (i=0; i<theForm.length; i++)
      {
         if (theForm.elements[i].name == "provType")
         {
             theForm.elements[i].selectedIndex = 0;
         }
      }
   }
   if (PlanType != "PPOCB"  && PlanType != "SSHP" && PlanType != "99" && PlanType != "TCN"  && PlanType != "MEDA")
   {
      for (i=0; i<theForm.length; i++)
      {
         if (theForm.elements[i].name == "hospital")
         {
            theForm.elements[i].selectedIndex = 0;
         }
      }
   }
   //new
   for (i=0; i<theForm.length; i++)
   {
      if (theForm.elements[i].name == "specialtySubGroup")
      {
         theForm.elements[i].selectedIndex = 0;
      }
   }
   // end new
   if (PlanType == "99" || PlanType == "MEDA" || PlanType == "15" || PlanType == "TRIM" || PlanType == "ECCA"){
		//checkPCPSpec(theForm.elements['planType'], theForm.elements['provType']);
		checkPCPSpec(theForm);
		//chooseSpecialtyForBCN(theForm)
		chooseHospitalForBCN(theForm)
		//chooseSpecialtyForPCP(document.forms['Search']);
   }
   // Start : new code by Jakileti 
   else if (PlanType == "TRD")
   {
   		chooseSpecialtyForTraditional(theForm)
   }
   else {
	   chooseSpecialtyForNonBCN(theForm);
	   chooseHospitalForNonBCN(theForm);
   }
}
function verifyDistance(theForm)
{
	debug("verifyDistance");
   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 && zip != null && zip.length > 0 && street != null && street.length > 0)
      {
         return true;
      } else
      {
         var state = theForm.elements["state"].value;
         alert ("To locate a provider near you,\nyou will need to fill in a complete and accurate address.");
*/

   if (dis != null && dis.length > 0)
   {
      if (zip != null && zip.length > 4)
      {
         return true;
      } else
      {

         alert ("To locate a provider near you,\nyou will need to fill in at least a ZIP code.");

/*
         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 < 5)
         {
            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 to check the Hospital Blue/Michigan Hospital network selection to ensure that they have selected
 * a network if they have chosen that plan type. 
 */
function checkHBnetwork(f) {
   var curr = f.planType.options[f.planType.selectedIndex].value;
   if (curr.toLowerCase() == 'mhmp' ) {
       return checkRequired(f.elements["mhmpNetwork"],"You must choose a Network to continue.");
   }
   return true;
}

function verify(form)
{
   return(checkRequired(form.elements["planType"],"You must choose a Plan to continue.") && verifySpecialty1(form.elements["specialty1"]) && verifyDistance(form) && checkHBnetwork(form));
}

function providerBcnId(planType, pNum)
{
   var pType = planType[planType.selectedIndex].value;
   if ((pType != "03") && (pType != "04") && (pType != "05") && (pType != "06") && (pType != "15") && (pType != "99") && (pType != "MEDA") && (pNum.value != ""))
   {
      alert("This selection is for 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))
   {  
      // new Code
      var plan = document.Search.planType[document.Search.planType.selectedIndex].value;
      if (plan == "BPP" || plan == "SMMH") 
      {
         if (document.Search.specialtySubGroup[document.Search.specialtySubGroup.selectedIndex].value=="") {
            document.Search.specialty.value=document.Search.specialty1[document.Search.specialty1.selectedIndex].value;
         }
         else{
            document.Search.specialty.value=document.Search.specialtySubGroup[document.Search.specialtySubGroup.selectedIndex].value;
         }
      }
      else
      {
          document.Search.specialty.value=document.Search.specialty1[document.Search.specialty1.selectedIndex].value;
      }
      //document.Search.specialty.value=document.Search.specialty1[document.Search.specialty1.selectedIndex].value;
      // end of new code
      document.forms['Search'];
      
      /* added by brent knop - 04.17.07 ************************************ */
      logger(f); 
      set_cookie(f);
      f.submit();      
      /* /added by brent knop - 04.17.07 *********************************** */            
   }
}



/*
 * Physician Search Logger
 * Purpose:         To colelct metrics on searches performed
 * 
 * @version         0.1
 * @author          Brent Knop [CeB]
 * 
 * @param object f  form to collect data from
 * @uses            fetch_vals()
 * @return          void
 */
function logger(f)
{      
  var uri = "/cgi-bin/logger.pl?" + escape(fetch_vals(f));
  var req = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP");  
  if (req)
  {
    try
    {
      req.open("GET", uri);
      req.send(null);          
    }
    catch (e) {}            
  }      
} //logger()



/*
 * Error checker
 * Purpose:         To alert IS when the Physician Search is down
 * 
 * @version         0.1
 * @author          Brent Knop [CeB]
 * 
 * @param object f  form to collect data from
 * @uses            fetch_vals()
 * @return          boolean
 */
function checker(f)
{      
  var uri = "http://www.bcbsm.com/provdir/ProviderSearchServlet?" + escape(fetch_vals(f));  
  //var uri = "/provdir/ProviderSearchServlet?" + escape(fetch_vals(f));  
  var req = (window.XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP");  
  if (req)
  {
    try
    {
      req.open("GET", uri);
      req.send(null);          
      req.onreadystatechange = function()
      {
        if (req.readyState == 4)
        {
          alert(req.status); 
        }        
      };      
    }
    catch (e) {alert(e)}      
  }
  return false;  
} //checker()



/*
 * fetch_vals
 * Purpose:         Collects form field values
 * 
 * @version         0.1
 * @author          Brent Knop [CeB]
 * 
 * @param object f  form to collect data from
 * @return          string str ("key=value" format)
 */
function fetch_vals(f)
{
  var val = "";  
  var elems = {};
  var str = "";
  for (var i = 0; i < f.length; i++)
  {
    val = (f[i].type == "radio") ? getRadioValue(f[f[i].name]) : f[i].value;
    elems[f[i].name] = val.replace(/,/g, "");    
  }  
  for (i in elems)
  {
    str += i + "=" + elems[i] + "&";
  }   
  str = str.replace(/&$/, "");
  return str;
} //fetch_vals()



/*
 * Physician Search Logger
 * Purpose:         Sets session cookie of data entered into form
 * 
 * @version         0.1
 * @author          Brent Knop [CeB]
 * 
 * @param object f  form to collect data from
 * @uses            fetch_vals
 * @return          void
 */
function set_cookie(f)
{
  document.cookie = "phys_search=" + escape(fetch_vals(f));    
} //set_cookie()



/*
 * Get checked radio button value
 * Purpose:           Returns value of checked radio button
 * 
 * @version           0.1
 * @author            Brent Knop [CeB]
 * 
 * @param array obj  radio button array to search for checked element
 * @return           string
 */
function getRadioValue(obj)
{
  for (var i = 0; i < obj.length; i++)
  {        
    if (obj[i].checked)
    {
      return (obj[i].value == "=") ? "equals" : obj[i].value;
    }  
  }  
  return null;
} //getRadioValue()



/*
 * determines weather or not to show MHMP/Hospital Blue Network Selection Box.
 *
 * @author          Ben Obst
 * @return          Void
 */
function check_mhmp_networks()
{
    if (document.getElementById("mhmp-networks"))
    {
      var elem = document.getElementById("mhmp-networks");
      var f = document.Search;
      var curr = f.planType.options[f.planType.selectedIndex].value;
      elem.style.display = (curr.toLowerCase() == "mhmp") ? "block": "none";
      if (curr.toLowerCase() == "mhmp") {
        if (f.mhmpNetwork.options.length==1) {
           alert('There are no active Hospital Blue Networks available');
        }
      }
    }
}

/*
 * determines whether or not to show radio buttons, based on selected plan
 * 
 * @version           0.1
 * @author            Brent Knop [CeB]
 * 
 * @return           void
 */
function check_after_hours()
{
	debug("check_after_hours");
  var plans = ['ppocb',
               'bpp',
               'dcn',
               'ppofb',
               'ford',
               'npp',
               'empp',
               'icb',
               'mctw',
               'mesc',
               'mc2',
               'sshp',
               'scn',
               'tcn'];  
  var planType = document.Search.planType;
  if (document.getElementById("after-hours"))
  {
    var elem = document.getElementById("after-hours");
    var bool = false;
    for (var i = 0; i < plans.length; i++)
    {
      if (planType.options[planType.options.selectedIndex].value.toLowerCase() == plans[i])
      {
        elem.style.display = "block";
        bool = true;
        break;
      }
    }
    if (bool == false) elem.style.display = "none";
  }      
}



function chooseSpecialtyForBCN(inForm) {	
debug("chooseSpecialtyForBcn");
	var box2 = inForm.specialty1.options;	
	var i = 0;
	box2[i++] = new Option ("Select a specialty group...", "" );
	box2[i++] = new Option ("Adolescent Medicine", "11");
	box2[i++] = new Option ("Allergy/Immunology", "12");       
	box2[i++] = new Option ("Cardiac Electrophysiology ","15");
	box2[i++] = new Option ("Cardiology","14");
	box2[i++] = new Option ("Cardiovascular Disease","17");
	box2[i++] = new Option ("Chiropractic Medicine","CH");
	box2[i++] = new Option ("Child/Adolescent Neurology", "13");
	box2[i++] = new Option ("Colon/Rectal Surgery","16");      
	box2[i++] = new Option ("Dermatology ","18");      
	box2[i++] = new Option ("Endocrinology ","21");
	box2[i++] = new Option ("Endocrinology, Diabetes, Metab","20");
	box2[i++] = new Option ("Family Practice ","22");
	box2[i++] = new Option ("Gastroenterology","23");
	box2[i++] = new Option ("General Practice","27");
	box2[i++] = new Option ("General Surgery ","24");
	box2[i++] = new Option ("Geriatric Medicine-Family Practice","25");
	box2[i++] = new Option ("Geriatric Medicine-Internal Medicine","26");
	box2[i++] = new Option ("Gynecologic Oncology","29");
	box2[i++] = new Option ("Gynecology","28");
	box2[i++] = new Option ("Hand Surgery-Orthopedic Surgery","30");
	box2[i++] = new Option ("Hand Surgery-Plastic Surgery ","31");
	box2[i++] = new Option ("Hand Surgery-Surgery","32");
	box2[i++] = new Option ("Hematology/Oncology ","34");
	box2[i++] = new Option ("Hematology-Internal Medicine","33");
	box2[i++] = new Option ("Hemophilia Network","HEMOPHILIA");
	if(!inArr(getPlanType(inForm), notImmune)) {
		box2[i++] = new Option("Immunization Pharmacies", "AC");
	}
	if(inArr(getPlanType(inForm), indyArr)) {
		//alert("Indy match");
		box2[i++] = new Option("Independent Laboratory", "6L");
	}
	box2[i++] = new Option ("Infectious Disease","35");
	box2[i++] = new Option ("Internal Medicine ","36");
	box2[i++] = new Option ("Internal Medicine-Pediatrics ","37");
	box2[i++] = new Option ("Maternal & Fetal Medicine ","38");
	box2[i++] = new Option ("Medical Genetics","39");
	box2[i++] = new Option ("Neonatal Perinatal Med-MD Only","44");
	box2[i++] = new Option ("Neonatology (DO Only) ","40");
	box2[i++] = new Option ("Nephrology","41");
	box2[i++] = new Option ("Neurological Surgery ","42");
	box2[i++] = new Option ("Neurology ","43");      
	box2[i++] = new Option ("Obstetrics","45");
	box2[i++] = new Option ("Obstetrics & Gynecology ","46");
	box2[i++] = new Option ("Oncology","49");
	box2[i++] = new Option ("Ophthalmology","52");
	box2[i++] = new Option ("Ophthalmology & Otorhinolaryngology","51");
	box2[i++] = new Option ("Optometrist","91");
	box2[i++] = new Option ("Oral & Maxillofacial Surgery","48");
	box2[i++] = new Option ("Orofacial Plastic Surgery ","47");
	box2[i++] = new Option ("Orthopedic Surgery","53");
	box2[i++] = new Option ("Otolaryngology","55");      
	box2[i++] = new Option ("Otology/Neurotology ","54");
	box2[i++] = new Option ("Otorhinolaryngology ","56");
	box2[i++] = new Option ("Otorhinolaryngology/Oro-Facial","50");      
	box2[i++] = new Option ("Pain Management ","70");
	box2[i++] = new Option ("Pediatric Allergy/Immunology","57");
	box2[i++] = new Option ("Pediatric Cardiology","58");      
	box2[i++] = new Option ("Pediatric Dermatology ","60");
	box2[i++] = new Option ("Pediatric Endocrinology ","61");      
	box2[i++] = new Option ("Pediatric Gastroenterology","67");
	box2[i++] = new Option ("Pediatric Hematology/Oncolgy","68");
	box2[i++] = new Option ("Pediatric Infectious Disease","62");
	box2[i++] = new Option ("Pediatric Nephrology","63");
	box2[i++] = new Option ("Pediatric Neurology ","64");
	box2[i++] = new Option ("Pediatric Ophthamology ","65");
	box2[i++] = new Option ("Pediatric Pulmonolgy","72");
	box2[i++] = new Option ("Pediatric Rheumatology","74");
	box2[i++] = new Option ("Pediatric Surgery ","66");      
	box2[i++] = new Option ("Pediatrics","59");
	box2[i++] = new Option ("Physical Medicine & Rehabilitation ","71");
	box2[i++] = new Option ("Plastic Surgery ","69");
	box2[i++] = new Option ("Plastic & Reconstructive Surgery ","76");
	box2[i++] = new Option ("Plastic Surgery - Head & Neck ","77");
	box2[i++] = new Option ("Podiatric Medicine","19");
	box2[i++] = new Option ("Preventive Medicine ","73");      
	box2[i++] = new Option ("Proctology (DO Only)","75");
	box2[i++] = new Option ("Pulmonary Disease ","78");
	box2[i++] = new Option ("Radiation Oncology","79");
	box2[i++] = new Option ("Reproductive Endocrinology","80");
	box2[i++] = new Option ("Retinology","81");
	box2[i++] = new Option ("Rheumatology","82");
	if(inArr(getPlanType(inForm), sleepArr)) {
		//alert("Sleep match");
		box2[i++] = new Option("Sleep Medicine", "83");
	}
	box2[i++] = new Option ("Sports Medicine Family Practice ","84");
	box2[i++] = new Option ("Sports Medicine Pediatric ","85");
	box2[i++] = new Option ("Thoracic Cardiovascular Surgery","86");
	box2[i++] = new Option ("Thoracic Surgery","87");
	box2[i++] = new Option ("Urological Surgery","89");
	box2[i++] = new Option ("Urology","88");
	box2[i++] = new Option ("Vascular Surgery","90");
	return;
}

function chooseSpecialtyForNonBCN(inForm)
	{
			debug("chooseSpecialtyForNonBCN");
		
		
		inForm.specialty1.options.length = 27;
		
		var box2 = inForm.specialty1.options;	
		var i = 0;
		box2[i++] = new Option ("Select a specialty group...", "");
		box2[i++] = new Option ("Allergy","AL");
		box2[i++] = new Option ("Anesthesiology","AN");
		box2[i++] = new Option ("Cardiology","CA");
		box2[i++] = new Option ("Chiropractic Medicine","CH");
		box2[i++] = new Option ("Dermatology","DE");
		box2[i++] = new Option ("Ear, Nose, And Throat","ET");
		box2[i++] = new Option ("Family Practice","FP");
		box2[i++] = new Option ("General Practice","GP");
        box2[i++] = new Option ("Gastroenterology", "DA");
		box2[i++] = new Option ("Gerontology","GE");
		box2[i++] = new Option ("Gynecology","GY");
        box2[i++] = new Option ("Hemophilia Network","HEMOPHILIA");
		if(!inArr(getPlanType(inForm), notImmune)) {
			box2[i++] = new Option("Immunization Pharmacies", "AC");
		}
		if(inArr(getPlanType(inForm), indyArr)) {
			//alert("Indy match");
			box2[i++] = new Option("Independent Laboratory", "6L");
		}
		box2[i++] = new Option ("Internal Medicine","IM");
		box2[i++] = new Option ("Neurology","NE");
        box2[i++] = new Option ("Nurse","NU");
		box2[i++] = new Option ("Obstetrics","OB");
		box2[i++] = new Option ("Obstetrics and Gynecology","OG");
		box2[i++] = new Option ("Oncology","ON");
		box2[i++] = new Option ("Ophthalmology","OP");
		box2[i++] = new Option ("Pathology","PA");
		box2[i++] = new Option ("Pediatrics","PE");    
		box2[i++] = new Option ("Physical Therapist","PT");
		box2[i++] = new Option ("Plastic Surgery","PO");
		box2[i++] = new Option ("Podiatric Medicine","PD");
		if(!inArr(getPlanType(inForm), noPsychiatry)) {
			box2[i++] = new Option ("Psychiatry","PS");
		}
		if(!inArr(getPlanType(inForm), noPsychology)) {
			box2[i++] = new Option ("Psychology","PY");
		}
		box2[i++] = new Option ("Radiology","RA");
		if(inArr(getPlanType(inForm), sleepArr)) {
			//alert("Sleep match");
			box2[i++] = new Option("Sleep Medicine", "83");
		}
        box2[i++] = new Option ("Social Worker","SW");
		box2[i++] = new Option ("Surgery","GS");
		box2[i++] = new Option ("Urology","UR");
      return;
	}
	
	
function chooseHospitalForNonBCN(inForm)
	{
		debug("chooseHospitalForNonBCN");
		var box2 = inForm.hospital.options;	
		if(!box2) {
			return;
		}
		box2[0] = new Option ("", "");
		box2[1] = new Option ("Allegan General Hospital","00117");
		box2[2] = new Option ("Alpena General Hospital","00105");
		box2[3] = new Option ("Baraga County Memorial Hospital","00204");
		box2[4] = new Option ("Battle Creek Health Systems","00014");
		box2[5] = new Option ("Bay Medical Center","00004");
		box2[6] = new Option ("Bell Memorial Hospital","00186");
		box2[7] = new Option ("Bi-County Community Hospital","00279");
		box2[8] = new Option ("Bixby Medical Center","00190");
		box2[9] = new Option ("Bon Secours Hospital","00023");
		box2[10] = new Option ("Borgess Medical Center","00032");
		box2[11] = new Option ("Borgess/Pipp Health Center","00156");
		box2[12] = new Option ("Botsford General Hospital","00276");
		box2[13] = new Option ("Bronson Methodist Hospital","00227");
		box2[14] = new Option ("Bronson Vicksburg Hospital","00146");
		box2[15] = new Option ("Caro Community Hospital","00092");
		box2[16] = new Option ("Carson City Hospital","00177");
		box2[17] = new Option ("Central Michigan Community Hospital","00093");
		box2[18] = new Option ("Charlevoix Area Hospital","00095");
		box2[19] = new Option ("Chelsea Community Hospital","00252");
		box2[20] = new Option ("Children's Hospital of Michigan","00244");
		box2[21] = new Option ("Chippewa County War Memorial Hosp Inc.","00222");
		box2[22] = new Option ("Clinton Memorial Hospital","00097");
		box2[23] = new Option ("Columbia Saint Lukes Medical Center","00503");
		box2[24] = new Option ("Community Hospital","00184");
		box2[25] = new Option ("Community Memorial Hospital","00141"	);
		box2[26] = new Option ("Cottage Hospital","00200"	);
		box2[27] = new Option ("Covenant Medical Center Inc.","00275"	);
		box2[28] = new Option ("Crittenton Hospital","00291"	);
		box2[29] = new Option ("Deckerville Community Hospital","00201"	);
		box2[30] = new Option ("Det Recv Hosp & University Health Cntr","00118"	);
		box2[31] = new Option ("Dickinson County Memorial Hospital","00144"	);
		box2[32] = new Option ("Doctors Hospital of Jackson","00191"	);
		box2[33] = new Option ("Eaton Rapids Community Hospital","00197"	);
		box2[34] = new Option ("Edward W Sparrow Hospital","00025"	);
		box2[35] = new Option ("Garden City Osteopathic Hospital","00136"	);
		box2[36] = new Option ("Genesys Regional Medical Center","00180"	);
		box2[37] = new Option ("Gerber Memorial Hospital","00088"	);
		box2[38] = new Option ("Grand View Hospital","00050"	);
		box2[39] = new Option ("Gratiot Community Hospital","00233"	);
		box2[40] = new Option ("Hackley Hospital","00066"	);
		box2[41] = new Option ("Harbor Beach Community Hospital Inc.","00239"	);
		box2[42] = new Option ("Harper Hutzel Hospital","00005"	);
		box2[43] = new Option ("Hayes Green Beach Memorial Hosp","00270"	);
		box2[44] = new Option ("Helen Newberry Joy Hospital","00282"	);
		box2[45] = new Option ("Henry Ford Hospital","00033"	);
		box2[46] = new Option ("Henry Ford Wyandotte Hospital","00285"	);
		box2[47] = new Option ("Herrick Memorial Hospital","00085"	);
		box2[48] = new Option ("Hills & Dales General Hospital","00256"	);
		box2[49] = new Option ("Hillsdale Community Health Center","00120"	);
        box2[49] = new Option ("Holland Community Hospital", "00130");
		box2[50] = new Option ("Hurley Medical Center","00003"	);
		box2[51] = new Option ("Huron Memorial Hospital","00165"	);
		box2[52] = new Option ("Huron Valley Sinai Hospital","00102"	);
		box2[53] = new Option ("Ingham Regional Medical Center","00179"	);
		box2[54] = new Option ("Ionia County Memorial Hosp Corp","00142"	);
		box2[55] = new Option ("Iron County Community Hospitals Inc.","00251"	);
		box2[56] = new Option ("Kalkaska Memorial Health Center","00211"	);
		box2[57] = new Option ("Kelsey Memorial Hospital Inc.","00166"	);
		box2[58] = new Option ("Kern Hospital","00043"	);
		box2[59] = new Option ("Keweenaw Memorial Medical Center","00108"	);
		box2[60] = new Option ("Lakeland Medical Center Saint Joseph","00219"	);
		box2[61] = new Option ("Lakeshore Community Hospital","00111"	);
		box2[62] = new Option ("Lakeview Community Hospital","00139"	);
		box2[63] = new Option ("Lapeer Regional Hospital","00045"	);
		box2[64] = new Option ("Lee Memorial Hospital","00038"	);
		box2[65] = new Option ("Leelanau Memorial Health Center","00167"	);
		box2[66] = new Option ("Mackinac Straits Hosp and Health Cntr","00223"	);
		box2[67] = new Option ("Madison Community Hospital","00299"	);
		box2[68] = new Option ("Marlette Community Hospital","00055"	);
		box2[69] = new Option ("Marquette General Hospital","00002"	);
		box2[70] = new Option ("Mckenzie Memorial Hospital","00288"	);
		box2[71] = new Option ("Mclaren Regional Medical Center","00011"	);
		box2[72] = new Option ("Mcpherson Hospital","00210"	);
		box2[73] = new Option ("Mecosta County General Hospital","00074"	);
		box2[74] = new Option ("Memorial Health Care Center","00058"	);
		box2[75] = new Option ("Mercy Gen Hlth Partners Sherman Campus","00266"	);
		box2[76] = new Option ("Mercy Hospital Cadillac","00096"	);
		box2[77] = new Option ("Mercy Hospital Grayling","00007"	);
		box2[78] = new Option ("Mercy Hospital Port Huron","00221"	);
		box2[79] = new Option ("Mercy Memorial Hospital Corporation","00060"	);
		box2[80] = new Option ("Metropolitan Hospital","00158"	);
		box2[81] = new Option ("Midmichigan Medical Center Clare","00138"	);
		box2[82] = new Option ("Midmichigan Medical Center Gladwin","00128"	);
		box2[83] = new Option ("Midmichigan Medical Center Midland","00257"	);
		box2[84] = new Option ("Mount Clemens General Hospital","00160"	);
		box2[85] = new Option ("Munising Memorial Hospital","00103"	);
		box2[86] = new Option ("Munson Medical Center","00064"	);
		box2[87] = new Option ("North Oakland Medical Centers","00065"	);
		box2[88] = new Option ("North Ottawa Community Hospital","00162"	);
		box2[89] = new Option ("Northern Michigan Hospital","00046"	);
		box2[90] = new Option ("Oaklawn Hospital","00115"	);
		box2[91] = new Option ("Oakwood Hosp & Medical Cntr Dearborn","00205"	);
		box2[92] = new Option ("Oakwood Hospital Annapolis Cntr Wayne","00176"	);
		box2[93] = new Option ("Oakwood Hospital Heritage Center Taylor","00016"	);
		box2[94] = new Option ("Oakwood Hospital Seaway Center Trenton","00079"	);
		box2[95] = new Option ("Ontonagon Memorial Hospital","00151"	);
		box2[96] = new Option ("OSF Saint Francis Hospital","00076"	);
		box2[97] = new Option ("Otsego Memorial Hospital","00027"	);
		box2[98] = new Option ("Paul Oliver Memorial Hospital","00149"	);
		box2[99] = new Option ("Pennock Hospital","00101"	);
		box2[100] = new Option ("Poh Medical Center","00213"	);
		box2[101] = new Option ("Port Huron Hospital","00059"	);
		box2[102] = new Option ("Portage Health System","00010"	);
		box2[103] = new Option ("Providence Hospital and Medical Centers","00277"	);
		box2[104] = new Option ("Rehabilitation Institute of Michigan","00258"	);
		box2[105] = new Option ("Riverside Osteopathic Hospital","00161"	);
		box2[106] = new Option ("Saint John Detroit Riverview Hospital","00013"	);
		box2[107] = new Option ("Saint John Hospital and Medical Center","00116"	);
		box2[108] = new Option ("Saint John Macomb Hospital","00048"	);
		box2[109] = new Option ("Saint John North Shores Hospital","00248"	);
		box2[110] = new Option ("Saint John Northeast Community Hospital","00040"	);
		box2[111] = new Option ("Saint John Oakland Hospital","00269"	);
		box2[112] = new Option ("Saint John River District Hospital","00056"	);
		box2[113] = new Option ("Saint Joseph Mercy Hospital","00042"	);
		box2[114] = new Option ("Saint Joseph Mercy Oakland","00008"	);
		box2[115] = new Option ("Saint Josephs Mercy Hospital of Macomb","00218"	);
		box2[116] = new Option ("Saint Mary Mercy Hospital","00243"	);
		box2[117] = new Option ("Saint Marys Health Services","00073"	);
		box2[118] = new Option ("Saint Marys Medical Cntr of Saginaw Inc.","00028"	);
		box2[119] = new Option ("Saint Vincent Medical Center","00338"	);
		box2[120] = new Option ("Saline Community Hospital","00075"	);
		box2[121] = new Option ("Scheurer Hospital","00126"	);
		box2[122] = new Option ("Schoolcraft Memorial Hospital","00193"	);
		box2[123] = new Option ("Sheridan Community Hospital","00057"	);
		box2[124] = new Option ("Sinai-Grace Hospital","00206"	);
		box2[125] = new Option ("South Haven Community Hospital","00131"	);
		box2[126] = new Option ("Spectrum Health Butterworth & Blodgett","00022"	);
		box2[127] = new Option ("Spectrum Health Reed City Campus","00091"	);
		box2[128] = new Option ("Standish Community Hospital","00262"	);
		box2[129] = new Option ("Straith Hospital forSpecial Surgery","00090"	);
		box2[130] = new Option ("Sturgis Hospital","00100"	);
		box2[131] = new Option ("Tawas Saint Joseph Hospital","00209"	);
		box2[132] = new Option ("The Toledo Hospital","00339"	);
		box2[133] = new Option ("Three Rivers Area Hospital","00083"	);
		box2[134] = new Option ("Trillium Hospital","00026"	);
		box2[135] = new Option ("United Memorial Health Center","00109"	);
		box2[136] = new Option ("University of Michigan Health System","00029"	);
		box2[137] = new Option ("W A Foote Memorial Hospital Inc.","00080"	);
		box2[138] = new Option ("West Branch Regional Medical Center","00094"	);
		box2[139] = new Option ("West Shore Medical Center","00198"	);
		box2[140] = new Option ("William Beaumont Hospital","00196"	);
		box2[141] = new Option ("William Beaumont Hospital Troy","00226"	);
		box2[142] = new Option ("Zeeland Community Hospital","00119"	);

		return;
	}
	
function chooseHospitalForBCN(inForm)
	{
		debug("chooseHospitalForBCN");
		//inForm.hospital.options.length = 114;
		
		var box2 = inForm.hospital.options;	
		if(!box2) {
			return;
		}
        box2[0] = new Option ("", "");
        box2[1] = new Option ("ALLEGAN GENERAL HOSPITAL","F00000000079");
        box2[2] = new Option ("ALPENA GENERAL HOSPITAL","F00000000072");
        box2[3] = new Option ("ANNAPOLIS HOSPITAL-OAKWOOD","F00000000099");
        box2[4] = new Option ("BATTLE CREEK HEALTH SYSTEMS ","F00000000021");
        box2[5] = new Option ("BAY MEDICAL CENTER","F00000000014");
        box2[6] = new Option ("BEAUMONT HOSPITAL TROY","F00000000127");
        box2[7] = new Option ("BEAUMONT HOSPITAL","F00000000109");
        box2[8] = new Option ("BI COUNTY COMMUNITY HOSPITAL","F00000000150");
        box2[9] = new Option ("BON SECOURS COTTAGE HEALTH","F00000000025");
        box2[10] = new Option ("BORGESS LEE MEMORIAL HOSPITAL","F00000000032");
        box2[11] = new Option ("BORGESS MEDICAL CENTER","F00000000030");
        box2[12] = new Option ("BORGESS-PIPP HOSPITAL","F00000000091");
        box2[13] = new Option ("BOTSFORD GENERAL HOSPITAL","F00000000148");
        box2[14] = new Option ("BRONSON METHODIST HOSPITAL","F00000000128");
        box2[15] = new Option ("BRONSON VICKSBURG HOSPITAL","F00000000009");
        box2[16] = new Option ("CARO COMMUNITY HOSPITAL","F00000000062");
        box2[17] = new Option ("CARSON CITY HOSPITAL","F00000000100");
        box2[18] = new Option ("CENTRAL MICHIGAN COMMUNITY HOSPITAL","F00000000063");
        box2[19] = new Option ("CHARLEVOIX AREA HOSPITAL","F00000000065");
        box2[20] = new Option ("CHEBOYGAN MEMORIAL HOSPITAL","F00000000006");
        box2[21] = new Option ("CHELSEA COMMUNITY HOSPITAL","F00000000137");
        box2[22] = new Option ("CHILDRENS HOSPITAL OF MICHIGAN","F00000000133");
        box2[23] = new Option ("CLINTON MEMORIAL HOSPITAL","F00000000067");
        box2[24] = new Option ("COMMUNITY HOSPITAL","F00000000104");
        box2[25] = new Option ("COVENANT MEDICAL CENTER ","F00000000147");
        box2[26] = new Option ("CRITTENTON HOSPITAL","F00000000156");
        box2[27] = new Option ("DETROIT RECEIVING HOSPITAL","F00000000080");
        box2[28] = new Option ("EATON RAPIDS MEDICAL CENTER","F00000000110");
        box2[29] = new Option ("EDWARD W SPARROW HOSPITAL","F00000000026");
        box2[30] = new Option ("GARDEN CITY HOSPITAL","F00000000003");
        box2[31] = new Option ("GENESYS REGIONAL MEDICAL CENTER","F00000000103");
        box2[32] = new Option ("GERBER MEMORIAL HOSPITAL","F00000000059");
        box2[33] = new Option ("GRATIOT COMMUNITY HOSPITAL","F00000000129");
        box2[34] = new Option ("HACKLEY HOSPITAL","F00000000050");
        box2[35] = new Option ("HARPER UNIVERSITY HOSPITAL","F00000000015");
        box2[36] = new Option ("HAYES GREEN BEACH MEMORIAL","F00000000146");
        box2[37] = new Option ("HENRY FORD HEALTH SYSTEM","F00000000031");
        box2[38] = new Option ("HENRY FORD WYANDOTTE HOSPITAL","F00000000152");
        box2[39] = new Option ("HILLS & DALES GENERAL HOSPITAL","F00000000139");
        box2[40] = new Option ("HILLSDALE COMMUNITY HEALTH CENTER","F00000000082");
        box2[41] = new Option ("HOLLAND COMMUNITY HOSPITAL","F00000000088");
        box2[42] = new Option ("HURLEY MEDICAL CENTER","F00000000013");
        box2[43] = new Option ("HURON VALLEY SINAI HOSPITAL","F00000000070");
        box2[44] = new Option ("INGHAM REGIONAL MEDICAL CENTER","F00000000102");
        box2[45] = new Option ("IONIA COUNTY MEMORIAL HOSPITAL","F00000000007");
        box2[46] = new Option ("KALKASKA MEMORIAL HOSPITAL","F00000000120");
        box2[47] = new Option ("LAKELAND MEDICAL CENTER","F00000000123");
        box2[48] = new Option ("LAKESHORE COMMUNITY HOSPITAL","F00000000076");
        box2[49] = new Option ("LAKEVIEW COMMUNITY HOSPITAL","F00000000005");
        box2[50] = new Option ("LAPEER REGIONAL HOSPITAL","F00000000036");
        box2[51] = new Option ("LEELANAU MEMORIAL HEALTH CENTER","F00000000098");
        box2[52] = new Option ("MACKINAC STRAITS HOSPITAL","F00000000126");
        box2[53] = new Option ("MARY FREE BED HOSPITAL & REHAB","F00000000144");
        box2[54] = new Option ("MCLAREN REGIONAL MEDICAL CENTER","F00000000019");
        box2[55] = new Option ("MECOSTA COUNTY GENERAL HOSPITAL","F00000000052");
        box2[56] = new Option ("MEMORIAL HEALTH CARE CENTER","F00000000045");
        box2[57] = new Option ("MEMORIAL MEDICAL CENTER","F00000000154");
        box2[58] = new Option ("MERCY HOSPITAL GRAYLING","F00000000016");
        box2[59] = new Option ("MERCY HOSPITAL MUSKEGON SHERMAN CAMPUS","F00000000143");
        box2[60] = new Option ("MERCY HOSPITAL PORT HURON","F00000000124");
        box2[61] = new Option ("MERCY MEMORIAL HOSPITAL","F00000000047");
        box2[62] = new Option ("METROPOLITAN HOSPITAL","F00000000092");
        box2[63] = new Option ("MID-MICHIGAN MEDICAL CENTER - CLARE","F00000000004");
        box2[64] = new Option ("MID-MICHIGAN MEDICAL CENTER - GLADWIN","F00000000086");
        box2[65] = new Option ("MID-MICHIGAN MEDICAL CENTER - MIDLAND","F00000000140");
        box2[66] = new Option ("MT CLEMENS GENERAL HOSPITAL","F00000000093");
        box2[67] = new Option ("MUNSON MEDICAL CENTER","F00000000048");
        box2[68] = new Option ("NORTH OAKLAND MEDICAL CENTER","F00000000049");
        box2[69] = new Option ("NORTH OTTAWA COMMUNITY HOSPITAL","F00000000094");
        box2[70] = new Option ("NORTHERN MICHIGAN HOSPITAL","F00000000037");
        box2[71] = new Option ("OAKLAWN HOSPITAL MARSHALL","F00000000077");
        box2[72] = new Option ("OAKWOOD HERITAGE HOSPITAL","F00000000022");
        box2[73] = new Option ("OAKWOOD HOSPITAL & MEDICAL CENTER","F00000000115");
        box2[74] = new Option ("OAKWOOD SOUTHSHORE MEDICAL CENTER","F00000000055");
        box2[75] = new Option ("OTSEGO MEMORIAL HOSPITAL","F00000000027");
        box2[76] = new Option ("PAUL OLIVER MEMORIAL HOSPITAL","F00000000010");
        box2[77] = new Option ("PENNOCK HOSPITAL","F00000000069");
        box2[78] = new Option ("POH MEDICAL CENTER","F00000000121");
        box2[79] = new Option ("PORT HURON HOSPITAL","F00000000046");
        box2[80] = new Option ("PROVIDENCE HOSPITAL","F00000000149");
        box2[81] = new Option ("SAINT JOSEPH MERCY LIVINGSTON","F00000000119");
        box2[82] = new Option ("SAINT JOSEPH MERCY SALINE HOSPITAL","F00000000053");
        box2[83] = new Option ("SHERIDAN COMMUNITY HOSPITAL","F00000000044");
        box2[84] = new Option ("SINAI GRACE HOSPITAL","F00000000116");
        box2[85] = new Option ("SOUTH HAVEN COMMUNITY HOSPITAL","F00000000001");
        box2[86] = new Option ("SOUTHEAST MICHIGAN SURGICAL HOSPITAL","F00018683000");
        box2[87] = new Option ("SPECTRUM HEALTH HOSPITALS","F00000000024");
        box2[88] = new Option ("SPECTRUM HEALTH REED CITY CAMPUS","F00000000061");
        box2[89] = new Option ("ST ANNE MERCY HOSPITAL","F00000002509");
        box2[90] = new Option ("ST CHARLES MERCY HOSPITAL","F00000007042");
        box2[91] = new Option ("ST JOHN DETROIT RIVERVIEW HOSPITAL","F00000000020");
        box2[92] = new Option ("ST JOHN HOSPITAL & MEDICAL CENTER","F00000000078");
        box2[93] = new Option ("ST JOHN MACOMB HOSPITAL","F00000000038");
        box2[94] = new Option ("ST JOHN NORTH SHORES HOSPITAL","F00000000134");
        box2[95] = new Option ("ST JOHN OAKLAND HOSPITAL","F00000000145");
        box2[96] = new Option ("ST JOHN RIVER DISTRICT HOSP","F00000000043");
        box2[97] = new Option ("ST JOSEPH MERCY HOSPITAL","F00000000034");
        box2[98] = new Option ("ST JOSEPH MERCY OAKLAND","F00000000017");
        box2[99] = new Option ("ST JOSEPHS MERCY MACOMB","F00000000122");
        box2[100] = new Option ("ST MARYS HEALTH SERVICES","F00000000051");
        box2[101] = new Option ("ST MARYS MEDICAL CENTER","F00000000028");
        box2[102] = new Option ("ST MARYS MERCY HOSPITAL","F00000000132");
        box2[103] = new Option ("ST VINCENT MERCY MEDICAL CTR","F00000000170");
        box2[104] = new Option ("STANDISH COMMUNITY HOSPITAL","F00000000142");
        box2[105] = new Option ("STRAITH HOSPITAL FOR SPECIAL SURGERY","F00000000060");
        box2[106] = new Option ("TAWAS ST JOSEPH HOSPITAL","F00000000118");
        box2[107] = new Option ("THREE RIVERS AREA HOSPITAL","F00000000057");
        box2[108] = new Option ("TOLEDO HOSPITAL","F00000000171");
        box2[109] = new Option ("UNIVERSITY OF MICHIGAN MEDICAL CENTER","F00000000029");
        box2[110] = new Option ("WA FOOTE MEMORIAL HOSPITAL","F00000000056");
        box2[111] = new Option ("WEST BRANCH REGIONAL MEDICAL CENTER","F00000000064");
        box2[112] = new Option ("WEST SHORE MEDICAL CENTER","F00000000111");
        box2[113] = new Option ("ZEELAND COMMUNITY HOSPITAL","F00000000081");


		return;
	}
	

function chooseSpecialtyForPCP(inForm)
	{
		debug("chooseSpecialtyForPCP");
           var box2 = inForm.specialty1.options;	

           inForm.specialty1.options.length = 7;
	
	      	box2[0] = new Option ("Select a PCP specialty group...", "" );
            box2[1] = new Option ("Family Practice ","22");
			box2[2] = new Option ("General Practice","27");
			box2[3] = new Option ("Internal Medicine ","36");
			box2[4] = new Option ("Internal Medicine-Pediatrics ","37");
			box2[5] = new Option ("Preventive Medicine ","73");
            box2[6] = new Option ("Pediatrics","59");
		return;
	}

function chooseSpecialtyForPOSPCP(inForm)
	{
		debug("chooseSpecialtyForPOSPCP");
           var box2 = inForm.specialty1.options;	

           inForm.specialty1.options.length = 7;
	
	      	box2[0] = new Option ("Select a PCP specialty group...", "" );
            box2[1] = new Option ("Family Practice ","FP");
			box2[2] = new Option ("General Practice","GP");
			box2[3] = new Option ("Internal Medicine ","IM");
			box2[4] = new Option ("Internal Medicine-Pediatrics ","IP");
			box2[5] = new Option ("Preventive Medicine ","PV");
            box2[6] = new Option ("Pediatrics","PE");
		return;
	}

function checkPCPSpec(f)
{
   var PlanType = getPlanType(f);
   var ProviderType = getProvType(f);
   if(ProviderType != "") {
	   if (!(PlanType == "99" || PlanType == "15" || PlanType == "TRIM" || PlanType == "MEDA" || PlanType == "ECCA"))
	   {
		  alert("PCP and Specialist selections are only available for \"Blue Choice POS\" and \"MESSA Tri Med\" providers");
		  f.provType.selectedIndex = 0;
		  f.provType.focus();
		  return false;
	   }
	   else {
		   if (ProviderType == "PCP") {
			   chooseSpecialtyForPCP(document.forms['Search']);
		   }
		   else {
			   chooseSpecialtyForBCN(document.forms['Search']);
		   }
	   }
   }
   return;
}
/*function checkPCPSpec(plan, provType)
{
   var PlanType = plan[plan.selectedIndex].value;
   
   var ProviderType = provType[provType.selectedIndex].value;

   if (!(PlanType == "99" || PlanType == "15" || PlanType == "TRIM" || PlanType == "MEDA" || PlanType == "ECCA"))
   {
      alert("PCP and Specialist selections are only available for \"Blue Choice POS\" and \"MESSA Tri Med\" providers");
      provType.selectedIndex = 0;
      provType.focus();
      return false;
   }
   else{
       if (ProviderType == "PCP") {
           chooseSpecialtyForPCP(document.forms['Search']);
       }
       else {
           chooseSpecialtyForBCN(document.forms['Search']);
       }
   } 
   return;
}*/

// Created by Jakileti on 08-02-2005


function chooseSpecialtySubGroupForNonBCN(inForm)
{
	debug("chooseSpecialtySubGroupForNonBCN");
   inForm.specialtySubGroup.options.length = 1;
   var box3 = inForm.specialtySubGroup.options;
   var plantype = document.Search.planType[document.Search.planType.selectedIndex].value;
   if(document.Search.specialty1.options[document.Search.specialty1.selectedIndex].value == "AC") {
	   document.Search.hospital.selectedIndex = 0;
	   document.Search.hospital.disabled = true;
   }
   else {
	   document.Search.hospital.disabled = false;
   }
   if (plantype == "BPP" || plantype == "SMMH") {      
         box3[0] = new Option ("Select a specialty sub group...", "");
   		var specialty = document.Search.specialty1[document.Search.specialty1.selectedIndex].value;
   		if (specialty == "AL")
   		{	
            box3[1] = new Option ("Allergy and Immunology","A3");
            box3[2] = new Option ("Diagnostic Laboratory Immunology","A2");
   			box3[3] = new Option ("Pediatric Allergy And Immunology","A1");      
   			
         }else if (specialty == "AN")
   		{
   			box3[1] = new Option ("Anesthesiology","AA");
   			box3[2] = new Option ("Critical Care Medicine","AB");
   		}else if (specialty == "CA")
   		{
   			box3[1] = new Option ("Angiography And Interventional","C8");
            box3[2] = new Option ("Cardiac Electrophysiology","C3");
            box3[3] = new Option ("Cardiology","C1");
   			box3[4] = new Option ("Cardiovascular Disease","C4");
            box3[5] = new Option ("Cardiovascular Surgery","C2");
            box3[6] = new Option ("Nuclear Cardiology","C7");
   			box3[7] = new Option ("Pediatric Cardiology","C5");
   			box3[8] = new Option ("Thoracic Surgery","C6");      
   		}else if (specialty == "CH")
   		{
   			box3[1] = new Option ("Chiropractic Medicine","H1");
   		}else if (specialty == "DE")
   		{
   			box3[1] = new Option ("Dermatologic Micrographic Surgery","D2");
            box3[2] = new Option ("Dermatological Immunology","D1");
   			box3[3] = new Option ("Dermatology","D4");
   			box3[4] = new Option ("Dermatopathology","D3");      
   		}else if (specialty == "ET")
   		{
            box3[1] = new Option ("Ophthalmology and Otorhinolaryngology","E4");
            box3[2] = new Option ("Orology and Neurotology","E3");      
            box3[3] = new Option ("Otolaryngology","E2");
            box3[4] = new Option ("Otorhinolaryngology","E1");
   		}
   		else if (specialty == "FP")
   		{
   			box3[1] = new Option ("Clinic/Common Provider","F4");
            box3[2] = new Option ("Family Practice","F1");
            box3[3] = new Option ("Geriatric Medicine (Family Practice)","F3");
   			box3[4] = new Option ("Sports Medicine","F2");      
   			
   		}else if (specialty == "GP")
   		{
            box3[1] = new Option ("Clinic and Common Provider","P2");
   			box3[2] = new Option ("General Practice","P1");      
   		}else if (specialty == "GE")
   		{
   			box3[1] = new Option ("Geriatric Medicine","G2");
            box3[2] = new Option ("Geriatric Medicine (Family Practice)","G1");
   			box3[3] = new Option ("Geriatric Psychiatry","G3");
   		}else if (specialty == "GY")
   		{
   			box3[1] = new Option ("Gynecology","Y1");
   			box3[2] = new Option ("Reproductive Endocrinology","Y2");						
   		}else if (specialty == "IM")
   		{
            box3[1] = new Option ("Aerospace Medicine","IB");
            box3[2] = new Option ("Allergy And Immunology","IW");
            box3[3] = new Option ("Clinic and Common Provider","IN");
            box3[4] = new Option ("Clinical Biochemical Genetics","I4");
   			box3[5] = new Option ("Clinical Genetics","I9");
            box3[6] = new Option ("Clinical Sytogenetics","I5");
            box3[7] = new Option ("Emergency Medicine","IL");
            box3[8] = new Option ("Endocrinology","DB");
            box3[9] = new Option ("Endrocrinology and Metabolism","IK");
            box3[10] = new Option ("Gastroenterology","DA");
            box3[11] = new Option ("Hematology","IG");
            box3[12] = new Option ("Hematology/Oncology","IO");
            box3[13] = new Option ("Infectious Disease","IH");
            //box3[13] = new Option ("Infectious Diseases","IY");
            box3[14] = new Option ("Internal Medicine","IX");
   			box3[15] = new Option ("Internal Medicine Critical Care Medicine","IJ");
            box3[16] = new Option ("Internal Medicine Diagnostic Laboratory Immunology","II");
            box3[17] = new Option ("Internal Medicine-Pediatrics","IZ");
            box3[18] = new Option ("Manipulative Therapy","DC");       
            box3[19] = new Option ("Medical Diseases Of The Chest","IE");
   			box3[20] = new Option ("Medical Genetics","IF");      
            box3[21] = new Option ("Nephrology","IA");
            box3[22] = new Option ("Nuclear Medicine","I8");
            box3[23] = new Option ("Occupational Medicine","IC");
            box3[24] = new Option ("Pain Management","I3");
            box3[25] = new Option ("Pediatric Endocrinology","IQ");
            box3[26] = new Option ("Pediatric Gastroenterology","IU");
   			box3[27] = new Option ("Pediatric Pulmonology","IR");      
            box3[28] = new Option ("Physical Medicine And Rehabilitation","I6");
            box3[29] = new Option ("Preventative Medicine","IT");
            //box3[30] = new Option ("Preventative Medicine","I1");
   			box3[30] = new Option ("Proctology","I2");  
            //box3[28] = new Option ("Proctology","IS");      
            box3[31] = new Option ("Public Health/Preventive Medicine","ID");
   			box3[32] = new Option ("Pulmonary Disease","I7"); 
            //box3[35] = new Option ("Rheumatology","DD");
   			box3[33] = new Option ("Rheumatology","IV");      
   			box3[34] = new Option ("Sports Medicine","CC");      
        }else if (specialty == "NU")
       {
           box3[1] = new Option ("Certified Clinical Nurse Specialist","N8");
           box3[2] = new Option ("Nurse Practitioner","N9");      
   		}else if (specialty == "NE")
   		{
   			box3[1] = new Option ("Child Neurology","N6");
   			box3[2] = new Option ("Clinical Neurophysiology","N7");
            box3[3] = new Option ("Neurological Surgery","N4");
            box3[4] = new Option ("Neurology","N1");
   			box3[5] = new Option ("Neuropathology","N2");      
   			box3[6] = new Option ("Nuclear Imaging And Therapy","N3");      
   			//box3[6] = new Option ("Neurological Surgery","N5");   
         }else if (specialty == "OB")
   		{
   			box3[1] = new Option ("Maternal and Fetal Medicine","B1");
   			box3[2] = new Option ("Obstetrics","B2");      
   		}else if (specialty == "OG")
   		{
   			box3[1] = new Option ("Diagnostic Ultra Sound","O2");
            box3[2] = new Option ("Gynecologic Oncology","O3");
            box3[3] = new Option ("Ob and Gyn Critical Care Medicine","O1");
            box3[4] = new Option ("Obstetrics and Gynecology","O4");
         }else if (specialty == "ON")
   		{
   			box3[1] = new Option ("Gynecologic Oncology","J3");
            box3[2] = new Option ("Hematology/Oncology","J6");
   			box3[3] = new Option ("Medical Oncology","J2");
   			box3[4] = new Option ("Oncology","J1");
   			box3[5] = new Option ("Pediatric Hematology/Oncology","J4");	
   			box3[6] = new Option ("Radiation Oncology","J5");
   			
   		}else if (specialty == "OP")
   		{
   			box3[1] = new Option ("Ophthalmology","K2");      
            box3[2] = new Option ("Ophthalmology And Otorhinolaryngology","K1");
   		}else if (specialty == "PA")
   		{
   			box3[1] = new Option ("Anatomic Pathology","L6");
            box3[2] = new Option ("Anatomic Pathology And Laboratory","L5");
            box3[3] = new Option ("Blood Banking/Transfusion Medicine","LF");
            box3[4] = new Option ("Chemical Pathology","LG");
            box3[5] = new Option ("Clinical Pathology","L4");     
            box3[6] = new Option ("Cytopathology","LH");      
            box3[7] = new Option ("Dermatopathology","LE");      
            box3[8] = new Option ("Diagnostic Laboratory Immunology","L7");
            box3[9] = new Option ("Forensic Pathology","LC");
            box3[10] = new Option ("Hematology","LB");
            box3[11] = new Option ("Immunopathology","LA");
            box3[12] = new Option ("Laboratory Medicine","LD");
            box3[13] = new Option ("Medical Microbiology","L9");			
            box3[14] = new Option ("Pathologic Anatomy","L3");      
            box3[15] = new Option ("Pathology","L2");
   			box3[16] = new Option ("Pediatric Pathology","L8");
            box3[17] = new Option ("Radioisotopic Pathology","L1");
         }else if (specialty == "PD")
   		{
   			box3[1] = new Option ("Podiatric Medicine","M1");
   		}else if (specialty == "PE")
   		{
   			box3[1] = new Option ("Adolescent Medicine","QJ");
            box3[2] = new Option ("Child Neurology","Q3");
            box3[3] = new Option ("Diagnostic Laboratory Immunology","QN");       
            box3[4] = new Option ("Internal Medicine-Pediatrics","QB");
            box3[5] = new Option ("Neonatal/Perinatal Medicine","QO");
            box3[6] = new Option ("Neonatology","QQ");
            box3[7] = new Option ("Pediatric Allergy And Immunology","QR");
            box3[8] = new Option ("Pediatric Cardiology","QM"); 
            box3[9] = new Option ("Pediatric Critical Care Medicine","QT");      
   			box3[10] = new Option ("Pediatric Emergency Medicine","Q2");
            box3[11] = new Option ("Pediatric Endocrinology","QL");
            box3[12] = new Option ("Pediatric Gastroenterology","Q1");
   			box3[13] = new Option ("Pediatric Hematology/Oncology","Q4");      
            box3[14] = new Option ("Pediatric Infectious Disease","Q6"); 
   			box3[15] = new Option ("Pediatric Intensive Care","Q7");
            box3[16] = new Option ("Pediatric Nephrology","Q5");      
            box3[17] = new Option ("Pediatric Pathology","QK");
            box3[18] = new Option ("Pediatric Pulmonology","Q9");			
            box3[19] = new Option ("Pediatric Radiology","QG"); 
            box3[20] = new Option ("Pediatric Rheumatology","Q8");
            box3[21] = new Option ("Pediatric Sports Medicine","QA");
            box3[22] = new Option ("Pediatric Surgery","QE");
            box3[23] = new Option ("Pediatrics","QU");
            //box3[17] = new Option ("Pediatric Gastroenterology","QC");      
            //box3[18] = new Option ("Pediatrics","QD");
            //box3[20] = new Option ("Pediatric Infectious Disease","QF");
            //box3[22] = new Option ("Pediatric Rheumatology","QH");
            //box3[23] = new Option ("Pediatric Surgery","QI"); 
            //box3[27] = new Option ("Pediatric Hematology and Oncology","QP");
            //box3[29] = new Option ("Pediatric Pulmonology","QS");      
   		}else if (specialty == "PO")
   		{      
   			box3[1] = new Option ("Oro-facial Plastic Surgery","R3");      
   			box3[2] = new Option ("Otorhinolaryngology And Oro-Facial Plastic Surgery","R4");	
            box3[3] = new Option ("Plastic Surgery","R1");
            box3[4] = new Option ("Plastic/Reconstructive Surgery","R5");
            //box3[2] = new Option ("Oro-Facial Plastic Surgery","R3");
   		}else if (specialty == "PS")
   		{      
   			box3[1] = new Option ("Addiction Psychiatry","S2");      
   			box3[2] = new Option ("Child Psychiatry","S3");
            box3[3] = new Option ("Forensic Psychiatry","S4");	
            box3[4] = new Option ("Geriatric Psychiatry","S6");
            box3[5] = new Option ("Psychiatry","S1");
   			box3[6] = new Option ("Psychiatry, Neurology","S5");
            box3[7] = new Option ("Neurology","S7");
            box3[8] = new Option ("Pain Management","S8");
            box3[9] = new Option ("Internal Medicine","S9");
            box3[10] = new Option ("Geriatric Medicine","S0");
            box3[11] = new Option ("Child Neurology","K3");
            box3[12] = new Option ("Family Practice","K4");

   		}else if (specialty == "PY")
   		{
   			box3[1] = new Option ("Psychology","PY");
            box3[2] = new Option ("Clinical Psychologist","T1");
   		}else if (specialty == "RA")
   		{
   			box3[1] = new Option ("Diagnostic Radiology","U3");	
            box3[2] = new Option ("Diagnostic Ultra Sound","U1");      
            box3[3] = new Option ("Neuroradiology","U6");
            box3[4] = new Option ("Nuclear Radiology","U8");
            box3[5] = new Option ("Pediatric Radiology","U0");
            box3[6] = new Option ("Radiation Oncology","U2");
            box3[7] = new Option ("Radiological Physics","U9");
            box3[8] = new Option ("Radiology","U4");
   			box3[9] = new Option ("Vascular Interventional Radiology","U5");      
            //box3[10] = new Option ("Diagnostic Radiology","U7");
   		}else if (specialty == "GS")
   		{
   			box3[1] = new Option ("Colon and Rectal Surgery","VK");            
            box3[2] = new Option ("Dental Surgery","VG");			
            box3[3] = new Option ("Dermatologic Micrographic Surgery","V1");       
            box3[4] = new Option ("General Surgery","V5");
            box3[5] = new Option ("General Vascular Surgery","V4");      
   			box3[6] = new Option ("Hand Surgery","V6");
            box3[7] = new Option ("Neurological Surgery","V3");	
   			box3[8] = new Option ("Neurological Surgery Critical Care Medicine","VJ");   			
   			box3[9] = new Option ("Oral Surgeon","V2");
            box3[10] = new Option ("Oral Surgery","VB");
            box3[11] = new Option ("Orofacial Plastic Surgery ","VD");
            box3[12] = new Option ("Orthopedic Surgery","VH");      
            box3[13] = new Option ("Pediatric Surgery","VA");
            box3[14] = new Option ("Surgery Of The Hand ","V8");
            box3[15] = new Option ("Surgical Critical Care","V0");
            box3[16] = new Option ("Thoracic Surgery","VE");
   			box3[17] = new Option ("Urological Surgery","V7");
            //box3[2] = new Option ("Colon Rectal Surgery","V9");
            //box3[19] = new Option ("Hand Surgery","VC");
   			//box3[20] = new Option ("Pediatric Surgery","VF");      
   		}else if (specialty == "UR")
   		{
            box3[1] = new Option ("Reproductive Endocrinology","W3");
   			box3[2] = new Option ("Urological Surgery","W2");      
            box3[3] = new Option ("Urology","W1"); 
   		}
         else if (specialty == "PT")
   		{
   			box3[1] = new Option ("Physical Therapist","Z1");   			
        }
        else if (specialty == "SW")
        {
            box3[1] = new Option ("Social Worker","Z2");
            box3[2] = new Option ("Clinical Social Worker","Z3"); 

	     } else {
		  for (i=0; i<inForm.length; i++)
		  {
			 if (inForm.elements[i].name == "specialtySubGroup")
			 {
				inForm.elements[i].selectedIndex = 0;
				inForm.elements[i].selectedText = "";
			 }
		  }
	   }
   }
    return;
}

function checkforPlanType(inForm)
{        
      var plan = document.Search.planType[document.Search.planType.selectedIndex].value;
      if (plan == "BPP" || plan == "SMMH") { }else
      {
         for (i=0; i<inForm.length; i++)
         {
            if (inForm.elements[i].name == "specialtySubGroup")
            {
               inForm.elements[i].selectedIndex = 0;
            }
         }
         alert('Specialty Sub Groups are only available for "Blue Preferred Plus" provider');
      }
      return;
}
function verifySpecialty1(theField)
{
   var plan = document.Search.planType[document.Search.planType.selectedIndex].value;
   if (plan == "BPP" || plan == "SMMH") 
   {
      /*v = document.Search.specialty1[document.Search.specialty1.selectedIndex].value;
      s="Please select specialty to continue...";
      if (isEmpty(v))
      {
         alert(s);
         location.hash = theField.name;
         theField.focus();
         return false;
      }
      if (isBlank(v))
      {
         return warnEmpty (form.elements["specialty1"], s);
      } else
      {
          return true;
       } */
      return true;
   }
   else
   {
      return true;
   }
}

function verifySpecialtySubGroup(theField1)
{
   var plan = document.Search.planType[document.Search.planType.selectedIndex].value;
   if (plan == "BPP" || plan == "SMMH") 
   {
          sg = document.Search.specialtySubGroup[document.Search.specialtySubGroup.selectedIndex].value;
          sm="Please select specialty sub goup to continue...";
    //change start on 17/Aug/2005
       s="Please select specialty to continue...";
       optLen=document.Search.specialtySubGroup.options.length;
       if (optLen<2) {
          alert(s);
          document.Search.specialty1.selectedIndex=0;
          document.Search.specialty1.focus();
          return false;
       }
       else
       {
       //change end


             if (isEmpty(sg))
             { 
                alert(sm);
                location.hash = theField1.name;
                theField1.focus();
                return false;
             }
             if (isBlank(sg))
             {
                return warnEmpty (form.elements["specialtySubGroup"], sm);
             } else
             {
         
                return true;
             }
       //change start
       }
       //change end
   }
   else
   {
      return true;
   }

}
function checkIndex(inForm)
{
   for (i=0; i<inForm.length; i++)
   {
      /*if (inForm.elements[i].name == "specialty1")
      {
         inForm.elements[i].selectedIndex = 0;
      }   */
      if (inForm.elements[i].name == "specialtySubGroup")
      {
         inForm.elements[i].selectedIndex = 0;
      }
   }
}
//below code is for five new specialties added for Traditional plan type by Prasad Jakileti

function chooseSpecialtyForTraditional(inForm)
{		debug("chooseSpecialtyForTraditional");
		inForm.specialty1.options.length = 32;
	
		var box2 = inForm.specialty1.options;	
		var i = 0;
        box2[i++] = new Option ("Select a specialty group...", "");
        box2[i++] = new Option ("Allergy","AL");
      box2[i++] = new Option ("Ambulance","5A");
      box2[i++] = new Option ("Anesthesiology","AN");
        box2[i++] = new Option ("Cardiology","CA");
      box2[i++] = new Option ("Certified Nurse Practitioners","5C");
        box2[i++] = new Option ("Chiropractic Medicine","CH");
        box2[i++] = new Option ("Dermatology","DE");
        box2[i++] = new Option ("Ear, Nose, And Throat","ET");
        box2[i++] = new Option ("Family Practice","FP");
        box2[i++] = new Option ("Gastroenterology", "DA");
        box2[i++] = new Option ("General Practice","GP");
        box2[i++] = new Option ("Gerontology","GE");
        box2[i++] = new Option ("Gynecology","GY");
        box2[i++] = new Option ("Hemophilia Network","HEMOPHILIA");
		if(!inArr(getPlanType(inForm), notImmune)) {
			box2[i++] = new Option("Immunization Pharmacies", "AC");
		}
        box2[i++] = new Option ("Independent Laboratory","6L");
      box2[i++] = new Option ("Internal Medicine","IM");
      box2[i++] = new Option ("Medical Equipment Suppliers","5X");
      box2[i++] = new Option ("Neurology","NE");
      box2[i++] = new Option ("Nurse Midwife","4N");
        box2[i++] = new Option ("Obstetrics","OB");
        box2[i++] = new Option ("Obstetrics and Gynecology","OG");
        box2[i++] = new Option ("Oncology","ON");
        box2[i++] = new Option ("Ophthalmology","OP");
        box2[i++] = new Option ("Pathology","PA");
        box2[i++] = new Option ("Pediatrics","PE");    
      box2[i++] = new Option ("Physical Therapist","PT");
        box2[i++] = new Option ("Plastic Surgery","PO");
      box2[i++] = new Option ("Podiatric Medicine","PD");
      box2[i++] = new Option ("Prosthetist and Orthotist","5O");
      box2[i++] = new Option ("Psychiatry","PS"); 
        box2[i++] = new Option ("Psychology","PY");
        box2[i++] = new Option ("Radiology","RA");
        box2[i++] = new Option ("Surgery","GS");
        box2[i++] = new Option ("Urology","UR");
		return;
	}
function debug(msg) {
	//alert(msg);
}
function getPlanType(f) {
	var sels = document.getElementsByTagName("select");
	for(var i = 0; i < sels.length; i++) {
		if(sels.name == "planType") {
			return f.planType.options[f.planType.options.selectedIndex].value;
		}
	}
	return f.planType.value;	
}
function getProvType(f) {
	var sels = document.getElementsByTagName("select");
	for(var i = 0; i < sels.length; i++) {
		if(sels.name == "provType") {
			return f.planType.options[f.planType.options.selectedIndex].value;
		}
	}
	return f.planType.value;	
}