function cuSel(n){function r(t,u,f){var w=t.outerWidth(),nt,a,tt,it,b,v,h,y,p,rt;if(w<=0){if(f<=o){window.setTimeout(function(){r(t,u,f+1)},e);return}w=200}var ut=t.prop("class"),l=t[0].id?t[0].id:"cuSel-"+ +Date.now()+"-"+u,ft=t.prop("name"),k=t.val(),c=t.find("option[value='"+k+"']").eq(0),et=c.attr("addTags")?c.attr("addTags"):"",d=c.data("setclass")?c.data("setclass"):"",ct=c.text(),ot=t.prop("disabled"),st=n.scrollArrows,g=t.prop("onchange"),ht=t.prop("tabindex");for(ot?(classDisCuselText="classDisCuselLabel",classDisCusel="classDisCusel"):(classDisCuselText="",classDisCusel=""),st&&(classDisCusel+=" cuselScrollArrows"),t.find("option").addClass("cuselItem"),c.addClass("cuselActive"),nt=t.html(),a=nt.replace(/option/ig,"span").replace(/value=/ig,"val="),$.browser.msie&&parseInt($.browser.version)<9&&(tt=/(val=)(.*?)(>)/g,a=a.replace(tt,"$1'$2'$3")),it=t.data("index")!==void 0?'" ng-change-value json="json" index="'+t.data("index")+'" data-ng-model="'+t.data("ngModel")+'"':t.data("custom-select")!==void 0?'" ng-change-cusel-value change-grain-size="changeGrainSize" data-ng-model="'+t.data("ngModel")+'"':t.data("custom-date-filter")!==void 0?'" ng-change-date data-ng-model="'+t.data("ngModel")+'"':t.data("select-prod-calculator")!==void 0?'" ng-change-grain-size change-grain-size="changeGrainSize" data-ng-model="'+t.data("ngModel")+'" product-id="'+t.data("productId")+'"':'"',b='<div class="cusel '+ut+" "+classDisCusel+'" id=cuselFrame-'+l+' style="width:'+w+'px" tabindex="'+ht+'"><div class="cuselFrameRight"><\/div><div data-class="'+d+'" class="cuselText '+d+'">'+et+"<label>"+c.text()+'<\/label><\/div><div class="cusel-scroll-wrap"><div class="cusel-scroll-pane" id="cusel-scroll-'+l+'">'+a+'<\/div><\/div><input type="hidden" id="'+l+'" name="'+ft+'" value="'+k+it+"/><\/div>",t.data("index")===void 0&&t.data("custom-select")===void 0&&t.data("custom-date-filter")===void 0&&t.data("select-prod-calculator")===void 0?t.replaceWith(b):($(b).insertAfter(t),t.hide()),g&&$("#"+l).bind("change",g),v=$("#cuselFrame-"+l),h=v.find("span.cuselItem"),h.wrapInner("<label/>"),h.eq(0).find("label").text()?y=h.eq(0).innerHeight():(y=h.eq(1).innerHeight(),h.eq(0).css("height",h.eq(1).height())),h.length>n.visRows?v.find(".cusel-scroll-wrap").eq(0).css({height:y*n.visRows+"px",display:"none",visibility:"visible"}).children(".cusel-scroll-pane").css("height",y*n.visRows+"px"):v.find(".cusel-scroll-wrap").eq(0).css({display:"none",visibility:"visible"}),p=$("#cusel-scroll-"+l).find("span[addTags]"),rt=p.length,i=0;i<rt;i++)p.eq(i).prepend(p.eq(i).attr("addTags")).removeAttr("addTags");s()}function s(){var i=f(),n;$("html").off("click.cusel");$("html").on("click.cusel",function(n){var t=$(n.target),s=t.attr("id"),c=t.prop("class"),r;if((t.hasClass("cuselText")||t.hasClass("cuselFrameRight")||t.parents(".cuselText:first").length)&&!t.parents(".cusel:first").hasClass("classDisCusel"))r=t.parents(".cusel:first").find(".cusel-scroll-wrap").eq(0),u(r);else if(t.hasClass("cusel")&&!t.hasClass("classDisCusel")&&t.is("div"))r=t.find(".cusel-scroll-wrap").eq(0),u(r);else if(t.parents(".cuselItem:first").length&&!t.parents(".cuselItem:first").hasClass("cuselActive")||t.is(".cuselItem")&&!t.hasClass("cuselActive")){var e=t.is(".cuselItem")?t:t.parents(".cuselItem:first"),f=t.parents(".cusel:first").length?t.parents(".cusel:first"):$(i.data("cusel-select")),o=e.index();if(!f.length)return;f.removeClass("cuselOpen").find(".cuselActive").removeClass("cuselActive").end().find(".cuselItem").eq(o).addClass("cuselActive");h(f,e);i.hide();f.focus()}else{if(t.parents(".cusel-scroll-wrap").is("div"))return;i.is(":visible")&&(i.hide(),$(".cuselOpen").removeClass("cuselOpen"))}});$(".cusel").off("keydown.cusel");$(".cusel").on("keydown.cusel",function(n){var r=$(this),s=r.is(".cuselOpen")?!0:!1,u=$("#cuselBox"),o,f,i,e;if(window.event?o=window.event.keyCode:n&&(o=n.which),o==null||o==0||o==9)return!0;if(r.prop("class").indexOf("classDisCusel")!=-1)return!1;switch(o){case 32:return s||r.trigger("click"),!1;case 40:case 39:return s?(i=u.find(".cuselOptHover").eq(0).length?u.find(".cuselOptHover").eq(0):u.find(".cuselActive").eq(0),f=i.next(),f.is(".cuselItem")&&(i.removeClass("cuselOptHover"),f.addClass("cuselOptHover"),t(u.find(".cusel-scroll-wrap").eq(0)))):(i=r.find(".cuselOptHover").eq(0).length?r.find(".cuselOptHover").eq(0):r.find(".cuselActive").eq(0),f=i.next(),f.is(".cuselItem")&&f.trigger("click")),!1;case 37:case 38:return s?(i=u.find(".cuselOptHover").eq(0).length?u.find(".cuselOptHover").eq(0):u.find(".cuselActive").eq(0),e=i.prev(),e.is(".cuselItem")&&(i.removeClass("cuselOptHover"),e.addClass("cuselOptHover"),t(u.find(".cusel-scroll-wrap").eq(0)))):(i=r.find(".cuselOptHover").eq(0).length?r.find(".cuselOptHover").eq(0):r.find(".cuselActive").eq(0),e=i.prev(),e.is(".cuselItem")&&e.trigger("click")),!1;case 27:s?(r.removeClass("cuselOpen"),u.hide()):r.blur();break;case 13:return s&&u.find(".cuselOptHover").eq(0).trigger("click").removeClass("cuselOptHover"),!1}});n=[];$(".cusel").keypress(function(i){var f=$(this),o=f.is(".cuselOpen")?!0:!1,r,u,e;if(o){if(u=$("#cuselBox"),window.event?r=window.event.keyCode:i&&(r=i.which),r==null||r==0||r==9)return!0;if($(this).prop("class").indexOf("classDisCusel")!=-1)return!1;n.push(i);clearTimeout($.data(this,"timer"));e=setTimeout(function(){s()},500);f.data("timer",e);function s(){var r=[],i,e,h,f,c,o,s;for(i in n)window.event?r[i]=n[i].keyCode:n[i]&&(r[i]=n[i].which),r[i]=String.fromCharCode(r[i]).toUpperCase();for(e=u.find(".cuselItem label"),h=e.length,f=0;f<h;f++){o=!0;for(s in n)c=e.eq(f).text().charAt(s).toUpperCase(),c!=r[s]&&(o=!1);if(o){u.find(".cuselOptHover").removeClass("cuselOptHover").end().find(".cuselItem").eq(f).addClass("cuselOptHover");t(u.find(".cusel-scroll-wrap").eq(0));n=n.splice;n=[];break}}n=n.splice;n=[]}if($.browser.opera&&window.event.keyCode!=9)return!1}})}function h(n,t){var r=t.data("setclass")?t.data("setclass"):"",u=n.find(".cuselText").data("class")?n.find(".cuselText").data("class"):"",i=t.attr("val");typeof i=="undefined"&&(i=t.find("label").text());n.find(".cuselText").removeClass(u).data("class",r).addClass(r).html(t.html()).end().find("input").val(i).change()}function u(n){var r=n.parent(".cusel"),i=f(),u,e;$(".cuselOpen").removeClass("cuselOpen");i.is(":hidden")?(i.empty(),n.clone(!0).appendTo(i).show(),i.show().data("cusel-select",r[0]),$.ui?i.position({my:"left top",at:"left bottom",of:r}):(u=r.offset(),i.offset({left:u.left,top:u.top+r.outerHeight()})),i.css("min-width",r.outerWidth()+"px"),r.addClass("cuselOpen"),e=r.hasClass("cuselScrollArrows"),i.find(".cusel-scroll-pane").jScrollPaneCusel({showArrows:e}),t(i.find(".cusel-scroll-wrap"))):i.hide().removeData("cusel-select")}function t(n){var t=n.find(".cuselOptHover:first").length?n.find(".cuselOptHover:first"):n.find(".cuselActive:first"),i,r;n.find(".jScrollPaneTrack:first").length&&t.length&&(i=t.position(),r=n.find(".cusel-scroll-pane:first")[0].id,n.find(".cusel-scroll-pane")[0].scrollTo(i.top))}function f(){var n=$("#cuselBox");return n.length||(n=$('<div id="cuselBox">').hide().appendTo("body")),n}var e=250,o=20;$(n.changedEl).each(function(n){var t=$(this);t.is("select")&&!t.prop("multiple")&&r(t,n,1)})}function cuSelRefresh(n){for(var f=n.refreshEl.split(","),e=f.length,t,r,u,i=0;i<e;i++)t=$(f[i]).parents(".cusel").find(".cusel-scroll-wrap").eq(0),t.find(".cusel-scroll-pane").jScrollPaneRemoveCusel(),t.css({visibility:"hidden",display:"block"}),r=t.find(".cuselItem"),u=r.eq(0).outerHeight(),r.length>n.visRows?t.css({height:u*n.visRows+"px",display:"none",visibility:"visible"}).children(".cusel-scroll-pane").css("height",u*n.visRows+"px"):t.css({display:"none",visibility:"visible"})}function cuselSetValue(n,t){var r=$(n).closest(".cusel"),i=r.find(".cuselItem[val="+t+"]").first();if(!i.length)return!1;i.click()}(function(n){n.jScrollPaneCusel={active:[]};n.fn.jScrollPaneCusel=function(t){t=n.extend({},n.fn.jScrollPaneCusel.defaults,t);var i=function(){return!1};return this.each(function(){var r=n(this),kt=this.parentNode.offsetWidth,ot,st,gt,a,ht,ni,k,v,y,e,d,p,lt,at,tt,et,bt,b,c;if(r.css("overflow","hidden"),ot=this,n(this).parent().is(".jScrollPaneContainer")){var st=t.maintainPosition?r.position().top:0,dt=n(this).parent(),o=kt,u=dt.outerHeight(),l=u;n(">.jScrollPaneTrack, >.jScrollArrowUp, >.jScrollArrowDown",dt).remove();r.css({top:0})}else{st=0;this.originalPadding=r.css("paddingTop")+" "+r.css("paddingRight")+" "+r.css("paddingBottom")+" "+r.css("paddingLeft");this.originalSidePaddingTotal=(parseInt(r.css("paddingLeft"))||0)+(parseInt(r.css("paddingRight"))||0);var o=kt,u=r.innerHeight(),l=u;r.wrap("<div class='jScrollPaneContainer'><\/div>").parent().css({height:u+"px",width:o+"px"});window.navigator.userProfile||(gt=parseInt(n(this).parent().css("border-left-width"))+parseInt(n(this).parent().css("border-right-width")),o-=gt,n(this).css("width",o+"px").parent().css("width",o+"px"));n(document).bind("emchange",function(){r.jScrollPaneCusel(t)})}if(t.reinitialiseOnImageLoad&&(a=n.data(ot,"jScrollPaneImagesToLoad")||n("img",r),ht=[],a.length&&a.each(function(i,u){n(this).bind("load",function(){n.inArray(i,ht)==-1&&(ht.push(u),a=n.grep(a,function(n){return n!=u}),n.data(ot,"jScrollPaneImagesToLoad",a),t.reinitialiseOnImageLoad=!1,r.jScrollPaneCusel(t))}).each(function(){(this.complete||this.complete===undefined)&&(this.src=this.src)})})),ni=this.originalSidePaddingTotal,k={height:"auto",width:o-t.scrollbarWidth-t.scrollbarMargin-ni+"px"},t.scrollbarOnLeft?k.paddingLeft=t.scrollbarMargin+t.scrollbarWidth+"px":k.paddingRight=t.scrollbarMargin+"px",r.css(k),v=r.outerHeight(),y=u/v,y<.99){if(e=r.parent(),e.append(n('<div class="jScrollPaneTrack"><\/div>').css({width:t.scrollbarWidth+"px"}).append(n('<div class="jScrollPaneDrag"><\/div>').css({width:t.scrollbarWidth+"px"}).append(n('<div class="jScrollPaneDragTop"><\/div>').css({width:t.scrollbarWidth+"px"}),n('<div class="jScrollPaneDragBottom"><\/div>').css({width:t.scrollbarWidth+"px"})))),d=n(">.jScrollPaneTrack",e),p=n(">.jScrollPaneTrack .jScrollPaneDrag",e),t.showArrows){var g,ct,ti,nt,ii=function(){(nt>4||nt%4==0)&&h(f+ct*yt);nt++},ri=function(){n("html").unbind("mouseup",ri);g.removeClass("jScrollActiveArrowButton");clearInterval(ti)},ui=function(){n("html").bind("mouseup",ri);g.addClass("jScrollActiveArrowButton");nt=0;ii();ti=setInterval(ii,100)};e.append(n("<div><\/div>").attr({"class":"jScrollArrowUp"}).css({width:t.scrollbarWidth+"px"}).bind("mousedown",function(){return g=n(this),ct=-1,ui(),this.blur(),!1}).bind("click",i),n("<div><\/div>").attr({"class":"jScrollArrowDown"}).css({width:t.scrollbarWidth+"px"}).bind("mousedown",function(){return g=n(this),ct=1,ui(),this.blur(),!1}).bind("click",i));lt=n(">.jScrollArrowUp",e);at=n(">.jScrollArrowDown",e);t.arrowSize?(l=u-t.arrowSize-t.arrowSize,d.css({height:l+"px",top:t.arrowSize+"px"})):(tt=lt.height(),t.arrowSize=tt,l=u-tt-at.height(),d.css({height:l+"px",top:tt+"px"}))}var vt=n(this).css({position:"absolute",overflow:"visible"}),w,s,yt,f=0,it=y*u/2,pt=function(n,t){var i=t=="X"?"Left":"Top";return n["page"+t]||n["client"+t]+(document.documentElement["scroll"+i]||document.body["scroll"+i])||0},rt=function(){return!1},ut=function(){b();w=p.offset();w.top-=f;s=l-p[0].offsetHeight;yt=2*t.wheelSpeed*s/v},li=function(t){return ut(),it=pt(t,"Y")-f-w.top,n("html").bind("mouseup",fi).bind("mousemove",ei),n.browser.msie&&n("html").bind("dragstart",rt).bind("selectstart",rt),!1},fi=function(){n("html").unbind("mouseup",fi).unbind("mousemove",ei);it=y*u/2;n.browser.msie&&n("html").unbind("dragstart",rt).unbind("selectstart",rt)},h=function(n){n=n<0?0:n>s?s:n;f=n;p.css({top:n+"px"});var i=n/s;vt.css({top:(u-v)*i+"px"});r.trigger("scroll");t.showArrows&&(lt[n==0?"addClass":"removeClass"]("disabled"),at[n==s?"addClass":"removeClass"]("disabled"))},ei=function(n){h(pt(n,"Y")-w.top-it)},ai=Math.max(Math.min(y*(u-t.arrowSize*2),t.dragMaxHeight),t.dragMinHeight);p.css({height:ai+"px"}).bind("mousedown",li);var oi,ft,si,hi=function(){(ft>8||ft%4==0)&&h(f-(f-si)/2);ft++},ci=function(){clearInterval(oi);n("html").unbind("mouseup",ci).unbind("mousemove",wt)},wt=function(n){si=pt(n,"Y")-w.top-it},vi=function(t){ut();wt(t);ft=0;n("html").bind("mouseup",ci).bind("mousemove",wt);oi=setInterval(hi,100);hi()};d.bind("mousedown",vi);e.bind("mousewheel",function(n,t){var i,r;return ut(),b(),i=f,h(f-t*yt),r=i!=f,!1});function yi(){var n=(et-f)/t.animateStep;n>1||n<-1?h(f+n):(h(et),b())}b=function(){bt&&(clearInterval(bt),delete et)};c=function(i,f){if(typeof i=="string"){if($e=n(i,r),!$e.length)return;i=$e.offset().top-r.offset().top}e.scrollTop(0);b();var o=-i/(u-v)*s;f||!t.animateTo?h(o):(et=o,bt=setInterval(yi,t.animateInterval))};r[0].scrollTo=c;r[0].scrollBy=function(n){var t=-parseInt(vt.css("top"))||0;c(t+n)};ut();c(-st,!0);n("*",this).bind("focus",function(){for(var f=n(this),i=0,o;f[0]!=r[0];)i+=f.position().top,f=f.offsetParent();var e=-parseInt(vt.css("top"))||0,s=e+u,h=i>e&&i<s;h||(o=i-t.scrollbarMargin,i>e&&(o+=n(this).height()+15+t.scrollbarMargin-u),c(o))});location.hash&&c(location.hash);n(document).bind("click",function(t){if($target=n(t.target),$target.is("a")){var i=$target.attr("href");i.substr(0,1)=="#"&&c(i)}});n.jScrollPaneCusel.active.push(r[0])}else r.css({height:u+"px",width:o-this.originalSidePaddingTotal+"px",padding:this.originalPadding}),r.parent().unbind("mousewheel")})};n.fn.jScrollPaneRemoveCusel=function(){n(this).each(function(){$this=n(this);var t=$this.parent();t.is(".jScrollPaneContainer")&&($this.css({top:"",height:"",width:"",padding:"",overflow:"",position:""}),$this.attr("style",$this.data("originalStyleTag")),t.after($this).remove())})};n.fn.jScrollPaneCusel.defaults={scrollbarWidth:10,scrollbarMargin:5,wheelSpeed:18,showArrows:!1,arrowSize:0,animateTo:!1,dragMinHeight:1,dragMaxHeight:99999,animateInterval:100,animateStep:3,maintainPosition:!0,scrollbarOnLeft:!1,reinitialiseOnImageLoad:!1};n(window).bind("unload",function(){for(var i=n.jScrollPaneCusel.active,t=0;t<i.length;t++)i[t].scrollTo=i[t].scrollBy=null})})(jQuery),function(n){function r(t){var i=t||window.event,e=[].slice.call(arguments,1),r=0,f=0,u=0;return t=n.event.fix(i),t.type="mousewheel",i.wheelDelta&&(r=i.wheelDelta/120),i.detail&&(r=-i.detail/3),u=r,i.axis!==undefined&&i.axis===i.HORIZONTAL_AXIS&&(u=0,f=-1*r),i.wheelDeltaY!==undefined&&(u=i.wheelDeltaY/120),i.wheelDeltaX!==undefined&&(f=i.wheelDeltaX/-120),e.unshift(t,r,f,u),(n.event.dispatch||n.event.handle).apply(this,e)}var t=["DOMMouseScroll","mousewheel"],i;if(n.event.fixHooks)for(i=t.length;i;)n.event.fixHooks[t[--i]]=n.event.mouseHooks;n.event.special.mousewheel={setup:function(){if(this.addEventListener)for(var n=t.length;n;)this.addEventListener(t[--n],r,!1);else this.onmousewheel=r},teardown:function(){if(this.removeEventListener)for(var n=t.length;n;)this.removeEventListener(t[--n],r,!1);else this.onmousewheel=null}};n.fn.extend({mousewheel:function(n){return n?this.bind("mousewheel",n):this.trigger("mousewheel")},unmousewheel:function(n){return this.unbind("mousewheel",n)}})}(jQuery),function(n,t){n.kalypto=function(t,i){var r=this,u=n(t),e={toggleClass:"toggle",checkedClass:"checked",hideInputs:!0,copyInputClasses:!0,dataLabel:u.data("label")||"",checkedEvent:"k_checked",uncheckedEvent:"k_unchecked",elBuiltEvent:"k_elbuilt",customClasses:""},o,s=function(){u.next().hasClass(r.settings.toggleClass)||(u.after(function(){var n=r.settings.toggleClass,t;return r.settings.copyInputClasses&&(t=u.attr("class"),t&&(n+=" "+t)),r.settings.customClasses.length&&(n+=" "+r.settings.customClasses),u.is(":checked")?"<a href='#' class='kalypto-btn "+n+" "+r.settings.checkedClass+"'>"+r.settings.dataLabel+"<\/a>":"<a href='#' class='kalypto-btn "+n+"'>"+r.settings.dataLabel+"<\/a>"}),r.settings.hideInputs&&u.hide(),o=u.next(),u.trigger(r.settings.elBuiltEvent))},f=function(t){var i=u.attr("type")==="radio"?n('input[name="'+u.attr("name")+'"]'):u,f=function(){u.attr("type")==="radio"&&i.each(function(t,i){var u=n(i);u.next().removeClass(r.settings.checkedClass);u.is(":checked")||r.lastClickedEl===u.next().get(0)||u.trigger(r.settings.uncheckedEvent)});u.is(":checked")?u.trigger(r.settings.checkedEvent):u.trigger(r.settings.uncheckedEvent);u.nextAll(".kalypto-btn:first").toggleClass(r.settings.checkedClass)};this.tagName!=="INPUT"?(t.preventDefault(),r.lastClickedEl=this,u.trigger("click")):(u.trigger("click"),setTimeout(f,100))},h=function(){u.next().on("click",f);u.on("change",f)};r.settings={};r.init=function(){r.settings=n.extend({},e,i);s();h()};r.init()};n.fn.kalypto=function(i){return this.each(function(){if(t===n(this).data("kalypto")){var r=new n.kalypto(this,i);n(this).data("kalypto",r)}})}}(jQuery)