/*
Name: jQuery Simple Drop Down Plugin
Author: Etienne Fardet
Version: 1.2
*/

(function($) {
    $.simpledropdown = function(selector, isDropdown, onSelect) {
        $(selector).children("ul").addClass("dropdown");
        $("ul.dropdown>li:first-child").addClass("selected");
        $("ul.dropdown>li").not(".dropdown>li:first-child").addClass("drop");
        $("ul.dropdown").click(function(event) {
            event.stopPropagation();
            var sel = "";
            var subitems = $(this).find(".drop ul li");
            var selecteditem = $(this).find(".selected");
            subitems.unbind().slideToggle("fast", function() {
                subitems.unbind().click(function(event) {
                    var selection = $(this).text();
                    //do ajax request
                    if (sel != selection) {
                        if ($.isFunction(onSelect))
                            onSelect(selection);
                    }
                    sel = selection;
                    //event.stopPropagation();
                    if (isDropdown == true) {
                        selecteditem.text(selection).fadeOut(5, function() {
                            if (jQuery.browser.msie) {
                                $(this).fadeIn(100);
                            } else {
                                $(this).fadeIn(400);
                            }
                        });
                    }
                });
            })
        });
    };
})(jQuery); 

