function nomark(a){return false}function cnomark(){return true}var selectTimeout=false;(function(a){a.fn.dropdown=function(b){b=a.extend({},a.fn.dropdown.defaults,b);return this.each(function(){var d=a(this);var f=d.parent();var i=a('<div class="dropdown" id="drop'+d.attr("id")+'" rel="'+d.attr("id")+'" style="display:none;"></div>');var c=a('<div class="options"></div>');var g="";var e=false;var h=0;init=function(){if(b.tworow){$lr=a('<div class="leftrow"></div>'),$rr=a('<div class="rightrow"></div>'),bp=Math.ceil((d.children().length/2))}d.children().each(function(j){if(b.hc&&!a(this).hasClass(b.hc)){return}if(a(this).val()!=""){$op=a('<div class="option" value="'+a(this).val()+'">'+a(this).html()+"</div>");$op.bind("mousedown",function(){if(b.multi){a(this).toggleClass("active")}else{a(this).hasClass("active")?a(this).removeClass("active"):(a("#drop"+d.attr("id")+" .option").removeClass("active"),a(this).addClass("active"))}if(b.multi){a(".option").bind("mouseenter",function(){a(this).toggleClass("active")});a(".options").bind("mouseleave",function(){a(".option").trigger("mouseup")})}}).bind("mouseup",function(){if(b.multi){a(".option").unbind("mouseenter");a(".options").unbind("mouseleave")}d.children().html(""),x="";a("#"+i.attr("id")+" .active").each(function(){d.children().append((a(this).html()).replace(/ \(.*\)/,"")+", ");x+=a(this).attr("value")+"','"});d.children().html((d.children().html()).replace(/, $/,""));x="'"+x.replace(/','$/,"")+"'";if(d.children().html()==""){d.children().html("--- "+translation.GLOBAL.selection+" ---")}if(x!=g){g=x,e=true,(!!b.change)?b.change(d.attr("id"),x):null}});if(a(this).attr("selected")){$op.addClass("active")}if(b.css.opt){$op.css(b.css.opt)}if(b.active!=null&&(b.active).search("'"+a(this).val()+"'")>=0){$op.addClass("active")}b.tworow?j+1<=bp?$lr.append($op):$rr.append($op):c.append($op);h++}});if(b.css.optl){c.css(b.css.optl)}if(b.css.drop){i.css(b.css.drop)}i.append(c).append('<div class="foot"><div class="any" style="float: left; cursor: pointer;">'+translation.GLOBAL.any+'</div><div class="teliad-icon-clickable select" style="float: right;"><img border="0" style="cursor: pointer;" src="/gfx/'+translation.GLOBAL.lang+'/btn_select_orange_small.png"></div></div>');f.append(i);if(b.reset!=null){i.children(".foot").children(".any").bind("click",function(){b.reset(i.attr("id"));d.children().html(""),x="";a("#"+i.attr("id")+" .active").each(function(){d.children().append(a(this).html()+", ");x+=a(this).attr("value")+"','"});d.children().html((d.children().html()).replace(/, $/,""));x="'"+x.replace(/','$/,"")+"'";if(d.children().html()==""){d.children().html("--- "+translation.GLOBAL.selection+" ---")}if(x!=g){g=x,e=true,(!!b.change)?b.change(d.attr("id"),x):null}a("select").show(0);a(".dropdown").hide(0,function(){if(b.close!=null){b.close(d.attr("id"),g,e)}})})}if(b.select!=null){i.children(".foot").children(".select").bind("click",function(){b.select(d.attr("id"),g,e);a("select").show(0);a(".dropdown").hide(0,function(){if(b.close!=null){b.close(d.attr("id"),g,e)}})})}d.html('<option value=""></option>').css({width:"196px"});if(h>0){d.bind("focusin",function(){a(this).blur()}).bind("mousedown",function(){a("select").show(0);a(this).blur();a(this).hide(0);a(".dropdown:visible").hide(0);i.toggle();if(b.open!=null){b.open(d.attr("id"))}document.getElementById(i.attr("id")).onselectstart=new Function("return false");if(window.sidebar){document.getElementById(i.attr("id")).onmousedown=nomark;document.getElementById(i.attr("id")).onclick=cnomark}i.bind("mouseleave",function(){a("body").bind("click",function(){a("select").show(0);a(".dropdown").hide(0,function(){if(b.close!=null){b.close(d.attr("id"),g,e)}a("body").unbind("click")})})}).bind("mouseenter",function(){a("body").unbind("click")})});a("#"+i.attr("id")+" .active").each(function(){d.children().append(a(this).html()+", ");g+=a(this).attr("value")+"','"});d.children().html((d.children().html()).replace(/, $/,""));g="'"+g.replace(/','$/,"")+"'"}else{d.attr("disabled","disabled")}if(d.children().html()==""){d.children().html("--- "+translation.GLOBAL.selection+" ---")}};init()})};a.fn.dropdown.defaults={multi:true,tworow:false,hc:false,css:{opt:null,optl:null,drop:null},active:null,open:null,close:null,change:null,reset:function(b){a("#"+b+" .active").removeClass("active")},select:null}})(jQuery);
