jQuery.autocomplete=function(d,w){var r=this;var A=jQuery(d).attr("autocomplete","off");if(w.inputClass){A.addClass(w.inputClass)}var s=document.createElement("div");var j=jQuery(s).hide().addClass(w.resultsClass).css("position","absolute");if(w.width>0){j.css("width",w.width)}jQuery("body").append(s);d.autocompleter=r;var J=null;var z="";var K=-1;var l={};var D=false;var n=false;var a=null;var m=false;var h=false;function o(){l={};l.data={};l.length=0}o();if(w.data!=null){var u="",P={},p=[];if(typeof w.url!="string"){w.cacheLength=1}for(var N=0;N<w.data.length;N++){p=((typeof w.data[N]=="string")?[w.data[N]]:w.data[N]);if(p[0].length>0){u=p[0].substring(0,1).toLowerCase();if(!P[u]){P[u]=[]}P[u].push(p)}}for(var M in P){w.cacheLength++;e(M,P[M])}}A.keydown(function(i){a=i.keyCode;switch(i.keyCode){case 38:i.preventDefault();F(-1);break;case 40:i.preventDefault();F(1);break;case 9:case 13:if(H()){A.get(0).blur();i.preventDefault()}break;default:K=-1;if(J){clearTimeout(J)}J=setTimeout(function(){v()},w.delay);break}}).focus(function(){n=true}).blur(function(){n=false;if(!m){c()}});x();function v(){if(a==46||(a>8&&a<32)){return j.hide()}var i=A.val();if(i==z){return}z=i;if(i.length>=w.minChars){A.addClass(w.loadingClass);E(i)}else{A.removeClass(w.loadingClass);j.hide()}}function F(k){var i=jQuery("li",s);if(!i){return}K+=k;if(K<0){K=0}else{if(K>=i.size()){K=i.size()-1}}i.removeClass("ac_over");jQuery(i[K]).addClass("ac_over")}function H(){var i=jQuery("li.ac_over",s)[0];if(!i){var k=jQuery("li",s);if(w.selectOnly){if(k.length==1){i=k[0]}}else{if(w.selectFirst){i=k[0]}}}if(i){t(i);return true}else{return false}}function t(i){if(!i){i=document.createElement("li");i.extra=[];i.selectValue=""}var k=jQuery.trim(i.selectValue?i.selectValue:i.innerHTML);d.lastSelected=k;z=k;j.html("");A.val(k);x();if(w.onItemSelect){setTimeout(function(){w.onItemSelect(i)},1)}}function b(R,k){var Q=A.get(0);if(Q.createTextRange){var i=Q.createTextRange();i.collapse(true);i.moveStart("character",R);i.moveEnd("character",k);i.select()}else{if(Q.setSelectionRange){Q.setSelectionRange(R,k)}else{if(Q.selectionStart){Q.selectionStart=R;Q.selectionEnd=k}}}Q.focus()}function y(i){if(a!=8){A.val(A.val()+i.substring(z.length));b(z.length,i.length)}}function G(){var k=B(d);var i=(w.width>0)?w.width:A.width();j.css({width:parseInt(i)+"px",top:(k.y+d.offsetHeight)+"px",left:k.x+"px"}).show()}function c(){if(J){clearTimeout(J)}J=setTimeout(x,200)}function x(){if(h){return}h=true;if(J){clearTimeout(J)}var i=A.removeClass(w.loadingClass).val();if(j.is(":visible")){j.hide()}if(w.mustMatch){if(!d.lastSelected||d.lastSelected!=i){t(null)}}h=false}function g(k,i){if(i){A.removeClass(w.loadingClass);s.innerHTML="";if(!n||i.length==0){return x()}if(jQuery.browser.msie){j.append(document.createElement("iframe"))}s.appendChild(L(i));if(w.autoFill&&(A.val().toLowerCase()==k.toLowerCase())){y(i[0][0])}G()}else{x()}}function f(S){if(!S){return null}var k=[];var R=S.split(w.lineSeparator);for(var Q=0;Q<R.length;Q++){var T=jQuery.trim(R[Q]);if(T){T=T.split(w.cellSeparator);if(typeof w.acceptRow=="undefined"||w.acceptRow(T)){k[k.length]=T}}}return k}function L(R){var V=document.createElement("ul");var T=R.length;if((w.maxItemsToShow>0)&&(w.maxItemsToShow<T)){T=w.maxItemsToShow}for(var S=0;S<T;S++){var X=R[S];if(!X){continue}var W=document.createElement("li");if(w.formatItem){W.innerHTML=w.formatItem(X,S,T,W);W.selectValue=X[0]}else{W.innerHTML=X[0];W.selectValue=X[0]}var k=null;if(X.length>0){k=[];for(var Q=0;Q<X.length;Q++){k[k.length]=X[Q]}}W.extra=k;V.appendChild(W);jQuery(W).hover(function(){jQuery("li",V).removeClass("ac_over");jQuery(this).addClass("ac_over");K=jQuery("li",V).indexOf(jQuery(this).get(0))},function(){jQuery(this).removeClass("ac_over")}).click(function(i){i.preventDefault();i.stopPropagation();t(this)});try{if(w.decorateRow){w.decorateRow(W)}}catch(U){console.error(U)}}jQuery(V).mousedown(function(){m=true}).mouseup(function(){m=false});return V}function E(k){if(!w.matchCase){k=k.toLowerCase()}var i=w.cacheLength?O(k):null;if(i){g(k,i)}else{if((typeof w.url=="string")&&(w.url.length>0)){jQuery.get(q(k),function(Q){Q=f(Q);e(k,Q);g(k,Q)})}else{A.removeClass(w.loadingClass)}}}function q(S){var Q=w.url.indexOf("?")==-1?"?":"&";Q="/";var k=w.url+Q+""+encodeURI(S);for(var R in w.extraParams){k+="&"+R+"="+encodeURI(w.extraParams[R])}return k}function O(V){if(!V){return null}if(l.data[V]){return l.data[V]}if(w.matchSubset){for(var T=V.length-1;T>=w.minChars;T--){var Q=V.substr(0,T);var W=l.data[Q];if(W){var U=[];for(var R=0;R<W.length;R++){var k=W[R];var S=k[0];if(C(S,V)){U[U.length]=k}}return U}}}return null}function C(R,Q){if(!w.matchCase){R=R.toLowerCase()}var k=R.indexOf(Q);if(k==-1){return false}return k==0||w.matchContains}this.flushCache=function(){o()};this.setExtraParams=function(i){w.extraParams=i};this.findValue=function(){var k=A.val();if(!w.matchCase){k=k.toLowerCase()}var i=w.cacheLength?O(k):null;if(i){I(k,i)}else{if((typeof w.url=="string")&&(w.url.length>0)){jQuery.get(q(k),function(Q){Q=f(Q);e(k,Q);I(k,Q)})}else{I(k,null)}}};function I(V,U){if(U){A.removeClass(w.loadingClass)}var S=(U)?U.length:0;var Q=null;for(var T=0;T<S;T++){var W=U[T];if(W[0].toLowerCase()==V.toLowerCase()){Q=document.createElement("li");if(w.formatItem){Q.innerHTML=w.formatItem(W,T,S);Q.selectValue=W[0]}else{Q.innerHTML=W[0];Q.selectValue=W[0]}var k=null;if(W.length>1){k=[];for(var R=1;R<W.length;R++){k[k.length]=W[R]}}Q.extra=k}}if(w.onFindValue){setTimeout(function(){w.onFindValue(Q)},1)}}function e(k,i){if(!i||!k||!w.cacheLength){return}if(!l.length||l.length>w.cacheLength){o();l.length++}else{if(!l[k]){l.length++}}l.data[k]=i}function B(k){var R=jQuery(k).offset();R={x:R.left,y:R.top};return R;var Q=k.offsetLeft||0;var i=k.offsetTop||0;while(k=k.offsetParent){Q+=k.offsetLeft;i+=k.offsetTop}return{x:Q+3,y:i}}};jQuery.fn.autocomplete=function(b,a,c){a=a||{};a.url=b;a.data=((typeof c=="object")&&(c.constructor==Array))?c:null;a=jQuery.extend({inputClass:"ac_input",resultsClass:"ac_results",lineSeparator:"\n",cellSeparator:"|",minChars:1,delay:400,matchCase:0,matchSubset:1,matchContains:0,cacheLength:1,mustMatch:0,extraParams:{},loadingClass:"ac_loading",selectFirst:false,selectOnly:false,maxItemsToShow:-1,autoFill:false,width:0},a);a.width=parseInt(a.width,10);this.each(function(){var d=this;new jQuery.autocomplete(d,a)});return this};jQuery.fn.autocompleteArray=function(b,a){return this.autocomplete(null,a,b)};jQuery.fn.indexOf=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return a}}return -1};addOnLoad(function(){jQuery("table.hoverable tr:not(.noHover) td").hover(function(){jQuery(this).closest("tr").addClass("hover")},function(){jQuery(this).closest("tr").removeClass("hover")});jQuery(".buttonLink").hover(function(){jQuery(this).addClass("hoverButtonLink")},function(){jQuery(this).removeClass("hoverButtonLink")});jQuery(".languages a:not(.selected) img").css("opacity","0.5");jQuery(".languages a img").hover(function(){jQuery(this).css("opacity","1")},function(){if(jQuery(this).parent().is(".selected")){jQuery(this).css("opacity","1")}else{jQuery(this).css("opacity","0.5")}})});var openTeamId=0;var MenuManager=function(){this.element=null;this.menuHandlers=new Map()};MenuManager.prototype.init=function(){var b=this.element=jQuery("<div/>");b.hide();jQuery(document.body).append(b);b.addClass("popupMenu");var a=this;jQuery(document.body).click(function(h){var g=false;var e=jQuery(h.target);var d=a.menuHandlers.keys();for(var c=0;c<d.length;c++){var f=d[c];if(e.is("."+f)){g=true}}if(!g){a.hideDropDown()}})};MenuManager.prototype.setMenuHandler=function(a,b){this.menuHandlers.put(a,b);this.attach()};MenuManager.prototype.attach=function(a){if(!a){a=document.body}a=jQuery(a);var c=this.menuHandlers.keys();for(var b=0;b<c.length;b++){var d=c[b];this.attachToType(a,d)}};MenuManager.prototype.attachToType=function(a,c){var d=this.menuHandlers.get(c);var b=this;a.find("."+c).unbind("click").click(function(){var f=jQuery(this);if(!f.is("."+c+"Pressed")){var e=b.generateDropDown(d,f);if(e){b.dropDown(f,c)}}else{b.hideDropDown()}return false}).blur(function(){})};MenuManager.prototype.generateDropDown=function(f,a){var d=this;var b=f(a);if(b.length==0){return false}this.element.html("");var g=jQuery("<div/>");g.addClass("tip");this.element.append(g);for(var c=0;c<b.length;c++){var e=b[c];var h=null;if(e.url){menuItem=jQuery('<a href="'+e.url+'">'+e.title+"</a>").appendTo(this.element)}else{menuItem=jQuery("<span>"+e.title+"</span>").appendTo(this.element)}menuItem.addClass("type_"+e.type);menuItem.addClass("menuItem");if(e.onclick&&e.url){menuItem.click(function(){d.hideDropDown();return e.onclick()})}menuItem.hover(function(){jQuery(this).addClass("menuItemHover")},function(){jQuery(this).removeClass("menuItemHover")})}return true};MenuManager.prototype.dropDown=function(c,g){clearTimeout(this.hideTimeout);this.hideTimeout=null;var h=c.offset();var a=c.outerHeight();this.element.css("left",h.left);this.element.css("top",h.top+a-1);var f=this;this.element.slideDown(200,function(){});if(this.currentSourceElement){var e=this.menuHandlers.keys();for(var d=0;d<e.length;d++){var b=e[d];this.currentSourceElement.removeClass(b+"Pressed")}this.currentSourceElement.css("position","static").css("z-index","")}c.addClass(g+"Pressed");c.css("position","relative").css("z-index","1000");this.currentSourceElement=c};MenuManager.prototype.hideDropDown=function(){var a=this;var b=this.currentSourceElement;this.hideTimeout=setTimeout(function(){a.element.hide();if(b){var e=a.menuHandlers.keys();for(var d=0;d<e.length;d++){var c=e[d];b.removeClass(c+"Pressed")}}clearTimeout(a.hideTimeout);a.hideTimeout=null},200)};var menuManager=new MenuManager();jQuery(function(){menuManager.init();addOnLoad(function(){menuManager.attach()})});var TeamMessaging=function(){this.currentTeamId=0};TeamMessaging.prototype.init=function(){var a=this;jQuery(".contactFormPopup .cancel").click(function(){a.close();
return false});jQuery(".contactFormPopup .submit button").click(function(){var b=jQuery(".contactFormPopup *[validate]");b.validate();var c=jQuery(".contactFormPopup *[validate].valid");if(b.length>c.length){return false}jQuery(".contactFormPopup a").hide();jQuery(".contactFormPopup .spinner").show();CupMan.callService("SendTeamMailService",{data:{toTeamId:a.currentTeamId,fromName:jQuery("#popup_yourName").val(),fromEmail:jQuery("#popup_yourEmail").val(),body:jQuery("#popup_messageBody").val()},success:function(e){a.close();var d=jQuery("td.teamName[teamId='"+a.currentTeamId+"'] a");d.qtip({content:"Mail sent!",position:{corner:{target:"rightMiddle",tooltip:"leftMiddle"}},style:{name:"red",padding:1,border:{width:2},tip:"leftMiddle"},show:{ready:true}});setTimeout(function(){d.qtip("hide")},2500)},complete:function(){jQuery(".contactFormPopup a").show();jQuery(".contactFormPopup .spinner").hide()}})})};TeamMessaging.prototype.close=function(){jQuery.modal.close()};TeamMessaging.prototype.open=function(a,b){this.currentTeamId=a;jQuery("#popup_teamName").val(b.trim());jQuery(".contactFormPopup").modal();window.scrollTo(0,0)};jQuery(function(){teamMessaging=new TeamMessaging();addOnLoad(function(){teamMessaging.init()})});var SubscribeManager=function(){this.el=null};SubscribeManager.prototype.init=function(){var b=this;var a=jQuery("#subscriptionDialog");if(a.length>0){this.el=a;jQuery("#page1_phoneNr").keyup(function(){var c=jQuery(this).val();var d=new RegExp("^(\\+|00)\\d").test(c);b.showError(null);if(!d){b.showError(".errorNoCountryCode")}});jQuery("#page1_nextBtn").click(function(){b.phone=jQuery("#page1_phoneNr").val();var c=new RegExp("^(\\+|00)\\d").test(b.phone);b.showError(null);if(!c){b.showError(".errorNoCountryCode");return false}var d={test:true,address:b.phone,request:"2 "+b.currentType.identifier,method:"SMS"};CupMan.callService("SubscribeService",{data:d,success:function(e){b.setPage(2)},error:function(e,f){b.showError(".errorBadNumber")}})});jQuery("#page2_nextBtn").click(function(){var c=jQuery("#page2_code").val();var d={test:false,address:b.phone,request:"2 "+b.currentType.identifier,method:"SMS",code:c};CupMan.callService("SubscribeService",{data:d,success:function(e){var f=e.message;a.find(".dialogPage3 p").html(f);b.setPage(3)},error:function(e,f){b.showError(".errorBadCode")}})});jQuery("#page3_closeBtn").click(function(){jQuery.modal.close()})}};SubscribeManager.prototype.showError=function(a){this.el.find(".error").hide();this.el.find(a).show()};SubscribeManager.prototype.setPage=function(a){this.el.find(".dialogPage").hide();this.el.find(".dialogPage"+a).show()};SubscribeManager.prototype.popup=function(b){var a=this;this.popdown();this.currentType=b;this.setPage(1);this.el.find("h1 span").html(b.name);window.scrollTo(0,0);this.el.modal({close:true,persist:true})};SubscribeManager.prototype.popdown=function(){jQuery.modal.close();this.currentType=null};var subscribeManager=null;jQuery(function(){subscribeManager=new SubscribeManager();addOnLoad(function(){subscribeManager.init()})});
