/**** Misc. JavaScript code for sanus.com.  Requires jQuery ****/

/* Launches a popup window. */
function launchPopup(url)
{
    window.open(url, '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=730,height=498');
}

function loadSidebarManufacturers(ajaxUrl) {
    $.getJSON(ajaxUrl, {}, function (json) {
        var manufacturerList = document.getElementById('simple_manufacturer');
        $(manufacturerList).empty();
        
        for (var key in json) {
            var tmp = document.createElement('option');
            var txt = document.createTextNode(json[key]);
            tmp.value = key;
            tmp.appendChild(txt);
            manufacturerList.appendChild(tmp);
        }
    });
}

function loadSidebarModels(ajaxUrl) {
    $.getJSON(ajaxUrl, {
            make : $('#simple_manufacturer').children("[@selected]").attr('value')
        },
        function (json) {
            var modelList = document.getElementById('simple_model');
            $(modelList).empty();

            for (var key in json) {
                var tmp = document.createElement('option');
                var txt = document.createTextNode(json[key]);
                tmp.value = key;
                tmp.appendChild(txt);
                modelList.appendChild(tmp);
            }
            $(this).change();
        });
}