$.fn.customSelect = function(){
	return this.each(function() {
		var fakeSelect = $(this);
		
		var selectedOption = $(fakeSelect).find("option")[0];
    	var optionsHtml = "";
		
    	$(fakeSelect).find("option").each(function() {
			if ($(this).attr("selected")) {
				selectedOption = this;
			}
			
			optionsHtml +=
				"<div " +
					"class=\"fake-select-option" + (($(this).attr("selected")) ? " selected" : "") + "\" " +
					"value=\"" + $(this).attr("value") + "\"" +
				"><span>" + $(this).html() + "</span></div>";
		});
		
		var html =
			"<input " +
				"type=\"hidden\" " +
				"id=\"" + $(fakeSelect).attr("id") + "\" " +
				"name=\"" + $(fakeSelect).attr("name") + "\" " +
				"value =\"" + $(selectedOption).attr("value") + "\"" +
			"/>" +
			"<div id=\"" + $(fakeSelect).attr("id") + "-fake-select\" class=\"fake-select\"><span>" + $(selectedOption).html() + "</span></div>" +
			"<div id=\"" + $(fakeSelect).attr("id") + "-fake-select-options-holder\" class=\"fake-select-options-holder\">" + optionsHtml +"</div>";
		
		$(fakeSelect).replaceWith(html);
		
		$("#" + $(fakeSelect).attr("id") + "-fake-select").click(function() {
			$("#" + $(fakeSelect).attr("id") + "-fake-select-options-holder").slideToggle(100);
		});
		
		$("#" + $(fakeSelect).attr("id") + "-fake-select-options-holder .fake-select-option").hover(
			function() {
				$(this).addClass("hover");
			},
			function() {
				$(this).removeClass("hover");
			}
		).click(function() {
            $("#" + $(fakeSelect).attr("id") + "-fake-select-options-holder .selected").removeClass("selected");
            $(this).addClass("selected");
            
            $("#" + $(fakeSelect).attr("id")).val($(this).attr("value"));
            $("#" + $(fakeSelect).attr("id") + "-fake-select").html($(this).html());
            $("#" + $(fakeSelect).attr("id") + "-fake-select-options-holder").slideToggle(150);
        });
    });
}

