﻿function preparePicker()
{
    if (document.getElementById && document.getElementsByTagName)
    {
        if (document.getElementById("dealerpicker"))
        {
            var pickerlist = document.getElementById("dealerpicker");
            pickerlist.style.display = "block";

            // access all options in list and add href jump
            var states = document.getElementById("ctl00_phMainContent_lbxState");
            states.onchange = function jumpToState(selectedState)
            {
                selectedState = this.options[this.selectedIndex].value;
                document.location.href = selectedState;
            }
        }
    }
}

function addLoadEvent(func)
{
    var oldonload = window.onload;
    if (typeof window.onload != 'function')
    {
        window.onload = func;
    }
    else
    {
        window.onload = function ()
        {
            if (oldonload)
            {
                oldonload();
            }
            func();
        }
    }
}

addLoadEvent(preparePicker);
