// JavaScript Document
function selectDropDownIEbehavior() {

// Apply this behavior for IE only
//if (!$.browser.msie)
//return;

var expand = function()
{
var width = $(this).css("width");
// Don't overwrite the stored original width,
// if the event occurs for a second time before contract()
if (width == "auto")
return;

$(this)
.data("origWidth", width)
.css("width", "auto")
};

var contract = function()
{
var width = $(this).css("width");
// Don't perform this twice
if (width != "auto")
return;

var origWidth = $(this).data("origWidth");
// If the original width was not stored, abort
if (origWidth === undefined)
return;

$(this)
.css("width", origWidth)
.data("origWidth", width);
};

$("select").each(function(index) {

// The select needs to be enclosed in a container with the same CSS width,
// which uses overflow:hidden, in order to hide the expanded part
var width = $(this).css("width");
var span = '<span style="padding: 2px; width:'+width+'; overflow:hidden; float:left;"/>';
$(this).wrap(span);

// Add event listeners
$(this)
.mousedown(expand)
.blur(contract)
.change(contract);

});

}

