﻿$(function () {
    //Convert the drop down lists
    $('.dropdown').each(function () {
        var ul = $(this);
        var sel = $("<select />", {
            "class": "schoolselect",
            change: function () {
                var loc = $(this).val();
                if (loc == "") { return false; }
                top.location.href = loc;
                return true;
            }
        });

        $("<option />", {
            value: "",
            'text': "View Other Schools"
        }).appendTo(sel);
        
        $('li', ul).each(function () {
            var li = $(this);
            var a = $('a', li);
            var opt = $("<option />", {
                value: a.attr('href'),
                'text': a.text()
            });

            //if (a.attr('href').toLowerCase() == top.location.pathname.toLowerCase())
            //    opt.attr("selected", "selected");

            opt.appendTo(sel);
        });

        sel.insertBefore(ul);
        ul.remove();
    });
});
