/**
 * .disableTextSelect - Disable Text Select Plugin
 *
 * Version: 1.1
 * Updated: 2007-11-28
 *
 * Used to stop users from selecting text
 *
 * Copyright (c) 2007 James Dempster (letssurf@gmail.com, http://www.jdempster.com/category/jquery/disabletextselect/)
 *
 * Dual licensed under the MIT (MIT-LICENSE.txt)
 * and GPL (GPL-LICENSE.txt) licenses.
 **/

/**
 * Requirements:
 * - jQuery (John Resig, http://www.jquery.com/)
 **/
(function($) {
    if ($.browser.mozilla) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).css({
                    'MozUserSelect' : 'none'
                });
            });
        };
        $.fn.enableTextSelect = function() {
            return this.each(function() {
                $(this).css({
                    'MozUserSelect' : ''
                });
            });
        };
    } else if ($.browser.msie) {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).bind('selectstart.disableTextSelect', function() {
                    return false;
                });
            });
        };
        $.fn.enableTextSelect = function() {
            return this.each(function() {
                $(this).unbind('selectstart.disableTextSelect');
            });
        };
    } else {
        $.fn.disableTextSelect = function() {
            return this.each(function() {
                $(this).bind('mousedown.disableTextSelect', function() {
                    return false;
                });
            });
        };
        $.fn.enableTextSelect = function() {
            return this.each(function() {
                $(this).unbind('mousedown.disableTextSelect');
            });
        };
    }
})(jQuery);

$.fn.customSelect = function() {
  // define defaults and override with options, if available
  // by extending the default settings, we don't modify the argument
return this.each(
 function(){
    var obj = $(this);
    var visible=false;
    obj.append("<div class=\"options\"> </div>");
    obj.find('option').each(
        function(i)
        {
            $(".options", obj).append('<div rel="' + $(this).attr("value") + '" class="items">' + $(this).html() + '</span></div>');
        }
    );
    obj.append('<input type="hidden" value ="" class="customsel" name="'+ $("select", obj).attr("name") +'" /><div class="select">' + $("select", obj).attr("title") + '</div><div class="holder"> </div>');//remove();
    obj.disableTextSelect().find('select').remove();
    $(".holder", obj).css({'z-index':'10000'});
    $(".select", obj).css({'z-index':'1'}).click(function(){
        if ($(".holder", obj).is(":hidden"))
        {
            $(".holder").hide();
            $(".holder", obj).show("fast");
        }
        else
        {
            $(".holder").hide();
        }
    });
	
    $(".holder", obj).append( $(".options")[0] );
    $(".items", obj).hover(
        function(){
            $(this).addClass("hover");
        },
        function(){
            $(this).removeClass("hover");
        }
    );
	$(".items", obj).click(
        function(){
            var that=$(this);
            $(".selected", obj).removeClass("selected");
            that.addClass("selected");
            var ion = that.html();
            $(".select", obj).html(ion);
            //if (DD_belatedPNG)
            //{
            //    DD_belatedPNG.fix('.select');
            //}
            var arel = that.attr('rel');
            $(".customsel", obj).val(arel);
            $(".holder", obj).toggle("slow")
        }
    );
 });  
  // do the rest of the plugin, using url and settings
}

