var selects = 900;
$.fn.customSelect = function() {
    function hide() {
            $(".iconselectholder").hide();
    }
    // define defaults and override with options, if available
    // by extending the default settings, we don't modify the argument
    return this.each(function() {
        obj = $(this);
        var width = $(this).width();
        var height = 18;
        var selectedIndex = 0;
        var opened = false;
        if ($.support.leadingWhitespace) { height += 1; }
        var parent = $(this).parent();
        var grand_parent = $(this).parent().parent();
        parent.css("z-index", selects);
        grand_parent.css("z-index", selects);
        obj.after("<div class=\"selectoptions\"> </div>");
        var options = 0;

        obj.find('option').each(function(i) {
            if ($(this).attr("selected")) {
                selectedIndex = i;
            }
            options++;
            parent = $(this).parent().parent();
            parent.find(".selectoptions").append("<div id=\"" + $(this).attr("value") + "\" class=\"selectitems\" style=\"z-index: " + selects + ";\">" + $(this).text() + "</div>");
        });
        var style = "";
        var divHeight = (options * 20);
        if (options > 5) { style = "height:" + divHeight + "px; overflow: auto;"; }
        obj.before("<input type=\"hidden\" value =\"" + $(this).find('option:selected').attr("value") + "\" name=\"" + this.name + "\" class=\"customselect\"/><div class=\"iconselect\" style=\"width: " + (width - 2) + "px; height: " + (height) + "px; z-index:" + (selects) + ";\">" + obj.find('option:selected').text() + "</div><div class=\"iconselectholder\" style=\"width: " + (width + 4) + "px; z-index:" + (selects) + ";" + style + "\"> </div><br style=\"clear: both\" />")
.remove();
        selects--;
        parent.find(".iconselect").click(function() {
            parent = $(this).parent();
            if (!opened) {
                $(document).bind("mouseup", hide);
            }
            parent.find(".iconselectholder").toggle();
            opened = !opened;
        }
        );

        parent.find(".iconselectholder").append(parent.find(".selectoptions")[0]);
        parent.find(".selectitems").mouseover(function() {
            $(this).addClass("hoverclass");

        });
        parent.find(".selectitems").mouseout(function() {
            $(this).removeClass("hoverclass");
        });

        parent.find(".selectitems").mousedown(function() {
            parent = $(this).parent().parent().parent();
            parent.find(".selectedclass").removeClass("selectedclass");
            $(this).addClass("selectedclass");
            var thisselection = $(this).text();
            parent.find(".customselect").val(this.id);
            parent.find(".iconselect").html(thisselection);
        });
    });
    // do the rest of the plugin, using url and settings
}

