﻿// Prepares page elements.
$j(document).ready(function() {
    // Highlight the option tags of any search criteria which have been selected.
    var selectedSearchCriteria = $j(".search_input_active");

    for (var i = 0; i < selectedSearchCriteria.length; i++) {
        var searchCriteria = selectedSearchCriteria[i];

        $j(searchCriteria[searchCriteria.selectedIndex]).css("background-color", $j(searchCriteria).css("background-color"));
        $j(searchCriteria[searchCriteria.selectedIndex]).css("color", $j(searchCriteria).css("color"));
    }

    // When hovering over the search dropdowns, make them expand when using IE.
    if ($j.browser.msie) {
        $j(".search_input").mousedown(function(eventObject) {
            $j(this).addClass("search_input_ie_fix");
        });
        $j(".search_input").change(function(eventObject) {
            $j(this).removeClass("search_input_ie_fix");
        });
        $j(".search_input").blur(function(eventObject) {
            $j(this).removeClass("search_input_ie_fix");
        });
    }
});

// Updates the text values and hidden fields for the width slider.
function updateWidth(min, max) {
    $j("#width_min").val(min);
    $j("#width_max").val(max);
    $j("#width").text(Math.floor(min / 12) + "'" + (min % 12) + "\"" + " - " + Math.floor(max / 12) + "'" + (max % 12) + "\"");
}

// Updates the text values and hidden fields for the length slider.
function updateLength(min, max) {
    $j("#length_min").val(min);
    $j("#length_max").val(max);
    $j("#length").text(Math.floor(min / 12) + "'" + (min % 12) + "\"" + " - " + Math.floor(max / 12) + "'" + (max % 12) + "\"");
}

// Updates the text values and hidden fields for the price slider.
function updatePrice(min, max) {
    $j("#price_min").val(min);
    $j("#price_max").val(max);
    $j("#price").text("$" + min + " - $" + max);
}
