﻿/// <reference path="../../Scripts/jquery-1.3.2.js" />
jQuery(document).ready(function() {
    var locations = jQuery("#specialtyLocationHeader + ul li");
    if (locations.length > 1) {
        var selectBox = jQuery("<select id=\"specialtyLocationSelection\" />");
        var defaultLocationListItem = jQuery("<li><img src=\"/MedicalServices/Locations/Images/RegionalMap.jpg\" class=\"IMGL\" alt=\"Image of Regional Map\" style=\"border-width: 0px;\" /><h3><a href=\"#\">Select a Location</a></h3><p>We offer this service at more than one location. Please choose the MeritCare location that is nearest you.</p></li>");
        defaultLocationListItem.insertBefore(jQuery("#specialtyLocationHeader + ul li:first"));
        locations = jQuery("#specialtyLocationHeader + ul li");
        locations.parent().css("display", "none").end().find("h3 a").each(function() {
            selectBox.append(jQuery("<option>" + this.innerHTML + "</option>"));
        });
        selectBox.change(function() {
            jQuery("#locationListingContent").html(locations.eq(jQuery("option", selectBox).index(jQuery("option:selected", selectBox))).html());
        }).insertAfter(jQuery("#specialtyLocationHeader"));

        jQuery("<div id=\"locationListingContent\" />").insertAfter(jQuery("#specialtyLocationHeader"));
        selectBox.insertAfter(jQuery("#locationListingContent"));
        jQuery("<br />").insertAfter(selectBox); // This addresses IE6 rendering issues with floats.
        jQuery("option:eq(" + (selectedLocationIndex == -1 ? 0 : selectedLocationIndex) + ")", selectBox).attr("selected", "selected");
        selectBox.change();
    }
});