function cuSel(params) {
jQuery(params.changedEl).each(
function(num)
{
var chEl = jQuery(this),
chElWid = chEl.outerWidth(),
chElClass = chEl.prop("class"),
chElId = chEl.prop("id"),
chElName = chEl.prop("name"),
defaultVal = chEl.val(),
activeOpt = chEl.find("option[value='"+defaultVal+"']").eq(0),
defaultText = activeOpt.text(),
disabledSel = chEl.prop("disabled"),
scrollArrows = params.scrollArrows,
chElOnChange = chEl.prop("onchange"),
chElTab = chEl.prop("tabindex"),
chElMultiple = chEl.prop("multiple");
if(!chElId || chElMultiple) return false;
if(!disabledSel)
{
classDisCuselText = "",
classDisCusel="";
}
else
{
classDisCuselText = "classDisCuselLabel";
classDisCusel="classDisCusel";
}
if(scrollArrows)
{
classDisCusel+=" cuselScrollArrows";
}
activeOpt.addClass("cuselActive");
var optionStr = chEl.html(),
spanStr = optionStr.replace(/option/ig,"span").replace(/value=/ig,"val=");
if($.browser.msie && parseInt($.browser.version) < 9)
{
var pattern = /(val=)(.*?)(>)/g;
spanStr = spanStr.replace(pattern, "$1'$2'$3");
}
var cuselFrame = '
'+
'
'+
'
'+defaultText+'
'+
'
'+
'
'+
'
';
chEl.replaceWith(cuselFrame);
if(chElOnChange) jQuery("#"+chElId).bind('change',chElOnChange);
var newSel = jQuery("#cuselFrame-"+chElId),
arrSpan = newSel.find("span"),
defaultHeight;
if(!arrSpan.eq(0).text())
{
defaultHeight = arrSpan.eq(1).innerHeight();
arrSpan.eq(0).css("height", arrSpan.eq(1).height());
}
else
{
defaultHeight = arrSpan.eq(0).innerHeight();
}
if(arrSpan.length>params.visRows)
{
newSel.find(".cusel-scroll-wrap").eq(0)
.css({height: defaultHeight*params.visRows+"px", display : "none", visibility: "visible" })
.children(".cusel-scroll-pane").css("height",defaultHeight*params.visRows+"px");
}
else
{
newSel.find(".cusel-scroll-wrap").eq(0)
.css({display : "none", visibility: "visible" });
}
var arrAddTags = jQuery("#cusel-scroll-"+chElId).find("span[addTags]"),
lenAddTags = arrAddTags.length;
for(i=0;iparams.visRows)
{
refreshScroll
.css({height: defaultHeight*params.visRows+"px", display : "none", visibility: "visible" })
.children(".cusel-scroll-pane").css("height",defaultHeight*params.visRows+"px");
}
else
{
refreshScroll
.css({display : "none", visibility: "visible" });
}
}
}
function cuselShowList(cuselWrap)
{
var cuselMain = cuselWrap.parent(".cusel");
if(cuselWrap.css("display")=="none")
{
$(".cusel-scroll-wrap").css("display","none");
cuselMain.addClass("cuselOpen");
cuselWrap.css("display","block");
var cuselArrows = false;
if(cuselMain.prop("class").indexOf("cuselScrollArrows")!=-1) cuselArrows=true;
if(!cuselWrap.find(".jScrollPaneContainer").eq(0).is("div"))
{
cuselWrap.find("div").eq(0).jScrollPaneCusel({showArrows:cuselArrows});
}
cuselScrollToCurent(cuselWrap);
}
else
{
cuselWrap.css("display","none");
cuselMain.removeClass("cuselOpen");
}
}
function cuselScrollToCurent(cuselWrap)
{
var cuselScrollEl = null;
if(cuselWrap.find(".cuselOptHover").eq(0).is("span")) cuselScrollEl = cuselWrap.find(".cuselOptHover").eq(0);
else if(cuselWrap.find(".cuselActive").eq(0).is("span")) cuselScrollEl = cuselWrap.find(".cuselActive").eq(0);
if(cuselWrap.find(".jScrollPaneTrack").eq(0).is("div") && cuselScrollEl)
{
var posCurrentOpt = cuselScrollEl.position(),
idScrollWrap = cuselWrap.find(".cusel-scroll-pane").eq(0).attr("id");
jQuery("#"+idScrollWrap)[0].scrollTo(posCurrentOpt.top);
}
}