
<!-- show block of fields -->
function show(id, disabledBoolean, theDocument)
{
    if ((theDocument == null) || (theDocument == 'undefined'))
    {
        theDocument = this.document;
    }
    showObject(theDocument.getElementById(id),disabledBoolean);

    switch (id)
    {
      case "med-results":
        window.searchType = "ZSTVX";
        break;
      case "pharma-results":
        window.searchType = "MAVP";
        break;
    }
}

function showObject(object,disabledBoolean)
{
    if (object != null)
    {
      object.style.visibility="visible";
      object.style.display="block";
      object.disabled=disabledBoolean;
    }
}

<!-- hide block of fields -->
function hide(id, theDocument)
{
    if ((theDocument == null) || (theDocument == 'undefined'))
    {
        theDocument = this.document;
    }
    hideObject(theDocument.getElementById(id));
}
function hideObject(object)
{
    if (object != null)
    {
      object.style.visibility="hidden";
      object.style.display="none";
    }
}

function doSearch(formName,firstRecord,searchType,sendSDC)
{
    try
    {
        if ((searchType == null) || (searchType == 'undefined'))
        {
            searchType = "ZSTVX";
        }

        var theForm = this.document.getElementById(formName);

        if ((null == firstRecord) || ('undefined' == firstRecord) || (0 == firstRecord))
        {
            theForm.start.value=0;
        }
        else
        {
            firstRecord += eval(theForm.start.value);
            theForm.start.value = firstRecord;
        }
        theForm.searchType.value = searchType;
        //sjl 9/24/09: removed 
        //if(sendSDC)
        //   sdcTagSearch(theForm);
        theForm.submit();
    }
//    catch(e){}
    catch(e){alert('error:'+e.description);}
}

function goToPrinterFriendly(formName,resultSize,searchType)
{
    var thisForm = this.document.getElementById(formName);
    var url      = thisForm.action;
    url         += '?searchBy='   + thisForm.searchBy.value;
    url         += '&start='      + thisForm.start.value;
    url         += '&searchType=' + searchType;
    url         += '&resultSize=' + resultSize;
    url         += '&forward=printerFriendly';

    try
    {
        url += '&zipCode=' + thisForm.zipCode.value;
        try
        {
            url += '&distance=' + thisForm.distance.value;
        }
        catch (e)
        {
            url += '&distance=10';
        }
    }
    catch (e) {}

    var w=window.open(url,'PRINT_RESULTS_PAGE','menubar=yes, scrollbars=yes, resizable=yes,width=750, height=650, left=100, top=20');

    try
    {
        w.focus();
    }
    catch(e){}

}

function goToEmailPage(formName,resultSize,searchType)
{
    var thisForm = this.document.getElementById(formName);

    var url      = '/pdc/email/start.do';
    url         += '?searchBy='   + thisForm.searchBy.value;
    url         += '&start='      + thisForm.start.value;
    url         += '&searchType=' + searchType
    url         += '&resultSize=' + resultSize
    url         += '&fnc=results';

    try
    {
        url += '&zipCode=' + thisForm.zipCode.value;
        try
        {
            url += '&distance=' + thisForm.distance.value;
        }
        catch (e)
        {
            url += '&distance=10';
        }
    }
    catch (e) {}

    var w=window.open(url,'EMAIL_RESULTS_PAGE','scrollbars=no, resizable=no,width=530, height=440, left=200, top=25');

    try
    {
        w.focus();
    }
    catch(e){}
}

function GetMap(address)
{
    // replace all spaces with plus signs
    var addr = address.replace(/ /g,'+');
    var url="http://maps.google.com/?q="+addr;

    openExternalWin("zostavax", url);
    tagOffsiteLink("maps.google.com", "Get Map");
}

function setImageActiveStatus(tab,listSize,theDocument)
{
    if ((theDocument == null) || (theDocument == 'undefined'))
    {
        theDocument = this.document;
    }
    try
    {
        if ((listSize == null) || (listSize == undefined) || (listSize == 0))
        {
            hideObject(theDocument.getElementById("med-printer-email-links"));
            hideObject(theDocument.getElementById("pharma-printer-email-links"));
            hideObject(theDocument.getElementById("link-print"));  // Print link in right nav
        }
    }
    catch(e){}
//    catch(e){alert('error:'+e.description);}
}

function setZipCode(zip,theDocument)
{
    if ((theDocument == null) || (theDocument == 'undefined'))
    {
        theDocument = this.document;
    }
    try
    {
        var control = theDocument.getElementById('zipCode');
        if ((zip == null) || (zip == 'undefined'))
        {
            control.value='';
        }
        else
        {
            control.value=zip;
        }
    }
    catch(e){}
//    catch(e){alert('error:'+e.description);}
}

function setDistance(dist,theDocument)
{
    if ((theDocument == null) || (theDocument == 'undefined'))
    {
        theDocument = this.document;
    }
    try
    {
        var control = theDocument.getElementById('distance');
        if ((dist != null) && (dist != 'undefined'))
        {
            var values = control.options;
            for(var i=0; i < values.length;i++)
            {
                if (values[i].value == dist)
                {
                    control.selectedIndex=i;
                    break;
                }
            }
        }
    }
    catch(e){}
//    catch(e){alert('error:'+e.description);}
}

function setStartValue(startValue,theDocument)
{
    if ((theDocument == null) || (theDocument == 'undefined'))
    {
        theDocument = this.document;
    }
    try
    {
        var control = theDocument.getElementById('start');
        if ((startValue == null) || (startValue == 'undefined'))
        {
            control.value='0';
        }
        else
        {
            control.value=startValue;
        }
    }
    catch(e){}
//    catch(e){alert('error:'+e.description);}
}

/**********************************
 SDC Tagging for Searches
 **********************************/
function sdcTagSearch(theForm)
{
   try
   {
      var eventName;

      // tag by provider type
      eventName = "Search-" + (theForm.searchType.value=="MAVP" ? "Pharmacy" : "Practice");
      tagEvent(eventName);

      // tag by geographical region
      eventName = "Search-Geo-" + theForm.zipCode.value.substr(0,3);
      tagEvent(eventName);
   }
   catch(e) {}

   return true;
}

function sdcTagNotFound()
{
   try
   {
      var theForm = document.forms["medSearch"];
      var eventName;

      // tag by provider type
      eventName = "Not-Found-" + (theForm.searchType.value=="MAVP" ? "Pharmacy" : "Practice") + "-" + theForm.zipCode.value.substr(0,3);
      tagEvent(eventName);
   }
   catch(e) {}
   return true;
}


/* wrapper for pre-submit of the Provider Search form */
function onSubmitProviderSearch(theForm)
{
   var test = isGlobalValidUSZip(theForm.zipCode.value);

   if (test == false)
   {
      alert("Provide a ZIP code as 5 digits");
      try {theForm.zipCode.focus();} catch(e){}
   }
   
   //sjl 9/24/09: removed
   //if (test == true)
   //   sdcTagSearch(theForm);

   return test;
}


