$.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() {  
 obj = $(this);  
 var sel='';
obj.after("<div id=\"selectoptions\"> </div>");
obj.find('option').each(function(i){ 
  if ($(this).attr("value")) {
	  if (this.title) {var hasimg = "<img src=\"" + this.title + "\" />";} else {var hasimg = '<span style=\"display:inline-block;width:50px;height:55px;margin-left:0px;\"></span>';}
	  // AZ modified 8/1/2009 maintain HTML in select
	  $("#selectoptions").append("<div id=\"" + $(this).attr("id") + "\" class=\"selectitems\"><table><tr><td>" + hasimg + "</td><td><span class=\"htmltitle\">" + $(this).attr("label") + "</span></td></tr></table></div>");
	  if ($(this).attr("selected")) {sel = this.id;}
  }
});
obj.before("<input type=\"hidden\" value =\"\" name=\"" + this.name + "\" class=\"customselect\"/><div id=\"iconselect\">" + this.title + "</div><div id=\"iconselectholder\"> </div>")
.remove();
$("#iconselect").click(function(){
$("#iconselectholder").toggle("fast");});
	$("#iconselectholder").append( $("#selectoptions")[0] );
$(".selectitems").mouseover(function(){
	$(this).addClass("hoverclass");
});
$(".selectitems").mouseout(function(){
	$(this).removeClass("hoverclass");
});
$(".selectitems").click(function(){
	$(".selectedclass").removeClass("selectedclass");
	$(this).addClass("selectedclass");
	var thisselection = $(this).html();
	// AZ modified 8/5/2009 maintain HTML in select and only show the first line
	var thisselection = $(".htmltitle", thisselection).html().split(new RegExp( "<br>", "i" ));
	$(".customselect").val(this.id);
	$("#iconselect").html(thisselection[0]);
	$("#iconselectholder").hide("fast")
});
if (sel) {
	var selid = '#' + sel;
	if(document.createEventObject){document.getElementById(sel).fireEvent("onclick");}
	else if (document.createEvent){$(selid).click();}
}
});  
  // do the rest of the plugin, using url and settings
}
