//touch click helper
(function ($) {
    'use strict';
    $.fn.tclick = function (onclick) {
        this.bind('touchstart', function (e) { onclick.call(this, e); e.stopPropagation(); e.preventDefault(); });
        this.bind('click', function (e) { onclick.call(this, e); });   //substitute mousedown event for exact same result as touchstart
        return this;
    };
})(jQuery);
/* http://keith-wood.name/realPerson.html
   Real Person Form Submission for jQuery v1.1.1.
   Written by Keith Wood (kwood{at}iinet.com.au) June 2009.
   Please attribute the author if you use it. */
(function($){function RealPerson(){this._defaults={length:6,includeNumbers:false,regenerate:'Click to change',hashName:'{n}Hash'}}var f='ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';var g=[['   *   ','  * *  ','  * *  ',' *   * ',' ***** ','*     *','*     *'],['****** ','*     *','*     *','****** ','*     *','*     *','****** '],[' ***** ','*     *','*      ','*      ','*      ','*     *',' ***** '],['****** ','*     *','*     *','*     *','*     *','*     *','****** '],['*******','*      ','*      ','****   ','*      ','*      ','*******'],['*******','*      ','*      ','****   ','*      ','*      ','*      '],[' ***** ','*     *','*      ','*      ','*   ***','*     *',' ***** '],['*     *','*     *','*     *','*******','*     *','*     *','*     *'],['*******','   *   ','   *   ','   *   ','   *   ','   *   ','*******'],['      *','      *','      *','      *','      *','*     *',' ***** '],['*     *','*   ** ','* **   ','**     ','* **   ','*   ** ','*     *'],['*      ','*      ','*      ','*      ','*      ','*      ','*******'],['*     *','**   **','* * * *','*  *  *','*     *','*     *','*     *'],['*     *','**    *','* *   *','*  *  *','*   * *','*    **','*     *'],[' ***** ','*     *','*     *','*     *','*     *','*     *',' ***** '],['****** ','*     *','*     *','****** ','*      ','*      ','*      '],[' ***** ','*     *','*     *','*     *','*   * *','*    * ',' **** *'],['****** ','*     *','*     *','****** ','*   *  ','*    * ','*     *'],[' ***** ','*     *','*      ',' ***** ','      *','*     *',' ***** '],['*******','   *   ','   *   ','   *   ','   *   ','   *   ','   *   '],['*     *','*     *','*     *','*     *','*     *','*     *',' ***** '],['*     *','*     *',' *   * ',' *   * ','  * *  ','  * *  ','   *   '],['*     *','*     *','*     *','*  *  *','* * * *','**   **','*     *'],['*     *',' *   * ','  * *  ','   *   ','  * *  ',' *   * ','*     *'],['*     *',' *   * ','  * *  ','   *   ','   *   ','   *   ','   *   '],['*******','     * ','    *  ','   *   ','  *    ',' *     ','*******'],['  ***  ',' *   * ','*   * *','*  *  *','* *   *',' *   * ','  ***  '],['   *   ','  **   ',' * *   ','   *   ','   *   ','   *   ','*******'],[' ***** ','*     *','      *','     * ','   **  ',' **    ','*******'],[' ***** ','*     *','      *','    ** ','      *','*     *',' ***** '],['    *  ','   **  ','  * *  ',' *  *  ','*******','    *  ','    *  '],['*******','*      ','****** ','      *','      *','*     *',' ***** '],['  **** ',' *     ','*      ','****** ','*     *','*     *',' ***** '],['*******','     * ','    *  ','   *   ','  *    ',' *     ','*      '],[' ***** ','*     *','*     *',' ***** ','*     *','*     *',' ***** '],[' ***** ','*     *','*     *',' ******','      *','     * ',' ****  ']];$.extend(RealPerson.prototype,{markerClassName:'hasRealPerson',propertyName:'realperson',setDefaults:function(a){$.extend(this._defaults,a||{});return this},_attachPlugin:function(a,b){a=$(a);if(a.hasClass(this.markerClassName)){return}var c={options:$.extend({},this._defaults)};a.addClass(this.markerClassName).data(this.propertyName,c);this._optionPlugin(a,b)},_optionPlugin:function(a,b,c){a=$(a);var d=a.data(this.propertyName);if(!b||(typeof b=='string'&&c==null)){var e=b;b=(d||{}).options;return(b&&e?b[e]:b)}if(!a.hasClass(this.markerClassName)){return}b=b||{};if(typeof b=='string'){var e=b;b={};b[e]=c}$.extend(d.options,b);a.prevAll('.'+this.propertyName+'-challenge,.'+this.propertyName+'-hash').remove().end().before(this._generateHTML(a,d))},_generateHTML:function(a,b){var c='';for(var i=0;i<b.options.length;i++){c+=f.charAt(Math.floor(Math.random()*(b.options.includeNumbers?36:26)))}var d='<div class="'+this.propertyName+'-challenge">'+'<div class="'+this.propertyName+'-text">';for(var i=0;i<g[0].length;i++){for(var j=0;j<c.length;j++){d+=g[f.indexOf(c.charAt(j))][i].replace(/ /g,'&nbsp;')+'&nbsp;&nbsp;'}d+='<br>'}d+='</div><div class="'+this.propertyName+'-regen">'+b.options.regenerate+'</div></div><input type="hidden" class="'+this.propertyName+'-hash" name="'+b.options.hashName.replace(/\{n\}/,a.attr('name'))+'" value="'+this._hash(c)+'">';return d},_enablePlugin:function(a){a=$(a);if(!a.hasClass(this.markerClassName)){return}a.removeClass(this.propertyName+'-disabled').prop('disabled',false).prevAll('.'+this.propertyName+'-challenge').removeClass(this.propertyName+'-disabled')},_disablePlugin:function(a){a=$(a);if(!a.hasClass(this.markerClassName)){return}a.addClass(this.propertyName+'-disabled').prop('disabled',true).prevAll('.'+this.propertyName+'-challenge').addClass(this.propertyName+'-disabled')},_destroyPlugin:function(a){a=$(a);if(!a.hasClass(this.markerClassName)){return}a.removeClass(this.markerClassName).removeData(this.propertyName).prevAll('.'+this.propertyName+'-challenge,.'+this.propertyName+'-hash').remove()},_hash:function(a){var b=3592802;for(var i=0;i<a.length;i++){b=((b<<5)+b)+a.charCodeAt(i)}return b}});var h=[''];function isNotChained(a,b){if(a=='option'&&(b.length==0||(b.length==1&&typeof b[0]=='string'))){return true}return $.inArray(a,h)>-1}$.fn.realperson=function(a){var b=Array.prototype.slice.call(arguments,1);if(isNotChained(a,b)){return k['_'+a+'Plugin'].apply(k,[this[0]].concat(b))}return this.each(function(){if(typeof a=='string'){if(!k['_'+a+'Plugin']){throw'Unknown command: '+a;}k['_'+a+'Plugin'].apply(k,[this].concat(b))}else{k._attachPlugin(this,a||{})}})};var k=$.realperson=new RealPerson();$(document).on('click','div.'+k.propertyName+'-challenge',function(){if(!$(this).hasClass(k.propertyName+'-disabled')){$(this).nextAll('.'+k.markerClassName).realperson('option',{})}})})(jQuery);
//noty
"function"!=typeof Object.create&&(Object.create=function(a){function b(){}return b.prototype=a,new b}),function(a){var b={init:function(b){return this.options=a.extend({},a.noty.defaults,b),this.options.layout=this.options.custom?a.noty.layouts.inline:a.noty.layouts[this.options.layout],a.noty.themes[this.options.theme]?this.options.theme=a.noty.themes[this.options.theme]:b.themeClassName=this.options.theme,delete b.layout,delete b.theme,this.options=a.extend({},this.options,this.options.layout.options),this.options.id="noty_"+(new Date).getTime()*Math.floor(1e6*Math.random()),this.options=a.extend({},this.options,b),this._build(),this},_build:function(){var b=a('<div class="noty_bar noty_type_'+this.options.type+'"></div>').attr("id",this.options.id);if(b.append(this.options.template).find(".noty_text").html(this.options.text),this.$bar=null!==this.options.layout.parent.object?a(this.options.layout.parent.object).css(this.options.layout.parent.css).append(b):b,this.options.themeClassName&&this.$bar.addClass(this.options.themeClassName).addClass("noty_container_type_"+this.options.type),this.options.buttons){this.options.closeWith=[],this.options.timeout=!1;var c=a("<div/>").addClass("noty_buttons");null!==this.options.layout.parent.object?this.$bar.find(".noty_bar").append(c):this.$bar.append(c);var d=this;a.each(this.options.buttons,function(b,c){var e=a("<button/>").addClass(c.addClass?c.addClass:"gray").html(c.text).attr("id",c.id?c.id:"button-"+b).appendTo(d.$bar.find(".noty_buttons")).bind("click",function(){a.isFunction(c.onClick)&&c.onClick.call(e,d)})})}this.$message=this.$bar.find(".noty_message"),this.$closeButton=this.$bar.find(".noty_close"),this.$buttons=this.$bar.find(".noty_buttons"),a.noty.store[this.options.id]=this},show:function(){var b=this;return b.options.custom?b.options.custom.find(b.options.layout.container.selector).append(b.$bar):a(b.options.layout.container.selector).append(b.$bar),b.options.theme&&b.options.theme.style&&b.options.theme.style.apply(b),"function"===a.type(b.options.layout.css)?this.options.layout.css.apply(b.$bar):b.$bar.css(this.options.layout.css||{}),b.$bar.addClass(b.options.layout.addClass),b.options.layout.container.style.apply(a(b.options.layout.container.selector)),b.showing=!0,b.options.theme&&b.options.theme.style&&b.options.theme.callback.onShow.apply(this),a.inArray("click",b.options.closeWith)>-1&&b.$bar.css("cursor","pointer").one("click",function(a){b.stopPropagation(a),b.options.callback.onCloseClick&&b.options.callback.onCloseClick.apply(b),b.close()}),a.inArray("hover",b.options.closeWith)>-1&&b.$bar.one("mouseenter",function(){b.close()}),a.inArray("button",b.options.closeWith)>-1&&b.$closeButton.one("click",function(a){b.stopPropagation(a),b.close()}),-1==a.inArray("button",b.options.closeWith)&&b.$closeButton.remove(),b.options.callback.onShow&&b.options.callback.onShow.apply(b),b.$bar.animate(b.options.animation.open,b.options.animation.speed,b.options.animation.easing,function(){b.options.callback.afterShow&&b.options.callback.afterShow.apply(b),b.showing=!1,b.shown=!0}),b.options.timeout&&b.$bar.delay(b.options.timeout).promise().done(function(){b.close()}),this},close:function(){if(!(this.closed||this.$bar&&this.$bar.hasClass("i-am-closing-now"))){var b=this;if(this.showing)return b.$bar.queue(function(){b.close.apply(b)}),void 0;if(!this.shown&&!this.showing){var c=[];return a.each(a.noty.queue,function(a,d){d.options.id!=b.options.id&&c.push(d)}),a.noty.queue=c,void 0}b.$bar.addClass("i-am-closing-now"),b.options.callback.onClose&&b.options.callback.onClose.apply(b),b.$bar.clearQueue().stop().animate(b.options.animation.close,b.options.animation.speed,b.options.animation.easing,function(){b.options.callback.afterClose&&b.options.callback.afterClose.apply(b)}).promise().done(function(){b.options.modal&&(a.notyRenderer.setModalCount(-1),0==a.notyRenderer.getModalCount()&&a(".noty_modal").fadeOut("fast",function(){a(this).remove()})),a.notyRenderer.setLayoutCountFor(b,-1),0==a.notyRenderer.getLayoutCountFor(b)&&a(b.options.layout.container.selector).remove(),"undefined"!=typeof b.$bar&&null!==b.$bar&&(b.$bar.remove(),b.$bar=null,b.closed=!0),delete a.noty.store[b.options.id],b.options.theme.callback&&b.options.theme.callback.onClose&&b.options.theme.callback.onClose.apply(b),b.options.dismissQueue||(a.noty.ontap=!0,a.notyRenderer.render()),b.options.maxVisible>0&&b.options.dismissQueue&&a.notyRenderer.render()})}},setText:function(a){return this.closed||(this.options.text=a,this.$bar.find(".noty_text").html(a)),this},setType:function(a){return this.closed||(this.options.type=a,this.options.theme.style.apply(this),this.options.theme.callback.onShow.apply(this)),this},setTimeout:function(a){if(!this.closed){var b=this;this.options.timeout=a,b.$bar.delay(b.options.timeout).promise().done(function(){b.close()})}return this},stopPropagation:function(a){a=a||window.event,"undefined"!=typeof a.stopPropagation?a.stopPropagation():a.cancelBubble=!0},closed:!1,showing:!1,shown:!1};a.notyRenderer={},a.notyRenderer.init=function(c){var d=Object.create(b).init(c);return d.options.killer&&a.noty.closeAll(),d.options.force?a.noty.queue.unshift(d):a.noty.queue.push(d),a.notyRenderer.render(),"object"==a.noty.returns?d:d.options.id},a.notyRenderer.render=function(){var b=a.noty.queue[0];"object"===a.type(b)?b.options.dismissQueue?b.options.maxVisible>0?a(b.options.layout.container.selector+" li").length<b.options.maxVisible&&a.notyRenderer.show(a.noty.queue.shift()):a.notyRenderer.show(a.noty.queue.shift()):a.noty.ontap&&(a.notyRenderer.show(a.noty.queue.shift()),a.noty.ontap=!1):a.noty.ontap=!0},a.notyRenderer.show=function(b){b.options.modal&&(a.notyRenderer.createModalFor(b),a.notyRenderer.setModalCount(1)),b.options.custom?0==b.options.custom.find(b.options.layout.container.selector).length?b.options.custom.append(a(b.options.layout.container.object).addClass("i-am-new")):b.options.custom.find(b.options.layout.container.selector).removeClass("i-am-new"):0==a(b.options.layout.container.selector).length?a("body").append(a(b.options.layout.container.object).addClass("i-am-new")):a(b.options.layout.container.selector).removeClass("i-am-new"),a.notyRenderer.setLayoutCountFor(b,1),b.show()},a.notyRenderer.createModalFor=function(b){if(0==a(".noty_modal").length){var c=a("<div/>").addClass("noty_modal").addClass(b.options.theme).data("noty_modal_count",0);b.options.theme.modal&&b.options.theme.modal.css&&c.css(b.options.theme.modal.css),c.prependTo(a("body")).fadeIn("fast")}},a.notyRenderer.getLayoutCountFor=function(b){return a(b.options.layout.container.selector).data("noty_layout_count")||0},a.notyRenderer.setLayoutCountFor=function(b,c){return a(b.options.layout.container.selector).data("noty_layout_count",a.notyRenderer.getLayoutCountFor(b)+c)},a.notyRenderer.getModalCount=function(){return a(".noty_modal").data("noty_modal_count")||0},a.notyRenderer.setModalCount=function(b){return a(".noty_modal").data("noty_modal_count",a.notyRenderer.getModalCount()+b)},a.fn.noty=function(b){return b.custom=a(this),a.notyRenderer.init(b)},a.noty={},a.noty.queue=[],a.noty.ontap=!0,a.noty.layouts={},a.noty.themes={},a.noty.returns="object",a.noty.store={},a.noty.get=function(b){return a.noty.store.hasOwnProperty(b)?a.noty.store[b]:!1},a.noty.close=function(b){return a.noty.get(b)?a.noty.get(b).close():!1},a.noty.setText=function(b,c){return a.noty.get(b)?a.noty.get(b).setText(c):!1},a.noty.setType=function(b,c){return a.noty.get(b)?a.noty.get(b).setType(c):!1},a.noty.clearQueue=function(){a.noty.queue=[]},a.noty.closeAll=function(){a.noty.clearQueue(),a.each(a.noty.store,function(a,b){b.close()})};var c=window.alert;a.noty.consumeAlert=function(b){window.alert=function(c){b?b.text=c:b={text:c},a.notyRenderer.init(b)}},a.noty.stopConsumeAlert=function(){window.alert=c},a.noty.defaults={layout:"top",theme:"defaultTheme",type:"alert",text:"",dismissQueue:!0,template:'<div class="noty_message"><span class="noty_text"></span><div class="noty_close"></div></div>',animation:{open:{height:"toggle"},close:{height:"toggle"},easing:"swing",speed:500},timeout:!1,force:!1,modal:!1,maxVisible:5,killer:!1,closeWith:["click"],callback:{onShow:function(){},afterShow:function(){},onClose:function(){},afterClose:function(){},onCloseClick:function(){}},buttons:!1},a(window).resize(function(){a.each(a.noty.layouts,function(b,c){c.container.style.apply(a(c.container.selector))})})}(jQuery),window.noty=function(a){return jQuery.notyRenderer.init(a)},function(a){a.noty.layouts.bottom={name:"bottom",options:{},container:{object:'<ul id="noty_bottom_layout_container" />',selector:"ul#noty_bottom_layout_container",style:function(){a(this).css({bottom:0,left:"5%",position:"fixed",width:"90%",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:9999999})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none"},addClass:""}}(jQuery),function(a){a.noty.layouts.bottomCenter={name:"bottomCenter",options:{},container:{object:'<ul id="noty_bottomCenter_layout_container" />',selector:"ul#noty_bottomCenter_layout_container",style:function(){a(this).css({bottom:20,left:0,position:"fixed",width:"310px",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:1e7}),a(this).css({left:(a(window).width()-a(this).outerWidth(!1))/2+"px"})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none",width:"310px"},addClass:""}}(jQuery),function(a){a.noty.layouts.bottomLeft={name:"bottomLeft",options:{},container:{object:'<ul id="noty_bottomLeft_layout_container" />',selector:"ul#noty_bottomLeft_layout_container",style:function(){a(this).css({bottom:20,left:20,position:"fixed",width:"310px",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:1e7}),window.innerWidth<600&&a(this).css({left:5})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none",width:"310px"},addClass:""}}(jQuery),function(a){a.noty.layouts.bottomRight={name:"bottomRight",options:{},container:{object:'<ul id="noty_bottomRight_layout_container" />',selector:"ul#noty_bottomRight_layout_container",style:function(){a(this).css({bottom:20,right:20,position:"fixed",width:"310px",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:1e7}),window.innerWidth<600&&a(this).css({right:5})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none",width:"310px"},addClass:""}}(jQuery),function(a){a.noty.layouts.center={name:"center",options:{},container:{object:'<ul id="noty_center_layout_container" />',selector:"ul#noty_center_layout_container",style:function(){a(this).css({position:"fixed",width:"310px",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:1e7});var b=a(this).clone().css({visibility:"hidden",display:"block",position:"absolute",top:0,left:0}).attr("id","dupe");a("body").append(b),b.find(".i-am-closing-now").remove(),b.find("li").css("display","block");var c=b.height();b.remove(),a(this).hasClass("i-am-new")?a(this).css({left:(a(window).width()-a(this).outerWidth(!1))/2+"px",top:(a(window).height()-c)/2+"px"}):a(this).animate({left:(a(window).width()-a(this).outerWidth(!1))/2+"px",top:(a(window).height()-c)/2+"px"},500)}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none",width:"310px"},addClass:""}}(jQuery),function(a){a.noty.layouts.centerLeft={name:"centerLeft",options:{},container:{object:'<ul id="noty_centerLeft_layout_container" />',selector:"ul#noty_centerLeft_layout_container",style:function(){a(this).css({left:20,position:"fixed",width:"310px",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:1e7});var b=a(this).clone().css({visibility:"hidden",display:"block",position:"absolute",top:0,left:0}).attr("id","dupe");a("body").append(b),b.find(".i-am-closing-now").remove(),b.find("li").css("display","block");var c=b.height();b.remove(),a(this).hasClass("i-am-new")?a(this).css({top:(a(window).height()-c)/2+"px"}):a(this).animate({top:(a(window).height()-c)/2+"px"},500),window.innerWidth<600&&a(this).css({left:5})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none",width:"310px"},addClass:""}}(jQuery),function(a){a.noty.layouts.centerRight={name:"centerRight",options:{},container:{object:'<ul id="noty_centerRight_layout_container" />',selector:"ul#noty_centerRight_layout_container",style:function(){a(this).css({right:20,position:"fixed",width:"310px",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:1e7});var b=a(this).clone().css({visibility:"hidden",display:"block",position:"absolute",top:0,left:0}).attr("id","dupe");a("body").append(b),b.find(".i-am-closing-now").remove(),b.find("li").css("display","block");var c=b.height();b.remove(),a(this).hasClass("i-am-new")?a(this).css({top:(a(window).height()-c)/2+"px"}):a(this).animate({top:(a(window).height()-c)/2+"px"},500),window.innerWidth<600&&a(this).css({right:5})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none",width:"310px"},addClass:""}}(jQuery),function(a){a.noty.layouts.inline={name:"inline",options:{},container:{object:'<ul class="noty_inline_layout_container" />',selector:"ul.noty_inline_layout_container",style:function(){a(this).css({width:"100%",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:9999999})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none"},addClass:""}}(jQuery),function(a){a.noty.layouts.top={name:"top",options:{},container:{object:'<ul id="noty_top_layout_container" />',selector:"ul#noty_top_layout_container",style:function(){a(this).css({top:0,left:"5%",position:"fixed",width:"90%",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:9999999})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none"},addClass:""}}(jQuery),function(a){a.noty.layouts.topCenter={name:"topCenter",options:{},container:{object:'<ul id="noty_topCenter_layout_container" />',selector:"ul#noty_topCenter_layout_container",style:function(){a(this).css({top:20,left:0,position:"fixed",width:"310px",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:1e7}),a(this).css({left:(a(window).width()-a(this).outerWidth(!1))/2+"px"})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none",width:"310px"},addClass:""}}(jQuery),function(a){a.noty.layouts.topLeft={name:"topLeft",options:{},container:{object:'<ul id="noty_topLeft_layout_container" />',selector:"ul#noty_topLeft_layout_container",style:function(){a(this).css({top:20,left:20,position:"fixed",width:"310px",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:1e7}),window.innerWidth<600&&a(this).css({left:5})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none",width:"310px"},addClass:""}}(jQuery),function(a){a.noty.layouts.topRight={name:"topRight",options:{},container:{object:'<ul id="noty_topRight_layout_container" />',selector:"ul#noty_topRight_layout_container",style:function(){a(this).css({top:20,right:20,position:"fixed",width:"310px",height:"auto",margin:0,padding:0,listStyleType:"none",zIndex:1e7}),window.innerWidth<600&&a(this).css({right:5})}},parent:{object:"<li />",selector:"li",css:{}},css:{display:"none",width:"310px"},addClass:""}}(jQuery),function(a){a.noty.themes.defaultTheme={name:"defaultTheme",helpers:{borderFix:function(){if(this.options.dismissQueue){var b=this.options.layout.container.selector+" "+this.options.layout.parent.selector;switch(this.options.layout.name){case"top":a(b).css({borderRadius:"0px 0px 0px 0px"}),a(b).last().css({borderRadius:"0px 0px 5px 5px"});break;case"topCenter":case"topLeft":case"topRight":case"bottomCenter":case"bottomLeft":case"bottomRight":case"center":case"centerLeft":case"centerRight":case"inline":a(b).css({borderRadius:"0px 0px 0px 0px"}),a(b).first().css({"border-top-left-radius":"5px","border-top-right-radius":"5px"}),a(b).last().css({"border-bottom-left-radius":"5px","border-bottom-right-radius":"5px"});break;case"bottom":a(b).css({borderRadius:"0px 0px 0px 0px"}),a(b).first().css({borderRadius:"5px 5px 0px 0px"})}}}},modal:{css:{position:"fixed",width:"100%",height:"100%",backgroundColor:"#000",zIndex:1e4,opacity:.6,display:"none",left:0,top:0}},style:function(){switch(this.$bar.css({overflow:"hidden",background:"url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAoCAYAAAAPOoFWAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAPZJREFUeNq81tsOgjAMANB2ov7/7ypaN7IlIwi9rGuT8QSc9EIDAsAznxvY4pXPKr05RUE5MEVB+TyWfCEl9LZApYopCmo9C4FKSMtYoI8Bwv79aQJU4l6hXXCZrQbokJEksxHo9KMOgc6w1atHXM8K9DVC7FQnJ0i8iK3QooGgbnyKgMDygBWyYFZoqx4qS27KqLZJjA1D0jK6QJcYEQEiWv9PGkTsbqxQ8oT+ZtZB6AkdsJnQDnMoHXHLGKOgDYuCWmYhEERCI5gaamW0bnHdA3k2ltlIN+2qKRyCND0bhqSYCyTB3CAOc4WusBEIpkeBuPgJMAAX8Hs1NfqHRgAAAABJRU5ErkJggg==') repeat-x scroll left top #fff"}),this.$message.css({fontSize:"13px",lineHeight:"16px",textAlign:"center",padding:"8px 10px 9px",width:"auto",position:"relative"}),this.$closeButton.css({position:"absolute",top:4,right:4,width:10,height:10,background:"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAKT2lDQ1BQaG90b3Nob3AgSUNDIHByb2ZpbGUAAHjanVNnVFPpFj333vRCS4iAlEtvUhUIIFJCi4AUkSYqIQkQSoghodkVUcERRUUEG8igiAOOjoCMFVEsDIoK2AfkIaKOg6OIisr74Xuja9a89+bN/rXXPues852zzwfACAyWSDNRNYAMqUIeEeCDx8TG4eQuQIEKJHAAEAizZCFz/SMBAPh+PDwrIsAHvgABeNMLCADATZvAMByH/w/qQplcAYCEAcB0kThLCIAUAEB6jkKmAEBGAYCdmCZTAKAEAGDLY2LjAFAtAGAnf+bTAICd+Jl7AQBblCEVAaCRACATZYhEAGg7AKzPVopFAFgwABRmS8Q5ANgtADBJV2ZIALC3AMDOEAuyAAgMADBRiIUpAAR7AGDIIyN4AISZABRG8lc88SuuEOcqAAB4mbI8uSQ5RYFbCC1xB1dXLh4ozkkXKxQ2YQJhmkAuwnmZGTKBNA/g88wAAKCRFRHgg/P9eM4Ors7ONo62Dl8t6r8G/yJiYuP+5c+rcEAAAOF0ftH+LC+zGoA7BoBt/qIl7gRoXgugdfeLZrIPQLUAoOnaV/Nw+H48PEWhkLnZ2eXk5NhKxEJbYcpXff5nwl/AV/1s+X48/Pf14L7iJIEyXYFHBPjgwsz0TKUcz5IJhGLc5o9H/LcL//wd0yLESWK5WCoU41EScY5EmozzMqUiiUKSKcUl0v9k4t8s+wM+3zUAsGo+AXuRLahdYwP2SycQWHTA4vcAAPK7b8HUKAgDgGiD4c93/+8//UegJQCAZkmScQAAXkQkLlTKsz/HCAAARKCBKrBBG/TBGCzABhzBBdzBC/xgNoRCJMTCQhBCCmSAHHJgKayCQiiGzbAdKmAv1EAdNMBRaIaTcA4uwlW4Dj1wD/phCJ7BKLyBCQRByAgTYSHaiAFiilgjjggXmYX4IcFIBBKLJCDJiBRRIkuRNUgxUopUIFVIHfI9cgI5h1xGupE7yAAygvyGvEcxlIGyUT3UDLVDuag3GoRGogvQZHQxmo8WoJvQcrQaPYw2oefQq2gP2o8+Q8cwwOgYBzPEbDAuxsNCsTgsCZNjy7EirAyrxhqwVqwDu4n1Y8+xdwQSgUXACTYEd0IgYR5BSFhMWE7YSKggHCQ0EdoJNwkDhFHCJyKTqEu0JroR+cQYYjIxh1hILCPWEo8TLxB7iEPENyQSiUMyJ7mQAkmxpFTSEtJG0m5SI+ksqZs0SBojk8naZGuyBzmULCAryIXkneTD5DPkG+Qh8lsKnWJAcaT4U+IoUspqShnlEOU05QZlmDJBVaOaUt2ooVQRNY9aQq2htlKvUYeoEzR1mjnNgxZJS6WtopXTGmgXaPdpr+h0uhHdlR5Ol9BX0svpR+iX6AP0dwwNhhWDx4hnKBmbGAcYZxl3GK+YTKYZ04sZx1QwNzHrmOeZD5lvVVgqtip8FZHKCpVKlSaVGyovVKmqpqreqgtV81XLVI+pXlN9rkZVM1PjqQnUlqtVqp1Q61MbU2epO6iHqmeob1Q/pH5Z/YkGWcNMw09DpFGgsV/jvMYgC2MZs3gsIWsNq4Z1gTXEJrHN2Xx2KruY/R27iz2qqaE5QzNKM1ezUvOUZj8H45hx+Jx0TgnnKKeX836K3hTvKeIpG6Y0TLkxZVxrqpaXllirSKtRq0frvTau7aedpr1Fu1n7gQ5Bx0onXCdHZ4/OBZ3nU9lT3acKpxZNPTr1ri6qa6UbobtEd79up+6Ynr5egJ5Mb6feeb3n+hx9L/1U/W36p/VHDFgGswwkBtsMzhg8xTVxbzwdL8fb8VFDXcNAQ6VhlWGX4YSRudE8o9VGjUYPjGnGXOMk423GbcajJgYmISZLTepN7ppSTbmmKaY7TDtMx83MzaLN1pk1mz0x1zLnm+eb15vft2BaeFostqi2uGVJsuRaplnutrxuhVo5WaVYVVpds0atna0l1rutu6cRp7lOk06rntZnw7Dxtsm2qbcZsOXYBtuutm22fWFnYhdnt8Wuw+6TvZN9un2N/T0HDYfZDqsdWh1+c7RyFDpWOt6azpzuP33F9JbpL2dYzxDP2DPjthPLKcRpnVOb00dnF2e5c4PziIuJS4LLLpc+Lpsbxt3IveRKdPVxXeF60vWdm7Obwu2o26/uNu5p7ofcn8w0nymeWTNz0MPIQ+BR5dE/C5+VMGvfrH5PQ0+BZ7XnIy9jL5FXrdewt6V3qvdh7xc+9j5yn+M+4zw33jLeWV/MN8C3yLfLT8Nvnl+F30N/I/9k/3r/0QCngCUBZwOJgUGBWwL7+Hp8Ib+OPzrbZfay2e1BjKC5QRVBj4KtguXBrSFoyOyQrSH355jOkc5pDoVQfujW0Adh5mGLw34MJ4WHhVeGP45wiFga0TGXNXfR3ENz30T6RJZE3ptnMU85ry1KNSo+qi5qPNo3ujS6P8YuZlnM1VidWElsSxw5LiquNm5svt/87fOH4p3iC+N7F5gvyF1weaHOwvSFpxapLhIsOpZATIhOOJTwQRAqqBaMJfITdyWOCnnCHcJnIi/RNtGI2ENcKh5O8kgqTXqS7JG8NXkkxTOlLOW5hCepkLxMDUzdmzqeFpp2IG0yPTq9MYOSkZBxQqohTZO2Z+pn5mZ2y6xlhbL+xW6Lty8elQfJa7OQrAVZLQq2QqboVFoo1yoHsmdlV2a/zYnKOZarnivN7cyzytuQN5zvn//tEsIS4ZK2pYZLVy0dWOa9rGo5sjxxedsK4xUFK4ZWBqw8uIq2Km3VT6vtV5eufr0mek1rgV7ByoLBtQFr6wtVCuWFfevc1+1dT1gvWd+1YfqGnRs+FYmKrhTbF5cVf9go3HjlG4dvyr+Z3JS0qavEuWTPZtJm6ebeLZ5bDpaql+aXDm4N2dq0Dd9WtO319kXbL5fNKNu7g7ZDuaO/PLi8ZafJzs07P1SkVPRU+lQ27tLdtWHX+G7R7ht7vPY07NXbW7z3/T7JvttVAVVN1WbVZftJ+7P3P66Jqun4lvttXa1ObXHtxwPSA/0HIw6217nU1R3SPVRSj9Yr60cOxx++/p3vdy0NNg1VjZzG4iNwRHnk6fcJ3/ceDTradox7rOEH0x92HWcdL2pCmvKaRptTmvtbYlu6T8w+0dbq3nr8R9sfD5w0PFl5SvNUyWna6YLTk2fyz4ydlZ19fi753GDborZ752PO32oPb++6EHTh0kX/i+c7vDvOXPK4dPKy2+UTV7hXmq86X23qdOo8/pPTT8e7nLuarrlca7nuer21e2b36RueN87d9L158Rb/1tWeOT3dvfN6b/fF9/XfFt1+cif9zsu72Xcn7q28T7xf9EDtQdlD3YfVP1v+3Njv3H9qwHeg89HcR/cGhYPP/pH1jw9DBY+Zj8uGDYbrnjg+OTniP3L96fynQ89kzyaeF/6i/suuFxYvfvjV69fO0ZjRoZfyl5O/bXyl/erA6xmv28bCxh6+yXgzMV70VvvtwXfcdx3vo98PT+R8IH8o/2j5sfVT0Kf7kxmTk/8EA5jz/GMzLdsAAAAgY0hSTQAAeiUAAICDAAD5/wAAgOkAAHUwAADqYAAAOpgAABdvkl/FRgAAATpJREFUeNoszrFqVFEUheG19zlz7sQ7ijMQBAvfYBqbpJCoZSAQbOwEE1IHGytbLQUJ8SUktW8gCCFJMSGSNxCmFBJO7j5rpXD6n5/P5vM53H3b3T9LOiB5AQDuDjM7BnA7DMPHDGBH0nuSzwHsRcRVRNRSysuU0i6AOwA/02w2+9Fae00SEbEh6SGAR5K+k3zWWptKepCm0+kpyRoRGyRBcpPkDsn1iEBr7drdP2VJZyQXERGSPpiZAViTBACXKaV9kqd5uVzCzO5KKb/d/UZSDwD/eyxqree1VqSu6zKAF2Z2RPJJaw0rAkjOJT0m+SuT/AbgDcmnkmBmfwAsJL1dXQ8lWY6IGwB1ZbrOOb8zs8thGP4COFwx/mE8Ho9Go9ErMzvJOW/1fY/JZIJSypqZfXX3L13X9fcDAKJct1sx3OiuAAAAAElFTkSuQmCC)",display:"none",cursor:"pointer"}),this.$buttons.css({padding:5,textAlign:"right",borderTop:"1px solid #ccc",backgroundColor:"#fff"}),this.$buttons.find("button").css({marginLeft:5}),this.$buttons.find("button:first").css({marginLeft:0}),this.$bar.bind({mouseenter:function(){a(this).find(".noty_close").stop().fadeTo("normal",1)},mouseleave:function(){a(this).find(".noty_close").stop().fadeTo("normal",0)}}),this.options.layout.name){case"top":this.$bar.css({borderRadius:"0px 0px 5px 5px",borderBottom:"2px solid #eee",borderLeft:"2px solid #eee",borderRight:"2px solid #eee",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.1)"});break;case"topCenter":case"center":case"bottomCenter":case"inline":this.$bar.css({borderRadius:"5px",border:"1px solid #eee",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.1)"}),this.$message.css({fontSize:"13px",textAlign:"center"});break;case"topLeft":case"topRight":case"bottomLeft":case"bottomRight":case"centerLeft":case"centerRight":this.$bar.css({borderRadius:"5px",border:"1px solid #eee",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.1)"}),this.$message.css({fontSize:"13px",textAlign:"left"});break;case"bottom":this.$bar.css({borderRadius:"5px 5px 0px 0px",borderTop:"2px solid #eee",borderLeft:"2px solid #eee",borderRight:"2px solid #eee",boxShadow:"0 -2px 4px rgba(0, 0, 0, 0.1)"});break;default:this.$bar.css({border:"2px solid #eee",boxShadow:"0 2px 4px rgba(0, 0, 0, 0.1)"})}switch(this.options.type){case"alert":case"notification":this.$bar.css({backgroundColor:"#FFF",borderColor:"#CCC",color:"#444"});break;case"warning":this.$bar.css({backgroundColor:"#FFEAA8",borderColor:"#FFC237",color:"#826200"}),this.$buttons.css({borderTop:"1px solid #FFC237"});break;case"error":this.$bar.css({backgroundColor:"red",borderColor:"darkred",color:"#FFF"}),this.$message.css({fontWeight:"bold"}),this.$buttons.css({borderTop:"1px solid darkred"});break;case"information":this.$bar.css({backgroundColor:"#57B7E2",borderColor:"#0B90C4",color:"#FFF"}),this.$buttons.css({borderTop:"1px solid #0B90C4"});break;case"success":this.$bar.css({backgroundColor:"lightgreen",borderColor:"#50C24E",color:"darkgreen"}),this.$buttons.css({borderTop:"1px solid #50C24E"});break;default:this.$bar.css({backgroundColor:"#FFF",borderColor:"#CCC",color:"#444"})}},callback:{onShow:function(){a.noty.themes.defaultTheme.helpers.borderFix.apply(this)},onClose:function(){a.noty.themes.defaultTheme.helpers.borderFix.apply(this)}}}}(jQuery);
/* jQuery elevateZoom 3.0.8 - Demo's and documentation: - www.elevateweb.co.uk/image-zoom - Copyright (c) 2013 Andrew Eades - www.elevateweb.co.uk - Dual licensed under the LGPL licenses. - http://en.wikipedia.org/wiki/MIT_License - http://en.wikipedia.org/wiki/GNU_General_Public_License */
"function"!==typeof Object.create&&(Object.create=function(d){function h(){}h.prototype=d;return new h});
(function(d,h,l,m){var k={init:function(b,a){var c=this;c.elem=a;c.$elem=d(a);c.imageSrc=c.$elem.data("zoom-image")?c.$elem.data("zoom-image"):c.$elem.attr("src");c.options=d.extend({},d.fn.elevateZoom.options,b);c.options.tint&&(c.options.lensColour="none",c.options.lensOpacity="1");"inner"==c.options.zoomType&&(c.options.showLens=!1);c.$elem.parent().removeAttr("title").removeAttr("alt");c.zoomImage=c.imageSrc;c.refresh(1);d("#"+c.options.gallery+" a").click(function(a){c.options.galleryActiveClass&&
(d("#"+c.options.gallery+" a").removeClass(c.options.galleryActiveClass),d(this).addClass(c.options.galleryActiveClass));a.preventDefault();d(this).data("zoom-image")?c.zoomImagePre=d(this).data("zoom-image"):c.zoomImagePre=d(this).data("image");c.swaptheimage(d(this).data("image"),c.zoomImagePre);return!1})},refresh:function(b){var a=this;setTimeout(function(){a.fetch(a.imageSrc)},b||a.options.refresh)},fetch:function(b){var a=this,c=new Image;c.onload=function(){a.largeWidth=c.width;a.largeHeight=
c.height;a.startZoom();a.currentImage=a.imageSrc;a.options.onZoomedImageLoaded(a.$elem)};c.src=b},startZoom:function(){var b=this;b.nzWidth=b.$elem.width();b.nzHeight=b.$elem.height();b.isWindowActive=!1;b.isLensActive=!1;b.isTintActive=!1;b.overWindow=!1;b.options.imageCrossfade&&(b.zoomWrap=b.$elem.wrap('<div style="height:'+b.nzHeight+"px;width:"+b.nzWidth+'px;" class="zoomWrapper" />'),b.$elem.css("position","absolute"));b.zoomLock=1;b.scrollingLock=!1;b.changeBgSize=!1;b.currentZoomLevel=b.options.zoomLevel;
b.nzOffset=b.$elem.offset();b.widthRatio=b.largeWidth/b.currentZoomLevel/b.nzWidth;b.heightRatio=b.largeHeight/b.currentZoomLevel/b.nzHeight;"window"==b.options.zoomType&&(b.zoomWindowStyle="overflow: hidden;background-position: 0px 0px;text-align:center;background-color: "+String(b.options.zoomWindowBgColour)+";width: "+String(b.options.zoomWindowWidth)+"px;height: "+String(b.options.zoomWindowHeight)+"px;float: left;background-size: "+b.largeWidth/b.currentZoomLevel+"px "+b.largeHeight/b.currentZoomLevel+
"px;display: none;z-index:100;border: "+String(b.options.borderSize)+"px solid "+b.options.borderColour+";background-repeat: no-repeat;position: absolute;");if("inner"==b.options.zoomType){var a=b.$elem.css("border-left-width");b.zoomWindowStyle="overflow: hidden;margin-left: "+String(a)+";margin-top: "+String(a)+";background-position: 0px 0px;width: "+String(b.nzWidth)+"px;height: "+String(b.nzHeight)+"px;float: left;display: none;cursor:"+b.options.cursor+";px solid "+b.options.borderColour+";background-repeat: no-repeat;position: absolute;"}"window"==
b.options.zoomType&&(lensHeight=b.nzHeight<b.options.zoomWindowWidth/b.widthRatio?b.nzHeight:String(b.options.zoomWindowHeight/b.heightRatio),lensWidth=b.largeWidth<b.options.zoomWindowWidth?b.nzWidth:b.options.zoomWindowWidth/b.widthRatio,b.lensStyle="background-position: 0px 0px;width: "+String(b.options.zoomWindowWidth/b.widthRatio)+"px;height: "+String(b.options.zoomWindowHeight/b.heightRatio)+"px;float: right;display: none;overflow: hidden;z-index: 999;-webkit-transform: translateZ(0);opacity:"+
b.options.lensOpacity+";filter: alpha(opacity = "+100*b.options.lensOpacity+"); zoom:1;width:"+lensWidth+"px;height:"+lensHeight+"px;background-color:"+b.options.lensColour+";cursor:"+b.options.cursor+";border: "+b.options.lensBorderSize+"px solid "+b.options.lensBorderColour+";background-repeat: no-repeat;position: absolute;");b.tintStyle="display: block;position: absolute;background-color: "+b.options.tintColour+";filter:alpha(opacity=0);opacity: 0;width: "+b.nzWidth+"px;height: "+b.nzHeight+"px;";
b.lensRound="";"lens"==b.options.zoomType&&(b.lensStyle="background-position: 0px 0px;float: left;display: none;border: "+String(b.options.borderSize)+"px solid "+b.options.borderColour+";width:"+String(b.options.lensSize)+"px;height:"+String(b.options.lensSize)+"px;background-repeat: no-repeat;position: absolute;");"round"==b.options.lensShape&&(b.lensRound="border-top-left-radius: "+String(b.options.lensSize/2+b.options.borderSize)+"px;border-top-right-radius: "+String(b.options.lensSize/2+b.options.borderSize)+
"px;border-bottom-left-radius: "+String(b.options.lensSize/2+b.options.borderSize)+"px;border-bottom-right-radius: "+String(b.options.lensSize/2+b.options.borderSize)+"px;");b.zoomContainer=d('<div class="zoomContainer" style="-webkit-transform: translateZ(0);position:absolute;left:'+b.nzOffset.left+"px;top:"+b.nzOffset.top+"px;height:"+b.nzHeight+"px;width:"+b.nzWidth+'px;"></div>');d("body").append(b.zoomContainer);b.options.containLensZoom&&"lens"==b.options.zoomType&&b.zoomContainer.css("overflow",
"hidden");"inner"!=b.options.zoomType&&(b.zoomLens=d("<div class='zoomLens' style='"+b.lensStyle+b.lensRound+"'>&nbsp;</div>").appendTo(b.zoomContainer).click(function(){b.$elem.trigger("click")}),b.options.tint&&(b.tintContainer=d("<div/>").addClass("tintContainer"),b.zoomTint=d("<div class='zoomTint' style='"+b.tintStyle+"'></div>"),b.zoomLens.wrap(b.tintContainer),b.zoomTintcss=b.zoomLens.after(b.zoomTint),b.zoomTintImage=d('<img style="position: absolute; left: 0px; top: 0px; max-width: none; width: '+
b.nzWidth+"px; height: "+b.nzHeight+'px;" src="'+b.imageSrc+'">').appendTo(b.zoomLens).click(function(){b.$elem.trigger("click")})));isNaN(b.options.zoomWindowPosition)?b.zoomWindow=d("<div style='z-index:999;left:"+b.windowOffsetLeft+"px;top:"+b.windowOffsetTop+"px;"+b.zoomWindowStyle+"' class='zoomWindow'>&nbsp;</div>").appendTo("body").click(function(){b.$elem.trigger("click")}):b.zoomWindow=d("<div style='z-index:999;left:"+b.windowOffsetLeft+"px;top:"+b.windowOffsetTop+"px;"+b.zoomWindowStyle+
"' class='zoomWindow'>&nbsp;</div>").appendTo(b.zoomContainer).click(function(){b.$elem.trigger("click")});b.zoomWindowContainer=d("<div/>").addClass("zoomWindowContainer").css("width",b.options.zoomWindowWidth);b.zoomWindow.wrap(b.zoomWindowContainer);"lens"==b.options.zoomType&&b.zoomLens.css({backgroundImage:"url('"+b.imageSrc+"')"});"window"==b.options.zoomType&&b.zoomWindow.css({backgroundImage:"url('"+b.imageSrc+"')"});"inner"==b.options.zoomType&&b.zoomWindow.css({backgroundImage:"url('"+b.imageSrc+
"')"});b.$elem.bind("touchmove",function(a){a.preventDefault();b.setPosition(a.originalEvent.touches[0]||a.originalEvent.changedTouches[0])});b.zoomContainer.bind("touchmove",function(a){"inner"==b.options.zoomType&&b.showHideWindow("show");a.preventDefault();b.setPosition(a.originalEvent.touches[0]||a.originalEvent.changedTouches[0])});b.zoomContainer.bind("touchend",function(a){b.showHideWindow("hide");b.options.showLens&&b.showHideLens("hide");b.options.tint&&"inner"!=b.options.zoomType&&b.showHideTint("hide")});
b.$elem.bind("touchend",function(a){b.showHideWindow("hide");b.options.showLens&&b.showHideLens("hide");b.options.tint&&"inner"!=b.options.zoomType&&b.showHideTint("hide")});b.options.showLens&&(b.zoomLens.bind("touchmove",function(a){a.preventDefault();b.setPosition(a.originalEvent.touches[0]||a.originalEvent.changedTouches[0])}),b.zoomLens.bind("touchend",function(a){b.showHideWindow("hide");b.options.showLens&&b.showHideLens("hide");b.options.tint&&"inner"!=b.options.zoomType&&b.showHideTint("hide")}));
b.$elem.bind("mousemove",function(a){!1==b.overWindow&&b.setElements("show");if(b.lastX!==a.clientX||b.lastY!==a.clientY)b.setPosition(a),b.currentLoc=a;b.lastX=a.clientX;b.lastY=a.clientY});b.zoomContainer.bind("mousemove",function(a){!1==b.overWindow&&b.setElements("show");if(b.lastX!==a.clientX||b.lastY!==a.clientY)b.setPosition(a),b.currentLoc=a;b.lastX=a.clientX;b.lastY=a.clientY});"inner"!=b.options.zoomType&&b.zoomLens.bind("mousemove",function(a){if(b.lastX!==a.clientX||b.lastY!==a.clientY)b.setPosition(a),
b.currentLoc=a;b.lastX=a.clientX;b.lastY=a.clientY});b.options.tint&&"inner"!=b.options.zoomType&&b.zoomTint.bind("mousemove",function(a){if(b.lastX!==a.clientX||b.lastY!==a.clientY)b.setPosition(a),b.currentLoc=a;b.lastX=a.clientX;b.lastY=a.clientY});"inner"==b.options.zoomType&&b.zoomWindow.bind("mousemove",function(a){if(b.lastX!==a.clientX||b.lastY!==a.clientY)b.setPosition(a),b.currentLoc=a;b.lastX=a.clientX;b.lastY=a.clientY});b.zoomContainer.add(b.$elem).mouseenter(function(){!1==b.overWindow&&
b.setElements("show")}).mouseleave(function(){b.scrollLock||b.setElements("hide")});"inner"!=b.options.zoomType&&b.zoomWindow.mouseenter(function(){b.overWindow=!0;b.setElements("hide")}).mouseleave(function(){b.overWindow=!1});b.minZoomLevel=b.options.minZoomLevel?b.options.minZoomLevel:2*b.options.scrollZoomIncrement;b.options.scrollZoom&&b.zoomContainer.add(b.$elem).bind("mousewheel DOMMouseScroll MozMousePixelScroll",function(a){b.scrollLock=!0;clearTimeout(d.data(this,"timer"));d.data(this,"timer",
setTimeout(function(){b.scrollLock=!1},250));var e=a.originalEvent.wheelDelta||-1*a.originalEvent.detail;a.stopImmediatePropagation();a.stopPropagation();a.preventDefault();0<e/120?b.currentZoomLevel>=b.minZoomLevel&&b.changeZoomLevel(b.currentZoomLevel-b.options.scrollZoomIncrement):b.options.maxZoomLevel?b.currentZoomLevel<=b.options.maxZoomLevel&&b.changeZoomLevel(parseFloat(b.currentZoomLevel)+b.options.scrollZoomIncrement):b.changeZoomLevel(parseFloat(b.currentZoomLevel)+b.options.scrollZoomIncrement);
return!1})},setElements:function(b){if(!this.options.zoomEnabled)return!1;"show"==b&&this.isWindowSet&&("inner"==this.options.zoomType&&this.showHideWindow("show"),"window"==this.options.zoomType&&this.showHideWindow("show"),this.options.showLens&&this.showHideLens("show"),this.options.tint&&"inner"!=this.options.zoomType&&this.showHideTint("show"));"hide"==b&&("window"==this.options.zoomType&&this.showHideWindow("hide"),this.options.tint||this.showHideWindow("hide"),this.options.showLens&&this.showHideLens("hide"),
this.options.tint&&this.showHideTint("hide"))},setPosition:function(b){if(!this.options.zoomEnabled)return!1;this.nzHeight=this.$elem.height();this.nzWidth=this.$elem.width();this.nzOffset=this.$elem.offset();this.options.tint&&"inner"!=this.options.zoomType&&(this.zoomTint.css({top:0}),this.zoomTint.css({left:0}));this.options.responsive&&!this.options.scrollZoom&&this.options.showLens&&(lensHeight=this.nzHeight<this.options.zoomWindowWidth/this.widthRatio?this.nzHeight:String(this.options.zoomWindowHeight/
this.heightRatio),lensWidth=this.largeWidth<this.options.zoomWindowWidth?this.nzWidth:this.options.zoomWindowWidth/this.widthRatio,this.widthRatio=this.largeWidth/this.nzWidth,this.heightRatio=this.largeHeight/this.nzHeight,"lens"!=this.options.zoomType&&(lensHeight=this.nzHeight<this.options.zoomWindowWidth/this.widthRatio?this.nzHeight:String(this.options.zoomWindowHeight/this.heightRatio),lensWidth=this.options.zoomWindowWidth<this.options.zoomWindowWidth?this.nzWidth:this.options.zoomWindowWidth/
this.widthRatio,this.zoomLens.css("width",lensWidth),this.zoomLens.css("height",lensHeight),this.options.tint&&(this.zoomTintImage.css("width",this.nzWidth),this.zoomTintImage.css("height",this.nzHeight))),"lens"==this.options.zoomType&&this.zoomLens.css({width:String(this.options.lensSize)+"px",height:String(this.options.lensSize)+"px"}));this.zoomContainer.css({top:this.nzOffset.top});this.zoomContainer.css({left:this.nzOffset.left});this.mouseLeft=parseInt(b.pageX-this.nzOffset.left);this.mouseTop=
parseInt(b.pageY-this.nzOffset.top);"window"==this.options.zoomType&&(this.Etoppos=this.mouseTop<this.zoomLens.height()/2,this.Eboppos=this.mouseTop>this.nzHeight-this.zoomLens.height()/2-2*this.options.lensBorderSize,this.Eloppos=this.mouseLeft<0+this.zoomLens.width()/2,this.Eroppos=this.mouseLeft>this.nzWidth-this.zoomLens.width()/2-2*this.options.lensBorderSize);"inner"==this.options.zoomType&&(this.Etoppos=this.mouseTop<this.nzHeight/2/this.heightRatio,this.Eboppos=this.mouseTop>this.nzHeight-
this.nzHeight/2/this.heightRatio,this.Eloppos=this.mouseLeft<0+this.nzWidth/2/this.widthRatio,this.Eroppos=this.mouseLeft>this.nzWidth-this.nzWidth/2/this.widthRatio-2*this.options.lensBorderSize);0>=this.mouseLeft||0>this.mouseTop||this.mouseLeft>this.nzWidth||this.mouseTop>this.nzHeight?this.setElements("hide"):(this.options.showLens&&(this.lensLeftPos=String(this.mouseLeft-this.zoomLens.width()/2),this.lensTopPos=String(this.mouseTop-this.zoomLens.height()/2)),this.Etoppos&&(this.lensTopPos=0),
this.Eloppos&&(this.tintpos=this.lensLeftPos=this.windowLeftPos=0),"window"==this.options.zoomType&&(this.Eboppos&&(this.lensTopPos=Math.max(this.nzHeight-this.zoomLens.height()-2*this.options.lensBorderSize,0)),this.Eroppos&&(this.lensLeftPos=this.nzWidth-this.zoomLens.width()-2*this.options.lensBorderSize)),"inner"==this.options.zoomType&&(this.Eboppos&&(this.lensTopPos=Math.max(this.nzHeight-2*this.options.lensBorderSize,0)),this.Eroppos&&(this.lensLeftPos=this.nzWidth-this.nzWidth-2*this.options.lensBorderSize)),
"lens"==this.options.zoomType&&(this.windowLeftPos=String(-1*((b.pageX-this.nzOffset.left)*this.widthRatio-this.zoomLens.width()/2)),this.windowTopPos=String(-1*((b.pageY-this.nzOffset.top)*this.heightRatio-this.zoomLens.height()/2)),this.zoomLens.css({backgroundPosition:this.windowLeftPos+"px "+this.windowTopPos+"px"}),this.changeBgSize&&(this.nzHeight>this.nzWidth?("lens"==this.options.zoomType&&this.zoomLens.css({"background-size":this.largeWidth/this.newvalueheight+"px "+this.largeHeight/this.newvalueheight+
"px"}),this.zoomWindow.css({"background-size":this.largeWidth/this.newvalueheight+"px "+this.largeHeight/this.newvalueheight+"px"})):("lens"==this.options.zoomType&&this.zoomLens.css({"background-size":this.largeWidth/this.newvaluewidth+"px "+this.largeHeight/this.newvaluewidth+"px"}),this.zoomWindow.css({"background-size":this.largeWidth/this.newvaluewidth+"px "+this.largeHeight/this.newvaluewidth+"px"})),this.changeBgSize=!1),this.setWindowPostition(b)),this.options.tint&&"inner"!=this.options.zoomType&&
this.setTintPosition(b),"window"==this.options.zoomType&&this.setWindowPostition(b),"inner"==this.options.zoomType&&this.setWindowPostition(b),this.options.showLens&&(this.fullwidth&&"lens"!=this.options.zoomType&&(this.lensLeftPos=0),this.zoomLens.css({left:this.lensLeftPos+"px",top:this.lensTopPos+"px"})))},showHideWindow:function(b){"show"!=b||this.isWindowActive||(this.options.zoomWindowFadeIn?this.zoomWindow.stop(!0,!0,!1).fadeIn(this.options.zoomWindowFadeIn):this.zoomWindow.show(),this.isWindowActive=
!0);"hide"==b&&this.isWindowActive&&(this.options.zoomWindowFadeOut?this.zoomWindow.stop(!0,!0).fadeOut(this.options.zoomWindowFadeOut):this.zoomWindow.hide(),this.isWindowActive=!1)},showHideLens:function(b){"show"!=b||this.isLensActive||(this.options.lensFadeIn?this.zoomLens.stop(!0,!0,!1).fadeIn(this.options.lensFadeIn):this.zoomLens.show(),this.isLensActive=!0);"hide"==b&&this.isLensActive&&(this.options.lensFadeOut?this.zoomLens.stop(!0,!0).fadeOut(this.options.lensFadeOut):this.zoomLens.hide(),
this.isLensActive=!1)},showHideTint:function(b){"show"!=b||this.isTintActive||(this.options.zoomTintFadeIn?this.zoomTint.css({opacity:this.options.tintOpacity}).animate().stop(!0,!0).fadeIn("slow"):(this.zoomTint.css({opacity:this.options.tintOpacity}).animate(),this.zoomTint.show()),this.isTintActive=!0);"hide"==b&&this.isTintActive&&(this.options.zoomTintFadeOut?this.zoomTint.stop(!0,!0).fadeOut(this.options.zoomTintFadeOut):this.zoomTint.hide(),this.isTintActive=!1)},setLensPostition:function(b){},
setWindowPostition:function(b){var a=this;if(isNaN(a.options.zoomWindowPosition))a.externalContainer=d("#"+a.options.zoomWindowPosition),a.externalContainerWidth=a.externalContainer.width(),a.externalContainerHeight=a.externalContainer.height(),a.externalContainerOffset=a.externalContainer.offset(),a.windowOffsetTop=a.externalContainerOffset.top,a.windowOffsetLeft=a.externalContainerOffset.left;else switch(a.options.zoomWindowPosition){case 1:a.windowOffsetTop=a.options.zoomWindowOffety;a.windowOffsetLeft=
+a.nzWidth;break;case 2:a.options.zoomWindowHeight>a.nzHeight&&(a.windowOffsetTop=-1*(a.options.zoomWindowHeight/2-a.nzHeight/2),a.windowOffsetLeft=a.nzWidth);break;case 3:a.windowOffsetTop=a.nzHeight-a.zoomWindow.height()-2*a.options.borderSize;a.windowOffsetLeft=a.nzWidth;break;case 4:a.windowOffsetTop=a.nzHeight;a.windowOffsetLeft=a.nzWidth;break;case 5:a.windowOffsetTop=a.nzHeight;a.windowOffsetLeft=a.nzWidth-a.zoomWindow.width()-2*a.options.borderSize;break;case 6:a.options.zoomWindowHeight>
a.nzHeight&&(a.windowOffsetTop=a.nzHeight,a.windowOffsetLeft=-1*(a.options.zoomWindowWidth/2-a.nzWidth/2+2*a.options.borderSize));break;case 7:a.windowOffsetTop=a.nzHeight;a.windowOffsetLeft=0;break;case 8:a.windowOffsetTop=a.nzHeight;a.windowOffsetLeft=-1*(a.zoomWindow.width()+2*a.options.borderSize);break;case 9:a.windowOffsetTop=a.nzHeight-a.zoomWindow.height()-2*a.options.borderSize;a.windowOffsetLeft=-1*(a.zoomWindow.width()+2*a.options.borderSize);break;case 10:a.options.zoomWindowHeight>a.nzHeight&&
(a.windowOffsetTop=-1*(a.options.zoomWindowHeight/2-a.nzHeight/2),a.windowOffsetLeft=-1*(a.zoomWindow.width()+2*a.options.borderSize));break;case 11:a.windowOffsetTop=a.options.zoomWindowOffety;a.windowOffsetLeft=-1*(a.zoomWindow.width()+2*a.options.borderSize);break;case 12:a.windowOffsetTop=-1*(a.zoomWindow.height()+2*a.options.borderSize);a.windowOffsetLeft=-1*(a.zoomWindow.width()+2*a.options.borderSize);break;case 13:a.windowOffsetTop=-1*(a.zoomWindow.height()+2*a.options.borderSize);a.windowOffsetLeft=
0;break;case 14:a.options.zoomWindowHeight>a.nzHeight&&(a.windowOffsetTop=-1*(a.zoomWindow.height()+2*a.options.borderSize),a.windowOffsetLeft=-1*(a.options.zoomWindowWidth/2-a.nzWidth/2+2*a.options.borderSize));break;case 15:a.windowOffsetTop=-1*(a.zoomWindow.height()+2*a.options.borderSize);a.windowOffsetLeft=a.nzWidth-a.zoomWindow.width()-2*a.options.borderSize;break;case 16:a.windowOffsetTop=-1*(a.zoomWindow.height()+2*a.options.borderSize);a.windowOffsetLeft=a.nzWidth;break;default:a.windowOffsetTop=
a.options.zoomWindowOffety,a.windowOffsetLeft=a.nzWidth}a.isWindowSet=!0;a.windowOffsetTop+=a.options.zoomWindowOffety;a.windowOffsetLeft+=a.options.zoomWindowOffetx;a.zoomWindow.css({top:a.windowOffsetTop});a.zoomWindow.css({left:a.windowOffsetLeft});"inner"==a.options.zoomType&&(a.zoomWindow.css({top:0}),a.zoomWindow.css({left:0}));a.windowLeftPos=String(-1*((b.pageX-a.nzOffset.left)*a.widthRatio-a.zoomWindow.width()/2));a.windowTopPos=String(-1*((b.pageY-a.nzOffset.top)*a.heightRatio-a.zoomWindow.height()/
2));a.Etoppos&&(a.windowTopPos=0);a.Eloppos&&(a.windowLeftPos=0);a.Eboppos&&(a.windowTopPos=-1*(a.largeHeight/a.currentZoomLevel-a.zoomWindow.height()));a.Eroppos&&(a.windowLeftPos=-1*(a.largeWidth/a.currentZoomLevel-a.zoomWindow.width()));a.fullheight&&(a.windowTopPos=0);a.fullwidth&&(a.windowLeftPos=0);if("window"==a.options.zoomType||"inner"==a.options.zoomType)1==a.zoomLock&&(1>=a.widthRatio&&(a.windowLeftPos=0),1>=a.heightRatio&&(a.windowTopPos=0)),a.largeHeight<a.options.zoomWindowHeight&&(a.windowTopPos=
0),a.largeWidth<a.options.zoomWindowWidth&&(a.windowLeftPos=0),a.options.easing?(a.xp||(a.xp=0),a.yp||(a.yp=0),a.loop||(a.loop=setInterval(function(){a.xp+=(a.windowLeftPos-a.xp)/a.options.easingAmount;a.yp+=(a.windowTopPos-a.yp)/a.options.easingAmount;a.scrollingLock?(clearInterval(a.loop),a.xp=a.windowLeftPos,a.yp=a.windowTopPos,a.xp=-1*((b.pageX-a.nzOffset.left)*a.widthRatio-a.zoomWindow.width()/2),a.yp=-1*((b.pageY-a.nzOffset.top)*a.heightRatio-a.zoomWindow.height()/2),a.changeBgSize&&(a.nzHeight>
a.nzWidth?("lens"==a.options.zoomType&&a.zoomLens.css({"background-size":a.largeWidth/a.newvalueheight+"px "+a.largeHeight/a.newvalueheight+"px"}),a.zoomWindow.css({"background-size":a.largeWidth/a.newvalueheight+"px "+a.largeHeight/a.newvalueheight+"px"})):("lens"!=a.options.zoomType&&a.zoomLens.css({"background-size":a.largeWidth/a.newvaluewidth+"px "+a.largeHeight/a.newvalueheight+"px"}),a.zoomWindow.css({"background-size":a.largeWidth/a.newvaluewidth+"px "+a.largeHeight/a.newvaluewidth+"px"})),
a.changeBgSize=!1),a.zoomWindow.css({backgroundPosition:a.windowLeftPos+"px "+a.windowTopPos+"px"}),a.scrollingLock=!1,a.loop=!1):(a.changeBgSize&&(a.nzHeight>a.nzWidth?("lens"==a.options.zoomType&&a.zoomLens.css({"background-size":a.largeWidth/a.newvalueheight+"px "+a.largeHeight/a.newvalueheight+"px"}),a.zoomWindow.css({"background-size":a.largeWidth/a.newvalueheight+"px "+a.largeHeight/a.newvalueheight+"px"})):("lens"!=a.options.zoomType&&a.zoomLens.css({"background-size":a.largeWidth/a.newvaluewidth+
"px "+a.largeHeight/a.newvaluewidth+"px"}),a.zoomWindow.css({"background-size":a.largeWidth/a.newvaluewidth+"px "+a.largeHeight/a.newvaluewidth+"px"})),a.changeBgSize=!1),a.zoomWindow.css({backgroundPosition:a.xp+"px "+a.yp+"px"}))},16))):(a.changeBgSize&&(a.nzHeight>a.nzWidth?("lens"==a.options.zoomType&&a.zoomLens.css({"background-size":a.largeWidth/a.newvalueheight+"px "+a.largeHeight/a.newvalueheight+"px"}),a.zoomWindow.css({"background-size":a.largeWidth/a.newvalueheight+"px "+a.largeHeight/
a.newvalueheight+"px"})):("lens"==a.options.zoomType&&a.zoomLens.css({"background-size":a.largeWidth/a.newvaluewidth+"px "+a.largeHeight/a.newvaluewidth+"px"}),a.largeHeight/a.newvaluewidth<a.options.zoomWindowHeight?a.zoomWindow.css({"background-size":a.largeWidth/a.newvaluewidth+"px "+a.largeHeight/a.newvaluewidth+"px"}):a.zoomWindow.css({"background-size":a.largeWidth/a.newvalueheight+"px "+a.largeHeight/a.newvalueheight+"px"})),a.changeBgSize=!1),a.zoomWindow.css({backgroundPosition:a.windowLeftPos+
"px "+a.windowTopPos+"px"}))},setTintPosition:function(b){this.nzOffset=this.$elem.offset();this.tintpos=String(-1*(b.pageX-this.nzOffset.left-this.zoomLens.width()/2));this.tintposy=String(-1*(b.pageY-this.nzOffset.top-this.zoomLens.height()/2));this.Etoppos&&(this.tintposy=0);this.Eloppos&&(this.tintpos=0);this.Eboppos&&(this.tintposy=-1*(this.nzHeight-this.zoomLens.height()-2*this.options.lensBorderSize));this.Eroppos&&(this.tintpos=-1*(this.nzWidth-this.zoomLens.width()-2*this.options.lensBorderSize));
this.options.tint&&(this.fullheight&&(this.tintposy=0),this.fullwidth&&(this.tintpos=0),this.zoomTintImage.css({left:this.tintpos+"px"}),this.zoomTintImage.css({top:this.tintposy+"px"}))},swaptheimage:function(b,a){var c=this,e=new Image;c.options.loadingIcon&&(c.spinner=d("<div style=\"background: url('"+c.options.loadingIcon+"') no-repeat center;height:"+c.nzHeight+"px;width:"+c.nzWidth+'px;z-index: 2000;position: absolute; background-position: center center;"></div>'),c.$elem.after(c.spinner));
c.options.onImageSwap(c.$elem);e.onload=function(){c.largeWidth=e.width;c.largeHeight=e.height;c.zoomImage=a;c.zoomWindow.css({"background-size":c.largeWidth+"px "+c.largeHeight+"px"});c.zoomWindow.css({"background-size":c.largeWidth+"px "+c.largeHeight+"px"});c.swapAction(b,a)};e.src=a},swapAction:function(b,a){var c=this,e=new Image;e.onload=function(){c.nzHeight=e.height;c.nzWidth=e.width;c.options.onImageSwapComplete(c.$elem);c.doneCallback()};e.src=b;c.currentZoomLevel=c.options.zoomLevel;c.options.maxZoomLevel=
!1;"lens"==c.options.zoomType&&c.zoomLens.css({backgroundImage:"url('"+a+"')"});"window"==c.options.zoomType&&c.zoomWindow.css({backgroundImage:"url('"+a+"')"});"inner"==c.options.zoomType&&c.zoomWindow.css({backgroundImage:"url('"+a+"')"});c.currentImage=a;if(c.options.imageCrossfade){var f=c.$elem,g=f.clone();c.$elem.attr("src",b);c.$elem.after(g);g.stop(!0).fadeOut(c.options.imageCrossfade,function(){d(this).remove()});c.$elem.width("auto").removeAttr("width");c.$elem.height("auto").removeAttr("height");
f.fadeIn(c.options.imageCrossfade);c.options.tint&&"inner"!=c.options.zoomType&&(f=c.zoomTintImage,g=f.clone(),c.zoomTintImage.attr("src",a),c.zoomTintImage.after(g),g.stop(!0).fadeOut(c.options.imageCrossfade,function(){d(this).remove()}),f.fadeIn(c.options.imageCrossfade),c.zoomTint.css({height:c.$elem.height()}),c.zoomTint.css({width:c.$elem.width()}));c.zoomContainer.css("height",c.$elem.height());c.zoomContainer.css("width",c.$elem.width());"inner"!=c.options.zoomType||c.options.constrainType||
(c.zoomWrap.parent().css("height",c.$elem.height()),c.zoomWrap.parent().css("width",c.$elem.width()),c.zoomWindow.css("height",c.$elem.height()),c.zoomWindow.css("width",c.$elem.width()))}else c.$elem.attr("src",b),c.options.tint&&(c.zoomTintImage.attr("src",a),c.zoomTintImage.attr("height",c.$elem.height()),c.zoomTintImage.css({height:c.$elem.height()}),c.zoomTint.css({height:c.$elem.height()})),c.zoomContainer.css("height",c.$elem.height()),c.zoomContainer.css("width",c.$elem.width());c.options.imageCrossfade&&
(c.zoomWrap.css("height",c.$elem.height()),c.zoomWrap.css("width",c.$elem.width()));c.options.constrainType&&("height"==c.options.constrainType&&(c.zoomContainer.css("height",c.options.constrainSize),c.zoomContainer.css("width","auto"),c.options.imageCrossfade?(c.zoomWrap.css("height",c.options.constrainSize),c.zoomWrap.css("width","auto"),c.constwidth=c.zoomWrap.width()):(c.$elem.css("height",c.options.constrainSize),c.$elem.css("width","auto"),c.constwidth=c.$elem.width()),"inner"==c.options.zoomType&&
(c.zoomWrap.parent().css("height",c.options.constrainSize),c.zoomWrap.parent().css("width",c.constwidth),c.zoomWindow.css("height",c.options.constrainSize),c.zoomWindow.css("width",c.constwidth)),c.options.tint&&(c.tintContainer.css("height",c.options.constrainSize),c.tintContainer.css("width",c.constwidth),c.zoomTint.css("height",c.options.constrainSize),c.zoomTint.css("width",c.constwidth),c.zoomTintImage.css("height",c.options.constrainSize),c.zoomTintImage.css("width",c.constwidth))),"width"==
c.options.constrainType&&(c.zoomContainer.css("height","auto"),c.zoomContainer.css("width",c.options.constrainSize),c.options.imageCrossfade?(c.zoomWrap.css("height","auto"),c.zoomWrap.css("width",c.options.constrainSize),c.constheight=c.zoomWrap.height()):(c.$elem.css("height","auto"),c.$elem.css("width",c.options.constrainSize),c.constheight=c.$elem.height()),"inner"==c.options.zoomType&&(c.zoomWrap.parent().css("height",c.constheight),c.zoomWrap.parent().css("width",c.options.constrainSize),c.zoomWindow.css("height",
c.constheight),c.zoomWindow.css("width",c.options.constrainSize)),c.options.tint&&(c.tintContainer.css("height",c.constheight),c.tintContainer.css("width",c.options.constrainSize),c.zoomTint.css("height",c.constheight),c.zoomTint.css("width",c.options.constrainSize),c.zoomTintImage.css("height",c.constheight),c.zoomTintImage.css("width",c.options.constrainSize))))},doneCallback:function(){this.options.loadingIcon&&this.spinner.hide();this.nzOffset=this.$elem.offset();this.nzWidth=this.$elem.width();
this.nzHeight=this.$elem.height();this.currentZoomLevel=this.options.zoomLevel;this.widthRatio=this.largeWidth/this.nzWidth;this.heightRatio=this.largeHeight/this.nzHeight;"window"==this.options.zoomType&&(lensHeight=this.nzHeight<this.options.zoomWindowWidth/this.widthRatio?this.nzHeight:String(this.options.zoomWindowHeight/this.heightRatio),lensWidth=this.options.zoomWindowWidth<this.options.zoomWindowWidth?this.nzWidth:this.options.zoomWindowWidth/this.widthRatio,this.zoomLens&&(this.zoomLens.css("width",
lensWidth),this.zoomLens.css("height",lensHeight)))},getCurrentImage:function(){return this.zoomImage},getGalleryList:function(){var b=this;b.gallerylist=[];b.options.gallery?d("#"+b.options.gallery+" a").each(function(){var a="";d(this).data("zoom-image")?a=d(this).data("zoom-image"):d(this).data("image")&&(a=d(this).data("image"));a==b.zoomImage?b.gallerylist.unshift({href:""+a+"",title:d(this).find("img").attr("title")}):b.gallerylist.push({href:""+a+"",title:d(this).find("img").attr("title")})}):
b.gallerylist.push({href:""+b.zoomImage+"",title:d(this).find("img").attr("title")});return b.gallerylist},changeZoomLevel:function(b){this.scrollingLock=!0;this.newvalue=parseFloat(b).toFixed(2);newvalue=parseFloat(b).toFixed(2);maxheightnewvalue=this.largeHeight/(this.options.zoomWindowHeight/this.nzHeight*this.nzHeight);maxwidthtnewvalue=this.largeWidth/(this.options.zoomWindowWidth/this.nzWidth*this.nzWidth);"inner"!=this.options.zoomType&&(maxheightnewvalue<=newvalue?(this.heightRatio=this.largeHeight/
maxheightnewvalue/this.nzHeight,this.newvalueheight=maxheightnewvalue,this.fullheight=!0):(this.heightRatio=this.largeHeight/newvalue/this.nzHeight,this.newvalueheight=newvalue,this.fullheight=!1),maxwidthtnewvalue<=newvalue?(this.widthRatio=this.largeWidth/maxwidthtnewvalue/this.nzWidth,this.newvaluewidth=maxwidthtnewvalue,this.fullwidth=!0):(this.widthRatio=this.largeWidth/newvalue/this.nzWidth,this.newvaluewidth=newvalue,this.fullwidth=!1),"lens"==this.options.zoomType&&(maxheightnewvalue<=newvalue?
(this.fullwidth=!0,this.newvaluewidth=maxheightnewvalue):(this.widthRatio=this.largeWidth/newvalue/this.nzWidth,this.newvaluewidth=newvalue,this.fullwidth=!1)));"inner"==this.options.zoomType&&(maxheightnewvalue=parseFloat(this.largeHeight/this.nzHeight).toFixed(2),maxwidthtnewvalue=parseFloat(this.largeWidth/this.nzWidth).toFixed(2),newvalue>maxheightnewvalue&&(newvalue=maxheightnewvalue),newvalue>maxwidthtnewvalue&&(newvalue=maxwidthtnewvalue),maxheightnewvalue<=newvalue?(this.heightRatio=this.largeHeight/
newvalue/this.nzHeight,this.newvalueheight=newvalue>maxheightnewvalue?maxheightnewvalue:newvalue,this.fullheight=!0):(this.heightRatio=this.largeHeight/newvalue/this.nzHeight,this.newvalueheight=newvalue>maxheightnewvalue?maxheightnewvalue:newvalue,this.fullheight=!1),maxwidthtnewvalue<=newvalue?(this.widthRatio=this.largeWidth/newvalue/this.nzWidth,this.newvaluewidth=newvalue>maxwidthtnewvalue?maxwidthtnewvalue:newvalue,this.fullwidth=!0):(this.widthRatio=this.largeWidth/newvalue/this.nzWidth,this.newvaluewidth=
newvalue,this.fullwidth=!1));scrcontinue=!1;"inner"==this.options.zoomType&&(this.nzWidth>this.nzHeight&&(this.newvaluewidth<=maxwidthtnewvalue?scrcontinue=!0:(scrcontinue=!1,this.fullwidth=this.fullheight=!0)),this.nzHeight>this.nzWidth&&(this.newvaluewidth<=maxwidthtnewvalue?scrcontinue=!0:(scrcontinue=!1,this.fullwidth=this.fullheight=!0)));"inner"!=this.options.zoomType&&(scrcontinue=!0);scrcontinue&&(this.zoomLock=0,this.changeZoom=!0,this.options.zoomWindowHeight/this.heightRatio<=this.nzHeight&&
(this.currentZoomLevel=this.newvalueheight,"lens"!=this.options.zoomType&&"inner"!=this.options.zoomType&&(this.changeBgSize=!0,this.zoomLens.css({height:String(this.options.zoomWindowHeight/this.heightRatio)+"px"})),"lens"==this.options.zoomType||"inner"==this.options.zoomType)&&(this.changeBgSize=!0),this.options.zoomWindowWidth/this.widthRatio<=this.nzWidth&&("inner"!=this.options.zoomType&&this.newvaluewidth>this.newvalueheight&&(this.currentZoomLevel=this.newvaluewidth),"lens"!=this.options.zoomType&&
"inner"!=this.options.zoomType&&(this.changeBgSize=!0,this.zoomLens.css({width:String(this.options.zoomWindowWidth/this.widthRatio)+"px"})),"lens"==this.options.zoomType||"inner"==this.options.zoomType)&&(this.changeBgSize=!0),"inner"==this.options.zoomType&&(this.changeBgSize=!0,this.nzWidth>this.nzHeight&&(this.currentZoomLevel=this.newvaluewidth),this.nzHeight>this.nzWidth&&(this.currentZoomLevel=this.newvaluewidth)));this.setPosition(this.currentLoc)},closeAll:function(){self.zoomWindow&&self.zoomWindow.hide();
self.zoomLens&&self.zoomLens.hide();self.zoomTint&&self.zoomTint.hide()},changeState:function(b){"enable"==b&&(this.options.zoomEnabled=!0);"disable"==b&&(this.options.zoomEnabled=!1)}};d.fn.elevateZoom=function(b){return this.each(function(){var a=Object.create(k);a.init(b,this);d.data(this,"elevateZoom",a)})};d.fn.elevateZoom.options={zoomActivation:"hover",zoomEnabled:!0,preloading:1,zoomLevel:1,scrollZoom:!1,scrollZoomIncrement:0.1,minZoomLevel:!1,maxZoomLevel:!1,easing:!1,easingAmount:12,lensSize:200,
zoomWindowWidth:400,zoomWindowHeight:400,zoomWindowOffetx:0,zoomWindowOffety:0,zoomWindowPosition:1,zoomWindowBgColour:"#fff",lensFadeIn:!1,lensFadeOut:!1,debug:!1,zoomWindowFadeIn:!1,zoomWindowFadeOut:!1,zoomWindowAlwaysShow:!1,zoomTintFadeIn:!1,zoomTintFadeOut:!1,borderSize:4,showLens:!0,borderColour:"#888",lensBorderSize:1,lensBorderColour:"#000",lensShape:"square",zoomType:"window",containLensZoom:!1,lensColour:"white",lensOpacity:0.4,lenszoom:!1,tint:!1,tintColour:"#333",tintOpacity:0.4,gallery:!1,
galleryActiveClass:"zoomGalleryActive",imageCrossfade:!1,constrainType:!1,constrainSize:!1,loadingIcon:!1,cursor:"default",responsive:!0,onComplete:d.noop,onZoomedImageLoaded:function(){},onImageSwap:d.noop,onImageSwapComplete:d.noop}})(jQuery,window,document);

(function(c){c.fn.jPaginator=function(p){this.length!=1&&c.error("You must use this plugin with a unique element");var a={selectedPage:1,nbPages:100,length:10,widthPx:30,marginPx:1,overBtnLeft:null,overBtnRight:null,maxBtnLeft:null,maxBtnRight:null,withSlider:!0,withAcceleration:!0,speed:2,coeffAcceleration:2,minSlidesForSlider:3,onPageClicked:null},b={realWid:0,curNum:1,infRel:0,cInfMax:0,cInf:0,nbMove:0,isMoving:!1,isLimitL:!1,isLimitR:!1,listenSlider:!0};return this.each(function(){function q(){j(a.selectedPage-
Math.floor((a.length-1)/2));b.listenSlider=!1;l(b.cInf);b.listenSlider=!0;a.onPageClicked&&a.onPageClicked.call(this,d,a.selectedPage)}function j(e){d.find(".paginator_p.selected").removeClass("selected");var e=Math.min(a.nbPages-a.length+1,e),e=Math.max(1,e),k=e-2;d.find(".paginator_p_bloc .paginator_p").each(function(){k+=1;c(this).html(k);a.selectedPage==k&&c(this).addClass("selected")});d.find(".paginator_p_bloc").css("left","-"+b.realWid+"px");b.curNum=e;b.cInf=(e-1)*b.realWid;b.infRel=0}function l(a){var a=
Math.round(a/b.cInfMax*100),k=d.find(".paginator_slider").slider("option","value");a!=k&&d.find(".paginator_slider").slider("option","value",a)}function r(e,d){if(b.listenSlider&&!b.isMoving){var c=d.value,c=Math.min(100,c),c=Math.max(0,c),g=Math.round(b.cInfMax*c/100)-b.cInf;c==100?j(a.nbPages-a.length+1):c==0?j(1):h(g)}}function h(e){var c=b.infRel+e,f=Math.abs(e)/e*Math.floor(Math.abs(c)/b.realWid);c%=b.realWid;b.infRel=c;var g=(b.curNum-1)*b.realWid+b.infRel,h=b.curNum+f;h<1&&(g=-1);h>a.nbPages&&
(g=b.cInfMax+1);g<0?(j(1),b.cInf=0,b.infRel=0,l(0),b.isLimitL=!0,m()):g>b.cInfMax?(j(a.nbPages),b.cInf=b.cInfMax,b.infRel=0,l(b.cInfMax),b.isLimitR=!0,m()):(b.isLimitL=!1,b.isLimitR=!1,b.cInf=g,e!=0&&(f!=0&&j(h),l(b.cInf),d.find(".paginator_p_bloc").css("left",-1*c-b.realWid+"px")))}function m(){b.nbMove=0;b.isMoving=!1}function n(a){if(!(b.isLimitR&&a=="right")&&!(b.isLimitL&&a=="left")){var c=Math.round(b.cInfMax/10);a=="left"&&(c*=-1);h(c);setTimeout(function(){b.nbMove+=1;n(a)},20)}}function o(c){if(b.isMoving){var d=
Math.min(Math.abs(a.speed),5),f=Math.min(Math.abs(a.coeffAcceleration),5);a.withAcceleration&&(d=Math.round(d+Math.round(f*b.nbMove*b.nbMove/8E4)));c=="left"&&(d*=-1);h(d);setTimeout(function(){b.nbMove+=1;o(c)},10)}}var d=c(this);p&&c.extend(a,p);for(i=1;i<=a.length+2;i++)d.find(".paginator_p_bloc").append(c("<div class='paginator_p'></div>"));a.length=Math.min(a.length,a.nbPages);a.nbPages<=a.length&&(d.find(".paginator_slider").hide(),d.find(".paginator_slider").children().hide());if(Math.ceil(a.nbPages/
a.length)<a.minSlidesForSlider)a.withSlider=!1;a.withSlider||(d.find(".paginator_slider").hide(),d.find(".paginator_slider").children().hide());var f=0,s=d.find(".paginator_p").first().css("border-left-width");s.indexOf("px")>0&&(f=s.replace("px","")*1);b.realWid=a.widthPx+a.marginPx*2+f*2;f=1*b.realWid*a.length;d.find(".paginator_p").css("width",a.widthPx+"px");d.find(".paginator_p").css("margin","0 "+a.marginPx+"px 0 "+a.marginPx+"px");d.find(".paginator_p_wrap").css("width",f+"px");d.find(".paginator_slider").css("width",
f+"px");b.cInfMax=a.nbPages*b.realWid-a.length*b.realWid;a.selectedPage=Math.min(a.selectedPage,a.nbPages);q(d);d.find(".paginator_p").bind("click.jPaginator",function(){var b=1*c(this).html();d.find(".paginator_p.selected").removeClass("selected");a.selectedPage=b;q()});a.withSlider&&(d.find(".paginator_slider").slider({animate:!1}),d.find(".paginator_slider").bind("slidechange.jPaginator",function(a,b){return r(a,b)}),d.find(".paginator_slider").bind("slide.jPaginator",function(a,b){return r(a,
b)}));a.overBtnLeft&&c(a.overBtnLeft).bind("mouseenter.jPaginator",function(){c(this);b.isMoving=!0;o("left")});a.overBtnRight&&c(a.overBtnRight).bind("mouseenter.jPaginator",function(){c(this);b.isMoving=!0;o("right")});a.overBtnLeft&&c(a.overBtnLeft).bind("mouseleave.jPaginator",function(){c(this);m()});a.overBtnRight&&c(a.overBtnRight).bind("mouseleave.jPaginator",function(){c(this);m()});a.maxBtnLeft&&c(a.maxBtnLeft).bind("click.jPaginator",function(){return n("left")});a.maxBtnRight&&c(a.maxBtnRight).bind("click.jPaginator",
function(){return n("right")});d.find(".paginator_p").bind("mouseenter.jPaginator",function(){var a=c(this);d.find(".paginator_p.over").removeClass("over");a.addClass("over")});d.find(".paginator_p").bind("mouseleave.jPaginator",function(){c(this);d.find(".paginator_p.over").removeClass("over")})})}})(jQuery);

/*! jQuery number 2.1.3 (c) github.com/teamdf/jquery-number | opensource.teamdf.com/license */
(function(h){function r(f,a){if(this.createTextRange){var c=this.createTextRange();c.collapse(true);c.moveStart("character",f);c.moveEnd("character",a-f);c.select()}else if(this.setSelectionRange){this.focus();this.setSelectionRange(f,a)}}function s(f){var a=this.value.length;f=f.toLowerCase()=="start"?"Start":"End";if(document.selection){a=document.selection.createRange();var c;c=a.duplicate();c.expand("textedit");c.setEndPoint("EndToEnd",a);c=c.text.length-a.text.length;a=c+a.text.length;return f==
"Start"?c:a}else if(typeof this["selection"+f]!="undefined")a=this["selection"+f];return a}var q={codes:{188:44,109:45,190:46,191:47,192:96,220:92,222:39,221:93,219:91,173:45,187:61,186:59,189:45,110:46},shifts:{96:"~",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",48:")",45:"_",61:"+",91:"{",93:"}",92:"|",59:":",39:'"',44:"<",46:">",47:"?"}};h.fn.number=function(f,a,c,k){k=typeof k==="undefined"?",":k;c=typeof c==="undefined"?".":c;a=typeof a==="undefined"?0:a;var j="\\u"+("0000"+
c.charCodeAt(0).toString(16)).slice(-4),o=RegExp("[^"+j+"0-9]","g"),p=RegExp(j,"g");if(f===true)return this.is("input:text")?this.on({"keydown.format":function(b){var d=h(this),e=d.data("numFormat"),g=b.keyCode?b.keyCode:b.which,m="",i=s.apply(this,["start"]),n=s.apply(this,["end"]),l="";l=false;if(q.codes.hasOwnProperty(g))g=q.codes[g];if(!b.shiftKey&&g>=65&&g<=90)g+=32;else if(!b.shiftKey&&g>=69&&g<=105)g-=48;else if(b.shiftKey&&q.shifts.hasOwnProperty(g))m=q.shifts[g];if(m=="")m=String.fromCharCode(g);
if(g!==8&&m!=c&&!m.match(/[0-9]/)){d=b.keyCode?b.keyCode:b.which;if(d==46||d==8||d==9||d==27||d==13||(d==65||d==82)&&(b.ctrlKey||b.metaKey)===true||(d==86||d==67)&&(b.ctrlKey||b.metaKey)===true||d>=35&&d<=39)return;b.preventDefault();return false}if(i==0&&n==this.value.length||d.val()==0)if(g===8){i=n=1;this.value="";e.init=a>0?-1:0;e.c=a>0?-(a+1):0;r.apply(this,[0,0])}else if(m===c){i=n=1;this.value="0"+c+Array(a+1).join("0");e.init=a>0?1:0;e.c=a>0?-(a+1):0}else{if(this.value.length===0){e.init=
a>0?-1:0;e.c=a>0?-a:0}}else e.c=n-this.value.length;if(a>0&&m==c&&i==this.value.length-a-1){e.c++;e.init=Math.max(0,e.init);b.preventDefault();l=this.value.length+e.c}else if(m==c){e.init=Math.max(0,e.init);b.preventDefault()}else if(a>0&&g==8&&i==this.value.length-a){b.preventDefault();e.c--;l=this.value.length+e.c}else if(a>0&&g==8&&i>this.value.length-a){if(this.value==="")return;if(this.value.slice(i-1,i)!="0"){l=this.value.slice(0,i-1)+"0"+this.value.slice(i);d.val(l.replace(o,"").replace(p,
c))}b.preventDefault();e.c--;l=this.value.length+e.c}else if(g==8&&this.value.slice(i-1,i)==k){b.preventDefault();e.c--;l=this.value.length+e.c}else if(a>0&&i==n&&this.value.length>a+1&&i>this.value.length-a-1&&isFinite(+m)&&!b.metaKey&&!b.ctrlKey&&!b.altKey&&m.length===1){this.value=l=n===this.value.length?this.value.slice(0,i-1):this.value.slice(0,i)+this.value.slice(i+1);l=i}l!==false&&r.apply(this,[l,l]);d.data("numFormat",e)},"keyup.format":function(b){var d=h(this),e=d.data("numFormat");b=b.keyCode?
b.keyCode:b.which;var g=s.apply(this,["start"]);if(!(this.value===""||(b<48||b>57)&&(b<96||b>105)&&b!==8)){d.val(d.val());if(a>0)if(e.init<1){g=this.value.length-a-(e.init<0?1:0);e.c=g-this.value.length;e.init=1;d.data("numFormat",e)}else if(g>this.value.length-a&&b!=8){e.c++;d.data("numFormat",e)}d=this.value.length+e.c;r.apply(this,[d,d])}},"paste.format":function(b){var d=h(this),e=b.originalEvent,g=null;if(window.clipboardData&&window.clipboardData.getData)g=window.clipboardData.getData("Text");
else if(e.clipboardData&&e.clipboardData.getData)g=e.clipboardData.getData("text/plain");d.val(g);b.preventDefault();return false}}).each(function(){var b=h(this).data("numFormat",{c:-(a+1),decimals:a,thousands_sep:k,dec_point:c,regex_dec_num:o,regex_dec:p,init:false});this.value!==""&&b.val(b.val())}):this.each(function(){var b=h(this),d=+b.text().replace(o,"").replace(p,".");b.number(!isFinite(d)?0:+d,a,c,k)});return this.text(h.number.apply(window,arguments))};var t=null,u=null;if(h.isPlainObject(h.valHooks.text)){if(h.isFunction(h.valHooks.text.get))t=
h.valHooks.text.get;if(h.isFunction(h.valHooks.text.set))u=h.valHooks.text.set}else h.valHooks.text={};h.valHooks.text.get=function(f){var a=h(f).data("numFormat");if(a){if(f.value==="")return"";f=+f.value.replace(a.regex_dec_num,"").replace(a.regex_dec,".");return""+(isFinite(f)?f:0)}else if(h.isFunction(t))return t(f)};h.valHooks.text.set=function(f,a){var c=h(f).data("numFormat");if(c)return f.value=h.number(a,c.decimals,c.dec_point,c.thousands_sep);else if(h.isFunction(u))return u(f,a)};h.number=
function(f,a,c,k){k=typeof k==="undefined"?",":k;c=typeof c==="undefined"?".":c;a=!isFinite(+a)?0:Math.abs(a);var j="\\u"+("0000"+c.charCodeAt(0).toString(16)).slice(-4),o="\\u"+("0000"+k.charCodeAt(0).toString(16)).slice(-4);f=(f+"").replace(".",c).replace(RegExp(o,"g"),"").replace(RegExp(j,"g"),".").replace(RegExp("[^0-9+-Ee.]","g"),"");f=!isFinite(+f)?0:+f;j="";j=function(p,b){var d=Math.pow(10,b);return""+Math.round(p*d)/d};j=(a?j(f,a):""+Math.round(f)).split(".");if(j[0].length>3)j[0]=j[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,
k);if((j[1]||"").length<a){j[1]=j[1]||"";j[1]+=Array(a-j[1].length+1).join("0")}return j.join(c)}})(jQuery);

$(function(a){a.datepicker.regional.de={closeText:"schließen",prevText:"zurück",nextText:"vor",currentText:"heute",monthNames:"Januar Februar März April Mai Juni Juli August September Oktober November Dezember".split(" "),monthNamesShort:"Jan Feb Mär Apr Mai Jun Jul Aug Sep Okt Nov Dez".split(" "),dayNames:"Sonntag Montag Dienstag Mittwoch Donnerstag Freitag Samstag".split(" "),dayNamesShort:"So Mo Di Mi Do Fr Sa".split(" "),dayNamesMin:"So Mo Di Mi Do Fr Sa".split(" "), weekHeader:"Wo",dateFormat:"dd.mm.yy",firstDay:1,isRTL:!1,showMonthAfterYear:!1,yearSuffix:""};a.datepicker.setDefaults(a.datepicker.regional.de)});

jQuery.fn.colourPicker=function(conf){var config=jQuery.extend({id:'jquery-colour-picker',ico:'ico.gif',title:'Pick a colour',inputBG:true,speed:500,openTxt:'Open colour picker'},conf);var hexInvert=function(hex){var r=hex.substr(0,2);var g=hex.substr(2,2);var b=hex.substr(4,2);return 0.212671*r+0.715160*g+0.072169*b<0.5?'ffffff':'000000'};var colourPicker=jQuery('#'+config.id);if(!colourPicker.length){colourPicker=jQuery('<div id="'+config.id+'"></div>').appendTo(document.body).hide();jQuery(document.body).click(function(event){if(!(jQuery(event.target).is('#'+config.id)||jQuery(event.target).parents('#'+config.id).length)){colourPicker.hide(config.speed)}})}return this.each(function(){var select=jQuery(this);var icon=jQuery('<a href="#"><img src="'+config.ico+'" alt="'+config.openTxt+'" /></a>').insertAfter(select);var input=jQuery('<input type="text" name="'+select.attr('name')+'" value="'+select.val()+'" size="6" readonly="true"/>').insertAfter(select);var loc='';jQuery('option',select).each(function(){var option=jQuery(this);var hex=option.val();var title=option.text();loc+='<li><a data-id="'+option.attr('data-id')+'" href="#" title="'+title+'" rel="'+hex+'" style="background: #'+hex+';borderColor: #'+hex+'; colour: '+hexInvert(hex)+';">'+title+'</a></li>'});select.attr('name','cpba');select.hide();if(config.inputBG){input.change(function(){input.css({background:'#'+input.val(),borderColor:'#'+input.val(),color:'#'+hexInvert(input.val())})});input.change()}icon.click(function(){var iconPos=icon.offset();var heading=config.title?'<h2>'+config.title+'</h2>':'';colourPicker.html(heading+'<ul>'+loc+'</ul>').css({position:'absolute',left:(iconPos.left - 84)+'px',top:iconPos.top+'px'}).show(config.speed);jQuery('a',colourPicker).click(function(){var hex=jQuery(this).attr('rel');input.val(hex);if(config.inputBG){input.css({background:'#'+hex,borderColor:'#'+hex,color:'#'+hexInvert(hex)})}input.change();colourPicker.hide(config.speed);return false});return false})})};

/*! Copyright (c) 2013 Brandon Aaron (http://brandon.aaron.sh)
 * Licensed under the MIT License (LICENSE.txt).
 * Version: 3.1.11
 * Requires: jQuery 1.2.2+
 */
!function(a){"function"==typeof define&&define.amd?define(["jquery"],a):"object"==typeof exports?module.exports=a:a(jQuery)}(function(a){function b(b){var g=b||window.event,h=i.call(arguments,1),j=0,l=0,m=0,n=0,o=0,p=0;if(b=a.event.fix(g),b.type="mousewheel","detail"in g&&(m=-1*g.detail),"wheelDelta"in g&&(m=g.wheelDelta),"wheelDeltaY"in g&&(m=g.wheelDeltaY),"wheelDeltaX"in g&&(l=-1*g.wheelDeltaX),"axis"in g&&g.axis===g.HORIZONTAL_AXIS&&(l=-1*m,m=0),j=0===m?l:m,"deltaY"in g&&(m=-1*g.deltaY,j=m),"deltaX"in g&&(l=g.deltaX,0===m&&(j=-1*l)),0!==m||0!==l){if(1===g.deltaMode){var q=a.data(this,"mousewheel-line-height");j*=q,m*=q,l*=q}else if(2===g.deltaMode){var r=a.data(this,"mousewheel-page-height");j*=r,m*=r,l*=r}if(n=Math.max(Math.abs(m),Math.abs(l)),(!f||f>n)&&(f=n,d(g,n)&&(f/=40)),d(g,n)&&(j/=40,l/=40,m/=40),j=Math[j>=1?"floor":"ceil"](j/f),l=Math[l>=1?"floor":"ceil"](l/f),m=Math[m>=1?"floor":"ceil"](m/f),k.settings.normalizeOffset&&this.getBoundingClientRect){var s=this.getBoundingClientRect();o=b.clientX-s.left,p=b.clientY-s.top}return b.deltaX=l,b.deltaY=m,b.deltaFactor=f,b.offsetX=o,b.offsetY=p,b.deltaMode=0,h.unshift(b,j,l,m),e&&clearTimeout(e),e=setTimeout(c,200),(a.event.dispatch||a.event.handle).apply(this,h)}}function c(){f=null}function d(a,b){return k.settings.adjustOldDeltas&&"mousewheel"===a.type&&b%120===0}var e,f,g=["wheel","mousewheel","DOMMouseScroll","MozMousePixelScroll"],h="onwheel"in document||document.documentMode>=9?["wheel"]:["mousewheel","DomMouseScroll","MozMousePixelScroll"],i=Array.prototype.slice;if(a.event.fixHooks)for(var j=g.length;j;)a.event.fixHooks[g[--j]]=a.event.mouseHooks;var k=a.event.special.mousewheel={version:"3.1.11",setup:function(){if(this.addEventListener)for(var c=h.length;c;)this.addEventListener(h[--c],b,!1);else this.onmousewheel=b;a.data(this,"mousewheel-line-height",k.getLineHeight(this)),a.data(this,"mousewheel-page-height",k.getPageHeight(this))},teardown:function(){if(this.removeEventListener)for(var c=h.length;c;)this.removeEventListener(h[--c],b,!1);else this.onmousewheel=null;a.removeData(this,"mousewheel-line-height"),a.removeData(this,"mousewheel-page-height")},getLineHeight:function(b){var c=a(b)["offsetParent"in a.fn?"offsetParent":"parent"]();return c.length||(c=a("body")),parseInt(c.css("fontSize"),10)},getPageHeight:function(b){return a(b).height()},settings:{adjustOldDeltas:!0,normalizeOffset:!0}};a.fn.extend({mousewheel:function(a){return a?this.bind("mousewheel",a):this.trigger("mousewheel")},unmousewheel:function(a){return this.unbind("mousewheel",a)}})});

/*
 jQuery Toggles v3.1.4
Copyright 2014 Simon Tabor - MIT License
https://github.com/simontabor/jquery-toggles / http://simontabor.com/labs/toggles
*/
(function(h){function l(f){var k=h.Toggles=function(b,a){if("boolean"===typeof a&&b.data("toggles"))b.data("toggles").toggle(a);else{for(var c="on drag click width height animate easing type checkbox".split(" "),e={},d=0;d<c.length;d++){var g=b.data("toggle-"+c[d]);"undefined"!==typeof g&&(e[c[d]]=g)}a=this.b=f.extend({drag:!0,click:!0,text:{on:"ON",off:"OFF"},on:!1,animate:250,easing:"swing",checkbox:null,clicker:null,width:50,height:20,type:"compact",event:"toggle"},a||{},e);this.c=b;this.active=
a.on;b.data("toggles",this);this.h="select"===a.type;this.l=f(a.checkbox);a.clicker&&(this.n=f(a.clicker));this.m();this.k()}};k.prototype.m=function(){function b(a){return f('<div class="toggle-'+a+'">')}var a=this.c.height(),c=this.c.width();a||this.c.height(a=this.b.height);c||this.c.width(c=this.b.width);this.g=a;this.i=c;this.a={f:b("slide"),e:b("inner"),on:b("on"),off:b("off"),d:b("blob")};var e=a/2,d=c-e,g=this.h;this.a.on.css({height:a,width:d,textIndent:g?"":-e,lineHeight:a+"px"}).html(this.b.text.on);
this.a.off.css({height:a,width:d,marginLeft:g?"":-e,textIndent:g?"":e,lineHeight:a+"px"}).html(this.b.text.off).addClass("active");this.a.d.css({height:a,width:a,marginLeft:-e});this.a.e.css({width:2*c-a,marginLeft:g||this.active?0:-c+a});this.h&&(this.a.f.addClass("toggle-select"),this.c.css("width",2*d),this.a.d.hide());this.a.e.append(this.a.on,this.a.d,this.a.off);this.a.f.html(this.a.e);this.c.html(this.a.f)};k.prototype.k=function(){function b(b){b.target===a.a.d[0]&&a.b.drag||a.toggle()}var a=
this;if(a.b.click&&(!a.b.clicker||!a.b.clicker.has(a.c).length))a.c.on("click",b);if(a.b.clicker)a.b.clicker.on("click",b);a.b.drag&&!a.h&&a.j()};k.prototype.j=function(){function b(b){a.c.off("mousemove");a.a.f.off("mouseleave");a.a.d.off("mouseup");!c&&a.b.click&&"mouseleave"!==b.type?a.toggle():(a.active?c<-e:c>e)?a.toggle():a.a.e.stop().animate({marginLeft:a.active?0:-a.i+a.g},a.b.animate/2)}var a=this,c,e=(a.i-a.g)/4,d=-a.i+a.g;a.a.d.on("mousedown",function(e){c=0;a.a.d.off("mouseup");a.a.f.off("mouseleave");
var f=e.pageX;a.c.on("mousemove",a.a.d,function(b){c=b.pageX-f;a.active?(b=c,0<c&&(b=0),c<d&&(b=d)):(b=c+d,0>c&&(b=d),c>-d&&(b=0));a.a.e.css("margin-left",b)});a.a.d.on("mouseup",b);a.a.f.on("mouseleave",b)})};k.prototype.toggle=function(b){this.active!==b&&(b=this.active=!this.active,this.c.data("toggle-active",b),this.a.off.toggleClass("active",!b),this.a.on.toggleClass("active",b),this.l.prop("checked",b),this.c.trigger(this.b.event,b),this.h||(b=b?0:-this.i+this.g,this.a.e.stop().animate({marginLeft:b},
this.b.animate)))};f.fn.toggles=function(b){return this.each(function(){new k(f(this),b)})}}"function"===typeof define&&define.amd?define(["jquery"],l):l(h.jQuery||h.Zepto||h.ender||h.$||$)})(this);
/*!
 * imagesLoaded PACKAGED v3.1.8
 * JavaScript is all like "You images are done yet or what?"
 * MIT License
 */
(function(){function e(){}function t(e,t){for(var n=e.length;n--;)if(e[n].listener===t)return n;return-1}function n(e){return function(){return this[e].apply(this,arguments)}}var i=e.prototype,r=this,o=r.EventEmitter;i.getListeners=function(e){var t,n,i=this._getEvents();if("object"==typeof e){t={};for(n in i)i.hasOwnProperty(n)&&e.test(n)&&(t[n]=i[n])}else t=i[e]||(i[e]=[]);return t},i.flattenListeners=function(e){var t,n=[];for(t=0;e.length>t;t+=1)n.push(e[t].listener);return n},i.getListenersAsObject=function(e){var t,n=this.getListeners(e);return n instanceof Array&&(t={},t[e]=n),t||n},i.addListener=function(e,n){var i,r=this.getListenersAsObject(e),o="object"==typeof n;for(i in r)r.hasOwnProperty(i)&&-1===t(r[i],n)&&r[i].push(o?n:{listener:n,once:!1});return this},i.on=n("addListener"),i.addOnceListener=function(e,t){return this.addListener(e,{listener:t,once:!0})},i.once=n("addOnceListener"),i.defineEvent=function(e){return this.getListeners(e),this},i.defineEvents=function(e){for(var t=0;e.length>t;t+=1)this.defineEvent(e[t]);return this},i.removeListener=function(e,n){var i,r,o=this.getListenersAsObject(e);for(r in o)o.hasOwnProperty(r)&&(i=t(o[r],n),-1!==i&&o[r].splice(i,1));return this},i.off=n("removeListener"),i.addListeners=function(e,t){return this.manipulateListeners(!1,e,t)},i.removeListeners=function(e,t){return this.manipulateListeners(!0,e,t)},i.manipulateListeners=function(e,t,n){var i,r,o=e?this.removeListener:this.addListener,s=e?this.removeListeners:this.addListeners;if("object"!=typeof t||t instanceof RegExp)for(i=n.length;i--;)o.call(this,t,n[i]);else for(i in t)t.hasOwnProperty(i)&&(r=t[i])&&("function"==typeof r?o.call(this,i,r):s.call(this,i,r));return this},i.removeEvent=function(e){var t,n=typeof e,i=this._getEvents();if("string"===n)delete i[e];else if("object"===n)for(t in i)i.hasOwnProperty(t)&&e.test(t)&&delete i[t];else delete this._events;return this},i.removeAllListeners=n("removeEvent"),i.emitEvent=function(e,t){var n,i,r,o,s=this.getListenersAsObject(e);for(r in s)if(s.hasOwnProperty(r))for(i=s[r].length;i--;)n=s[r][i],n.once===!0&&this.removeListener(e,n.listener),o=n.listener.apply(this,t||[]),o===this._getOnceReturnValue()&&this.removeListener(e,n.listener);return this},i.trigger=n("emitEvent"),i.emit=function(e){var t=Array.prototype.slice.call(arguments,1);return this.emitEvent(e,t)},i.setOnceReturnValue=function(e){return this._onceReturnValue=e,this},i._getOnceReturnValue=function(){return this.hasOwnProperty("_onceReturnValue")?this._onceReturnValue:!0},i._getEvents=function(){return this._events||(this._events={})},e.noConflict=function(){return r.EventEmitter=o,e},"function"==typeof define&&define.amd?define("eventEmitter/EventEmitter",[],function(){return e}):"object"==typeof module&&module.exports?module.exports=e:this.EventEmitter=e}).call(this),function(e){function t(t){var n=e.event;return n.target=n.target||n.srcElement||t,n}var n=document.documentElement,i=function(){};n.addEventListener?i=function(e,t,n){e.addEventListener(t,n,!1)}:n.attachEvent&&(i=function(e,n,i){e[n+i]=i.handleEvent?function(){var n=t(e);i.handleEvent.call(i,n)}:function(){var n=t(e);i.call(e,n)},e.attachEvent("on"+n,e[n+i])});var r=function(){};n.removeEventListener?r=function(e,t,n){e.removeEventListener(t,n,!1)}:n.detachEvent&&(r=function(e,t,n){e.detachEvent("on"+t,e[t+n]);try{delete e[t+n]}catch(i){e[t+n]=void 0}});var o={bind:i,unbind:r};"function"==typeof define&&define.amd?define("eventie/eventie",o):e.eventie=o}(this),function(e,t){"function"==typeof define&&define.amd?define(["eventEmitter/EventEmitter","eventie/eventie"],function(n,i){return t(e,n,i)}):"object"==typeof exports?module.exports=t(e,require("wolfy87-eventemitter"),require("eventie")):e.imagesLoaded=t(e,e.EventEmitter,e.eventie)}(window,function(e,t,n){function i(e,t){for(var n in t)e[n]=t[n];return e}function r(e){return"[object Array]"===d.call(e)}function o(e){var t=[];if(r(e))t=e;else if("number"==typeof e.length)for(var n=0,i=e.length;i>n;n++)t.push(e[n]);else t.push(e);return t}function s(e,t,n){if(!(this instanceof s))return new s(e,t);"string"==typeof e&&(e=document.querySelectorAll(e)),this.elements=o(e),this.options=i({},this.options),"function"==typeof t?n=t:i(this.options,t),n&&this.on("always",n),this.getImages(),a&&(this.jqDeferred=new a.Deferred);var r=this;setTimeout(function(){r.check()})}function f(e){this.img=e}function c(e){this.src=e,v[e]=this}var a=e.jQuery,u=e.console,h=u!==void 0,d=Object.prototype.toString;s.prototype=new t,s.prototype.options={},s.prototype.getImages=function(){this.images=[];for(var e=0,t=this.elements.length;t>e;e++){var n=this.elements[e];"IMG"===n.nodeName&&this.addImage(n);var i=n.nodeType;if(i&&(1===i||9===i||11===i))for(var r=n.querySelectorAll("img"),o=0,s=r.length;s>o;o++){var f=r[o];this.addImage(f)}}},s.prototype.addImage=function(e){var t=new f(e);this.images.push(t)},s.prototype.check=function(){function e(e,r){return t.options.debug&&h&&u.log("confirm",e,r),t.progress(e),n++,n===i&&t.complete(),!0}var t=this,n=0,i=this.images.length;if(this.hasAnyBroken=!1,!i)return this.complete(),void 0;for(var r=0;i>r;r++){var o=this.images[r];o.on("confirm",e),o.check()}},s.prototype.progress=function(e){this.hasAnyBroken=this.hasAnyBroken||!e.isLoaded;var t=this;setTimeout(function(){t.emit("progress",t,e),t.jqDeferred&&t.jqDeferred.notify&&t.jqDeferred.notify(t,e)})},s.prototype.complete=function(){var e=this.hasAnyBroken?"fail":"done";this.isComplete=!0;var t=this;setTimeout(function(){if(t.emit(e,t),t.emit("always",t),t.jqDeferred){var n=t.hasAnyBroken?"reject":"resolve";t.jqDeferred[n](t)}})},a&&(a.fn.imagesLoaded=function(e,t){var n=new s(this,e,t);return n.jqDeferred.promise(a(this))}),f.prototype=new t,f.prototype.check=function(){var e=v[this.img.src]||new c(this.img.src);if(e.isConfirmed)return this.confirm(e.isLoaded,"cached was confirmed"),void 0;if(this.img.complete&&void 0!==this.img.naturalWidth)return this.confirm(0!==this.img.naturalWidth,"naturalWidth"),void 0;var t=this;e.on("confirm",function(e,n){return t.confirm(e.isLoaded,n),!0}),e.check()},f.prototype.confirm=function(e,t){this.isLoaded=e,this.emit("confirm",this,t)};var v={};return c.prototype=new t,c.prototype.check=function(){if(!this.isChecked){var e=new Image;n.bind(e,"load",this),n.bind(e,"error",this),e.src=this.src,this.isChecked=!0}},c.prototype.handleEvent=function(e){var t="on"+e.type;this[t]&&this[t](e)},c.prototype.onload=function(e){this.confirm(!0,"onload"),this.unbindProxyEvents(e)},c.prototype.onerror=function(e){this.confirm(!1,"onerror"),this.unbindProxyEvents(e)},c.prototype.confirm=function(e,t){this.isConfirmed=!0,this.isLoaded=e,this.emit("confirm",this,t)},c.prototype.unbindProxyEvents=function(e){n.unbind(e.target,"load",this),n.unbind(e.target,"error",this)},s});

/*! sly 1.5.1 - 28th Apr 2015 | https://github.com/darsain/sly */
!function(a,b,c){"use strict";function d(b,p,q){function K(c){var d=0,e=Gb.length;if(yb.old=a.extend({},yb),wb=tb?0:ub[rb.horizontal?"width":"height"](),Bb=zb[rb.horizontal?"width":"height"](),xb=tb?b:vb[rb.horizontal?"outerWidth":"outerHeight"](),Gb.length=0,yb.start=0,yb.end=H(xb-wb,0),Rb){d=Ib.length,Hb=vb.children(rb.itemSelector),Ib.length=0;var f,g=j(vb,rb.horizontal?"paddingLeft":"paddingTop"),h=j(vb,rb.horizontal?"paddingRight":"paddingBottom"),i="border-box"===a(Hb).css("boxSizing"),l="none"!==Hb.css("float"),m=0,n=Hb.length-1;xb=0,Hb.each(function(b,c){var d=a(c),e=c.getBoundingClientRect(),i=G(rb.horizontal?e.width||e.right-e.left:e.height||e.bottom-e.top),k=j(d,rb.horizontal?"marginLeft":"marginTop"),o=j(d,rb.horizontal?"marginRight":"marginBottom"),p=i+k+o,q=!k||!o,r={};r.el=c,r.size=q?i:p,r.half=r.size/2,r.start=xb+(q?k:0),r.center=r.start-G(wb/2-r.size/2),r.end=r.start-wb+r.size,b||(xb+=g),xb+=p,rb.horizontal||l||o&&k&&b>0&&(xb-=I(k,o)),b===n&&(r.end+=h,xb+=h,m=q?o:0),Ib.push(r),f=r}),vb[0].style[rb.horizontal?"width":"height"]=(i?xb:xb-g-h)+"px",xb-=m,Ib.length?(yb.start=Ib[0][Pb?"center":"start"],yb.end=Pb?f.center:xb>wb?f.end:yb.start):yb.start=yb.end=0}if(yb.center=G(yb.end/2+yb.start/2),V(),Ab.length&&Bb>0&&(rb.dynamicHandle?(Cb=yb.start===yb.end?Bb:G(Bb*wb/xb),Cb=k(Cb,rb.minHandleSize,Bb),Ab[0].style[rb.horizontal?"width":"height"]=Cb+"px"):Cb=Ab[rb.horizontal?"outerWidth":"outerHeight"](),Db.end=Bb-Cb,ec||N()),!tb&&wb>0){var o=yb.start,p="";if(Rb)a.each(Ib,function(a,b){Pb?Gb.push(b.center):b.start+b.size>o&&o<=yb.end&&(o=b.start,Gb.push(o),o+=wb,o>yb.end&&o<yb.end+wb&&Gb.push(yb.end))});else for(;o-wb<yb.end;)Gb.push(o),o+=wb;if(Eb[0]&&e!==Gb.length){for(var q=0;q<Gb.length;q++)p+=rb.pageBuilder.call(sb,q);Fb=Eb.html(p).children(),Fb.eq(Jb.activePage).addClass(rb.activeClass)}}if(Jb.slideeSize=xb,Jb.frameSize=wb,Jb.sbSize=Bb,Jb.handleSize=Cb,Rb){c&&null!=rb.startAt&&(T(rb.startAt),sb[Qb?"toCenter":"toStart"](rb.startAt));var r=Ib[Jb.activeItem];L(Qb&&r?r.center:k(yb.dest,yb.start,yb.end))}else c?null!=rb.startAt&&L(rb.startAt,1):L(k(yb.dest,yb.start,yb.end));ob("load")}function L(a,b,c){if(Rb&&cc.released&&!c){var d=U(a),e=a>yb.start&&a<yb.end;Qb?(e&&(a=Ib[d.centerItem].center),Pb&&rb.activateMiddle&&T(d.centerItem)):e&&(a=Ib[d.firstItem].start)}cc.init&&cc.slidee&&rb.elasticBounds?a>yb.end?a=yb.end+(a-yb.end)/6:a<yb.start&&(a=yb.start+(a-yb.start)/6):a=k(a,yb.start,yb.end),ac.start=+new Date,ac.time=0,ac.from=yb.cur,ac.to=a,ac.delta=a-yb.cur,ac.tweesing=cc.tweese||cc.init&&!cc.slidee,ac.immediate=!ac.tweesing&&(b||cc.init&&cc.slidee||!rb.speed),cc.tweese=0,a!==yb.dest&&(yb.dest=a,ob("change"),ec||M()),Z(),V(),W(),O()}function M(){if(sb.initialized){if(!ec)return ec=t(M),void(cc.released&&ob("moveStart"));ac.immediate?yb.cur=ac.to:ac.tweesing?(ac.tweeseDelta=ac.to-yb.cur,D(ac.tweeseDelta)<.1?yb.cur=ac.to:yb.cur+=ac.tweeseDelta*(cc.released?rb.swingSpeed:rb.syncSpeed)):(ac.time=I(+new Date-ac.start,rb.speed),yb.cur=ac.from+ac.delta*a.easing[rb.easing](ac.time/rb.speed,ac.time,0,1,rb.speed)),ac.to===yb.cur?(yb.cur=ac.to,cc.tweese=ec=0):ec=t(M),ob("move"),tb||(m?vb[0].style[m]=n+(rb.horizontal?"translateX":"translateY")+"("+-yb.cur+"px)":vb[0].style[rb.horizontal?"left":"top"]=-G(yb.cur)+"px"),!ec&&cc.released&&ob("moveEnd"),N()}}function N(){Ab.length&&(Db.cur=yb.start===yb.end?0:((cc.init&&!cc.slidee?yb.dest:yb.cur)-yb.start)/(yb.end-yb.start)*Db.end,Db.cur=k(G(Db.cur),Db.start,Db.end),_b.hPos!==Db.cur&&(_b.hPos=Db.cur,m?Ab[0].style[m]=n+(rb.horizontal?"translateX":"translateY")+"("+Db.cur+"px)":Ab[0].style[rb.horizontal?"left":"top"]=Db.cur+"px"))}function O(){Fb[0]&&_b.page!==Jb.activePage&&(_b.page=Jb.activePage,Fb.removeClass(rb.activeClass).eq(Jb.activePage).addClass(rb.activeClass),ob("activePage",_b.page))}function P(){bc.speed&&yb.cur!==(bc.speed>0?yb.end:yb.start)||sb.stop(),hc=cc.init?t(P):0,bc.now=+new Date,bc.pos=yb.cur+(bc.now-bc.lastTime)/1e3*bc.speed,L(cc.init?bc.pos:G(bc.pos)),cc.init||yb.cur!==yb.dest||ob("moveEnd"),bc.lastTime=bc.now}function Q(a,b,d){if("boolean"===e(b)&&(d=b,b=c),b===c)L(yb[a],d);else{if(Qb&&"center"!==a)return;var f=sb.getPos(b);f&&L(f[a],d,!Qb)}}function R(a){return null!=a?i(a)?a>=0&&a<Ib.length?a:-1:Hb.index(a):-1}function S(a){return R(i(a)&&0>a?a+Ib.length:a)}function T(a,b){var c=R(a);return!Rb||0>c?!1:((_b.active!==c||b)&&(Hb.eq(Jb.activeItem).removeClass(rb.activeClass),Hb.eq(c).addClass(rb.activeClass),_b.active=Jb.activeItem=c,W(),ob("active",c)),c)}function U(a){a=k(i(a)?a:yb.dest,yb.start,yb.end);var b={},c=Pb?0:wb/2;if(!tb)for(var d=0,e=Gb.length;e>d;d++){if(a>=yb.end||d===Gb.length-1){b.activePage=Gb.length-1;break}if(a<=Gb[d]+c){b.activePage=d;break}}if(Rb){for(var f=!1,g=!1,h=!1,j=0,l=Ib.length;l>j;j++)if(f===!1&&a<=Ib[j].start+Ib[j].half&&(f=j),h===!1&&a<=Ib[j].center+Ib[j].half&&(h=j),j===l-1||a<=Ib[j].end+Ib[j].half){g=j;break}b.firstItem=i(f)?f:0,b.centerItem=i(h)?h:b.firstItem,b.lastItem=i(g)?g:b.centerItem}return b}function V(b){a.extend(Jb,U(b))}function W(){var a=yb.dest<=yb.start,b=yb.dest>=yb.end,c=(a?1:0)|(b?2:0);if(_b.slideePosState!==c&&(_b.slideePosState=c,Yb.is("button,input")&&Yb.prop("disabled",a),Zb.is("button,input")&&Zb.prop("disabled",b),Yb.add(Vb)[a?"addClass":"removeClass"](rb.disabledClass),Zb.add(Ub)[b?"addClass":"removeClass"](rb.disabledClass)),_b.fwdbwdState!==c&&cc.released&&(_b.fwdbwdState=c,Vb.is("button,input")&&Vb.prop("disabled",a),Ub.is("button,input")&&Ub.prop("disabled",b)),Rb&&null!=Jb.activeItem){var d=0===Jb.activeItem,e=Jb.activeItem>=Ib.length-1,f=(d?1:0)|(e?2:0);_b.itemsButtonState!==f&&(_b.itemsButtonState=f,Wb.is("button,input")&&Wb.prop("disabled",d),Xb.is("button,input")&&Xb.prop("disabled",e),Wb[d?"addClass":"removeClass"](rb.disabledClass),Xb[e?"addClass":"removeClass"](rb.disabledClass))}}function X(a,b,c){if(a=S(a),b=S(b),a>-1&&b>-1&&a!==b&&(!c||b!==a-1)&&(c||b!==a+1)){Hb.eq(a)[c?"insertAfter":"insertBefore"](Ib[b].el);var d=b>a?a:c?b:b-1,e=a>b?a:c?b+1:b,f=a>b;null!=Jb.activeItem&&(a===Jb.activeItem?_b.active=Jb.activeItem=c?f?b+1:b:f?b:b-1:Jb.activeItem>d&&Jb.activeItem<e&&(_b.active=Jb.activeItem+=f?1:-1)),K()}}function Y(a,b){for(var c=0,d=$b[a].length;d>c;c++)if($b[a][c]===b)return c;return-1}function Z(){cc.released&&!sb.isPaused&&sb.resume()}function $(a){return G(k(a,Db.start,Db.end)/Db.end*(yb.end-yb.start))+yb.start}function _(){cc.history[0]=cc.history[1],cc.history[1]=cc.history[2],cc.history[2]=cc.history[3],cc.history[3]=cc.delta}function ab(a){cc.released=0,cc.source=a,cc.slidee="slidee"===a}function bb(b){var c="touchstart"===b.type,d=b.data.source,e="slidee"===d;cc.init||!c&&eb(b.target)||("handle"!==d||rb.dragHandle&&Db.start!==Db.end)&&(!e||(c?rb.touchDragging:rb.mouseDragging&&b.which<2))&&(c||f(b),ab(d),cc.init=0,cc.$source=a(b.target),cc.touch=c,cc.pointer=c?b.originalEvent.touches[0]:b,cc.initX=cc.pointer.pageX,cc.initY=cc.pointer.pageY,cc.initPos=e?yb.cur:Db.cur,cc.start=+new Date,cc.time=0,cc.path=0,cc.delta=0,cc.locked=0,cc.history=[0,0,0,0],cc.pathToLock=e?c?30:10:0,u.on(c?x:w,cb),sb.pause(1),(e?vb:Ab).addClass(rb.draggedClass),ob("moveStart"),e&&(fc=setInterval(_,10)))}function cb(a){if(cc.released="mouseup"===a.type||"touchend"===a.type,cc.pointer=cc.touch?a.originalEvent[cc.released?"changedTouches":"touches"][0]:a,cc.pathX=cc.pointer.pageX-cc.initX,cc.pathY=cc.pointer.pageY-cc.initY,cc.path=E(F(cc.pathX,2)+F(cc.pathY,2)),cc.delta=rb.horizontal?cc.pathX:cc.pathY,cc.released||!(cc.path<1)){if(!cc.init){if(!(rb.horizontal?D(cc.pathX)>D(cc.pathY):D(cc.pathX)<D(cc.pathY)))return db();cc.init=1}f(a),!cc.locked&&cc.path>cc.pathToLock&&cc.slidee&&(cc.locked=1,cc.$source.on(z,g)),cc.released&&(db(),rb.releaseSwing&&cc.slidee&&(cc.swing=(cc.delta-cc.history[0])/40*300,cc.delta+=cc.swing,cc.tweese=D(cc.swing)>10)),L(cc.slidee?G(cc.initPos-cc.delta):$(cc.initPos+cc.delta))}}function db(){clearInterval(fc),cc.released=!0,u.off(cc.touch?x:w,cb),(cc.slidee?vb:Ab).removeClass(rb.draggedClass),setTimeout(function(){cc.$source.off(z,g)}),yb.cur===yb.dest&&cc.init&&ob("moveEnd"),sb.resume(1),cc.init=0}function eb(b){return~a.inArray(b.nodeName,B)||a(b).is(rb.interactive)}function fb(){sb.stop(),u.off("mouseup",fb)}function gb(a){switch(f(a),this){case Ub[0]:case Vb[0]:sb.moveBy(Ub.is(this)?rb.moveBy:-rb.moveBy),u.on("mouseup",fb);break;case Wb[0]:sb.prev();break;case Xb[0]:sb.next();break;case Yb[0]:sb.prevPage();break;case Zb[0]:sb.nextPage()}}function hb(a){return dc.curDelta=(rb.horizontal?a.deltaY||a.deltaX:a.deltaY)||-a.wheelDelta,dc.curDelta/=1===a.deltaMode?3:100,Rb?(o=+new Date,dc.last<o-dc.resetTime&&(dc.delta=0),dc.last=o,dc.delta+=dc.curDelta,D(dc.delta)<1?dc.finalDelta=0:(dc.finalDelta=G(dc.delta/1),dc.delta%=1),dc.finalDelta):dc.curDelta}function ib(a){a.originalEvent[r]=sb;var b=+new Date;if(J+rb.scrollHijack>b&&Sb[0]!==document&&Sb[0]!==window)return void(J=b);if(rb.scrollBy&&yb.start!==yb.end){var c=hb(a.originalEvent);(rb.scrollTrap||c>0&&yb.dest<yb.end||0>c&&yb.dest>yb.start)&&f(a,1),sb.slideBy(rb.scrollBy*c)}}function jb(a){rb.clickBar&&a.target===zb[0]&&(f(a),L($((rb.horizontal?a.pageX-zb.offset().left:a.pageY-zb.offset().top)-Cb/2)))}function kb(a){if(rb.keyboardNavBy)switch(a.which){case rb.horizontal?37:38:f(a),sb["pages"===rb.keyboardNavBy?"prevPage":"prev"]();break;case rb.horizontal?39:40:f(a),sb["pages"===rb.keyboardNavBy?"nextPage":"next"]()}}function lb(a){return eb(this)?void(a.originalEvent[r+"ignore"]=!0):void(this.parentNode!==vb[0]||a.originalEvent[r+"ignore"]||sb.activate(this))}function mb(){this.parentNode===Eb[0]&&sb.activatePage(Fb.index(this))}function nb(a){rb.pauseOnHover&&sb["mouseenter"===a.type?"pause":"resume"](2)}function ob(a,b){if($b[a]){for(qb=$b[a].length,C.length=0,pb=0;qb>pb;pb++)C.push($b[a][pb]);for(pb=0;qb>pb;pb++)C[pb].call(sb,a,b)}}var pb,qb,rb=a.extend({},d.defaults,p),sb=this,tb=i(b),ub=a(b),vb=rb.slidee?a(rb.slidee).eq(0):ub.children().eq(0),wb=0,xb=0,yb={start:0,center:0,end:0,cur:0,dest:0},zb=a(rb.scrollBar).eq(0),Ab=zb.children().eq(0),Bb=0,Cb=0,Db={start:0,end:0,cur:0},Eb=a(rb.pagesBar),Fb=0,Gb=[],Hb=0,Ib=[],Jb={firstItem:0,lastItem:0,centerItem:0,activeItem:null,activePage:0},Kb=new l(ub[0]),Lb=new l(vb[0]),Mb=new l(zb[0]),Nb=new l(Ab[0]),Ob="basic"===rb.itemNav,Pb="forceCentered"===rb.itemNav,Qb="centered"===rb.itemNav||Pb,Rb=!tb&&(Ob||Qb||Pb),Sb=rb.scrollSource?a(rb.scrollSource):ub,Tb=rb.dragSource?a(rb.dragSource):ub,Ub=a(rb.forward),Vb=a(rb.backward),Wb=a(rb.prev),Xb=a(rb.next),Yb=a(rb.prevPage),Zb=a(rb.nextPage),$b={},_b={},ac={},bc={},cc={released:1},dc={last:0,delta:0,resetTime:200},ec=0,fc=0,gc=0,hc=0;tb||(b=ub[0]),sb.initialized=0,sb.frame=b,sb.slidee=vb[0],sb.pos=yb,sb.rel=Jb,sb.items=Ib,sb.pages=Gb,sb.isPaused=0,sb.options=rb,sb.dragging=cc,sb.reload=function(){K()},sb.getPos=function(a){if(Rb){var b=R(a);return-1!==b?Ib[b]:!1}var c=vb.find(a).eq(0);if(c[0]){var d=rb.horizontal?c.offset().left-vb.offset().left:c.offset().top-vb.offset().top,e=c[rb.horizontal?"outerWidth":"outerHeight"]();return{start:d,center:d-wb/2+e/2,end:d-wb+e,size:e}}return!1},sb.moveBy=function(a){bc.speed=a,!cc.init&&bc.speed&&yb.cur!==(bc.speed>0?yb.end:yb.start)&&(bc.lastTime=+new Date,bc.startPos=yb.cur,ab("button"),cc.init=1,ob("moveStart"),s(hc),P())},sb.stop=function(){"button"===cc.source&&(cc.init=0,cc.released=1)},sb.prev=function(){sb.activate(null==Jb.activeItem?0:Jb.activeItem-1)},sb.next=function(){sb.activate(null==Jb.activeItem?0:Jb.activeItem+1)},sb.prevPage=function(){sb.activatePage(Jb.activePage-1)},sb.nextPage=function(){sb.activatePage(Jb.activePage+1)},sb.slideBy=function(a,b){a&&(Rb?sb[Qb?"toCenter":"toStart"](k((Qb?Jb.centerItem:Jb.firstItem)+rb.scrollBy*a,0,Ib.length)):L(yb.dest+a,b))},sb.slideTo=function(a,b){L(a,b)},sb.toStart=function(a,b){Q("start",a,b)},sb.toEnd=function(a,b){Q("end",a,b)},sb.toCenter=function(a,b){Q("center",a,b)},sb.getIndex=R,sb.activate=function(a,b){var c=T(a);rb.smart&&c!==!1&&(Qb?sb.toCenter(c,b):c>=Jb.lastItem?sb.toStart(c,b):c<=Jb.firstItem?sb.toEnd(c,b):Z())},sb.activatePage=function(a,b){i(a)&&L(Gb[k(a,0,Gb.length-1)],b)},sb.resume=function(a){rb.cycleBy&&rb.cycleInterval&&("items"!==rb.cycleBy||Ib[0]&&null!=Jb.activeItem)&&!(a<sb.isPaused)&&(sb.isPaused=0,gc?gc=clearTimeout(gc):ob("resume"),gc=setTimeout(function(){switch(ob("cycle"),rb.cycleBy){case"items":sb.activate(Jb.activeItem>=Ib.length-1?0:Jb.activeItem+1);break;case"pages":sb.activatePage(Jb.activePage>=Gb.length-1?0:Jb.activePage+1)}},rb.cycleInterval))},sb.pause=function(a){a<sb.isPaused||(sb.isPaused=a||100,gc&&(gc=clearTimeout(gc),ob("pause")))},sb.toggle=function(){sb[gc?"pause":"resume"]()},sb.set=function(b,c){a.isPlainObject(b)?a.extend(rb,b):rb.hasOwnProperty(b)&&(rb[b]=c)},sb.add=function(b,c){var d=a(b);Rb?(null==c||!Ib[0]||c>=Ib.length?d.appendTo(vb):Ib.length&&d.insertBefore(Ib[c].el),null!=Jb.activeItem&&c<=Jb.activeItem&&(_b.active=Jb.activeItem+=d.length)):vb.append(d),K()},sb.remove=function(b){if(Rb){var c=S(b);if(c>-1){Hb.eq(c).remove();var d=c===Jb.activeItem;null!=Jb.activeItem&&c<Jb.activeItem&&(_b.active=--Jb.activeItem),K(),d&&(_b.active=null,sb.activate(Jb.activeItem))}}else a(b).remove(),K()},sb.moveAfter=function(a,b){X(a,b,1)},sb.moveBefore=function(a,b){X(a,b)},sb.on=function(a,b){if("object"===e(a))for(var c in a)a.hasOwnProperty(c)&&sb.on(c,a[c]);else if("function"===e(b))for(var d=a.split(" "),f=0,g=d.length;g>f;f++)$b[d[f]]=$b[d[f]]||[],-1===Y(d[f],b)&&$b[d[f]].push(b);else if("array"===e(b))for(var h=0,i=b.length;i>h;h++)sb.on(a,b[h])},sb.one=function(a,b){function c(){b.apply(sb,arguments),sb.off(a,c)}sb.on(a,c)},sb.off=function(a,b){if(b instanceof Array)for(var c=0,d=b.length;d>c;c++)sb.off(a,b[c]);else for(var e=a.split(" "),f=0,g=e.length;g>f;f++)if($b[e[f]]=$b[e[f]]||[],null==b)$b[e[f]].length=0;else{var h=Y(e[f],b);-1!==h&&$b[e[f]].splice(h,1)}},sb.destroy=function(){return Sb.add(Ab).add(zb).add(Eb).add(Ub).add(Vb).add(Wb).add(Xb).add(Yb).add(Zb).off("."+r),u.off("keydown",kb),Wb.add(Xb).add(Yb).add(Zb).removeClass(rb.disabledClass),Hb&&null!=Jb.activeItem&&Hb.eq(Jb.activeItem).removeClass(rb.activeClass),Eb.empty(),tb||(ub.off("."+r),Kb.restore(),Lb.restore(),Mb.restore(),Nb.restore(),a.removeData(b,r)),Ib.length=Gb.length=0,_b={},sb.initialized=0,sb},sb.init=function(){if(!sb.initialized){sb.on(q);var a=["overflow","position"],b=["position","webkitTransform","msTransform","transform","left","top","width","height"];Kb.save.apply(Kb,a),Mb.save.apply(Mb,a),Lb.save.apply(Lb,b),Nb.save.apply(Nb,b);var c=Ab;return tb||(c=c.add(vb),ub.css("overflow","hidden"),m||"static"!==ub.css("position")||ub.css("position","relative")),m?n&&c.css(m,n):("static"===zb.css("position")&&zb.css("position","relative"),c.css({position:"absolute"})),rb.forward&&Ub.on(A,gb),rb.backward&&Vb.on(A,gb),rb.prev&&Wb.on(z,gb),rb.next&&Xb.on(z,gb),rb.prevPage&&Yb.on(z,gb),rb.nextPage&&Zb.on(z,gb),Sb.on(y,ib),zb[0]&&zb.on(z,jb),Rb&&rb.activateOn&&ub.on(rb.activateOn+"."+r,"*",lb),Eb[0]&&rb.activatePageOn&&Eb.on(rb.activatePageOn+"."+r,"*",mb),Tb.on(v,{source:"slidee"},bb),Ab&&Ab.on(v,{source:"handle"},bb),u.on("keydown",kb),tb||(ub.on("mouseenter."+r+" mouseleave."+r,nb),ub.on("scroll."+r,h)),sb.initialized=1,K(!0),rb.cycleBy&&!tb&&sb[rb.startPaused?"pause":"resume"](),sb}}}function e(a){return null==a?String(a):"object"==typeof a||"function"==typeof a?Object.prototype.toString.call(a).match(/\s([a-z]+)/i)[1].toLowerCase()||"object":typeof a}function f(a,b){a.preventDefault(),b&&a.stopPropagation()}function g(b){f(b,1),a(this).off(b.type,g)}function h(){this.scrollLeft=0,this.scrollTop=0}function i(a){return!isNaN(parseFloat(a))&&isFinite(a)}function j(a,b){return 0|G(String(a.css(b)).replace(/[^\-0-9.]/g,""))}function k(a,b,c){return b>a?b:a>c?c:a}function l(a){var b={};return b.style={},b.save=function(){if(a&&a.nodeType){for(var c=0;c<arguments.length;c++)b.style[arguments[c]]=a.style[arguments[c]];return b}},b.restore=function(){if(a&&a.nodeType){for(var c in b.style)b.style.hasOwnProperty(c)&&(a.style[c]=b.style[c]);return b}},b}var m,n,o,p="sly",q="Sly",r=p,s=b.cancelAnimationFrame||b.cancelRequestAnimationFrame,t=b.requestAnimationFrame,u=a(document),v="touchstart."+r+" mousedown."+r,w="mousemove."+r+" mouseup."+r,x="touchmove."+r+" touchend."+r,y=(document.implementation.hasFeature("Event.wheel","3.0")?"wheel.":"mousewheel.")+r,z="click."+r,A="mousedown."+r,B=["INPUT","SELECT","BUTTON","TEXTAREA"],C=[],D=Math.abs,E=Math.sqrt,F=Math.pow,G=Math.round,H=Math.max,I=Math.min,J=0;u.on(y,function(a){var b=a.originalEvent[r],c=+new Date;(!b||b.options.scrollHijack<c-J)&&(J=c)}),function(a){function b(a){var b=(new Date).getTime(),d=Math.max(0,16-(b-c)),e=setTimeout(a,d);return c=b,e}t=a.requestAnimationFrame||a.webkitRequestAnimationFrame||b;var c=(new Date).getTime(),d=a.cancelAnimationFrame||a.webkitCancelAnimationFrame||a.clearTimeout;s=function(b){d.call(a,b)}}(window),function(){function a(a){for(var d=0,e=b.length;e>d;d++){var f=b[d]?b[d]+a.charAt(0).toUpperCase()+a.slice(1):a;if(null!=c.style[f])return f}}var b=["","webkit","moz","ms","o"],c=document.createElement("div");m=a("transform"),n=a("perspective")?"translateZ(0) ":""}(),b[q]=d,a.fn[p]=function(b,c){var f,g;return a.isPlainObject(b)||(("string"===e(b)||b===!1)&&(f=b===!1?"destroy":b,g=Array.prototype.slice.call(arguments,1)),b={}),this.each(function(e,h){var i=a.data(h,r);i||f?i&&f&&i[f]&&i[f].apply(i,g):i=a.data(h,r,new d(h,b,c).init())})},d.defaults={slidee:null,horizontal:!1,itemNav:null,itemSelector:null,smart:!1,activateOn:null,activateMiddle:!1,scrollSource:null,scrollBy:0,scrollHijack:300,scrollTrap:!1,dragSource:null,mouseDragging:!1,touchDragging:!1,releaseSwing:!1,swingSpeed:.2,elasticBounds:!1,interactive:null,scrollBar:null,dragHandle:!1,dynamicHandle:!1,minHandleSize:50,clickBar:!1,syncSpeed:.5,pagesBar:null,activatePageOn:null,pageBuilder:function(a){return"<li>"+(a+1)+"</li>"},forward:null,backward:null,prev:null,next:null,prevPage:null,nextPage:null,cycleBy:null,cycleInterval:5e3,pauseOnHover:!1,startPaused:!1,moveBy:300,speed:0,easing:"swing",startAt:null,keyboardNavBy:null,draggedClass:"dragged",activeClass:"active",disabledClass:"disabled"}}(jQuery,window);

;(function(plugin) {
    var chicago = window.Chicago || {
        utils : {
            now: Date.now || function() {
                return new Date().getTime();
            },
            uid : function(prefix) {
                return ( prefix || 'id' ) + chicago.utils.now() + 'RAND' + Math.ceil( Math.random() * 1e5 );
            },
            is : {
                number : function(obj) {
                    return ! isNaN( parseFloat( obj ) ) && isFinite( obj );
                },
                fn : function(obj) {
                    return typeof obj === 'function';
                },
                object : function(obj) {
                    return Object.prototype.toString.call(obj) === "[object Object]";
                }
            },
            debounce : function(fn, wait, immediate) {
                var timeout;
                return function() {
                    var context = this,
                        args = arguments,
                        later = function() {
                            timeout = null;
                            if ( ! immediate ) {
                                fn.apply( context, args );
                            }
                        },
                        callNow = immediate && !timeout;
                    if( timeout ) {
                        clearTimeout(timeout);
                    }
                    timeout = setTimeout( later, wait );
                    if( callNow ) {
                        fn.apply( context, args );
                    }
                };
            },
        },
        $ : window.jQuery || null
    };

    if(typeof define === 'function' && define.amd) {
        define('chicago', function() {
            chicago.load = function(res, req, onload, config) {
                var resources = res.split(','),
                    load = [];
                var base = ( config.config && config.config.chicago && config.config.chicago.base ? config.config.chicago.base : '' ).replace( /\/+$/g, '' );
                if( ! base ) {
                    throw new Error( 'Please define base path to jQuery resizeend in the requirejs config.' );
                }
                var i = 0;
                while(i < resources.length) {
                    var resource = resources[i].replace(/\./g, '/');
                    load.push(base + '/' + resource);
                    i += 1;
                }
                req(load, function() {
                    onload( chicago );
                });
            };
            return chicago;
        });
    }

    if( window && window.jQuery ) {
        return plugin( chicago, window, window.document );
    } else if( ! window.jQuery ) {
        throw new Error( 'jQuery resizeend requires jQuery' );
    }

})(function(_c, win, doc) {

    _c.$win = _c.$(win);
    _c.$doc = _c.$(doc);

    if( ! _c.events ) {
        _c.events = {};
    }

    _c.events.resizeend = {
        defaults : {
            delay : 250
        },
        setup : function() {
            var args = arguments,
                options = {
                    delay : _c.$.event.special.resizeend.defaults.delay
                },
                fn;

            if( _c.utils.is.fn( args[0] ) ) {
                fn = args[0];
            } else if( _c.utils.is.number( args[0] ) ) {
                options.delay = args[0];
            } else if( _c.utils.is.object( args[0] ) ) {
                options = _c.$.extend({}, options, args[0]);
            }

            var uid = _c.utils.uid('resizeend'),
                _data = _c.$.extend({
                    delay : _c.$.event.special.resizeend.defaults.delay
                }, options),
                timer = _data,
                handler = function(e) {
                    if(timer) {
                        clearTimeout(timer);
                    }
                    timer = setTimeout(function() {
                        timer = null;
                        e.type = 'resizeend.chicago.dom';
                        return _c.$(e.target).trigger('resizeend', e);
                    }, _data.delay);
                };
            _c.$(this).data('chicago.event.resizeend.uid', uid);
            return _c.$(this).on('resize', _c.utils.debounce(handler, 100)).data(uid, handler);
        },
        teardown : function() {
            var uid = _c.$(this).data('chicago.event.resizeend.uid');
            _c.$(this).off('resize', _c.$(this).data(uid));
            _c.$(this).removeData(uid);
            return _c.$(this).removeData('chicago.event.resizeend.uid');
        }
    };

    (function() {
        _c.$.event.special.resizeend = _c.events.resizeend;
        _c.$.fn.resizeend = function(options, callback) {
            return this.each(function() {
                _c.$(this).on('resizeend', options, callback);
            });
        };
    })();
});

(function (factory) {
	if (typeof define === 'function' && define.amd) {
		// AMD
		define(['jquery'], factory);
	} else if (typeof exports === 'object') {
		// CommonJS
		module.exports = factory;
	} else {
		// Browser globals
		factory(jQuery);
	}
});

(function( $ ){

	var defaults = {
		obj_main: null,

		width: 0,
		height: 0,

		dynamicHeight: false,

		text_backLink: '<i><</i> zurück',

		css_mainClass: 'sMultiMenu',
		css_page: 'sMultiMenu_page',
		css_pageBehind: 'sMultiMenu_pageBehind',
		css_backSide: 'sMultiMenu_backSide',
		css_backLink: 'sMultiMenu_backLink',
	};

    var elem, options, methods = {
    	init: function(customOptions) {
            return this.each(function () {
            	if (customOptions) {
                    options = $.extend( {}, defaults, customOptions);;
                }
            	methods.init2(this);
            });
		},

		init2: function(iElem){
			options.obj_main = iElem;

			// Allgemein
			$(iElem).addClass(options.css_mainClass);


			// Umschliessene Divs
			$(iElem).find('LI').each(function(index, item){
				if($(this).children('h2').length > 0){
					var tmpDiv = $('<div></div>').addClass(options.css_page)
												.append($(this).children(':not(a)'));

					var backLink = $('<a></a>').attr('href', '#')
												.addClass(options.css_backLink)
												.html(options.text_backLink)
												.on('click', function(){
													methods.check_backLink(this);
													return false;
												});
					backLink.insertAfter(tmpDiv.children('H2'));

					$(this).append(tmpDiv);
				}
			});

			// Link Events
			$(iElem).find('A').not('.nosub').on('click', function(){
				if($(this).next().is('.' + options.css_page)){
					var tmpBackSide = $('<a></a>').addClass(options.css_backSide)
													.attr('href', '#')
													.html($('<span></span>').html( ($(this).closest('.' + options.css_page).length > 0)?$(this).closest('.' + options.css_page).children('H2').html():$(this).closest('nav').children('H2').html()))
													.on('click', function(){
														methods.check_backLink(this);
														return false;
													});

					if($(this).closest('.' + options.css_page).length > 0){
						$(this).closest('.' + options.css_page)
								.addClass(options.css_pageBehind)
								.prepend(tmpBackSide);
					}else{
						$(this).closest('nav')
								.addClass(options.css_pageBehind)
								.prepend(tmpBackSide);
					}
					$(this).next('.' + options.css_page).removeClass('slideOutRight').addClass('animated slideInRight').show();

					methods.updateSize();
					return false;
				}
			}).each(function(){
				if($(this).parent().children('.' + options.css_page).length > 0){
					$(this).append($('<i></i>').html('>'));
				}
			});

			// Size
			methods.updateSize();

			$(iElem).on('resize orientationchange', function(){
				methods.updateSize();
			});
		},

		updateSize: function(){
			var tmpMaxHeight = 0;

			options.width = $(options.obj_main).width();

			if(options.dynamicHeight == true) {
				var tmpHeight = 0;
				$(options.obj_main).find('nav').children().each(function(index, item){
					tmpHeight += $(item).outerHeight(true);
				});

				tmpMaxHeight = tmpHeight

				$(options.obj_main).find('.' + options.css_page).each(function(index, item){
					if($(this).hasClass('slideOutRight')){
					}else{
						var tmpHeight = 0;
						$(this).children().each(function(iIndex, iItem){
							tmpHeight += $(this).outerHeight(true);
						});
						if(tmpHeight > tmpMaxHeight){
							tmpMaxHeight = tmpHeight
						}
					}
				});
				options.height = tmpMaxHeight;
			}

			if(options.dynamicHeight != true || tmpMaxHeight == 0) {
				options.height = $(options.obj_main).height();
			}


			$(options.obj_main).children('nav').width(options.width);
			$(options.obj_main).children('nav').height(options.height);
		},

		check_backLink: function(linkElem){
			if($(linkElem).hasClass(options.css_backSide)){

				$(linkElem).parent()
						.removeClass(options.css_pageBehind)
						.find('.' + options.css_page)
						.removeClass(options.css_pageBehind)
						.removeClass('slideInRight')
						.addClass('slideOutRight');
						//.removeClass(options.css_pageBehind)
						//.hide();
				$(linkElem).parent().find('.' + options.css_backSide).remove();
				$(linkElem).remove();

			}else{
				if($(linkElem).closest('.' + options.css_page).parent().closest('.' + options.css_page).length > 0){
					$(linkElem).closest('.' + options.css_page)
								.parent()
								.closest('.' + options.css_page)
								.removeClass(options.css_pageBehind)
								.children('.' + options.css_backSide)
								.remove();
				}else{
					$(linkElem).closest('nav')
								.removeClass(options.css_pageBehind)
								.children('.' + options.css_backSide)
								.remove();
				}
				$(linkElem).parent().removeClass('slideInRight').addClass('slideOutRight');
			}
			methods.updateSize();
		},


    }


    $.fn.sMultiMenu = function (method) {
        if ( methods[method] ) {
            return methods[method].apply( this, Array.prototype.slice.call( arguments, 1 ));
        } else if ( typeof method === 'object' || ! method ) {
            return methods.init.apply( this, arguments );
        } else {
            $.error( 'Method ' + method + ' does not exist on jQuery.myplugin' );
        }
    };



})( jQuery );


/*!
 * VERSION: 1.11.2
 * DATE: 2013-11-20
 * UPDATES AND DOCS AT: http://www.greensock.com
 * @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
 * This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
 * Club GreenSock members, the software agreement that was issued with your membership.
 *
 * @author: Jack Doyle, jack@greensock.com
 */
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('(17(e){"5v 5u";19 t=e.6h||e;1a(!t.5c){19 n,r,i,s,o,u=17(e){19 n,r=e.1s("."),i=t;1b(n=0;r.1c>n;n++)i[r[n]]=i=i[r[n]]||{};18 i},a=u("4F.4A"),f=1e-10,l=[].6G,c=17(){},h=17(){19 e=9h.1x.9i,t=e.1Z([]);18 17(n){18 n 2a 3K||"3T"==1j n&&!!n.28&&e.1Z(n)===t}}(),p={},d=17(n,r,i,s){15.4v=p[n]?p[n].4v:[],p[n]=15,15.5a=1d,15.76=i;19 o=[];15.5F=17(a){1b(19 f,l,c,h,v=r.1c,m=v;--v>-1;)(f=p[r[v]]||1g d(r[v],[])).5a?(o[v]=f.5a,m--):a&&f.4v.28(15);1a(0===m&&i)1b(l=("4F.4A."+n).1s("."),c=l.4G(),h=u(l.1G("."))[c]=15.5a=i.36(i,o),s&&(t[c]=h,"17"==1j 5V&&5V.9j?5V((e.8F?e.8F+"/":"")+n.1s(".").1G("/"),[],17(){18 h}):"9f"!=1j 5E&&5E.8A&&(5E.8A=h)),v=0;15.4v.1c>v;v++)15.4v[v].5F()},15.5F(!0)},v=e.3R=17(e,t,n,r){18 1g d(e,t,n,r)},m=a.7W=17(e,t,n){18 t=t||17(){},v(e,[],17(){18 t},n),t};v.97=t;19 g=[0,0,1,1],y=[],b=m("2j.7v",17(e,t,n,r){15.5B=e,15.6j=n||0,15.6g=r||0,15.5C=t?g.3U(t):g},!0),w=b.7Z={},E=b.7X=17(e,t,n,r){1b(19 i,s,o,u,f=t.1s(","),l=f.1c,c=(n||"5s,5R,5r").1s(",");--l>-1;)1b(s=f[l],i=r?m("2j."+s,1d,!0):a.2j[s]||{},o=c.1c;--o>-1;)u=c[o],w[s+"."+u]=w[u+s]=i[u]=e.2x?e:e[u]||1g e};1b(i=b.1x,i.3m=!1,i.2x=17(e){1a(15.5B)18 15.5C[0]=e,15.5B.36(1d,15.5C);19 t=15.6j,n=15.6g,r=1===t?1-e:2===t?e:.5>e?2*e:2*(1-e);18 1===n?r*=r:2===n?r*=r*r:3===n?r*=r*r*r:4===n&&(r*=r*r*r*r),1===t?1-r:2===t?r:.5>e?r/2:1-r/2},n=["8u","8w","9a","9c","9l,9x"],r=n.1c;--r>-1;)i=n[r]+",9y"+r,E(1g b(1d,1d,1,r),i,"5R",!0),E(1g b(1d,1d,2,r),i,"5s"+(0===r?",96":"")),E(1g b(1d,1d,3,r),i,"5r");w.9s=a.2j.8u.5s,w.9o=a.2j.8w.5r;19 S=m("8m.8q",17(e){15.40={},15.8r=e||15});i=S.1x,i.8M=17(e,t,n,r,i){i=i||0;19 u,a,f=15.40[e],l=0;1b(1d==f&&(15.40[e]=f=[]),a=f.1c;--a>-1;)u=f[a],u.c===t&&u.s===n?f.2W(a,1):0===l&&i>u.2s&&(l=a+1);f.2W(l,0,{c:t,s:n,8o:r,2s:i}),15!==s||o||s.3a()},i.9n=17(e,t){19 n,r=15.40[e];1a(r)1b(n=r.1c;--n>-1;)1a(r[n].c===t)18 r.2W(n,1),2u 0},i.8C=17(e){19 t,n,r,i=15.40[e];1a(i)1b(t=i.1c,n=15.8r;--t>-1;)r=i[t],r.8o?r.c.1Z(r.s||n,{2r:e,2v:n}):r.c.1Z(r.s||n)};19 x=e.9z,T=e.8S,N=8l.95||17(){18(1g 8l).92()},C=N();1b(n=["64","8W","91","o"],r=n.1c;--r>-1&&!x;)x=e[n[r]+"8Z"],T=e[n[r]+"93"]||e[n[r]+"8U"];m("52",17(e,t){19 n,r,i,u,a,f=15,l=N(),h=t!==!1&&x,p=17(e){C=N(),f.3u=(C-l)/8d;19 t,s=f.3u-a;(!n||s>0||e===!0)&&(f.41++,a+=s+(s>=u?.9t:u-s),t=!0),e!==!0&&(i=r(p)),t&&f.8C("5y")};S.1Z(f),f.3u=f.41=0,f.5y=17(){p(!0)},f.4X=17(){1d!=i&&(h&&T?T(i):aa(i),r=c,i=1d,f===s&&(o=!1))},f.3a=17(){1d!==i&&f.4X(),r=0===n?c:h&&x?x:17(e){18 6p(e,0|8d*(a-f.3u)+1)},f===s&&(o=!0),p(2)},f.6f=17(e){18 22.1c?(n=e,u=1/(n||60),a=15.3u+u,f.3a(),2u 0):n},f.8e=17(e){18 22.1c?(f.4X(),h=e,f.6f(n),2u 0):h},f.6f(e),6p(17(){h&&(!i||5>f.41)&&f.8e(!1)},af)}),i=a.52.1x=1g a.8m.8q,i.2M=a.52;19 k=m("5k.72",17(e,t){1a(15.1o=t=t||{},15.1N=15.2l=e||0,15.2J=1C(t.4y)||0,15.1y=1,15.2c=t.1V===!0,15.1z=t.1z,15.2G=t.43===!0,q){o||s.3a();19 n=15.1o.5Q?I:q;n.1P(15,n.1n),15.1o.34&&15.34(!0)}});s=k.8h=1g a.52,i=k.1x,i.2o=i.1I=i.2w=i.1A=!1,i.1K=i.1n=0,i.1O=-1,i.1f=i.3h=i.32=i.1p=i.1U=1d,i.1A=!1;19 L=17(){o&&N()-C>8p&&s.3a(),6p(L,8p)};L(),i.7w=17(e,t){18 22.1c&&15.4e(e,t),15.43(!1).34(!1)},i.6c=17(e,t){18 22.1c&&15.4e(e,t),15.34(!0)},i.aB=17(e,t){18 22.1c&&15.4e(e,t),15.34(!1)},i.4e=17(e,t){18 15.2Z(1C(e),t!==!1)},i.ar=17(e,t){18 15.43(!1).34(!1).2Z(e?-15.2J:0,t!==!1,!0)},i.as=17(e,t){18 22.1c&&15.4e(e||15.26(),t),15.43(!0).34(!1)},i.1B=17(){},i.5i=17(){18 15},i.4O=17(){19 e,t=15.1p,n=15.1i;18!t||!15.1I&&!15.1A&&t.4O()&&(e=t.3y())>=n&&n+15.26()/15.1y>e},i.1M=17(e,t){18 o||s.3a(),15.1I=!e,15.2c=15.4O(),t!==!0&&(e&&!15.1U?15.1p.1P(15,15.1i-15.2J):!e&&15.1U&&15.1p.3C(15,!0)),!1},i.2p=17(){18 15.1M(!1,!1)},i.4c=17(e,t){18 15.2p(e,t),15},i.35=17(e){1b(19 t=e?15:15.1U;t;)t.2o=!0,t=t.1U;18 15},i.5o=17(e){1b(19 t=e.1c,n=e.3U();--t>-1;)"{4t}"===e[t]&&(n[t]=15);18 n},i.aw=17(e,t,n,r){1a("a8"===(e||"").1t(0,2)){19 i=15.1o;1a(1===22.1c)18 i[e];1d==t?3L i[e]:(i[e]=t,i[e+"6o"]=h(n)&&-1!==n.1G("").1k("{4t}")?15.5o(n):n,i[e+"6l"]=r),"5q"===e&&(15.32=t)}18 15},i.4y=17(e){18 22.1c?(15.1p.2F&&15.8f(15.1i+e-15.2J),15.2J=e,15):15.2J},i.2C=17(e){18 22.1c?(15.1N=15.2l=e,15.35(!0),15.1p.2F&&15.1n>0&&15.1n<15.1N&&0!==e&&15.2Z(15.1K*(e/15.1N),!0),15):(15.2o=!1,15.1N)},i.26=17(e){18 15.2o=!1,22.1c?15.2C(e):15.2l},i.3u=17(e,t){18 22.1c?(15.2o&&15.26(),15.2Z(e>15.1N?15.1N:e,t)):15.1n},i.2Z=17(e,t,n){1a(o||s.3a(),!22.1c)18 15.1K;1a(15.1p){1a(0>e&&!n&&(e+=15.26()),15.1p.2F){15.2o&&15.26();19 r=15.2l,i=15.1p;1a(e>r&&!n&&(e=r),15.1i=(15.1A?15.4D:i.1n)-(15.2G?r-e:e)/15.1y,i.2o||15.35(!1),i.1p)1b(;i.1p;)i.1p.1n!==(i.1i+i.1K)/i.1y&&i.2Z(i.1K,!0),i=i.1p}15.1I&&15.1M(!0,!1),(15.1K!==e||0===15.1N)&&15.1B(e,t,!1)}18 15},i.9N=i.9P=17(e,t){18 22.1c?15.2Z(15.2C()*e,t):15.1n/15.2C()},i.8f=17(e){18 22.1c?(e!==15.1i&&(15.1i=e,15.1U&&15.1U.4J&&15.1U.1P(15,e-15.2J)),15):15.1i},i.5N=17(e){1a(!22.1c)18 15.1y;1a(e=e||f,15.1p&&15.1p.2F){19 t=15.4D,n=t||0===t?t:15.1p.2Z();15.1i=n-(n-15.1i)*15.1y/e}18 15.1y=e,15.35(!1)},i.43=17(e){18 22.1c?(e!=15.2G&&(15.2G=e,15.2Z(15.1K,!0)),15):15.2G},i.34=17(e){1a(!22.1c)18 15.1A;1a(e!=15.1A&&15.1p){o||e||s.3a();19 t=15.1p,n=t.3y(),r=n-15.4D;!e&&t.2F&&(15.1i+=r,15.35(!1)),15.4D=e?n:1d,15.1A=e,15.2c=15.4O(),!e&&0!==r&&15.2w&&15.2C()&&15.1B(t.2F?15.1K:(n-15.1i)/15.1y,!0,!0)}18 15.1I&&!e&&15.1M(!0,!1),15};19 A=m("5k.7n",17(e){k.1Z(15,0,e),15.4P=15.2F=!0});i=A.1x=1g k,i.2M=A,i.4c().1I=!1,i.27=i.3h=1d,i.4J=!1,i.1P=i.84=17(e,t){19 n,r;1a(e.1i=1C(t||0)+e.2J,e.1A&&15!==e.1p&&(e.4D=e.1i+(15.3y()-e.1i)/e.1y),e.1U&&e.1U.3C(e,!0),e.1U=e.1p=15,e.1I&&e.1M(!0,!0),n=15.3h,15.4J)1b(r=e.1i;n&&n.1i>r;)n=n.1l;18 n?(e.1f=n.1f,n.1f=e):(e.1f=15.27,15.27=e),e.1f?e.1f.1l=e:15.3h=e,e.1l=n,15.1p&&15.35(!0),15},i.3C=17(e,t){18 e.1U===15&&(t||e.1M(!1,!0),e.1U=1d,e.1l?e.1l.1f=e.1f:15.27===e&&(15.27=e.1f),e.1f?e.1f.1l=e.1l:15.3h===e&&(15.3h=e.1l),15.1p&&15.35(!0)),15},i.1B=17(e,t,n){19 r,i=15.27;1b(15.1K=15.1n=15.1O=e;i;)r=i.1f,(i.2c||e>=i.1i&&!i.1A)&&(i.2G?i.1B((i.2o?i.26():i.2l)-(e-i.1i)*i.1y,t,n):i.1B((e-i.1i)*i.1y,t,n)),i=r},i.3y=17(){18 o||s.3a(),15.1K};19 O=m("5c",17(t,n,r){1a(k.1Z(15,n,r),15.1B=O.1x.1B,1d==t)5W"87 6v a 1d 2v.";15.2v=t="1H"!=1j t?t:O.3w(t)||t;19 i,s,o,u=t.9I||t.1c&&t!==e&&t[0]&&(t[0]===e||t[0].3o&&t[0].1v&&!t.3o),a=15.1o.4L;1a(15.5S=a=1d==a?F[O.8i]:"2t"==1j a?a>>0:F[a],(u||t 2a 3K||t.28&&h(t))&&"2t"!=1j t[0])1b(15.2z=o=l.1Z(t,0),15.3A=[],15.2Y=[],i=0;o.1c>i;i++)s=o[i],s?"1H"!=1j s?s.1c&&s!==e&&s[0]&&(s[0]===e||s[0].3o&&s[0].1v&&!s.3o)?(o.2W(i--,1),15.2z=o=o.3U(l.1Z(s,0))):(15.2Y[i]=R(s,15,!1),1===a&&15.2Y[i].1c>1&&U(s,15,1d,1,15.2Y[i])):(s=o[i--]=O.3w(s),"1H"==1j s&&o.2W(i+1,1)):o.2W(i--,1);1m 15.3A={},15.2Y=R(t,15,!1),1===a&&15.2Y.1c>1&&U(t,15,1d,1,15.2Y);(15.1o.1V||0===n&&0===15.2J&&15.1o.1V!==!1)&&15.1B(-15.2J,!1,!0)},!0),M=17(t){18 t.1c&&t!==e&&t[0]&&(t[0]===e||t[0].3o&&t[0].1v&&!t.3o)},2q=17(e,t){19 n,r={};1b(n 1w e)j[n]||n 1w t&&"x"!==n&&"y"!==n&&"3M"!==n&&"3B"!==n&&"39"!==n&&"3X"!==n||!(!P[n]||P[n]&&P[n].9D)||(r[n]=e[n],3L e[n]);e.4s=r};i=O.1x=1g k,i.2M=O,i.4c().1I=!1,i.3i=0,i.1r=i.2z=i.3f=i.29=1d,i.4I=!1,O.3Z="1.11.2",O.6n=i.2H=1g b(1d,1d,1,1),O.8i="2n",O.8h=s,O.8J=!0,O.3w=e.$||e.9C||17(t){18 e.$?(O.3w=e.$,e.$(t)):e.69?e.69.9G("#"===t.1u(0)?t.1t(1):t):t};19 D=O.4p={7T:h,7U:M},P=O.9R={},H=O.a2={},B=0,j=D.7i={3Q:1,4y:1,4L:1,4i:1,61:1,62:1,5Q:1,4C:1,38:1,5q:1,67:1,6b:1,4B:1,5D:1,63:1,4j:1,7b:1,7o:1,a3:1,a4:1,a6:1,5p:1,a5:1,1V:1,a0:1,9Z:1,1z:1,34:1,43:1,5A:1},F={3r:0,3Y:1,2n:2,9U:3,9T:4,9S:5,"9V":1,"5O":0},I=k.6Y=1g A,q=k.9W=1g A;q.1i=s.3u,I.1i=s.41,q.2c=I.2c=!0,k.86=17(){1a(q.1B((s.3u-q.1i)*q.1y,!1,!1),I.1B((s.41-I.1i)*I.1y,!1,!1),!(s.41%9Y)){19 e,t,n;1b(n 1w H){1b(t=H[n].3x,e=t.1c;--e>-1;)t[e].1I&&t.2W(e,1);0===t.1c&&3L H[n]}1a(n=q.27,(!n||n.1A)&&O.8J&&!I.27&&1===s.40.5y.1c){1b(;n&&n.1A;)n=n.1f;n||s.4X()}}},s.8M("5y",k.86);19 R=17(e,t,n){19 r,i,s=e.7h;1a(H[s||(e.7h=s="t"+B++)]||(H[s]={2v:e,3x:[]}),t&&(r=H[s].3x,r[i=r.1c]=t,n))1b(;--i>-1;)r[i]===t&&r.2W(i,1);18 H[s].3x},U=17(e,t,n,r,i){19 s,o,u,a;1a(1===r||r>=4){1b(a=i.1c,s=0;a>s;s++)1a((u=i[s])!==t)u.1I||u.1M(!1,!1)&&(o=!0);1m 1a(5===r)7p;18 o}19 l,c=t.1i+f,h=[],p=0,d=0===t.1N;1b(s=i.1c;--s>-1;)(u=i[s])===t||u.1I||u.1A||(u.1p!==t.1p?(l=l||z(t,0,d),0===z(u,l,d)&&(h[p++]=u)):c>=u.1i&&u.1i+u.26()/u.1y+f>c&&((d||!u.2w)&&2e-10>=c-u.1i||(h[p++]=u)));1b(s=p;--s>-1;)u=h[s],2===r&&u.2p(n,e)&&(o=!0),(2!==r||!u.1r&&u.2w)&&u.1M(!1,!1)&&(o=!0);18 o},z=17(e,t,n){1b(19 r=e.1p,i=r.1y,s=e.1i;r.1p;){1a(s+=r.1i,i*=r.1y,r.1A)18-23;r=r.1p}18 s/=i,s>t?s-t:n&&s===t||!e.2w&&2*f>s-t?f:(s+=e.26()/e.1y/i)>t+f?0:s-t-f};i.7c=17(){19 e,t,n,r,i=15.1o,s=15.3f,o=15.1N,u=i.1V,a=i.3Q;1a(i.38){1a(15.29&&15.29.1B(-1,!0),i.38.4L=0,i.38.1V=!0,15.29=O.3v(15.2v,0,i.38),u)1a(15.1n>0)15.29=1d;1m 1a(0!==o)18}1m 1a(i.4C&&0!==o)1a(15.29)15.29.1B(-1,!0),15.29=1d;1m{n={};1b(r 1w i)j[r]&&"5A"!==r||(n[r]=i[r]);1a(n.4L=0,n.1z="7G",15.29=O.3v(15.2v,0,n),i.1V){1a(0===15.1n)18}1m 15.29.1B(-1,!0)}1a(15.2H=a?a 2a b?i.5p 2a 3K?a.3t.36(a,i.5p):a:"17"==1j a?1g b(a,i.5p):w[a]||O.6n:O.6n,15.5P=15.2H.6j,15.7f=15.2H.6g,15.1r=1d,15.2z)1b(e=15.2z.1c;--e>-1;)15.4o(15.2z[e],15.3A[e]={},15.2Y[e],s?s[e]:1d)&&(t=!0);1m t=15.4o(15.2v,15.3A,15.2Y,s);1a(t&&O.4U("4Z",15),s&&(15.1r||"17"!=1j 15.2v&&15.1M(!1,!1)),i.4C)1b(n=15.1r;n;)n.s+=n.c,n.c=-n.c,n=n.1f;15.32=i.5q,15.2w=!0},i.4o=17(t,n,r,i){19 s,o,u,a,f,l;1a(1d==t)18!1;15.1o.4s||t.1v&&t!==e&&t.3o&&P.4s&&15.1o.5A!==!1&&2q(15.1o,t);1b(s 1w 15.1o){1a(l=15.1o[s],j[s])l&&(l 2a 3K||l.28&&h(l))&&-1!==l.1G("").1k("{4t}")&&(15.1o[s]=l=15.5o(l,15));1m 1a(P[s]&&(a=1g P[s]).6M(t,15.1o[s],15)){1b(15.1r=f={1f:15.1r,t:a,p:"1X",s:0,c:1,f:!0,n:s,4M:!0,2s:a.5T},o=a.2E.1c;--o>-1;)n[a.2E[o]]=15.1r;(a.5T||a.4Z)&&(u=!0),(a.6q||a.89)&&(15.4I=!0)}1m 15.1r=n[s]=f={1f:15.1r,t:t,p:s,f:"17"==1j t[s],n:s,4M:!1,2s:0},f.s=f.f?t[s.1k("4h")||"17"!=1j t["7g"+s.1t(3)]?s:"7g"+s.1t(3)]():1q(t[s]),f.c="1H"==1j l&&"="===l.1u(1)?3q(l.1u(0)+"1",10)*1C(l.1t(2)):1C(l)-f.s||0;f&&f.1f&&(f.1f.1l=f)}18 i&&15.2p(i,t)?15.4o(t,n,r,i):15.5S>1&&15.1r&&r.1c>1&&U(t,15,n,15.5S,r)?(15.2p(n,t),15.4o(t,n,r,i)):u},i.1B=17(e,t,n){19 r,i,s,o,u=15.1n,a=15.1N;1a(e>=a)15.1K=15.1n=a,15.3i=15.2H.3m?15.2H.2x(1):1,15.2G||(r=!0,i="4i"),0===a&&(o=15.1O,(0===e||0>o||o===f)&&o!==e&&(n=!0,o>f&&(i="4j")),15.1O=o=!t||e?e:f);1m 1a(1e-7>e)15.1K=15.1n=0,15.3i=15.2H.3m?15.2H.2x(0):0,(0!==u||0===a&&15.1O>f)&&(i="4j",r=15.2G),0>e?(15.2c=!1,0===a&&(15.1O>=0&&(n=!0),15.1O=o=!t||e?e:f)):15.2w||(n=!0);1m 1a(15.1K=15.1n=e,15.5P){19 l=e/a,c=15.5P,h=15.7f;(1===c||3===c&&l>=.5)&&(l=1-l),3===c&&(l*=2),1===h?l*=l:2===h?l*=l*l:3===h?l*=l*l*l:4===h&&(l*=l*l*l*l),15.3i=1===c?1-l:2===c?l:.5>e/a?l/2:1-l/2}1m 15.3i=15.2H.2x(e/a);1a(15.1n!==u||n){1a(!15.2w){1a(15.7c(),!15.2w||15.1I)18;15.1n&&!r?15.3i=15.2H.2x(15.1n/a):r&&15.2H.3m&&(15.3i=15.2H.2x(0===15.1n?0:1))}1b(15.2c||!15.1A&&15.1n!==u&&e>=0&&(15.2c=!0),0===u&&(15.29&&(e>=0?15.29.1B(e,t,n):i||(i="a1")),15.1o.4B&&(0!==15.1n||0===a)&&(t||15.1o.4B.36(15.1o.63||15,15.1o.5D||y))),s=15.1r;s;)s.f?s.t[s.p](s.c*15.3i+s.s):s.t[s.p]=s.c*15.3i+s.s,s=s.1f;15.32&&(0>e&&15.29&&15.1i&&15.29.1B(e,t,n),t||n&&0===15.1n&&0===u||15.32.36(15.1o.6b||15,15.1o.67||y)),i&&(15.1I||(0>e&&15.29&&!15.32&&15.1i&&15.29.1B(e,t,n),r&&(15.1p.4P&&15.1M(!1,!1),15.2c=!1),!t&&15.1o[i]&&15.1o[i].36(15.1o[i+"6l"]||15,15.1o[i+"6o"]||y),0===a&&15.1O===f&&o!==f&&(15.1O=0)))}},i.2p=17(e,t){1a("3Y"===e&&(e=1d),1d==e&&(1d==t||t===15.2v))18 15.1M(!1,!1);t="1H"!=1j t?t||15.2z||15.2v:O.3w(t)||t;19 n,r,i,s,o,u,a,f;1a((h(t)||M(t))&&"2t"!=1j t[0])1b(n=t.1c;--n>-1;)15.2p(e,t[n])&&(u=!0);1m{1a(15.2z){1b(n=15.2z.1c;--n>-1;)1a(t===15.2z[n]){o=15.3A[n]||{},15.3f=15.3f||[],r=15.3f[n]=e?15.3f[n]||{}:"3Y";7p}}1m{1a(t!==15.2v)18!1;o=15.3A,r=15.3f=e?15.3f||{}:"3Y"}1a(o){a=e||o,f=e!==r&&"3Y"!==r&&e!==o&&("3T"!=1j e||!e.9Q);1b(i 1w a)(s=o[i])&&(s.4M&&s.t.2p(a)&&(u=!0),s.4M&&0!==s.t.2E.1c||(s.1l?s.1l.1f=s.1f:s===15.1r&&(15.1r=s.1f),s.1f&&(s.1f.1l=s.1l),s.1f=s.1l=1d),3L o[i]),f&&(r[i]=1);!15.1r&&15.2w&&15.1M(!1,!1)}}18 u},i.5i=17(){18 15.4I&&O.4U("6q",15),15.1r=1d,15.3f=1d,15.32=1d,15.29=1d,15.2w=15.2c=15.4I=!1,15.3A=15.2z?{}:[],15},i.1M=17(e,t){1a(o||s.3a(),e&&15.1I){19 n,r=15.2z;1a(r)1b(n=r.1c;--n>-1;)15.2Y[n]=R(r[n],15,!0);1m 15.2Y=R(15.2v,15,!0)}18 k.1x.1M.1Z(15,e,t),15.4I&&15.1r?O.4U(e?"89":"6q",15):!1},O.3v=17(e,t,n){18 1g O(e,t,n)},O.68=17(e,t,n){18 n.4C=!0,n.1V=0!=n.1V,1g O(e,t,n)},O.66=17(e,t,n,r){18 r.38=n,r.1V=0!=r.1V&&0!=n.1V,1g O(e,t,r)},O.6k=17(e,t,n,r,i){18 1g O(t,0,{4y:e,4i:t,61:n,62:r,4j:t,7b:n,7o:r,1V:!1,5Q:i,4L:0})},O.4h=17(e,t){18 1g O(e,0,t)},O.3W=17(e,t){1a(1d==e)18[];e="1H"!=1j e?e:O.3w(e)||e;19 n,r,i,s;1a((h(e)||M(e))&&"2t"!=1j e[0]){1b(n=e.1c,r=[];--n>-1;)r=r.3U(O.3W(e[n],t));1b(n=r.1c;--n>-1;)1b(s=r[n],i=n;--i>-1;)s===r[i]&&r.2W(n,1)}1m 1b(r=R(e).3U(),n=r.1c;--n>-1;)(r[n].1I||t&&!r[n].4O())&&r.2W(n,1);18 r},O.9J=O.9O=17(e,t,n){"3T"==1j t&&(n=t,t=!1);1b(19 r=O.3W(e,t),i=r.1c;--i>-1;)r[i].2p(n,e)};19 W=m("4z.7Q",17(e,t){15.2E=(e||"").1s(","),15.4N=15.2E[0],15.5T=t||0,15.9M=W.1x},!0);1a(i=W.1x,W.3Z="1.10.1",W.3J=2,i.1r=1d,i.9K=17(e,t,n,r,i,s){19 o,u;18 1d!=r&&(o="2t"==1j r||"="!==r.1u(1)?1C(r)-n:3q(r.1u(0)+"1",10)*1C(r.1t(2)))?(15.1r=u={1f:15.1r,t:e,p:t,s:n,c:o,f:"17"==1j e[t],n:i||t,r:s},u.1f&&(u.1f.1l=u),u):2u 0},i.1X=17(e){1b(19 t,n=15.1r,r=1e-6;n;)t=n.c*e+n.s,n.r?t=0|t+(t>0?.5:-.5):r>t&&t>-r&&(t=0),n.f?n.t[n.p](t):n.t[n.p]=t,n=n.1f},i.2p=17(e){19 t,n=15.2E,r=15.1r;1a(1d!=e[15.4N])15.2E=[];1m 1b(t=n.1c;--t>-1;)1d!=e[n[t]]&&n.2W(t,1);1b(;r;)1d!=e[r.n]&&(r.1f&&(r.1f.1l=r.1l),r.1l?(r.1l.1f=r.1f,r.1l=1d):15.1r===r&&(15.1r=r.1f)),r=r.1f;18!1},i.71=17(e,t){1b(19 n=15.1r;n;)(e[15.4N]||1d!=n.n&&e[n.n.1s(15.4N+"2q").1G("")])&&(n.r=t),n=n.1f},O.4U=17(e,t){19 n,r,i,s,o,u=t.1r;1a("4Z"===e){1b(;u;){1b(o=u.1f,r=i;r&&r.2s>u.2s;)r=r.1f;(u.1l=r?r.1l:s)?u.1l.1f=u:i=u,(u.1f=r)?r.1l=u:s=u,u=o}u=t.1r=i}1b(;u;)u.4M&&"17"==1j u.t[e]&&u.t[e]()&&(n=!0),u=u.1f;18 n},W.6P=17(e){1b(19 t=e.1c;--t>-1;)e[t].3J===W.3J&&(P[(1g e[t]).4N]=e[t]);18!0},v.2A=17(e){1a(!(e&&e.7a&&e.78&&e.3J))5W"9L 2A a7.";19 t,n=e.7a,r=e.5H||0,i=e.av,s={78:"6M",4h:"1X",4c:"2p",59:"71",au:"4Z"},o=m("4z."+n.1u(0).5h()+n.1t(1)+"8j",17(){W.1Z(15,n,r),15.2E=i||[]},e.aq===!0),u=o.1x=1g W(n);u.2M=o,o.3J=e.3J;1b(t 1w s)"17"==1j e[t]&&(u[s[t]]=e[t]);18 o.3Z=e.3Z,W.6P([o]),o},n=e.3b){1b(r=0;n.1c>r;r++)n[r]();1b(i 1w p)p[i].76||e.65.6U("ax ay aD aE: 4F.4A."+i)}o=!1}})(1T);(1T.3b||(1T.3b=[])).28(17(){"5v 5u";1T.3R("aC",["5k.72","5k.7n","5c"],17(e,t,n){19 r=17(e){t.1Z(15,e),15.2L={},15.4P=15.1o.4P===!0,15.2F=15.1o.2F===!0,15.4J=!0,15.32=15.1o.5q;19 n,r,i=15.1o;1b(r 1w i)n=i[r],o(n)&&-1!==n.1G("").1k("{4t}")&&(i[r]=15.5o(n));o(i.3x)&&15.1P(i.3x,0,i.aA,i.ap)},i=1e-10,s=n.4p.7U,o=n.4p.7T,u=[],a=17(e){19 t,n={};1b(t 1w e)n[t]=e[t];18 n},f=17(e,t,n,r){e.1p.6c(e.1i),t&&t.36(r||e.1p,n||u)},l=u.6G,c=r.1x=1g t;18 r.3Z="1.11.0",c.2M=r,c.4c().1I=!1,c.3v=17(e,t,r,i){18 t?15.1P(1g n(e,t,r),i):15.4h(e,r,i)},c.68=17(e,t,r,i){18 15.1P(n.68(e,t,r),i)},c.66=17(e,t,r,i,s){18 t?15.1P(n.66(e,t,r,i),s):15.4h(e,i,s)},c.5I=17(e,t,i,o,u,f,c,p){19 d,v=1g r({4i:f,61:c,62:p});1b("1H"==1j e&&(e=n.3w(e)||e),s(e)&&(e=l.1Z(e,0)),o=o||0,d=0;e.1c>d;d++)i.38&&(i.38=a(i.38)),v.3v(e[d],t,a(i),d*o);18 15.1P(v,u)},c.ac=17(e,t,n,r,i,s,o,u){18 n.1V=0!=n.1V,n.4C=!0,15.5I(e,t,n,r,i,s,o,u)},c.a9=17(e,t,n,r,i,s,o,u,a){18 r.38=n,r.1V=0!=r.1V&&0!=n.1V,15.5I(e,t,r,i,s,o,u,a)},c.1Z=17(e,t,r,i){18 15.1P(n.6k(0,e,t,r),i)},c.4h=17(e,t,r){18 r=15.3d(r,0,!0),1d==t.1V&&(t.1V=r===15.1n&&!15.1A),15.1P(1g n(e,0,t),r)},r.ab=17(e,t){e=e||{},1d==e.2F&&(e.2F=!0);19 i,s,o=1g r(e),u=o.1p;1b(1d==t&&(t=!0),u.3C(o,!0),o.1i=0,o.1O=o.1n=o.1K=u.1n,i=u.27;i;)s=i.1f,t&&i 2a n&&i.2v===i.1o.4i||o.1P(i,i.1i-i.2J),i=s;18 u.1P(o,0),o},c.1P=17(i,s,u,a){19 f,l,c,h,p,d;1a("2t"!=1j s&&(s=15.3d(s,0,!0,i)),!(i 2a e)){1a(i 2a 3K||i&&i.28&&o(i)){1b(u=u||"ag",a=a||0,f=s,l=i.1c,c=0;l>c;c++)o(h=i[c])&&(h=1g r({3x:h})),15.1P(h,f),"1H"!=1j h&&"17"!=1j h&&("9A"===u?f=h.1i+h.26()/h.1y:"ah"===u&&(h.1i-=h.4y())),f+=a;18 15.35(!0)}1a("1H"==1j i)18 15.80(i,s);1a("17"!=1j i)5W"87 1P "+i+" am an 1U; 3z al 8a a 6v, 1U, 17, ak 1H.";i=n.6k(0,i)}1a(t.1x.1P.1Z(15,i,s),15.1I&&!15.1A&&15.1N<15.2C())1b(p=15,d=p.3y()>i.1i;p.1I&&p.1p;)p.1p.2F&&d?p.2Z(p.1K,!0):p.1M(!0,!1),p=p.1p;18 15},c.51=17(t){1a(t 2a e)18 15.3C(t,!1);1a(t 2a 3K||t&&t.28&&o(t)){1b(19 n=t.1c;--n>-1;)15.51(t[n]);18 15}18"1H"==1j t?15.7P(t):15.4c(1d,t)},c.3C=17(e,n){t.1x.3C.1Z(15,e,n);19 r=15.3h;18 r?15.1n>r.1i+r.2l/r.1y&&(15.1n=15.2C(),15.1K=15.2l):15.1n=15.1K=0,15},c.aF=17(e,t){18 15.1P(e,15.3d(1d,t,!0,e))},c.84=c.8R=17(e,t,n,r){18 15.1P(e,t||0,n,r)},c.8T=17(e,t,n,r){18 15.1P(e,15.3d(1d,t,!0,e),n,r)},c.80=17(e,t){18 15.2L[e]=15.3d(t),15},c.94=17(e,t,n,r){18 15.1Z(f,["{4t}",t,n,r],15,e)},c.7P=17(e){18 3L 15.2L[e],15},c.8X=17(e){18 1d!=15.2L[e]?15.2L[e]:-1},c.3d=17(t,n,r,i){19 s;1a(i 2a e&&i.1U===15)15.51(i);1m 1a(i&&(i 2a 3K||i.28&&o(i)))1b(s=i.1c;--s>-1;)i[s]2a e&&i[s].1U===15&&15.51(i[s]);1a("1H"==1j n)18 15.3d(n,r&&"2t"==1j t&&1d==15.2L[n]?t-15.2C():0,r);1a(n=n||0,"1H"!=1j t||!5X(t)&&1d==15.2L[t])1d==t&&(t=15.2C());1m{1a(s=t.1k("="),-1===s)18 1d==15.2L[t]?r?15.2L[t]=15.2C()+n:n:15.2L[t]+n;n=3q(t.1u(s-1)+"1",10)*1C(t.1t(s+1)),t=s>1?15.3d(t.1t(0,s-1),0,r):15.2C()}18 1C(t)+n},c.4e=17(e,t){18 15.2Z("2t"==1j e?e:15.3d(e),t!==!1)},c.8V=17(){18 15.34(!0)},c.9r=17(e,t){18 15.7w(e,t)},c.9q=17(e,t){18 15.6c(e,t)},c.1B=17(e,t,n){15.1I&&15.1M(!0,!1);19 r,s,o,a,f,l=15.2o?15.26():15.2l,c=15.1n,h=15.1i,p=15.1y,d=15.1A;1a(e>=l?(15.1K=15.1n=l,15.2G||15.5U()||(s=!0,a="4i",0===15.1N&&(0===e||0>15.1O||15.1O===i)&&15.1O!==e&&15.27&&(f=!0,15.1O>i&&(a="4j"))),15.1O=15.1N||!t||e?e:i,e=l+1e-6):1e-7>e?(15.1K=15.1n=0,(0!==c||0===15.1N&&(15.1O>i||0>e&&15.1O>=0))&&(a="4j",s=15.2G),0>e?(15.2c=!1,0===15.1N&&15.1O>=0&&15.27&&(f=!0),15.1O=e):(15.1O=15.1N||!t||e?e:i,e=0,15.2w||(f=!0))):15.1K=15.1n=15.1O=e,15.1n!==c&&15.27||n||f){1a(15.2w||(15.2w=!0),15.2c||!15.1A&&15.1n!==c&&e>0&&(15.2c=!0),0===c&&15.1o.4B&&0!==15.1n&&(t||15.1o.4B.36(15.1o.63||15,15.1o.5D||u)),15.1n>=c)1b(r=15.27;r&&(o=r.1f,!15.1A||d);)(r.2c||r.1i<=15.1n&&!r.1A&&!r.1I)&&(r.2G?r.1B((r.2o?r.26():r.2l)-(e-r.1i)*r.1y,t,n):r.1B((e-r.1i)*r.1y,t,n)),r=o;1m 1b(r=15.3h;r&&(o=r.1l,!15.1A||d);)(r.2c||c>=r.1i&&!r.1A&&!r.1I)&&(r.2G?r.1B((r.2o?r.26():r.2l)-(e-r.1i)*r.1y,t,n):r.1B((e-r.1i)*r.1y,t,n)),r=o;15.32&&(t||15.32.36(15.1o.6b||15,15.1o.67||u)),a&&(15.1I||(h===15.1i||p!==15.1y)&&(0===15.1n||l>=15.26())&&(s&&(15.1p.4P&&15.1M(!1,!1),15.2c=!1),!t&&15.1o[a]&&15.1o[a].36(15.1o[a+"6l"]||15,15.1o[a+"6o"]||u)))}},c.5U=17(){1b(19 e=15.27;e;){1a(e.1A||e 2a r&&e.5U())18!0;e=e.1f}18!1},c.5g=17(e,t,r,i){i=i||-4Y;1b(19 s=[],o=15.27,u=0;o;)i>o.1i||(o 2a n?t!==!1&&(s[u++]=o):(r!==!1&&(s[u++]=o),e!==!1&&(s=s.3U(o.5g(!0,t,r)),u=s.1c))),o=o.1f;18 s},c.3W=17(e,t){1b(19 r=n.3W(e),i=r.1c,s=[],o=0;--i>-1;)(r[i].1U===15||t&&15.7A(r[i]))&&(s[o++]=r[i]);18 s},c.7A=17(e){1b(19 t=e.1U;t;){1a(t===15)18!0;t=t.1U}18!1},c.7l=17(e,t,n){n=n||0;1b(19 r,i=15.27,s=15.2L;i;)i.1i>=n&&(i.1i+=e),i=i.1f;1a(t)1b(r 1w s)s[r]>=n&&(s[r]+=e);18 15.35(!0)},c.2p=17(e,t){1a(!e&&!t)18 15.1M(!1,!1);1b(19 n=t?15.3W(t):15.5g(!0,!0,!1),r=n.1c,i=!1;--r>-1;)n[r].2p(e,t)&&(i=!0);18 i},c.9b=17(e){19 t=15.5g(!1,!0,!0),n=t.1c;1b(15.1n=15.1K=0;--n>-1;)t[n].1M(!1,!1);18 e!==!1&&(15.2L={}),15.35(!0)},c.5i=17(){1b(19 e=15.27;e;)e.5i(),e=e.1f;18 15},c.1M=17(e,n){1a(e===15.1I)1b(19 r=15.27;r;)r.1M(e,!0),r=r.1f;18 t.1x.1M.1Z(15,e,n)},c.2C=17(e){18 22.1c?(0!==15.2C()&&0!==e&&15.5N(15.1N/e),15):(15.2o&&15.26(),15.1N)},c.26=17(e){1a(!22.1c){1a(15.2o){1b(19 t,n,r=0,i=15.3h,s=9g;i;)t=i.1l,i.2o&&i.26(),i.1i>s&&15.4J&&!i.1A?15.1P(i,i.1i-i.2J):s=i.1i,0>i.1i&&!i.1A&&(r-=i.1i,15.1p.2F&&(15.1i+=i.1i/15.1y),15.7l(-i.1i,!1,-4Y),s=0),n=i.1i+i.2l/i.1y,n>r&&(r=n),i=t;15.1N=15.2l=r,15.2o=!1}18 15.2l}18 0!==15.26()&&0!==e&&15.5N(15.2l/e),15},c.cW=17(){1b(19 t=15.1p;t.1p;)t=t.1p;18 t===e.6Y},c.3y=17(){18 15.1A?15.1K:(15.1p.3y()-15.1i)*15.1y},r},!0)}),1T.3R&&1T.3b.4G()();(1T.3b||(1T.3b=[])).28(17(){"5v 5u";1T.3R("2j.7F",["2j.7v"],17(e){19 t,n,r,i=1T.6h||1T,s=i.4F.4A,o=2*1h.4l,u=1h.4l/2,a=s.7W,f=17(t,n){19 r=a("2j."+t,17(){},!0),i=r.1x=1g e;18 i.2M=r,i.2x=n,r},l=e.7X||17(){},c=17(e,t,n,r){19 i=a("2j."+e,{5R:1g t,5s:1g n,5r:1g r},!0);18 l(i,e),i},h=17(e,t,n){15.t=e,15.v=t,n&&(15.5t=n,n.5x=15,15.c=n.v-t,15.7x=n.t-e)},p=17(t,n){19 r=a("2j."+t,17(e){15.1R=e||0===e?e:1.c7,15.2k=1.ci*15.1R},!0),i=r.1x=1g e;18 i.2M=r,i.2x=n,i.3t=17(e){18 1g r(e)},r},d=c("7F",p("d3",17(e){18(e-=1)*e*((15.1R+1)*e+15.1R)+1}),p("d6",17(e){18 e*e*((15.1R+1)*e-15.1R)}),p("cU",17(e){18 1>(e*=2)?.5*e*e*((15.2k+1)*e-15.2k):.5*((e-=2)*e*((15.2k+1)*e+15.2k)+2)})),v=a("2j.5Z",17(e,t,n){t=t||0===t?t:.7,1d==e?e=.7:e>1&&(e=1),15.7V=1!==e?t:0,15.1R=(1-e)/2,15.2k=e,15.3c=15.1R+15.2k,15.3m=n===!0},!0),m=v.1x=1g e;18 m.2M=v,m.2x=17(e){19 t=e+(.5-e)*15.7V;18 15.1R>e?15.3m?1-(e=1-e/15.1R)*e:t-(e=1-e/15.1R)*e*e*e*t:e>15.3c?15.3m?1-(e=(e-15.3c)/15.1R)*e:t+(e-t)*(e=(e-15.3c)/15.1R)*e*e*e:15.3m?1:t},v.3Q=1g v(.7,.7),m.3t=v.3t=17(e,t,n){18 1g v(e,t,n)},t=a("2j.7S",17(e){e=e||1,15.1R=1/e,15.2k=e+1},!0),m=t.1x=1g e,m.2M=t,m.2x=17(e){18 0>e?e=0:e>=1&&(e=.cH),(15.2k*e>>0)*15.1R},m.3t=t.3t=17(e){18 1g t(e)},n=a("2j.7Y",17(t){t=t||{};1b(19 n,r,i,s,o,u,a=t.cT||"3r",f=[],l=0,c=0|(t.d4||20),p=c,d=t.d1!==!1,v=t.cX===!0,m=t.7J 2a e?t.7J:1d,g="2t"==1j t.7K?.4*t.7K:.4;--p>-1;)n=d?1h.7L():1/c*p,r=m?m.2x(n):n,"3r"===a?i=g:"cC"===a?(s=1-n,i=s*s*g):"1w"===a?i=n*n*g:.5>n?(s=2*n,i=.5*s*s*g):(s=2*(1-n),i=.5*s*s*g),d?r+=1h.7L()*i-.5*i:p%2?r+=.5*i:r-=.5*i,v&&(r>1?r=1:0>r&&(r=0)),f[l++]={x:n,y:r};1b(f.ch(17(e,t){18 e.x-t.x}),u=1g h(1,1,1d),p=c;--p>-1;)o=f[p],u=1g h(o.x,o.y,u);15.1l=1g h(0,0,0!==u.t?u:u.5t)},!0),m=n.1x=1g e,m.2M=n,m.2x=17(e){19 t=15.1l;1a(e>t.t){1b(;t.5t&&e>=t.t;)t=t.5t;t=t.5x}1m 1b(;t.5x&&t.t>=e;)t=t.5x;18 15.1l=t,t.v+(e-t.t)/t.7x*t.c},m.3t=17(e){18 1g n(e)},n.3Q=1g n,c("cm",f("cA",17(e){18 1/2.75>e?7.2I*e*e:2/2.75>e?7.2I*(e-=1.5/2.75)*e+.75:2.5/2.75>e?7.2I*(e-=2.25/2.75)*e+.6i:7.2I*(e-=2.6d/2.75)*e+.6e}),f("cu",17(e){18 1/2.75>(e=1-e)?1-7.2I*e*e:2/2.75>e?1-(7.2I*(e-=1.5/2.75)*e+.75):2.5/2.75>e?1-(7.2I*(e-=2.25/2.75)*e+.6i):1-(7.2I*(e-=2.6d/2.75)*e+.6e)}),f("co",17(e){19 t=.5>e;18 e=t?1-2*e:2*e-1,e=1/2.75>e?7.2I*e*e:2/2.75>e?7.2I*(e-=1.5/2.75)*e+.75:2.5/2.75>e?7.2I*(e-=2.25/2.75)*e+.6i:7.2I*(e-=2.6d/2.75)*e+.6e,t?.5*(1-e):.5*e+.5})),c("cr",f("cs",17(e){18 1h.3l(1-(e-=1)*e)}),f("cp",17(e){18-(1h.3l(1-e*e)-1)}),f("cn",17(e){18 1>(e*=2)?-.5*(1h.3l(1-e*e)-1):.5*(1h.3l(1-(e-=2)*e)+1)})),r=17(t,n,r){19 i=a("2j."+t,17(e,t){15.1R=e||1,15.2k=t||r,15.3c=15.2k/o*(1h.cv(1/15.1R)||0)},!0),s=i.1x=1g e;18 s.2M=i,s.2x=n,s.3t=17(e,t){18 1g i(e,t)},i},c("cB",r("cz",17(e){18 15.1R*1h.3n(2,-10*e)*1h.2h((e-15.3c)*o/15.2k)+1},.3),r("cy",17(e){18-(15.1R*1h.3n(2,10*(e-=1))*1h.2h((e-15.3c)*o/15.2k))},.3),r("cw",17(e){18 1>(e*=2)?-.5*15.1R*1h.3n(2,10*(e-=1))*1h.2h((e-15.3c)*o/15.2k):.5*15.1R*1h.3n(2,-10*(e-=1))*1h.2h((e-15.3c)*o/15.2k)+1},.45)),c("cc",f("ca",17(e){18 1-1h.3n(2,-10*e)}),f("c8",17(e){18 1h.3n(2,10*(e-1))-.cd}),f("ce",17(e){18 1>(e*=2)?.5*1h.3n(2,10*(e-1)):.5*(2-1h.3n(2,-10*(e-1)))})),c("ck",f("cf",17(e){18 1h.2h(e*u)}),f("cJ",17(e){18-1h.2D(e*u)+1}),f("cZ",17(e){18-.5*(1h.2D(1h.4l*e)-1)})),a("2j.cV",{d0:17(t){18 e.7Z[t]}},!0),l(i.5Z,"5Z","3Q,"),l(n,"7Y","3Q,"),l(t,"7S","3Q,"),d},!0)}),1T.3R&&1T.3b.4G()();(1T.3b||(1T.3b=[])).28(17(){"5v 5u";1T.3R("4z.cE",["4z.7Q","5c"],17(e,t){19 n,r,i,s,o=17(){e.1Z(15,"4s"),15.2E.1c=0,15.1X=o.1x.1X},u={},a=o.1x=1g e("4s");a.2M=o,o.3Z="1.11.2",o.3J=2,o.8g=0,a="2d",o.6z={3k:a,7e:a,4x:a,4u:a,3M:a,3B:a,cP:a,6x:a,6w:a,33:a};19 f,l,c,h,p,d,v=/(?:\\d|\\-\\d|\\.\\d|\\-\\.\\d)+/g,m=/(?:\\d|\\-\\d|\\.\\d|\\-\\.\\d|\\+=\\d|\\-=\\d|\\+=.\\d|\\-=\\.\\d)+/g,g=/(?:\\+=|\\-=|\\-|\\b)[\\d\\-\\.]+[a-cN-cO-9]*(?:%|\\b)/3N,y=/[^\\d\\-\\.]/g,b=/(?:\\d|\\-|\\+|=|#|\\.)*/g,w=/1Y *= *([^)]*)/,E=/1Y:([^;]*)/,S=/3E\\(1Y *=.+?\\)/i,x=/^(5e|6m)/,T=/([A-Z])/g,N=/-([a-z])/3N,C=/(^(?:74\\(\\"|74\\())|(?:(\\"\\))$|\\)$)/3N,k=17(e,t){18 t.5h()},L=/(?:5Y|7s|7k)/i,A=/(8z|8O|8N|8L)=[\\d\\-\\.e]+/3N,O=/8x\\:5J\\.5L\\.5M\\(.+?\\)/i,M=/,(?=[^\\)]*(?:\\(|$))/3N,2q=1h.4l/31,D=31/1h.4l,P={},H=69,B=H.6a("77"),j=H.6a("ba"),F=o.4p={bb:u},I=b8.b7,q=17(){19 e,t=I.1k("b3"),n=H.6a("77");18 c=-1!==I.1k("b5")&&-1===I.1k("b6")&&(-1===t||1C(I.1t(t+8,1))>3),p=c&&6>1C(I.1t(I.1k("bc/")+8,1)),h=-1!==I.1k("bd"),/bk ([0-9]{1,}[\\.0-9]{0,})/.bl(I)&&(d=1q(4k.$1)),n.bm="<a 1v=\'3k:bj;1Y:.55;\'>a</a>",e=n.bi("a")[0],e?/^0.55/.2P(e.1v.1Y):!1}(),R=17(e){18 w.2P("1H"==1j e?e:(e.2R?e.2R.2i:e.1v.2i)||"")?1q(4k.$1)/23:1},U=17(e){1T.65&&65.6U(e)},z="",W="",X=17(e,t){t=t||B;19 n,r,i=t.1v;1a(2u 0!==i[e])18 e;1b(e=e.1u(0).5h()+e.1t(1),n=["O","be","64","bf","bg"],r=5;--r>-1&&2u 0===i[n[r]+e];);18 r>=0?(W=3===r?"64":n[r],z="-"+W.6R()+"-",W+e):1d},V=H.6Z?H.6Z.bh:17(){},$=o.c6=17(e,t,n,r,i){19 s;18 q||"1Y"!==t?(!r&&e.1v[t]?s=e.1v[t]:(n=n||V(e,1d))?(e=n.4m(t.1D(T,"-$1").6R()),s=e||n.1c?e:n[t]):e.2R&&(s=e.2R[t]),1d==i||s&&"3r"!==s&&"2n"!==s&&"2n 2n"!==s?s:i):R(e)},J=17(e,t,n,r,i){1a("2d"===r||!r)18 n;1a("2n"===r||!n)18 0;19 s,o=L.2P(t),u=e,a=B.1v,f=0>n;18 f&&(n=-n),"%"===r&&-1!==t.1k("3X")?s=n/23*(o?e.b2:e.b1):(a.37="3X:0 4S 8P;4q:"+$(e,"4q")+";aN-3B:0;","%"!==r&&u.7m?a[o?"aO":"70"]=n+r:(u=e.aP||H.aM,a[o?"3M":"3B"]=n+r),u.7m(B),s=1q(B[o?"4H":"4r"]),u.aL(B),0!==s||i||(s=J(e,t,n,r,!0))),f?-s:s},K=17(e,t,n){1a("8y"!==$(e,"4q",n))18 0;19 r="4u"===t?"5Y":"7r",i=$(e,"6w"+r,n);18 e["aH"+r]-(J(e,t,1q(i),i.1D(b,""))||0)},Q=17(e,t){19 n,r,i={};1a(t=t||V(e,1d))1a(n=t.1c)1b(;--n>-1;)i[t[n].1D(N,k)]=t.4m(t[n]);1m 1b(n 1w t)i[n]=t[n];1m 1a(t=e.2R||e.1v)1b(n 1w t)"1H"==1j n&&2u 0!==i[n]&&(i[n.1D(N,k)]=t[n]);18 q||(i.1Y=R(e)),r=44(e,t,!1),i.1F=r.1F,i.1S=r.1S,i.2f=r.2f,i.2g=r.2g,i.x=r.x,i.y=r.y,3j&&(i.z=r.z,i.1Q=r.1Q,i.21=r.21,i.2N=r.2N),i.7q&&3L i.7q,i},G=17(e,t,n,r,i){19 s,o,u,a={},f=e.1v;1b(o 1w n)"37"!==o&&"1c"!==o&&5X(o)&&(t[o]!==(s=n[o])||i&&i[o])&&-1===o.1k("aI")&&("2t"==1j s||"1H"==1j s)&&(a[o]="2n"!==s||"4u"!==o&&"3k"!==o?""!==s&&"2n"!==s&&"3r"!==s||"1H"!=1j t[o]||""===t[o].1D(y,"")?s:0:K(e,o),2u 0!==f[o]&&(u=1g ct(f,o,f[o],u)));1a(r)1b(o 1w r)"39"!==o&&(a[o]=r[o]);18{4T:a,42:u}},Y={3M:["5Y","7s"],3B:["7r","aK"]},Z=["7C","81","83","82"],3D=17(e,t,n){19 r=1q("3M"===t?e.4H:e.4r),i=Y[t],s=i.1c;1b(n=n||V(e,1d);--s>-1;)r-=1q($(e,"6x"+i[s],n,!0))||0,r-=1q($(e,"3X"+i[s]+"7k",n,!0))||0;18 r},3e=17(e,t){(1d==e||""===e||"2n"===e||"2n 2n"===e)&&(e="0 0");19 n=e.1s(" "),r=-1!==e.1k("4u")?"0%":-1!==e.1k("7e")?"23%":n[0],i=-1!==e.1k("3k")?"0%":-1!==e.1k("4x")?"23%":n[1];18 1d==i?i="0":"7d"===i&&(i="50%"),("7d"===r||5X(1q(r))&&-1===(r+"").1k("="))&&(r="50%"),t&&(t.8K=-1!==r.1k("%"),t.8H=-1!==i.1k("%"),t.aQ="="===r.1u(1),t.aR="="===i.1u(1),t.57=1q(r.1D(y,"")),t.5K=1q(i.1D(y,""))),r+" "+i+(n.1c>2?" "+n[2]:"")},3s=17(e,t){18"1H"==1j e&&"="===e.1u(1)?3q(e.1u(0)+"1",10)*1q(e.1t(2)):1q(e)-1q(t)},2B=17(e,t){18 1d==e?t:"1H"==1j e&&"="===e.1u(1)?3q(e.1u(0)+"1",10)*1C(e.1t(2))+t:1q(e)},3z=17(e,t,n,r){19 i,s,o,u,a=1e-6;18 1d==e?u=t:"2t"==1j e?u=e:(i=6r,s=e.1s("2q"),o=1C(s[0].1D(y,""))*(-1===e.1k("aY")?1:D)-("="===e.1u(1)?0:t),s.1c&&(r&&(r[n]=t+o),-1!==e.1k("aZ")&&(o%=i,o!==o%(i/2)&&(o=0>o?o+i:o-i)),-1!==e.1k("b0")&&0>o?o=(o+4Y*i)%i-(0|o/i)*i:-1!==e.1k("aX")&&o>0&&(o=(o-4Y*i)%i-(0|o/i)*i)),u=t+o),a>u&&u>-a&&(u=0),u},3G={aS:[0,1E,1E],aT:[0,1E,0],aU:[5j,5j,5j],8k:[0,0,0],aV:[2O,0,0],bn:[0,2O,2O],bo:[0,0,1E],bS:[0,0,2O],bT:[1E,1E,1E],bU:[1E,0,1E],bR:[2O,2O,0],bQ:[1E,1E,0],bM:[1E,bN,0],bO:[2O,2O,2O],bP:[2O,0,2O],bV:[0,2O,0],8P:[1E,0,0],c2:[1E,5j,c4],c1:[0,1E,1E],4a:[1E,1E,1E,0]},4W=17(e,t,n){18 e=0>e?e+1:e>1?e-1:e,0|1E*(1>6*e?t+6*(n-t)*e:.5>e?n:2>3*e?t+6*(n-t)*(2/3-e):t)+.5},5d=17(e){19 t,n,r,i,s,o;18 e&&""!==e?"2t"==1j e?[e>>16,1E&e>>8,1E&e]:(","===e.1u(e.1c-1)&&(e=e.1t(0,e.1c-1)),3G[e]?3G[e]:"#"===e.1u(0)?(4===e.1c&&(t=e.1u(1),n=e.1u(2),r=e.1u(3),e="#"+t+t+n+n+r+r),e=3q(e.1t(1),16),[e>>16,1E&e>>8,1E&e]):"6m"===e.1t(0,3)?(e=e.2K(v),i=1C(e[0])%6r/6r,s=1C(e[1])/23,o=1C(e[2])/23,n=.5>=o?o*(s+1):o+s-o*s,t=2*o-n,e.1c>3&&(e[3]=1C(e[3])),e[0]=4W(i+1/3,t,n),e[1]=4W(i,t,n),e[2]=4W(i-1/3,t,n),e):(e=e.2K(v)||3G.4a,e[0]=1C(e[0]),e[1]=1C(e[1]),e[2]=1C(e[2]),e.1c>3&&(e[3]=1C(e[3])),e)):3G.8k},at="(?:\\\\b(?:(?:5e|6N|6m|bZ)\\\\(.+?\\\\))|\\\\B#.+?\\\\b";1b(a 1w 3G)at+="|"+a+"\\\\b";at=4k(at+")","3N");19 6I=17(e,t,n,r){1a(1d==e)18 17(e){18 e};19 i,s=t?(e.2K(at)||[""])[0]:"",o=e.1s(s).1G("").2K(g)||[],u=e.1t(0,e.1k(o[0])),a=")"===e.1u(e.1c-1)?")":"",f=-1!==e.1k(" ")?" ":",",l=o.1c,c=l>0?o[0].1D(v,""):"";18 l?i=t?17(e){19 t,h,p,d;1a("2t"==1j e)e+=c;1m 1a(r&&M.2P(e)){1b(d=e.1D(M,"|").1s("|"),p=0;d.1c>p;p++)d[p]=i(d[p]);18 d.1G(",")}1a(t=(e.2K(at)||[s])[0],h=e.1s(t).1G("").2K(g)||[],p=h.1c,l>p--)1b(;l>++p;)h[p]=n?h[0|(p-1)/2]:o[p];18 u+h.1G(f)+f+t+a+(-1!==e.1k("6D")?" 6D":"")}:17(e){19 t,s,h;1a("2t"==1j e)e+=c;1m 1a(r&&M.2P(e)){1b(s=e.1D(M,"|").1s("|"),h=0;s.1c>h;h++)s[h]=i(s[h]);18 s.1G(",")}1a(t=e.2K(g)||[],h=t.1c,l>h--)1b(;l>++h;)t[h]=n?t[0|(h-1)/2]:o[h];18 u+t.1G(f)+a}:17(e){18 e}},6A=17(e){18 e=e.1s(","),17(t,n,r,i,s,o,u){19 a,f=(n+"").1s(" ");1b(u={},a=0;4>a;a++)u[e[a]]=f[a]=f[a]||f[(a-1)/2>>0];18 i.2S(t,u,s,o)}},ct=(F.bL=17(e){15.2A.1X(e);1b(19 t,n,r,i,s=15.1z,o=s.8t,u=s.42,a=1e-6;u;)t=o[u.v],u.r?t=t>0?0|t+.5:0|t-.5:a>t&&t>-a&&(t=0),u.t[u.p]=t,u=u.1f;1a(s.8c&&(s.8c.1F=o.1F),1===e)1b(u=s.42;u;){1a(n=u.t,n.2r){1a(1===n.2r){1b(i=n.1W+n.s+n.3V,r=1;n.l>r;r++)i+=n["3g"+r]+n["2X"+(r+1)];n.e=i}}1m n.e=n.s+n.1W;u=u.1f}},17(e,t,n,r,i){15.t=e,15.p=t,15.v=n,15.r=i,r&&(r.1l=15,15.1f=r)}),24=(F.bK=17(e,t,n,r,i,s){19 o,u,a,f,l,c=r,h={},p={},d=n.3p,v=P;1b(n.3p=1d,P=t,r=l=n.2S(e,t,r,i),P=v,s&&(n.3p=d,c&&(c.1l=1d,c.1l&&(c.1l.1f=1d)));r&&r!==c;){1a(1>=r.2r&&(u=r.p,p[u]=r.s+r.c,h[u]=r.s,s||(f=1g ct(r,"s",u,f,r.r),r.c=0),1===r.2r))1b(o=r.l;--o>0;)a="3g"+o,u=r.p+"2q"+a,p[u]=r.1z[a],h[u]=r[a],s||(f=1g ct(r,a,u,f,r.5f[a]));r=r.1f}18{8t:h,bw:p,42:f,4f:l}},F.bx=17(e,t,r,i,o,u,a,f,l,c,h){15.t=e,15.p=t,15.s=r,15.c=i,15.n=a||t,e 2a 24||s.28(15.n),15.r=f,15.2r=u||0,l&&(15.2s=l,n=!0),15.b=2u 0===c?r:c,15.e=2u 0===h?r+i:h,o&&(15.1f=o,o.1l=15)}),4f=o.46=17(e,t,n,r,i,s,o,u,a,l){n=n||s||"",o=1g 24(e,t,0,0,o,l?2:1,1d,!1,u,n,r),r+="";19 c,h,p,d,g,y,b,w,E,S,T,N,C=n.1s(", ").1G(",").1s(" "),k=r.1s(", ").1G(",").1s(" "),L=C.1c,A=f!==!1;1b((-1!==r.1k(",")||-1!==n.1k(","))&&(C=C.1G(" ").1D(M,", ").1s(" "),k=k.1G(" ").1D(M,", ").1s(" "),L=C.1c),L!==k.1c&&(C=(s||"").1s(" "),L=C.1c),o.2A=a,o.1X=l,c=0;L>c;c++)1a(d=C[c],g=k[c],w=1q(d),w||0===w)o.3I("",w,3s(g,w),g.1D(m,""),A&&-1!==g.1k("2d"),!0);1m 1a(i&&("#"===d.1u(0)||3G[d]||x.2P(d)))N=","===g.1u(g.1c-1)?"),":")",d=5d(d),g=5d(g),E=d.1c+g.1c>6,E&&!q&&0===g[3]?(o["2X"+o.l]+=o.l?" 4a":"4a",o.e=o.e.1s(k[c]).1G("4a")):(q||(E=!1),o.3I(E?"6N(":"5e(",d[0],g[0]-d[0],",",!0,!0).3I("",d[1],g[1]-d[1],",",!0).3I("",d[2],g[2]-d[2],E?",":N,!0),E&&(d=4>d.1c?1:d[3],o.3I("",d,(4>g.1c?1:g[3])-d,N,!1)));1m 1a(y=d.2K(v)){1a(b=g.2K(m),!b||b.1c!==y.1c)18 o;1b(p=0,h=0;y.1c>h;h++)T=y[h],S=d.1k(T,p),o.3I(d.1t(p,S-p),1C(T),3s(b[h],T),"",A&&"2d"===d.1t(S+T.1c,2),0===h),p=S+T.1c;o["2X"+o.l]+=d.1t(p)}1m o["2X"+o.l]+=o.l?" "+d:d;1a(-1!==r.1k("=")&&o.1z){1b(N=o.1W+o.1z.s,c=1;o.l>c;c++)N+=o["2X"+c]+o.1z["3g"+c];o.e=N+o["2X"+c]}18 o.l||(o.2r=-1,o.1W=o.e),o.3H||o},2m=9;1b(a=24.1x,a.l=a.2s=0;--2m>0;)a["3g"+2m]=0,a["2X"+2m]="";a.1W="",a.1f=a.1l=a.3H=a.1z=a.2A=a.1X=a.5f=1d,a.3I=17(e,t,n,r,i,s){19 o=15,u=o.l;18 o["2X"+u]+=s&&u?" "+e:e||"",n||0===u||o.2A?(o.l++,o.2r=o.1X?2:1,o["2X"+o.l]=r||"",u>0?(o.1z["3g"+u]=t+n,o.5f["3g"+u]=i,o["3g"+u]=t,o.2A||(o.3H=1g 24(o,"3g"+u,t,n,o.3H||o,0,o.n,i,o.2s),o.3H.1W=0),o):(o.1z={s:t+n},o.5f={},o.s=t,o.c=n,o.r=i,o)):(o["2X"+u]+=t+(r||""),o)};19 5G=17(e,t){t=t||{},15.p=t.2T?X(e)||e:e,u[e]=u[15.p]=15,15.2U=t.4R||6I(t.2y,t.4g,t.by,t.47),t.2b&&(15.2S=t.2b),15.8D=t.4g,15.47=t.47,15.4V=t.4V,15.49=t.2y,15.2s=t.5H||0},1L=F.bv=17(e,t,n){"3T"!=1j t&&(t={2b:n});19 r,i,s=e.1s(","),o=t.2y;1b(n=n||[o],r=0;s.1c>r;r++)t.2T=0===r&&t.2T,t.2y=n[r]||o,i=1g 5G(s[r],t)},7H=17(e){1a(!u[e]){19 t=e.1u(0).5h()+e.1t(1)+"8j";1L(e,{2b:17(e,n,r,i,s,o,a){19 f=(1T.6h||1T).4F.4A.4z[t];18 f?(f.bu(),u[r].2S(e,n,r,i,s,o,a)):(U("bp: "+t+" bq br 8a bs."),s)}})}};a=5G.1x,a.46=17(e,t,n,r,i,s){19 o,u,a,f,l,c,h=15.4V;1a(15.47&&(M.2P(n)||M.2P(t)?(u=t.1D(M,"|").1s("|"),a=n.1D(M,"|").1s("|")):h&&(u=[t],a=[n])),a){1b(f=a.1c>u.1c?a.1c:u.1c,o=0;f>o;o++)t=u[o]=u[o]||15.49,n=a[o]=a[o]||15.49,h&&(l=t.1k(h),c=n.1k(h),l!==c&&(n=-1===c?a:u,n[o]+=" "+h));t=u.1G(", "),n=a.1G(", ")}18 4f(e,15.p,t,n,15.8D,15.49,r,15.2s,i,s)},a.2S=17(e,t,n,r,s,o){18 15.46(e.1v,15.2U($(e,15.p,i,!1,15.49)),15.2U(t),s,o)},o.bA=17(e,t,n){1L(e,{2b:17(e,r,i,s,o,u){19 a=1g 24(e,i,0,0,o,2,i,!1,n);18 a.2A=u,a.1X=t(e,r,s.2V,i),a},5H:n})};19 6K="2f,2g,2N,x,y,z,1S,1F,1Q,21,33".1s(","),bt=X("3P"),8B=z+"3P",5m=X("4Q"),3j=1d!==X("33"),44=17(e,t,n,r){1a(e.4b&&n&&!r)18 e.4b;19 i,s,u,a,f,l,c,h,p,d,v,m,g,y=n?e.4b||{30:0}:{30:0},b=0>y.2f,w=2e-5,E=54,S=bH.99,x=S*2q,T=3j?1q($(e,5m,t,!1,"0 0 0").1s(" ")[2])||y.2Q||0:0;1b(bt?i=$(e,8B,t,!0):e.2R&&(i=e.2R.2i.2K(A),i=i&&4===i.1c?[i[0].1t(4),1C(i[2].1t(4)),1C(i[1].1t(4)),i[3].1t(4),y.x||0,y.y||0].1G(","):""),s=(i||"").2K(/(?:\\-|\\b)[\\d\\-\\.e]+\\b/3N)||[],u=s.1c;--u>-1;)a=1C(s[u]),s[u]=(f=a-(a|=0))?(0|f*E+(0>f?-.5:.5))/E+a:a;1a(16===s.1c){19 N=s[8],C=s[9],k=s[10],L=s[12],O=s[13],M=s[14];1a(y.2Q&&(M=-y.2Q,L=N*M-s[12],O=C*M-s[13],M=k*M+y.2Q-s[14]),!n||r||1d==y.1Q){19 P,H,B,j,F,I,q,R=s[0],U=s[1],z=s[2],W=s[3],X=s[4],V=s[5],J=s[6],K=s[7],Q=s[11],G=1h.4w(J,k),Y=-x>G||G>x;y.1Q=G*D,G&&(j=1h.2D(-G),F=1h.2h(-G),P=X*j+N*F,H=V*j+C*F,B=J*j+k*F,N=X*-F+N*j,C=V*-F+C*j,k=J*-F+k*j,Q=K*-F+Q*j,X=P,V=H,J=B),G=1h.4w(N,R),y.21=G*D,G&&(I=-x>G||G>x,j=1h.2D(-G),F=1h.2h(-G),P=R*j-N*F,H=U*j-C*F,B=z*j-k*F,C=U*F+C*j,k=z*F+k*j,Q=W*F+Q*j,R=P,U=H,z=B),G=1h.4w(U,V),y.1F=G*D,G&&(q=-x>G||G>x,j=1h.2D(-G),F=1h.2h(-G),R=R*j+X*F,H=U*j+V*F,V=U*-F+V*j,J=z*-F+J*j,U=H),q&&Y?y.1F=y.1Q=0:q&&I?y.1F=y.21=0:I&&Y&&(y.21=y.1Q=0),y.2f=(0|1h.3l(R*R+U*U)*E+.5)/E,y.2g=(0|1h.3l(V*V+C*C)*E+.5)/E,y.2N=(0|1h.3l(J*J+k*k)*E+.5)/E,y.1S=0,y.33=Q?1/(0>Q?-Q:Q):0,y.x=L,y.y=O,y.z=M}}1m 1a(!(3j&&!r&&s.1c&&y.x===s[4]&&y.y===s[5]&&(y.1Q||y.21)||2u 0!==y.x&&"3r"===$(e,"6s",t))){19 Z=s.1c>=6,3D=Z?s[0]:1,3e=s[1]||0,3s=s[2]||0,2B=Z?s[3]:1;y.x=s[4]||0,y.y=s[5]||0,l=1h.3l(3D*3D+3e*3e),c=1h.3l(2B*2B+3s*3s),h=3D||3e?1h.4w(3e,3D)*D:y.1F||0,p=3s||2B?1h.4w(3s,2B)*D+h:y.1S||0,d=l-1h.56(y.2f||0),v=c-1h.56(y.2g||0),1h.56(p)>90&&bJ>1h.56(p)&&(b?(l*=-1,p+=0>=h?31:-31,h+=0>=h?31:-31):(c*=-1,p+=0>=p?31:-31)),m=(h-y.1F)%31,g=(p-y.1S)%31,(2u 0===y.1S||d>w||-w>d||v>w||-w>v||m>-S&&S>m&&5O|m*E||g>-S&&S>g&&5O|g*E)&&(y.2f=l,y.2g=c,y.1F=h,y.1S=p),3j&&(y.1Q=y.21=y.z=0,y.33=1q(o.8g)||0,y.2N=1)}y.2Q=T;1b(u 1w y)w>y[u]&&y[u]>-w&&(y[u]=0);18 n&&(e.4b=y),y},7O=17(e){19 t,n,r=15.1z,i=-r.1F*2q,s=i+r.1S*2q,o=54,u=(0|1h.2D(i)*r.2f*o)/o,a=(0|1h.2h(i)*r.2f*o)/o,f=(0|1h.2h(s)*-r.2g*o)/o,l=(0|1h.2D(s)*r.2g*o)/o,c=15.t.1v,h=15.t.2R;1a(h){n=a,a=-f,f=-n,t=h.2i,c.2i="";19 p,v,m=15.t.4H,g=15.t.4r,y="8y"!==h.4q,E="8x:5J.5L.5M(8z="+u+", 8O="+a+", 8N="+f+", 8L="+l,S=r.x,x=r.y;1a(1d!=r.57&&(p=(r.8K?.8I*m*r.57:r.57)-m/2,v=(r.8H?.8I*g*r.5K:r.5K)-g/2,S+=p-(p*u+v*a),x+=v-(p*f+v*l)),y?(p=m/2,v=g/2,E+=", 8E="+(p-(p*u+v*a)+S)+", 8G="+(v-(p*f+v*l)+x)+")"):E+=", bF=\'2n bB\')",c.2i=-1!==t.1k("5J.5L.5M(")?t.1D(O,E):E+" "+t,(0===e||1===e)&&1===u&&0===a&&0===f&&1===l&&(y&&-1===E.1k("8E=0, 8G=0")||w.2P(t)&&23!==1q(4k.$1)||-1===t.1k("bD("&&t.1k("bE"))&&c.6Q("2i")),!y){19 T,N,C,k=8>d?1:-1;1b(p=r.5l||0,v=r.58||0,r.5l=1h.59((m-((0>u?-u:u)*m+(0>a?-a:a)*g))/2+S),r.58=1h.59((g-((0>l?-l:l)*g+(0>f?-f:f)*m))/2+x),2m=0;4>2m;2m++)N=Z[2m],T=h[N],n=-1!==T.1k("2d")?1q(T):J(15.t,N,1q(T),T.1D(b,""))||0,C=n!==r[N]?2>2m?-r.5l:-r.58:2>2m?p-r.5l:v-r.58,c[N]=(r[N]=1h.59(n-C*(0===2m||2===2m?1:k)))+"2d"}}},7D=17(){19 e,t,n,r,i,s,o,u,a,f,l,c,p,d,v,m,g,y,b,w,E,S,x,T=15.1z,N=15.t.1v,C=T.1F*2q,k=T.2f,L=T.2g,A=T.2N,O=T.33;1a(h){19 M=1e-4;M>k&&k>-M&&(k=A=2e-5),M>L&&L>-M&&(L=A=2e-5),!O||T.z||T.1Q||T.21||(O=0)}1a(C||T.1S)y=1h.2D(C),b=1h.2h(C),e=y,i=b,T.1S&&(C-=T.1S*2q,y=1h.2D(C),b=1h.2h(C)),t=-b,s=y;1m{1a(!(T.21||T.1Q||1!==A||O))18 N[bt]="bC("+T.x+"2d,"+T.y+"2d,"+T.z+"2d)"+(1!==k||1!==L?" 48("+k+","+L+")":""),2u 0;e=s=1,t=i=0}l=1,n=r=o=u=a=f=c=p=d=0,v=O?-1/O:0,m=T.2Q,g=54,C=T.21*2q,C&&(y=1h.2D(C),b=1h.2h(C),a=l*-b,p=v*-b,n=e*b,o=i*b,l*=y,v*=y,e*=y,i*=y),C=T.1Q*2q,C&&(y=1h.2D(C),b=1h.2h(C),w=t*y+n*b,E=s*y+o*b,S=f*y+l*b,x=d*y+v*b,n=t*-b+n*y,o=s*-b+o*y,l=f*-b+l*y,v=d*-b+v*y,t=w,s=E,f=S,d=x),1!==A&&(n*=A,o*=A,l*=A,v*=A),1!==L&&(t*=L,s*=L,f*=L,d*=L),1!==k&&(e*=k,i*=k,a*=k,p*=k),m&&(c-=m,r=n*c,u=o*c,c=l*c+m),r=(w=(r+=T.x)-(r|=0))?(0|w*g+(0>w?-.5:.5))/g+r:r,u=(w=(u+=T.y)-(u|=0))?(0|w*g+(0>w?-.5:.5))/g+u:u,c=(w=(c+=T.z)-(c|=0))?(0|w*g+(0>w?-.5:.5))/g+c:c,N[bt]="bG("+[(0|e*g)/g,(0|i*g)/g,(0|a*g)/g,(0|p*g)/g,(0|t*g)/g,(0|s*g)/g,(0|f*g)/g,(0|d*g)/g,(0|n*g)/g,(0|o*g)/g,(0|l*g)/g,(0|v*g)/g,r,u,c,O?1+ -c/O:1].1G(",")+")"},7B=17(){19 e,t,n,r,i,s,o,u,a,f=15.1z,l=15.t,c=l.1v;h&&(e=c.3k?"3k":c.4x?"4x":1q($(l,"3k",1d,!1))?"4x":"3k",t=$(l,e,1d,!1),n=1q(t)||0,r=t.1t((n+"").1c)||"2d",f.6y=!f.6y,c[e]=(f.6y?n+.8v:n-.8v)+r),f.1F||f.1S?(i=f.1F*2q,s=i-f.1S*2q,o=54,u=f.2f*o,a=f.2g*o,c[bt]="8b("+(0|1h.2D(i)*u)/o+","+(0|1h.2h(i)*u)/o+","+(0|1h.2h(s)*-a)/o+","+(0|1h.2D(s)*a)/o+","+f.x+","+f.y+")"):c[bt]="8b("+f.2f+",0,0,"+f.2g+","+f.x+","+f.y+")"};1L("3P,48,2f,2g,2N,x,y,z,1F,1Q,21,6u,1S,30,6t,6B,6C,bI,4Q,8s,8n,8Q,4E",{2b:17(e,t,n,r,s,o,u){1a(r.3p)18 s;19 a,f,l,c,h,p,d,v=r.3p=44(e,i,!0,u.8Q),m=e.1v,g=1e-6,y=6K.1c,b=u,w={};1a("1H"==1j b.3P&&bt)l=m.37,m[bt]=b.3P,m.6s="bz",a=44(e,1d,!1),m.37=l;1m 1a("3T"==1j b){1a(a={2f:2B(1d!=b.2f?b.2f:b.48,v.2f),2g:2B(1d!=b.2g?b.2g:b.48,v.2g),2N:2B(1d!=b.2N?b.2N:b.48,v.2N),x:2B(b.x,v.x),y:2B(b.y,v.y),z:2B(b.z,v.z),33:2B(b.8s,v.33)},d=b.8n,1d!=d)1a("3T"==1j d)1b(l 1w d)b[l]=d[l];1m b.1F=d;a.1F=3z("1F"1w b?b.1F:"6t"1w b?b.6t+"6J":"6u"1w b?b.6u:v.1F,v.1F,"1F",w),3j&&(a.1Q=3z("1Q"1w b?b.1Q:"6B"1w b?b.6B+"6J":v.1Q||0,v.1Q,"1Q",w),a.21=3z("21"1w b?b.21:"6C"1w b?b.6C+"6J":v.21||0,v.21,"21",w)),a.1S=1d==b.1S?v.1S:3z(b.1S,v.1S),a.30=1d==b.30?v.30:3z(b.30,v.30),(f=a.30-v.30)&&(a.1S+=f,a.1F+=f)}1b(1d!=b.4E&&(v.4E=b.4E,p=!0),h=v.4E||v.z||v.1Q||v.21||a.z||a.1Q||a.21||a.33,h||1d==b.48||(a.2N=1);--y>-1;)n=6K[y],c=a[n]-v[n],(c>g||-g>c||1d!=P[n])&&(p=!0,s=1g 24(v,n,v[n],c,s),n 1w w&&(s.e=w[n]),s.1W=0,s.2A=o,r.2E.28(s.n));18 c=b.4Q,(c||3j&&h&&v.2Q)&&(bt?(p=!0,n=5m,c=(c||$(e,n,i,!1,"50% 50%"))+"",s=1g 24(m,n,0,0,s,-1,"4Q"),s.b=m[n],s.2A=o,3j?(l=v.2Q,c=c.1s(" "),v.2Q=(c.1c>2&&(0===l||"1J"!==c[2])?1q(c[2]):l)||0,s.1W=s.e=m[n]=c[0]+" "+(c[1]||"50%")+" 1J",s=1g 24(v,"2Q",0,0,s,-1,s.n),s.b=l,s.1W=s.e=v.2Q):s.1W=s.e=m[n]=c):3e(c+"",v)),p&&(r.3S=h||3===15.3S?3:2),s},2T:!0}),1L("bY",{2y:"1J 1J 1J 1J #6V",2T:!0,4g:!0,47:!0,4V:"6D"}),1L("bX",{2y:"1J",2b:17(e,t,n,s,o){t=15.2U(t);19 u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x=["c0","c3","bW","aW"],T=e.1v;1b(v=1q(e.4H),m=1q(e.4r),u=t.1s(" "),a=0;x.1c>a;a++)15.p.1k("3X")&&(x[a]=X(x[a])),c=l=$(e,x[a],i,!1,"1J"),-1!==c.1k(" ")&&(l=c.1s(" "),c=l[0],l=l[1]),h=f=u[a],p=1q(c),y=c.1t((p+"").1c),b="="===h.1u(1),b?(d=3q(h.1u(0)+"1",10),h=h.1t(2),d*=1q(h),g=h.1t((d+"").1c-(0>d?1:0))||""):(d=1q(h),g=h.1t((d+"").1c)),""===g&&(g=r[n]||y),g!==y&&(w=J(e,"6X",p,y),E=J(e,"aJ",p,y),"%"===g?(c=23*(w/v)+"%",l=23*(E/m)+"%"):"4d"===g?(S=J(e,"6X",1,"4d"),c=w/S+"4d",l=E/S+"4d"):(c=w+"2d",l=E+"2d"),b&&(h=1q(c)+d+g,f=1q(l)+d+g)),o=4f(T,x[a],c+" "+l,h+" "+f,!1,"1J",o);18 o},2T:!0,4R:6I("1J 1J 1J 1J",!1,!0)}),1L("b4",{2y:"0 0",2b:17(e,t,n,r,s,o){19 u,a,f,l,c,h,p="b9-4q",v=i||V(e,1d),m=15.2U((v?d?v.4m(p+"-x")+" "+v.4m(p+"-y"):v.4m(p):e.2R.c5+" "+e.2R.cQ)||"0 0"),g=15.2U(t);1a(-1!==m.1k("%")!=(-1!==g.1k("%"))&&(h=$(e,"cS").1D(C,""),h&&"3r"!==h)){1b(u=m.1s(" "),a=g.1s(" "),j.cM("cG",h),f=2;--f>-1;)m=u[f],l=-1!==m.1k("%"),l!==(-1!==a[f].1k("%"))&&(c=0===f?e.4H-j.3M:e.4r-j.3B,u[f]=l?1q(m)/23*c+"2d":23*(1q(m)/c)+"%");m=u.1G(" ")}18 15.46(e.1v,m,g,s,o)},4R:3e}),1L("cI",{2y:"0 0",4R:3e}),1L("33",{2y:"1J",2T:!0}),1L("cK",{2y:"50% 50%",2T:!0}),1L("cY",{2T:!0}),1L("cj",{2T:!0}),1L("cx",{2T:!0}),1L("6w",{2b:6A("83,81,82,7C")}),1L("6x",{2b:6A("cq,cl,cb,cF")}),1L("c9",{2y:"7R(1J,1J,1J,1J)",2b:17(e,t,n,r,s,o){19 u,a,f;18 9>d?(a=e.2R,f=8>d?" ":",",u="7R("+a.aG+f+a.cg+f+a.cD+f+a.d2+")",t=15.2U(t).1s(",").1G(f)):(u=15.2U($(e,15.p,i,!1,15.49)),t=15.2U(t)),15.46(e.1v,u,t,s,o)}}),1L("d5",{2y:"1J 1J 1J #6V",4g:!0,47:!0}),1L("7N,85",{2b:17(e,t,n,r,i){18 i}}),1L("3X",{2y:"1J 4S #6O",2b:17(e,t,n,r,s,o){18 15.46(e.1v,15.2U($(e,"70",i,!1,"1J")+" "+$(e,"cL",i,!1,"4S")+" "+$(e,"cR",i,!1,"#6O")),15.2U(t),s,o)},4g:!0,4R:17(e){19 t=e.1s(" ");18 t[0]+" "+(t[1]||"4S")+" "+(e.2K(at)||["#6O"])[0]}}),1L("9E,6S,6W",{2b:17(e,t,n,r,i){19 s=e.1v,o="6S"1w s?"6S":"6W";18 1g 24(s,o,0,0,i,-1,n,!1,0,s[o],t)}});19 73=17(e){19 t,n=15.t,r=n.2i||$(15.1z,"2i"),i=0|15.s+15.c*e;23===i&&(-1===r.1k("9k(")&&-1===r.1k("9e(")&&-1===r.1k("98(")?(n.6Q("2i"),t=!$(15.1z,"2i")):(n.2i=r.1D(S,""),t=!0)),t||(15.3O&&(n.2i=r=r||"3E(1Y="+i+")"),-1===r.1k("1Y")?0===i&&15.3O||(n.2i=r+" 3E(1Y="+i+")"):n.2i=r.1D(w,"1Y="+i))};1L("1Y,3E,5n",{2y:"1",2b:17(e,t,n,r,s,o){19 u=1q($(e,"1Y",i,!1,"1")),a=e.1v,f="5n"===n;18"1H"==1j t&&"="===t.1u(1)&&(t=("-"===t.1u(0)?-1:1)*1q(t.1t(2))+u),f&&1===u&&"5z"===$(e,"6E",i)&&0!==t&&(u=0),q?s=1g 24(a,"1Y",u,t-u,s):(s=1g 24(a,"1Y",23*u,23*(t-u),s),s.3O=f?1:0,a.7z=1,s.2r=2,s.b="3E(1Y="+s.s+")",s.e="3E(1Y="+(s.s+s.c)+")",s.1z=e,s.2A=o,s.1X=73),f&&(s=1g 24(a,"6E",0,0,s,-1,1d,!1,0,0!==u?"6T":"5z",0===t?"5z":"6T"),s.1W="6T",r.2E.28(s.n),r.2E.28(n)),s}});19 53=17(e,t){t&&(e.88?e.88(t.1D(T,"-$1").6R()):e.6Q(t))},7M=17(e){1a(15.t.4K=15,1===e||0===e){15.t.39=0===e?15.b:15.e;1b(19 t=15.1z,n=15.t.1v;t;)t.v?n[t.p]=t.v:53(n,t.p),t=t.1f;1===e&&15.t.4K===15&&(15.t.4K=1d)}1m 15.t.39!==15.e&&(15.t.39=15.e)};1L("39",{2b:17(e,t,r,s,o,u,a){19 f,l,c,h,p,d=e.39,v=e.1v.37;1a(o=s.6F=1g 24(e,r,0,0,o,2),o.1X=7M,o.2s=-11,n=!0,o.b=d,l=Q(e,i),c=e.4K){1b(h={},p=c.1z;p;)h[p.p]=1,p=p.1f;c.1X(1)}18 e.4K=o,o.e="="!==t.1u(1)?t:d.1D(4k("\\\\s*\\\\b"+t.1t(2)+"\\\\b"),"")+("+"===t.1u(0)?" "+t.1t(2):""),s.2V.1N&&(e.39=o.e,f=G(e,l,Q(e),a,h),e.39=d,o.1z=f.42,e.1v.37=v,o=o.3H=s.2S(e,f.4T,o,u)),o}});19 7I=17(e){1a((1===e||0===e)&&15.1z.1K===15.1z.2l&&"7G"!==15.1z.1z){19 t,n,r,i,s=15.t.1v,o=u.3P.2S;1a("3Y"===15.e)s.37="",i=!0;1m 1b(t=15.e.1s(","),r=t.1c;--r>-1;)n=t[r],u[n]&&(u[n].2S===o?i=!0:n="4Q"===n?5m:u[n].p),53(s,n);i&&(53(s,bt),15.t.4b&&3L 15.t.4b)}};1b(1L("9d",{2b:17(e,t,r,i,s){18 s=1g 24(e,r,0,0,s,2),s.1X=7I,s.e=t,s.2s=-10,s.1z=i.2V,n=!0,s}}),a="9m,9v,9u,9w".1s(","),2m=a.1c;2m--;)7H(a[2m]);a=o.1x,a.1r=1d,a.6M=17(e,t,u){1a(!e.3o)18!1;15.7t=e,15.2V=u,15.7E=t,f=t.7N,n=!1,r=t.6z||o.6z,i=V(e,""),s=15.2E;19 a,h,d,v,m,g,y,b,w,S=e.1v;1a(l&&""===S.3F&&(a=$(e,"3F",i),("2n"===a||""===a)&&(S.3F=0)),"1H"==1j t&&(v=S.37,a=Q(e,i),S.37=v+";"+t,a=G(e,a,Q(e)).4T,!q&&E.2P(t)&&(a.1Y=1q(4k.$1)),t=a,S.37=v),15.1r=h=15.2S(e,t,1d),15.3S){1b(w=3===15.3S,bt?c&&(l=!0,""===S.3F&&(y=$(e,"3F",i),("2n"===y||""===y)&&(S.3F=0)),p&&(S.7y=15.7E.7y||(w?"9p":"5z"))):S.7z=1,d=h;d&&d.1f;)d=d.1f;b=1g 24(e,"3P",0,0,1d,2),15.5w(b,1d,d),b.1X=w&&3j?7D:bt?7B:7O,b.1z=15.3p||44(e,i,!0),s.4G()}1a(n){1b(;h;){1b(g=h.1f,d=v;d&&d.2s>h.2s;)d=d.1f;(h.1l=d?d.1l:m)?h.1l.1f=h:v=h,(h.1f=d)?d.1l=h:m=h,h=g}15.1r=v}18!0},a.2S=17(e,t,n,s){19 o,a,l,c,h,p,d,v,m,g,y=e.1v;1b(o 1w t)p=t[o],a=u[o],a?n=a.2S(e,p,o,15,n,s,t):(h=$(e,o,i)+"",m="1H"==1j p,"4g"===o||"8Y"===o||"aj"===o||-1!==o.1k("ai")||m&&x.2P(p)?(m||(p=5d(p),p=(p.1c>3?"6N(":"5e(")+p.1G(",")+")"),n=4f(y,o,h,p,!0,"4a",n,0,s)):!m||-1===p.1k(" ")&&-1===p.1k(",")?(l=1q(h),d=l||0===l?h.1t((l+"").1c):"",(""===h||"2n"===h)&&("3M"===o||"3B"===o?(l=3D(e,o,i),d="2d"):"4u"===o||"3k"===o?(l=K(e,o,i),d="2d"):(l="1Y"!==o?0:1,d="")),g=m&&"="===p.1u(1),g?(c=3q(p.1u(0)+"1",10),p=p.1t(2),c*=1q(p),v=p.1D(b,"")):(c=1q(p),v=m?p.1t((c+"").1c)||"":""),""===v&&(v=r[o]||d),p=c||0===c?(g?c+l:c)+v:t[o],d!==v&&""!==v&&(c||0===c)&&(l||0===l)&&(l=J(e,o,l,d),"%"===v?(l/=J(e,o,23,"%")/23,l>23&&(l=23),t.85!==!0&&(h=l+"%")):"4d"===v?l/=J(e,o,1,"4d"):(c=J(e,o,c,v),v="2d"),g&&(c||0===c)&&(p=c+l+v)),g&&(c+=l),!l&&0!==l||!c&&0!==c?2u 0!==y[o]&&(p||"ad"!=p+""&&1d!=p)?(n=1g 24(y,o,c||l||0,0,n,-1,o,!1,0,h,p),n.1W="3r"!==p||"6s"!==o&&-1===o.1k("ae")?p:h):U("ao "+o+" 6v az: "+t[o]):(n=1g 24(y,o,l,c-l,n,0,o,f!==!1&&("2d"===v||"3F"===o),0,h,p),n.1W=v)):n=4f(y,o,h,p,!0,1d,n,0,s)),s&&n&&!n.2A&&(n.2A=s);18 n},a.1X=17(e){19 t,n,r,i=15.1r,s=1e-6;1a(1!==e||15.2V.1n!==15.2V.1N&&0!==15.2V.1n)1a(e||15.2V.1n!==15.2V.1N&&0!==15.2V.1n||15.2V.1O===-1e-6)1b(;i;){1a(t=i.c*e+i.s,i.r?t=t>0?0|t+.5:0|t-.5:s>t&&t>-s&&(t=0),i.2r)1a(1===i.2r)1a(r=i.l,2===r)i.t[i.p]=i.1W+t+i.3V+i.3O+i.5b;1m 1a(3===r)i.t[i.p]=i.1W+t+i.3V+i.3O+i.5b+i.6L+i.6H;1m 1a(4===r)i.t[i.p]=i.1W+t+i.3V+i.3O+i.5b+i.6L+i.6H+i.79+i.7u;1m 1a(5===r)i.t[i.p]=i.1W+t+i.3V+i.3O+i.5b+i.6L+i.6H+i.79+i.7u+i.9B+i.9F;1m{1b(n=i.1W+t+i.3V,r=1;i.l>r;r++)n+=i["3g"+r]+i["2X"+(r+1)];i.t[i.p]=n}1m-1===i.2r?i.t[i.p]=i.1W:i.1X&&i.1X(e);1m i.t[i.p]=t+i.1W;i=i.1f}1m 1b(;i;)2!==i.2r?i.t[i.p]=i.b:i.1X(e),i=i.1f;1m 1b(;i;)2!==i.2r?i.t[i.p]=i.e:i.1X(e),i=i.1f},a.9H=17(e){15.3S=e||3===15.3S?3:2,15.3p=15.3p||44(15.7t,i,!0)},a.5w=17(e,t,n,r){18 e&&(t&&(t.1l=e),e.1f&&(e.1f.1l=e.1l),e.1l?e.1l.1f=e.1f:15.1r===e&&(15.1r=e.1f,r=!0),n?n.1f=e:r||1d!==15.1r||(15.1r=e),e.1f=t,e.1l=n),e},a.2p=17(t){19 n,r,i,s=t;1a(t.5n||t.3E){s={};1b(r 1w t)s[r]=t[r];s.1Y=1,s.5n&&(s.6E=1)}18 t.39&&(n=15.6F)&&(i=n.3H,i&&i.1l?15.5w(i.1l,n.1f,i.1l.1l):i===15.1r&&(15.1r=n.1f),n.1f&&15.5w(n.1f,n.1f.1f,i.1l),15.6F=1d),e.1x.2p.1Z(15,s)};19 4n=17(e,t,n){19 r,i,s,o;1a(e.6G)1b(i=e.1c;--i>-1;)4n(e[i],t,n);1m 1b(r=e.7j,i=r.1c;--i>-1;)s=r[i],o=s.2r,s.1v&&(t.28(Q(s)),n&&n.28(s)),1!==o&&9!==o&&11!==o||!s.7j.1c||4n(s,t,n)};18 o.9X=17(e,n,r){19 i,s,o,u=t.3v(e,n,r),a=[u],f=[],l=[],c=[],h=t.4p.7i;1b(e=u.2z||u.2v,4n(e,f,c),u.1B(n,!0),4n(e,l),u.1B(0,!0),u.1M(!0),i=c.1c;--i>-1;)1a(s=G(c[i],f[i],l[i]),s.42){s=s.4T;1b(o 1w r)h[o]&&(s[o]=r[o]);a.28(t.3v(c[i],n,s))}18 a},e.6P([o]),o},!0)}),1T.3R&&1T.3b.4G()()',62,813,'|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||this||function|return|var|if|for|length|null||_next|new|Math|_startTime|typeof|indexOf|_prev|else|_time|vars|_timeline|parseFloat|_firstPT|split|substr|charAt|style|in|prototype|_timeScale|data|_paused|render|Number|replace|255|rotation|join|string|_gc|0px|_totalTime|mt|_enabled|_duration|_rawPrevTime|add|rotationX|_p1|skewX|window|timeline|immediateRender|xs0|setRatio|opacity|call||rotationY|arguments|100|ht||totalDuration|_first|push|_startAt|instanceof|parser|_active|px||scaleX|scaleY|sin|filter|easing|_p2|_totalDuration|dt|auto|_dirty|_kill|_|type|pr|number|void|target|_initted|getRatio|defaultValue|_targets|plugin|rt|duration|cos|_overwriteProps|smoothChildTiming|_reversed|_ease|5625|_delay|match|_labels|constructor|scaleZ|128|test|zOrigin|currentStyle|parse|prefix|format|_tween|splice|xs|_siblings|totalTime|skewY|180|_onUpdate|perspective|paused|_uncache|apply|cssText|startAt|className|wake|_gsQueue|_p3|_parseTimeOrLabel|tt|_overwrittenProps|xn|_last|ratio|St|top|sqrt|_calcEnd|pow|nodeType|_transform|parseInt|none|nt|config|time|to|selector|tweens|rawTime|it|_propLookup|height|_remove|et|alpha|zIndex|st|xfirst|appendXtra|API|Array|delete|width|gi|xn1|transform|ease|_gsDefine|_transformType|object|concat|xs1|getTweensOf|border|all|version|_listeners|frame|firstMPT|reversed|xt||parseComplex|multi|scale|dflt|transparent|_gsTransform|kill|em|seek|pt|color|set|onComplete|onReverseComplete|RegExp|PI|getPropertyValue|Mt|_initProps|_internals|position|offsetHeight|css|self|left|sc|atan2|bottom|delay|plugins|greensock|onStart|runBackwards|_pauseTime|force3D|com|pop|offsetWidth|_notifyPluginsOfEnabled|_sortChildren|_gsClassPT|overwrite|pg|_propName|isActive|autoRemoveChildren|transformOrigin|formatter|solid|difs|_onPluginEvent|keyword|ot|sleep|9999999999|_onInitAllProps||remove|Ticker|Lt|1e5||abs|ox|ieOffsetY|round|gsClass|xs2|TweenLite|ut|rgb|rxp|getChildren|toUpperCase|invalidate|192|core|ieOffsetX|Et|autoAlpha|_swapSelfInParams|easeParams|onUpdate|easeInOut|easeIn|next|strict|use|_linkCSSP|prev|tick|hidden|autoCSS|_func|_params|onStartParams|module|check|vt|priority|staggerTo|DXImageTransform|oy|Microsoft|Matrix|timeScale|false|_easeType|useFrames|easeOut|_overwrite|_priority|_hasPausedChild|define|throw|isNaN|Left|SlowMo||onCompleteParams|onCompleteScope|onStartScope|ms|console|fromTo|onUpdateParams|from|document|createElement|onUpdateScope|pause|625|984375|fps|_power|GreenSockGlobals|9375|_type|delayedCall|Scope|hsl|defaultEase|Params|setTimeout|_onDisable|360|display|shortRotation|rotationZ|tween|margin|padding|_ffFix|suffixMap|lt|shortRotationX|shortRotationY|inset|visibility|_classNamePT|slice|xs3|ft|_short|yt|xn2|_onInitTween|rgba|000|activate|removeAttribute|toLowerCase|cssFloat|inherit|log|999|styleFloat|borderLeft|_rootFramesTimeline|defaultView|borderTopWidth|_roundProps|Animation|kt|url||func|div|init|xn3|propName|onReverseCompleteParams|_init|center|right|_easePower|get|_gsTweenID|reservedProps|childNodes|Width|shiftChildren|appendChild|SimpleTimeline|onReverseCompleteScope|break|filters|Top|Right|_target|xs4|Ease|play|gap|WebkitBackfaceVisibility|zoom|_contains|Ct|marginLeft|Nt|_vars|Back|isFromStart|gt|Ot|template|strength|random|At|autoRound|Tt|removeLabel|TweenPlugin|rect|SteppedEase|isArray|isSelector|_p|_class|register|RoughEase|map|addLabel|marginRight|marginBottom|marginTop|insert|strictUnits|_updateRoot|Cannot|removeProperty|_onEnable|not|matrix|autoRotate|1e3|useRAF|startTime|defaultTransformPerspective|ticker|defaultOverwrite|Plugin|black|Date|events|directionalRotation|up|2e3|EventDispatcher|_eventTarget|transformPerspective|proxy|Linear|05|Quad|progid|absolute|M11|exports|wt|dispatchEvent|clrs|Dx|GreenSockAMDPath|Dy|oyp|01|autoSleep|oxp|M22|addEventListener|M21|M12|red|parseTransform|insertMultiple|cancelAnimationFrame|appendMultiple|CancelRequestAnimationFrame|stop|moz|getLabelTime|fill|RequestAnimationFrame||webkit|getTime|CancelAnimationFrame|addPause|now|easeNone|globals|oader||Cubic|clear|Quart|clearProps|radient|undefined|999999999999|Object|toString|amd|atrix|Quint|bezier|removeEventListener|swing|visible|gotoAndStop|gotoAndPlay|linear|004|physicsProps|throwProps|physics2D|Strong|Power|requestAnimationFrame|sequence|xn4|jQuery|_autoCSS|float|xs5|getElementById|_enableTransforms|jquery|killTweensOf|_addTween|illegal|_super|progress|killDelayedCallsTo|totalProgress|_tempKill|_plugins|preexisting|allOnStart|concurrent|true|_rootTimeline|cascadeTo|120|repeatDelay|repeat|_dummyGS|_tweenLookup|onRepeat|onRepeatParams|yoyo|onRepeatScope|definition|on|staggerFromTo|clearTimeout|exportRoot|staggerFrom|NaN|Style|1500|normal|start|Color|stroke|or|is|into|the|invalid|stagger|global|restart|reverse||initAll|overwriteProps|eventCallback|GSAP|encountered|value|align|resume|TimelineLite|missing|dependency|append|clipTop|offset|Origin|borderTop|Bottom|removeChild|body|line|borderLeftWidth|parentNode|oxr|oyr|aqua|lime|silver|maroon|borderBottomLeftRadius|ccw|rad|short|_cw|clientHeight|clientWidth|Android|backgroundPosition|Safari|Chrome|userAgent|navigator|background|img|_specialProps|Version|Firefox|Moz|Ms|Webkit|getComputedStyle|getElementsByTagName|1px|MSIE|exec|innerHTML|teal|blue|Error|js|file|loaded||_cssRegister|_registerComplexSpecialProp|end|CSSPropTween|collapsible|block|registerSpecialProp|expand|translate3d|gradient|Alpha|sizingMethod|matrix3d|179|shortRotationZ|270|_parseToProxy|_setPluginRatio|orange|165|gray|purple|yellow|olive|navy|white|fuchsia|green|borderBottomRightRadius|borderRadius|boxShadow|hsla|borderTopLeftRadius|cyan|pink|borderTopRightRadius|203|backgroundPositionX|getStyle|70158|ExpoIn|clip|ExpoOut|paddingBottom|Expo|001|ExpoInOut|SineOut|clipRight|sort|525|backfaceVisibility|Sine|paddingRight|Bounce|CircInOut|BounceInOut|CircIn|paddingTop|Circ|CircOut||BounceIn|asin|ElasticInOut|userSelect|ElasticIn|ElasticOut|BounceOut|Elastic|out|clipBottom|CSSPlugin|paddingLeft|src|999999999|backgroundSize|SineIn|perspectiveOrigin|borderTopStyle|setAttribute|zA|Z0|fontSize|backgroundPositionY|borderTopColor|backgroundImage|taper|BackInOut|EaseLookup|usesFrames|clamp|transformStyle|SineInOut|find|randomize|clipLeft|BackOut|points|textShadow|BackIn'.split('|'),0,{}))

/*
	* LayerSlider
	* (c) 2011-2014 George Krupa, John Gera & Kreatura Media
	* Plugin web:			http://kreaturamedia.com/
	* licenses:				http://codecanyon.net/licenses/
*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--){d[e(c)]=k[c]||e(c)}k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('18 ad(e,t,n){16 r;6(1W e=="5T"){r=3A("#"+e)}19 6(1W e=="ai"){r=e}16 i,s;2p(t){1l"8N":i="bV 3A 99";s=\'96 98 4K bT ca b6 44 4O c5 c3 an c4 c2 2X 21 3A 9l c1 dG 23 2A 2e 64 4O de. <1Y>4P dd 4e 4O 5g dc db 2e 21 dj di 2X 2A 4Q da 21 "d3 bN d2 2e 3U" d1 d0 21 d4 & d5 d8 3K.</1Y>\';1j;1l"ae":i="5V 3A 99";s="96 98 4K d7 d6 ch an 5V 2s ("+n+\') 2X 21 3A 9l. 2A dk at dl 2s 1.7.0 44 dA. 4P b5 3A 2e 1.10.x 44 dz. dy: 4P do 2I dE 21 3A dD b6 4e 5g 4Q do 2I b5 2e 2.x 2s 2X 3A dx 4i 3m 2I bP b3 dw dq 4K dp 7 & 8. <a 2i="6P://dn.dm.5N/dv/4/69-23-du/#ap-13&ar-60">cZ cY cw cu cy cC 3A by cr cl.</a>\';1j}r.1r("12-3Z");r.3S(\'<p 1t="12-ck">!</p>\');r.3S(\'<p 1t="12-3Z-ci">2A: \'+i+"</p>");r.3S(\'<p 1t="12-3Z-8J">\'+s+"</p>")}(18(e){e.fn.2V=18(n){16 r="1.7.0";16 i=e.fn.8N;16 s=e(14);16 o=18(e,t){16 n=e.1E(".");16 r=t.1E(".");23(16 i=0;i<n.1k;++i){6(r.1k==i){1T 1g}6(1b(n[i])==1b(r[i])){cm}19 6(1b(n[i])>1b(r[i])){1T 1g}19{1T 1c}}6(n.1k!=r.1k){1T 1c}1T 1c};6(!o("1.8.0",i)){s.1r("12-aW")}6(!o(r,i)){ad(s,"ae",i)}19{6((1W n).3H("ai|2W")){1T 14.1O(18(e){1I t(14,n)})}19{6(n=="11"){16 u=e(14).11("2A").g;6(u){1T u}}19{1T 14.1O(18(t){16 r=e(14).11("2A");6(r){6(!r.g.36&&!r.g.48){6(1W n=="3V"){6(n>0&&n<r.g.2y+1&&n!=r.g.27){r.4C(n)}}19{2p(n){1l"1S":r.o.7v(r.g);r.1S("6j");1j;1l"1X":r.o.7l(r.g);r.1X("6j");1j;1l"22":6(!r.g.2w){r.o.b2(r.g);r.g.2t=1c;r.22()}1j}}}6(n=="4X"){r.d.64()}6((r.g.2w||!r.g.2w&&r.g.2t)&&n=="1x"){r.o.ax(r.g);r.g.2t=1g;r.g.1L.17(\'2b[1h*="66.53"], 2b[1h*="62.52"]\').1O(18(){2v(e(14).11("6C"))});r.1x()}6(n=="cn"){r.af()}}})}}}};16 t=18(u,a){16 f=14;f.$el=e(u).1r("12-2n");f.$el.11("2A",f);f.31=18(){f.o=e.4D({},t.9K,a);f.g=e.4D({},t.7q);f.1y=e.4D({},t.9Q);f.4Z=e.4D({},t.9H);f.g.co=e(u).30("12-aW")?1g:1c;6(f.g.2o){f.o.47=1g}6(f.o.2u==="cE"){f.o.2u=1c}6(f.o.2u==="av"){f.o.2u=1g}6(1W aY!=="2W"){f.t=e.4D({},aY)}6(1W aO!=="2W"){f.ct=e.4D({},aO)}6(!f.g.aN){f.g.aN=1c;f.4X();6(e("4u").17(\'aE[91*="5g"]\').1k){f.g.8v=e("4u").17(\'aE[91*="5g"]\').1f("91").1E("5g")[1]}6(e("4u").17(\'94[1h*="69"]\').1k){6(e("4u").17(\'94[1h*="69"]\').1f("1h").1i("?")!=-1){f.g.8x=e("4u").17(\'94[1h*="69"]\').1f("1h").1E("?")[1].1E("=")[1]}}f.d.aT("2A bq");f.d.aU(\'<a 2i="#">1S</a> | <a 2i="#">1X</a> | <a 2i="#">22</a> | <a 2i="#">1x</a> | <a 2i="#">cS 1x</a>\');f.d.3R.17("a").1O(18(){e(14).2k(18(t){t.3t();e(u).2V(e(14).8J())})});f.d.aT("2A 2s cR");f.d.aU("bN 2s: <1Y>"+f.g.2s+"</1Y>");6(f.g.8x){f.d.aL("cX 2s: <1Y>"+f.g.8x+"</1Y>")}6(f.g.8v){f.d.aL("5g 2s: <1Y>"+f.g.8v+"</1Y>")}f.d.aL("3A 2s: <1Y>"+e().8N+"</1Y>");6(e(u).1f("4N")){f.d.aT("2A 2n");f.d.aU("#"+e(u).1f("4N"))}6(!f.o.2r||f.o.2r==""||!f.o.3z||f.o.3z==""){f.d.aT("cW cV 2r. cP: cO 2r 4Q / 44 3z.");f.59()}19{f.d.aT("cI 2e 31 b3 2r: "+f.o.2r,1c);e(u).1r("12-"+f.o.2r);16 n=f.o.3z+f.o.2r+"/2r.1a";8w=e("bC");6(!e("bC").1k){8w=e("3U")}6(e(\'7c[2i="\'+n+\'"]\').1k){f.d.aU(\'cH "\'+f.o.2r+\'" 3m cG 2S.\');r=e(\'7c[2i="\'+n+\'"]\');6(!f.g.2S){f.g.2S=1c;f.g.a9=2g(18(){f.59()},7u)}}19{6(6c.bR){6c.bR(n);16 r=e(\'7c[2i="\'+n+\'"]\')}19{16 r=e(\'<7c 55="cF" 2i="\'+n+\'" 4y="8J/1a" />\').1w(8w)}}r.31(18(){6(!f.g.2S){f.d.aU("bl.31(); 8U");f.g.2S=1c;f.g.a8=2g(18(){f.59()},7u)}});e(2q).31(18(){6(!f.g.2S){f.d.aU("$(2q).31(); 8U");f.g.2S=1c;f.g.aa=2g(18(){f.59()},7u)}});f.g.ab=2g(18(){6(!f.g.2S){f.d.aT("cJ cK: cM bl.31(); 44 $(2q).31(); cL 8U");f.g.2S=1c;f.59()}},1P)}}};f.59=18(){6(!e("4u").1f("4N")){e("4u").1f("4N","12-7q")}19 6(!e("3U").1f("4N")){e("3U").1f("4N","12-7q")}f.g.1A=18(){1T e(u).1d()};f.g.1H=18(){1T e(u).1e()};e(u).17(".12-4G").2x("12-4G").1r("12-1p");e(u).17(\'.12-1p > *[1t*="12-s"]\').1O(18(){16 t=e(14).1f("1t").1E("12-s")[1].1E(" ")[0];e(14).2x("12-s"+t).1r("12-l"+t)});6(f.o.b8){f.o.33=f.o.b8}6(f.o.cN===1g){f.o.4B=1g}6(e(u).17(".12-1p").1k==1){f.o.7g=1g;f.o.8M=1g;f.o.7e=1g;f.o.7h=1g;f.o.4j=0;f.o.7m=1g;f.o.2u=1c;f.o.33=1;f.o.3e="av"}6(f.o.1d){f.g.8y=f.g.2E=""+f.o.1d}19{f.g.8y=f.g.2E=e(u)[0].1N.1d}6(f.o.1e){f.g.4m=""+f.o.1e}19{f.g.4m=e(u)[0].1N.1e}6(f.g.2E.1i("%")==-1&&f.g.2E.1i("1J")==-1){f.g.2E+="1J"}6(f.g.4m.1i("%")==-1&&f.g.4m.1i("1J")==-1){f.g.4m+="1J"}6(f.o.9L&&f.g.2E.1i("1J")!=-1&&f.g.4m.1i("1J")!=-1){f.g.4a=1c}19{f.g.4a=1g}e(u).17(\'*[1t*="12-l"], *[1t*="12-bg"]\').1O(18(){6(!e(14).24().30("12-1p")){e(14).cU(e(14).24())}});e(u).17(".12-1p").1O(18(){e(14).3h(\':2I([1t*="12-"])\').1O(18(){e(14).7a()});16 t=e("<1n>").1r("12-cT");6(e(14).17(".12-bg").1k){t.cQ(e(14).17(".12-bg").eq("0"))}19{t.6q(e(14))}});e(u).17(\'.12-1p, *[1t*="12-l"]\').1O(18(){6(e(14).11("12")||e(14).1f("55")||e(14).1f("1N")){6(e(14).11("12")){16 t=e(14).11("12").20().1E(";")}19 6(e(14).1f("55")&&e(14).1f("55").1i(":")!=-1&&e(14).1f("55").1i(";")!=-1){16 t=e(14).1f("55").20().1E(";")}19{16 t=e(14).1f("1N").20().1E(";")}23(x=0;x<t.1k;x++){3G=t[x].1E(":");6(3G[0].1i("4A")!=-1){3G[1]=f.ak(3G[1])}16 n="";6(3G[2]){n=":"+e.5A(3G[2])}6(3G[0]!=" "&&3G[0]!=""){e(14).11(e.5A(3G[0]),e.5A(3G[1])+n)}}}16 r=e(14);r.11("4h",r[0].1N.1m);r.11("4k",r[0].1N.1q);6(e(14).3m("a")&&e(14).3h().1k>0){r=e(14).3h()}16 i=r.1d();16 s=r.1e();6(r[0].1N.1d&&r[0].1N.1d.1i("%")!=-1){i=r[0].1N.1d}6(r[0].1N.1e&&r[0].1N.1e.1i("%")!=-1){s=r[0].1N.1e}r.11("2Z",i);r.11("2Y",s);r.11("7F",r.1a("28-1m"));r.11("7z",r.1a("28-1F"));r.11("8R",r.1a("28-1q"));r.11("8Q",r.1a("28-1o"));16 o=1W 3i(r.1a("2Q"))=="3V"?1C.cD(3i(r.1a("2Q"))*1D)/1D:1;e(14).11("7d",o);6(r.1a("3v-1m-1d").1i("1J")==-1){r.11("6H",r[0].1N.9d)}19{r.11("6H",r.1a("3v-1m-1d"))}6(r.1a("3v-1F-1d").1i("1J")==-1){r.11("6K",r[0].1N.97)}19{r.11("6K",r.1a("3v-1F-1d"))}6(r.1a("3v-1q-1d").1i("1J")==-1){r.11("6J",r[0].1N.9g)}19{r.11("6J",r.1a("3v-1q-1d"))}6(r.1a("3v-1o-1d").1i("1J")==-1){r.11("6I",r[0].1N.9V)}19{r.11("6I",r.1a("3v-1o-1d"))}r.11("9u",r.1a("9h-9j"));r.11("9n",r.1a("9k-1e"))});6(6c.4M.aV){23(16 t=0;t<e(u).17(".12-1p").1k;t++){6(e(u).17(".12-1p").eq(t).11("cp")==6c.4M.aV.1E("#")[1]){f.o.33=t+1}}}e(u).17(\'*[1t*="12-7K-"]\').1O(18(){16 t=e(14).1f("1t").1E(" ");23(16 n=0;n<t.1k;n++){6(t[n].1i("12-7K-")!=-1){16 r=1b(t[n].1E("12-7K-")[1]);e(14).1a({cq:"cj"}).2k(18(t){t.3t();e(u).2V(r)})}}});f.g.2y=e(u).17(".12-1p").1k;6(f.o.7k&&f.g.2y>2){f.o.33=="2h";f.o.92=1g}19{f.o.7k=1g}6(f.o.33=="2h"){f.o.33=1C.26(1C.2h()*f.g.2y+1)}f.o.5h=f.o.5h<f.g.2y+1?f.o.5h:1;f.o.5h=f.o.5h<1?1:f.o.5h;f.g.4r=1;6(f.o.4B){f.g.4r=0}16 n=6c.4M.2i.1i("cs:")===-1?"":"6P:";e(u).17(\'2b[1h*="66.53"], 2b[1h*="53.be"]\').1O(18(){e(14).24().1r("12-2M-4G");6(e(14).24(\'[1t*="12-l"]\')){16 t=e(14);16 r=n;e.bA(r+"//cA.8j.5N/cB/bH/cz/"+e(14).1f("1h").1E("89/")[1].1E("?")[0]+"?v=2&5J=bS&bQ=?",18(e){t.11("6Q",1b(e["ar"]["cv$ap"]["cx$2l"]["dt"])*1P)});16 i=e("<1n>").1r("12-67").1w(e(14).24());6(f.o.47){e("<1Z>").1w(i).1r("12-2F").1f("5J","6O 2M").11("1h",r+"//1Z.8j.5N/bx/"+e(14).1f("1h").1E("89/")[1].1E("?")[0]+"/"+f.o.87)}19{e("<1Z>").1w(i).1r("12-2F").1f("5J","6O 2M").1f("1h",r+"//1Z.8j.5N/bx/"+e(14).1f("1h").1E("89/")[1].1E("?")[0]+"/"+f.o.87)}e("<1n>").1w(i).1r("12-bM");e(14).24().1a({1d:e(14).1d(),1e:e(14).1e()}).2k(18(){f.g.36=1c;6(f.g.38){6(f.o.2u!=1g){f.g.38=1g}f.g.2t=1c}19{f.g.2t=f.g.2w}6(f.o.2u!=1g){f.1x()}f.g.5b=1c;r=e(14).17("2b").11("3X").1i("6P")===-1?n:"";e(14).17("2b").1f("1h",r+e(14).17("2b").11("3X"));e(14).17(".12-67").1M(f.g.v.d).3J(f.g.v.fo,18(){6(f.o.2u=="1U"&&f.g.2t==1c){16 e=2g(18(){f.22()},t.11("6Q")-f.g.v.d);t.11("6C",e)}f.g.36=1g;6(f.g.2T==1c){f.3s(f.g.1L,18(){f.g.2T=1g})}})});16 s="&";6(e(14).1f("1h").1i("?")==-1){s="?"}16 o="&ba=b4&ds=1";6(e(14).1f("1h").1i("4f")==-1){e(14).11("3X",e(14).1f("1h")+s+"4f=1"+o)}19{e(14).11("3X",e(14).1f("1h").2j("4f=0","4f=1")+o)}e(14).11("2Z",e(14).1f("1d"));e(14).11("2Y",e(14).1f("1e"));e(14).1f("1h","")}});e(u).17(\'2b[1h*="62.52"]\').1O(18(){e(14).24().1r("12-2M-4G");6(e(14).24(\'[1t*="12-l"]\')){16 t=e(14);16 r=n;16 i=e("<1n>").1r("12-67").1w(e(14).24());e.bA(r+"//52.5N/bH/dr/2M/"+e(14).1f("1h").1E("2M/")[1].1E("?")[0]+".bS?bQ=?",18(n){6(f.o.47){e("<1Z>").1w(i).1r("12-2F").1f("5J","6O 2M").11("1h",n[0]["bJ"])}19{e("<1Z>").1w(i).1r("12-2F").1f("5J","6O 2M").1f("1h",n[0]["bJ"])}t.11("6Q",1b(n[0]["2l"])*1P);e("<1n>").1w(i).1r("12-bM")});e(14).24().1a({1d:e(14).1d(),1e:e(14).1e()}).2k(18(){f.g.36=1c;6(f.g.38){6(f.o.2u!=1g){f.g.38=1g}f.g.2t=1c}19{f.g.2t=f.g.2w}6(f.o.2u!=1g){f.1x()}f.g.5b=1c;r=e(14).17("2b").11("3X").1i("6P")===-1?n:"";e(14).17("2b").1f("1h",r+e(14).17("2b").11("3X"));e(14).17(".12-67").1M(f.g.v.d).3J(f.g.v.fo,18(){6(f.o.2u=="1U"&&f.g.2t==1c){16 e=2g(18(){f.22()},t.11("6Q")-f.g.v.d);t.11("6C",e)}f.g.36=1g;6(f.g.2T==1c){f.3s(f.g.1L,18(){f.g.2T=1g})}})});16 s="&";6(e(14).1f("1h").1i("?")==-1){s="?"}16 o="&ba=b4";6(e(14).1f("1h").1i("4f")==-1){e(14).11("3X",e(14).1f("1h")+s+"4f=1"+o)}19{e(14).11("3X",e(14).1f("1h").2j("4f=0","4f=1")+o)}e(14).11("2Z",e(14).1f("1d"));e(14).11("2Y",e(14).1f("1e"));e(14).1f("1h","")}});e(u).17("2M, 6X").1O(18(){16 t=1W e(14).1f("1d")!=="2W"?e(14).1f("1d"):"dF";16 n=1W e(14).1f("1e")!=="2W"?e(14).1f("1e"):""+e(14).1e();6(t.1i("%")===-1){t=1b(t)}6(n.1i("%")===-1){n=1b(n)}6(t==="1D%"&&(n===0||n==="0"||n==="1D%")){e(14).1f("1e","1D%");n="1U"}e(14).24().1r("12-2M-4G").1a({1d:t,1e:n}).11({2Z:t,2Y:n});16 r=e(14);e(14).5E("1d").5E("1e").1a({1d:"1D%",1e:"1D%"}).2k(18(){6(1W r.1f("bq")==="2W"){14.dC=0;14.dB()}f.g.36=1c;6(f.g.38){6(f.o.2u!==1g){f.g.38=1g}f.g.2t=1c}19{f.g.2t=f.g.2w}6(f.o.2u!==1g){f.1x()}f.g.5b=1c;e(14).4e("d9",18(){6(f.o.2u==="1U"&&f.g.2t===1c){f.22()}});f.g.36=1g;6(f.g.2T===1c){f.3s(f.g.1L,18(){f.g.2T=1g})}})});6(f.o.4B){f.o.33=f.o.33-1===0?f.g.2y:f.o.33-1}f.g.27=f.o.33;f.g.1L=e(u).17(".12-1p:eq("+(f.g.27-1)+")");e(u).17(".12-1p").dh(\'<1n 1t="12-2c"></1n>\');6(f.o.9W){f.g.3u=e("<1n>").1r("12-dg-5Q").1w(e(u).17(".12-2c"))}6(f.o.a6&&!f.g.2o){f.g.3f=e("<1n>").1r("12-df-5Q").1w(e(u).17(".12-2c"));f.g.3f.3S(e(\'<1n 1t="12-ct-1m"><1n 1t="12-ct-3F"><1n 1t="12-ct-9N"><1n 1t="12-ct-a5"></1n></1n></1n></1n><1n 1t="12-ct-1F"><1n 1t="12-ct-3F"><1n 1t="12-ct-9N"><1n 1t="12-ct-a5"></1n></1n></1n></1n><1n 1t="12-ct-cc"></1n>\'))}f.g.3E=e("<1n>").1a({aD:-1,1K:"1Q"}).1r("12-9T-2n").1w(e(u));e("<1n>").1r("12-9T-c7").1w(f.g.3E);6(e(u).1a("3x")=="c8"){e(u).1a("3x","aq")}6(f.o.7p){e(u).17(".12-2c").1a({bX:"63("+f.o.7p+")"})}19{e(u).17(".12-2c").1a({bY:f.o.8q})}6(f.o.8q=="8p"&&f.o.7p==1g){e(u).17(".12-2c").1a({3l:"1Q 8p !bZ"})}e(u).17(".12-1p 1Z").1O(18(){e(14).5E("1d").5E("1e");6(f.o.43===1c&&f.o.47===1c){6(1W e(14).11("1h")!=="5T"){e(14).11("1h",e(14).1f("1h"));16 t=f.o.3z+"../1a/c0.c6";e(14).1f("1h",t)}}19{6(1W e(14).11("1h")==="5T"){e(14).1f("1h",e(14).11("1h"));e(14).5E("11-1h")}}});e(u).17(".12-1p").4e("cd",18(t){f.g.bG=t.8X-e(14).24().5m().1m;f.g.bF=t.bE-e(14).24().5m().1q});e(u).17(".12-1p").4e("aj",18(t){16 n=e(14).24().5m().1m+f.g.bG;16 r=e(14).24().5m().1q+f.g.bF;16 i=t.8X-n;16 s=t.bE-r;e(14).17("> *:2I(.12-bg)").1O(18(){6(1W e(14).11("4V")!=="2W"&&1b(e(14).11("4V"))!==0){e(14).1a({3p:-i/1D*1b(e(14).11("4V")),3O:-s/1D*1b(e(14).11("4V"))})}})});e(u).17(".12-1p").4e("ce",18(){e(14).17("> *:2I(.12-bg)").1O(18(){6(1W e(14).11("4V")!=="2W"&&1b(e(14).11("4V"))!==0){3a.2e(14,.4,{1a:{3p:0,3O:0}})}})});6(f.o.8M){e(\'<a 1t="12-1s-1S" 2i="#" />\').2k(18(t){t.3t();e(u).2V("1S")}).1w(e(u));e(\'<a 1t="12-1s-1X" 2i="#" />\').2k(18(t){t.3t();e(u).2V("1X")}).1w(e(u));6(f.o.9F){e(u).17(".12-1s-1S, .12-1s-1X").1a({1K:"1Q"});e(u).1R(18(){6(!f.g.8r){6(f.g.2o){e(u).17(".12-1s-1S, .12-1s-1X").1a("1K","2m")}19{e(u).17(".12-1s-1S, .12-1s-1X").1x(1c,1c).2J(2z)}}},18(){6(f.g.2o){e(u).17(".12-1s-1S, .12-1s-1X").1a("1K","1Q")}19{e(u).17(".12-1s-1S, .12-1s-1X").1x(1c,1c).3J(2z)}})}}6(f.o.7e||f.o.7h){16 r=e(\'<1n 1t="12-1o-1s-2R" />\').1w(e(u));f.g.3n=r;6(f.o.3e=="4R"){r.1r("12-aJ-5i")}6(f.o.7h&&f.o.3e!="4R"){e(\'<5G 1t="12-1o-4T" />\').1w(e(u).17(".12-1o-1s-2R"));6(f.o.3e=="1R"){16 i=e(\'<1n 1t="12-1G-1R"><1n 1t="12-1G-1R-2c"><1n 1t="12-1G-1R-bg"></1n><1n 1t="12-1G-1R-1Z"><1Z></1n><5G></5G></1n></1n>\').1w(e(u).17(".12-1o-4T"))}23(x=1;x<f.g.2y+1;x++){16 s=e(\'<a 2i="#" />\').1w(e(u).17(".12-1o-4T")).2k(18(t){t.3t();e(u).2V(e(14).5D()+1)});6(f.o.3e=="1R"){e(u).17(".12-1G-1R, .12-1G-1R-1Z").1a({1d:f.o.7V,1e:f.o.65});16 o=e(u).17(".12-1G-1R");16 a=o.17("1Z").1a({1e:f.o.65});16 l=e(u).17(".12-1G-1R-2c").1a({29:"2O",1K:"2m"});s.1R(18(){16 t=e(u).17(".12-1p").eq(e(14).5D());16 n;6(f.o.43===1c&&f.o.47===1c){6(t.17(".12-4l").1k){n=t.17(".12-4l").11("1h")}19 6(t.17(".12-2F").1k){n=t.17(".12-2F").11("1h")}19 6(t.17(".12-bg").1k){n=t.17(".12-bg").11("1h")}19{n=f.o.3z+f.o.2r+"/6D.4H"}}19{6(t.17(".12-4l").1k){n=t.17(".12-4l").1f("1h")}19 6(t.17(".12-2F").1k){n=t.17(".12-2F").1f("1h")}19 6(t.17(".12-bg").1k){n=t.17(".12-bg").1f("1h")}19{n=f.o.3z+f.o.2r+"/6D.4H"}}e(u).17(".12-1G-1R-1Z").1a({1m:1b(o.1a("28-1m")),1q:1b(o.1a("28-1q"))});a.31(18(){6(e(14).1d()==0){a.1a({3x:"aq",3j:"0 1U",1m:"1U"})}19{a.1a({3x:"cf",3p:-e(14).1d()/2,1m:"50%"})}}).1f("1h",n);o.1a({1K:"2m"}).1x().4s({1m:e(14).3x().1m+(e(14).1d()-o.3D())/2},8i);l.1a({1K:"1Q",29:"34"}).1x().2J(8i)},18(){l.1x().3J(8i,18(){o.1a({29:"2O",1K:"2m"})})})}}6(f.o.3e=="1R"){i.1w(e(u).17(".12-1o-4T"))}e(u).17(".12-1o-4T a:eq("+(f.o.33-1)+")").1r("12-1s-1V")}6(f.o.7e){16 c=e(\'<a 1t="12-1s-22" 2i="#" />\').2k(18(t){t.3t();e(u).2V("22")}).6q(e(u).17(".12-1o-1s-2R"));16 h=e(\'<a 1t="12-1s-1x" 2i="#" />\').2k(18(t){t.3t();e(u).2V("1x")}).1w(e(u).17(".12-1o-1s-2R"))}19 6(f.o.3e!="4R"){e(\'<5G 1t="12-1s-aw 12-1s-cb" />\').6q(e(u).17(".12-1o-1s-2R"));e(\'<5G 1t="12-1s-aw 12-1s-bW" />\').1w(e(u).17(".12-1o-1s-2R"))}6(f.o.7j&&f.o.3e!="4R"){r.1a({1K:"1Q"});e(u).1R(18(){6(!f.g.8r){6(f.g.2o){r.1a("1K","2m")}19{r.1x(1c,1c).2J(2z)}}},18(){6(f.g.2o){r.1a("1K","1Q")}19{r.1x(1c,1c).3J(2z)}})}}6(f.o.3e=="4R"){f.g.42=e(\'<1n 1t="12-1G-2R"></1n>\').1w(e(u));16 i=e(\'<1n 1t="12-1G"><1n 1t="12-1G-2c"><1n 1t="12-1G-1p-2n"><1n 1t="12-1G-1p"></1n></1n></1n></1n>\').1w(f.g.42);f.g.5i=e(u).17(".12-1G-1p-2n");6(!("6s"3M 2q)){f.g.5i.1R(18(){e(14).1r("12-1G-1p-1R")},18(){e(14).2x("12-1G-1p-1R");f.7y()}).aj(18(t){16 n=1b(t.8X-e(14).5m().1m)/e(14).1d()*(e(14).1d()-e(14).17(".12-1G-1p").1d());e(14).17(".12-1G-1p").1x().1a({3p:n})})}19{f.g.5i.1r("12-c9")}e(u).17(".12-1p").1O(18(){16 t=e(14).5D()+1;16 n;6(f.o.43===1c&&f.o.47===1c){6(e(14).17(".12-4l").1k){n=e(14).17(".12-4l").11("1h")}19 6(e(14).17(".12-2F").1k){n=e(14).17(".12-2F").11("1h")}19 6(e(14).17(".12-bg").1k){n=e(14).17(".12-bg").11("1h")}19{n=f.o.3z+f.o.2r+"/6D.4H"}}19{6(e(14).17(".12-4l").1k){n=e(14).17(".12-4l").1f("1h")}19 6(e(14).17(".12-2F").1k){n=e(14).17(".12-2F").1f("1h")}19 6(e(14).17(".12-bg").1k){n=e(14).17(".12-bg").1f("1h")}19{n=f.o.3z+f.o.2r+"/6D.4H"}}16 r=e(\'<a 2i="#" 1t="12-4g-\'+t+\'"><1Z 1h="\'+n+\'"></a>\');r.1w(e(u).17(".12-1G-1p"));6(!("6s"3M 2q)){r.1R(18(){e(14).3h().1x().6t(2z,f.o.7U/1D)},18(){6(!e(14).3h().30("12-4g-1V")){e(14).3h().1x().6t(2z,f.o.81/1D)}})}r.2k(18(n){n.3t();e(u).2V(t)})});6(c&&h){16 p=f.g.3n=e(\'<1n 1t="12-1o-1s-2R 12-cg-5i"></1n>\').1w(e(u));c.8c().2k(18(t){t.3t();e(u).2V("22")}).1w(p);h.8c().2k(18(t){t.3t();e(u).2V("1x")}).1w(p)}6(f.o.7j){f.g.42.1a("1K","1Q");6(p){f.g.3n=p.1a("1K")=="2m"?p:e(u).17(".12-aJ-5i");f.g.3n.1a("1K","1Q")}e(u).1R(18(){e(u).1r("12-1R");6(!f.g.8r){6(f.g.2o){f.g.42.1a("1K","2m");6(f.g.3n){f.g.3n.1a("1K","2m")}}19{f.g.42.1x(1c,1c).2J(2z);6(f.g.3n){f.g.3n.1x(1c,1c).2J(2z)}}}},18(){e(u).2x("12-1R");6(f.g.2o){f.g.42.1a("1K","1Q");6(f.g.3n){f.g.3n.1a("1K","1Q")}}19{f.g.42.1x(1c,1c).3J(2z);6(f.g.3n){f.g.3n.1x(1c,1c).3J(2z)}}})}}f.g.40=e(\'<1n 1t="12-40"></1n>\').1w(e(u));6(f.g.40.1a("1K")=="2m"&&!f.g.40.17("1Z").1k){f.g.6G=18(){f.g.40.1a({1K:"1Q",29:"34"}).2J(41,18(){f.g.6G=1g})};f.g.51=e("<1Z>").1f("1h",f.o.3z+f.o.2r+"/40.4H").1w(f.g.40);f.g.9B=1W 1b(e(u).1a("28-1o"))=="3V"?1b(e(u).1a("28-1o")):0}f.8t();6(f.o.9y&&e(u).17(".12-1p").1k>1){e("3U").6F("bU",18(e){6(!f.g.36&&!f.g.48){6(e.bm==37){f.o.7v(f.g);f.1S("6j")}19 6(e.bm==39){f.o.7l(f.g);f.1X("6j")}}})}6("6s"3M 2q&&e(u).17(".12-1p").1k>1&&f.o.9G){e(u).17(".12-2c").6F("ec",18(e){16 t=e.5a?e.5a:e.bf.5a;6(t.1k==1){f.g.6E=f.g.5z=t[0].bK}});e(u).17(".12-2c").6F("eD",18(e){16 t=e.5a?e.5a:e.bf.5a;6(t.1k==1){f.g.5z=t[0].bK}6(1C.49(f.g.6E-f.g.5z)>45){e.3t()}});e(u).17(".12-2c").6F("eV",18(t){6(1C.49(f.g.6E-f.g.5z)>45){6(f.g.6E-f.g.5z>0){f.o.7l(f.g);e(u).2V("1X")}19{f.o.7v(f.g);e(u).2V("1S")}}})}6(f.o.9M==1c&&e(u).17(".12-1p").1k>1){e(u).17(".12-2c").1R(18(){f.o.au(f.g);6(f.g.2w){f.g.38=1c;f.1x();6(f.g.3u){f.g.3u.1x()}6(f.g.3f){6(f.g.2P){f.g.2P.68()}}f.g.46=(1I 57).4U()}},18(){6(f.g.38==1c){f.22();f.g.38=1g}})}f.8z();6(f.o.1u){f.g.1u=e("<1Z>").1r("12-eU").1w(e(u)).1f("1N",f.o.bo).1a({29:"2O",1K:"eT"}).31(18(){16 t=0;6(!f.g.1u){t=1P}2g(18(){f.g.1u.11("2Z",f.g.1u.1d());f.g.1u.11("2Y",f.g.1u.1e());6(f.g.1u.1a("1m")!="1U"){f.g.1u.11("4h",f.g.1u[0].1N.1m)}6(f.g.1u.1a("1F")!="1U"){f.g.1u.11("6e",f.g.1u[0].1N.1F)}6(f.g.1u.1a("1q")!="1U"){f.g.1u.11("4k",f.g.1u[0].1N.1q)}6(f.g.1u.1a("1o")!="1U"){f.g.1u.11("6d",f.g.1u[0].1N.1o)}6(f.o.7Z!=1g){e("<a>").1w(e(u)).1f("2i",f.o.7Z).1f("eR",f.o.bp).1a({eS:"1Q",eW:"1Q"}).3S(f.g.1u)}f.g.1u.1a({1K:"1Q",29:"34"});f.8Z()},t)}).1f("1h",f.o.1u)}e(2q).2T(18(){f.g.2T=1c;6(!f.g.36){f.3s(f.g.1L,18(){6(f.g.2D){f.g.2D.5C()}f.g.2T=1g});6(f.g.1u){f.8Z()}}});f.g.9a=1c;6(f.o.4B==1c){6(f.o.7g){f.g.2w=1c;e(u).17(".12-1s-22").1r("12-1s-22-1V")}19{e(u).17(".12-1s-1x").1r("12-1s-1x-1V")}f.1X()}19{f.43(f.g.1L,18(){f.g.1L.2J(1P,18(){f.g.48=1g;e(14).1r("12-1V");6(f.o.86){e(14).1M(e(14).11("5d")+25).f1(18(){e(14).17(".12-2F, 2M, 6X").2k();e(14).8D()})}f.g.1L.17(\' > *[1t*="12-l"]\').1O(18(){6(e(14).11("5v")>0){16 t=e(14);t.11("6W",2g(18(){f.8H(t)},t.11("5v")))}})});f.7R(f.g.27);6(f.o.7g){f.g.48=1g;f.22()}19{e(u).17(".12-1s-1x").1r("12-1s-1x-1V")}})}f.o.bz(e(u))};f.22=18(){6(f.g.2w){6(f.g.2f=="1S"&&f.o.92){f.1S()}19{f.1X()}}19{f.g.2w=1c;6(!f.g.36&&!f.g.48){f.5Q()}}e(u).17(".12-1s-22").1r("12-1s-22-1V");e(u).17(".12-1s-1x").2x("12-1s-1x-1V")};f.5Q=18(){6(e(u).17(".12-1V").11("12")){16 t=f.4Z.7i}19{16 t=f.o.7i}16 n=e(u).17(".12-1V").11("5H")?1b(e(u).17(".12-1V").11("5H")):t;6(!f.o.4B&&!e(u).17(".12-1V").11("5H")){16 r=e(u).17(".12-1p:eq("+(f.o.33-1)+")").11("5H");n=r?r:t}2v(f.g.4o);6(f.g.46){6(!f.g.4d){f.g.4d=(1I 57).4U()}6(f.g.4d>f.g.46){f.g.46=(1I 57).4U()}6(!f.g.3I){f.g.3I=n}f.g.3I-=f.g.46-f.g.4d;f.g.46=1g;f.g.4d=(1I 57).4U()}19{f.g.3I=n;f.g.4d=(1I 57).4U()}f.g.3I=1b(f.g.3I);f.g.4o=2g(18(){f.g.4d=f.g.46=f.g.3I=1g;f.22()},f.g.3I);6(f.g.3u){f.g.3u.4s({1d:f.g.1A()},f.g.3I,"8b",18(){e(14).1a({1d:0})})}6(f.g.3f){16 i=f.g.3f.17(".12-ct-1F .12-ct-3F");16 s=f.g.3f.17(".12-ct-1m .12-ct-3F");6(f.g.3f.1a("1K")=="1Q"){i.1a({3F:0});s.1a({3F:0});f.g.3f.2J(b1)}6(!f.g.2P){f.g.2P=1I bD;f.g.2P.aZ(3a.6R(i[0],n/b0,{3g:0},{3T:7B.7A,3g:6N,f0:18(){f.g.2P=1g}}));f.g.2P.aZ(3a.6R(s[0],n/b0,{3g:0},{3T:7B.7A,3g:6N}))}19{f.g.2P.eZ()}}};f.1x=18(){f.g.46=(1I 57).4U();6(f.g.3u){f.g.3u.1x()}6(f.g.3f){6(f.g.2P){f.g.2P.68()}}6(!f.g.38&&!f.g.2t){e(u).17(".12-1s-1x").1r("12-1s-1x-1V");e(u).17(".12-1s-22").2x("12-1s-22-1V")}2v(f.g.4o);f.g.2w=1g};f.af=18(){2v(f.g.4o);f.g.2w=1g;2v(f.g.a9);2v(f.g.a8);2v(f.g.aa);2v(f.g.ab);2v(f.g.aB);6(f.g.3u){f.g.3u.1x()}6(f.g.3f){6(f.g.2P){f.g.2P.68()}}e(u).17("*").1x(1c,1g).8D();e(u).17(".12-1p >").1O(18(){6(e(14).11("3N")){e(14).11("3N").68()}});6(!f.g.38&&!f.g.2t){e(u).17(".12-1s-1x").1r("12-1s-1x-1V");e(u).17(".12-1s-22").2x("12-1s-22-1V")}};f.eY=18(){e(u).17("*").1x();2v(f.g.4o);f.4C(f.g.27,f.g.2f)};f.ak=18(t){6(e.5A(t.20())=="aR"||e.5A(t.20())=="8b"){1T t.20()}19{1T t.2j("7E","aS").2j("7J","ay").2j("7H","az").2j("eQ","eP").2j("eH","eG").2j("eF","eE").2j("eJ","eO").2j("eN","eM").2j("eK","eL").2j("f3","fp").2j("fm","fl").2j("5P","fj").2j("fk","fq")}};f.1S=18(e){6(f.g.27<2){f.g.4r+=1}6(f.g.4r>f.o.4j&&f.o.4j>0&&!e){f.g.4r=0;f.1x();6(f.o.7m==1g){f.o.4j=0}}19{16 t=f.g.27<2?f.g.2y:f.g.27-1;f.g.2f="1S";f.4C(t,f.g.2f)}};f.1X=18(e){6(!f.o.7k){6(!(f.g.27<f.g.2y)){f.g.4r+=1}6(f.g.4r>f.o.4j&&f.o.4j>0&&!e){f.g.4r=0;f.1x();6(f.o.7m==1g){f.o.4j=0}}19{16 t=f.g.27<f.g.2y?f.g.27+1:1;f.g.2f="1X";f.4C(t,f.g.2f)}}19 6(!e){16 t=f.g.27;16 n=18(){t=1C.26(1C.2h()*f.g.2y)+1;6(t==f.g.27){n()}19{f.g.2f="1X";f.4C(t,f.g.2f)}};n()}19 6(e){16 t=f.g.27<f.g.2y?f.g.27+1:1;f.g.2f="1X";f.4C(t,f.g.2f)}};f.4C=18(t,n){f.g.4d=f.g.46=f.g.3I=1g;6(f.g.3u){f.g.3u.1x().1M(2z).4s({1d:0},fr)}6(f.g.3f){f.g.3f.3J(41);6(f.g.2P){f.g.2P.5W().2l(.35)}}6(f.g.5b==1c){f.g.5b=1g;f.g.2w=f.g.2t;f.g.1L.17(\'2b[1h*="66.53"], 2b[1h*="62.52"]\').1O(18(){e(14).24().17(".12-67").2J(f.g.v.fi,18(){e(14).24().17("2b").1f("1h","")})});f.g.1L.17("2M, 6X").1O(18(){14.68()})}e(u).17(\'2b[1h*="66.53"], 2b[1h*="62.52"]\').1O(18(){2v(e(14).11("6C"))});2v(f.g.4o);f.g.61=t;f.g.1v=e(u).17(".12-1p:eq("+(f.g.61-1)+")");6(!n){6(f.g.27<f.g.61){f.g.2f="1X"}19{f.g.2f="1S"}}16 r=0;6(e(u).17(\'2b[1h*="66.53"], 2b[1h*="62.52"]\').1k>0){r=f.g.v.fi}f.43(f.g.1v,18(){f.4s()})};f.43=18(t,n){f.g.48=1c;6(f.g.9a){e(u).1a({29:"34"})}6(f.o.43){16 r=[];16 i=0;6(t.1a("3l-2K")!="1Q"&&t.1a("3l-2K").1i("63")!=-1&&!t.30("12-3w")&&!t.30("12-2I-3w")){16 s=t.1a("3l-2K");s=s.3H(/63\\((.*)\\)/)[1].2j(/"/9U,"");r[r.1k]=[s,t]}t.17("1Z:2I(.12-3w, .12-2I-3w)").1O(18(){6(f.o.47===1c){e(14).1f("1h",e(14).11("1h"))}r[r.1k]=[e(14).1f("1h"),e(14)]});t.17("*").1O(18(){6(e(14).1a("3l-2K")!="1Q"&&e(14).1a("3l-2K").1i("63")!=-1&&!e(14).30("12-3w")&&!e(14).30("12-2I-3w")){16 t=e(14).1a("3l-2K");t=t.3H(/63\\((.*)\\)/)[1].2j(/"/9U,"");r[r.1k]=[t,e(14)]}});6(r.1k==0){e(".12-1G-2R, .12-1s-1X, .12-1s-1S, .12-1o-1s-2R").1a({29:"34"});f.3s(t,n)}19{6(f.g.2o){f.g.3E.1a("1K","2m")}19{f.g.3E.1M(9A).2J(2z)}23(x=0;x<r.1k;x++){e("<1Z>").11("el",r[x]).31(18(){e(14).11("el")[1].1r("12-3w");6(++i==r.1k){f.g.3E.1x(1c,1c).1a({1K:"1Q"});e(".12-1G-2R, .12-1s-1X, .12-1s-1S, .12-1o-1s-2R").1a({29:"34"});6(3W.3Y.1i("fv/7")!==-1||f.g.2o){2g(18(){f.3s(t,n)},50)}19{f.3s(t,n)}}}).3Z(18(){16 t=e(14).11("el")[0].9D(e(14).11("el")[0].9O("/")+1,e(14).11("el")[0].1k);6(2q.4w){4w.ft(\'2A 3Z:\\r\\n\\r\\6x 6L 4K 21 6M 2X 21 2K 44 3l 2K "\'+t+\'" 3m 71 2e a 70 4M 4Q 4i 6Z be 2S. 4P 6Y 21 72 2X 4t 4O 73 76 3M 21 75.\')}19{9P(\'2A 3Z:\\r\\n\\r\\6x 6L 4K 21 6M 2X 21 2K 44 3l 2K "\'+t+\'" 3m 71 2e a 70 4M 4Q 4i 6Z be 2S. 4P 6Y 21 72 2X 4t 4O 73 76 3M 21 75.\')}e(14).1r("12-2I-3w");i++}).1f("1h",r[x][0])}}}19{e(".12-1G-2R, .12-1s-1X, .12-1s-1S, .12-1o-1s-2R").1a({29:"34"});f.3s(t,n)}};f.3s=18(t,n){t.1a({29:"2O",1K:"2m"});6(f.g.6G){f.g.6G()}f.8z();6(f.o.3e=="4R"){f.9J()}t.3h().1O(18(){16 t=e(14);16 n=t.11("4h")?t.11("4h"):"0";16 r=t.11("4k")?t.11("4k"):"0";6(t.3m("a")&&t.3h().1k>0){t.1a({1K:"2m"});t=t.3h()}16 i="1U";16 s="1U";6(t.11("2Z")){6(1W t.11("2Z")=="3V"){i=1b(t.11("2Z"))*f.g.1z}19 6(t.11("2Z").1i("%")!=-1){i=t.11("2Z")}}6(t.11("2Y")){6(1W t.11("2Y")=="3V"){s=1b(t.11("2Y"))*f.g.1z}19 6(t.11("2Y").1i("%")!=-1){s=t.11("2Y")}}16 o=t.11("7F")?1b(t.11("7F"))*f.g.1z:0;16 a=t.11("7z")?1b(t.11("7z"))*f.g.1z:0;16 l=t.11("8R")?1b(t.11("8R"))*f.g.1z:0;16 c=t.11("8Q")?1b(t.11("8Q"))*f.g.1z:0;16 h=t.11("6H")?1b(t.11("6H"))*f.g.1z:0;16 p=t.11("6K")?1b(t.11("6K"))*f.g.1z:0;16 d=t.11("6J")?1b(t.11("6J"))*f.g.1z:0;16 v=t.11("6I")?1b(t.11("6I"))*f.g.1z:0;16 m=t.11("9u");16 g=t.11("9n");6(f.g.4a||f.o.4E>0){6(t.3m("1Z")&&!t.30("12-bg")&&t.1f("1h")){t.1a({1d:"1U",1e:"1U"});6((i==0||i=="1U")&&1W s=="3V"&&s!=0){i=s/t.1e()*t.1d()}6((s==0||s=="1U")&&1W i=="3V"&&i!=0){s=i/t.1d()*t.1e()}6(i=="1U"){i=t.1d()*f.g.1z}6(s=="1U"){s=t.1e()*f.g.1z}t.1a({1d:i,1e:s})}6(!t.3m("1Z")){t.1a({1d:i,1e:s,"9h-9j":1b(m)*f.g.1z+"1J","9k-1e":1b(g)*f.g.1z+"1J"})}6(t.3m("1n")&&t.17("2b").11("3X")){16 y=t.17("2b");y.1f("1d",1b(y.11("2Z"))*f.g.1z).1f("1e",1b(y.11("2Y"))*f.g.1z);t.1a({1d:1b(y.11("2Z"))*f.g.1z,1e:1b(y.11("2Y"))*f.g.1z})}t.1a({28:l+"1J "+a+"1J "+c+"1J "+o+"1J ",9d:h+"1J",97:p+"1J",9g:d+"1J",9V:v+"1J"})}6(!t.30("12-bg")){16 b=t;6(t.24().3m("a")){t=t.24()}16 w=0;6(f.o.7f){w=f.o.7f>0?(f.g.1A()-f.o.7f)/2:0}19 6(f.o.8E){w=f.o.8E>0?(f.g.1A()-f.o.8E)/2:0}w=w<0?0:w;6(n.1i("%")!=-1){t.1a({1m:f.g.1A()/1D*1b(n)-b.1d()/2-o-h})}19 6(w>0||f.g.4a||f.o.4E>0){t.1a({1m:w+1b(n)*f.g.1z})}6(r.1i("%")!=-1){t.1a({1q:f.g.1H()/1D*1b(r)-b.1e()/2-l-d})}19 6(f.g.4a||f.o.4E>0){t.1a({1q:1b(r)*f.g.1z})}}19{16 E=e(u).17(".12-2c");t.1a({1d:"1U",1e:"1U"});i=t.1d();s=t.1e();16 S=f.g.1z;6(f.g.2E.1i("%")!=-1){6(f.g.1A()>i){S=f.g.1A()/i;6(f.g.1H()>s*S){S=f.g.1H()/s}}19 6(f.g.1H()>s){S=f.g.1H()/s;6(f.g.1A()>i*S){S=f.g.1A()/i}}}t.1a({1d:i*S,1e:s*S,3p:E.1d()/2-i*S/2,3O:E.1e()/2-s*S/2})}});t.1a({1K:"1Q",29:"34"});f.8t();n();e(14).8D()};f.8t=18(){6(f.g.51){16 e=18(){6(f.g.51.1e()>0){6(f.g.9B>0){f.g.40.1a({1e:f.g.51.1e()/2})}19{f.g.40.1a({1e:f.g.51.1e(),3O:-f.g.51.1e()/2})}}19{2g(18(){e()},50)}};e()}};f.8z=18(){6(f.o.4E>0){6(e(2q).1d()<f.o.4E){f.g.4a=1c;f.g.2E=f.o.4E+"1J"}19{f.g.4a=1g;f.g.2E=f.g.8y;f.g.1z=1}}6(f.g.4a){16 t=e(u).24();e(u).1a({1d:t.1d()-1b(e(u).1a("28-1m"))-1b(e(u).1a("28-1F"))});f.g.1z=e(u).1d()/1b(f.g.2E);e(u).1a({1e:f.g.1z*1b(f.g.4m)})}19{f.g.1z=1;e(u).1a({1d:f.g.2E,1e:f.g.4m})}6(e(u).6a(".12-6f-6g-2n").1k){e(u).6a(".12-6f-6g-9z").1a({1e:e(u).3y(1c)});e(u).6a(".12-6f-6g-2n").1a({1e:e(u).3y(1c)});e(u).6a(".12-6f-6g-9z").1a({1d:e(2q).1d(),1m:-e(u).6a(".12-6f-6g-2n").5m().1m});6(f.g.2E.1i("%")!=-1){16 n=1b(f.g.2E);16 r=e("3U").1d()/1D*n-(e(u).3D()-e(u).1d());e(u).1d(r)}}e(u).17(".12-2c, .12-1y-2n").1a({1d:f.g.1A(),1e:f.g.1H()});6(f.g.1L&&f.g.1v){f.g.1L.1a({1d:f.g.1A(),1e:f.g.1H()});f.g.1v.1a({1d:f.g.1A(),1e:f.g.1H()})}19{e(u).17(".12-1p").1a({1d:f.g.1A(),1e:f.g.1H()})}};f.8Z=18(){f.g.1u.1a({1d:f.g.1u.11("2Z")*f.g.1z,1e:f.g.1u.11("2Y")*f.g.1z});6(f.g.2o){f.g.1u.1a("1K","2m")}19{f.g.1u.2J(2z)}16 t=6B=6A=6u="1U";6(f.g.1u.11("4h")&&f.g.1u.11("4h").1i("%")!=-1){t=f.g.1A()/1D*1b(f.g.1u.11("4h"))-f.g.1u.1d()/2+1b(e(u).1a("28-1m"))}19{t=1b(f.g.1u.11("4h"))*f.g.1z}6(f.g.1u.11("6e")&&f.g.1u.11("6e").1i("%")!=-1){6B=f.g.1A()/1D*1b(f.g.1u.11("6e"))-f.g.1u.1d()/2+1b(e(u).1a("28-1F"))}19{6B=1b(f.g.1u.11("6e"))*f.g.1z}6(f.g.1u.11("4k")&&f.g.1u.11("4k").1i("%")!=-1){6A=f.g.1H()/1D*1b(f.g.1u.11("4k"))-f.g.1u.1e()/2+1b(e(u).1a("28-1q"))}19{6A=1b(f.g.1u.11("4k"))*f.g.1z}6(f.g.1u.11("6d")&&f.g.1u.11("6d").1i("%")!=-1){6u=f.g.1H()/1D*1b(f.g.1u.11("6d"))-f.g.1u.1e()/2+1b(e(u).1a("28-1o"))}19{6u=1b(f.g.1u.11("6d"))*f.g.1z}f.g.1u.1a({1m:t,1F:6B,1q:6A,1o:6u})};f.9J=18(){f.7N("4e");16 t=f.g.2E.1i("%")==-1?1b(f.g.2E):f.g.1A();e(u).17(".12-1G-1p a").1a({1d:1b(f.o.7V*f.g.1z),1e:1b(f.o.65*f.g.1z)});e(u).17(".12-1G-1p a:4n").1a({3j:0});e(u).17(".12-1G-1p").1a({1e:1b(f.o.65*f.g.1z)});16 n=e(u).17(".12-1G");16 r=f.o.7o.1i("%")==-1?1b(f.o.7o):1b(t/1D*1b(f.o.7o));n.1a({1d:r*1C.26(f.g.1z*1D)/1D});6(n.1d()>e(u).17(".12-1G-1p").1d()){n.1a({1d:e(u).17(".12-1G-1p").1d()})}f.7N("9I")};f.7R=18(t){16 n=t?t:f.g.61;e(u).17(".12-1G-1p a:2I(.12-4g-"+n+")").3h().1O(18(){e(14).2x("12-4g-1V").1x().6t(88,f.o.81/1D)});e(u).17(".12-1G-1p a.12-4g-"+n).3h().1r("12-4g-1V").1x().6t(88,f.o.7U/1D)};f.7y=18(){6(!e(u).17(".12-1G-1p-2n").30("12-1G-1p-1R")){16 t=e(u).17(".12-4g-1V").1k?e(u).17(".12-4g-1V").24():1g;6(t){16 n=t.3x().1m+t.1d()/2;16 r=e(u).17(".12-1G-1p-2n").1d()/2-n;r=r<e(u).17(".12-1G-1p-2n").1d()-e(u).17(".12-1G-1p").1d()?e(u).17(".12-1G-1p-2n").1d()-e(u).17(".12-1G-1p").1d():r;r=r>0?0:r;e(u).17(".12-1G-1p").4s({3p:r},fs)}}};f.7N=18(t){6(f.o.7j&&!e(u).30("12-1R")){2p(t){1l"4e":f.g.42.1a({29:"2O",1K:"2m"});1j;1l"9I":f.g.42.1a({29:"34",1K:"1Q"});1j}}};f.4s=18(){6(e(u).17(".12-1p").1k>1){f.g.36=1c}f.g.48=1g;2v(f.g.4o);2v(f.g.fh);f.g.9C=f.g.1L;f.o.ac(f.g);6(f.o.3e=="4R"){f.7R();6(!("6s"3M 2q)){f.7y()}}f.g.1v.1r("12-9e");16 t=7D=6w=8n=6z=8a=6y=8k=6r=fg=6v=f8="1U";16 a=8e=f.g.1A();16 l=8d=f.g.1H();16 c=f.g.2f=="1S"?f.g.1L:f.g.1v;16 h=c.11("3C")?c.11("3C"):f.o.8s;16 p=f.g.7W[f.g.2f][h];6(p=="1m"||p=="1F"){a=6w=8e=6y=0;6v=0}6(p=="1q"||p=="1o"){l=t=8d=6z=0;6r=0}2p(p){1l"1m":7D=6z=0;6r=-f.g.1A();1j;1l"1F":t=8a=0;6r=f.g.1A();1j;1l"1q":8n=6y=0;6v=-f.g.1H();1j;1l"1o":6w=8k=0;6v=f.g.1H();1j}f.g.1L.1a({1m:t,1F:7D,1q:6w,1o:8n});f.g.1v.1a({1d:8e,1e:8d,1m:6z,1F:8a,1q:6y,1o:8k});16 d=f.g.1L.11("5w")?1b(f.g.1L.11("5w")):f.o.7t;16 v=f.g.1L.11("4L")?1b(f.g.1L.11("4L")):f.o.4S;16 m=f.g.1L.11("4J")?f.g.1L.11("4J"):f.o.4F;16 g=f.g.1v.11("5d")?1b(f.g.1v.11("5d")):f.o.5r;16 y=f.g.1v.11("5t")?1b(f.g.1v.11("5t")):f.o.5y;16 b=f.g.1v.11("5K")?f.g.1v.11("5K"):f.o.5F;16 w=18(){f.g.1L.1M(d+v/15).4s({1d:a,1e:l},v,m,18(){E()})};16 E=18(){f.g.9C.17(\' > *[1t*="12-l"]\').1O(18(){6(e(14).11("3N")){e(14).11("3N").85()}e(14).1a({f7:"1Q"})});f.o.7Q(f.g);f.g.1L=f.g.1v;f.g.27=f.g.61;6(f.o.43&&f.o.47){16 t=f.g.27==f.g.2y?1:f.g.27+1;e(u).17(".12-1p").eq(t-1).17("1Z:2I(.12-3w)").1O(18(){e(14).31(18(){e(14).1r("12-3w")}).3Z(18(){16 t=e(14).11("1h").9D(e(14).11("1h").9O("/")+1,e(14).11("1h").1k);6(2q.4w){4w(\'2A 3Z:\\r\\n\\r\\6x 6L 4K 21 6M 2X 21 2K 44 3l 2K "\'+t+\'" 3m 71 2e a 70 4M 4Q 4i 6Z be 2S. 4P 6Y 21 72 2X 4t 4O 73 76 3M 21 75.\')}19{9P(\'2A 3Z:\\r\\n\\r\\6x 6L 4K 21 6M 2X 21 2K 44 3l 2K "\'+t+\'" 3m 71 2e a 70 4M 4Q 4i 6Z be 2S. 4P 6Y 21 72 2X 4t 4O 73 76 3M 21 75.\')}e(14).1r("12-2I-3w")}).1f("1h",e(14).11("1h"))})}e(u).17(".12-1p").2x("12-1V");e(u).17(".12-1p:eq("+(f.g.27-1)+")").1r("12-1V").2x("12-9e");e(u).17(".12-1o-4T a").2x("12-1s-1V");e(u).17(".12-1o-4T a:eq("+(f.g.27-1)+")").1r("12-1s-1V");6(f.g.2w){f.5Q()}f.g.36=1g;6(f.g.2T==1c){f.3s(f.g.1L,18(){f.g.2T=1g})}};16 S=18(t){f.g.1L.17(\' > *[1t*="12-l"]\').1O(18(){6(!e(14).11("2B")){f.5O(e(14))}e(14).2x("12-8F");16 r=e(14).11("3C")?e(14).11("3C"):p;16 i,s;2p(r){1l"1m":i=-f.g.1A();s=0;1j;1l"1F":i=f.g.1A();s=0;1j;1l"1q":s=-f.g.1H();i=0;1j;1l"1o":s=f.g.1H();i=0;1j;1l"3B":s=0;i=0;1j}6(e(14).11("2B")==="1I"){16 o="1I"}19{16 o=e(14).11("6b")?e(14).11("6b"):1g}2p(o){1l"1m":i=f.g.1A();s=0;1j;1l"1F":i=-f.g.1A();s=0;1j;1l"1q":s=f.g.1H();i=0;1j;1l"1o":s=-f.g.1H();i=0;1j;1l"3B":s=0;i=0;1j;1l"1I":6(e(14).11("3c")){6(e(14).11("3c")==="1m"){i=f.g.1A()}19 6(e(14).11("3c")==="1F"){i=-f.g.1A()}19{i=-1b(e(14).11("3c"))}}19{i=-f.1y.8l}6(e(14).11("3r")){6(e(14).11("3r")==="1q"){s=f.g.1H()}19 6(e(14).11("3r")==="1o"){s=-f.g.1H()}19{s=-1b(e(14).11("3r"))}}19{s=-f.1y.7C}1j}16 u=58=5o=4c=5p=5q=3k=3q="1Q";u=e(14).11("5U")?e(14).11("5U"):f.1y.7x;58=e(14).11("6p")?e(14).11("6p"):f.1y.7G;5o=e(14).11("6i")?e(14).11("6i"):f.1y.7P;4c=e(14).11("5M")?e(14).11("5M"):f.1y.7O;5p=e(14).11("6n")?e(14).11("6n"):f.1y.8T;5q=e(14).11("6o")?e(14).11("6o"):f.1y.8W;6(4c===1){3k=e(14).11("6m")?e(14).11("6m"):f.1y.8P;3q=e(14).11("6l")?e(14).11("6l"):f.1y.8O}19{3k=3q=4c}16 a=e(14).11("78")?e(14).11("78").1E(" "):f.1y.8V;23(16 l=0;l<a.1k;l++){6(a[l].1i("%")===-1&&a[l].1i("1m")!==-1&&a[l].1i("1F")!==-1&&a[l].1i("1q")!==-1&&a[l].1i("1o")!==-1){a[l]=""+1b(a[l])*f.g.1z+"1J"}}16 c=a.8Y(" ");16 h=e(14).11("6k")?e(14).11("6k"):f.1y.8S;16 d=1b(e(14).1a("1m"));16 v=1b(e(14).1a("1q"));16 m=1b(e(14).1f("1t").1E("12-l")[1]);16 g=e(14).3D()>e(14).3y()?e(14).3D():e(14).3y();16 y=1b(u)===0?e(14).3D():g;16 b=1b(u)===0?e(14).3y():g;6(m===-1&&o!=="1I"||e(14).11("3c")==="1m"||e(14).11("3c")==="1F"){6(i<0){i=-(f.g.1A()-d+(3k/2-.5)*y+1D)}19 6(i>0){i=d+(3k/2+.5)*y+1D}}19{i=i*f.g.1z}6(m===-1&&o!=="1I"||e(14).11("3r")==="1q"||e(14).11("3r")==="1o"){6(s<0){s=-(f.g.1H()-v+(3q/2-.5)*b+1D)}19 6(s>0){s=v+(3q/2+.5)*b+1D}}19{s=s*f.g.1z}6(m===-1||o==="1I"){16 w=1}19{16 E=f.g.1L.11("7w")?1b(f.g.1L.11("7w")):f.o.8L;16 w=m*E}6(e(14).11("2B")==="1I"){16 S=f.1y.7t;16 x=f.1y.4S;16 T=f.1y.4F}19{16 S=f.o.7t;16 x=f.o.4S;16 T=f.o.4F}16 N=e(14).11("5w")?1b(e(14).11("5w")):S;16 C=e(14).11("4L")?1b(e(14).11("4L")):x;16 k=e(14).11("4J")?e(14).11("4J"):T;6(t){N=0;C=t}6(e(14).11("6W")){2v(e(14).11("6W"))}16 L={29:"2O"};16 A=e(14);16 O={3g:u,4x:58,4z:5o,7s:5p,7r:5q,5k:3k,5j:3q,x:-i*w,y:-s*w,1M:N/1P,3T:n(k),8B:18(){A.1a(L)}};6(o=="3B"||!o&&r==="3B"||e(14).11("bO")!=="1g"&&e(14).11("2B")==="1I"){O["2Q"]=0;L["2Q"]=e(14).11("7d")}6(e(14).11("3N")){e(14).11("3N").85()}3a.8K(e(14)[0],{8C:c,8G:h});e(14).11("3N",3a.2e(e(14)[0],C/1P,O))})};16 x=18(){f.g.1v.1M(d+g).4s({1d:f.g.1A(),1e:f.g.1H()},y,b)};16 T=18(){6(f.g.3o){d=0}6(1W f.o.9w==="18"){f.o.9w(f.g,d+g)}f.g.1v.17(\' > *[1t*="12-l"]\').1O(18(){6(!e(14).11("2B")){f.5O(e(14))}6(e(14).11("2B")==="1I"){16 t="1I"}19{16 t=e(14).11("3C")?e(14).11("3C"):p}16 r,i;2p(t){1l"1m":r=-f.g.1A();i=0;1j;1l"1F":r=f.g.1A();i=0;1j;1l"1q":i=-f.g.1H();r=0;1j;1l"1o":i=f.g.1H();r=0;1j;1l"3B":i=0;r=0;1j;1l"1I":6(e(14).11("5e")){6(e(14).11("5e")==="1m"){r=-f.g.1A()}19 6(e(14).11("5e")==="1F"){r=f.g.1A()}19{r=1b(e(14).11("5e"))}}19{r=f.1y.9R}6(e(14).11("5f")){6(e(14).11("5f")==="1q"){i=-f.g.1H()}19 6(e(14).11("5f")==="1o"){i=f.g.1H()}19{i=1b(e(14).11("5f"))}}19{i=f.1y.9S}1j}16 s=83=82=74=84=7L=5n=5c="1Q";s=e(14).11("8I")?e(14).11("8I"):f.1y.9X;83=e(14).11("9r")?e(14).11("9r"):f.1y.9Y;82=e(14).11("9q")?e(14).11("9q"):f.1y.a4;74=e(14).11("8A")?e(14).11("8A"):f.1y.9x;84=e(14).11("9p")?e(14).11("9p"):f.1y.9Z;7L=e(14).11("9f")?e(14).11("9f"):f.1y.a0;6(74===1){5n=e(14).11("9t")?e(14).11("9t"):f.1y.a3;5c=e(14).11("9v")?e(14).11("9v"):f.1y.a2}19{5n=5c=74}16 o=e(14).11("9o")?e(14).11("9o").1E(" "):f.1y.a1;23(16 u=0;u<o.1k;u++){6(o[u].1i("%")===-1&&o[u].1i("1m")!==-1&&o[u].1i("1F")!==-1&&o[u].1i("1q")!==-1&&o[u].1i("1o")!==-1){o[u]=""+1b(o[u])*f.g.1z+"1J"}}16 a=o.8Y(" ");16 l=e(14).11("9i")?e(14).11("9i"):f.1y.9E;16 c=1b(e(14).1a("1m"));16 h=1b(e(14).1a("1q"));16 d=1b(e(14).1f("1t").1E("12-l")[1]);6(e(14)[0].1N.1d.1i("%")!==-1){e(14).1a({1d:f.g.1A()/1D*1b(e(14)[0].1N.1d)})}16 v=e(14).3D()>e(14).3y()?e(14).3D():e(14).3y();16 m=1b(s)===0?e(14).3D():v;16 g=1b(s)===0?e(14).3y():v;6(d===-1&&t!=="1I"||e(14).11("5e")==="1m"||e(14).11("5e")==="1F"){6(r<0){r=-(c+(5n/2+.5)*m+1D)}19 6(r>0){r=f.g.1A()-c+(5n/2-.5)*m+1D}}19{r=r*f.g.1z}6(d===-1&&t!=="1I"||e(14).11("5f")==="1q"||e(14).11("5f")==="1o"){6(i<0){i=-(h+(5c/2+.5)*g+1D)}19 6(i>0){i=f.g.1H()-h+(5c/2-.5)*g+1D}}19{i=i*f.g.1z}6(d===-1||t==="1I"){16 y=1}19{16 b=f.g.1v.11("9s")?1b(f.g.1v.11("9s")):f.o.ao;16 y=d*b}6(e(14).11("2B")==="1I"){16 w=f.1y.5r;16 E=f.1y.5y;16 S=f.1y.5F}19{16 w=f.o.5r;16 E=f.o.5y;16 S=f.o.5F}16 x=e(14).11("5d")?1b(e(14).11("5d")):w;16 T=e(14).11("5t")?1b(e(14).11("5t")):E;16 N=e(14).11("5K")?e(14).11("5K"):S;16 C=e(14);16 k=18(){6(C.30("12-2M-4G")){C.1r("12-8F")}6(f.o.86==1c){C.17(".12-2F, 2M, 6X").2k()}6(C.11("5v")>0){C.11("6W",2g(18(){f.8H(C)},C.11("5v")))}};e(14).1a({3p:0,3O:0});16 L={5k:5n,5j:5c,7s:84,7r:7L,3g:s,4x:83,4z:82,29:"34",x:r*y,y:i*y};16 A={3g:0,4x:0,4z:0,7s:0,7r:0,5k:1,5j:1,3T:n(N),1M:x/1P,x:0,y:0,8B:18(){k()}};6(t.1i("3B")!=-1||e(14).11("f4")!=="1g"&&e(14).11("2B")==="1I"){L["2Q"]=0;A["2Q"]=e(14).11("7d")}6(e(14).11("3N")){e(14).11("3N").85()}3a.8K(e(14)[0],{8G:l,8C:a});e(14).11("3N",3a.6R(e(14)[0],T/1P,L,A))})};16 N=18(){6(i(e(u))&&(f.g.1v.11("4W")||f.g.1v.11("5u"))){6(f.g.1v.11("4W")&&f.g.1v.11("5u")){16 t=1C.26(1C.2h()*2);16 n=[["3d",f.g.1v.11("4W")],["bj",f.g.1v.11("5u")]];k(n[t][0],n[t][1])}19 6(f.g.1v.11("4W")){k("3d",f.g.1v.11("4W"))}19{k("bj",f.g.1v.11("5u"))}}19{6(f.g.1v.11("5B")&&f.g.1v.11("5s")){16 t=1C.26(1C.2h()*2);16 n=[["2d",f.g.1v.11("5B")],["bn",f.g.1v.11("5s")]];k(n[t][0],n[t][1])}19 6(f.g.1v.11("5B")){k("2d",f.g.1v.11("5B"))}19 6(f.g.1v.11("5s")){k("bn",f.g.1v.11("5s"))}19{k("2d","1")}}};16 C=18(){6(i(e(u))&&5x.1i("3d")!=-1){k("3d",5x.1E(":")[1])}19{6(5x.1i("3d")!=-1){k("2d","4t")}19{k("2d",5x.1E(":")[1])}}};16 k=18(e,t){16 n=e.1i("f5")==-1?f.t:f.ct;16 r="3d",i,s;6(e.1i("2d")!=-1){r="2d"}6(t.1i("4n")!=-1){s=n["t"+r].1k-1;i="4n"}19 6(t.1i("4t")!=-1){s=1C.26(1C.2h()*o(n["t"+r]));i="2h bs 4t"}19{16 u=t.1E(",");16 a=u.1k;s=1b(u[1C.26(1C.2h()*a)])-1;i="2h bs f9"}L(r,n["t"+r][s])};16 L=18(t,i){16 o=e(u).17(".12-2c");16 a=f.g.1L.17(\'*[1t*="12-l"]\').1k>0?1P:0;16 l=i.6T.20().1i("fa")==-1?1g:1c;16 c=i.6T.20().1i("ff")==-1?1g:1c;16 h=1W i.4p;16 p=1W i.4b;2p(h){1l"3V":h=i.4p;1j;1l"5T":h=1C.26(1C.2h()*(1b(i.4p.1E(",")[1])-1b(i.4p.1E(",")[0])+1))+1b(i.4p.1E(",")[0]);1j;b7:h=1C.26(1C.2h()*(i.4p[1]-i.4p[0]+1))+i.4p[0];1j}2p(p){1l"3V":p=i.4b;1j;1l"5T":p=1C.26(1C.2h()*(1b(i.4b.1E(",")[1])-1b(i.4b.1E(",")[0])+1))+1b(i.4b.1E(",")[0]);1j;b7:p=1C.26(1C.2h()*(i.4b[1]-i.4b[0]+1))+i.4b[0];1j}6(f.g.9m()==1c&&f.o.bu==1c||f.g.2o&&f.o.bv==1c){6(h>=15){h=7}19 6(h>=5){h=4}19 6(h>=4){h=3}19 6(h>2){h=2}6(p>=15){p=7}19 6(p>=5){p=4}19 6(p>=4){p=3}19 6(p>2){p=2}6(p>2&&h>2){p=2;6(h>4){h=4}}}16 d=e(u).17(".12-2c").1d()/h;16 v=e(u).17(".12-2c").1e()/p;6(!f.g.2D){f.g.2D=e("<1n>").1r("12-1y-2n").1r("12-4q-2O").1a({1d:o.1d(),1e:o.1e()}).6q(o)}19{f.g.2D.1x(1c,1c).5C().1a({1K:"2m",1d:o.1d(),1e:o.1e()})}16 m=o.1d()-1C.26(d)*h;16 g=o.1e()-1C.26(v)*p;16 y=[];y.bc=18(){16 e=14.1k,t,n,r;6(e==0)1T 1g;bt(--e){t=1C.26(1C.2h()*(e+1));n=14[e];r=14[t];14[e]=r;14[t]=n}1T 14};23(16 b=0;b<h*p;b++){y.7Y(b)}2p(i.3Q.fd){1l"5W":y.5W();1j;1l"bd-7X":y=s(p,h,"7X");1j;1l"bd-5W":y=s(p,h,"5W");1j;1l"2h":y.bc();1j}16 w=f.g.1L.17(".12-bg");16 x=f.g.1v.17(".12-bg");6(w.1k==0&&x.1k==0){t="2d";i=e.4D(1c,{},f.t["fb"][0]);i.1B.2l=1;i.3Q.1M=0}6(t=="3d"){f.g.3o=(h*p-1)*i.3Q.1M;16 N=0;6(i.2H&&i.2H.2l){N+=i.2H.2l}6(i.2a&&i.2a.2l){N+=i.2a.2l}6(i.2C&&i.2C.2l){N+=i.2C.2l}f.g.3o+=N;16 C=0;6(i.2H&&i.2H.1M){C+=i.2H.1M}6(i.2a&&i.2a.1M){C+=i.2a.1M}6(i.2C&&i.2C.1M){C+=i.2C.1M}f.g.3o+=C}19{f.g.3o=(h*p-1)*i.3Q.1M+i.1B.2l;f.g.54=e("<1n>").1r("12-fc").1w(f.g.2D);f.g.8f=e("<1n>").1r("12-f2").1w(f.g.2D)}16 k=f.g.2f;23(16 L=0;L<h*p;L++){16 A=L%h==0?m:0;16 O=L>(p-1)*h-1?g:0;16 M=e("<1n>").1r("12-1y-3Q").1a({1d:1C.26(d)+A,1e:1C.26(v)+O}).1w(f.g.2D);16 56,D;6(t=="3d"){M.1r("12-3d-2n");16 P=1C.26(d)+A;16 H=1C.26(v)+O;16 B;6(i.2a.5Z=="bB"){6(1C.49(i.2a.1B.3b)>90&&i.3Q.a7!="bL"){B=1C.26(P/7)+A}19{B=P}}19{6(1C.49(i.2a.1B.2U)>90&&i.3Q.a7!="bL"){B=1C.26(H/7)+O}19{B=H}}16 j=P/2;16 F=H/2;16 I=B/2;16 q=18(t,n,r,i,s,o,u,a,f){e("<1n>").1r(t).1a({1d:r,1e:i,3P:"5X("+s+"1J, "+o+"1J, "+u+"1J) 2U("+a+"3L) 3b("+f+"3L) 5R(5L) 4v(1, 1, 1)","-o-3P":"5X("+s+"1J, "+o+"1J, "+u+"1J) 2U("+a+"3L) 3b("+f+"3L) 5R(5L) 4v(1, 1, 1)","-bi-3P":"5X("+s+"1J, "+o+"1J, "+u+"1J) 2U("+a+"3L) 3b("+f+"3L) 5R(5L) 4v(1, 1, 1)","-bh-3P":"5X("+s+"1J, "+o+"1J, "+u+"1J) 2U("+a+"3L) 3b("+f+"3L) 5R(5L) 4v(1, 1, 1)","-5S-3P":"5X("+s+"1J, "+o+"1J, "+u+"1J) 2U("+a+"3L) 3b("+f+"3L) 5R(5L) 4v(1, 1, 1)"}).1w(n)};q("12-3d-3K",M,0,0,0,0,-I,0,0);16 R=0;16 U=0;16 z=0;6(i.2a.5Z=="dW"&&1C.49(i.2a.1B.2U)>90){q("12-3d-5P",M.17(".12-3d-3K"),P,H,-j,-F,-I,6N,0)}19{q("12-3d-5P",M.17(".12-3d-3K"),P,H,-j,-F,-I,0,6N)}q("12-3d-1o",M.17(".12-3d-3K"),P,B,-j,F-I,0,-90,0);q("12-3d-1q",M.17(".12-3d-3K"),P,B,-j,-F-I,0,90,0);q("12-3d-bw",M.17(".12-3d-3K"),P,H,-j,-F,I,0,0);q("12-3d-1m",M.17(".12-3d-3K"),B,H,-j-I,-F,0,0,-90);q("12-3d-1F",M.17(".12-3d-3K"),B,H,j-I,-F,0,0,90);56=M.17(".12-3d-bw");6(i.2a.5Z=="bB"){6(1C.49(i.2a.1B.3b)>90){D=M.17(".12-3d-5P")}19{D=M.17(".12-3d-1m, .12-3d-1F")}}19{6(1C.49(i.2a.1B.2U)>90){D=M.17(".12-3d-5P")}19{D=M.17(".12-3d-1q, .12-3d-1o")}}16 W=y[L]*i.3Q.1M;16 X=f.g.2D.17(".12-3d-2n:eq("+L+") .12-3d-3K");16 V=1I bD;6(i.2H&&i.2H.1B){i.2H.1B.1M=i.2H.1B.1M?(i.2H.1B.1M+W)/1P:W/1P;V.2e(X[0],i.2H.2l/1P,r(i.2H.1B,i.2H.4A))}19{i.2a.1B.1M=i.2a.1B.1M?(i.2a.1B.1M+W)/1P:W/1P}V.2e(X[0],i.2a.2l/1P,r(i.2a.1B,i.2a.4A));6(i.2C){6(!i.2C.1B){i.2C.1B={}}V.2e(X[0],i.2C.2l/1P,r(i.2C.1B,i.2C.4A,"2C"))}}19{16 J=32=2N=2G="1U";16 K=6U=1;6(i.1B.5Z=="2h"){16 Q=["1q","1o","1F","1m"];16 G=Q[1C.26(1C.2h()*Q.1k)]}19{16 G=i.1B.5Z}6(i.6T.20().1i("ag")!=-1&&L%2==0){6(k=="1S"){k="1X"}19{k="1S"}}6(k=="1S"){2p(G){1l"1q":G="1o";1j;1l"1o":G="1q";1j;1l"1m":G="1F";1j;1l"1F":G="1m";1j;1l"8m":G="7S";1j;1l"8h":G="8g";1j;1l"8g":G="8h";1j;1l"7S":G="8m";1j}}2p(G){1l"1q":J=2N=-M.1e();32=2G=0;1j;1l"1o":J=2N=M.1e();32=2G=0;1j;1l"1m":J=2N=0;32=2G=-M.1d();1j;1l"1F":J=2N=0;32=2G=M.1d();1j;1l"8m":J=M.1e();2N=0;32=M.1d();2G=0;1j;1l"8h":J=M.1e();2N=0;32=-M.1d();2G=0;1j;1l"8g":J=-M.1e();2N=0;32=M.1d();2G=0;1j;1l"7S":J=-M.1e();2N=0;32=-M.1d();2G=0;1j}f.g.4Y=i.1B.5I?i.1B.5I:1;6(l==1c&&f.g.4Y!=1){J=J/2;2N=2N/2;32=32/2;2G=2G/2}2p(i.1B.4y){1l"3B":J=2N=32=2G=0;K=0;6U=1;1j;1l"dH":K=0;6U=1;6(f.g.4Y==1){2N=2G=0}1j}6((i.1B.3F||i.1B.2U||i.1B.3b||f.g.4Y!=1)&&!f.g.2o&&i.1B.4y!="1p"){M.1a({4q:"34"})}19{M.1a({4q:"2O"})}6(l==1c){f.g.54.1a({4q:"34"})}19{f.g.54.1a({4q:"2O"})}6(c==1c||i.1B.4y=="1p"||l==1c){16 Y=M.1w(f.g.54);16 Z=M.8c().1w(f.g.8f);56=e("<1n>").1r("12-dN").1w(Y)}19{16 Z=M.1w(f.g.8f)}D=e("<1n>").1r("12-dT").1w(Z).1a({1q:-J,1m:-32,dP:"2m",2Q:K});16 et=y[L]*i.3Q.1M;16 5l=i.1B.3F?i.1B.3F:0;16 6S=i.1B.2U?i.1B.2U:0;16 6V=i.1B.3b?i.1B.3b:0;6(k=="1S"){5l=-5l;6S=-6S;6V=-6V}3a.6R(D[0],i.1B.2l/1P,{3g:5l,4x:6S,4z:6V,5I:f.g.4Y},{1M:et/1P,1q:0,1m:0,2Q:6U,3g:0,4x:0,4z:0,5I:1,3T:n(i.1B.4A)});6(c==1c&&(x.1k<1||x.1k>0&&(x.1f("1h").20().1i("4H")!=-1||x.1d()<f.g.1A()||x.1e()<f.g.1H()))){3a.2e(56[0],i.1B.2l/1P,{1M:et/1P,2Q:0,3T:n(i.1B.4A)})}6((i.1B.4y=="1p"||l==1c)&&i.6T.20().1i("ag")==-1){16 4i=0;6(5l!=0){4i=-5l}3a.2e(56[0],i.1B.2l/1P,{1M:et/1P,1q:2N,1m:2G,3g:4i,5I:f.g.4Y,2Q:K,3T:n(i.1B.4A)})}}6(w.1k){6(t=="3d"||t=="2d"&&(c==1c||i.1B.4y=="1p"||l==1c)){56.3S(e("<1Z>").1f("1h",w.1f("1h")).1a({1d:w[0].1N.1d,1e:w[0].1N.1e,3p:3i(w.1a("3j-1m"))-3i(M.3x().1m),3O:3i(w.1a("3j-1q"))-3i(M.3x().1q)}))}19 6(f.g.54.3h().1k==0){f.g.54.3S(e("<1Z>").1f("1h",w.1f("1h")).1a({1d:w[0].1N.1d,1e:w[0].1N.1e,3p:3i(w.1a("3j-1m")),3O:3i(w.1a("3j-1q"))}))}}6(x.1k){D.3S(e("<1Z>").1f("1h",x.1f("1h")).1a({1d:x[0].1N.1d,1e:x[0].1N.1e,3p:3i(x.1a("3j-1m"))-3i(M.3x().1m),3O:3i(x.1a("3j-1q"))-3i(M.3x().1q)}))}}16 4Z=f.g.1L;16 2L=f.g.1v;2g(18(){4Z.17(".12-bg").1a({29:"2O"})},50);2L.17(".12-bg").1a({29:"2O"});f.g.2D.2x("12-4q-2O");S(a);2g(18(){4Z.1a({1d:0})},a);16 95=1b(2L.11("77"))?1b(2L.11("77")):0;16 at=f.g.3o+95>0?f.g.3o+95:0;2g(18(){6(f.g.2T==1c){f.g.2D.5C();4Z.2x("12-1V");f.3s(2L,18(){f.g.2T=1g})}T();6(2L.17(".12-bg").1k<1||2L.17(".12-bg").1k>0&&2L.17(".12-bg").1f("1h").20().1i("4H")!=-1){f.g.2D.1M(b1).3J(2z,18(){e(14).5C().64()})}2L.1a({1d:f.g.1A(),1e:f.g.1H()})},at);6(f.g.3o<2z){f.g.3o=1P}2g(18(){f.g.2D.1r("12-4q-2O");2L.1r("12-1V");6(2L.17(".12-bg").1k){2L.17(".12-bg").1a({1K:"1Q",29:"34"});6(f.g.2o){2L.17(".12-bg").1a("1K","2m");2g(18(){E()},41)}19{2L.17(".12-bg").2J(41,18(){E()})}}19{E()}},f.g.3o)};16 A=(f.g.1v.11("4W")||f.g.1v.11("5B"))&&f.t||(f.g.1v.11("5u")||f.g.1v.11("5s"))&&f.ct?"1I":"5V";6(!f.g.1v.11("2B")){f.5O(f.g.1v)}6(f.g.1v.11("2B")==="1I"){A="1I"}6(f.o.8u){A="aA"}6(f.o.4B&&!f.g.aI){6(f.g.2y==1){16 d=0;f.o.7Q(f.g)}19{16 O=1b(f.g.1v.11("77"))?1b(f.g.1v.11("77")):0;16 M=A=="1I"?0:v;f.g.aB=2g(18(){E()},M+1C.49(O))}f.g.3o=1c;T();f.g.1v.1a({1d:f.g.1A(),1e:f.g.1H()});6(!f.g.2o){f.g.1v.17(".12-bg").1a({1K:"1Q"}).2J(41)}f.g.aI=1c;f.g.48=1g}19{2p(A){1l"5V":f.g.3o=1g;6(f.g.2D){f.g.2D.5C()}w();S();x();T();1j;1l"1I":6(1W 5x!="2W"){C()}19{N()}1j;1l"aA":L(f.o.8u.4y,f.o.8u.ev);1j}}};f.5O=18(e){16 t=e.11("12")||!e.11("12")&&!e.11("5H")&&!e.11("3C")&&!e.11("6b")&&!e.11("5d")&&!e.11("5w")&&!e.11("5t")&&!e.11("4L")&&!e.11("5v")&&!e.11("5K")&&!e.11("4J")&&!e.11("8A")&&!e.11("5M")&&!e.11("8I")&&!e.11("5U")?"1I":"5V";e.11("2B",t)};f.8H=18(e){6(!e.11("2B")){f.5O(e)}e.2x("12-8F");16 t=f.g.1L;6(f.g.2f!="1S"&&f.g.1v){t=f.g.1v}16 r=t.11("3C")?t.11("3C"):f.o.8s;16 i=f.g.7W[f.g.2f][r];16 s=e.11("3C")?e.11("3C"):i;16 o,u;2p(s){1l"1m":o=-f.g.1A();u=0;1j;1l"1F":o=f.g.1A();u=0;1j;1l"1q":u=-f.g.1H();o=0;1j;1l"1o":u=f.g.1H();o=0;1j;1l"3B":u=0;o=0;1j}6(e.11("2B")==="1I"){16 a="1I"}19{16 a=e.11("6b")?e.11("6b"):1g}2p(a){1l"1m":o=f.g.1A();u=0;1j;1l"1F":o=-f.g.1A();u=0;1j;1l"1q":u=f.g.1H();o=0;1j;1l"1o":u=-f.g.1H();o=0;1j;1l"3B":u=0;o=0;1j;1l"1I":6(e.11("3c")){6(e.11("3c")==="1m"){o=f.g.1A()}19 6(e.11("3c")==="1F"){o=-f.g.1A()}19{o=-1b(e.11("3c"))}}19{o=-f.1y.8l}6(e.11("3r")){6(e.11("3r")==="1q"){u=f.g.1H()}19 6(e.11("3r")==="1o"){u=-f.g.1H()}19{u=-1b(e.11("3r"))}}19{u=-f.1y.7C}1j}16 l=58=5o=4c=5p=5q=3k=3q="1Q";l=e.11("5U")?e.11("5U"):f.1y.7x;58=e.11("6p")?e.11("6p"):f.1y.7G;5o=e.11("6i")?e.11("6i"):f.1y.7P;4c=e.11("5M")?e.11("5M"):f.1y.7O;5p=e.11("6n")?e.11("6n"):f.1y.8T;5q=e.11("6o")?e.11("6o"):f.1y.8W;6(4c===1){3k=e.11("6m")?e.11("6m"):f.1y.8P;3q=e.11("6l")?e.11("6l"):f.1y.8O}19{3k=3q=4c}16 c=e.11("78")?e.11("78").1E(" "):f.1y.8V;23(16 h=0;h<c.1k;h++){6(c[h].1i("%")===-1&&c[h].1i("1m")!==-1&&c[h].1i("1F")!==-1&&c[h].1i("1q")!==-1&&c[h].1i("1o")!==-1){c[h]=""+1b(c[h])*f.g.1z+"1J"}}16 p=c.8Y(" ");16 d=e.11("6k")?e.11("6k"):f.1y.8S;16 v=1b(e.1a("1m"));16 m=1b(e.1a("1q"));16 g=1b(e.1f("1t").1E("12-l")[1]);16 y=e.3D()>e.3y()?e.3D():e.3y();16 b=1b(l)===0?e.3D():y;16 w=1b(l)===0?e.3y():y;6(g===-1&&a!=="1I"||e.11("3c")==="1m"||e.11("3c")==="1F"){6(o<0){o=-(f.g.1A()-v+(3k/2-.5)*b+1D)}19 6(o>0){o=v+(3k/2+.5)*b+1D}}19{o=o*f.g.1z}6(g===-1&&a!=="1I"||e.11("3r")==="1q"||e.11("3r")==="1o"){6(u<0){u=-(f.g.1H()-m+(3q/2-.5)*w+1D)}19 6(u>0){u=m+(3q/2+.5)*w+1D}}19{u=u*f.g.1z}6(g===-1||a==="1I"){16 E=1}19{16 S=f.g.1L.11("7w")?1b(f.g.1L.11("7w")):f.o.8L;16 E=g*S}6(e.11("2B")==="1I"){16 x=f.1y.4S;16 T=f.1y.4F}19{16 x=f.o.4S;16 T=f.o.4F}16 N=e.11("4L")?1b(e.11("4L")):x;16 C=e.11("4J")?e.11("4J"):T;16 k={29:"2O"};16 L={3g:l,4x:58,4z:5o,7s:5p,7r:5q,5k:3k,5j:3q,x:-o*E,y:-u*E,3T:n(C),8B:18(){e.1a(k)}};6(a=="3B"||!a&&s=="3B"||e.11("bO")!=="1g"&&e.11("2B")==="1I"){L["2Q"]=0;k["2Q"]=e.11("7d")}3a.8K(e[0],{8G:d,8C:p});3a.2e(e[0],N/1P,L)};f.4X=18(){f.d={3R:e("<1n>"),aT:18(t){e("<bI>"+t+"</bI>").1w(f.d.3R)},am:18(){e("<4I>").1w(f.d.3R)},aU:18(t){e("<4I><3E>"+t+"</3E></4I>").1w(f.d.3R)},aL:18(t){e("<3E>"+t+"</3E>").1w(f.d.3R.17("4I:4n"))},93:18(t){e("<4I>").1w(f.d.3R.17("4I:4n 3E:4n"))},aF:18(e){f.d.3R.17("4I:4n 3E:4n").1R(18(){e.1a({3v:"ej ei eg",3O:1b(e.1a("3j-1q"))-2,3p:1b(e.1a("3j-1m"))-2})},18(){e.1a({3v:"9b",3O:1b(e.1a("3j-1q"))+2,3p:1b(e.1a("3j-1m"))+2})})},64:18(){6(!e("3U").17(".12-4X-4w").1k){6(!f.d.aC){f.d.aT("eh eB");f.d.am();23(16 t 3M f.o){f.d.aL(t+": <1Y>"+f.o[t]+"</1Y>")}f.d.aT("2A ee");f.d.aU("en 2X ex ez: <1Y>"+e(u).17(".12-1p").1k+"</1Y>");e(u).17(\'.12-2c .12-1p, .12-2c *[1t*="12-l"]\').1O(18(){6(e(14).30("12-1p")){f.d.aU("<1Y>aK "+(e(14).5D()+1)+"</1Y>");f.d.93();f.d.aL("<1Y>aK "+(e(14).5D()+1)+" aG:</1Y><br><br>")}19{f.d.aU("&7b;&7b;&7b;&7b;ep ( "+e(14).aM("aH")+" )");f.d.aF(e(14));f.d.93();f.d.aL("<1Y>"+e(14).aM("aH")+" 4G aG:</1Y><br><br>");f.d.aL("es / 1t: <1Y>"+e(14).1f("1t")+"</1Y>")}e.1O(e(14).11(),18(e,t){f.d.aL(e+": <1Y>"+t+"</1Y>")})});f.d.aC=1c}16 n=e("<1n>").1r("12-4X-4w").1a({3x:"dI",aD:"dL",1q:"6h",1F:"6h",1d:"dU",28:"dV",3l:"e3","3v-e4":"6h",1e:e(2q).1e()-60,2Q:0,aX:7u}).1w(e("3U")).1a({aX:0,2Q:.9}).2k(18(t){6(t.aQ&&t.aP){e(14).7a()}});16 r=e("<1n>").1a({1d:"1D%",1e:"1D%",4q:"1U"}).1w(n);16 i=e("<1n>").1a({1d:"1D%"}).1w(r).3S(f.d.3R)}},e5:18(){e("3U").17(".12-4X-4w").7a()}};e(u).2k(18(e){6(e.aQ&&e.aP){f.d.64()}})};f.31()};16 n=18(e){16 t;6(e.20().1i("aR")!==-1||e.20().1i("8b")!==-1){t=7B.7A}19 6(e.20().1i("7E")!==-1){16 n=e.20().1E("7E")[1];t=2q[n.7I(0).8o()+n.7M(1)].aS}19 6(e.20().1i("7H")!==-1){16 n=e.20().1E("7H")[1];t=2q[n.7I(0).8o()+n.7M(1)].az}19 6(e.20().1i("7J")!==-1){16 n=e.20().1E("7J")[1];t=2q[n.7I(0).8o()+n.7M(1)].ay}1T t};16 r=18(e,t,r,i){6(1W t==="2W"){16 t="e1"}16 s={};6(e.3F!==i){s.3g=e.3F}6(e.3b!==i){s.4z=e.3b}6(e.2U!==i){s.4x=e.2U}6(r==="2C"){s.5k=s.5j=s.ah=1}19 6(e.4v!==i){s.5k=s.5j=s.ah=e.4v}6(e.1M){s.1M=r==="2C"?e.1M/1P:e.1M}s.3T=n(t);1T s};16 i=18(t){16 n=e("<1n>"),r=1g,i=1g,s=["dX","e0","eC","fw","dM"];3P=["eI","eX","e2","er","eo"];23(16 o=s.1k-1;o>=0;o--){r=r?r:n[0].1N[s[o]]!=2W}23(16 o=3P.1k-1;o>=0;o--){n.1a("3P-1N","al-3d");i=i?i:n[0].1N[3P[o]]=="al-3d"}6(r&&n[0].1N[s[4]]!=2W){n.1f("4N","12-ef").1w(t);r=n[0].ek===3&&n[0].ea===9;n.7a()}1T r&&i};16 s=18(e,t,n){16 r=[];6(n=="7X"){23(16 i=0;i<e;i++){23(16 s=0;s<t;s++){r.7Y(i+s*e)}}}19{23(16 i=e-1;i>-1;i--){23(16 s=t-1;s>-1;s--){r.7Y(i+s*e)}}}1T r};16 o=18(e){16 t=0;23(16 n 3M e){6(e.e9(n)){++t}}1T t};16 u=18(){bb=18(e){e=e.20();16 t=/(b9)[ \\/]([\\w.]+)/.5Y(e)||/(5S)[ \\/]([\\w.]+)/.5Y(e)||/(eb)(?:.*2s|)[ \\/]([\\w.]+)/.5Y(e)||/(9c) ([\\w.]+)/.5Y(e)||e.1i("bP")<0&&/(ed)(?:.*? em:([\\w.]+)|)/.5Y(e)||[];1T{7T:t[1]||"",2s:t[2]||"0"}};16 e=bb(3W.3Y),t={};6(e.7T){t[e.7T]=1c;t.2s=e.2s}6(t.b9){t.5S=1c}19 6(t.5S){t.ey=1c}1T t};eA=18(e,t){16 n=["5S","ew","bh","bi","o",""];16 r=0,i,s;bt(r<n.1k&&!e[i]){i=t;6(n[r]==""){i=i.bk(0,1).20()+i.bk(1)}i=n[r]+i;s=1W e[i];6(s!="2W"){n=[n[r]];1T s=="18"?e[i]():e[i]}r++}};t.7q={2s:"5.1.0",9m:18(){6(3W.3Y.3H(/eu/i)||3W.3Y.3H(/e8/i)||3W.3Y.3H(/e7/i)||3W.3Y.3H(/dQ/i)||3W.3Y.3H(/dR/i)||3W.3Y.3H(/dS/i)||3W.3Y.3H(/dO dJ/i)){1T 1c}19{1T 1g}},dK:18(e){6(e.1a("28-1o")=="1U"||e.1a("28-1o")=="1Q"||e.1a("28-1o")==0||e.1a("28-1o")=="9b"){1T 1c}19{1T 1g}},2o:u().9c&&u().2s<9?1c:1g,38:1g,5b:1g,2w:1g,36:1g,2y:79,2f:"1X",4o:79,1A:79,1H:79,7W:{1S:{1m:"1F",1F:"1m",1q:"1o",1o:"1q"},1X:{1m:"1m",1F:"1F",1q:"1q",1o:"1o"}},v:{d:41,fo:88,fi:41}};t.9Q={9R:80,9S:0,5y:1P,5r:0,5F:"7n",2J:1c,9X:0,9Y:0,a4:0,9x:1,a3:1,a2:1,9Z:0,a0:0,a1:["50%","50%","0"],9E:41,8l:-80,7C:0,4S:9A,e6:0,4F:"7n",3J:1c,7x:0,7G:0,7P:0,7O:1,8P:1,8O:1,8T:0,8W:0,8V:["50%","50%","0"],8S:41};t.9H={7i:as};t.9K={9L:1c,4E:0,7f:0,7g:1c,9M:1c,33:1,4B:1c,4j:0,7m:1c,92:1g,7k:1g,2r:"dY",3z:"/69/dZ/",8q:"8p",7p:1g,8M:1c,7e:1c,7h:1c,9y:1c,9G:1c,9F:1c,7j:1g,9W:1g,a6:1c,3e:"1R",7o:"60%",7V:1D,65:60,7U:35,81:1D,86:1c,2u:"1U",87:"fe.f6",43:1c,47:1c,1u:1g,bo:"1m: -6h; 1q: -6h;",7Z:1g,bp:"fu",bu:1c,bv:1c,bz:18(e){},b2:18(e){},ax:18(e){},au:18(e){},ac:18(e){},7Q:18(e){},7v:18(e){},7l:18(e){},7i:as,8s:"1F",ao:.45,8L:.45,5y:1P,4S:1P,5F:"7n",4F:"7n",5r:0,7t:0}})(3A)',62,963,'||||||if|||||||||||||||||||||||||||||||||||||||||||||||||||||||||data|ls||this||var|find|function|else|css|parseInt|true|width|height|attr|false|src|indexOf|break|length|case|left|div|bottom|slide|top|addClass|nav|class|yourLogo|nextLayer|appendTo|stop|lt|ratio|sliderWidth|transition|Math|100|split|right|thumbnail|sliderHeight|new|px|display|curLayer|delay|style|each|1e3|none|hover|prev|return|auto|active|typeof|next|strong|img|toLowerCase|the|start|for|parent||floor|curLayerIndex|padding|visibility|animation|iframe|inner||to|prevNext|setTimeout|random|href|replace|click|duration|block|container|ie78|switch|window|skin|version|originalAutoSlideshow|autoPauseSlideshow|clearTimeout|autoSlideshow|removeClass|layersNum|300|LayerSlider|transitiontype|after|ltContainer|sliderOriginalWidth|videopreview|L2|before|not|fadeIn|image|ot|video|T2|hidden|cttl|opacity|wrapper|loaded|resize|rotateX|layerSlider|undefined|of|originalHeight|originalWidth|hasClass|load|L1|firstSlide|visible||isAnimating||paused||TweenLite|rotateY|offsetxout||thumbnailNavigation|circleTimer|rotation|children|parseFloat|margin|curSubScaleX|background|is|bottomWrapper|totalDuration|marginLeft|curSubScaleY|offsetyout|makeResponsive|preventDefault|barTimer|border|preloaded|position|outerHeight|skinsPath|jQuery|fade|slidedirection|outerWidth|li|rotate|param|match|curSlideTime|fadeOut|box|deg|in|tr|marginTop|transform|tile|history|append|ease|body|number|navigator|videoSrc|userAgent|error|shadow|500|thumbsWrapper|imgPreload|or||pausedSlideTime|lazyLoad|isLoading|abs|responsiveMode|rows|curSubScale|startSlideTime|on|autoplay|thumb|originalLeft|it|loops|originalTop|tn|sliderOriginalHeight|last|slideTimer|cols|overflow|nextLoop|animate|all|html|scale3d|console|rotationX|type|rotationY|easing|animateFirstSlide|change|extend|responsiveUnder|easingOut|layer|png|ul|easingout|like|durationout|location|id|your|Please|and|always|durationOut|slidebuttons|getTime|parallaxlevel|transition3d|debug|scale2D|st||shadowImg|vimeo|youtu|curTiles|rel|_|Date|curSubRotateX|init|touches|pausedByVideo|nextSubScaleY|delayin|offsetxin|offsetyin|WordPress|fisrtSlide|thumbnails|scaleY|scaleX|tt|offset|nextSubScaleX|curSubRotateY|curSubSkewX|curSubSkewY|delayIn|customtransition2d|durationin|customtransition3d|showuntil|delayout|LSCustomTransition|durationIn|touchEndX|trim|transition2d|empty|index|removeAttr|easingIn|span|slidedelay|scale|alt|easingin|0deg|scaleout|com|transitionType|back|timer|rotateZ|webkit|string|rotateout|old|reverse|translate3d|exec|direction||nextLayerIndex|player|url|show|tnHeight|www|vpcontainer|pause|layerslider|closest|slideoutdirection|document|originalBottom|originalRight|wp|fullwidth|10px|rotateyout|clicked|perspectiveout|scaleyout|scalexout|skewxout|skewyout|rotatexout|prependTo|layerMarginLeft|ontouchstart|fadeTo|oB|layerMarginTop|curLayerTop|nIt|nextLayerTop|nextLayerLeft|oT|oR|videoTimer|nothumb|touchStartX|bind|showShadow|originalBorderLeft|originalBorderBottom|originalBorderTop|originalBorderRight|seems|URL|180|Play|http|videoDuration|fromTo|nt|name|O2|rt|showUntilTimer|audio|check|cannot|wrong|pointing|URLs|images|nextSubScale|slider|used|timeshift|transformoriginout|null|remove|nbsp|link|originalOpacity|navStartStop|layersContainer|autoStart|navButtons|slideDelay|hoverBottomNav|randomSlideshow|cbNext|forceLoopNum|easeInOutQuint|tnContainerWidth|globalBGImage|global|skewY|skewX|delayOut|150|cbPrev|parallaxout|rotateOut|scrollThumb|originalPaddingRight|easeNone|Linear|offsetYOut|curLayerRight|easeinout|originalPaddingLeft|rotateXOut|easeout|charAt|easein|linkto|nextSubSkewY|slice|bottomNavSizeHelper|scaleOut|rotateYOut|cbAnimStop|changeThumb|bottomright|browser|tnActiveOpacity|tnWidth|slideDirections|forward|push|yourLogoLink||tnInactiveOpacity|nextSubRotateY|nextSubRotateX|nextSubSkewX|kill|autoPlayVideos|youtubePreview|750|embed|nextLayerRight|linear|clone|nextLayerHeight|nextLayerWidth|nextTiles|bottomleft|topright|250|youtube|nextLayerBottom|offsetXOut|topleft|curLayerBottom|toUpperCase|transparent|globalBGColor|forceHideControls|slideDirection|resizeShadow|slideTransition|wpVersion|cssContainer|lswpVersion|sliderOriginalWidthRU|resizeSlider|scalein|onComplete|transformOrigin|dequeue|sublayerContainer|videohack|transformPerspective|sublayerShowUntil|rotatein|text|set|parallaxOut|navPrevNext|jquery|scaleYOut|scaleXOut|originalPaddingBottom|originalPaddingTop|perspectiveOut|skewXOut|fired|transformOriginOut|skewYOut|pageX|join|resizeYourLogo||content|twoWaySlideshow|aUU|script|ut|It|borderRightWidth|looks|issue|showSlider|0px|msie|borderLeftWidth|animating|skewyin|borderTopWidth|font|perspectivein|size|line|library|isMobile|originalLineHeight|transformoriginin|skewxin|rotateyin|rotatexin|parallaxin|scalexin|originalFontSize|scaleyin|cbTimeLineStart|scaleIn|keybNav|helper|400|shadowBtmMod|stopLayer|substring|perspectiveIn|hoverPrevNext|touchNav|slideTransitions|off|resizeThumb|options|responsive|pauseOnHover|hider|lastIndexOf|alert|layerTransitions|offsetXIn|offsetYIn|loading|gi|borderBottomWidth|showBarTimer|rotateIn|rotateXIn|skewXIn|skewYIn|transformOriginIn|scaleYIn|scaleXIn|rotateYIn|half|showCircleTimer|depth|t2|t1|t3|t4|cbAnimStart|lsShowNotice|oldjquery|forcestop|mirror|scaleZ|object|mousemove|ieEasing|preserve|aeU||parallaxIn|group|relative|entry|4e3||cbPause|disabled|sides|cbStop|easeIn|easeOut|forced|t5|putData|zIndex|meta||properties|tagName|firstSlideAnimated|above|SLIDE||prop|initialized|layerSliderCustomTransitions|altKey|shiftKey|swing|easeInOut|||hash|norotate|marginRight|layerSliderTransitions|add|2e3|350|cbStart|with|opaque|update|plugin|default|firstLayer|chrome|wmode|uaMatch|randomize|col||originalEvent||moz|ms|custom3d|substr|curSkin|which|custom2d|yourLogoStyle|yourLogoTarget|controls||from|while|optimizeForMobile|optimizeForIE78|front|vi||cbInit|getJSON|horizontal|head|TimelineLite|pageY|parallaxStartY|parallaxStartX|api|h1|thumbnail_large|clientX|large|playvideo|JS|fadeout|compatible|callback|createStyleSheet|json|that|keydown|multiple|sideright|backgroundImage|backgroundColor|important|blank|causing|copy|loads|extra|theme|gif|indicator|static|touchscroll|another|sideleft|center|mouseenter|mouseleave|absolute|below|using|title|pointer|exclam|here|continue|forceStop|enableCSS3|deeplink|cursor|clicking|file||more|media|read|yt|about|videos|gdata|feeds|updating|round|enabled|stylesheet|already|Skin|Trying|Fallback|mode|were|Neither|animateFirstLayer|mistyped|Possibilities|insertAfter|information|force|gpuhack|insertBefore|without|Loading|WP|can|You|within|option|includes|Put|Troubleshooting|Advanced|are|you|Settings|ended|enable|area|admin|navigate|sliders|circle|bar|wrapAll|page|main|requires|least|kreaturamedia|support||IE|browsers|v2|html5|seconds|wordpress|faq|older|because|Important|higher|newer|play|currentTime|Updater|use|640|problems|mixed|fixed|Phone|isHideOn3D|10000000000|WebkitPerspective|curtile|Windows|dispay|iPad|iPod|BlackBerry|nexttile|300px|20px|vertical|perspective|v5|skins|OPerspective|easeInOutQuart|msTransformStyle|black|radius|hide|showUntil|iPhone|webOS|hasOwnProperty|offsetLeft|opera|touchstart|mozilla|Content|test3d|red|Init|solid|2px|offsetHeight||rv|Number|WebkitTransformStyle|Layer||MozTransformStyle|distance||Android|obj|khtml|slides|safari|found|lsPrefixes|code|msPerspective|touchmove|Cubic|cubic|Quart|quart|transformStyle|quint|expo|Expo|Sine|sine|Quint|Quad|quad|target|textDecoration|bock|yourlogo|touchend|outline|OTransformStyle|restart|resume|onReverseComplete|queue|nexttiles|circ|fadein|custom|jpg|filter|layerMarginBottom|specified|carousel|t2d|curtiles|sequence|maxresdefault|crossfad|layerMarginRight|changeTimer||Back|bounce|Elastic|elastic|||Circ|Bounce|450|600|log|_self|Trident|MozPerspective'.split('|'),0,{}))
/*
	* 2D & 3D Transitions for LayerSlider
	* (c) 2011-2014 George Krupa, John Gera & Kreatura Media
	* Plugin web:			http://kreaturamedia.com/
	* Licenses: 			http://codecanyon.net/licenses/
*/
eval(function(p,a,c,k,e,d){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};while(c--){if(k[c]){p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c])}}return p}('20 1Z={27:[{j:"13 N E",d:1,g:1,f:{e:0,i:"o"},c:{n:"W",b:"1e",a:G,h:"r"}},{j:"13 N r",d:1,g:1,f:{e:0,i:"o"},c:{n:"W",b:"1e",a:G,h:"E"}},{j:"13 N L",d:1,g:1,f:{e:0,i:"o"},c:{n:"W",b:"1e",a:G,h:"J"}},{j:"13 N J",d:1,g:1,f:{e:0,i:"o"},c:{n:"W",b:"1e",a:G,h:"L"}},{j:"26",d:1,g:1,f:{e:0,i:"o"},c:{n:"14",b:"1e",a:G,h:"r"}},{j:"Z R o",d:[2,4],g:[4,7],f:{e:1k,i:"o"},c:{n:"14",b:"z",a:G,h:"r"}},{j:"Z R D",d:[2,4],g:[4,7],f:{e:1k,i:"D"},c:{n:"14",b:"z",a:G,h:"r"}},{j:"Z R 1j-o",d:[2,4],g:[4,7],f:{e:1k,i:"1j-o"},c:{n:"14",b:"z",a:G,h:"r"}},{j:"Z R 1j-D",d:[2,4],g:[4,7],f:{e:1k,i:"1j-D"},c:{n:"14",b:"z",a:G,h:"r"}},{j:"Z R (k)",d:[2,4],g:[4,7],f:{e:1k,i:"k"},c:{n:"14",b:"z",a:G,h:"r"}},{j:"1y 1H N E",d:1,g:1s,f:{e:25,i:"D"},c:{n:"14",b:"1X",a:V,h:"r"}},{j:"1y 1H N r",d:1,g:1s,f:{e:25,i:"o"},c:{n:"14",b:"w",a:V,h:"r"}},{j:"1y 1H N L",d:1s,g:1,f:{e:25,i:"1j-D"},c:{n:"14",b:"w",a:V,h:"r"}},{j:"1y 1H N J",d:1s,g:1,f:{e:25,i:"1j-o"},c:{n:"14",b:"w",a:V,h:"r"}},{j:"1y Y N E",d:1,g:25,f:{e:1k,i:"D"},c:{n:"W",b:"w",a:1g,h:"r"}},{j:"1y Y N r",d:1,g:25,f:{e:1k,i:"o"},c:{n:"W",b:"w",a:1g,h:"E"}},{j:"1y 1W N L",d:25,g:1,f:{e:1k,i:"1j-D"},c:{n:"W",b:"w",a:1g,h:"J"}},{j:"1y Y N J",d:25,g:1,f:{e:1k,i:"1j-o"},c:{n:"W",b:"w",a:1g,h:"L"}},{j:"13 R m E (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"W",b:"z",a:1m,h:"E"}},{j:"13 R m r (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"W",b:"z",a:1m,h:"r"}},{j:"13 R m L (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"W",b:"z",a:1m,h:"L"}},{j:"13 R m J (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"W",b:"z",a:1m,h:"J"}},{j:"13 k R m k 1S",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"W",b:"z",a:1m,h:"k"}},{j:"13 d m E (o)",d:[7,11],g:1,f:{e:1d,i:"o"},c:{n:"W",b:"w",a:p,h:"E"}},{j:"13 d m E (D)",d:[7,11],g:1,f:{e:1d,i:"D"},c:{n:"W",b:"w",a:p,h:"E"}},{j:"13 d m E (k)",d:[7,11],g:1,f:{e:1d,i:"k"},c:{n:"W",b:"w",a:p,h:"E"}},{j:"13 d m r (o)",d:[7,11],g:1,f:{e:1d,i:"o"},c:{n:"W",b:"w",a:p,h:"r"}},{j:"13 d m r (D)",d:[7,11],g:1,f:{e:1d,i:"D"},c:{n:"W",b:"w",a:p,h:"r"}},{j:"13 d m r (k)",d:[7,11],g:1,f:{e:1d,i:"k"},c:{n:"W",b:"w",a:p,h:"r"}},{j:"13 d N J m L (o)",d:[7,11],g:1,f:{e:1d,i:"o"},c:{n:"W",b:"w",a:p,h:"L"}},{j:"13 d N J m L (k)",d:[7,11],g:1,f:{e:1d,i:"k"},c:{n:"W",b:"w",a:p,h:"L"}},{j:"13 d N L m J (D)",d:[7,11],g:1,f:{e:1d,i:"D"},c:{n:"W",b:"w",a:p,h:"J"}},{j:"13 d N L m J (k)",d:[7,11],g:1,f:{e:1d,i:"k"},c:{n:"W",b:"w",a:p,h:"J"}},{j:"13 P m L (o)",d:1,g:[12,16],f:{e:q,i:"o"},c:{n:"W",b:"w",a:p,h:"L"}},{j:"13 P m L (D)",d:1,g:[12,16],f:{e:q,i:"D"},c:{n:"W",b:"w",a:p,h:"L"}},{j:"13 P m L (k)",d:1,g:[12,16],f:{e:q,i:"k"},c:{n:"W",b:"w",a:p,h:"L"}},{j:"13 P m J (o)",d:1,g:[12,16],f:{e:q,i:"o"},c:{n:"W",b:"w",a:p,h:"J"}},{j:"13 P m J (D)",d:1,g:[12,16],f:{e:q,i:"D"},c:{n:"W",b:"w",a:p,h:"J"}},{j:"13 P m J (k)",d:1,g:[12,16],f:{e:q,i:"k"},c:{n:"W",b:"w",a:p,h:"J"}},{j:"13 P N r m E (o)",d:1,g:[12,16],f:{e:q,i:"o"},c:{n:"W",b:"w",a:p,h:"E"}},{j:"13 P N r m E (k)",d:1,g:[12,16],f:{e:q,i:"k"},c:{n:"W",b:"w",a:p,h:"E"}},{j:"13 P N E m r (D)",d:1,g:[12,16],f:{e:q,i:"D"},c:{n:"W",b:"w",a:p,h:"r"}},{j:"13 P N E m r (k)",d:1,g:[12,16],f:{e:q,i:"k"},c:{n:"W",b:"w",a:p,h:"r"}},{j:"Z v Y R m E (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"Q",b:"z",a:1m,h:"E"}},{j:"Z v Y R m r (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"Q",b:"z",a:1m,h:"r"}},{j:"Z v Y R m L (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"Q",b:"z",a:1m,h:"L"}},{j:"Z v Y R m J (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"Q",b:"z",a:1m,h:"J"}},{j:"Z v Y k R m k 1S",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"Q",b:"z",a:1m,h:"k"}},{j:"Z v Y R N J-r (o)",d:[2,4],g:[4,7],f:{e:1f,i:"o"},c:{n:"Q",b:"z",a:1m,h:"1V"}},{j:"Z v Y R N L-E (D)",d:[2,4],g:[4,7],f:{e:1f,i:"D"},c:{n:"Q",b:"z",a:1m,h:"21"}},{j:"Z v Y R N J-E (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"Q",b:"z",a:1m,h:"1T"}},{j:"Z v Y R N L-r (k)",d:[2,4],g:[4,7],f:{e:1f,i:"k"},c:{n:"Q",b:"z",a:1m,h:"1U"}},{j:"Z v Y d m E (o)",d:[7,11],g:1,f:{e:1d,i:"o"},c:{n:"Q",b:"w",a:p,h:"E"}},{j:"Z v Y d m E (D)",d:[7,11],g:1,f:{e:1d,i:"D"},c:{n:"Q",b:"w",a:p,h:"E"}},{j:"Z v Y d m E (k)",d:[7,11],g:1,f:{e:1d,i:"k"},c:{n:"Q",b:"w",a:p,h:"E"}},{j:"Z v Y d m r (o)",d:[7,11],g:1,f:{e:1d,i:"o"},c:{n:"Q",b:"w",a:p,h:"r"}},{j:"Z v Y d m r (D)",d:[7,11],g:1,f:{e:1d,i:"D"},c:{n:"Q",b:"w",a:p,h:"r"}},{j:"Z v Y d m r (k)",d:[7,11],g:1,f:{e:1d,i:"k"},c:{n:"Q",b:"w",a:p,h:"r"}},{j:"Z v Y d N J m L (o)",d:[7,11],g:1,f:{e:1d,i:"o"},c:{n:"Q",b:"w",a:p,h:"L"}},{j:"Z v Y d N J m L (k)",d:[7,11],g:1,f:{e:1d,i:"k"},c:{n:"Q",b:"w",a:p,h:"L"}},{j:"Z v Y d N L m J (D)",d:[7,11],g:1,f:{e:1d,i:"D"},c:{n:"Q",b:"w",a:p,h:"J"}},{j:"Z v Y d N L m J (k)",d:[7,11],g:1,f:{e:1d,i:"k"},c:{n:"Q",b:"w",a:p,h:"J"}},{j:"Z v Y P m L (o)",d:1,g:[12,16],f:{e:q,i:"o"},c:{n:"Q",b:"w",a:p,h:"L"}},{j:"Z v Y P m L (D)",d:1,g:[12,16],f:{e:q,i:"D"},c:{n:"Q",b:"w",a:p,h:"L"}},{j:"Z v Y P m L (k)",d:1,g:[12,16],f:{e:q,i:"k"},c:{n:"Q",b:"w",a:p,h:"L"}},{j:"Z v Y P m J (o)",d:1,g:[12,16],f:{e:q,i:"o"},c:{n:"Q",b:"w",a:p,h:"J"}},{j:"Z v Y P m J (D)",d:1,g:[12,16],f:{e:q,i:"D"},c:{n:"Q",b:"w",a:p,h:"J"}},{j:"Z v Y P m J (k)",d:1,g:[12,16],f:{e:q,i:"k"},c:{n:"Q",b:"w",a:p,h:"J"}},{j:"Z v Y P N r m E (o)",d:1,g:[12,16],f:{e:q,i:"o"},c:{n:"Q",b:"w",a:p,h:"E"}},{j:"Z v Y P N r m E (k)",d:1,g:[12,16],f:{e:q,i:"k"},c:{n:"Q",b:"w",a:p,h:"E"}},{j:"Z v Y P N E m r (D)",d:1,g:[12,16],f:{e:q,i:"D"},c:{n:"Q",b:"w",a:p,h:"r"}},{j:"Z v Y P N E m r (k)",d:1,g:[12,16],f:{e:q,i:"k"},c:{n:"Q",b:"w",a:p,h:"r"}},{j:"1u",d:1,g:1,f:{e:0,i:"o"},c:{n:"Q",b:"1e",a:V,h:"r",1h:.5}},{j:"1u d",d:4,g:1,f:{e:1f,i:"o"},c:{n:"Q",b:"1e",a:V,h:"r",1h:.5}},{j:"1u g",d:1,g:4,f:{e:1f,i:"o"},c:{n:"Q",b:"1e",a:V,h:"r",1h:.5}},{j:"1u R A",d:3,g:4,f:{e:1s,i:"o"},c:{n:"Q",b:"1e",a:V,h:"r",1h:.5,y:x}},{j:"1u R F",d:3,g:4,f:{e:1s,i:"o"},c:{n:"Q",b:"1e",a:V,h:"J",1h:.5,u:-x}},{j:"1u-1I R A",d:3,g:4,f:{e:15,i:"o"},c:{n:"Q",b:"1e",a:V,h:"r",1h:.5,y:x}},{j:"1u-1I R F",d:3,g:4,f:{e:15,i:"o"},c:{n:"Q",b:"1e",a:V,h:"J",1h:.5,u:-x}},{j:"1u 1I d",d:4,g:1,f:{e:1f,i:"o"},c:{n:"Q",b:"1e",a:V,h:"E",1h:.5}},{j:"1u 1I g",d:1,g:4,f:{e:1f,i:"o"},c:{n:"Q",b:"1e",a:V,h:"r",1h:.5}},{j:"1c f N r",d:1,g:1,f:{e:0,i:"o"},c:{n:"W",b:"z",a:V,h:"E",y:x}},{j:"1c f N E",d:1,g:1,f:{e:0,i:"o"},c:{n:"W",b:"z",a:V,h:"r",y:-x}},{j:"1c f N J",d:1,g:1,f:{e:0,i:"o"},c:{n:"W",b:"z",a:V,h:"L",u:-x}},{j:"1c f N L",d:1,g:1,f:{e:0,i:"o"},c:{n:"W",b:"z",a:V,h:"J",u:x}},{j:"1c R N r",d:[3,4],g:[3,4],f:{e:19,i:"o"},c:{n:"14",b:"z",a:V,h:"r",y:x}},{j:"1c R N E",d:[3,4],g:[3,4],f:{e:19,i:"D"},c:{n:"14",b:"z",a:V,h:"r",y:-x}},{j:"1c R N J",d:[3,4],g:[3,4],f:{e:19,i:"o"},c:{n:"14",b:"z",a:V,h:"r",u:-x}},{j:"1c R N L",d:[3,4],g:[3,4],f:{e:19,i:"D"},c:{n:"14",b:"z",a:V,h:"r",u:x}},{j:"1c d N J",d:[6,12],g:1,f:{e:19,i:"o"},c:{n:"14",b:"z",a:V,h:"r",u:x}},{j:"1c d N L",d:[6,12],g:1,f:{e:19,i:"D"},c:{n:"14",b:"z",a:V,h:"r",u:-x}},{j:"1c g N r",d:1,g:[6,12],f:{e:19,i:"o"},c:{n:"14",b:"z",a:V,h:"r",y:-x}},{j:"1c g N E",d:1,g:[6,12],f:{e:19,i:"D"},c:{n:"14",b:"z",a:V,h:"r",y:x}},{j:"1v d N r",d:[3,10],g:1,f:{e:19,i:"o"},c:{n:"14",b:"z",a:V,h:"r",y:x}},{j:"1v d N E",d:[3,10],g:1,f:{e:19,i:"D"},c:{n:"14",b:"z",a:V,h:"r",y:-x}},{j:"1v g N J",d:1,g:[3,10],f:{e:19,i:"o"},c:{n:"14",b:"z",a:V,h:"r",u:-x}},{j:"1v g N L",d:1,g:[3,10],f:{e:19,i:"D"},c:{n:"14",b:"z",a:V,h:"r",u:x}},{j:"1v v 1z f N r",d:1,g:1,f:{e:q,i:"o"},c:{n:"Q",b:"z",a:V,h:"E",1h:.1,1r:-x,y:x}},{j:"1v v 1z f N E",d:1,g:1,f:{e:q,i:"o"},c:{n:"Q",b:"z",a:V,h:"r",1h:.1,1r:x,y:-x}},{j:"1v v 1z R N r",d:[3,4],g:[3,4],f:{e:19,i:"o"},c:{n:"Q",b:"z",a:V,h:"E",1r:-1w}},{j:"1v v 1z R N E",d:[3,4],g:[3,4],f:{e:19,i:"o"},c:{n:"Q",b:"z",a:V,h:"r",1r:-1w}},{j:"1v v 1z R N k",d:[3,4],g:[3,4],f:{e:19,i:"k"},c:{n:"Q",b:"z",a:V,h:"k",1r:-1w}},{j:"B f 1O",d:1,g:1,f:{e:0,i:"o"},c:{n:"14",b:"z",a:1a,h:"r",1h:.8}},{j:"B f N 1L",d:1,g:1,f:{e:0,i:"o"},c:{n:"14",b:"w",a:1a,h:"r",1h:1.2}},{j:"B R k",d:[3,4],g:[3,4],f:{e:1s,i:"k"},c:{n:"14",b:"z",a:V,h:"r",1h:.1}},{j:"B R N 1L k",d:[3,4],g:[3,4],f:{e:1s,i:"k"},c:{n:"14",b:"z",a:V,h:"r",1h:2}},{j:"B 1O v 1z R k",d:[3,4],g:[3,4],f:{e:1s,i:"k"},c:{n:"14",b:"z",a:V,h:"r",1h:.1,1r:x}},{j:"B v 1z R N 1L k",d:[3,4],g:[3,4],f:{e:1s,i:"k"},c:{n:"14",b:"z",a:V,h:"r",1h:2,1r:-x}},{j:"1D-Y R 24",d:3,g:4,f:{e:15,i:"o"},c:{n:"W",b:"w",a:1Y,h:"1T"}},{j:"1D-Y d A",d:6,g:1,f:{e:0,i:"o"},c:{n:"Q",b:"z",a:V,h:"r"}},{j:"1D-Y d F",d:6,g:1,f:{e:0,i:"o"},c:{n:"Q",b:"z",a:V,h:"J"}},{j:"1D-Y g A",d:1,g:8,f:{e:0,i:"o"},c:{n:"Q",b:"z",a:V,h:"r"}},{j:"1D-Y g F",d:1,g:8,f:{e:0,i:"o"},c:{n:"Q",b:"z",a:V,h:"J"}}],23:[{j:"1b f m E (l&#t;)",d:1,g:1,f:{e:q,i:"o"},s:{c:{y:1E},b:"1F",a:G,h:"A"},C:{c:{y:l},b:"z",a:G,h:"A"}},{j:"1b f m r (l&#t;)",d:1,g:1,f:{e:q,i:"o"},s:{c:{y:-1E},b:"1F",a:G,h:"A"},C:{c:{y:-l},b:"z",a:G,h:"A"}},{j:"1b f m L (l&#t;)",d:1,g:1,f:{e:q,i:"o"},s:{c:{u:-1E},b:"1F",a:1x,h:"F"},C:{c:{u:-l},b:"z",a:1x,h:"F"}},{j:"1b f m J (l&#t;)",d:1,g:1,f:{e:q,i:"o"},s:{c:{u:1E},b:"1F",a:1x,h:"F"},C:{c:{u:l},b:"z",a:1x,h:"F"}},{j:"1b R m E (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"o"},s:{c:{y:l},b:"w",a:G,h:"A"}},{j:"1b R m r (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"D"},s:{c:{y:-l},b:"w",a:G,h:"A"}},{j:"1b R m L (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"1j-o"},s:{c:{u:-l},b:"w",a:G,h:"F"}},{j:"1b R m J (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"1j-D"},s:{c:{u:l},b:"w",a:G,h:"F"}},{j:"1B S R k (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"k"},s:{c:{y:l},b:"w",a:1G,h:"A"}},{j:"1C S R k (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"k"},s:{c:{u:l},b:"w",a:1G,h:"F"}},{j:"B v S R m E (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"o"},M:{c:{I:.1A},a:1l,b:"18"},s:{c:{y:l},b:"H",a:G,h:"A"},C:{a:1g,b:"H"}},{j:"B v S R m r (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"D"},M:{c:{I:.1A},a:1l,b:"18"},s:{c:{y:-l},b:"H",a:G,h:"A"},C:{a:1g,b:"H"}},{j:"B v S R m L (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"1j-o"},M:{c:{I:.1A},a:1l,b:"18"},s:{c:{u:-l},b:"H",a:G,h:"F"},C:{a:1g,b:"H"}},{j:"B v S R m J (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"1j-D"},M:{c:{I:.1A},a:1l,b:"18"},s:{c:{u:l},b:"H",a:G,h:"F"},C:{a:1g,b:"H"}},{j:"B v A S R k (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"k"},M:{c:{I:.1A,u:1k},a:1l,b:"18"},s:{c:{y:l,u:-1k},b:"H",a:1G,h:"A"},C:{c:{u:0},a:1g,b:"H"}},{j:"B v F S R k (l&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"k"},M:{c:{I:.1A,y:-15},a:1l,b:"18"},s:{c:{u:l,y:15},b:"H",a:1G,h:"F"},C:{c:{y:0},a:1g,b:"H"}},{j:"1b d m E (l&#t;)",d:[5,9],g:1,f:{e:q,i:"o"},s:{c:{y:l},b:"w",a:1a,h:"A"}},{j:"1b d m r (l&#t;)",d:[5,9],g:1,f:{e:q,i:"o"},s:{c:{y:-l},b:"w",a:1a,h:"A"}},{j:"1b d m L (l&#t;)",d:[5,9],g:1,f:{e:q,i:"o"},s:{c:{u:-l},b:"w",a:G,h:"F"}},{j:"1b d m J (l&#t;)",d:[5,9],g:1,f:{e:q,i:"D"},s:{c:{u:l},b:"w",a:G,h:"F"}},{j:"1B S d k (l&#t;)",d:[5,9],g:1,f:{e:q,i:"k"},s:{c:{y:l},b:"w",a:1a,h:"A"}},{j:"1C S d k (l&#t;)",d:[5,9],g:1,f:{e:q,i:"k"},s:{c:{u:-l},b:"w",a:1a,h:"F"}},{j:"1C S d k (1J&#t;)",d:[3,7],g:1,f:{e:1Q,i:"k"},s:{c:{u:-1J},b:"w",a:1R,h:"F"}},{j:"B v S d m E (l&#t;)",d:[5,9],g:1,f:{e:19,i:"o"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:l},b:"H",a:1p,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v S d m r (l&#t;)",d:[5,9],g:1,f:{e:19,i:"D"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:-l},b:"H",a:1p,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v S d m L (l&#t;)",d:[5,9],g:1,f:{e:19,i:"o"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-l},b:"w",a:p,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v S d m J (l&#t;)",d:[5,9],g:1,f:{e:19,i:"D"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:l},b:"w",a:p,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v A S d k (l&#t;)",d:[5,9],g:1,f:{e:19,i:"k"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:l},b:"H",a:1p,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v F S d k (l&#t;)",d:[5,9],g:1,f:{e:19,i:"k"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-l},b:"H",a:p,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"1b P m E (l&#t;)",d:1,g:[5,9],f:{e:q,i:"o"},s:{c:{y:l},b:"w",a:1a,h:"A"}},{j:"1b P m r (l&#t;)",d:1,g:[5,9],f:{e:q,i:"o"},s:{c:{y:-l},b:"w",a:1a,h:"A"}},{j:"1b P m L (l&#t;)",d:1,g:[5,9],f:{e:q,i:"o"},s:{c:{u:-l},b:"w",a:G,h:"F"}},{j:"1b P m J (l&#t;)",d:1,g:[5,9],f:{e:q,i:"D"},s:{c:{u:l},b:"w",a:G,h:"F"}},{j:"1B S P k (l&#t;)",d:1,g:[5,9],f:{e:q,i:"k"},s:{c:{y:l},b:"w",a:1a,h:"A"}},{j:"1C S P k (l&#t;)",d:1,g:[5,9],f:{e:q,i:"k"},s:{c:{u:-l},b:"w",a:1a,h:"F"}},{j:"1B S P k (1J&#t;)",d:1,g:[4,9],f:{e:1Q,i:"k"},s:{c:{y:1J},b:"w",a:1R,h:"A"}},{j:"B v S P m E (l&#t;)",d:1,g:[7,11],f:{e:19,i:"o"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:l},b:"w",a:p,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v S P m r (l&#t;)",d:1,g:[7,11],f:{e:19,i:"D"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:-l},b:"w",a:p,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v S P m L (l&#t;)",d:1,g:[7,11],f:{e:19,i:"o"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-l},b:"H",a:1p,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v S P m J (l&#t;)",d:1,g:[7,11],f:{e:q,i:"D"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:l},b:"H",a:1p,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v A S P k (l&#t;)",d:1,g:[7,11],f:{e:q,i:"k"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:l},b:"H",a:p,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v F S P k (l&#t;)",d:1,g:[7,11],f:{e:q,i:"k"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-l},b:"H",a:1p,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"1N 1P 1M v S m E (l&#t;)",d:1,g:[7,11],f:{e:q,i:"o"},M:{c:{I:.O,u:-1k},a:p,b:"z"},s:{c:{u:-1k,y:l},b:"w",a:G,h:"A"},C:{c:{u:0,e:X},b:"z",a:p}},{j:"1N 1P 1M v S m r (l&#t;)",d:1,g:[7,11],f:{e:q,i:"D"},M:{c:{I:.O,u:-1k},a:p,b:"z"},s:{c:{u:1k,y:-l},b:"w",a:G,h:"A"},C:{c:{u:0,e:X},b:"z",a:p}},{j:"1c 1t m E (x&#t;)",d:1,g:1,f:{e:q,i:"o"},s:{c:{y:x},b:"w",a:1a,h:"A"}},{j:"1c 1t m r (x&#t;)",d:1,g:1,f:{e:q,i:"o"},s:{c:{y:-x},b:"w",a:1a,h:"A"}},{j:"1c 1t m L (x&#t;)",d:1,g:1,f:{e:q,i:"o"},s:{c:{u:-x},b:"w",a:1a,h:"F"}},{j:"1c 1t m J (x&#t;)",d:1,g:1,f:{e:q,i:"o"},s:{c:{u:x},b:"w",a:1a,h:"F"}},{j:"B v 17 1t m E (x&#t;)",d:1,g:1,f:{e:q,i:"k"},s:{c:{I:.8,1r:7,u:10,y:1w},b:"1e",a:1x,h:"A"},C:{c:{1r:0,u:0,y:x},a:1x,b:"1e"}},{j:"B v 17 1t m r (x&#t;)",d:1,g:1,f:{e:q,i:"k"},s:{c:{I:.8,1r:-7,u:10,y:-1w},b:"1e",a:1x,h:"A"},C:{c:{1r:0,u:0,y:-x},a:1x,b:"1e"}},{j:"B v 17 1n m E (x&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"o"},M:{c:{I:.O},a:1l,b:"18"},s:{c:{y:x},b:"H",a:G,h:"A"},C:{a:1g,b:"H"}},{j:"B v 17 1n m r (x&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"D"},M:{c:{I:.O},a:1l,b:"18"},s:{c:{y:-x},b:"H",a:G,h:"A"},C:{a:1g,b:"H"}},{j:"B v 17 1n m L (x&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"1j-o"},M:{c:{I:.O},a:1l,b:"18"},s:{c:{u:-x},b:"H",a:G,h:"F"},C:{a:1g,b:"H"}},{j:"B v 17 1n m J (x&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"1j-D"},M:{c:{I:.O},a:1l,b:"18"},s:{c:{u:x},b:"H",a:G,h:"F"},C:{a:1g,b:"H"}},{j:"B v A 17 1n k (x&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"k"},M:{c:{I:.1i,u:-15},a:1o,b:"18"},s:{c:{y:q,u:15},b:"H",a:1o,h:"A"},C:{c:{y:x,u:0},a:1o,b:"H"}},{j:"B v F 17 1n k (x&#t;)",d:[2,4],g:[4,7],f:{e:q,i:"k"},M:{c:{I:.1i,y:15},a:1o,b:"18"},s:{c:{u:q,y:-15},b:"H",a:1o,h:"F"},C:{c:{u:x,y:0},a:1o,b:"H"}},{j:"1c d m E (x&#t;)",d:[5,9],g:1,f:{e:q,i:"o"},s:{c:{y:x},b:"w",a:1a,h:"A"}},{j:"1c d m r (x&#t;)",d:[5,9],g:1,f:{e:q,i:"o"},s:{c:{y:-x},b:"w",a:1a,h:"A"}},{j:"1B 17 d k (x&#t;)",d:[5,9],g:1,f:{e:q,i:"k"},s:{c:{y:x},b:"w",a:1a,h:"A"}},{j:"B v 17 d m E (x&#t;)",d:[5,9],g:1,f:{e:q,i:"o"},M:{c:{I:.O,u:3},a:p,b:"K"},s:{c:{y:22,u:0},b:"H",a:G,h:"A"},C:{c:{e:X,y:x},b:"K",a:p}},{j:"B v 17 d m r (x&#t;)",d:[5,9],g:1,f:{e:q,i:"D"},M:{c:{I:.O,u:3},a:p,b:"K"},s:{c:{y:-x,u:0},b:"H",a:G,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v 17 d m L (x&#t;)",d:[5,9],g:1,f:{e:q,i:"o"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-x},b:"H",a:G,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v 17 d m J (x&#t;)",d:[5,9],g:1,f:{e:q,i:"D"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:x},b:"H",a:G,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v A 17 d k (x&#t;)",d:[5,9],g:1,f:{e:q,i:"k"},M:{c:{I:.O,u:3},a:p,b:"K"},s:{c:{y:x,u:0},b:"H",a:G,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v F 17 d k (x&#t;)",d:[5,9],g:1,f:{e:q,i:"k"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-x},b:"H",a:G,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v A 17 1K d m E (x&#t;)",d:[7,11],g:1,f:{e:q,i:"o"},s:{c:{I:.O,u:5,y:1w},b:"18",a:G,h:"A"},C:{c:{u:0,y:x},b:"18",a:G}},{j:"B v A 17 1K d m r (x&#t;)",d:[7,11],g:1,f:{e:q,i:"D"},s:{c:{I:.O,u:5,y:-1w},b:"18",a:G,h:"A"},C:{c:{u:0,y:-x},b:"18",a:G}},{j:"1c P m L (x&#t;)",d:1,g:[5,9],f:{e:q,i:"o"},s:{c:{u:-x},b:"w",a:G,h:"F"}},{j:"1c P m J (x&#t;)",d:1,g:[5,9],f:{e:q,i:"D"},s:{c:{u:x},b:"w",a:G,h:"F"}},{j:"1C 17 P k (x&#t;)",d:1,g:[5,9],f:{e:q,i:"k"},s:{c:{u:-x},b:"w",a:G,h:"F"}},{j:"B v 17 P m L (x&#t;)",d:1,g:[7,11],f:{e:q,i:"o"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-x},b:"H",a:G,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v 17 P m J (x&#t;)",d:1,g:[7,11],f:{e:q,i:"D"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:x},b:"H",a:G,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v 17 P m E (x&#t;)",d:1,g:[7,11],f:{e:q,i:"o"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:x},b:"H",a:G,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v 17 P m r (x&#t;)",d:1,g:[7,11],f:{e:q,i:"D"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:-x},b:"H",a:G,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v A 17 P k (x&#t;)",d:1,g:[7,11],f:{e:q,i:"k"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:x},b:"H",a:G,h:"A"},C:{c:{e:X},b:"K",a:p}},{j:"B v F 17 P k (x&#t;)",d:1,g:[7,11],f:{e:q,i:"k"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-x},b:"H",a:G,h:"F"},C:{c:{e:X},b:"K",a:p}},{j:"B v F 17 1K P m E (x&#t;)",d:1,g:[7,11],f:{e:q,i:"o"},s:{c:{I:.O,u:1w,y:-5},b:"18",a:G,h:"F"},C:{c:{u:x,y:0},b:"18",a:G}},{j:"B v F 17 1K P m r (x&#t;)",d:1,g:[7,11],f:{e:q,i:"D"},s:{c:{I:.O,u:-1w,y:-5},b:"18",a:G,h:"F"},C:{c:{u:-x,y:0},b:"18",a:G}},{j:"1b 1t m E (l&#t;, T U)",d:1,g:1,f:{e:q,i:"o",U:"T"},s:{c:{y:l},b:"w",a:1a,h:"A"}},{j:"1b 1t m r (l&#t;, T U)",d:1,g:1,f:{e:q,i:"o",U:"T"},s:{c:{y:-l},b:"w",a:1a,h:"A"}},{j:"1b 1t m L (l&#t;, T U)",d:1,g:1,f:{e:q,i:"o",U:"T"},s:{c:{u:-l},b:"w",a:1a,h:"F"}},{j:"1b 1t m J (l&#t;, T U)",d:1,g:1,f:{e:q,i:"o",U:"T"},s:{c:{u:l},b:"w",a:1a,h:"F"}},{j:"B v S 1n m E (l&#t;, T U)",d:[2,4],g:[4,7],f:{e:q,i:"o",U:"T"},M:{c:{I:.O},a:1l,b:"18"},s:{c:{y:l},b:"H",a:G,h:"A"},C:{a:1g,b:"H"}},{j:"B v S 1n m r (l&#t;, T U)",d:[2,4],g:[4,7],f:{e:q,i:"D",U:"T"},M:{c:{I:.O},a:1l,b:"18"},s:{c:{y:-l},b:"H",a:G,h:"A"},C:{a:1g,b:"H"}},{j:"B v S 1n m L (l&#t;, T U)",d:[2,4],g:[4,7],f:{e:q,i:"1j-o",U:"T"},M:{c:{I:.O},a:1l,b:"18"},s:{c:{u:-l},b:"H",a:G,h:"F"},C:{a:1g,b:"H"}},{j:"B v S 1n m J (l&#t;, T U)",d:[2,4],g:[4,7],f:{e:q,i:"1j-D",U:"T"},M:{c:{I:.O},a:1l,b:"18"},s:{c:{u:l},b:"H",a:G,h:"F"},C:{a:1g,b:"H"}},{j:"B v A S 1n k (l&#t;, T U)",d:[2,4],g:[4,7],f:{e:q,i:"k",U:"T"},M:{c:{I:.1i},a:1o,b:"18"},s:{c:{y:l},b:"H",a:1o,h:"A"},C:{a:1o,b:"H"}},{j:"B v F S 1n k (l&#t;, T U)",d:[2,4],g:[4,7],f:{e:q,i:"k",U:"T"},M:{c:{I:.1i},a:1o,b:"18"},s:{c:{u:l},b:"H",a:1o,h:"F"},C:{a:1o,b:"H"}},{j:"B v S d m E (l&#t;, T U)",d:[5,9],g:1,f:{e:1i,i:"o",U:"T"},M:{c:{I:.O,u:3},a:p,b:"K"},s:{c:{y:l,u:-3},b:"w",a:1p,h:"A"},C:{c:{e:X,u:0},b:"z",a:1q}},{j:"B v S d m r (l&#t;, T U)",d:[5,9],g:1,f:{e:1i,i:"D",U:"T"},M:{c:{I:.O,u:3},a:p,b:"K"},s:{c:{y:-l,u:-3},b:"w",a:1p,h:"A"},C:{c:{e:X,u:0},b:"z",a:1q}},{j:"B v S d m L (l&#t;, T U)",d:[5,9],g:1,f:{e:1i,i:"o",U:"T"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-l},b:"H",a:G,h:"F"},C:{c:{e:X},b:"z",a:1q}},{j:"B v S d m J (l&#t;, T U)",d:[5,9],g:1,f:{e:1i,i:"D",U:"T"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:l},b:"H",a:G,h:"F"},C:{c:{e:X},b:"z",a:1q}},{j:"B v A S d k (l&#t;, T U)",d:[5,9],g:1,f:{e:1i,i:"k",U:"T"},M:{c:{I:.O,u:3},a:p,b:"K"},s:{c:{y:l,u:-3},b:"w",a:1p,h:"A"},C:{c:{e:X,u:0},b:"z",a:1q}},{j:"B v F S d k (l&#t;, T U)",d:[5,9],g:1,f:{e:1i,i:"k",U:"T"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-l},b:"H",a:G,h:"F"},C:{c:{e:X},b:"z",a:1q}},{j:"B v S P m L (l&#t;, T U)",d:1,g:[7,11],f:{e:1i,i:"o",U:"T"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-l},b:"w",a:1p,h:"F"},C:{c:{e:X},b:"z",a:1q}},{j:"B v S P m J (l&#t;, T U)",d:1,g:[7,11],f:{e:1i,i:"D",U:"T"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:l},b:"w",a:1p,h:"F"},C:{c:{e:X},b:"z",a:1q}},{j:"B v S P m E (l&#t;, T U)",d:1,g:[7,11],f:{e:1i,i:"o",U:"T"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:l},b:"H",a:G,h:"A"},C:{c:{e:X},b:"z",a:1q}},{j:"B v S P m r (l&#t;, T U)",d:1,g:[7,11],f:{e:1i,i:"D",U:"T"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:-l},b:"H",a:G,h:"A"},C:{c:{e:X},b:"z",a:1q}},{j:"B v A S P k (l&#t;, T U)",d:1,g:[7,11],f:{e:1i,i:"k",U:"T"},M:{c:{I:.O},a:p,b:"K"},s:{c:{y:l},b:"H",a:G,h:"A"},C:{c:{e:X},b:"z",a:1q}},{j:"B v F S P k (l&#t;, T U)",d:1,g:[7,11],f:{e:1i,i:"k",U:"T"},M:{c:{I:.O},a:p,b:"K"},s:{c:{u:-l},b:"w",a:1p,h:"F"},C:{c:{e:X},b:"z",a:1q}}]}',62,132,'||||||||||duration|easing|transition|rows|delay|tile|cols|direction|sequence|name|random|180|to|type|forward|600|75|left|animation|176|rotateX|and|easeInOutQuart|90|rotateY|easeOutQuart|horizontal|Scaling|after|reverse|right|vertical|1e3|easeInOutBack|scale3d|top|easeOutBack|bottom|before|from|85|columns|mixed|tiles|spinning|large|depth|750|slide|200|sliding|Fading||||Sliding|fade|||turning|easeInOutQuint|55|1500|Spinning|Turning|100|easeInOutQuad|50|350|scale|65|col|30|450|500|cuboids|700|1200|400|rotate|35|cuboid|Carousel|Flying|45|800|Smooth|rotating|95|Horizontal|Vertical|Mirror|91|easeInQuart|1300|fading|mirror|540|drunk|out|scaling|Drunk|in|colums|150|2e3|directions|topright|bottomleft|topleft|sliging|linear|850|layerSliderTransitions|var|bottomright|87|t3d|diagonal||Crossfading|t2d'.split('|')))





/*jslint indent: 4, nomen: true, unparam: true, regexp: true, eqeq: true  */
/*global $: true, history: true, clearTimeout:true, confirm:true, noty:true, Modernizr:true, location:true, document:true, window:true, sprache:true, clearInterval:true, setInterval:true, setTimeout:true  */
var timer = null;

//set default options for all future tooltip instantiations
$.fn.tooltipster('setDefaults', {
	delay: 10,
	multiple: true,
    touchDevices: false,
	contentAsHTML : true,
	functionInit: function() {
        var element, cont;
    	element = $(this);
    	cont = element.attr('data-title');
    	if (typeof cont == 'undefined') {
            cont = element.attr('title');
        }
        return cont;
    }
});

$.initTooltipster = function() {
	$('.ui-icon[data-title],.resizeables, .rotatable').tooltipster();
};

$.setInfo = function (text, type, deleteolds) {
    'use strict';
    if (deleteolds) {
        $('#info').html('');
    }
    if (type) {
        text = '<div class="contenta ' + type + '">' + text + '</div>';
    } else {
        text = '<div class="contenta">' + text + '</div>';
    }
    $('#info').append(text + '<div class="ym-clearfix"></div>').slideDown('slow');
    clearTimeout(timer);
    timer = setTimeout(function () {
        $('#info').slideUp('slow', function () {
            $('#info').html('');
        });
    }, 3000);
};
$.fn.outerHTML = function () {
    'use strict';
    return $(this).clone().wrap('<div></div>').parent().html();
};
$.rgb2hex = function (rgb) {
    'use strict';
    rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
    function hex(x) {
        return ("0" + parseInt(x, 10).toString(16)).slice(-2);
    }
    if (rgb) {
        return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
    }
};
$.hexToRgb = function (hex) {
   var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
   return result ? 'rgb(' + parseInt(result[1], 16) + ', ' + parseInt(result[2], 16) + ', ' + parseInt(result[3], 16) + ')' : hex;
};
function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}
function number_format(n, d, dc, t) {
    'use strict';
    return $.number(n, d, dc, t);
}
function strpos(h, n, o) {
    'use strict';
    var i = h.indexOf(n, (o || 0));
    return i === -1 ? false : i;
}
$.bizRound = function (x) {
    'use strict';
    var result = Math.round(x * 100) / 100;
    return result;
};

function warenkorb_updateCount(anzahl, price) {

    'use strict';

    var s;
    var tht = '<span class="cart-count">' + anzahl + '</span>&nbsp;<span class="cart-details">';

    if (typeof sprache !== 'undefined') {
        s = sprache;
    }

    if (anzahl == 1) {
        tht += s.header_produkt;
    } else {
        tht += s.header_produkte;
    }

    if ($('span[data-id="shop_nettoPreise"]').attr('data-val') == 1) {
        if (price.ware_netto > 0) {
            tht += ' / ' + number_format(price.ware_netto, 2, ',', '.') + ' €';
        }
    } else {
        if (price.ware_brutto > 0) {
            tht += ' / ' + number_format(price.ware_brutto, 2, ',', '.') + ' €';
        }
    }

    $('#shop_warenkorb_text').html(tht + '</span>');

}

function warenkorb_updateRabatt(naechsteStaffel, artikelAnzahl) {
	if(naechsteStaffel && naechsteStaffel.rabatt_prozent){
		$('.wk_xArticle_amount').html( (naechsteStaffel.rabatt_ab_stueck - artikelAnzahl) );
		$('.wk_xArticle_percent').html(parseInt(naechsteStaffel.rabatt_prozent));
		$('.wk_xArticle').show();
	}else{
		$('.wk_xArticle').hide();
	}

}

function warenkorb_updateItems(wkItems, wkPreise) {
    'use strict';
    var itemCount = Object.size(wkItems), tht = '', i, bundelLst, i_intern, imgSize = 50, imgWidth = 45, img, lftdiv, rgtdiv;
    lftdiv = '<div class="ym-g66 ym-gl"><div class="ym-gbox-left">';
    rgtdiv = '<div class="ym-g33 ym-gr"><div class="ym-gbox-right">';
    $('#cartInner').html('');
    if ($('.body_warenkorb').length) {
        return false;
    }
    if (itemCount > 0) {
        if (itemCount > 6) {
            imgSize = 25;
            imgWidth = 23;
        }
        for (i = 0; i < itemCount; i = i + 1) {
            if (wkItems[i] != undefined && wkItems[i] != null) {
                tht += '<div class="ym-grid onewkitem" data-hs="' + wkItems[i]['hersteller_id'] + '">';
                if (wkItems[i].istArtikel == 1 || wkItems[i].istKomposition == 1) {
                    if (wkItems[i].bundelParent == null || wkItems[i].istKomposition == 1) {
                        if ((wkItems[i].istKomposition == 1 && wkItems[i].positionen[0]  && wkItems[i].positionen[0].motivAnzahl > 0) || (wkItems[i].positionen[0] && wkItems[i].positionen[0].akPId)) {
                            img = '<img src="' + $('span[data-id="imageScript"]').attr('data-val') + '?akPoId=' + wkItems[i].positionen[0].akPId + '&maxWidth=' + imgWidth + '&maxHeight=' + imgSize + '" alt=""/>';
                        } else if (wkItems[i].wShopArtikel && wkItems[i].wShopArtikel != '' && wkItems[i].positionen[0]) {
                            img = '<img src="' + $('span[data-id="imageScript"]').attr('data-val') + '?imgType=product&id=' + wkItems[i].positionen[0].vorschauId + '&sId=' + $('span[data-id="shopId"]').attr('data-val') + '&ssId=' + wkItems[i].sSaId + '&pSize=' + wkItems[i].groesse3 + '&pCol=' + wkItems[i].hersteller_farbcode3 + '&width=' + imgWidth + '&height=' + imgSize + '" alt=""/>';
                        } else {
                            if (wkItems[i].positionen[0]) {
                                img = '<img src="' + $('span[data-id="imageScript"]').attr('data-val') + '?imgType=product&id=' + wkItems[i].positionen[0].vorschauId + '&sId=' + $('span[data-id="shopId"]').attr('data-val') + '&pSize=' + wkItems[i].groesse2 + '&pCol=' + wkItems[i].hersteller_farbcode2 + '&width=' + imgWidth + '&height=' + imgSize + '" alt=""/>';
                            }
                        }
                        tht += '<div class="ym-g25 ym-gl"><div class="ym-gbox-left">';
                        tht +=  img;
                        tht += '</div></div>';
                        tht += '<div class="ym-g75 ym-gr"><div class="ym-gbox-right">';
                        tht +=  "<b>" + wkItems[i].bezeichnung + " " + wkItems[i].farbBezeichnung + "</b><br />";
                        if (wkItems[i].anzahl > 1) {
                            tht += wkItems[i].anzahl + ' x ';
                        }
                        if (sprache.groessenTyp) {
                            tht +=  sprache.groessenTyp.replace('[groessenTyp]', wkItems[i].groessenTyp_bezeichnung) + ' ';
                        }
                        tht +=  wkItems[i].groessenBezeichnung;
                        if (wkItems[i].istBundel == 1) {
                            bundelLst = [];
                            tht +=  '<div class="checkout_warenkorb_colInhalt">';
                            tht +=  'Inhalt:';
                            for (i_intern = 0; i_intern < itemCount; i_intern = i_intern + 1) {
                                if (wkItems[i_intern].bundelParent == wkItems[i].id) {
                                    bundelLst[bundelLst.length] = [wkItems[i_intern].anzahl, wkItems[i_intern].bezeichnung];
                                }
                            }
                            for (i_intern = 0; i_intern < bundelLst.length; i_intern = i_intern + 1) {
                                tht +=  '<div>' + bundelLst[i_intern][0] + ' x ' + bundelLst[i_intern][1] + '</div>';
                            }
                            tht +=  '</div>';
                        }
                        if (wkItems[i].bundelParent == null) {
                            if ($('span[data-id="shop_nettoPreise"]').attr('data-val') == 1) {
                                tht +=  '<span class="float-right">' +  $.bizRound(wkItems[i].gesamtpreis_netto).toFixed(2).toString().replace('.', ',') + ' €</span>';
                            } else {
                                tht +=  '<span class="float-right">' +  $.bizRound(wkItems[i].gesamtpreis_brutto).toFixed(2).toString().replace('.', ',') + ' €</span>';
                            }
                        }
                        tht += '</div></div>';
                    }
                } else if (wkItems[i].istPunch == 1) {
                    tht += "<div class='" + ((i + 1 < itemCount) ? "header_warenkorb_row" : "header_warenkorb_rowNoBorder") + "'>";
                    tht +=  "<img class='header_warenkorb_colPicture' src='" + $('span[data-id="imageScript"]').attr('data-val') + "?imgType=upload&id=" + wkItems[i].vorschauId + "&width=80&maxHeight=100' alt=''/>";
                    tht +=  "<div class='header_warenkorb_colBezeichnung'>" + sprache.seite_warenkorb_stickErstellung + "</div>";
                    tht +=  "<div class='header_warenkorb_colFarbe'>&nbsp;</div>";
                    tht +=  "<div class='header_warenkorb_colGroesse'>" + sprache.seite_checkout_warenkorb_groesse + ": " + wkItems[i].width_mm + "mm x " + wkItems[i].height_mm + "mm</div>";
                    tht +=  "<div class='header_warenkorb_colAnzahl'>" + sprache.seite_checkout_warenkorb_anzahl + ": 1</div>";
                    tht +=  "<div class='header_warenkorb_colGesamtpreis'>" +  number_format(wkItems[i].preis_netto, 2, ',', '.') + " €</div>";
                    tht +=  "<div class='clear'></div>";
                    tht += '</div>';
                }
                tht += '</div>';
            }
        }
        if ($('span[data-id="shop_nettoPreise"]').attr('data-val') == 1) {
            tht += '<div class="ym-grid sumbox">';
            tht += lftdiv + sprache.seite_checkout_warenkorb_nettoPreis + ":</div></div>";
            tht += rgtdiv +  $.bizRound(wkPreise.ware_netto).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
            tht += '</div>';
            if (wkPreise.rabatt_netto > 0) {
                tht += '<div class="ym-grid sumbox">';
                tht += lftdiv + sprache.seite_checkout_warenkorb_rabatt + ":</div></div>";
                tht += rgtdiv + '-' +  $.bizRound(wkPreise.rabatt_netto).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
                tht += '</div>';
            }
            tht += '<div class="ym-grid sumbox">';
            tht += lftdiv + sprache.seite_checkout_warenkorb_versandkosten + ":</div></div>";
            tht += rgtdiv +  $.bizRound(wkPreise.versand_netto).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
            tht += '</div>';
            tht += '<div class="ym-grid sumbox">';
            tht += lftdiv + sprache.seite_checkout_warenkorb_zzglMwst + ":</div></div>";
            tht += rgtdiv +  $.bizRound(wkPreise.gesamt_mwst).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
            tht += '</div>';
            if (wkPreise.guthaben > 0) {
                tht += '<div class="ym-grid sumbox">';
                tht += lftdiv + sprache.seite_checkout_warenkorb_guthaben + ":</div></div>";
                tht += rgtdiv + '-' +  $.bizRound(wkPreise.guthaben).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
                tht += '</div>';
            }
            if (wkPreise.budget > 0) {
                tht += '<div class="ym-grid sumbox">';
                tht += lftdiv + sprache.seite_checkout_warenkorb_budget + ":</div></div>";
                tht += rgtdiv + '-' +  $.bizRound(wkPreise.budget).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
                tht += '</div>';
            }
            if (wkPreise.gutschein_brutto > 0) {
                tht += '<div class="ym-grid sumbox">';
                tht += lftdiv + sprache.seite_checkout_warenkorb_gutschein + ":</div></div>";
                tht += rgtdiv + '-' +  $.bizRound(wkPreise.gutschein_brutto).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
                tht += '</div>';
            }
            if (wkPreise.bonuspunkte_wert > 0) {
                tht += '<div class="ym-grid sumbox">';
                tht += lftdiv + sprache.seite_checkout_warenkorb_bonuspunkte + " (-" +  $.bizRound(wkPreise.bonuspunkte).toFixed(2).toString().replace('.', ',') + sprache.seite_checkout_warenkorb_punkteShort + ":</div></div>";
                tht += rgtdiv + '-' +  $.bizRound(wkPreise.bonuspunkte_wert).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
                tht += '</div>';
            }
            tht += '<div class="ym-grid sumbox totalbox">';
            tht += lftdiv + sprache.seite_checkout_warenkorb_bruttoPreis + ":</div></div>";
            tht += rgtdiv +  $.bizRound(wkPreise.gesamt_bruttoAbzGutschein).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
            tht += '</div>';
        } else {
            tht += '<div class="ym-grid sumbox">';
            tht += lftdiv + sprache.seite_checkout_warenkorb_zwischensumme + ":</div></div>";
            tht += rgtdiv +  $.bizRound(wkPreise.ware_brutto).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
            tht += '</div>';
            if ($('span[data-id="warenkorb_preise_rabatt_brutto"]').attr('data-val') > 0) {
                tht += '<div class="ym-grid sumbox">';
                tht += lftdiv + sprache.seite_checkout_warenkorb_rabatt + ":</div></div>";
                tht += rgtdiv + '-' +  $.bizRound(wkPreise.rabatt_brutto).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
                tht += '</div>';
            }
            tht += '<div class="ym-grid sumbox">';
            tht += lftdiv + sprache.seite_checkout_warenkorb_versandkosten + ":</div></div>";
            tht += rgtdiv +  $.bizRound(wkPreise.versand_brutto).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
            tht += '</div>';
            tht += '<div class="ym-grid sumbox">';
            tht += lftdiv + sprache.seite_checkout_warenkorb_inklMwst + ":</div></div>";
            tht += rgtdiv +  $.bizRound(wkPreise.gesamt_mwst).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
            tht += '</div>';
            if (wkPreise.guthaben > 0) {
                tht += '<div class="ym-grid sumbox">';
                tht += lftdiv + sprache.seite_checkout_warenkorb_guthaben + ":</div></div>";
                tht += rgtdiv + '-' +  $.bizRound(wkPreise.guthaben).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
                tht += '</div>';
            }
            if (wkPreise.budget > 0) {
                tht += '<div class="ym-grid sumbox">';
                tht += lftdiv + sprache.seite_checkout_warenkorb_budget + ":</div></div>";
                tht += rgtdiv + '-' +  $.bizRound(wkPreise.budget).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
                tht += '</div>';
            }
            if (wkPreise.gutschein_brutto > 0) {
                tht += '<div class="ym-grid sumbox">';
                tht += lftdiv + sprache.seite_checkout_warenkorb_gutschein + ":</div></div>";
                tht += rgtdiv + '-' +  $.bizRound(wkPreise.gutschein_brutto).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
                tht += '</div>';
            }
            tht += '<div class="ym-grid sumbox totalbox">';
            tht += lftdiv + sprache.seite_checkout_warenkorb_bruttoPreis + ":</div></div>";
            tht += rgtdiv +  $.bizRound(wkPreise.gesamt_bruttoAbzGutschein).toFixed(2).toString().replace('.', ',') + ' €</div></div>';
            tht += '</div>';
        }
        tht += '<div class="ym-grid sumbox"><a class="button ebutton" href="' + $('span[data-id="activeLangPrefix"]').attr('data-val') + '/warenkorb">' + sprache.warenkorb_ansehen + '</a></div>';
        $('#cartInner').append(tht);
    } else {
    	if (typeof sprache != 'undefined') {
    		$('#cartInner').append(sprache.seite_warenkorb_noItems);
    	}
    }
}
Object.size = function (obj) {
    'use strict';
    var size = 0, key;
    for (key in obj) {
        if (obj.hasOwnProperty(key)) {
            size = size + 1;
        }
    }
    return size;
};
//check if exist and is visible
function isVisible(element) {
    'use strict';
    if (element.length > 0 && element.css('visibility') !== 'hidden' && element.css('display') !== 'none') {
        return true;
    } else {
        return false;
    }
}
////////////////////////////////////////////////////////////////////////////
// Funktionen Bestellformular
function checkRechnungsfirma(){
	if ($("#checkout_step1_firma").length) {
		var firmaValue = $("#checkout_step1_firma").val();
		var anredeValue = $("#checkout_step1_anrede").val();
		if(firmaValue != '' && anredeValue != 3) {
			$("#checkout_step1_anrede").val(3);
			$('#checkout_step1_firma').parent().find('.ym-required').remove();
			$('#checkout_step1_firma').parent().find('label').append(' <sup class="ym-required">*</sup>');
			$('#checkout_step1_firma').attr('required', true);
		} else if (firmaValue == '' && anredeValue == 3){
			$('#checkout_step1_firma').parent().find('.ym-required').remove();
			$('#checkout_step1_firma').parent().find('label').append(' <sup class="ym-required">*</sup>');
			$('#checkout_step1_firma').attr('required', true);
		} else {
			$('#checkout_step1_firma').parent().find('.ym-required').remove();
			$('#checkout_step1_firma').attr('required', false);
		}
		checkAndDoValidateUstid();
	}
};
function checkLiefererfirma(){
	if ($("#checkout_step1_lieferFirma").length) {
		var lieferAnrede = $("#checkout_step1_lieferAnrede").val();
		var lieferFirma = $("#checkout_step1_lieferFirma").val();
		if(lieferFirma != '' && lieferAnrede != 3) {
			$("#checkout_step1_lieferAnrede").val(3);
			$('#checkout_step1_lieferFirma').parent().find('.ym-required').remove();
			$('#checkout_step1_lieferFirma').parent().find('label').append(' <sup class="ym-required">*</sup>');
			$('#checkout_step1_lieferFirma').attr('required', true);
			checkAndDoValidateUstid();
		} else if (lieferFirma == '' && lieferAnrede == 3){
			$('#checkout_step1_lieferFirma').parent().find('.ym-required').remove();
			$('#checkout_step1_lieferFirma').parent().find('label').append(' <sup class="ym-required">*</sup>');
			$('#checkout_step1_lieferFirma').attr('required', true);
		} else {
			$('#checkout_step1_lieferFirma').parent().find('.ym-required').remove();
			$('#checkout_step1_lieferFirma').attr('required', false);
		}
		checkAndDoValidateUstid();
	}
};


//Beguenstigte Person
if ( $("#checkout_step1_eigenbedarf").length) {
	$("#id_lieferadresseGleichBPerson").hide();
	var cEigenbedarf = $("#checkout_step1_eigenbedarf").val();
	cEigenbedarf = parseInt(cEigenbedarf);
	if(cEigenbedarf == 0){
		$("#id_lieferadresseGleichBPerson").show();
		$('#checkout_step1_lieferadresseGleichBPerson').parent().find('.ym-required').remove();
		$('#checkout_step1_lieferadresseGleichBPerson').parent().find('label').append(' <sup class="ym-required">*</sup>');
		$('#checkout_step1_lieferadresseGleichBPerson').attr('required', true);
	} else {
		$('#checkout_step1_lieferadresseGleichBPerson').parent().find('.ym-required').remove();
		$('#checkout_step1_lieferadresseGleichBPerson').attr('required', false);
	}
	$("#checkout_step1_eigenbedarf").change(function(){
		var wert = $(this).val();
		wert = parseInt(wert);
		$("#checkout_step1_lieferadresseGleichBPerson").val('');
		$('#checkout_step1_lieferadresseGleichBPerson option').removeAttr('selected');


		if(wert == 0){
			$("#id_lieferadresseGleichBPerson").show();
			$('#checkout_step1_lieferadresseGleichBPerson').parent().find('.ym-required').remove();
			$('#checkout_step1_lieferadresseGleichBPerson').parent().find('label').append(' <sup class="ym-required">*</sup>');
			$('#checkout_step1_lieferadresseGleichBPerson').attr('required', true);
		} else {
			$("#id_lieferadresseGleichBPerson").hide();
			$('#checkout_step1_lieferadresseGleichBPerson').parent().find('.ym-required').remove();
			$('#checkout_step1_lieferadresseGleichBPerson').attr('required', false);
		}
	});
};

function checkAndDoValidateUstid(){
	var nettoPreise = 0;
	if ($("#sssNettoPreise").length) {
		if($("#sssNettoPreise").val()>=1){
			nettoPreise = 1;
		}
	}
	if(nettoPreise == 1){
		var tmpReq = false;
		var abweichendeLA = false;
		var checkUstIdPossible = true;
		var firmaValue = $("#checkout_step1_firma").val();
		var anredeValue = $("#checkout_step1_anrede").val();
		var anschriftGleich = false;
		if($('#checkout_step1_land').length > 0){
			var rechL = $('#checkout_step1_land OPTION:selected').val();
			var rechInnerGem = $('#checkout_step1_land OPTION:selected').attr('data-innerGem');
			var rechEU = $('#checkout_step1_land OPTION:selected').attr('data-istEu');
		}else if($('#hRechInfo').length > 0){
			anredeValue = 3;
			var rechL = $('#hRechInfo').val();
			var rechInnerGem = $('#hRechInfo').attr('data-innerGem');
			var rechEU = $('#hRechInfo').attr('data-istEu');
		}
		if($('#checkout_step1_lieferAbweichend_1').is(':checked')){
			abweichendeLA = true;
			var lieferL = $('#checkout_step1_lieferLand OPTION:selected').val();
			var lieferInnerGem = $('#checkout_step1_lieferLand OPTION:selected').attr('data-innerGem');
			var lieferEU = $('#checkout_step1_lieferLand OPTION:selected').attr('data-istEu');
		}else{
			var lieferL = rechL;
			var lieferInnerGem = rechInnerGem;
			var lieferEU = rechEU;
			anschriftGleich = true;
		}
		if(lieferL && lieferInnerGem && lieferEU && lieferL && lieferInnerGem && lieferEU){
			if( (rechL == 1 && lieferEU == 1 && lieferInnerGem == 1) ||
				(rechInnerGem == 1 && rechEU == 1 && lieferEU == 1 && lieferInnerGem == 1) ||
				(rechInnerGem == 0 && rechEU == 0 && lieferInnerGem == 1 && lieferEU == 1) ||
				(anredeValue == 3 && anschriftGleich == true && rechInnerGem == 1 && rechEU == 1)
			){
				tmpReq = true;
			}
		}
		if(tmpReq == true){
			$('#checkout_step1_ustId').parent().find('.ym-required').remove();
			$('#checkout_step1_ustId').attr('required', false);
			if(anredeValue == 3){
				$('#checkout_step1_ustId').parent().find('label').append(' <sup class="ym-required">*</sup>');
				$('#checkout_step1_ustId').attr('required', true);
				checkVatN('#checkout_step1_ustId');
			}
			/*
			if(rechInnerGem == 1 && rechEU == 1) {
				$('#checkout_step1_ustId').parent().find('.ym-required').remove();
				$('#checkout_step1_ustId').parent().find('label').append(' <sup class="ym-required">*</sup>');
				$('#checkout_step1_ustId').attr('required', true);
				checkVatN('#checkout_step1_ustId');
				//wenn es keine Firma ist dann kein pflichtfeld::
			} else {
				if($('#checkout_step1_ustId').length > 0){
					$('#checkout_step1_ustId').parent().find('.ym-required').remove();
					$('#checkout_step1_ustId').attr('required', false);
				}
			}
			*/
			if(abweichendeLA == true){
				if(lieferInnerGem == 1 && lieferEU == 1) {
					var lieferAnrede = $("#checkout_step1_lieferAnrede").val();
					var lieferFirma = $("#checkout_step1_lieferFirma").val();
					if(lieferAnrede == 3 || lieferFirma != ""){
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').parent().find('label').append(' <sup class="ym-required">*</sup>');
						$('#checkout_step1_lieferUstId').attr('required', true);
						checkVatN('#checkout_step1_lieferUstId');
						if($('#checkout_step1_ustId').length){
							$('#checkout_step1_ustId').parent().find('.ym-required').remove();
							$('#checkout_step1_ustId').attr('required', false);
						}
					} else {
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').attr('required', false);
					}
				} else {
					if($('#checkout_step1_lieferUstId').length){
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').attr('required', false);
					}
				}
				if(rechInnerGem == 0 && rechEU == 0){
					if($('#checkout_step1_ustId').length){
						$('#checkout_step1_ustId').parent().find('.ym-required').remove();
						$('#checkout_step1_ustId').attr('required', false);
					}
				}
			} else {
				if($('#checkout_step1_lieferUstId').length){
					$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
					$('#checkout_step1_lieferUstId').attr('required', false);
				}
			}
		}else{
			if(rechInnerGem == 1 && rechEU == 1) {
				$('#checkout_step1_ustId').parent().find('.ym-required').remove();
				$('#checkout_step1_ustId').parent().find('label').append(' <sup class="ym-required">*</sup>');
				$('#checkout_step1_ustId').attr('required', true);
				checkVatN('#checkout_step1_ustId');
			} else {
				if($('#checkout_step1_ustId').length){
					$('#checkout_step1_ustId').parent().find('.ym-required').remove();
					$('#checkout_step1_ustId').attr('required', false);
				}
			}
			// USt.-Id der Lieferanschrift wenn abweichend
			if(abweichendeLA == true){
				if(lieferInnerGem == 1 && lieferEU == 1) {
					var lieferAnrede = $("#checkout_step1_lieferAnrede").val();
					var lieferFirma = $("#checkout_step1_lieferFirma").val();
					if(lieferAnrede == 3 || lieferFirma != ""){
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').parent().find('label').append(' <sup class="ym-required">*</sup>');
						$('#checkout_step1_lieferUstId').attr('required', true);
						checkVatN('#checkout_step1_lieferUstId');
						if($('#checkout_step1_ustId').length){
							$('#checkout_step1_ustId').parent().find('.ym-required').remove();
							$('#checkout_step1_ustId').attr('required', false);
						}
					} else {
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').attr('required', false);
					}
				} else {
					if($('#checkout_step1_lieferUstId').length){
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').attr('required', false);
					}
				}
				if(rechInnerGem == 0 && rechEU == 0){
					if($('#checkout_step1_ustId').length){
						$('#checkout_step1_ustId').parent().find('.ym-required').remove();
						$('#checkout_step1_ustId').attr('required', false);
					}
				}
			} else {
				if($('#checkout_step1_lieferUstId').length){
					$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
					$('#checkout_step1_lieferUstId').attr('required', false);
				}
			}
		}
	} else {
		var tmpReq = false;
		var anschriftGleich = false;
		var firmaValue = $("#checkout_step1_firma").val();
		var anredeValue = $("#checkout_step1_anrede").val();
		if($('#checkout_step1_land').length > 0){
			var rechL = $('#checkout_step1_land OPTION:selected').val();
			var rechInnerGem = $('#checkout_step1_land OPTION:selected').attr('data-innerGem');
			var rechEU = $('#checkout_step1_land OPTION:selected').attr('data-istEu');
		}else if($('#hRechInfo').length > 0){
			anredeValue = 3;
			var rechL = $('#hRechInfo').val();
			var rechInnerGem = $('#hRechInfo').attr('data-innerGem');
			var rechEU = $('#hRechInfo').attr('data-istEu');
		}
		if($('#checkout_step1_lieferAbweichend_1').is(':checked')){
			var lieferL = $('#checkout_step1_lieferLand OPTION:selected').val();
			var lieferInnerGem = $('#checkout_step1_lieferLand OPTION:selected').attr('data-innerGem');
			var lieferEU = $('#checkout_step1_lieferLand OPTION:selected').attr('data-istEu');
		}else{
			var lieferL = rechL;
			var lieferInnerGem = rechInnerGem;
			var lieferEU = rechEU;
			anschriftGleich = true;
		}
		/*
		if(lieferL && lieferInnerGem && lieferEU && lieferL && lieferInnerGem && lieferEU){
			if((firmaValue != '' && anschriftGleich == true && rechInnerGem == 1 && rechEU == 1)
				|| (anredeValue == 3 && anschriftGleich == true && rechInnerGem == 1 && rechEU == 1)
			){
				tmpReq = true;
			}
		}
		*/
		if(lieferL && lieferInnerGem && lieferEU && lieferL && lieferInnerGem && lieferEU){
			if( (rechL == 1 && lieferEU == 1 && lieferInnerGem == 1) ||
				(rechInnerGem == 1 && rechEU == 1 && lieferEU == 1 && lieferInnerGem == 1) ||
				(rechInnerGem == 0 && rechEU == 0 && lieferInnerGem == 1 && lieferEU == 1)  ||
				(anredeValue == 3 && anschriftGleich == true && rechInnerGem == 1 && rechEU == 1)
			){
				tmpReq = true;
			}
		}
		if(tmpReq == true){
			$('#checkout_step1_ustId').parent().find('.ym-required').remove();
			$('#checkout_step1_ustId').attr('required', false);
			if(anredeValue == 3){
				$('#checkout_step1_ustId').parent().find('label').append(' <sup class="ym-required">*</sup>');
				$('#checkout_step1_ustId').attr('required', true);
				checkVatN('#checkout_step1_ustId');
			}
			if(anschriftGleich == false){
				if(lieferInnerGem == 1 && lieferEU == 1) {
					var lieferAnrede = $("#checkout_step1_lieferAnrede").val();
					var lieferFirma = $("#checkout_step1_lieferFirma").val();
					if(lieferAnrede == 3 || lieferFirma != ""){
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').parent().find('label').append(' <sup class="ym-required">*</sup>');
						$('#checkout_step1_lieferUstId').attr('required', true);
						checkVatN('#checkout_step1_lieferUstId');
						if($('#checkout_step1_ustId').length){
							$('#checkout_step1_ustId').parent().find('.ym-required').remove();
							$('#checkout_step1_ustId').attr('required', false);
						}
					} else {
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').attr('required', false);
					}
				} else {
					if($('#checkout_step1_lieferUstId').length){
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').attr('required', false);
					}
				}
			} else {
				if($('#checkout_step1_lieferUstId').length){
					$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
					$('#checkout_step1_lieferUstId').attr('required', false);
				}
			}
		}else{
			if(rechInnerGem == 1 && rechEU == 1) {
				$('#checkout_step1_ustId').parent().find('.ym-required').remove();
				$('#checkout_step1_ustId').parent().find('label').append(' <sup class="ym-required">*</sup>');
				$('#checkout_step1_ustId').attr('required', true);
				checkVatN('#checkout_step1_ustId');
			} else {
				if($('#checkout_step1_ustId').length){
					$('#checkout_step1_ustId').parent().find('.ym-required').remove();
					$('#checkout_step1_ustId').attr('required', false);
				}
			}
			// USt.-Id der Lieferanschrift wenn abweichend
			if(anschriftGleich == false){
				if(lieferInnerGem == 1 && lieferEU == 1) {
					var lieferAnrede = $("#checkout_step1_lieferAnrede").val();
					var lieferFirma = $("#checkout_step1_lieferFirma").val();
					if(lieferAnrede == 3 || lieferFirma != ""){
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').parent().find('label').append(' <sup class="ym-required">*</sup>');
						$('#checkout_step1_lieferUstId').attr('required', true);
						checkVatN('#checkout_step1_lieferUstId');
						if($('#checkout_step1_ustId').length){
							$('#checkout_step1_ustId').parent().find('.ym-required').remove();
							$('#checkout_step1_ustId').attr('required', false);
						}
					} else {
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').attr('required', false);
					}
				} else {
					if($('#checkout_step1_lieferUstId').length){
						$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
						$('#checkout_step1_lieferUstId').attr('required', false);
					}
				}
			} else {
				if($('#checkout_step1_lieferUstId').length){
					$('#checkout_step1_lieferUstId').parent().find('.ym-required').remove();
					$('#checkout_step1_lieferUstId').attr('required', false);
				}
			}
		}
	}
}

function checkVatN(inputField){
	wert = $(inputField).val();
	var newVATNumber = checkVATNumber(wert);
	if (newVATNumber) {
		wert = newVATNumber;
		$(inputField).val(wert);
	} else {
		$(inputField).val("");
	}
};

$(function () {
    'use strict';
    var initStageWidth, content;
    $('a.blank, a[href*=".pdf"]').attr('target', '_blank');
    content = $.trim($('#info').html()).length;
    if (content > 0) {
        content = $('#info').html();
        $('#info').html('');
        $.setInfo(content);
    }
    if (!Modernizr.input.placeholder) {
        $('[placeholder]').each(function () {
            if ($(this).val() === '') {
                $(this).val($(this).attr('placeholder'));
                $(this).addClass('placeholder');
            }
        });
        $(document).on('focus', '[placeholder]', function () {
            if ($(this).val() === $(this).attr('placeholder')) {
                $(this).val('').attr('value', '').removeClass('placeholder');
            }
        });
        $(document).on('blur', '[placeholder]', function () {
            if ($(this).val() === '' || $(this).val() === $(this).attr('placeholder')) {
                $(this).val($(this).attr('placeholder')).attr('value', $(this).attr('placeholder')).addClass('placeholder');
            }
        });
        $('[placeholder]').closest('form').submit(function () {
            $(this).find('[placeholder]').each(function () {
                if ($(this).val() === $(this).attr('placeholder')) {
                    $(this).attr('value', '');
                }
            });
        });
    }

    $(document).ajaxStop(function () {
        if ($('#motivDesignerForm').length) {
            //$('.rpcol').imagesLoaded().done(function () {
                //$.loadOverlay(true);
            //});
        }
    });
    $(function () {
        $('#login_register_real').realperson({
            length: 6,
            includeNumbers: true,
            regenerate: ''
        });
    });
    $(function () {
        $('#kennwortReset_real').realperson({
            length: 6,
            includeNumbers: true,
            regenerate: ''
        });
    });

    $("#shop_warenkorb_link").mouseover(function(e) {
    	if ($('.body_warenkorb').length) {
            return false;
        }
        $('#shop_warenkorb_content').stop().fadeIn('slow');
        return false;
    }).mouseout(function(e) {
        $('#shop_warenkorb_content').stop().fadeOut('slow');
    });
    /*$(document).on('click', '#shop_warenkorb_link', function (e) {
        if ($('.body_warenkorb').length) {
            return false;
        }
        if (!$(e.target).parents('#shop_warenkorb_content').length) {
            $('#shop_warenkorb_content').fadeIn('slow');
            return false;
        }
    });*/
    $(function () {
        var price = $.parseJSON($('span[data-id="headerWarenkorb_preis"]').attr('data-val'));
        warenkorb_updateCount($('span[data-id="warenkorb_itemsCount"]').attr('data-val'), price);
        warenkorb_updateItems($.parseJSON($('span[data-id="wkitems"]').attr('data-val')), price);
    });
    $(function () {
        var d = new Date(), disableCart = false, addToCart;
        function shopArtikel_bild(bildId, shopId, groessenId, farbId, bildWidth, bildHeight) {
            return $('span[data-id="imageScript"]').attr('data-val') + '?imgType=product&amp;id=' + bildId + '&amp;sId=' + shopId + '&amp;pSize=' + groessenId + '&amp;pCol=' + farbId + '&amp;width=' + bildWidth + '&amp;height=' + bildHeight + '&amp;' + d.getTime();
        }
        function shop_update_prodZoom() {
            $('.zoomContainer').remove();
            $('.detailsImage img').first().elevateZoom({
                zoomType: 'inner',
                cursor: 'crosshair',
                zoomWindowFadeIn: 500,
                zoomWindowFadeOut: 500,
                lensFadeIn: 500,
                lensFadeOut: 500,
                responsive: 1
            });
        }
        $(function () {
            var bundelStates = new Array($('.shop_prodDetails_mainWk').attr('data-bcount')), ia;
            for (ia = 0; ia < $('.shop_prodDetails_mainWk').attr('data-bcount'); ia = ia + 1) {
                bundelStates[ia] = (ia == 0) ? true : false;
            }
            function bundelStatus_update() {
                var i;
                for (i = 1; i <= bundelStates.length; i = i + 1) {
                    if (bundelStates[i - 1] == true) {
                        $('.bundelState_step_' + i).addClass('bundelState_aktiveBg');
                        $('.bundelState_stepFooter_' + (i - 1)).addClass('bundelState_aktiveFooter');
                        $('.bundelState_stepArrow_' + i).addClass('bundelState_aktiveBorder');
                    } else {
                        $('.bundelState_step_' + i).removeClass('bundelState_aktiveBg');
                        $('.bundelState_stepFooter_' + (i - 1)).removeClass('bundelState_aktiveFooter');
                        $('.bundelState_stepArrow_' + i).removeClass('bundelState_aktiveBorder');
                    }
                }
            }
            $('.shop_bundel_menu > LI > A').on('click', function () {
                var aktId;
                aktId = ($(this).children('.shop_bundel_number').html() - 1);
                bundelStates[aktId] = true;
                $(this).parents('.shop_bundel_frame').children('.shop_bundel_page').hide();
                $(this).parents('.shop_bundel_frame').children('.shop_bundel_page_' + aktId).show();
                $(this).parents('.shop_bundel_frame').find('.shop_bundel_menu').children('.aktive').removeClass('aktive');
                $(this).parent('LI').addClass('aktive').addClass('clicked');
                shop_update_prodZoom();
                bundelStatus_update();
                return false;
            });
            bundelStatus_update();
        });
        function shop_getGroesseFromParent(parentEl) {
            var groessenId;
            if ($(parentEl).find('.jsSizeSelect').length) {
                if ($(parentEl).find('.jsSizeSelect:first span.selected').length > 0) {
                    groessenId = $(parentEl).find('.jsSizeSelect:first span.selected').attr('data-id').split('_');
                } else {
                    groessenId = $(parentEl).find('.jsSizeSelect:first > li:first > span').attr('data-id').split('_');
                }
                return groessenId[1];
            }
        }
        function shop_getFarbeFromParent(parentEl) {
            var farbId;
            if ($(parentEl).find('.jsColorSelect').length) {
                if ($(parentEl).find('.jsColorSelect:first a.selected').length > 0) {
                    farbId = $(parentEl).find('.jsColorSelect:first a.selected').attr('data-id').split('_');
                } else {
                    farbId = $(parentEl).find('.jsColorSelect:first > li:first > a').attr('data-id').split('_');
                }
                return farbId[1];
            }
        }
        function shop_get_artDetails() {
            var groessenId, farbId, artDet, tmpObj, i;
            groessenId = shop_getGroesseFromParent($('.shop_prodDetails_mainDetails').find('.ym-grid:first'));
            farbId = shop_getFarbeFromParent($('.shop_prodDetails_mainDetails').find('.ym-grid:first'));
            artDet = {};
            tmpObj = $('.shop_prodDetails_preise').find('.shop_prodDetails_preise_' + farbId + '_' + groessenId);
            artDet.artNr = $(tmpObj).children('.artNr').html();
            artDet.bestGrp = $(tmpObj).children('.bestGrp').html();
            artDet.id = $(tmpObj).children('.id').html();
            artDet.preis = $(tmpObj).children('.preis').html();
            artDet.istBundel = false;
            if ($('#isBundle').length) {
                artDet.istBundel = true;
                artDet.bundel = {};
                for (i = 0; i < $('.shop_prodDetails_mainWk').attr('data-bcount'); i = i + 1) {
                    artDet.bundel[i] = {};
                    artDet.bundel[i].anzahl = $('#shop_bundel_pageBox_' + i).find('.shop_prodForm_bundelAnzahl').val();
                    artDet.bundel[i].groesse = $('#shop_bundel_pageBox_' + i).find('.shop_prodDetails_groessen').find('.selected').attr('data-groesse');
                    if ($('#shop_bundel_pageBox_' + i).find('.shop_prodDetails_farben').find('.selected').length > 0) {
                        artDet.bundel[i].farbe = $('#shop_bundel_pageBox_' + i).find('.shop_prodDetails_farben').find('.selected').attr('data-farbe');
                    } else {
                        artDet.bundel[i].farbe = $('#shop_bundel_pageBox_' + i).find('.shop_prodDetails_farben').find('LI:first').children("A").attr('data-farbe');
                    }
                    artDet.bundel[i].aId = $('#shop_bundel_pageBox_' + i).find('.shop_prodDetails_preise_' + artDet.bundel[i].farbe + '_' + artDet.bundel[i].groesse).children(".id").html();
                }
            }
            return artDet;
        }
        function shop_update_preis() {

            var groessenId, farbId, preisHtml;
            if ($('#isBundle').length) {
                return;
            }
            groessenId = shop_getGroesseFromParent($('.shop_prodDetails_mainDetails'));
            farbId = shop_getFarbeFromParent($('.shop_prodDetails_mainDetails'));
            preisHtml = $('.shop_prodDetails_preise').find('.shop_prodDetails_preise_' + farbId + '_' + groessenId).children('.preis').html();
            $('.pricediv span.price').html(preisHtml);
            $('.clone-designer-price span').html(preisHtml + ' €');
        }
        function shop_update_artId() {
            if (!$('#isBundle').length) {
                var farbId = shop_getFarbeFromParent($('.shop_prodDetails_mainDetails'));
                $('.shop_prodDetails_artId:first').children('span').html($('span[data-id="shopId"]').attr('data-val') + '.' + $('span[data-id="saId"]').attr('data-val') + '.' + farbId);
            }
        }
        $(document).on('click', '.pbutton', function () {
        //$('.pbutton').on('click', function () {
            $(this).closest('div').find('.hide').fadeToggle();
        });
        $(document).on('click', '.apbutton', function () {
        //$('.apbutton').on('click', function () {
            var dataid = $(this).attr('data-id');
            $(this).closest('.holdsinfo').find('.mottab').removeClass('active');
            $(this).addClass('active');
            $('.tabtextcontent.hidee').hide();
            $('div[data-id="' + dataid + '"]').show();
        });
        $(document).on('click', '.tlist h4', function () {
        //$('.tlist h4').on('click', function () {
            var div;
            div = $(this).next('.tanswer');
            if ($(div).size()) {
                if ($(div).is(':visible')) {
                    $(this).removeClass('bold').removeClass('changed');
                } else {
                    $(this).addClass('bold').addClass('changed');
                }
                $(div).slideToggle();
            }
        });
        $(document).on('click', '.jsPositionThumbs a', function () {
        //$('.jsPositionThumbs').find('a').on('click', function () {
            if ($(this).hasClass('selected')) {
                return false;
            }
            var idSplit = $(this).attr('id').split('_'), prodVariants, height, innerHeight, parentEl, oldImg, newImgSrc, newZoomImgSrc, newImg, bildId, farbId, groessenId, newZoomImgSrcPre;
            innerHeight = $('.detailsImage').height();
            height = $('.shop_prodDetails_images').height();
            $('.detailsImage').css('height', innerHeight);
            $('.shop_prodDetails_images').css('height', height);
            $(this).closest('.jsPositionThumbs').find('a').removeClass('selected');
            $(this).addClass('selected');
            /* Bundel Artikel Ja/Nein */
            if ($(this).parents('.shop_bundel_pageBox').length > 0) {
                /* JA */
                parentEl = $(this).parents('.shop_bundel_pageBox');
            } else {
                /* NEIN */
                parentEl = $(this).parents('.ym-grid');
                prodVariants = $('#prodVariants');
            }
            farbId = shop_getFarbeFromParent(parentEl);
            if (!farbId) {
                farbId = $(this).find('img:first()').attr('data-farbId');
            }
            groessenId = shop_getGroesseFromParent(parentEl);
            if (!groessenId) {
                groessenId = $(this).find('img:first()').attr('data-groessenId');
            }
            bildId = $(prodVariants).find('.shop_prodDetails_posFarben_' + farbId + '_' + idSplit[1] + ':first').html();
            if (!bildId) {
                bildId = $(this).find('img:first()').attr('data-bildId');
            }
            oldImg = $(parentEl).find('.detailsImage:first > img');
            newImgSrc = shopArtikel_bild(bildId, $('span[data-id="shopId"]').attr('data-val'), groessenId, farbId, 300, 335);
            newZoomImgSrc = shopArtikel_bild(bildId, $('span[data-id="shopId"]').attr('data-val'), groessenId, farbId, 718, 800);
            newImg = '<img class="flexible" src="' + newImgSrc  + '" data-zoom-image="' + newZoomImgSrc  + '" alt=""/>';
            newZoomImgSrcPre = $('<img src="' + newZoomImgSrc  + '"alt=""/>');
            $(newImg).hide();
            $(newZoomImgSrcPre).hide();
            oldImg.fadeOut(400, function () {
                oldImg.remove();
                $(parentEl).find('.detailsImage:first').hide().append(newImg).fadeIn(500, function () {
                    $.loadOverlay(true);
                    shop_update_prodZoom();
                });
            });
            return false;
        });
        shop_update_prodZoom();
        addToCart = function (that) {
            var i, tmpDetails, urlAddon = '', amount, bundelOffen, bundelStates = new Array($('.shop_prodDetails_mainWk').attr('data-bcount'));
            if ($('.shop_prodDetails_mainDetails').length) {
                amount = $('#shop_prodForm_anzahl').val();
                tmpDetails = shop_get_artDetails();
            } else {
                tmpDetails = [];
                tmpDetails.id = $(that).attr('data-artId');
                amount = 1;
            }
            if (tmpDetails.istBundel == true) {
                bundelOffen = '';
                for (i = 0; i < bundelStates.length; i = i + 1) {
                    if (bundelStates[i] != true) {
                        bundelOffen += (i + 1) + ', ';
                    }
                }
                if (bundelOffen != '') {
                    $.setInfo(sprache.designer_produktInWarenkorb_bundelError + ' ' + bundelOffen.substr(0, bundelOffen.length - 2), 'error');
                    disableCart = false;
                    return;
                }
                urlAddon += "&bundel=" + JSON.stringify(tmpDetails.bundel);
            }
            $.ajax({
                data: 'artId=' + tmpDetails.id + '&anz=' + amount + urlAddon,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax.php?action=set_shop_produkt2Warenkorb',
                success: function (msg) {
                    var tmpCount = 0, ii;
                    for (ii = 0; ii < Object.size(msg.shop_warenkorbItems); ii = ii + 1) {
                        if (msg.shop_warenkorbItems[ii].bundelParent == null) {
                            tmpCount += parseInt(msg.shop_warenkorbItems[ii].anzahl, 10);
                        }
                    }
                    warenkorb_updateCount(tmpCount, msg.warenkorb_preis);
                    warenkorb_updateItems(msg.shop_warenkorbItems, msg.warenkorb_preis);

                    $.setInfo(sprache.designer_produktInWarenkorb);
                    $('.item').css('zIndex', 'inherit');
                    $('.smodal').fadeOut();
                    $('.overlay').remove();
                    disableCart = false;
                },
                error: function (msg) {
                    $.setInfo(sprache.designer_produktInWarenkorb_error, 'error');
                    disableCart = false;
                }
            });
        };
        $(document).on('click', '.addToCart', function () {
        //$('.addToCart').on('click', function () {
            $(this).unbind('click', addToCart);
            if (disableCart === false) {
                disableCart = true;
                addToCart(this);
            }
        });
        $(document).on('click', '.jsSizeSelect span', function () {
        //$('.jsSizeSelect span').on('click', function () {
            var origUri, origColor, origSize, newUri, artGroesse;
            origSize = $('.jsSizeSelect span.selected').attr('data-artGroesse');
            origColor = $('.jsColorSelect li a.selected').attr('data-artFarbe');
            $(this).parents('.jsSizeSelect').find('span.selected').removeClass('selected');
            $(this).addClass('selected');
            $(this).closest('ul').find('input').attr('checked', false);
            $(this).find('input').attr('checked', true);
            shop_update_preis();
            artGroesse = $(this).attr('data-artGroesse');
            $('.jsColorSelect > li > a').attr('data-artGroesse', artGroesse);
            origUri = $('.gotodesigner').attr('href');
            if (origUri) {
                newUri = origUri.replace('_' + origColor + '/', '_' + origColor + '_' + artGroesse + '/');
                newUri = newUri.replace('_' + origColor + '_' + origSize + '/', '_' + origColor + '_' + artGroesse + '/');
                $('.gotodesigner').attr('href', newUri);
            }
            return false;
        });

        $(document).on('click', '.jsColorSelect > li > a', function () {
        //$('.jsColorSelect > li > a').on('click', function () {
            if ($(this).hasClass('selected')) {
                return false;
            }
            var ja, origUri, newUri, uri, origColor, sstr, artFarbe,  height, width, innerHeight, farbId, parentEl, groessenId, newZoomImgSrcPre;
            origColor = $('.jsColorSelect li a.selected').attr('data-artFarbe');
            $('.jsPositionThumbs li a').removeClass('selected');
            $('.jsPositionThumbs li a:first').addClass('selected');
            $(this).closest('ul').find('input[type="radio"]').attr('checked', false);
            $(this).closest('li').find('input[type="radio"]').attr('checked', true);
            artFarbe = $(this).attr('data-artFarbe');
            sstr = $(this).attr('data-str');
            sstr = sstr ? sstr + '/' : '';
            $('.jsSizeSelect span').attr('data-artFarbe', artFarbe);
            $('#productname').find('span').text(artFarbe);

            origUri = $('.smakeitbutton').attr('href');
            if (origUri) {
                newUri = origUri.replace('/' + origColor, '/' + artFarbe);
                newUri = newUri.replace('_' + origColor, '_' + artFarbe);
                $('.smakeitbutton').attr('href', newUri);
            }
            origUri = $('.gotodesigner').attr('href');
            if (origUri) {
                newUri = origUri.replace('/' + origColor, '/' + artFarbe);
                newUri = newUri.replace('_' + origColor, '_' + artFarbe);
                $('.gotodesigner').attr('href', newUri);
            }
            uri = window.location.pathname.replace('/' + origColor, '/' + artFarbe);
            ja = $('.jsPositionThumbs li a');
            innerHeight = $('.detailsImage').height();
            height = ja.height();
            width = ja.width();
            $('.detailsImage').css('height', innerHeight);
            ja.css('height', height).css('width', width);
            $(this).parents('.jsColorSelect').find('a.selected').removeClass('selected');
            $(this).addClass('selected');

            if ($('.body_motivDesigner').length && typeof (window.history.pushState) === 'function') {
                history.pushState({id: location.pathname}, document.title, location.pathname);
                history.pushState({id: uri}, '', uri);
            }
            farbId = $(this).attr('data-farbe');
            /* Bundel Artikel Ja/Nein */
            if ($(this).parents('.shop_bundel_pageBox').length > 0) {
                parentEl = $(this).parents('.shop_bundel_pageBox');
            } else {
                parentEl = $('.ym-grid');
            }
            groessenId = shop_getGroesseFromParent(parentEl);
            $('.jsPositionThumbs').children('li').each(function (index) {
                var bildId = $('.shop_prodDetails_posFarben_' + farbId + '_' + $(this).children('a').attr('data-position')).html(), oldImg, newImgSrc, newZoomImgSrc, newImg;
                if (index == 0) {
                    oldImg = $(this).parents('.shop_prodDetails_images').find('.detailsImage:first > IMG');
                    newImgSrc = shopArtikel_bild(bildId, $('span[data-id="shopId"]').attr('data-val'), groessenId, farbId, 300, 335);
                    newZoomImgSrc = shopArtikel_bild(bildId, $('span[data-id="shopId"]').attr('data-val'), groessenId, farbId, 718, 800);
                    newImg = '<img class="flexible" src="' + newImgSrc  + '" data-zoom-image="' + newZoomImgSrc  + '" alt=""/>';

                    newZoomImgSrcPre = $('<img src="' + newZoomImgSrc  + '"alt=""/>');
                    $(newImg).hide();
                    $(newZoomImgSrcPre).hide();
                    oldImg.fadeOut(400, function () {
                        oldImg.remove();
                        $(parentEl).find('.detailsImage:first').hide().append(newImg).fadeIn(500, function () {
                            shop_update_prodZoom();
                        });
                    });
                }
                $(this).children('a').html('<img src="' + shopArtikel_bild(bildId, $('span[data-id="shopId"]').attr('data-val'), groessenId, farbId, 45, 50) + '" alt=""/>');
            });
            shop_update_prodZoom();
            shop_update_artId();
            shop_update_preis();
            return false;
        });
    });
    $(function () {
        $(document).on('keyup', '.rowamount', function (event) {
            var c, init;
            c = $(this).val();
            init = $(this).attr('data-init');
            if (c && c % 1 === 0) {
                c = parseInt(c, 10);
                init = parseInt(init, 10);
                if (c > 0 && c !== init) {
                    $(this).parent().find('.delItem').fadeOut(55, function () {
                        $(this).parent().find('.refreshWk').fadeIn();
                    });
                } else {
                    $(this).parent().find('.refreshWk').fadeOut(55, function () {
                        $(this).parent().find('.delItem').fadeIn();
                    });
                }
            } else {
                $(this).parent().find('.refreshWk').fadeOut(55, function () {
                    $(this).parent().find('.delItem').fadeIn();
                });
            }
        });
        $(document).on('click', '.refreshWk', function () {
        //$('.refreshWk').on('click', function () {
            var val, init;
            $('.rowamount').each(function () {
                val = $(this).val();
                init = $(this).attr('data-init');
                if (init != val) {
                    $('#warenkorb_frame').submit();
                }
            });
            return false;
        });
        function wkZoom(el) {
            $('.zoomContainer').remove();
            el.elevateZoom({
                zoomType: 'inner',
                cursor: 'crosshair',
                zoomWindowFadeIn: 500,
                zoomWindowFadeOut: 500,
                lensFadeIn: 500,
                lensFadeOut: 500,
                responsive: 1
            });
        }
        $('.warenkorb_row .wk_aimgs').find('li').on('click', function () {
            var wk, tmpId, parentRow, tmpSId, tmpSSaId, tmpCol, innerHeight, oldImg, newImgSrc, newZoomImgSrc, newImg, newZoomImgSrcPre, imgScript;
            if ($(this).hasClass('selected')) {
                return false;
            }
            imgScript = $('span[data-id="imageScript"]').attr('data-val');
            tmpId = $(this).attr('data-tmpId');
            parentRow = $(this).parents('.warenkorb_row');
            $(parentRow).find('.wk_aimgs li').removeClass('selected');
            $(this).addClass('selected');
            wk = $(this).parents('.warenkorb_row');
            tmpSId = wk.children('.warenkorb_artSID').val();
            tmpSSaId = wk.children('.warenkorb_artSSaID').val();
            tmpCol = wk.children('.warenkorb_artCol').val();
            innerHeight = $(parentRow).find('.wk_aimg').height();
            $(parentRow).find('.wk_aimg').height(innerHeight);
            if ($(parentRow).hasClass('iskomp')) {
                if (!$(this).hasClass('nokomp')) {
                    newImgSrc = imgScript + "?akPoId=" + tmpId + "&sId=" + $('span[data-id="shopId"]').attr('data-val') + "&pSize=" + tmpSId + "&pCol=" + tmpCol + "&maxWidth=130&maxHeight=150";
                    newZoomImgSrc = imgScript + "?akPoId=" + tmpId + "&sId=" + $('span[data-id="shopId"]').attr('data-val') + "&pSize=" + tmpSId + "&pCol=" + tmpCol + "&maxWidth=450&maxHeight=500";
                } else {
                    newImgSrc = imgScript + "?imgType=product&id=" + tmpId + "&sId=" + $('span[data-id="shopId"]').attr('data-val') + ((tmpSSaId != '') ? '&ssId=' + tmpSSaId : '') + "&pSize=" + tmpSId + "&pCol=" + tmpCol + "&width=130&height=150";
                    newZoomImgSrc = imgScript + "?imgType=product&id=" + tmpId + "&sId=" + $('span[data-id="shopId"]').attr('data-val') + ((tmpSSaId != '') ? '&ssId=' + tmpSSaId : '') + "&pSize=" + tmpSId + "&pCol=" + tmpCol + "&width=450&height=500";
                }
            } else {
                newImgSrc = imgScript + "?imgType=product&id=" + tmpId + "&sId=" + $('span[data-id="shopId"]').attr('data-val') + ((tmpSSaId != '') ? '&ssId=' + tmpSSaId : '') + "&pSize=" + tmpSId + "&pCol=" + tmpCol + "&width=130&height=150";
                newZoomImgSrc = imgScript + "?imgType=product&id=" + tmpId + "&sId=" + $('span[data-id="shopId"]').attr('data-val') + ((tmpSSaId != '') ? '&ssId=' + tmpSSaId : '') + "&pSize=" + tmpSId + "&pCol=" + tmpCol + "&width=450&height=500";
            }
            oldImg = $(parentRow).find('.wk_aimg:first > img');
            newImg = '<img class="flexible" src="' + newImgSrc  + '" data-zoom-image="' + newZoomImgSrc  + '" alt=""/>';
            newZoomImgSrcPre = $('<img src="' + newZoomImgSrc  + '" alt=""/>');
            $(newImg).hide();
            $(newZoomImgSrcPre).hide();
            oldImg.fadeOut(400, function () {
                oldImg.remove();
                $(parentRow).find('.wk_aimg:first').hide().append(newImg).fadeIn(500, function () {
                    wkZoom($(parentRow).find('.wk_aimg').find('img'));
                });
            });
        });

        $('.warenkorb_rowAk .warenkorb_col_preis').each(function (index) {
        	$(this).children('span').attr('title', $(this).parents('.warenkorb_row').find('.warenkorb_col_preisInfo').html()).tooltipster({
        		content: function () {
        			return $($(this).prop('title'));
    			}
			});
        });

        wkZoom($('.wk_aimg').find('img'));
        $('.warenkorb_buttons_checkout').click(function () {
            $('#warenkorbAction').val('checkout');
            $('#warenkorb_frame').submit();
            return false;
        });
        $('#warenkorb_gutscheinBtn').click(function () {
            $('#warenkorbAction').val('update');
            return true;
        });
    });
    $(document).on('click', '#loginForm_pwVergessen', function () {
        $('#loginForm_link_pwVergessen').click();
        return false;
    });
    $(document).on('click', '#loginForm_kontoErstellen', function () {
        $('#loginForm_link_neuesKonto').click();
        return false;
    });
    $(document).on('click touchstart', '#info', function () {
        $('#info').slideUp('fast', function () {
            $('#info').html('');
        });
    });
    $(document).on('click touchstart', function (e) {
        if (!$(e.target).hasClass('cart') && $('#shop_warenkorb_content').length && isVisible($('#shop_warenkorb_content')) && !$(e.target).parents('#shop_warenkorb_link').length) {
            $('#shop_warenkorb_content').fadeOut('fast');
        }
    });
    $(document).on('click touchstart', '.jsOpensizes', function (e) {
        $('.smodal').fadeOut();
        $('.overlay').remove();
        $('.item').css('zIndex', 'inherit');
        $(this).closest('.item').css('zIndex', 1002);
        $('body').append('<div class="overlay"></div>');
        $('.overlay').fadeIn();
        $(this).parent().find('.smodal').fadeIn();
    });
    $(document).on('click touchstart', '.overlay', function (e) {
        $('.item').css('zIndex', 'inherit');
        $('.smodal').fadeOut();
        $('.overlay').remove();
    });
    $(document).on('click', 'a[href*=#]', function () {
        if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) {
            var $target = $(this.hash),
                targetOffset;
            $target = ($target.length && $target) || $('[name="' + this.hash.slice(1) + '"]');
            if (this.hash.slice(1) === 'top') {
                $('html,body').animate({
                    scrollTop: 0
                }, 300);
                return false;
            }
            if ($target.length) {
                targetOffset = $target.offset().top - 100;
                $('html,body').animate({
                    scrollTop: targetOffset
                }, 300);
            }
        }
        return false;
    });
    $.doStuff = function () {
        var paddingTop = parseInt($('.thelist').find('.fuseda').css('padding-top'), 10);
        $('.temsdelect').not('.done').each(function () {
            var outerHeight, height, margin;
            height = $(this).find('img').height();
            if (height > 0) {
                outerHeight = $(this).closest('.relative').height();
                margin = ((outerHeight - height) / 2) - paddingTop;
                $(this).find('img').css('marginTop', parseInt(margin, 10));
                $(this).addClass('done');

            }
        });
        $('.thelist').not('.adjusted').each(function () {
            var that = this;
            $(this).imagesLoaded().done(function (a) {
                var outerHeight = $(that).height();
                $(that).addClass('adjusted');
                $(that).find('.temselect').not('.done').each(function () {
                    var height, margin;
                    height = $(this).find('img').height();
                    if (height > 0) {
                        margin = ((outerHeight - height) / 2) - paddingTop;
                        $(this).find('img').css('marginTop', parseInt(margin, 10));
                        $(this).addClass('done');
                    }
                });
            });
        });
        $('#designinner').imagesLoaded().done(function (a) {
            if ($('#designinner').data('sly')) {
                $('#designinner').sly('reload');
            } else {
                $.buildVerticalScroller('#designinner');
            }
        });

        $.initTooltipster();

    };
    $(window).on('resize orientationchange', function (event) {

        if (!$(event.target).hasClass('ui-resizable')) {

            var height, bodyheight, initWidth, newImgFactor, initHeight, initLeft, initTop, stageWidth, update, relImage, drdiv;
            height = $(window).height();
            bodyheight = $('body').height();
            if (bodyheight - $('#mfooter').height() - $('footer').height() > height) {
                $('#totopa').show();
            } else {
                $('#totopa').hide();
            }
            if ($('#motivDesignerForm').length) {

                clearTimeout(0);
                relImage = $('.motivImage').find('.rpcol').first();
                newImgFactor = 520 / $('.motivImage').find('.flexible.rpcol').first().width();
                stageWidth = $('.motivImage').find('.stageHolder').width();
                update = false;
                //if (initStageWidth && initStageWidth != stageWidth) {

                    $('.ccHolder').remove();
                    drdiv = $('.motivImage').find('.drov');
                    drdiv.width(drdiv.attr('data-initWidth') / newImgFactor);
                    drdiv.height(drdiv.attr('data-initHeight') / newImgFactor);
                    drdiv.css('left', drdiv.attr('data-initLeft') / newImgFactor + relImage.position().left);
                    drdiv.css('top', drdiv.attr('data-initTop') / newImgFactor + relImage.position().top);
                    //flexible stageImage
                    $('.motivImage').find('.ovholder').each(function () {
                        initWidth = $(this).attr('data-initWidth');
                        initHeight = $(this).attr('data-initHeight');
                        initLeft = $(this).attr('data-initLeft');
                        initTop = $(this).attr('data-initTop');
                        $(this).width(initWidth / newImgFactor)
                        $(this).height(initHeight / newImgFactor);
                        $(this).css('left', initLeft / newImgFactor);
                        $(this).css('top', initTop / newImgFactor);
                        update = false;
                    });
                //}
                setTimeout('$.doneResizing()', 1000, update);
            }
            if ($('.temselect').length) {
                $.doStuff();
            }
        }
        //if ($('.personer').length) {

            setTimeout(function () {
                $.doneResizing();
            }, 1000);

        //}

    });
    $('input[type=search]').on('focus', function () {
        $(this).select();
    });
    $(function () {
        $('#ustId-message').hide();
        var sb, wkcontent;
        wkcontent = $('#shop_warenkorb_content').clone();
        if (typeof wkcontent.find('.wk_xArticle').html() !== 'undefined') {
            $('.float-right.wklink').prepend('<p class="cart-info"><span>' + wkcontent.find('.wk_xArticle').html() + '</span></p>');
        }
        $('#wkcontent').html(wkcontent.html());
        sb = $('#wkcontent').find('.sumbox');
        if (typeof sprache != 'undefined') {
        	sb.find('.ebutton').html(sprache.seite_checkout_warenkorb_edit);
        }
        sb.find('.nbutton').remove();
        $('#checkout_step1_anrede').change();
        $('#checkout_step1_lieferAnrede').change();
        $('#checkout_step1_lieferFields').find('.ym-required').closest('div').find(':input[required]').attr('required', false);
        $('#checkout_step1_lieferAbweichend_0, #checkout_step1_lieferAbweichend_1').change(function () {
            if ($('#checkout_step1_lieferAbweichend_1').is(':checked')) {
                $('#checkout_step1_lieferFields').find('.ym-required').closest('div').find(':input').attr('required', true);
                $('#checkout_step1_lieferFields, .lieferRequired').slideDown().prev('input');
            } else {
                $('#checkout_step1_lieferFields, .lieferRequired').slideUp();
                $('#checkout_step1_lieferFields').find('.ym-required').closest('div').find(':input[required]').attr('required', false);
            }
			checkAndDoValidateUstid();
        });
        $('#checkout_step1_lieferAbweichend_1').change();
		/*
        $("#checkout_step1_ustId").blur(function () {
            var wert = $(this).val(), checkPerAjax = false, field = $('#checkout_step1_ustId'), messageField = $('#ustId-message');
            if (wert != '') {
                //$(this).val('');
                field.parent().find('.ym-required').remove();
                field.parent().find('label').append(' <sup class="ym-required">*</sup>');
                field.hide();
                field.attr('required', true);
                messageField.empty();
                messageField.html('Ust.-Id wird überprüft');
                messageField.show();
                checkPerAjax = true;
            } else {
                field.parent().find('.ym-required').remove();
                field.attr('required', false);
                field.val('');
                field.show();
                messageField.hide();
            }
            if (checkPerAjax == true) {
                //Ajax pruefen
                $.ajax({
                    data: '&ustId=' + wert,
                    dataType: "json",
                    cache: false,
                    type: 'POST',
                    url: '/ajax/ajax.php?action=checkUstId',
                    success: function (msg) {
                        if (msg.status != undefined && msg.status == true) {
                            field.attr('required', false);
                            field.val(wert);
                            field.show();
                            messageField.hide();
                        } else {
                            if (msg.status == false) {
                                field.val('');
                                messageField.empty();
                                messageField.html('Ust.-Id <strong>' + wert + '</strong> ist laut Überprüfung falsch');
                                messageField.show();
                                field.show();
                                field.parent().find('.ym-required').remove();
                                field.attr('required', false);
                            }
                        }
                    },
                    error:  function (msg) {
                        field.val('');
                        messageField.empty();
                        messageField.html('Ust.-Id <strong>' + wert + '</strong> ist laut Überprüfung falsch');
                        messageField.show();
                        field.show();
                        field.parent().find('.ym-required').remove();
                        field.attr('required', false);
                    }
                });
            }
        });
		*/
        /*
        $( "#checkout_frame" ).submit(function( event ) {
	      	var hasError = false;
	      	$('#checkout_frame').find('input:text').each(function(i,e) {
	      		console.log($(e).val());
	            var userInput = $(e).val();
	            if(userInput == "null"){
	            	$(e).val("");
	            	hasError = true;
	            }
	        });
            if(hasError == true){
            	event.preventDefault();
            } else {
            	$('#checkout_frame').submit();
            }
        });
        */
        $('.checkout_buttons_zahlung, .checkout_buttons_pruefen, .checkout_buttons_bestellen').click(function (e) {
            if ($('#checkoutAgb').length && !$('#checkoutAgb').is(':checked')) {
                $('#checkoutAgb').closest('.ym-grid').find('.underlinea').addClass('error');
                return false;
            }
            $('#checkout_frame').submit();
            return false;
        });
    });
    $(function () {
        var kField = $('#checkout_step1_kennwort');
        $('input:radio[name="checkoutFields[accountAction]"]').change(function () {
            switch ($('input:radio[name="checkoutFields[accountAction]"]:checked').val()) {
            case '1':
                $('#checkout_detail_row_kennwort').slideDown();
                kField.addClass('validate[required]');
                kField.attr('required', true);
                break;
            default:
                $('#checkout_detail_row_kennwort').slideUp();
                kField.removeClass('validate[required]');
                kField.attr('required', false);
                break;
            }
        });
        $('input[name="checkoutFields[accountAction]"]').change();
    });
    
    
    $(function () {
        $('.checkout_details_adressbuch').click(function () {
            var adressNoty, adressTyp = $(this).attr('href'), thtHeadline, tht, headline;
            switch (adressTyp) {
            case '#liefer':
                headline = sprache.seite_checkout_step1_lieferadresse;
                break;
            default:
                headline = sprache.seite_checkout_step1_rechnungsadresse;
                break;
            }
            thtHeadline = '<div class="checkout_details_adressbuch_headline">' + headline + '</div>';
            tht = thtHeadline;
            adressNoty = noty({
                layout: 'center',
                text: tht,
                modal: true,
                killer: true,
                buttons: [{
                    text: sprache.seite_checkout_step1_adressbuch_btnOk,
                    onClick: function ($noty) {
                        if ($('input[name="checkout_adressbuch_adresse"]:checked').length > 0) {
                            var tmpIdx = $('input[name="checkout_adressbuch_adresse"]:checked').val();
                            if (adressTyp != '#liefer') {
                                $('#checkout_step1_anrede option[value="' + $('input[name="checkout_adressbuch_fieldsAnrede[' + tmpIdx + ']"]').val() + '"]').prop('selected', true).change();
                                $('#checkout_step1_vorname').val($('input[name="checkout_adressbuch_fieldsVorname[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_nachname').val($('input[name="checkout_adressbuch_fieldsNachname[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_firma').val($('input[name="checkout_adressbuch_fieldsFirma[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_strasse').val($('input[name="checkout_adressbuch_fieldsStrasse[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_adresszusatz').val($('input[name="checkout_adressbuch_fieldsAdressZusatz[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_plz').val($('input[name="checkout_adressbuch_fieldsPlz[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_ort').val($('input[name="checkout_adressbuch_fieldsOrt[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_telefon').val($('input[name="checkout_adressbuch_fieldsTelefon[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_land option[value="' + $('input[name="checkout_adressbuch_fieldsLand[' + tmpIdx + ']"]').val() + '"]').prop('selected', true).change();
                            } else {
                                $('#checkout_step1_lieferAnrede option[value="' + $('input[name="checkout_adressbuch_fieldsAnrede[' + tmpIdx + ']"]').val() + '"]').prop('selected', true).change();
                                $('#checkout_step1_lieferVorname').val($('input[name="checkout_adressbuch_fieldsVorname[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_lieferNachname').val($('input[name="checkout_adressbuch_fieldsNachname[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_lieferFirma').val($('input[name="checkout_adressbuch_fieldsFirma[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_lieferStrasse').val($('input[name="checkout_adressbuch_fieldsStrasse[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_lieferAdresszuastz').val($('input[name="checkout_adressbuch_fieldsAdressZusatz[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_lieferPlz').val($('input[name="checkout_adressbuch_fieldsPlz[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_lieferOrt').val($('input[name="checkout_adressbuch_fieldsOrt[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_lieferTelefon').val($('input[name="checkout_adressbuch_fieldsTelefon[' + tmpIdx + ']"]').val());
                                $('#checkout_step1_lieferLand option[value="' + $('input[name="checkout_adressbuch_fieldsLand[' + tmpIdx + ']"]').val() + '"]').prop('selected', true).change();
                                $('#checkout_step1_lieferAbweichend_1').attr('checked', true).change();
                            }
                            //$.uniform.update();
                            $noty.close();
                        }
                    }
                },
                    {
                        text: sprache.seite_checkout_step1_adressbuch_btnAbbrechen,
                        onClick: function ($noty) {
                            $noty.close();
                        }
                    }],
                callback: {
                    onShow: function () {
                        $.ajax({
                            data: 'subaction=getAdressbuch&adressTyp=' + adressTyp.substr(1),
                            dataType: 'json',
                            cache: false,
                            type: 'POST',
                            url: '/ajax/ajax.php?action=load_checkout',
                            success: function (msg) {
                                var tblObj, trObj, i, tmpTrObj, trHtml, tmpForm;
                                if (msg.status != undefined && msg.status == true) {
                                    if (msg.adressen != undefined && Object.size(msg.adressen) > 0) {
                                        tblObj = $('.checkout_details_adressbuch_dummy table').clone();
                                        trObj = tblObj.find('tr').clone();
                                        tblObj.html('<tr><td colspan="2"><hr/></td></tr>');
                                        for (i = 0; i < Object.size(msg.adressen); i = i + 1) {
                                            tmpTrObj = trObj.clone();
                                            tmpTrObj.find('.checkout_details_adressbuch_tbl_tdLeft').children('input').val(i);
                                            trHtml = tmpTrObj.outerHTML();
                                            tmpForm = '';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsAnrede[' + i + ']" value="' + msg.adressen[i].anrede + '"/>';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsVorname[' + i + ']" value="' + msg.adressen[i].vorname + '"/>';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsNachname[' + i + ']" value="' + msg.adressen[i].nachname + '"/>';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsFirma[' + i + ']" value="' + msg.adressen[i].firma + '"/>';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsStrasse[' + i + ']" value="' + msg.adressen[i].strasse + '"/>';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsAdressZusatz[' + i + ']" value="' + msg.adressen[i].adressZusatz + '"/>';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsPlz[' + i + ']" value="' + msg.adressen[i].plz + '"/>';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsOrt[' + i + ']" value="' + msg.adressen[i].ort + '"/>';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsLand[' + i + ']" value="' + msg.adressen[i].land + '"/>';
                                            tmpForm += '<input type="hidden" name="checkout_adressbuch_fieldsTelefon[' + i + ']" value="' + msg.adressen[i].telefon + '"/>';
                                            trHtml = trHtml.replace('[RIGHTTD]', msg.adressen[i].adressHtml + tmpForm);
                                            tblObj.append(trHtml + '<tr><td colspan="2"><hr/></td></tr>');
                                        }
                                        tblObj.find('.checkout_details_adressbuch_tbl_tdLeft:first').children('input').attr('checked', true);
                                        adressNoty.setText(thtHeadline + tblObj.outerHTML());
                                    } else {
                                        adressNoty.close();
                                        $.setInfo(sprache.seite_checkout_step1_adressbuch_noAdress);
                                    }
                                } else {
                                    adressNoty.close();
                                    $.setInfo(sprache.seite_checkout_step1_adressbuch_loadError);
                                }
                            },
                            error:  function (msg) {
                                adressNoty.close();
                                $.setInfo(sprache.seite_checkout_step1_adressbuch_loadError);
                            }
                        });
                    },
                    afterClose: function () {
                        adressNoty = null;
                    }
                }
            });
            return false;
        });
    });
    $(function () {
        var needsMovement = false, dmdx = 1, menuCreated = false, realActive, ajaxId, TMP, recoupLeft = 0, recoupTop = 0, usedFixpos = {}, pmo = {}, tmpPos, defaultMotives = [], ttTimer, imgs = [], disableCart = false, xhr = {}, xhrcc, xhruc, xhrp, xhd,  zoomFac = 3, zoomLeftDiff = 1, mm2pxFactor, mm2pxFactorScaled;
         $.doneResizing = function (update) {
            var oldOverflow = document.body.style.overflow, cWidth, currHeight, currWidth, prevUndefined;
            document.body.style.overflow = "hidden";
            currHeight = $(window).height();
            currWidth = $(window).width();
            document.body.style.overflow = oldOverflow;
            prevUndefined = (this.prevHeight === undefined || this.prevWidth === undefined);
            if (prevUndefined || this.prevHeight !== currHeight || this.prevWidth !== currWidth) {
                cWidth = this.prevWidth;
                this.prevHeight = currHeight;
                this.prevWidth = currWidth;
                if ($('.personer').length && $('.ttttt').length) {
                    $('.personer').submit();
                }
            }
            if (update) {
                initStageWidth = $('.motivImage').find('.stageHolder').width();
                $('.ccHolder').remove();
                $('.drov').remove();
                if (pmo) {
                    $.each(pmo, function (a) {
                        $.each(pmo[a], function (b) {
                            $.setMotive(a, b, true, true);
                        });
                    });
                }
            }
        };
        $.addToCart = function (form) {
            var rtext, minLabel, motiveCount = 0, r, showTextWarning = false, hasMotives = false, hadMotives = true, hasCollision = false, collisionHtml = '', motct = 0, posct = 0, prod = {}, amountChoosen, position, positions = {}, motiv = {}, produktDetails = {}, produktAnzahl = {}, overwrite = false;
            amountChoosen = false;
            produktDetails.stammartikelId = parseInt($('#stammartikelId').attr('data-id'), 10);
            produktDetails.farbId = parseInt($('.jsMsColor').find('.selected').attr('data-farbId'), 10);
            produktDetails.imageWidthPx = 520;
            produktDetails.imageHeightPx = 580;
            form.find('.vsma').find('input').each(function (i) {
                var sAId, artikelId, anzahl, items = {};
                anzahl = $(this).val();
                if (anzahl > 0) {
                    produktAnzahl[i] = items;
                    items.anzahl = anzahl;
                    if ($('#ssId').length) {
                        sAId = $('.shop_prodDetails_preise_' + produktDetails.farbId + '_' + $(this).attr('data-id')).attr('data-sAId');
                        items.sAId = sAId;
                    } else {
                        artikelId = $('.shop_prodDetails_preise_' + produktDetails.farbId + '_' + $(this).attr('data-id')).find('.id').text();
                        items.artikelId = artikelId;
                    }
                    if ((artikelId || sAId) && anzahl) {
                        amountChoosen = true;
                    }
                }
            });
            if (amountChoosen === false) {
                $.setInfo(sprache.motivDesigner_bitteweahlengroesse);
                $('.sizeSelect:visible').find('input:first').focus();
                disableCart = false;
                return false;
            }
            produktDetails.positionen = {};
            if (pmo) {
                hadMotives = true;
                $.each(pmo, function (a) {
                    motct = 1;
                    positions = {};
                    positions.motive = {};
                    position = a;
                    positions.positionId = parseInt(position, 10);
                    $.each(pmo[a], function (b) {
                        if (pmo[a][b].hasCollision === true) {
                            hasCollision = true;
                        }
                        motiv = {};
                        motiv.typ = {};
                        if (pmo[a][b].templateTyp == 'stick') {
                            motiv.typ.istStick = 1;
                            motiv.typ.orig = 1;
                        } else if (pmo[a][b].templateTyp == 'druck') {
                            motiv.typ.istDruck = 1;
                            motiv.typ.orig = 3;
                        } else if (pmo[a][b].templateTyp == 'upload') {
                            motiv.typ.istDruck = 1;
                            motiv.typ.istUpload = 1;
                            motiv.typ.orig = 4;
                        }
                        if (pmo[a][b].aoData && !pmo[a][b].text) {
                            $.each(pmo[a][b].aoData, function () {
                                var v = this.value;
                                if (/Mein Text/i.test(v) || /Pferdename/i.test(v) || /Dein Text/i.test(v) || /Freitext/i.test(v) ||  /Abteilung/i.test(v) || /Firmenname/i.test(v) || /Fachbereich/i.test(v) || /Mitarbeitername/i.test(v)) {
                                    showTextWarning = this.value;
                                }
                            });
                        } else if (pmo[a][b].aoData && pmo[a][b].text) {
                            $.each(pmo[a][b].text, function () {
                                var v = this.text;
                                if (/Mein Text/i.test(v) || /Pferdename/i.test(v) || /Dein Text/i.test(v) || /Freitext/i.test(v) ||  /Abteilung/i.test(v) || /Firmenname/i.test(v) || /Fachbereich/i.test(v) || /Mitarbeitername/i.test(v)) {
                                    showTextWarning = v;
                                }
                            });
                        }

                        positions.drTopPx = pmo[a][b].info.drTopPx;
                        positions.drLeftPx = pmo[a][b].info.drLeftPx;
                        positions.drWidthPx = pmo[a][b].info.drWidthPx;
                        positions.drHeightPx = pmo[a][b].info.drHeightPx;
                        motiv.typ.istTemplate = 1;
                        motiv.idx = pmo[a][b].zIndex;
                        motiv.details = {};
                        motiv.details.soapId = pmo[a][b].soapId;
                        motiv.details.aktLeft_px = pmo[a][b].aktLeft_px;
                        motiv.details.aktTop_px = pmo[a][b].aktTop_px;
                        motiv.details.left_mm =  pmo[a][b].left_mm;
                        motiv.details.top_mm =  pmo[a][b].top_mm;
                        motiv.details.drehungBrowser =  pmo[a][b].rotation;
                        motiv.details.aktWidth_px = pmo[a][b].aktWidth_px;
                        motiv.details.aktHeight_px =  pmo[a][b].aktHeight_px;
                        motiv.details.grundWidth_mm =  pmo[a][b].grundWidth_mm;
                        motiv.details.grundHeight_mm =  pmo[a][b].grundHeight_mm;
                        if(pmo[a][b].uniqueGruppe){
                            motiv.details.uniqueGruppe =  pmo[a][b].uniqueGruppe;
                        }
                        if(pmo[a][b].druck_id){
                            motiv.details.druck_id =  pmo[a][b].druck_id;
                        }
                        if (pmo[a][b].templateTyp == 'upload') {
                            motiv.details.image = pmo[a][b].img;
                            motiv.details.imageUuid = pmo[a][b].sid;
                        }
                        motiv.details.defMot = pmo[a][b].defMot;
                        motiv.details.defMotId = pmo[a][b].defMotId;
                        positions.motive[motct] = motiv;
                        motct = motct + 1;
                        motiveCount = motiveCount + 1;
                        hasMotives = true;
                    });
                    produktDetails.positionen[posct] = positions;
                    posct = posct + 1;
                });
            }
            if (showTextWarning) {
                if (sprache.motivdesigner_textwarning) {
                    rtext = sprache.motivdesigner_textwarning;
                } else {
                    rtext = 'Dieses Motiv mit -' + showTextWarning + '- wirklich in den Warenkorb legen?';
                }
                r = confirm(rtext);
                if (r === false) {
                    disableCart = false;
                    return false;
                }
            }
            if (!hasMotives && !hadMotives) {
                delete produktDetails.positionen;
            }
            if (hasCollision === true) {
                $.each(pmo, function (a) {
                    $.each(pmo[a], function (b) {
                        var posLabel = $('#pos_' + a).attr('data-label'), typLabel = pmo[a][b].label, templatelabel = pmo[a][b].templatelabel;
                        if (pmo[a][b].hasCollision === true) {
                            collisionHtml += '<br />' + typLabel + ' ' + templatelabel + ' ' + posLabel;
                        }
                    });
                });

                $.setInfo(sprache.motivDesigner_positioncheck + '<span class="smaller">' + collisionHtml + '</span>');

                return false;
            }
            if($('#stammartikelId').attr('data-minMotive') && $('#stammartikelId').attr('data-minMotive') > 0 && motiveCount < $('#stammartikelId').attr('data-minMotive')){
                minLabel = $('#stammartikelId').attr('data-minMotive') > 1 ? sprache.Motive : sprache.Motiv;
                $.setInfo(sprache.minMotiveError + ' ' + $('#stammartikelId').attr('data-minMotive') + ' ' + minLabel);
                return false;
            }
            prod.produktDetails = JSON.stringify(produktDetails);
            prod.produktAnzahl = JSON.stringify(produktAnzahl);
            prod.overwrite = overwrite;
            $.ajax({
                data: prod,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax.php?action=set_designer_produkt2Warenkorb',
                success: function (msg) {
                    if (msg !== null) {
                        var tmpCount = 0, i;
                        for (i = 0; i < Object.size(msg.shop_warenkorbItems); i = i + 1) {
                            tmpCount += parseInt(msg.shop_warenkorbItems[i].anzahl, 10);
                        }
                        warenkorb_updateCount(tmpCount, msg.warenkorb_preis);
                        warenkorb_updateItems(msg.shop_warenkorbItems, msg.warenkorb_preis);
                        warenkorb_updateRabatt(msg.naechsteRabattstaffel, msg.aktArtikelAnzahl);

                        $.setInfo(sprache.designer_produktInWarenkorb);
                        $('.vsma').find('input').val('');
                        disableCart = false;
                        return false;
                    }
                },
                error: function () {
                    $.setInfo(sprache.designer_produktInWarenkorb_error, 'error');
                    disableCart = false;
                }
            });
        };
        $.createAkObject = function () {
            var hasMotives = false, hadMotives = false, motct = 0, posct = 0, prod = {}, position, positions = {}, motiv = {}, produktDetails = {}, produktAnzahl = {}, overwrite = false;
            produktDetails.stammartikelId = parseInt($('#stammartikelId').attr('data-id'), 10);
            produktDetails.farbId = parseInt($('.jsMsColor').find('.selected').attr('data-farbId'), 10);
            produktDetails.imageWidthPx = 520;
            produktDetails.imageHeightPx = 580;
            produktDetails.positionen = {};
            if (pmo) {
                hadMotives = true;
                $.each(pmo, function (a) {
                    hadMotives = true;
                    motct = 1;
                    positions = {};
                    positions.motive = {};
                    position = a;
                    positions.positionId = parseInt(position, 10);
                    $.each(pmo[a], function (b) {
                        motiv = {};
                        motiv.typ = {};
                        motiv.details = {};

                        if (pmo[a][b].templateTyp == 'stick') {
                            motiv.typ.istStick = 1;
                            motiv.typ.orig = 1;
                        } else if (pmo[a][b].templateTyp == 'druck') {
                            motiv.typ.istDruck = 1;
                        	if(pmo[a][b].druck_id){
                                motiv.details.druck_id = pmo[a][b].druck_id;
                                motiv.typ.orig = 2;
                        	}else{
                                motiv.typ.orig = 3;
                        	}
                        } else if (pmo[a][b].templateTyp == 'upload') {
                            motiv.typ.istUpload = 1;
                            motiv.typ.orig = 4;
                        }
                        positions.drTopPx = pmo[a][b].info.drTopPx;
                        positions.drLeftPx = pmo[a][b].info.drLeftPx;
                        positions.drWidthPx = pmo[a][b].info.drWidthPx;
                        positions.drHeightPx = pmo[a][b].info.drHeightPx;
                        motiv.typ.istTemplate = 1;
                        motiv.idx = pmo[a][b].zIndex;
                        motiv.details.soapId = pmo[a][b].soapId;
                        motiv.details.aktLeft_px = pmo[a][b].aktLeft_px;
                        motiv.details.aktTop_px = pmo[a][b].aktTop_px;
                        motiv.details.left_mm =  pmo[a][b].left_mm;
                        motiv.details.top_mm =  pmo[a][b].top_mm;
                        motiv.details.rotation =  pmo[a][b].rotation;
                        motiv.details.drehungBrowser =  pmo[a][b].rotation;
                        motiv.details.aktWidth_px = pmo[a][b].aktWidth_px;
                        motiv.details.aktHeight_px =  pmo[a][b].aktHeight_px;
                        motiv.details.grundWidth_mm =  pmo[a][b].grundWidth_mm;
                        motiv.details.grundHeight_mm =  pmo[a][b].grundHeight_mm;
                        motiv.details.defMot = pmo[a][b].defMot;
                        motiv.details.defMotId = pmo[a][b].defMotId;
                        if (pmo[a][b].templateTyp == 'upload') {
                            motiv.details.image = pmo[a][b].img;
                            motiv.details.imageUuid = pmo[a][b].sid;
                        }
                        if(pmo[a][b].uniqueGruppe){
                            motiv.details.uniqueGruppe =  pmo[a][b].uniqueGruppe;
                        }
                        positions.motive[motct] = motiv;
                        motct = motct + 1;
                        hasMotives = true;
                    });
                    produktDetails.positionen[posct] = positions;
                    posct = posct + 1;
                });
            }
            if (!hasMotives && !hadMotives) {
                delete produktDetails.positionen;
            }
            prod.produktDetails = JSON.stringify(produktDetails);
            prod.overwrite = overwrite;
            $('.vsma').find('input').each(function (i) {
                var sAId, artikelId, anzahl, items = {};
                anzahl = 1;
                if (i == 0) {
                    if ($('#ssId').length) {
                        sAId = $('.shop_prodDetails_preise_' + produktDetails.farbId + '_' + $(this).attr('data-id')).attr('data-sAId');
                        items.sAId = sAId;
                    } else {
                        artikelId = $('.shop_prodDetails_preise_' + produktDetails.farbId + '_' + $(this).attr('data-id')).find('.id:first').html();
                        items.artikelId = artikelId;
                    }
                    items.anzahl = anzahl;
                    produktAnzahl[i] = items;
                }
            });
            prod.produktAnzahl = JSON.stringify(produktAnzahl);
            return prod;
        };
        $('.addToListDsCart').on('click', function (e) {
            e.preventDefault();
            if($(this).data('disabled') && $(this).data('disabled') == 'disabled'){return false;}
            if (disableCart === false) {
                $.addListToCart($(this).closest('.listItem'));
                return false;
            }
        });
        $(document).on('click', '.addToDsCart', function (e) {
        //$('.addToDsCart').on('click', function (e) {
            e.preventDefault();
            $(this).unbind('click', $.addToCart);
            if (disableCart === false) {
                $.addToCart($(this).closest('div'));
                return false;
            }
        });
        $.appendLoadimg = function (active) {
            var loadimg;
            loadimg = $('.loadimg');
            loadimg.hide();
            if (!loadimg.length) {
                loadimg = $('<span />');
                loadimg.addClass('loadimg');
                $('body').append(loadimg);
            }
            loadimg
                .css('position', 'absolute')
                .css('zIndex', 20000)
                .css('left', active.width() / 2 - loadimg.width() / 2)
                .css('top', active.height() / 2 - loadimg.height() / 2);
            active.closest('div').append(loadimg);
            loadimg.show();
        };
        $.loadOverlay = function (remove, ajaxId) {
            var div, div2, div3, loadimg;
            loadimg = $('.loadimg');
            if (!loadimg.length) {
                loadimg = $('<span />');
                loadimg.addClass('loadimg');
                $('body').append(loadimg);
            }
            if (remove === true) {
                loadimg.stop();
                $('.overlayload').hide().remove();
                $('.loadimg').hide().remove();
                return false;
            }
            if (ajaxId && $('.motivImage').find('.ovholder[data-auid="' + ajaxId + '"]').length) {
                $.appendLoadimg($('.motivImage').find('.ovholder[data-auid="' + ajaxId + '"]'));
            } else if ($('.motivImage').find('.ovholder.active').length) {
                $.appendLoadimg($('.motivImage').find('.ovholder.active'));
            } else {
                $.appendLoadimg($('.motivImage'));
            }
            div = $('.oholdload');
            div2 = $('.oholdload');
            div3 = $('.oholdload');
            if (!div.length) {
                div = $('<div />');
                div.addClass('overlayload oholdload')
                    .css('background', 'transparent')
                    .css('position', 'absolute')
                    .css('textAlign', 'center')
                    .css('top', '0')
                    .css('left', '0')
                    .css('width', $('.leftpane').width())
                    .css('height', $('.leftpane').height())
                    .css('zIndex', 19000)
                    .css('opacity', '0')
                    .hide()
                    .html('');
                $('.leftpane').prepend(div);
                div2 = $('<div />');
                div2.addClass('overlayload oholdload')
                    .css('background', 'transparent')
                    .css('position', 'absolute')
                    .css('textAlign', 'center')
                    .css('top', '0')
                    .css('left', '0')
                    .css('width', $('.wkadder').width())
                    .css('height', $('.wkadder').height())
                    .css('zIndex', 19000)
                    .css('opacity', '0')
                    .hide()
                    .html('');
                $('.wkadder').prepend(div2);
                div3 = $('<div />');
                div3.addClass('overlayload oholdload')
                    .css('background', 'transparent')
                    .css('position', 'absolute')
                    .css('textAlign', 'center')
                    .css('top', '0')
                    .css('left', '0')
                    .css('width', $('#mtabholder').width())
                    .css('height', $('#mtabholder').height())
                    .css('zIndex', 19000)
                    .css('opacity', '0')
                    .hide()
                    .html('');
                //$('#mtabholder').prepend(div3);
            }
            div.show();
            div2.show();
            //div3.show();
        };
        $.loadTemplateForm = function (template, dataId) {
            if (xhd) {
                xhd.abort();
            }
            var url, aoData = [];
            if (template) {
                aoData.push({'name': 'template', 'value': template});
                url = '/ajax/ajax_update_designer.php?action=changeTemplate&language=' + $('html').attr('lang');
                xhd = $.ajax({
                    dataType: 'json',
                    type: 'POST',
                    url: url,
                    data: aoData,
                    success: function (data) {
                        var datajson;
                        $('#motivElements').html(data.motivElements).show();
                        $('#motivColors').html(data.motivColors).show();
                        $('#templateTextElements').html(data.templateTextElements).show();
                        defaultMotives[template] = $.trim($('#meditor').html()).replace(/\r\n|\n|\r|\t/g, '');
                        datajson = $('.activeTemplate').find('span[data-id="' + dataId + '"]').attr('data-json');
                        if (datajson) {
                            $.updateDesignerElements(datajson);
                            $.initColorpicker();
                        }
                        $.checkNeededDivs();
                    }
                });
            }
        };
        $.loadTemplate = function (usebestmatch, first, setcookies, useoverlay) {
            if (xhd) {
                xhd.abort();
            }
            var template, url, aoData = [];
            template = $('.temselect.selected').first().attr('data-value');
            if (template) {
                aoData.push({'name': 'template', 'value': template});
                url = '/ajax/ajax_update_designer.php?action=changeTemplate&language=' + $('html').attr('lang');
                if (!first) {
                    xhd = $.ajax({
                        dataType: 'json',
                        type: 'POST',
                        url: url,
                        data: aoData,
                        success: function (data) {
                            var span;
                            $('#motivElements').html(data.motivElements);
                            $('#motivColors').html(data.motivColors).show();
                            $('#templateTextElements').html(data.templateTextElements);
                            defaultMotives[template] = $.trim($('#meditor').html()).replace(/\r\n|\n|\r|\t/g, '');
                            $('.activeTemplate').find('span[data-defaulttemplate="' + template + '"]').remove();
                            span = $('<span />')
                                .attr('data-defaulttemplate', template)
                                .attr('data-json', JSON.stringify(data));
                            $('.activeTemplate').append(span);
                            $.initColorpicker();
                            $.setMotive();
                            $.checkNeededDivs();
                        }
                    });
                }
            }
        };
        $.updatePriceDiv = function () {
            var vPriceManipulated = false, fixKostenDruck = false, motPrice, motivesUsed = false, usePHtml, tmpObj, groessenId, farbId, vPrice = 0, tHtml = '', veredelung = 'Veredelung', inklusive = 'inklusive', price = 0, sPrice, bprice, pHtml;

            farbId = parseInt($('.jsMsColor').find('.selected').attr('data-farbId'), 10);
            groessenId = $('.vsma').find('input').first().attr('data-id');

            if($('.fix_kosten_druck').length){
                fixKostenDruck = parseFloat($('.fix_kosten_druck').attr('data-price'));
            }

            tmpObj = $('.shop_prodDetails_preise').find('.shop_prodDetails_preise_' + farbId + '_' + groessenId);
            bprice = $(tmpObj).children('.preis').html();
            if ($('.basepriceDefaultMotives').first().attr('data-price')) {
                bprice = bprice.replace(',', '.') - $('.basepriceDefaultMotives').first().attr('data-price');
            } else {
                if(!bprice){
                    bprice = '0';
                }
                bprice = bprice.replace(',', '.');
            }
            if($('#contenthere').length && $('#contenthere').attr('data-ssId') && $('.basepriceShopProduct').attr('data-price')){
                bprice = $('.basepriceShopProduct').attr('data-price');
            }
            $('.baseprice').first().attr('data-price', bprice);
            bprice = parseFloat($('.baseprice').first().attr('data-price'));
            $('.moredetails').closest('.detailprice').find('.hidee').slideUp();
            $('.detailprice').html('');
            pHtml = '<ul class="btop hidee">';
            if (sprache.inklusive) {
                inklusive = sprache.inklusive;
            }
            $.each(pmo, function (a) {
                $.each(pmo[a], function (b) {
                    motivesUsed = true;
                    var deleter = '', posLabel = $('#pos_' + a).attr('data-label'), typLabel = pmo[a][b].label, templatelabel = pmo[a][b].templatelabel;
                    typLabel = sprache[typLabel] ? sprache[typLabel] : typLabel;
                    if ((pmo[a][b].price || pmo[a][b].defMot) && pmo[a][b].grundHeight_mm && pmo[a][b].grundWidth_mm) {
                        $('div[data-id="' + pmo[a][b].imageid + '"]').show();
                        if(pmo[a][b].druck_id && pmo[a][b].templateTyp == 'druck'){
                            sPrice = 0;
                            vPrice = 0;
                            vPriceManipulated = true;
                        } else if(fixKostenDruck !== false && pmo[a][b].templateTyp == 'druck'){
                            sPrice = 0;
                            vPrice = vPrice;
                            vPriceManipulated = true;
                        } else {
                            sPrice = pmo[a][b].price;
                            vPrice = vPrice + parseFloat(pmo[a][b].price);
                        }
                        price = price + parseFloat(sPrice);
                        usePHtml = true;
                        pHtml += '<li>';
                        if ((pmo[a][b].deleteable && pmo[a][b].deleteable == 1) || !pmo[a][b].deleteable) {
                            deleter = '<span data-title="löschen" data-m="' + pmo[a][b].imageid + '" class="delmotive icon-trash psa" data-pos="' + a + '" data-index="' + b + '" data-posTyp="' + pmo[a][b].aPT + '"></span>';
                        } else {
                            deleter = '';
                        }
                        if (pmo[a][b].template && pmo[a][b].template == 1346) {
                            templatelabel = 'Upload';
                            pmo[a][b].templatelabel = templatelabel;
                        }
                        if (pmo[a][b].text) {
                            if (pmo[a][b].templateTyp == 'druck') {
                                typLabel = 'Druck';
                            } else {
                                typLabel = 'Stick';
                            }
                            pmo[a][b].typLabel = typLabel;
                            templatelabel = 'Text ' + pmo[a][b].text[0].text;
                            pmo[a][b].templatelabel = templatelabel;
                        }
                        pHtml += typLabel + ' ' + templatelabel + deleter;
                        //pHtml += templatelabel + deleter;
                        if ($.bizRound(sPrice) !== 0) {
                            motPrice = $.bizRound(sPrice).toFixed(2).toString().replace('.', ',') + ' €';
                        } else {
                            motPrice = inklusive;
                        }
                        if(fixKostenDruck !== false && pmo[a][b].templateTyp == 'druck'){
                            if(fixKostenDruck != 0){
                                motPrice = '';
                            } else {
                                motPrice = inklusive;
                            }
                        }
                        pHtml += '<div class="ym-grid"><div class="ym-g68 ym-gl"><div class="ym-gbox-left">' + posLabel + ' <span class="nowrap">ca. ' + Math.round(pmo[a][b].grundWidth_mm) + 'x' + Math.round(pmo[a][b].grundHeight_mm) + 'mm</span></div></div><div class="ym-g32 ym-gr"><div class="ym-gbox-right" data-pid="' + pmo[a][b].sid + '">' + motPrice + '</div></div></div>';
                        pHtml += '</li>';
                        $('#md_' + pmo[a][b].imageid).hide();
                    } else {
                        if (pmo[a] && pmo[a][b] && pmo[a][b].price != 0) {
                            delete pmo[a][b];
                        }
                    }
                });
            });
            /*
            if (!motivesUsed && bprice > parseFloat($('.basepriceProduct').first().attr('data-price'))) {
                bprice = parseFloat($('.basepriceProduct').first().attr('data-price'));
            }
            */
            pHtml += '</ul>';
            if (sprache.Veredelung) {
                veredelung = sprache.Veredelung;
            }
            price = parseFloat(price) + bprice;
            if(fixKostenDruck !== false && vPriceManipulated == true){
                vPrice = vPrice + fixKostenDruck;
                price = price + fixKostenDruck;
            }

            if (usePHtml === true) {
                tHtml += '<div class="likeli"><div class="ym-grid btop">';
                    tHtml += '<div class="ym-g68 ym-gl">';
                        tHtml += '<div class="ym-gbox-left">' + veredelung + ' <span class="psa mainColor1 moredetails">&gt;&gt; Details</span></div>';
                    tHtml += '</div>';
                    tHtml += '<div class="ym-g32 ym-gr">';
                        if ($.bizRound(vPrice) !== 0) {
                            motPrice = $.bizRound(vPrice).toFixed(2).toString().replace('.', ',') + ' €';
                        } else {
                            motPrice = inklusive;
                        }
                        tHtml += '<div class="ym-gbox-right">' + motPrice + '</div>';
                    tHtml += '</div>';
                tHtml += '</div></div>';
            }
            $('.detailprice').html('<div class="likeli"><div class="ym-grid btops"><div class="ym-g68 ym-gl"><div class="ym-gbox-left">' + $('.artbasetit').html() + '</div></div><div class="ym-g32 ym-gr"><div class="ym-gbox-right">' + $.bizRound(bprice).toFixed(2).toString().replace('.', ',') + ' €</div></div></div></div>' + tHtml + pHtml);
            $('.price').removeClass('lpri').html($.bizRound(price).toFixed(2).toString().replace('.', ','));
            $('.clone-designer-price span').html($.bizRound(price).toFixed(2).toString().replace('.', ',') + ' €');
            $('.csym, .priceinfo').show();
            $('.detailprice').find('li').removeClass('selected');
            $('.delmotive[data-m="' + $('.motivImage').find('.ovholder.active').attr('data-id') + '"]').closest('li').addClass('selected');
        };
        $.buildDropArea = function (that, ndrgebietWidthPx, ndrgebietHeightPx, ndrgebietLeftPos, ndrgebietTopPos, relImage, factor, drgebietLeftPx, drgebietTopPx, res, debug) {
            var drgebietOv;
            if ($(that).find('.drov').length) {
                drgebietOv = $(that).find('.drov');
            } else {
                drgebietOv = $('<div />');
            }
            drgebietOv
                .addClass('absolute')
                .addClass('drov')
                .width(ndrgebietWidthPx)
                .height(ndrgebietHeightPx)
                .attr('data-initWidth', ndrgebietWidthPx * factor)
                .attr('data-initHeight', ndrgebietHeightPx * factor)
                .attr('data-initLeft', drgebietLeftPx)
                .attr('data-initTop', drgebietTopPx)
                .css('left', ndrgebietLeftPos)
                .css('top', ndrgebietTopPos);
            if (!$(that).find('.drov').length) {
                relImage.closest('.hasMotiv').find('.stageHolder').append(drgebietOv);
            }
        };
        $.addIconHelper = function (classes, css, attr, icon, motOv, abox) {
            var dim = 16, iconHelper, outerHelper, boxhelperbox, isInBox, hasNeigbhors = true;
            iconHelper = $('<div />');
            iconHelper
                .addClass('absolute outerhelper ' + classes + ' ui-state-active')
                .css('background', '#fff')
                .css('zIndex', 6000).hide();
            if (iconHelper.hasClass('dui-resizable-handle')) {
                iconHelper.width(9);
                iconHelper.height(9);
            } else {
                iconHelper.width(dim);
                iconHelper.height(dim);
            }
            if (css && $.type(css) === 'object') {
                $.each(css, function (a) {
                    iconHelper.css(a, css[a]);
                });
            } else if (css && $.type(css) === 'string') {
                iconHelper.removeClass('absolute');
                boxhelperbox = motOv.find('.' + css + 'helperbox');
                if (!$(boxhelperbox).length) {
                    boxhelperbox = $('<div />');
                    boxhelperbox
                        .addClass(css + 'helperbox absolute')
                        .height(dim)
                        .width('100%')
                        .css('textAlign', 'left');
                    switch (css) {
                    case 'bottom':
                        boxhelperbox.css('left', -18)
                            .css('bottom', -18);
                        break;
                    case 'top':
                        boxhelperbox.css('left', -18)
                            .css('top', -18);
                        break;
                    }
                    hasNeigbhors = false;
                }
                if (hasNeigbhors === true) {
                    iconHelper.css('marginLeft', 3);
                }
                isInBox = true;
                outerHelper = $('<div />');
                iconHelper
                    .css('display', 'inline-block').hide();
                outerHelper
                    .width(dim)
                    .height(dim);
                if (icon) {
                    outerHelper.addClass('ui-icon ui-icon-' + icon);
                }
                iconHelper.append(outerHelper);
                boxhelperbox.append(iconHelper);
                motOv.append(boxhelperbox);
            }
            if (attr) {
                $.each(attr, function (a) {
                    iconHelper.attr(a, attr[a]);
                });
            }
            if (!isInBox) {
                outerHelper = $('<div />');
                outerHelper
                    .width(dim)
                    .height(dim);
                if (icon) {
                    outerHelper.addClass('ui-icon ui-icon-' + icon);
                }
                iconHelper.append(outerHelper);
                motOv.append(iconHelper);
            }
        };
        $.doExistCheck = function () {
            var used = [];
            $.each(pmo, function (a) {
                $.each(pmo[a], function (b) {
                    used[pmo[a][b].imageid] = pmo[a][b].imageid;
                });
            });
            $('.motov').each(function () {
                var a;
                a = $(this).attr('data-id');
                if (!used[a]) {
                    $(this).remove();
                    $('.motov[data-id="' + a + '"]').remove();
                }
            });
        };
        $.findNextNumber = function (seq) {
            var i = 0, x;
            for (i; i < 100; i = i + 1) {
                x = i + 1;
                if (seq[i] != x) {
                    seq.splice(i, 0, x);
                    seq.length = 100;
                    return x;
                }
            }
        };
        $.findNextFixpos = function (acP, mm2pxFactor) {
            var dimgFactor, notPossible = [], notPossibleFix = {}, possibleFix = {}, possible, positions = [], iteration, set = false;
            if (pmo && pmo[acP]) {
                dimgFactor = 520 / $('.motivImage').find('.flexible.rpcol').width();
                $.each(pmo[acP], function (b) {
                    var aktMotWidthPx, aktMotLeftPx, aktMotHeightPx, aktMotTopPx, rotation = 0, rotWidth, rotHeight;
                    aktMotWidthPx = pmo[acP][b].grundWidth_mm / mm2pxFactor / dimgFactor;
                    aktMotLeftPx = pmo[acP][b].aktLeft_px / dimgFactor;
                    aktMotHeightPx = pmo[acP][b].grundHeight_mm / mm2pxFactor / dimgFactor;
                    aktMotTopPx = pmo[acP][b].aktTop_px  / dimgFactor;
                    rotation = pmo[acP][b].rotation;
                    if (rotation < 0 || rotation > 0) {
                        rotWidth = ((aktMotWidthPx * Math.abs(Math.cos(rotation * Math.PI / 180))) + (aktMotHeightPx * Math.abs(Math.sin(rotation * Math.PI / 180))));
                        rotHeight = ((aktMotWidthPx * Math.abs(Math.sin(rotation * Math.PI / 180))) + (aktMotHeightPx * Math.abs(Math.cos(rotation * Math.PI / 180))));
                        aktMotWidthPx = rotWidth;
                        aktMotHeightPx = rotHeight;
                    }
                    $('.motpos[value="' + acP + '"]').closest('li').find('.fixpos[data-fuerMotiv="1"]').each(function (i, a) {
                        var aktPosLeftPx, aktPosTopPx, x, y, l, r, b, t;
                        iteration = i + 1;
                        aktPosLeftPx = $(this).attr('data-leftPx') / dimgFactor;
                        aktPosTopPx = $(this).attr('data-topPx') / dimgFactor;
                        x = aktPosLeftPx;
                        y = aktPosTopPx;
                        l = aktMotLeftPx;
                        r = aktMotLeftPx + aktMotWidthPx;
                        b = aktMotTopPx + aktMotHeightPx;
                        t = aktMotTopPx;
                        if ((x >= l && x <= r) && (y >= t && y <= b)) {
                            notPossible.push(iteration);
                            notPossibleFix[iteration] =  $(this).attr('data-fixId');
                        } else {
                            possibleFix[iteration] =  $(this).attr('data-fixId');
                        }
                        positions.push(iteration);
                    });
                });
            }
            possible = 1;
            $.each(positions, function (i, a) {
                if(set === false && possible == 1 && $.inArray(a, notPossible) == -1){
                    possible = positions[i];
                    set = true;
                    return true;
                }
            });
            if (notPossibleFix[possible]) {
                if (usedFixpos && Object.size(usedFixpos) == 1 && usedFixpos[notPossibleFix[possible]]){
                    usedFixpos[notPossibleFix[possible]] = usedFixpos[notPossibleFix[possible]] + 1;
                } else {
                    usedFixpos[notPossibleFix[possible]] = 1;
                }
            }
            return possible;
        };

        $.checkQuality = function (ob) {
            var widthMM, heightMM, maxWidthMM, maxHeightMM;
            widthMM = ob.grundWidth_mm;
            heightMM = ob.grundHeight_mm;
            maxWidthMM = ob.maxPrintWidth;
            maxHeightMM = ob.maxPrintHeight;
        };
        $.process = function (changeFixPos, isText, uploadTrim, uploaduuid, relImage,
        		ooWidth, initWidthMM, templateTyp, mm2pxFactor, imgFactor, drgebietLeftPx,
        		drgebietTopPx, drgebietWidthPx, drgebietHeightPx, fixpos, motivp, motivi,
        		akt_fixposLeftPos, akt_fixposTopPos, fixposAlign, that, isReload, oldid, acP,
        		posIndex, template, aPT, zIndex, imageid, img, scaleable, rotatable, deleteable,
        		editable, draggable, resizableClass, draggableClass, rotatableClass, aktLeft_px,
        		aktTop_px, aktWidth_px, aktHeight_px, motOvHelper, helperWidth, aId, res, aoData,
        		renew, apiWidth, initHeightMM, apiHeight, initHeightPrint, uniqueGruppe, options) {
        	if(!options){
        		options = {};
        	}
            var fixMoved = false, fixOffset = 20, span, ppp = {}, rotWidth, rotHeight, centerX, centerY, ovid, rotation = 0, imgsrc, wsize, motivname, ccov, motOvImg, motOvLeft, motOvTop, motOvWidth, motOvHeight, motOv, fixposLeftPos, fixposTopPos, factor, ndrgebietWidthPx, ndrgebietHeightPx, ndrgebietLeftPos, ndrgebietTopPos, zeroLeft = 0, zeroTop = 0, relwidth;
            relwidth = relImage.width();
            factor = ooWidth / relwidth;
            motOvWidth = initWidthMM;
            if (templateTyp == 'stick') {
                motOvWidth = apiWidth / 10;
            }
            motOvWidth = motOvWidth / factor / mm2pxFactor;

            if (templateTyp == 'druck' && initHeightPrint && !motivi) {
                motOvHeight = initHeightPrint / factor / mm2pxFactor;
                motOvWidth = motOvHeight * imgFactor;
            } else {
                motOvHeight = motOvWidth / imgFactor;
            }
            zeroLeft = relImage.position().left + parseFloat(relImage.css('marginLeft'));
            zeroTop = relImage.position().top + parseFloat(relImage.css('marginTop'));
            ndrgebietLeftPos = zeroLeft + drgebietLeftPx / factor;
            ndrgebietTopPos = zeroTop + drgebietTopPx / factor;
            ndrgebietWidthPx = drgebietWidthPx / factor;
            ndrgebietHeightPx = drgebietHeightPx / factor;
            if (fixpos) {
                fixposAlign = fixpos.attr('data-ausrichtung');
                fixposLeftPos = fixpos.attr('data-leftPx') / factor;
                fixposTopPos = fixpos.attr('data-topPx') / factor;
                if (fixpos.attr('data-rotation')) {
                    rotation = fixpos.attr('data-rotation');
                }
                if (motivp && pmo[motivp][motivi].isClone === true) {
                    fixposLeftPos = fixposLeftPos + (20 / factor);
                    fixposTopPos = fixposTopPos + (20 / factor);
                } else {
                    //if (changeFixPos) {
                        if (pmo[acP] && usedFixpos[fixpos.attr('data-fixId')]) {
                            fixOffset = usedFixpos[fixpos.attr('data-fixId')] * fixOffset;
                            fixOffset =  fixOffset / factor;
                            fixposLeftPos = fixposLeftPos + fixOffset;
                            fixposTopPos = fixposTopPos + fixOffset;
                            fixMoved = fixpos.attr('data-fixId');
                        }
                    //}
                }
            } else {
                if (pmo[motivp][motivi] && pmo[motivp][motivi].fixPointAlign) {
                    akt_fixposLeftPos = pmo[motivp][motivi].fixPointLeft;
                    akt_fixposTopPos = pmo[motivp][motivi].fixPointTop;
                    fixposAlign = pmo[motivp][motivi].fixPointAlign;
                    fixposLeftPos = akt_fixposLeftPos / factor;
                    fixposTopPos = akt_fixposTopPos / factor;
                    if (motivp && motivi && pmo[motivp][motivi].isClone && pmo[motivp][motivi].isClone === true) {
                        fixposLeftPos = fixposLeftPos + (20 / factor);
                        fixposTopPos = fixposTopPos + (20 / factor);
                    }
                } else if (pmo[motivp][motivi]) {
                    fixposAlign = 'c';
                    if(!pmo[motivp][motivi].aktWidth_px) {
                        pmo[motivp][motivi].aktWidth_px = motOvWidth * factor;
                        pmo[motivp][motivi].aktHeight_px = motOvHeight * factor;
                    }
                    fixposLeftPos = pmo[motivp][motivi].aktLeft_px / factor  + pmo[motivp][motivi].aktWidth_px / 2 / factor;
                    fixposTopPos = pmo[motivp][motivi].aktTop_px / factor + pmo[motivp][motivi].aktHeight_px / 2 / factor;
                    if (motivp && pmo[motivp][motivi].isClone === true) {
                        fixposLeftPos = fixposLeftPos + (20 / factor);
                        fixposTopPos = fixposTopPos + (20 / factor);
                    }
                }
            }
            $.buildDropArea(that, ndrgebietWidthPx, ndrgebietHeightPx, ndrgebietLeftPos, ndrgebietTopPos, relImage, factor, drgebietLeftPx, drgebietTopPx, res);
            if (fixposAlign) {
                if (fixposAlign == 'bc') {
                    motOvLeft = fixposLeftPos - (motOvWidth / 2);
                    motOvTop = fixposTopPos - motOvHeight;
                } else if (fixposAlign == 'bl') {
                    motOvLeft = fixposLeftPos;
                    motOvTop = fixposTopPos - motOvHeight;
                } else if (fixposAlign == 'br') {
                    motOvLeft = fixposLeftPos - motOvWidth;
                    motOvTop = fixposTopPos - motOvHeight;
                } else if (fixposAlign == 'c') {
                    motOvLeft = fixposLeftPos - (motOvWidth / 2);
                    motOvTop = fixposTopPos - (motOvHeight / 2);
                } else if (fixposAlign == 'tl') {
                    motOvLeft = fixposLeftPos;
                    motOvTop = fixposTopPos;
                } else if (fixposAlign == 'tc') {
                    motOvLeft = fixposLeftPos - (motOvWidth / 2);
                    motOvTop = fixposTopPos;
                } else if (fixposAlign == 'tr') {
                    motOvLeft = fixposLeftPos - motOvWidth;
                    motOvTop = fixposTopPos;
                }
            }
            if (isReload) {
                $(that).find('div[data-id="' + oldid + '"]').remove();
            }
            motOv = $('<div />');

            if (motivp && motivi && pmo[motivp][motivi] && pmo[motivp][motivi].rotation) {
                rotation = pmo[motivp][motivi].rotation;
            }
           //braucht man für anzeige, aber nicth für api?
            var centerXOrig = centerX;
            var centerYOrig = centerY;
            var motOvLeftOrig = motOvLeft;
            var motOvTopOrig = motOvTop;
            if ((rotation > 0 || rotation < 0)) {
                rotWidth = ((motOvWidth * Math.abs(Math.cos(rotation * Math.PI / 180))) + (motOvHeight * Math.abs(Math.sin(rotation * Math.PI / 180))));
                rotHeight = ((motOvWidth * Math.abs(Math.sin(rotation * Math.PI / 180))) + (motOvHeight * Math.abs(Math.cos(rotation * Math.PI / 180))));
                centerX = motOvLeft + rotWidth / 2;
                centerY = motOvTop + rotHeight / 2;
                motOvLeft = centerX - motOvWidth / 2;
                motOvTop = centerY - motOvHeight / 2;
            }

            motOv
                .width(Math.round(motOvWidth))
                .height(Math.round(motOvHeight))
                .attr('data-pos', acP)
                .attr('data-posIndex', posIndex)
                .attr('data-template', template)
                .attr('data-rotation', rotation)
                .attr('data-crid', res.mid)
                .attr('data-postyp', aPT)
                .css('left', Math.round(motOvLeft))
                .css('top', Math.round(motOvTop))
                .css('zIndex', zIndex);

            if(options.druck_id){
            	motOv.attr('data-did', options.druck_id);
            }

            if (rotation > 0 || rotation < 0) {
                motOv.css('transform','rotate(' + rotation + 'deg)');
                motOv.css('-moz-transform','rotate(' + rotation + 'deg)');
                motOv.css('-webkit-transform','rotate(' + rotation + 'deg)');
                motOv.css('-o-transform','rotate(' + rotation + 'deg)');
            }
            if (relImage.hasClass('stageImage') || relImage.hasClass('motivImage') || relImage.hasClass('primg')) {
                motOvWidth = parseFloat(motOvWidth);
                motOvHeight = parseFloat(motOvHeight);
                resizableClass = scaleable === '1' ? ' resizable' : '';
                rotatableClass = rotatable === '1' ? ' rotatable' : '';
                draggableClass = draggable === '1' ? ' draggable' : '';
                if ($.browser.msie && $.browser.version === '8.0'){
                    rotatableClass = '';
                    rotatable = 0;
                }
                if (isReload) {
                    $('.ovholder').removeClass('active');
                    $('.clone-type-configurator > ul > li').removeClass('active');
                }
                motOv.attr('data-editable', editable);
                //kein autoactive
                //motOv.addClass(draggableClass + resizableClass + rotatableClass + ' ovholder active')
                motOv.addClass(draggableClass + resizableClass + rotatableClass + ' ovholder')
                    .width(Math.round(motOvWidth))
                    .height(Math.round(motOvHeight));
                motOv.attr('data-initWidth', Math.round(motOvWidth * factor));
                motOv.attr('data-initHeight', Math.round(motOvHeight * factor));
                motOv.attr('data-initLeft', Math.round(motOvLeft * factor));
                motOv.attr('data-initTop', Math.round(motOvTop * factor));


                centerX = centerXOrig;
                centerY = centerYOrig;
                motOvLeft = motOvLeftOrig;
                motOvTop = motOvTopOrig;



                if (uploaduuid) {
                    motOv.attr('data-uploaduuid', uploaduuid);
                }
                if (isText) {
                    motOv.attr('data-isText', 1);
                    motOv.attr('data-ptyp', 'text');
                }
                if (uploadTrim) {
                    motOv.attr('data-uploadTrim', uploadTrim);
                }
                if (motivi && pmo[motivp][motivi] && pmo[motivp][motivi].uniqueGruppe) {
                    uniqueGruppe = pmo[motivp][motivi].uniqueGruppe;
                }
                if (uniqueGruppe) {
                    motOv.attr('data-uniqueGruppe', uniqueGruppe);
                }
                if (motivi && pmo[motivp][motivi] && pmo[motivp][motivi].fixPointAlign) {
                    aktLeft_px = pmo[motivp][motivi].aktLeft_px;
                    aktTop_px = pmo[motivp][motivi].aktTop_px;
                    aktTop_px = Math.round(motOvTop * factor);
                } else {
                    aktLeft_px = Math.round(motOvLeft * factor);
                    aktTop_px = Math.round(motOvTop * factor);
                }
                if (res.data.isUpload) {
                    motOv.attr('data-ptyp', 'upload');
                }
                if (res && res.post && res.post.designId) {
                    motOv.attr('data-ptyp', 'motive');
                    motOv.attr('data-motive', res.post.motivId);
                }
                if (res && res.post && res.post.uniqueGruppe) {
                    motOv.attr('data-uniqueGruppe', 'motive');
                }
                aktWidth_px = Math.round(motOvWidth * factor);
                aktHeight_px = Math.round(motOvHeight * factor);
                $('.ovholder').not('.active').find('.activewrapper').hide();
                $('.ovholder').not('.active').find('.outerhelper').hide();
                motOv.find('.activewrapper').remove();
                motOvHelper = $('<div />');
                motOvHelper.addClass('absolute activewrapper').css('left', -2).css('top', -2).css('right', -3).css('bottom', -2);
                motOv.append(motOvHelper);
                if (motivi && pmo[motivp][motivi]) {
                    motivname = pmo[motivp][motivi].templatelabel;
                } else {
                    if (templateTyp == 'upload') {
                        motivname = $('.uploadselect.selected').find('.holder').find('img').attr('data-name');
                    } else {
                        motivname = $('.temselect[data-value="' +  template + '"]').attr('data-title');
                    }
                }
                if ($('#favoritelist').length && !res.data.isUpload) {
                    $.addIconHelper('addtofav', 'top', {'data-title': 'zu Favoriten hinzufügen'}, 'star', motOv);
                }
                if (!deleteable || deleteable == 1) {
                    $.addIconHelper('deleter', 'bottom', {'data-title': 'löschen'}, 'trash', motOv);
                    if (!res || (res.data && res.data.defMot != 1)) {
                        $.addIconHelper('duplicater', 'top', {'data-title': 'Motiv duplizieren'}, 'copy', motOv);
                    }
                }
                relImage.closest('.hasMotiv').find('.stageHolder').find('.ccHolder').remove();
                ovid = aId.split('-');
                ovid = ovid[0];
                ccov = $('<div />');
                ccov
                    .width($('.motivImage').find('.rpcol').width()).height($('.motivImage').find('.rpcol').height())
                    .addClass('absolute ccHolder')
                    .css('display', 'none')
                    .css('opacity', '.5')
                    .css('left', $('.motivImage').find('.rpcol').position().left)
                    .css('top', 0)
                    .html('<img style="width:100%;height:100%" src="https://imaging3.smake.com/overlays/' + ovid + '_' + aPT + '.png"/>');
                relImage.closest('.hasMotiv').find('.stageHolder').append(ccov);
                if (rotatable === '1') {
                    $.addIconHelper('rotate', {right: -18, top: -18}, {'data-title': 'Drehen'}, 'arrowrefresh-1-e', motOv);
                }
            }
            motOv.addClass('absolute motov');
            motOv.attr('data-id', imageid);
            motOvImg = $('<img />');
            wsize = '&width=' + Math.round(motOvWidth);
            //wsize = '&width=1';
            imgsrc = img;
            if (1==2 && res && res.data && res.data.result && res.data.result.info && res.data.result.info.Base64PreviewTemplate) {
                imgsrc = 'data:image/png;base64,' + res.data.result.info.Base64PreviewTemplate;
                wsize = '';
                img = imgsrc;
            }
            motOvImg
                .width('100%').height('100%')
                .css('zIndex', 2001)
                .attr('data-src', img)
                .addClass('ovimga')
                .attr('src', imgsrc + wsize).show();
            //aenderung fuer bugfix schriftwechsel ohne
            $('.ovholder').removeClass('active');
            $('.clone-type-configurator > ul > li').removeClass('active');
            motOv.append(motOvImg);
            relImage.closest('.hasMotiv').find('.drov').append(motOv);
            motOvImg.imagesLoaded().done(function () {
                motOvImg.show();
                if (motivp && !isReload) {
                    if (oldid) {
                        $(that).find('div[data-id="' + oldid + '"]').remove();
                    }
                    relImage.closest('.hasMotiv').find('.drov').append(motOv);
                    $.doExistCheck();
                }
            });
            if ((relImage.hasClass('stageImage') || relImage.hasClass('motivImage') || relImage.hasClass('primg')) && relImage.width() > 0) {

                if (!pmo) {
                    pmo = {};
                }
                if (!pmo[acP]) {
                    pmo[acP] = {};
                }
                if (!pmo[acP][posIndex]) {
                    pmo[acP][posIndex] = {};
                }
                pmo[acP][posIndex].img = img;
                pmo[acP][posIndex].templateTyp = templateTyp;
                if (uploaduuid) {
                    pmo[acP][posIndex].uploaduuid = uploaduuid;
                    pmo[acP][posIndex].templateTyp = 'druck';

                    //if(!pmo[acP][posIndex].origWidth){
                        pmo[acP][posIndex].origWidth = res.data.width;
                        pmo[acP][posIndex].origHeight = res.data.height;
                    //}
                }
                pmo[acP][posIndex].uploadTrim = uploadTrim;
                pmo[acP][posIndex].scaleable = scaleable;
                pmo[acP][posIndex].rotatable = rotatable;
                pmo[acP][posIndex].deleteable = deleteable;
                pmo[acP][posIndex].editable = editable;
                pmo[acP][posIndex].rotation = rotation;
                pmo[acP][posIndex].draggable = draggable;
                pmo[acP][posIndex].mm2pxFactor = mm2pxFactor;
                pmo[acP][posIndex].imageFactor = 520 / relImage.width();
                pmo[acP][posIndex].imageid = imageid;
                if(!pmo[acP][posIndex].ajaxId){
                    pmo[acP][posIndex].ajaxId = imageid;
                    realActive = null;
                }
                motOv.attr('data-auid', pmo[acP][posIndex].ajaxId);
                pmo[acP][posIndex].posIndex = posIndex;
                pmo[acP][posIndex].acP = acP;
                pmo[acP][posIndex].aPT = aPT;
                pmo[acP][posIndex].sid = res.data.result.info.id;
                pmo[acP][posIndex].zIndex = parseFloat(zIndex);
                if (!isReload) {
                    if (!res.data.isUpload) {
                        if (!isText) {
                            pmo[acP][posIndex].template = template;
                            if(!pmo[acP][posIndex].theme){
                                pmo[acP][posIndex].theme = $('.temselect[data-value="' +  template + '"]').attr('data-tw');
                            }
                            if(!pmo[acP][posIndex].label){
                                pmo[acP][posIndex].label = $('.temselect[data-value="' +  template + '"]').attr('data-label');
                            }
                            if(!pmo[acP][posIndex].templatelabel){
                                pmo[acP][posIndex].templatelabel = $('.temselect[data-value="' +  template + '"]').attr('data-title');
                            }
                        } else {

                            pmo[acP][posIndex].label = 'Stick';
                            pmo[acP][posIndex].templatelabel = isText[0].text;
                        }
                    } else {
                        pmo[acP][posIndex].label = 'Upload';
                        pmo[acP][posIndex].templatelabel = res.data.templatelabel;
                    }
                }
                if(uniqueGruppe){
                    pmo[acP][posIndex].uniqueGruppe = uniqueGruppe;
                }
                pmo[acP][posIndex].image = img + '&width=50';
                // ausgeschaltet weil wegen problem
                //if (pmo[acP][posIndex].isClone !== true && !isReload) {
                    pmo[acP][posIndex].aktLeft_px = aktLeft_px;
                    pmo[acP][posIndex].aktTop_px = aktTop_px;
                    pmo[acP][posIndex].aktWidth_px = aktWidth_px;
                    pmo[acP][posIndex].aktHeight_px = aktHeight_px;
                //}
                if (pmo[acP][posIndex].templateTyp == 'stick') {
                    if (!pmo[acP][posIndex].initialApiWidth) {
                        pmo[acP][posIndex].initialApiWidth = apiWidth;
                        pmo[acP][posIndex].initWidthHeightRatio = initWidthMM / initHeightMM;
                    } else {
                        pmo[acP][posIndex].wFactor = apiWidth / 10 / initWidthMM;
                    }
                    pmo[acP][posIndex].apiWidth = apiWidth;
                    if (!pmo[acP][posIndex].initialApiHeight) {
                        pmo[acP][posIndex].initialApiHeight = apiHeight;
                        pmo[acP][posIndex].initHeightHeightRatio = initHeightMM / initHeightMM;
                    } else {
                        pmo[acP][posIndex].hFactor = apiHeight / 10 / initHeightMM;
                    }
                    pmo[acP][posIndex].apiHeight = apiHeight;
                }

                if (pmo[acP][posIndex].templateTyp == 'druck' || pmo[acP][posIndex].templateTyp == 'upload') {
                    if (!pmo[acP][posIndex].initialApiWidth) {
                        pmo[acP][posIndex].initialApiWidth = apiWidth * mm2pxFactor * pmo[acP][posIndex].imageFactor;
                        pmo[acP][posIndex].initialApiHeight = apiHeight * mm2pxFactor * pmo[acP][posIndex].imageFactor;
                    }
                }
                if (pmo[acP][posIndex].templateTyp == 'upload') {
                        pmo[acP][posIndex].maxPrintWidth = $('.motupload[data-uuid="' + pmo[acP][posIndex].sid + '"]').attr('data-maxWidth');
                        pmo[acP][posIndex].maxPrintHeight = $('.motupload[data-uuid="' + pmo[acP][posIndex].sid + '"]').attr('data-maxHeight');
                        $.checkQuality(pmo[acP][posIndex]);
                }
                if (isText) {
                    pmo[acP][posIndex].text = isText;
                    //pmo[acP][posIndex].fontid = isText[0].schriftartId;
                    //pmo[acP][posIndex].lineheight = isText[0].zeilenabstand;
                    //pmo[acP][posIndex].radius = isText[0].tradius;
                    //pmo[acP][posIndex].tradius = isText[0].tradius;
                }
                pmo[acP][posIndex].aoData = aoData;
                pmo[acP][posIndex].left_mm = parseFloat(aktLeft_px * mm2pxFactor * pmo[acP][posIndex].imageFactor);
                pmo[acP][posIndex].top_mm = parseFloat(aktTop_px * mm2pxFactor * pmo[acP][posIndex].imageFactor);
                if (pmo[acP][posIndex].templateTyp == 'stick') {
                    pmo[acP][posIndex].grundWidth_mm = parseFloat(res.data.width / 10);
                    pmo[acP][posIndex].grundHeight_mm = parseFloat(res.data.height / 10);
                } else {
                    pmo[acP][posIndex].grundWidth_mm = Math.round(aktWidth_px * mm2pxFactor);
                    pmo[acP][posIndex].grundHeight_mm = Math.round(aktHeight_px * mm2pxFactor);
                }
                if (!pmo[acP][posIndex].maxAvailableImgWidth) {
                    pmo[acP][posIndex].maxAvailableImgWidth = aktWidth_px;
                    pmo[acP][posIndex].maxAvailableImage = res.data.imageSrc;
                } else if (pmo[acP][posIndex].maxAvailableImgWidth < aktWidth_px) {
                    pmo[acP][posIndex].maxAvailableImgWidth = aktWidth_px;
                    pmo[acP][posIndex].maxAvailableImage = res.data.imageSrc;
                }
                if (renew) {
                    pmo[acP][posIndex].maxAvailableImgWidth = aktWidth_px;
                    pmo[acP][posIndex].maxAvailableImage = res.data.imageSrc;
                }
                pmo[acP][posIndex].soapId = res.data.result.soapId;
                pmo[acP][posIndex].price = res.data.result.price.preis;
                pmo[acP][posIndex].isClone = false;

                delete pmo[acP][posIndex].isClone;
                if (isReload) {
                    $('.ovholder').removeClass('active');
                    $('.clone-type-configurator > ul > li').removeClass('active');
                }
                ppp.drTopPx = drgebietTopPx;
                ppp.drLeftPx = drgebietLeftPx;
                ppp.drWidthPx = drgebietWidthPx;
                ppp.drHeightPx = drgebietHeightPx;
                pmo[acP][posIndex].info = ppp;
                if (!isReload && !relImage.closest('.origholder').length) {
                    $.checkPosition(false, pmo[acP][posIndex].ajaxId);
                }
                if (!relImage.closest('.origholder').length) {
                    //$.updatePriceDiv();
                    $.loadMotiveDragger();
                }
                if(res && res.data && res.data.result &&res.data.result.info && res.data.result.info.elementInfo){
                    $('.tempPreview[data-template="' + pmo[acP][posIndex].template + '"][data-acP="' + acP + '"]').remove();
                    $.each(res.data.result.info.elementInfo, function (e) {
                        var div = $('<div />');
                        div.addClass('tempPreview');
                        div.attr('data-template', pmo[acP][posIndex].template);
                        div.attr('data-acP', acP);
                        div.attr('data-posIndex', posIndex);
                        div.attr('data-base64', res.data.result.info.elementInfo[e]['base64preview']);
                        div.attr('data-element', res.data.result.info.elementInfo[e]['elementName']);
                        $('body').append(div);
                    });
                }
            }
            if (relImage.hasClass('stageImage') || relImage.hasClass('motivImage') || relImage.hasClass('primg')) {
                $('.activeTemplate').find('span[data-id="' + imageid + '"]').remove();
                $('.tbdl').remove();
                span = $('<span />')
                    .attr('data-id', imageid)
                    .attr('data-json', JSON.stringify(res.post));
                $('.activeTemplate').append(span);
            }
            if (isReload) {
                $('.ovholder').removeClass('active');
                $('.clone-type-configurator > ul > li').removeClass('active');
                $('.outerhelper').hide();
                $('.activewrapper').hide();
            }
            if (oldid) {
                $.loadMotiveDragger();
            }
        };
        $.buildMotive = function (isText, uploadTrim, uploaduuid, res, motivp, motivi, acP, aPT, renew, oldid, drgebiet, initWidthMM,
        		initHeightMM, isReload, template, aoData, isMover, initHeightPrint, uniqueGruppe) {

        	var changeFixPos, test, dd, resizableClass = '', draggableClass = '', rotatableClass = '', scaleable, rotatable, deleteable, editable, draggable, ppind = [], akt_fixposLeftPos, akt_fixposTopPos, fixposAlign, aktWidth_px, aktHeight_px, aktLeft_px, aktTop_px, zIndex = 2000, motOvHelper, imageid, ooWidth = 520, apiWidth, mm2pxFactor, imgFactor, apiHeight, drgebietWidthPx, drgebietHeightPx, drgebietLeftPx, drgebietTopPx, img, fixpos, templateTyp, helperWidth = 16, posIndex = 1, aId = $('#arthead').attr('data-aId');
            if (!res) {
                return false;
            }
            dd = res.data;
            if (dd && dd.result && dd.result.info && dd.result.info.ErrorMessage) {
            	    if (sprache[dd.result.info.ErrorMessage] !== undefined) {
                    $.setInfo('<p>' + sprache[dd.result.info.ErrorMessage] + '</p>');
                } else {
                    $.setInfo('<p>' + dd.result.info.ErrorMessage + '</p>');
                }
                $.loadOverlay(true);
                return;
            }
            if (isText) {
                initWidthMM = res.post.widthMM;
                initHeightMM = res.post.heightMM;
            }
            if (!res.data.result.price) {
            	   $.loadOverlay(true);
                return;
            }

            if (!pmo || (!pmo[motivp] && !motivi)) {
            	if (!res.data.isUpload) {
                    templateTyp = $('.temselect.selected').first().attr('data-type');
                    scaleable = $('.temselect.selected').first().attr('data-scaleable');
                    draggable = $('.temselect.selected').first().attr('data-draggable');
                    rotatable = $('.temselect.selected').first().attr('data-rotatable');
                    deleteable = $('.temselect.selected').first().attr('data-deleteable');
                    editable = $('.temselect.selected').first().attr('data-editable');
                    if (typeof $('.uploadselect.selected').first().find('img').data('uuid') !== 'undefined') {
                        if ($('.uploadselect.selected').length && $('.uploadselect.selected').first().find('img').attr('data-uuid').length) {
                            scaleable = '1';
                            draggable = '1';
                            rotatable = '1';
                            deleteable = '1';
                            editable = '1';
                        }
                    }
                } else {
                    templateTyp = 'upload';
                    scaleable = '1';
                    draggable = '1';
                    rotatable = '1';
                    deleteable = '1';
                    editable = '1';
                }
                if (res && res.data && res.data.isText) {
                    scaleable = '1';
                    draggable = '1';
                    rotatable = '1';
                    deleteable = '1';
                    editable = '1';
                    if (res.post && res.post.type && res.post.type == 'druck') {
                        templateTyp = 'druck';
                    } else {
                        templateTyp = 'stick';
                    }
                }


            } else {
            	 if (res && res.data && res.data.isText) {
                    if (res.post && res.post.type && res.post.type == 'druck') {
                        pmo[motivp][motivi].templateTyp = 'druck';
                    } else {
                        pmo[motivp][motivi].templateTyp = 'stick';
                    }
                }
                templateTyp = pmo[motivp][motivi].templateTyp;
                scaleable = pmo[motivp][motivi].scaleable;
                draggable = pmo[motivp][motivi].draggable;
                rotatable = pmo[motivp][motivi].rotatable;
                deleteable = pmo[motivp][motivi].deleteable;
                editable = pmo[motivp][motivi].editable;

                if($('#contenthere').length && $('#contenthere').attr('data-ssId')){

                    scaleable = '1';
                    draggable = '1';
                    rotatable = '1';
                    deleteable = '1';
                    editable = '1';
                    pmo[motivp][motivi].defMot = 0;
                }
            }
            ppind = [];
            if (!motivp) {
                if (pmo && pmo[acP]) {
                    $.each(pmo[acP], function (b) {
                        ppind.push(parseFloat(pmo[acP][b].posIndex));
                        if (pmo[acP][b].zIndex && pmo[acP][b].templateTyp == 'druck') {
                            zIndex = pmo[acP][b].zIndex;
                        }
                        zIndex = zIndex + 10;
                    });
                    posIndex = $.findNextNumber(ppind);
                }
            } else {
                posIndex = motivi;
                zIndex = pmo[motivp][motivi].zIndex + 10;
            }
            imageid = posIndex + '-' + acP + '-' + res.data.result.info.id;
            if (renew && oldid && oldid == imageid && pmo[motivp][motivi].isClone && pmo[motivp][motivi].isClone === false && !isReload) {
                $.loadOverlay(true);
                return true;
            }
            if (templateTyp == 'stick') {
                zIndex = 3000;
            }
            img = res.data.imageSrc;
            apiWidth = res.data.width;
            apiHeight = res.data.height;
            imgFactor = apiWidth / apiHeight;
            mm2pxFactor = $('.frsize_' + acP).attr('data-width-mm') / drgebiet.attr('data-drWidthPx');
            if (!motivp && !isMover) {
                test = $.findNextFixpos(acP, mm2pxFactor);
                fixpos = $('.motpos[value="' + acP + '"]').closest('li').find('.fixpos[data-fuerMotiv="1"]').eq(test - 1);
                if (!fixpos.length) {
                    fixpos = $('.motpos[value="' + acP + '"]').closest('li').find('.fixpos[data-fuerMotiv="1"]').first();
                }
            }
            drgebietWidthPx = parseFloat(drgebiet.attr('data-drWidthPx'));
            drgebietHeightPx = parseFloat(drgebiet.attr('data-drHeightPx'));
            drgebietLeftPx = parseFloat(drgebiet.attr('data-drLeftPx'));
            drgebietTopPx = parseFloat(drgebiet.attr('data-drTopPx'));

            $('.hasMotiv' + aPT).each(function () {
                var that, relImage, isOk = true;
                that = this;
                relImage = $(that).find('.rpcol').first();
            	var options = {};

                if (relImage.length && relImage.width() == 0) {
                    isOk = false;
                    relImage.imagesLoaded().progress(function (t) {
                        $.process(changeFixPos, isText, uploadTrim, uploaduuid, relImage, ooWidth, initWidthMM,
                        		templateTyp, mm2pxFactor, imgFactor, drgebietLeftPx, drgebietTopPx, drgebietWidthPx,
                        		drgebietHeightPx, fixpos, motivp, motivi, akt_fixposLeftPos, akt_fixposTopPos,
                        		fixposAlign, that, isReload, oldid, acP, posIndex, template, aPT, zIndex, imageid,
                        		img, scaleable, rotatable, deleteable, editable, draggable, resizableClass,
                        		draggableClass, rotatableClass, aktLeft_px, aktTop_px, aktWidth_px, aktHeight_px,
                        		motOvHelper, helperWidth, aId, res, aoData, renew, apiWidth, initHeightMM, apiHeight,
                        		initHeightPrint, uniqueGruppe, options);
                    });
                }
                if (isOk === true && relImage.length && relImage.width() > 0) {
                	if(motivp && motivi && pmo[motivp][motivi].druck_id){
                		options.druck_id = pmo[motivp][motivi].druck_id;
                	}
                    $.process(changeFixPos, isText, uploadTrim, uploaduuid, relImage, ooWidth,
                    		initWidthMM, templateTyp, mm2pxFactor, imgFactor, drgebietLeftPx, drgebietTopPx,
                    		drgebietWidthPx, drgebietHeightPx, fixpos, motivp, motivi, akt_fixposLeftPos,
                    		akt_fixposTopPos, fixposAlign, that, isReload, oldid, acP, posIndex, template, aPT, zIndex, imageid,
                    		img, scaleable, rotatable, deleteable, editable, draggable, resizableClass, draggableClass, rotatableClass,
                    		aktLeft_px, aktTop_px, aktWidth_px, aktHeight_px, motOvHelper, helperWidth, aId, res, aoData, renew,
                    		apiWidth, initHeightMM, apiHeight, initHeightPrint, uniqueGruppe, options);
                }
            });
        };
        $.setMotive = function (motivp, motivi, renew, isReload, isMover, res, textrows) {
        	if(motivp && motivi && pmo[motivp][motivi].ajaxId){
                ajaxId = pmo[motivp][motivi].ajaxId;
            } else {
                if(!ajaxId){
                    ajaxId = 1;
                } else {
                    ajaxId = ajaxId + 1;
                    ajaxId = ajaxId + 1;
                }
            }
            if (xhr[ajaxId] && !isReload) {
                xhr[ajaxId].abort(); //tempdisabled
            }


            $('.tmp').remove();
            $.loadOverlay();
            var uniqueGruppe, initHeightPrint, tate, text, trow, trowid, tradius, scale, scaleHeight, isText, textcolor, topt = {}, ti, tmpIdx, tmpZeilen = {}, pixratio, uploadTrim, uploaduuid, drgebiet, hasText = true, hasElements = true, isUpload = false, oldid, initWidthMM, initHeightMM, url, acP, aPT, useAllText = true, iia = 0, usedTextColors = [], aoData = [], template, val, colorHolder, colorRgb, isMotive = false;

            acP = $('#motivDesignerForm').attr('data-activePos');
            aPT = $('#motivDesignerForm').attr('data-activePositionsTyp');

            if (!textrows && motivp && motivi && pmo[motivp][motivi] && pmo[motivp][motivi].text) {
                textrows = [];
                if (isReload) {
                    $.each(pmo[motivp][motivi].text, function(a) {
                        textrows[a] = pmo[motivp][motivi].text[a].text;
                    });
                } else {
                    text = $.trim($('#sticktext').val());
                    text = text.split('\n');
                    //textrows = $.grep(text,function(n){ return(n) });
                    textrows = text;
                }
            }
            if (!textrows) {
                if (!template && motivp && motivi && pmo[motivp] && pmo[motivp][motivi] && pmo[motivp][motivi] && pmo[motivp][motivi].template) {
                    template = pmo[motivp][motivi].template;
                } else {

                    template = $('.temselect.selected').first().attr('data-value');
                    //check for uniqueGruppe
                    if($('.temselect.selected').first().attr('data-uniqueGruppe')){

                        //search for exist on this side
                        uniqueGruppe = $('.temselect.selected').first().attr('data-uniqueGruppe');
                        if($('.ovholder[data-pos="' + acP + '"][data-uniquegruppe="' + uniqueGruppe + '"]').length){

                            motivp = acP;
                            motivi = $('.ovholder[data-pos="' + acP + '"][data-uniqueGruppe="' + uniqueGruppe + '"]').attr('data-posindex');
                            renew = true;
                            isReload = false;

                            pmo[motivp][motivi].template = template;

                            pmo[motivp][motivi].label = $('.temselect[data-value="' +  template + '"]').attr('data-label');
                            pmo[motivp][motivi].templatelabel = $('.temselect[data-value="' +  template + '"]').attr('data-title');



                            delete pmo[motivp][motivi].designId;
                            delete pmo[motivp][motivi].stickMotiv;
                            delete pmo[motivp][motivi].aoData.designId;
                            delete pmo[motivp][motivi].aoData.motivId;
                            delete pmo[motivp][motivi].aoData.widthMM;
                            delete pmo[motivp][motivi].aoData.heightMM;
                            delete pmo[motivp][motivi].aoData;
                            delete pmo[motivp][motivi].aktWidth_px;
                            delete pmo[motivp][motivi].aktHeight_px;
                            delete pmo[motivp][motivi].initialApiWidth;
                            delete pmo[motivp][motivi].initialApiHeight;
                            delete pmo[motivp][motivi].ajaxId;
                            delete pmo[motivp][motivi].grundHeight_mm;
                            delete pmo[motivp][motivi].grundWidth_mm;
                            pmo[motivp][motivi].template = template;

                        }
                    }
                }

                if ((!template && !isMover && !renew) || (motivp && pmo[motivp][motivi].templateTyp && pmo[motivp][motivi].templateTyp === 'upload')) {
                    uploaduuid = $('.uploadselect.selected').first().find('img').attr('data-uuid');
                    pixratio = $('.uploadselect.selected').first().find('img').attr('data-width') / $('.uploadselect.selected').first().find('img').attr('data-height');
                    isUpload = false;
                    //aoData.push({'name': 'isUpload', 'value': true});

                    if ($('input[name="uploadTrim"]').is(':checked') || !$('input[name="uploadTrim"]').length) {
                        aoData.push({'name': 'uploadTrim', 'value': 1});
                        uploadTrim = 1;
                    } else {
                        aoData.push({'name': 'uploadTrim', 'value': 0});
                        uploadTrim = 0;
                    }
                    if (motivp && motivi && pmo[motivp][motivi] && pmo[motivp][motivi].isMotive && pmo[motivp][motivi].designId) {
                        aoData.push({'name': 'motivId', 'value': pmo[motivp][motivi].stickMotiv});
                        aoData.push({'name': 'designId', 'value': pmo[motivp][motivi].designId});
                        isMotive = true;
                    } else {
                        if (!textrows) {
                            aoData.push({'name': 'uploaduuid', 'value': uploaduuid});
                            aoData.push({'name': 'templateId', 'value': 1346});

                            template = 1346;
                            $('.temselect[data-value="' + template + '"]').addClass('selected');
                            $.loadTemplateForm(template);
                        }
                    }
                }
            }
            if (textrows) {
                topt.typ = 'normal';
                topt.envelope = 'rectangle';
                aoData.push({'name': 'drehung', 'value': 0});
                aoData.push({'name': 'type', 'value': $('.textmottype.active').attr('data-type')});
                if (motivp && motivi && pmo[motivp] && pmo[motivp][motivi]) {
                    pmo[motivp][motivi].templateTyp = $('.textmottype.active').attr('data-type');
                    if (pmo[motivp][motivi].templateTyp == 'stick') {
                        pmo[motivp][motivi].zIndex = 3000;
                    } else {
                        pmo[motivp][motivi].zIndex = 2000;
                    }
                }
                for (ti = 0; ti < textrows.length; ti = ti + 1) {
                    trowid = parseInt(ti, 10) + 1;
                    trow = $('.tformat[data-row="' + trowid + '"]');
                    //if (textrows[ti]) {
                        tmpIdx = Object.size(tmpZeilen);
                        if (isReload && renew && motivp && motivi  && pmo[motivp][motivi] && pmo[motivp][motivi].text && pmo[motivp][motivi].text[ti] && pmo[motivp][motivi].text[ti].farbe) {
                            topt.farbe = pmo[motivp][motivi].text[ti].farbe;
                            topt.rgb = pmo[motivp][motivi].text[ti].rgb;
                        } else if (trow.length) {
                            colorHolder = trow.find('.txtColorPicker').find('input[name="color"]');
                            colorRgb = colorHolder.css('backgroundColor');
                            if (colorRgb === undefined) {
                                $.initColorpicker();
                                colorHolder = trow.find('.txtColorPicker').find('input[name="color"]');
                                colorRgb = colorHolder.css('backgroundColor');
                                colorRgb = trow.find('.colorico').css('backgroundColor');
                            }
                            if (colorRgb == 'transparent') {
                                colorRgb = trow.find('.colorico').css('backgroundColor');
                            }
                            topt.rgb = $.hexToRgb(colorRgb);
                            colorRgb = colorRgb.split(' ').join('').toString();
                            tate = $.rgb2hex(colorRgb);
                            if (!tate) {
                                tate = colorRgb;
                            }
                            tate = tate.replace('#', '');
                            topt.farbe = trow.find('.txtColorPicker').find('option[value="' + tate + '"]').first().attr('data-mad');
                        }
                        if (isReload && renew && motivp && motivi  && pmo[motivp][motivi] && pmo[motivp][motivi].text && pmo[motivp][motivi].text[ti] && pmo[motivp][motivi].text[ti].schriftartId) {
                            topt.schriftartId = pmo[motivp][motivi].text[ti].schriftartId;
                        } else if (trow.length) {
                        	if($('.tformat[data-row="' + trowid + '"]').find('.sfont[data-type="' + $('.textmottype.active').attr('data-type') + '"]').find('.cfont.selected').length == 0){
                        		$('.tformat[data-row="' + trowid + '"]').find('.sfont[data-type="' + $('.textmottype.active').attr('data-type') + '"]').find('.cfont:first').addClass('selected');
                        	}
                            topt.schriftartId = $('.tformat[data-row="' + trowid + '"]').find('.sfont[data-type="' + $('.textmottype.active').attr('data-type') + '"]').find('.cfont.selected').attr('data-value');
                        }

                        if (isReload && renew && motivp && motivi  && pmo[motivp][motivi] && pmo[motivp][motivi].text && pmo[motivp][motivi].text[ti] && pmo[motivp][motivi].text[ti].ausrichtung) {
                            topt.ausrichtung = pmo[motivp][motivi].text[ti].ausrichtung;
                        } else if (trow.length) {
                            topt.ausrichtung = $('.tformat[data-row="' + trowid + '"]').find('.sausrichtung').find('.causrichtung.selected').attr('data-value');
                        }

                        if (isReload && renew && motivp && motivi  && pmo[motivp][motivi] && pmo[motivp][motivi].text && pmo[motivp][motivi].text[ti] && pmo[motivp][motivi].text[ti].schrifthoehe) {
                            topt.schrifthoehe = pmo[motivp][motivi].text[ti].schrifthoehe;
                        } else if (trow.length) {
                            topt.schrifthoehe = $('.tformat[data-row="' + trowid + '"]').find('.fontsize').slider('value');
                            if(pmo && pmo[motivp] && pmo[motivp][motivi] && pmo[motivp][motivi].templateTyp == 'stick' && topt.schrifthoehe > 23){
                                topt.schrifthoehe = 23;
                            }
                        }
                        tradius = 0;
                        topt.tradius = tradius;
                        if (isReload && renew && motivp && motivi  && pmo[motivp][motivi] && pmo[motivp][motivi].text && pmo[motivp][motivi].text[ti] && pmo[motivp][motivi].text[ti].tradius) {
                            topt.tradius = pmo[motivp][motivi].text[ti].tradius;
                            tradius = topt.tradius;
                        } else if(trow.length){
                            tradius = $('.tformat[data-row="' + trowid + '"]').find('.tradius').slider('value');
                            topt.tradius = tradius;
                        }

                        if (isReload && renew && motivp && motivi  && pmo[motivp][motivi] && pmo[motivp][motivi].text && pmo[motivp][motivi].text[ti] && pmo[motivp][motivi].text[ti].zeilenabstand) {
                            topt.zeilenabstand = pmo[motivp][motivi].text[ti].zeilenabstand;
                        } else if(trow.length) {
                            topt.zeilenabstand = $('.tformat[data-row="' + trowid + '"]').find('.lineheight').slider('value');
                        }
                        topt.typ = 'normal';
                        topt.refY = 0;
                        if (tradius == 0) {
                            topt.typ = 'normal';
                            topt.refY = 0;
                        } else {
                            topt.typ = 'kreis';
                            if (tradius > 0) {
                                topt.refY = $('.tformat').find('.tradius').slider('option', 'max') - tradius;
                                topt.position = 'oben';
                            } else {
                                if (tradius) {
                                    topt.refY = ($('.tformat').find('.tradius').slider('option', 'min') - tradius) * -1;
                                } else {
                                    topt.refY = 0;
                                    topt.tradius = 0;
                                }
                                topt.position = 'unten';
                            }
                        }
                        tmpZeilen[tmpIdx] = $.extend(true, {}, topt);
                        tmpZeilen[tmpIdx].text = textrows[ti];
                    //}
                }
                aoData.push({'name': 'textrows', 'value': JSON.stringify(tmpZeilen, 2, null)});
                scale = 1;
                if (motivp && motivi && pmo[motivp][motivi] && pmo[motivp][motivi].scale) {
                    scale = pmo[motivp][motivi].scale;
                }
                aoData.push({'name': 'scale', 'value': scale});
                aoData.push({'name': 'isText', 'value': 1});
                isText = tmpZeilen;
            }
            if (!textrows) {
            	if (motivp && motivi && pmo[motivp] && pmo[motivp][motivi] && pmo[motivp][motivi].isMotive && pmo[motivp][motivi].designId) {
                	aoData.push({'name': 'motivId', 'value': pmo[motivp][motivi].stickMotiv});
                    aoData.push({'name': 'designId', 'value': pmo[motivp][motivi].designId});
                    isMotive = true;
                }

                if (motivp && motivi && pmo[motivp] && pmo[motivp][motivi] && pmo[motivp][motivi].isMotive && pmo[motivp][motivi].druck_id) {
                	aoData.push({'name': 'druck_id', 'value': pmo[motivp][motivi].druck_id});
                    isMotive = true;
                }
                if (motivp && pmo[motivp][motivi].uploaduuid) {
                	uploaduuid = pmo[motivp][motivi].uploaduuid;
                    template = 1346;
                    if ($('input[name="uploadTrim"]').is(':checked')) {
                        aoData.push({'name': 'uploadTrim', 'value': 1});
                        uploadTrim = 1;
                    } else {
                        aoData.push({'name': 'uploadTrim', 'value': 0});
                        uploadTrim = 0;
                    }
                    isUpload = false;
                    aoData.push({'name': 'uploaduuid', 'value': uploaduuid});
                    aoData.push({'name': 'templateId', 'value': template});
                }
            }
            $('.origholder').find('.mtt').width($('.motivImage.hasMotiv.hasMotiv' + aPT).width());
            if (motivp) {
                acP = motivp;
                aPT = pmo[motivp][motivi].aPT;
                if (!textrows) {
                    template = pmo[motivp][motivi].template;
                }
            }
            drgebiet = $('.motpos[value="' + acP + '"]').closest('li').find('.drgebiet').first();
            if (!$('.motpos[value="' + acP + '"]').closest('li').find('.drgebiet').first().length) {
                $.setInfo('Auf dieser Position ist leider keine Individualisierung möglich');
                $.loadOverlay(true);
                return;
            }
            if (!isReload && !textrows) {
                if (isUpload === false && isMotive === false && !pixratio) {
                    $('.elcolorholder').find('.mcpick').find('input[name="color"]').each(function () {
                        var  holder, cname, hex, tho;
                        holder = $(this).closest('div');
                        if ($(this).closest('.mcpick').hasClass('multichang')){
                            cname = 'elementColor[' + holder.attr('data-element') + '][' + holder.attr('data-colorId') + ']';
                            aoData.push({'name': cname, 'value': $.hexToRgb($(this).closest('.colorPicker').find('.colorico').css('backgroundColor'))});
                        } else {
                            cname = 'motivColor[' + holder.attr('data-colorId') + ']';
                            aoData.push({'name': cname, 'value': $.hexToRgb($(this).css('backgroundColor'))});
                        }
                        hex = $.rgb2hex($(this).css('backgroundColor'));
                        if (!hex) {
                            hex = $(this).css('backgroundColor');
                        }
                        hex = hex.replace("#", "");
                        $(this).attr('title', $('.colorpicker').find('option[value="' + hex + '"]').first().text());
                        $(this).attr('value', hex).val(hex);
                        $(this).css('backgroundColor', '#' + hex);
                        $(this).css('borderColor', '#' + hex);
                        if (hex == 'ffffff') {
                            $(this).css('borderColor', '#000000');
                        }
                });
                    $('#motivColors').find('.mcpick').find('input[name="color"]').each(function () {
                        var  holder, cname, hex;
                        holder = $(this).closest('div');
                        cname = 'motivColor[' + holder.attr('data-colorId') + ']';
                        aoData.push({'name': cname, 'value': $.hexToRgb($(this).css('backgroundColor'))});
                        hex = $.rgb2hex($(this).css('backgroundColor'));
                        if (!hex) {
                            hex = $(this).css('backgroundColor');
                        }
                        hex = hex.replace("#", "");
                        $(this).attr('title', $('.colorpicker').find('option[value="' + hex + '"]').first().text());
                        $(this).attr('value', hex).val(hex);
                        $(this).css('backgroundColor', '#' + hex);
                        $(this).css('borderColor', '#' + hex);
                        if (hex == 'ffffff') {
                            $(this).css('borderColor', '#000000');
                        }
                    });
                    if (!$('.textinput').length) {
                        hasText = true;
                    }
                    $('.desinput').each(function () {
                        var toggler, name, hex;
                        name = $(this).attr('name');
                        val = $(this).val();
                        $(this).val(val).attr('value', val);
                        if ($.trim(val) === '') {
                            $(this).val(val).attr('value', val);
                        }
                        if (val == '') {
                            val = ' ';
                        }
                        aoData.push({'name': name, 'value': val});
                        if ($(this).hasClass('textinput') && $(this).is('[type=text]')) {
                            if ($.trim(val) !== '') {
                                hasText = true;
                            }
                            colorHolder = $(this).closest('.ym-grid').find('input[name="color"]');
                            colorRgb = colorHolder.css('backgroundColor');
                            name = $(this).attr('data-name');
                            name = 'color[' + name + ']';
                            if (colorRgb === undefined) {
                                $.initColorpicker();
                                colorHolder = $(this).closest('.ym-grid').find('input[name="color"]');
                                colorRgb = colorHolder.css('backgroundColor');
                            }
                            colorRgb = colorRgb.split(' ').join('').toString();
                            colorRgb = colorHolder.closest('.colorPicker').find('.colorico').css('backgroundColor');
                            hex = $.rgb2hex(colorHolder.closest('.colorPicker').find('.colorico').css('backgroundColor'));
                            if (!hex) {
                                hex = colorHolder.closest('.colorPicker').find('.colorico').css('backgroundColor');
                            }
                            hex = hex.replace("#", "");
                            colorHolder.attr('data-id', $('.colorpicker').find('option[value="' + hex + '"]').first().attr('data-id'));
                            colorHolder.attr('title', $('.colorpicker').find('option[value="' + hex + '"]').first().text());
                            colorHolder.attr('value', hex).val(hex);
                            aoData.push({'name': name, 'value': $.hexToRgb(colorRgb)});
                            if (iia === 0) {
                                usedTextColors[iia] = colorHolder.val();
                            } else if (usedTextColors[0] !== colorHolder.val()) {
                                useAllText = false;
                            }
                            iia = iia + 1;
                            if (motivp === null) {
                                toggler = $(this).closest('.ym-grid').find('.toggles').data('toggles');
                                if ($.trim($(this).val())) {
                                    toggler.toggle(true);
                                } else {
                                    toggler.toggle(false);
                                }
                            }
                        }
                    });
                    if (useAllText === true) {
                        $('input[name="alltexts"]').val(usedTextColors[0]).attr('value', usedTextColors[0]).css('backgroundColor', '#' + usedTextColors[0]).css('color', '#' + usedTextColors[0]);
                        $('input[name="alltexts"]').closest('.colorPicker').find('.colorico').css('backgroundColor', '#' + usedTextColors[0]);
                        $('input[name="alltexts"]').closest('.colorPicker').find('.colorico').css('borderColor', '#' + usedTextColors[0]);
                        if (usedTextColors[0] == 'ffffff') {
                            $('input[name="alltexts"]').closest('.colorPicker').find('.colorico').css('borderColor', '#000000');
                        }
                    }
                    $('.allelementsholder[data-id="' + template + '"]').find('.detselect.selected').each(function () {
                        aoData.push({'name': $(this).first().attr('data-name'), 'value': $(this).first().attr('data-value')});
                        if ($(this).first().attr('data-value') && $(this).first().attr('data-value') !== '0') {
                            hasElements = true;
                        }
                    });
                }

                switch (aPT) {
                case '1':
                    initWidthMM = 90;
                    initHeightMM = 180;
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-type') == 'stick') {
                        initHeightMM = 180;
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm') && parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm')) > 0) {
                        //initHeightMM = $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm');
                        initWidthMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm'));
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm') && parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm')) > 0 && initWidthMM > $('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm')) {
                        initWidthMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm'));
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-initHeight_mm') && parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initHeight_mm')) > 0) {
                        //initHeightMM = $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm');
                        initHeightMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initHeight_mm'));
                        initHeightPrint = initHeightMM;
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm') && parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm')) > 0 && initHeightMM > $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm')) {
                        initHeightMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm'));
                    }
                    break;
                case '2':
                    initWidthMM = 190;
                    initHeightMM = 190;
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-type') == 'stick') {
                        initHeightMM = 380;
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm') && parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm')) > 0) {
                        //initHeightMM = $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm');
                        initWidthMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm'));
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm') && parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm')) > 0 && initWidthMM > $('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm')) {
                        initWidthMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm'));
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm') && parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm')) > 0 && initHeightMM > $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm')) {
                        initHeightMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm'));
                    }
                    break;

                case '3':
                    initWidthMM = 90;
                    initHeightMM = 180;
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-type') == 'stick') {
                        initHeightMM = 180;
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm') && parseFloat($('.temselect[data-value="' + template +'"]').first().attr('data-initWidth_mm')) > 0) {
                        //initHeightMM = $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm');
                        initWidthMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm'));
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm') && parseFloat($('.temselect[data-value="' + template +'"]').first().attr('data-maxWidth_mm')) > 0 && initWidthMM > $('.temselect[data-value="' + template +'"]').first().attr('data-maxWidth_mm')) {
                        initWidthMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm'));
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-initHeight_mm') && parseFloat($('.temselect[data-value="' + template +'"]').first().attr('data-initHeight_mm')) > 0) {
                        //initHeightMM = $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm');
                        initHeightMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initHeight_mm'));
                        initHeightPrint = initHeightMM;
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm') && parseFloat($('.temselect[data-value="' + template +'"]').first().attr('data-maxHeight_mm')) > 0 && initHeightMM > $('.temselect[data-value="' + template +'"]').first().attr('data-maxHeight_mm')) {
                        initHeightMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm'));
                    }
                break;
                case '4':
                    initWidthMM = 90;
                    initHeightMM = 180;
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-type') == 'stick') {
                        initHeightMM = 180;
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm') && parseFloat($('.temselect[data-value="' + template +'"]').first().attr('data-initWidth_mm')) > 0) {
                        //initHeightMM = $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm');
                        initWidthMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initWidth_mm'));
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm') && parseFloat($('.temselect[data-value="' + template +'"]').first().attr('data-maxWidth_mm')) > 0 && initWidthMM > $('.temselect[data-value="' + template +'"]').first().attr('data-maxWidth_mm')) {
                        initWidthMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxWidth_mm'));
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-initHeight_mm') && parseFloat($('.temselect[data-value="' + template +'"]').first().attr('data-initHeight_mm')) > 0) {
                        //initHeightMM = $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm');
                        initHeightMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-initHeight_mm'));
                        initHeightPrint = initHeightMM;
                    }
                    if (template && $('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm') && parseFloat($('.temselect[data-value="' + template +'"]').first().attr('data-maxHeight_mm')) > 0 && initHeightMM > parseFloat($('.temselect[data-value="' + template +'"]').first().attr('data-maxHeight_mm'))) {
                        initHeightMM = parseFloat($('.temselect[data-value="' + template + '"]').first().attr('data-maxHeight_mm'));
                    }
                break;

                default:
                    initWidthMM = 95;
                    initHeightMM = 140;
                    break;
                }
                if (pixratio) {
                    initHeightMM = initWidthMM / pixratio;
                }
            }
            if (motivp && pmo[motivp][motivi].newPxWidth) {
                initWidthMM = parseFloat(pmo[motivp][motivi].newPxWidth * pmo[motivp][motivi].mm2pxFactor * pmo[motivp][motivi].imageFactor);
                initHeightMM = parseFloat(pmo[motivp][motivi].newPxHeight * pmo[motivp][motivi].mm2pxFactor * pmo[motivp][motivi].imageFactor);
                if (textrows) {
                    //scale = pmo[motivp][motivi].newPxWidth / pmo[motivp][motivi].aktWidth_px;
                    scale = 1;
                    pmo[motivp][motivi].scale = scale;
                    aoData.push({'name': 'scale', 'value': scale});
                }
            } else if (motivp && pmo[motivp][motivi].aktWidth_px) {
                initWidthMM = parseFloat(pmo[motivp][motivi].aktWidth_px * pmo[motivp][motivi].mm2pxFactor);
                initHeightMM = parseFloat(pmo[motivp][motivi].aktHeight_px * pmo[motivp][motivi].mm2pxFactor);
                if (tmpPos && tmpPos.newPxWidth) {
                    initWidthMM = parseFloat(tmpPos.newPxWidth * pmo[motivp][motivi].mm2pxFactor * pmo[motivp][motivi].imageFactor);
                    initHeightMM = parseFloat(tmpPos.newPxHeight * pmo[motivp][motivi].mm2pxFactor * pmo[motivp][motivi].imageFactor);
                    tmpPos.newPxWidth = false;
                    tmpPos.newPxHeight = false;
                }
            }
            if (motivp && motivi && pmo[motivp][motivi] && pmo[motivp][motivi].isClone && pmo[motivp][motivi].isClone === true) {
                initWidthMM = pmo[motivp][motivi].grundWidth_mm;
                initHeightMM = pmo[motivp][motivi].grundHeight_mm;
            }
            if (isReload === true && !isMover) {
                initWidthMM = pmo[motivp][motivi].grundWidth_mm;
                initHeightMM = pmo[motivp][motivi].grundHeight_mm;
            }
            if (motivp && motivi && pmo[motivp][motivi].isClone !== true) {
                oldid = pmo[motivp][motivi].imageid;
            }
            if (motivp && motivi && pmo[motivp][motivi].uniqueGruppe) {
                uniqueGruppe = pmo[motivp][motivi].uniqueGruppe;
            }
            if (isReload) {
                aoData = pmo[motivp][motivi].aoData;
            } else {
                if (motivp && motivi && pmo[motivp][motivi] && pmo[motivp][motivi].initialApiWidth && pmo[motivp][motivi].templateTyp == 'stick') {
                    if (pmo[motivp][motivi].wFactor && pmo[motivp][motivi].initialApiWidth > pmo[motivp][motivi].apiWidth && !pmo[motivp][motivi].newPxWidth) {
                        initWidthMM = pmo[motivp][motivi].initialApiWidth / initWidthMM * initWidthMM / 10;
                    } else if (pmo[motivp][motivi].wFactor && pmo[motivp][motivi].wFactor < 1) {
                        initWidthMM = pmo[motivp][motivi].initialApiWidth / initWidthMM * initWidthMM / 10 / pmo[motivp][motivi].wFactor;
                    } else if (pmo[motivp][motivi].wFactor && pmo[motivp][motivi].wFactor > 1) {
                        initWidthMM = pmo[motivp][motivi].initialApiWidth / initWidthMM * initWidthMM / 10;
                    } else {
                        initWidthMM = pmo[motivp][motivi].initialApiWidth / initWidthMM * initWidthMM / 10;
                    }
                }
                if (motivp && motivi && pmo[motivp][motivi] && pmo[motivp][motivi].initialApiHeight && pmo[motivp][motivi].templateTyp == 'stick') {
                    if (pmo[motivp][motivi].hFactor && pmo[motivp][motivi].initialApiHeight > pmo[motivp][motivi].apiHeight && !pmo[motivp][motivi].newPxHeight) {
                        initHeightMM = pmo[motivp][motivi].initialApiHeight / initHeightMM * initHeightMM / 10;
                    } else if (pmo[motivp][motivi].hFactor && pmo[motivp][motivi].hFactor < 1) {
                        initHeightMM = pmo[motivp][motivi].initialApiHeight / initHeightMM * initHeightMM / 10 / pmo[motivp][motivi].hFactor;
                    } else if (pmo[motivp][motivi].hFactor && pmo[motivp][motivi].hFactor > 1) {
                        initHeightMM = pmo[motivp][motivi].initialApiHeight / initHeightMM * initHeightMM / 10;
                    } else {
                        initHeightMM = pmo[motivp][motivi].initialApiHeight / initHeightMM * initHeightMM / 10;
                    }
                }
                if (res) {
                    initWidthMM = res.post.widthMM;
                    initHeightMM = res.post.heightMM;
                }
                aoData.push({'name': 'widthMM', 'value': Math.round(initWidthMM)});
                aoData.push({'name': 'heightMM', 'value': Math.round(initHeightMM)});
            }
            if (res) {
                initWidthMM = res.post.widthMM;
                initHeightMM = res.post.heightMM;
            }
            if (motivp && pmo[motivp][motivi].newPxWidth) {
                delete pmo[motivp][motivi].newPxWidth;
                delete pmo[motivp][motivi].newPxHeight;
            }
            if (!isReload && hasText === false && hasElements === false && $('.detselect').length) {
                $.loadOverlay(true);
                return false;
            }
            if (1==2 && motivp && motivi && pmo[motivp] && pmo[motivp][motivi]) {
                if (initWidthMM) {
                    $.each(aoData, function (a) {
                        if(aoData[a]){
                            if (aoData[a].name == 'previewWidth' || aoData[a].name == 'previewHeight') {
                                delete aoData[a];
                            }
                        }
                    });
                    aoData.push({'name': 'previewWidth', 'value': parseInt(initWidthMM / pmo[motivp][motivi].mm2pxFactor / pmo[motivp][motivi].imageFactor, 10)});
                    aoData.push({'name': 'previewHeight', 'value': parseInt(initHeightMM / pmo[motivp][motivi].mm2pxFactor / pmo[motivp][motivi].imageFactor, 10)});
                }
            }

            if (!res) {
                url = '/ajax/ajax_update_designer.php?language=' + $('html').attr('lang');
                xhr[ajaxId] = $.ajax({
                    dataType: 'json',
                    type: 'POST',
                    url: url,
                    async: true,
                    data: aoData,
                    success: function (res) {
                        $.buildMotive(isText, uploadTrim, uploaduuid, res, motivp, motivi, acP, aPT, renew, oldid, drgebiet,
                        		initWidthMM, initHeightMM, isReload, template, aoData, isMover, initHeightPrint, uniqueGruppe);
                        $.loadMotiveDragger();
                    }
                });
            } else {
            	$.buildMotive(isText, uploadTrim, uploaduuid, res, motivp, motivi, acP, aPT, renew, oldid, drgebiet, initWidthMM, initHeightMM, isReload, template, aoData, isMover, initHeightPrint, uniqueGruppe);
                $.loadMotiveDragger();
            }

        };
        $.motRuler = function (element) {
            var rotWidth, rotHeight, rotation, relDiv, relImg, hide = {}, prefix = '', stageHolder, v1, v2, v3, v4, v5, v6, v1l, v2l, v3l, v4l, v5l, v6l, line, midLeft, midLeftAdd, active, activeLeft, activeWidth, activeTop, activeHeight;
            active = $('.motivImage').find('.ovholder.active');
            prefix = 'ad' + active.attr('data-id');
            if (element && element.attr('data-id') !== active.attr('data-id')) {
                active = element;
                prefix = 'ad' + active.attr('data-id');
                prefix = prefix + ' brightline';
            }
            $('.tmp.' + prefix).hide();
            relImg = active.closest('.stageHolder').find('.rpcol');
            relDiv = active.closest('.stageHolder').find('.drov');
            if (!active.position()) {
                return false;
            }
            activeLeft = active.position().left + relDiv.position().left;
            activeTop = active.position().top + relDiv.position().top;
            activeWidth = active.width();
            activeHeight = active.height();
            if (active.attr('data-rotation') && active.attr('data-rotation') !== '0') {
                rotation = parseInt(active.attr('data-rotation'), 10);
                rotWidth = ((activeWidth * Math.abs(Math.cos(rotation * Math.PI / 180))) + (activeHeight * Math.abs(Math.sin(rotation * Math.PI / 180))));
                rotHeight = ((activeWidth * Math.abs(Math.sin(rotation * Math.PI / 180))) + (activeHeight * Math.abs(Math.cos(rotation * Math.PI / 180))));

                activeWidth = rotWidth;
                activeHeight = rotHeight;
            }
            midLeft = relImg.width() / 2 + relImg.position().left;
            midLeftAdd = Math.round(((midLeft - (activeLeft + activeWidth)) * 2) + activeWidth);
            stageHolder = active.closest('.stageHolder');
            line = $('.mh1.' + prefix).show();
            if (!line.length) {
                line = $('<div />').width('100%').addClass('tmp motruler mvx mh1 ' + prefix).css('left', 0);
                stageHolder.append(line);
            }
            line.css('top', parseInt(activeTop - 2, 10));

            line = $('.mh2.' + prefix).show();
            if (!line.length) {
                line = $('<div />').width('100%').addClass('tmp motruler mvx mh2 ' + prefix).css('left', 0);
                stageHolder.append(line);
            }
            line.css('top', parseInt(activeTop + activeHeight + 2, 10));

            line = $('.mh3.' + prefix).show();
            if (!line.length) {
                line = $('<div />').width('100%').addClass('tmp motruler mvx mh3 ' + prefix).css('left', 0);
                stageHolder.append(line);
            }
            line.css('top', parseInt(activeTop + activeHeight / 2, 10));
            v1 = $('.mv1.' + prefix).show();
            v2 = $('.mv1.mirrorline.' + prefix).show();
            if (!v2.length) {
                v2 = $('<div />').addClass('tmp motruler mv1 ' + prefix + ' mirrorline').height('100%').css('top', 0);
                if (!element) {
                    stageHolder.append(v2);
                }
            }
            if (!v1.length) {
                v1 = $('<div />').addClass('tmp motruler mv1 ' + prefix + ' mvy').height('100%').css('top', 0);
                stageHolder.append(v1);
            }
            v1l = Math.round(activeLeft - 2);
            v2l = v1l + midLeftAdd;
            v1.css('left', v1l);
            v2.css('left', v2l);
            v3 = $('.mv2.' + prefix).show();
            v4 = $('.mv2.mirrorline.' + prefix).show();
            if (!v4.length) {
                v4 = $('<div />').addClass('tmp motruler mv2 ' + prefix + ' mirrorline').height('100%').css('top', 0);
                if (!element) {
                    stageHolder.append(v4);
                }
            }
            if (!v3.length) {
                v3 = $('<div />').addClass('tmp motruler mv2 ' + prefix + ' mvy').height('100%').css('top', 0);
                stageHolder.append(v3);
            }
            v3l = Math.round(activeLeft + activeWidth + 2);
            v4l = v3l + midLeftAdd;
            v3.css('left', v3l);
            v4.css('left', v4l);
            v5 = $('.mv3.' + prefix).show();
            v6 = $('.mv3.mirrorline.' + prefix).show();
            if (!v6.length) {
                v6 = $('<div />').addClass('tmp motruler mv3 ' + prefix + ' mirrorline').height('100%').css('top', 0);
                if (!element) {
                    stageHolder.append(v6);
                }
            }
            if (!v5.length) {
                v5 = $('<div />').addClass('tmp motruler mv3 ' + prefix + ' mvy').height('100%').css('top', 0);
                stageHolder.append(v5);
            }
            v5l = Math.round(activeLeft + activeWidth / 2);
            v6l = v5l + midLeftAdd;
            v5.css('left', v5l);
            v6.css('left', v6l);
            if (!element) {
                stageHolder.find('.mvy.' + prefix).each(function () {
                    var left = parseInt($(this).css('left'), 10), tolerance = 1;
                    if (left >= v2l - tolerance && left <= v2l + tolerance) {
                        $(this).addClass('mirrorkong');
                        hide[1] = v2;
                    } else if (left >= v4l - tolerance && left <= v4l + tolerance) {
                        $(this).addClass('mirrorkong');
                        hide[2] = v4;
                    } else if (left >= v6l - tolerance && left <= v6l + tolerance) {
                        $(this).addClass('mirrorkong');
                        hide[3] = v6;
                    } else {
                        $(this).removeClass('mirrorkong');
                        $('.mirrorline').show();
                    }
                });
                $.each(hide, function (a) {
                    hide[a].hide();
                });
            }
        };
        $.updateCreation = function () {
            if ($.active > 0) {
                window.setTimeout($.updateCreation, 10);
            } else {
                var checkData = {}, muri, akObject, surl;
                muri =  $('#turl').attr('data-url');
                surl = $('#turl').attr('data-surl');
                checkData.uri = surl + muri;
                if (!$.isEmptyObject(pmo)) {
                    checkData.motives = JSON.stringify(pmo);
                }
                akObject = $.createAkObject();
                checkData.produktDetails = akObject;

                xhruc = $.ajax({
                    dataType: 'json',
                    type: 'POST',
                    url: '/ajax/ajax_update_designer.php?action=uc&language=' + $('html').attr('lang'),
                    data: checkData,
                    success: function (ddd) {
                        var uri, qrcode, htmlimg = $('<span />').hide(), smallimg, set = {}, img, imgsrc = $('<img />');
                        uri = muri + '/' + ddd.p.uuid;
                        qrcode = '/images/qrcodes/' + ddd.p.qrcode;
                        $('#qrcode').attr('src', qrcode);
                        $('#qrcode').attr('data-uuid', ddd.p.uuid);
                        $('#qrcode').closest('div').show();
                        if (ddd.akp) {
                            $.each(ddd.akp, function (e) {
                                var img, imgsrc = $('<img />');
                                imgsrc.attr('src', $('span[data-id="imageScript"]').attr('data-val') + '?akPoId=' + ddd.akp[e].akPId + '&sId=' + $('span[data-id="shopId"]').attr('data-val') + '&maxWidth=60&maxHeight=60&pSize=1');
                                imgsrc.addClass('prdc');
                                //img = $('<a href="' + $('span[data-id="imageScript"]').attr('data-val') + '?akPoId=' + ddd.akp[e].akPId + '&sId=' + $('span[data-id="shopId"]').attr('data-val') + '&maxWidth=1000&maxHeight=1000&pSize=1" target="_blank"></a>');
                                img = $('<a href="' + $('span[data-id="imageScript"]').attr('data-val') + '?akPoId=' + ddd.akp[e].akPId + '&sId=' + $('span[data-id="shopId"]').attr('data-val') + '&maxWidth=1000&maxHeight=1000&pSize=1" target="_blank"></a>');
                                img.append(imgsrc);
                                htmlimg.append(img);
                            });
                            $('.prdc').imagesLoaded().done(function () {
                                $('.imgsharer').html('');
                                $('.imgsharer').html(htmlimg.show().html()).show();
                            });
                        } else {
                            imgsrc.attr('src', $('.rpcol').first().attr('src') + '&width=60&height=60&maxWidth=60&maxHeight=60');
                            imgsrc.addClass('prdc');
                            img = $('<a href="' + $('.rpcol').first().attr('src') + '&width=1000&height=1000&maxWidth=1000&maxHeight=1000&pSize=1" target="_blank"></a>');
                            img.append(imgsrc);
                            htmlimg.append(img);
                            $('.prdc').imagesLoaded().done(function () {
                                $('.imgsharer').html('');
                                $('.imgsharer').html(htmlimg.show().html()).show();
                            });
                        }
                        if (ddd.preise && pmo) {
                            $.each(pmo, function (a) {
                                $.each(pmo[a], function (b) {
                                    $.each(ddd.preise, function (c) {
                                        if (ddd.preise[c].apiId == pmo[a][b].sid && ddd.preise[c].acP == pmo[a][b].acP && !set[a + '-' + b]) {
                                            pmo[a][b].price = ddd.preise[c].preis;
                                            $.updatePriceDiv();
                                            delete ddd.preise[c];
                                            set[a + '-' + b] = a + '-' + b;
                                        }
                                    });
                                });
                            });
                        } else {
                            $.updatePriceDiv();
                        }
                        $('#fbsharer').attr('href', 'https://www.facebook.com/sharer/sharer.php?u=' + surl + uri);
                        $('#fbsharer').attr('data-id', ddd.p.uuid);
                        $('#twsharer').attr('href', 'https://twitter.com/share?hashtags=' + sprache.hashtags + '&url=' + surl + uri);
                        $('#twsharer').attr('data-id', ddd.p.uuid);
                        $('#insharer').attr('data-id', ddd.p.uuid);
                        $('#bthp').attr('data-id', ddd.p.uuid);
                        $('#bthpp').attr('data-id', ddd.p.uuid);
                        $('#dUuid').attr('data-uuid', ddd.p.uuid);
                        $('#sasa').attr('data-id', ddd.p.uuid);
                        if (ddd.akp) {
                            $('#insharer').attr('href', '//de.pinterest.com/pin/create/button/?url=' + encodeURIComponent(surl + uri) + '&description=' + $('#arthead').text() + '&media=' + encodeURIComponent($('span[data-id="imageScript"]').attr('data-val') + '?akPoId=' + ddd.akp[0].akPId + '&sId=' + $('span[data-id="shopId"]').attr('data-val') + '&maxWidth=250&maxHeight=250&pSize=1'));
                        }
                        if ($('.body_motivDesigner').length && typeof (window.history.pushState) === 'function') {
                            history.pushState({id: location.pathname}, document.title, location.pathname);
                            history.pushState({id: surl + uri}, '', surl + uri);
                        }
                        $('.langswitch').find('a').each(function () {
                            $(this).attr('href', $(this).attr('data-prefix') + uri.replace($('#turl').attr('data-prefix'), '/').replace('//', '/'));
                        });
                        $('.topbox').find('a').each(function () {
                            if ($(this).attr('data-cr') && $(this).closest('.fleinner').find('.gebiet').length) {
                                $(this).attr('href', $(this).attr('data-cr') + ddd.p.uuid);
                            }
                        });
                        $('.otpro').find('a').each(function () {
                            if ($(this).attr('data-cr')) {
                                $(this).attr('href', $(this).attr('data-cr') + ddd.p.uuid);
                            }
                        });
                        if (!$('.motivImage').find('.ovholder.active[data-ptyp="text"]').length) {
                            $.checkNeededDivs();
                        }
                        if ($('.motivImage').find('.ovholder.active[data-ptyp="upload"]').length || $('.motivImage').find('.ovholder.active[data-ptyp="text"]').length) {
                            $.activateMotive($('.motivImage').find('.ovholder.active'));
                        }else {
                            if(!$('.motivImage').find('.ovholder.active').length){
                                //klick first possible motive
                                $.each(pmo, function (a) {
                                    $.each(pmo[a], function (b) {
                                        if (pmo[a][b].defMot && (pmo[a][b].editable == 1 || pmo[a][b].deleteable == 1)) {
                                            $.activateMotive($('.motivImage').find('.ovholder[data-auid="' + pmo[a][b].ajaxId + '"]'));
                                            return true;
                                        }
                                    })
                                });
                            }
                        }
                        $.initTooltipster();

                        clearTimeout(ttTimer);
                        ttTimer = setTimeout(function () {
                            $.loadOverlay(true);
                        }, 300);

                        if(needsMovement === true){
                            needsMovement = false;
                            var widget = $('.ovholder.active');
                            if(widget.attr('data-ptyp') == 'text'){
                                widget.simulate('drag', {
                                    dx: dmdx,
                                    moves: 1
                                });
                                dmdx = dmdx * -1;
                            }
                        }
                    }
                });
            }
        };
        $.checkUploadQuality = function(widthPx, widthMM) {
            var resultX, result = [], text;
            resultX = parseInt(widthPx / (widthMM / 10), 10);
            result.percent = resultX;
            $('.active').find('.activewrapper').removeClass('qualityError');
            switch (true) {
            case (resultX > 100):
                result.text = 'perfekteQualitaet';
                result.percent = 100;

                break;
            case (resultX > 60):
                result.text = 'guteQualitaet';
                break;
            case (resultX > 38):
                result.text = 'minimumQualitaet';
                break;
            default:
                result.text = 'schlechteQualitaet';
                $('.active').find('.activewrapper').addClass('qualityError');
                break;
            }
            if(sprache[result.text]){
                text = sprache[result.text];
                $('#qualitytext').html(text);
            }
            //$('.qbarres').find('span').text(result.percent + '%');
            $('.qbarres').css('left', result.percent + '%');
            return result;
        };
        $.checkPosition = function (noCc, id) {
                var div, diameter = 12, blinktime = 600, dataacPt, aId, active = $('.motivImage').find('.ovholder.active'), checkData = {}, dataacP, dataposIndex, relImgFactor;
                if (id && $('.motivImage').find('.ovholder[data-auid="' + id + '"]').length) {
                    active = $('.motivImage').find('.ovholder[data-auid="' + id + '"]');
                }
                dataposIndex = active.attr('data-posIndex');
                dataacP = active.attr('data-pos');
                dataacPt = active.attr('data-posTyp');
                aId = $('#arthead').attr('data-aId');
                pmo[dataacP][dataposIndex].hasCollision = false;
                relImgFactor = 520 / $('.motivImage').find('.flexible.rpcol').width();
                checkData.left = $.bizRound((active.position().left + $('.motivImage').find('.drov').position().left - $('.motivImage').find('.flexible.rpcol').position().left) * relImgFactor);
                checkData.top = $.bizRound((active.position().top  + $('.motivImage').find('.drov').position().top - $('.motivImage').find('.flexible.rpcol').position().top) * relImgFactor);
                checkData.rotation = pmo[dataacP][dataposIndex].rotation;
                checkData.motive = pmo[dataacP][dataposIndex].img + '&width=' + pmo[dataacP][dataposIndex].aktWidth_px;
                aId = aId.split('-');
                aId = aId[0];
                checkData.position = aId + '_' + dataacPt;

                pmo[dataacP][dataposIndex].hasCollision = false;
                if(Math.ceil(checkData.left) >= 520){
                    pmo[dataacP][dataposIndex].hasCollision = true;
                    div = $('<div />');
                    div
                        .addClass('tmp errorpoint')
                        .attr('data-title', 'Das Motiv liegt ausserhalb vom ' + pmo[dataacP][dataposIndex].label + '-Bereich.<br />Der ' + pmo[dataacP][dataposIndex].label + '-Bereich wird durch die Einfärbung über dem Artikel angezeigt.<br />Innerhalb vom ' + pmo[dataacP][dataposIndex].label + '-Bereich kann das Motiv frei positioniert werden.')
                        .width(diameter)
                        .height(diameter)
                        .css('position', 'absolute')
                        .css('zIndex', 4985)
                        .css('top', (checkData.top / parseFloat(520 / $('.motivImage').find('.flexible.rpcol').width()) - (diameter / 2) + $('.ccHolder').closest('.motivImage').find('.flexible.rpcol').position().top))
                        .css('border-radius', diameter)
                        .css('left', (checkData.left / parseFloat(520 / $('.motivImage').find('.flexible.rpcol').width()) - (diameter / 2) + $('.ccHolder').closest('.motivImage').find('.flexible.rpcol').position().left));
                    $('.ccHolder').closest('.motivImage').append(div);
                    div.fadeOut(blinktime, function () {
                        $(this).fadeIn(blinktime, function () {
                            $(this).fadeOut(blinktime, function () {
                                $(this).fadeIn(blinktime);
                            });
                        });
                    });
                    $('.motruler').hide();

                    if (!$('.motivImage').find('.ovholder.active').html()) {
                        active.addClass('active');
                        active.find('.outerhelper').show();
                    }
                    if (!noCc) {
                        $.updateCreation();
                    }

                    return;
                }

                if (pmo[dataacP][dataposIndex].uploaduuid && pmo[dataacP][dataposIndex].origWidth && pmo[dataacP][dataposIndex].origHeight) {
                    $.checkUploadQuality(pmo[dataacP][dataposIndex].origWidth, pmo[dataacP][dataposIndex].grundWidth_mm);
                }
                if (!$('.ccHolder').closest('.motivImage').find('.flexible.rpcol').length) {
                    return;
                }
                $('.tmp').remove();
                if(typeof xhrcc != 'undefined'){
                	var xhrcc;
                }
                xhrcc = $.ajax({
                    dataType: 'json',
                    type: 'POST',
                    url: '/ajax/ajax_update_designer.php?action=cc&language=' + $('html').attr('lang'),
                    data: checkData,
                    success: function (ddd) {
                        var div, diameter = 12, blinktime = 600;
                        if (ddd.koords !== undefined && ddd.koords !== true) {
                            $('.ccHolder').show();
                            pmo[dataacP][dataposIndex].hasCollision = true;
                            div = $('<div />');
                            div
                                .addClass('tmp errorpoint')
                                .attr('data-title', 'Das Motiv liegt ausserhalb vom ' + pmo[dataacP][dataposIndex].label + '-Bereich.<br />Der ' + pmo[dataacP][dataposIndex].label + '-Bereich wird durch die Einfärbung über dem Artikel angezeigt.<br />Innerhalb vom ' + pmo[dataacP][dataposIndex].label + '-Bereich kann das Motiv frei positioniert werden.')
                                .width(diameter)
                                .height(diameter)
                                .css('position', 'absolute')
                                .css('zIndex', 4985)
                                .css('top', (ddd.koords[1] / parseFloat(520 / $('.motivImage').find('.flexible.rpcol').width()) - (diameter / 2) + $('.ccHolder').closest('.motivImage').find('.flexible.rpcol').position().top))
                                .css('border-radius', diameter)
                                .css('left', (ddd.koords[0] / parseFloat(520 / $('.motivImage').find('.flexible.rpcol').width()) - (diameter / 2) + $('.ccHolder').closest('.motivImage').find('.flexible.rpcol').position().left));
                            $('.ccHolder').closest('.motivImage').append(div);
                            div.fadeOut(blinktime, function () {
                                $(this).fadeIn(blinktime, function () {
                                    $(this).fadeOut(blinktime, function () {
                                        $(this).fadeIn(blinktime);
                                    });
                                });
                            });
                        } else {
                            if (dataacP && pmo[dataacP] && pmo[dataacP][dataposIndex]) {
                                pmo[dataacP][dataposIndex].hasCollision = false;
                            }
                            $('.ccHolder').hide();
                        }
                        if (!$('.motivImage').find('.ovholder.active').html()) {
                            active.addClass('active');
                            active.find('.outerhelper').show();
                        }
                        if (!noCc) {
                            $.updateCreation();
                        }

                        //$.initTooltipster();

                        if (realActive && $('.motivImage').find('.ovholder[data-auid="' + realActive + '"]').length && !$('.motivImage').find('.ovholder[data-auid="' + realActive + '"]').hasClass('active')) {
                            $('.motivImage').find('.ovholder[data-auid="' + realActive + '"]').trigger('click');
                        }

                        $('input[name="color"]').each(function () {
                            var color;
                            color = $(this).val();
                            if (color == 'ffffff') {
                                $(this).css('borderColor', '#000000');
                            } else if (color == '000000') {
                                $(this).css('borderColor', '#FFFFFF');
                            }
                        });

                    }
                });
        };
        $.loadMotiveDragger = function () {
            var initThumbLeft, initThumbTop, doMotruler = true, doDrop = true, dataacP, factor, targetRelImg, mainImgFactor, dataposIndex, resizefromcenter = false, startHeightMM;
            dataacP = $('#motivDesignerForm').attr('data-activePos');
            targetRelImg = $('.simage').find('.previewImg').first();
            factor = targetRelImg.width() / $('.flexible.rpcol').width();
            mainImgFactor = 520 / $('.flexible.rpcol').width();
            $('.motivImage').find('.resizable:visible').each(function () {
                if (!$(this).data('ui-resizable')) {
                    if ($(this).data('ui-resizable')) {
                        $(this).resizable('destroy');
                    }
                    if (!$(this).find('.resser').length) {
                        $.addIconHelper('resser ui-resizable-handle', {right: -18, bottom: -18 }, {'data-title': 'Skalieren'}, 'arrow-2-se-nw', $(this));
                    }

                    //$.initTooltipster();

                    $(this).resizable({
                        //containment: '.motivImage .drov',
                        containment: 'document',
                        aspectRatio: true,
                        grid: 1,
                        handles: {'se': '.resser.ui-resizable-handle'},
                        autoHide: false,
                        disabled: false,
                        start: function (event, ui) {
                            var target = $('.jsMsThumbs div[data-id="' + $(event.target).attr('data-id') + '"]'), center, motCenter, top, left;
                            if (!$(event.target).hasClass('active')) {
                                $.activateMotive(event.target);
                            }
                            left = parseInt($(this).css('left'),10);
                            left = isNaN(left) ? 0 : left;
                            top = parseInt($(this).css('top'),10);
                            top = isNaN(top) ? 0 : top;
                            recoupLeft = left - ui.position.left;
                            recoupTop = top - ui.position.top;

                            dataposIndex = $(event.target).attr('data-posIndex');
                            target.closest('.simage').find('.motov[data-id="' + pmo[dataacP][dataposIndex].imageid + '"]').find('.ovimga').attr('src', $(event.target).find('.ovimga').attr('src'));
                            $(this).find('.activewrapper').css('borderColor', 'transparent');
                            //$('.outerhelper').hide();
                            $('.errorpoint').remove();
                            center = Math.round($('.motivImage').find('.drov').width() / 2);
                            motCenter = Math.round(ui.position.left - $('.drov').position().left + $(this).width() / 2 + $('.drov').position().left);
                            //if ((motCenter >= center - 2) && (motCenter <= center + 2) || (pmo[dataacP][dataposIndex].rotation > 0 || pmo[dataacP][dataposIndex].rotation < 0)) {
                            if ((motCenter >= center - 2) && (motCenter <= center + 2)) {
                                $(this).resizable('option', 'resizefromcenter', true);
                                resizefromcenter = true;
                            } else {
                                $(this).resizable('option', 'resizefromcenter', false);
                                resizefromcenter = false;
                            }
                            mm2pxFactor = pmo[dataacP][dataposIndex].mm2pxFactor;
                            mm2pxFactorScaled = mm2pxFactor * mainImgFactor;

                            if (!pmo[dataacP][dataposIndex].text) {
                                $(this).resizable('option', 'minWidth', Math.round(90 / mm2pxFactorScaled));
                                $(this).resizable('option', 'minHeight', 1);
                                if (pmo[dataacP][dataposIndex].aPT == 3 || pmo[dataacP][dataposIndex].aPT == 4) {
                                    $(this).resizable('option', 'maxWidth', Math.round(100 / mm2pxFactorScaled));
                                    //$(this).resizable('option', 'maxHeight', Math.round(110 / mm2pxFactorScaled));
                                } else if (pmo[dataacP][dataposIndex].templateTyp == 'stick' && (pmo[dataacP][dataposIndex].aPT == 1 || pmo[dataacP][dataposIndex].aPT == 2)) {
                                    $(this).resizable('option', 'maxWidth', Math.round(290 / mm2pxFactorScaled));
                                    $(this).resizable('option', 'maxHeight', Math.round(270 / mm2pxFactorScaled));
                                } else if ((pmo[dataacP][dataposIndex].templateTyp == 'druck' || pmo[dataacP][dataposIndex].templateTyp == 'upload') && (pmo[dataacP][dataposIndex].aPT == 1 || pmo[dataacP][dataposIndex].aPT == 2)) {
                                    $(this).resizable('option', 'minWidth', Math.round(70 / mm2pxFactorScaled));
                                    $(this).resizable('option', 'maxWidth', Math.round(350 / mm2pxFactorScaled));
                                    $(this).resizable('option', 'maxHeight', Math.round(450 / mm2pxFactorScaled));
                                } else if (pmo[dataacP][dataposIndex].templateTyp == 'druck' && (pmo[dataacP][dataposIndex].aPT == 3 || pmo[dataacP][dataposIndex].aPT == 4)) {
                                    $(this).resizable('option', 'minWidth', Math.round(70 / mm2pxFactorScaled));
                                } else {
                                    $(this).resizable('option', 'minWidth', Math.round(10 / mm2pxFactorScaled));
                                    $(this).resizable('option', 'maxWidth', Math.round(270 / mm2pxFactorScaled));
                                    $(this).resizable('option', 'minHeight', Math.round(10 / mm2pxFactorScaled));
                                    $(this).resizable('option', 'maxHeight', Math.round(270 / mm2pxFactorScaled));
                                }
                                if (pmo[dataacP][dataposIndex].wFactor && pmo[dataacP][dataposIndex].wFactor < 1) {
                                    $(this).resizable('option', 'minWidth', Math.round(90 * pmo[dataacP][dataposIndex].wFactor / mm2pxFactorScaled));
                                }
                                if ($('.temselect[data-value="' +  pmo[dataacP][dataposIndex].template + '"]').attr('data-maxWidth_mm')) {
                                    $(this).resizable('option', 'maxWidth', Math.round($('.temselect[data-value="' +  pmo[dataacP][dataposIndex].template + '"]').attr('data-maxWidth_mm') / mm2pxFactorScaled));
                                }
                                if ($('.temselect[data-value="' +  pmo[dataacP][dataposIndex].template + '"]').attr('data-minWidth_mm')) {
                                    $(this).resizable('option', 'minWidth', Math.round($('.temselect[data-value="' +  pmo[dataacP][dataposIndex].template + '"]').attr('data-minWidth_mm') / mm2pxFactorScaled));
                                }
                                if ($('.temselect[data-value="' +  pmo[dataacP][dataposIndex].template + '"]').attr('data-minHeight_mm')) {
                                    $(this).resizable('option', 'minHeight', Math.round($('.temselect[data-value="' +  pmo[dataacP][dataposIndex].template + '"]').attr('data-minHeight_mm') / mm2pxFactorScaled));
                                    $(this).resizable('option', 'minWidth', Math.round(10 / mm2pxFactorScaled));
                                }
                                if ($('.temselect[data-value="' +  pmo[dataacP][dataposIndex].template + '"]').attr('data-maxHeight_mm')) {
                                    $(this).resizable('option', 'maxHeight', Math.round($('.temselect[data-value="' +  pmo[dataacP][dataposIndex].template + '"]').attr('data-maxHeight_mm') / mm2pxFactorScaled));
                                }
                                //druck immer, wird ansonsten vom collissionChecker...
                                if(pmo[dataacP][dataposIndex].templateTyp == 'druck'){
                                    $(this).resizable('option', 'maxWidth', Math.round(350 / mm2pxFactorScaled));
                                    $(this).resizable('option', 'maxHeight', Math.round(450 / mm2pxFactorScaled));
                                }
                            } else {
                                $(this).resizable('option', 'minWidth', Math.round(1 / mm2pxFactorScaled));
                                $(this).resizable('option', 'maxWidth', Math.round(270 / mm2pxFactorScaled));
                                $(this).resizable('option', 'minHeight', Math.round(1 / mm2pxFactorScaled));
                                $(this).resizable('option', 'maxHeight', Math.round(270 / mm2pxFactorScaled));
                                if(pmo[dataacP][dataposIndex].templateTyp == 'druck'){
                                    //druck immer, wird ansonsten vom collissionChecker...
                                    $(this).resizable('option', 'maxWidth', Math.round(450 / mm2pxFactorScaled));
                                    $(this).resizable('option', 'maxHeight', Math.round(450 / mm2pxFactorScaled));
                                }
                            }

                            //$(this).tooltipster('show');
                            //$(this).tooltipster('option', 'position', 'bottom');
                        },
                        stop: function (event, ui) {
                            var cssTop, cssLeft, rotWidth, rotHeight, centerX, centerY, angle, changeFactor;
                            dataposIndex = $(event.target).attr('data-posIndex');
                            if (resizefromcenter === true) {
                                cssTop = ui.position.top + ((ui.originalSize.height - ui.size.height)) / 2;
                                cssLeft = ui.position.left + ((ui.originalSize.width - ui.size.width)) / 2;
                                ui.position.left = cssLeft;
                                ui.position.top = cssTop;
                            }
                            if (pmo[dataacP][dataposIndex].rotation !== 0) {
                                angle = pmo[dataacP][dataposIndex].rotation;

                                ui.position.top = $(event.target).position().top;
                                ui.position.left = $(event.target).position().left;

                                pmo[dataacP][dataposIndex].aktLeft_px = ui.position.left * mainImgFactor;
                                pmo[dataacP][dataposIndex].aktTop_px = ui.position.top * mainImgFactor;
                                $(this).attr('data-initLeft', pmo[dataacP][dataposIndex].aktLeft_px);
                                $(this).attr('data-initTop', pmo[dataacP][dataposIndex].aktTop_px);
                                pmo[dataacP][dataposIndex].fixPointLeft = (ui.position.left + $(this).width() / 2) * mainImgFactor;
                                pmo[dataacP][dataposIndex].fixPointTop = (ui.position.top + $(this).height() / 2) * mainImgFactor;
                            }
                            if (pmo[dataacP][dataposIndex].templateTyp == 'stick') {
                                pmo[dataacP][dataposIndex].initialApiWidth = Math.round(ui.size.width * mm2pxFactorScaled) * 10;
                                pmo[dataacP][dataposIndex].initWidthHeightRatio = ui.size.width / ui.size.height;
                                pmo[dataacP][dataposIndex].initialApiHeight = Math.round(ui.size.height * mm2pxFactorScaled) * 10;
                                pmo[dataacP][dataposIndex].initHeightHeightRatio = ui.size.height / ui.size.height;
                            }
                            pmo[dataacP][dataposIndex].newPxWidth = ui.size.width;
                            pmo[dataacP][dataposIndex].newPxHeight = ui.size.height;
                            if (pmo[dataacP][dataposIndex].rotation == 0) {
                                pmo[dataacP][dataposIndex].fixPointLeft = (ui.position.left + ui.size.width / 2) * mainImgFactor;
                                pmo[dataacP][dataposIndex].fixPointTop = (ui.position.top + ui.size.height / 2) * mainImgFactor;
                            }
                            pmo[dataacP][dataposIndex].fixPointAlign = 'c';
                            pmo[dataacP][dataposIndex].aktLeft_px = ui.position.left * mainImgFactor;
                            pmo[dataacP][dataposIndex].aktTop_px = ui.position.top * mainImgFactor;
                            pmo[dataacP][dataposIndex].left_mm = pmo[dataacP][dataposIndex].aktLeft_px * pmo[dataacP][dataposIndex].mm2pxFactor;
                            pmo[dataacP][dataposIndex].top_mm = pmo[dataacP][dataposIndex].aktTop_px * pmo[dataacP][dataposIndex].mm2pxFactor;

                            tmpPos = {};
                            tmpPos.newPxWidth = pmo[dataacP][dataposIndex].newPxWidth;
                            tmpPos.newPxHeight = pmo[dataacP][dataposIndex].newPxHeight;

                            if (pmo[dataacP][dataposIndex].text) {
                                changeFactor = ui.size.height / ui.originalSize.height ;
                                $('.tformatholder').find('.fontsize').each(function () {
                                    var sliderValue = $(this).slider('value'), newValue;
                                    newValue = parseInt(sliderValue * changeFactor, 10);
                                    $(this).slider('value', newValue);
                                });
                            }
                            $.setMotive(dataacP, dataposIndex);
                            if(pmo[dataacP][dataposIndex].text){
                                needsMovement = true;
                            }

                            //$(this).tooltipster('hide');

                            $(this).find('.activewrapper').css('borderColor', '#777');
                            $(this).find('.outerhelper').show();
                        },
                        resize: function (event, ui) {
                            var left, top, width, height, cssTop, cssLeft, widthMM, heightMM, changeFactor, that, quality;
                            that = this;
                            dataposIndex = $(event.target).attr('data-posIndex');
                            ui.position.left += recoupLeft;
                            ui.position.top += recoupTop;
                            if (event.ctrlKey) {
                                $(this).resizable('option', 'resizefromcenter', true);
                                resizefromcenter = true;
                            }

                            widthMM = Math.round(ui.size.width * mm2pxFactorScaled);
                            heightMM = Math.round(ui.size.height * mm2pxFactorScaled);

                            //$(this).tooltipster('show');

                            if (widthMM && heightMM) {
                                /*
                                if (ui.size.width <= $(this).resizable('option', 'minWidth')) {

                                	$(this).tooltipster('content', 'die Mindestgröße wurde erreicht');

                                } else if (ui.size.width >= $(this).resizable('option', 'maxWidth')) {

                                	$(this).tooltipster('content', 'die Maximalbreite wurde erreicht');

                                } else if (ui.size.height >= $(this).resizable('option', 'maxHeight')) {

                                	$(this).tooltipster('content', 'die Maximalhöhe wurde erreicht');

                                } else {
                                    */

                                    if (pmo[dataacP][dataposIndex].uploaduuid && pmo[dataacP][dataposIndex].origWidth) {
                                        $.checkUploadQuality (pmo[dataacP][dataposIndex].origWidth, widthMM);
                                    }

                                    //$(this).tooltipster('content', 'ca. ' + widthMM + 'x' + heightMM + ' mm');

                                //}

                            }
                            if (pmo[dataacP][dataposIndex].text) {
                                changeFactor = ui.size.height / ui.originalSize.height;
                                $('.tformatholder').find('.fontsize').each(function () {
                                    var sliderValue = $(this).slider('value'), newValue;
                                    newValue = parseInt(sliderValue * changeFactor, 10);
                                    if (newValue <= 10) {
                                    	//$(this).tooltipster('content', 'die Mindestgröße wurde erreicht');
                                        $(that).resizable('option', 'minWidth', Math.round(widthMM / mm2pxFactorScaled));
                                    }
                                });
                            }
                            if (resizefromcenter === true || $(this).resizable('option', 'resizefromcenter') === true) {
                                cssTop = ui.position.top + ((ui.originalSize.height - ui.size.height)) / 2;
                                cssLeft = ui.position.left + ((ui.originalSize.width - ui.size.width)) / 2;
                                $(this).css({
                                    'top': cssTop,
                                    'left': cssLeft
                                });
                            } else {
                                cssTop = ui.position.top;
                                cssLeft = ui.position.left;
                            }
                            left = cssLeft * factor;
                            top = cssTop * factor;
                            width = ui.size.width * factor;
                            height = ui.size.height * factor;
                            $('.jsMsThumbs div[data-id="' + $(event.target).attr('data-id') + '"]').css('left', left).css('top', top).width(width).height(height);
                        }
                    });
                }
            });
            $('.draggable:visible').each(function () {
                if (!$(this).data('ui-draggable')) {
                    if ($(this).data('ui-draggable')) {
                        $(this).draggable('destroy');
                    }
                    var startWidth, drovs = {}, idi = 0;
                    $(this).draggable({
                        grid: [ 1, 1 ],
                        revert: 'invalid',
                        delay: 0,
                        //handle: '.activewrapper',
                        scroll: false,
                        start: function (event, ui) {
                            var left, top;
                            if (!$(event.target).hasClass('active')) {
                                $.activateMotive(event.target);
                            }
                            left = parseInt($(this).css('left'),10);
                            left = isNaN(left) ? 0 : left;
                            top = parseInt($(this).css('top'),10);
                            top = isNaN(top) ? 0 : top;
                            recoupLeft = left - ui.position.left;
                            recoupTop = top - ui.position.top;

                            $(this).find('.activewrapper').css('borderColor', 'transparent');
                            $('.errorpoint').remove();
                            if (doMotruler === true) {
                                $('.ovholder').not('.active').each(function () {
                                    $.motRuler($(this));
                                });
                            }
                            $('.outerhelper').hide();
                            initThumbLeft = $('.jsMsThumbs div[data-id="' + $(event.target).attr('data-id') + '"]').position().left;
                            initThumbTop = $('.jsMsThumbs div[data-id="' + $(event.target).attr('data-id') + '"]').position().top;
                            $('.drov').each(function(){
                                startWidth = $(this).css('width');
                                drovs[idi] = {};
                                drovs[idi]['w'] = startWidth;
                                drovs[idi]['d'] = $(this);
                                idi = idi + 1;
                            });
                        },
                        drag: function (event, ui) {
                            var left, top, target;
                            ui.position.left += recoupLeft;
                            ui.position.top += recoupTop;
                            target = $('.jsMsThumbs div[data-id="' + $(event.target).attr('data-id') + '"]');
                            left = ui.position.left * factor;
                            top = ui.position.top * factor;
                            target.css('left', left).css('top', top);
                            if (doMotruler === true) {
                                $.motRuler();
                            }
                            $('.drov').css('width', '100%');
                        },
                        stop: function (event, ui) {
                            var center, motCenter, target;
                            $('.jsMsThumbs').find('.motov').show();
                            if (!pmo[dataacP]) {
                                return;
                            }
                            if (doDrop === false) {
                                target = $('.jsMsThumbs div[data-id="' + $(event.target).attr('data-id') + '"]');
                                target.css('left', initThumbLeft).css('top', initThumbTop);
                                $('.motruler').hide();
                                return;
                            }
                            ui.position.top = $(event.target).position().top;
                            ui.position.left = $(event.target).position().left;

                            dataposIndex = $(event.target).attr('data-posIndex');
                            if (!pmo[dataacP][dataposIndex]) {
                                return;
                            }
                            pmo[dataacP][dataposIndex].aktLeft_px = ui.position.left * mainImgFactor;

                            pmo[dataacP][dataposIndex].aktTop_px = ui.position.top * mainImgFactor;
                            $(this).attr('data-initLeft', pmo[dataacP][dataposIndex].aktLeft_px);
                            $(this).attr('data-initTop', pmo[dataacP][dataposIndex].aktTop_px);
                            pmo[dataacP][dataposIndex].fixPointLeft = (ui.position.left + $(this).width() / 2) * mainImgFactor;
                            pmo[dataacP][dataposIndex].fixPointTop = (ui.position.top + $(this).height() / 2) * mainImgFactor;
                            pmo[dataacP][dataposIndex].fixPointAlign = 'c';
                            pmo[dataacP][dataposIndex].left_mm = pmo[dataacP][dataposIndex].aktLeft_px * pmo[dataacP][dataposIndex].mm2pxFactor;
                            pmo[dataacP][dataposIndex].top_mm = pmo[dataacP][dataposIndex].aktTop_px * pmo[dataacP][dataposIndex].mm2pxFactor;
                            $.checkPosition(false, pmo[dataacP][dataposIndex].ajaxId);
                            $(this).find('.activewrapper').css('borderColor', '#777');
                            if ($(event.target).attr('data-scaleable') === '1') {
                                center = Math.round($('.motivImage').find('.flexible.rpcol').position().left + $('.motivImage').find('.flexible.rpcol').width() / 2);
                                motCenter = Math.round(ui.position.left - $('.flexible.rpcol').position().left + $(this).width() / 2 + $('.flexible.rpcol').position().left);
                                if ((motCenter >= center - 2) && (motCenter <= center + 2)) {
                                    $(this).resizable('option', 'resizefromcenter', true);
                                    resizefromcenter = true;
                                } else {
                                    $(this).resizable('option', 'resizefromcenter', false);
                                    resizefromcenter = false;
                                }
                            }
                            $.each(drovs, function (a) {
                                $(drovs[a].d).css('width', drovs[a].w);
                            });

                            $(this).find('.outerhelper').show();
                            $.doExistCheck();
                        }
                    });
                }
            });

            /*
            $('.rotatable').tooltip({
                items: '.resizable',
                track: false,
                show: true
            });
            */

            $('.rotatable').rotatable({
                create: function (event, ui) {
                    var rotation, icos;
                    if ($(event.target).attr('data-rotation')) {
                        rotation = $(event.target).attr('data-rotation');
                        rotation = $.bizRound(rotation) / 180 * Math.PI;
                        $(this).data('uiRotatable').angle(rotation);
                        icos = $(event.target).find('.ui-rotatable-handle, .resizer, .outerhelper');
                        rotation = rotation * -1;

                        icos.css('transform','rotate(' + rotation + 'rad)');
                        icos.css('-moz-transform','rotate(' + rotation + 'rad)');
                        icos.css('-webkit-transform','rotate(' + rotation + 'rad)');
                        icos.css('-o-transform','rotate(' + rotation + 'rad)');

                        rotation = 0;
                        $('.resser').css('transform','rotate(' + rotation + 'rad)');
                        $('.resser').css('-moz-transform','rotate(' + rotation + 'rad)');
                        $('.resser').css('-webkit-transform','rotate(' + rotation + 'rad)');
                        $('.resser').css('-o-transform','rotate(' + rotation + 'rad)');
                    }
                    $('.svgc').remove();
                },
                start: function (event, ui) {
                    $('.svgc').remove();
                    if (!$(event.target).hasClass('active')) {
                        $.activateMotive(event.target);
                    }
                    var target, circle, width, height, radius, svg, diameter, x, y;
                    target = $(event.target);
                    width = $(event.target).width();
                    height = $(event.target).height();

                    radius = 0.5 * Math.sqrt(width * width + height * height) + 2;
                    diameter = radius * 2 + 4;

                    x = width/2 - radius;
                    y = height/2 - radius;

                    $(this).tooltipster('show');

                    target.prepend('<svg class="svgc" style="left:' + x + 'px;top:' + y + 'px;position:absolute" height="' + diameter + '" width="' + diameter + '"><circle cx="' + radius + '" cy="' + radius + '" r="' + radius + '" stroke="green" stroke-width="1" fill="none" vector-effect="non-scaling-stroke"/></svg> ');
                },
                rotate: function (event, ui) {
                    // -ms-transform
                    var target, rad, icos;
                    target = $('.jsMsThumbs div[data-id="' + $(event.target).attr('data-id') + '"]');
                    rad = ui.angle.current;

                    $(this).tooltipster('show');
                    $(this).tooltipster('content', $.bizRound(ui.angle.current * 180 / Math.PI) +'°');

                    target.css('transform','rotate(' + rad + 'rad)');
                    target.css('-moz-transform','rotate(' + rad + 'rad)');
                    target.css('-webkit-transform','rotate(' + rad + 'rad)');
                    target.css('-o-transform','rotate(' + rad + 'rad)');

                    icos = $(event.target).find('.ui-rotatable-handle, .resizer, .outerhelper');
                    rad = rad * -1;

                    icos.css('transform','rotate(' + rad + 'rad)');
                    icos.css('-moz-transform','rotate(' + rad + 'rad)');
                    icos.css('-webkit-transform','rotate(' + rad + 'rad)');
                    icos.css('-o-transform','rotate(' + rad + 'rad)');

                    rad = 0;
                    $('.resser').css('transform','rotate(' + rad + 'rad)');
                    $('.resser').css('-moz-transform','rotate(' + rad + 'rad)');
                    $('.resser').css('-webkit-transform','rotate(' + rad + 'rad)');
                    $('.resser').css('-o-transform','rotate(' + rad + 'rad)');
                },
                stop: function (event, ui) {
                    var rotation = $.bizRound(ui.angle.current * 180 / Math.PI), icos, top, left;
                    dataposIndex = $(event.target).attr('data-posIndex');
                    pmo[dataacP][dataposIndex].rotation = rotation;
                    $(event.target).attr('data-rotation', rotation);

                    top = $(event.target).position().top;
                    left = $(event.target).position().left;

                    pmo[dataacP][dataposIndex].aktLeft_px = left * mainImgFactor;
                    pmo[dataacP][dataposIndex].aktTop_px = top * mainImgFactor;
                    $(this).attr('data-initLeft', pmo[dataacP][dataposIndex].aktLeft_px);
                    $(this).attr('data-initTop', pmo[dataacP][dataposIndex].aktTop_px);
                    pmo[dataacP][dataposIndex].fixPointLeft = (left + $(this).width() / 2) * mainImgFactor;
                    pmo[dataacP][dataposIndex].fixPointTop = (top + $(this).height() / 2) * mainImgFactor;
                    pmo[dataacP][dataposIndex].fixPointAlign = 'c';
                    pmo[dataacP][dataposIndex].left_mm = parseFloat(pmo[dataacP][dataposIndex].aktLeft_px * pmo[dataacP][dataposIndex].mm2pxFactor * mainImgFactor);
                    pmo[dataacP][dataposIndex].top_mm = parseFloat(pmo[dataacP][dataposIndex].aktTop_px * pmo[dataacP][dataposIndex].mm2pxFactor * mainImgFactor);

                    $.checkPosition(false, pmo[dataacP][dataposIndex].ajaxId);

                    icos = $(event.target).find('.ui-rotatable-handle, .resizer, .outerhelper');
                    rotation = rotation * -1;
                    icos.css('transform','rotate(' + rotation + 'deg)');
                    icos.css('-moz-transform','rotate(' + rotation + 'deg)');
                    icos.css('-webkit-transform','rotate(' + rotation + 'deg)');
                    icos.css('-o-transform','rotate(' + rotation + 'deg)');

                    rotation = 0;
                    $('.resser').css('transform','rotate(' + rotation + 'rad)');
                    $('.resser').css('-moz-transform','rotate(' + rotation + 'rad)');
                    $('.resser').css('-webkit-transform','rotate(' + rotation + 'rad)');
                    $('.resser').css('-o-transform','rotate(' + rotation + 'rad)');

                    /*$('.ui-tooltip').hide();*/
                    $('.svgc').remove();

                    $(this).tooltipster('hide');
                }
            });
            $('.acceptdrop, .motivImage .drov').not('.selected').droppable({
                accept: '.ovholder',
                drop: function (event, ui) {
                    var ppind = [], newpos, oldpos, newindex = 1, newObject, aa = 0;
                    if ($(this).hasClass('motselect')) {
                        if (!$(this).hasClass('selected')) {
                            doDrop = false;
                            dataposIndex = $(ui.draggable).attr('data-posIndex');
                            oldpos = $(ui.draggable).attr('data-pos');
                            newpos = $(this).attr('data-positionsId');
                            $('.div[data-id="' + $(ui.draggable).attr('data-id') + '"]').remove();
                            $(this).trigger('click');
                            $('.mtainfo').hide();
                            newObject = pmo[oldpos][dataposIndex];
                            if (pmo[newpos]) {
                                $.each(pmo[newpos], function (b) {
                                    ppind.push(pmo[newpos][b].posIndex);
                                });
                                newindex = $.findNextNumber(ppind);
                            }
                            if (!pmo[newpos]) {
                                pmo[newpos] = {};
                            }
                            pmo[newpos][newindex] = newObject;
                            pmo[newpos][newindex].acP = newpos;
                            pmo[newpos][newindex].aPT = $(this).attr('data-pos');
                            pmo[newpos][newindex].oldid = pmo[oldpos][dataposIndex].imageid;
                            delete pmo[oldpos][dataposIndex];
                            $.each(pmo[oldpos], function (a) {
                                aa = aa + 1;
                            });
                            if (aa < 1) {
                                delete pmo[oldpos];
                            }
                            $.loadOverlay();

                            $.setMotive(newpos, newindex, true, null, true);
                            $('.motselect').removeClass('over');
                        } else {
                            $('.motselect').removeClass('over');
                        }
                    } else {
                        if (!$(this).hasClass('drov') || $(this).hasClass('selected')) {
                            doDrop = false;
                        } else {
                            doDrop = true;
                            $(this).removeClass('over');
                        }
                    }
                },
                over: function (event, ui) {
                    if ($(this).hasClass('motselect') && !$(this).hasClass('selected')) {
                        doMotruler = false;
                        $('.motselect').removeClass('over');
                        $('.motruler').hide();
                        $(this).addClass('over');
                    } else {
                        if ($(this).closest('.motivImage').length) {
                            doMotruler = true;
                            $('.motselect').find('.drov').show();
                            $('.motselect').removeClass('over');
                            $('.jsMsThumbs div[data-id="' + $(ui.draggable).attr('data-id') + '"]').show();
                            $('.motruler').show();
                        }
                    }
                },
                out: function (event, ui) {
                    $('.motselect').removeClass('over');
                    doMotruler = false;
                    doDrop = false;
                    $('.jsMsThumbs div[data-id="' + $(ui.draggable).attr('data-id') + '"]').hide();
                    $('.motruler').hide();
                }
            });
            $('.active').find('.ui-resizable-handle').show();
        };
        $.changeColorfilter = function (a) {
            var activeLine = $('#mproducts .fbutton.active').attr('data-line');
            $('.colorfilter').show();
            $('.colorfilter').each(function () {
                var colorgroup = $(this).attr('data-colorgroup');
                if (!$('#' + activeLine).find('.otherColor[data-colorgroup="' + colorgroup + '"]').length) {
                    $(this).hide();
                }
            });
            if ($('#mproductsScroller').data('sly')) {
                $('#mproductsScroller').sly('reload');
            } else {
                //$.buildVerticalScroller('#mproductsScroller');
            }
        };
        $.checkAvailableArticlesForColor = function () {
            $('.ermsg').remove();
            $('.otholder:visible').each(function () {
                if (!$(this).find('.fused:visible').length) {
                    $(this).find('.frame').prepend('<p class="ermsg center">Keine Artikel in dieser Farbe</p>');
                    $(this).find('.scrollbar').hide();
                    $(this).find('.pages').hide();
                    $(this).find('.btn').hide();
                    $('#' + $(this).attr('id')).sly('destroy');
                }
            });
            if ($('#mproductsScroller').data('sly')) {
                $('#mproductsScroller').sly('reload');
            } else {
                $.buildVerticalScroller('#mproductsScroller');
            }
        };
        $(document).on('click touchstart', '.ui-rotatable-handle', function (e) {
            var icos, rotation;
            icos = $('.resizable.active');
            rotation = icos.attr('data-rotation');
            icos.css('transform','rotate(' + rotation + 'deg)');
            icos.css('-moz-transform','rotate(' + rotation + 'deg)');
            icos.css('-webkit-transform','rotate(' + rotation + 'deg)');
            icos.css('-o-transform','rotate(' + rotation + 'deg)');
            return false;
        });
        $(document).on('click', '.colorfilter', function (e) {
            var colorgroup = $(this).attr('data-colorgroup'), li;
            $('.colorfilter').removeClass('active');
            $(this).addClass('active');
            $('.otlist').find('li').removeClass('fused').hide();
            $('.otlist').find('li').find('span[data-colorgroup="' + colorgroup + '"]').each(function () {
                li = $(this).closest('li');
                // mit sprite
                //li.find('span.otlists').removeClass().addClass('otlists').addClass($(this).attr('data-class'));
                // mit bild
                li.find('img').attr('src', $(this).attr('data-image'));

                li.find('.nproduct').attr('data-href', $(this).attr('data-link'));

                li.find('a').attr('href', $(this).attr('data-link')).attr('data-cr', $(this).attr('data-cr'));
                if ($('#qrcode').attr('data-uuid')) {
                    li.find('a').attr('href', $(this).attr('data-cr') + $('#qrcode').attr('data-uuid'));
                }
                li.show().addClass('fused').show();
            });
            $.checkAvailableArticlesForColor();
        });
        $(document).on('click', '.moredetails', function (e) {
            $(this).closest('.detailprice').find('.hidee').slideDown();
        });
        $(document).on('click', '.resetcf', function (e) {
            $('.colorfilter').removeClass('active');
            $('.otlist').find('li').find('span.otlists').each(function () {
                $(this).removeClass();
                $(this).addClass($(this).attr('data-class'));
                $(this).closest('li').find('a').attr('href', $(this).attr('data-href'));
                $(this).closest('li').find('a').attr('data-cr', $(this).attr('data-cr'));
                if ($('#qrcode').attr('data-uuid')) {
                    $(this).closest('li').find('a').attr('href', $(this).attr('data-cr') + $('#qrcode').attr('data-uuid'));
                }
            });
            $('.otlist').find('li').show().addClass('fused').show();
            $.checkAvailableArticlesForColor();
            $.changeColorfilter();
        });
        $(document).on('click', 'a[data-cr]', function (e) {
            var div, title, link, printable = '', stickable = '', b1, b2, b3, origlink, hasMotives = false;

            if($('#seoString').attr('data-value') == 'admin'){
                e.preventDefault();

                var idata = {};
                idata.farbe = $(this).attr('data-farbe');
                idata.artNr = $(this).attr('data-artNr');
                idata.katNr = $('.s_verwArt_katEditName').attr('data-kid');
                idata.motiv = $('#dUuid').attr('data-uuid');

                $.ajax({
                    data: idata,
                    cache: false,
                    type: 'POST',
                    url: '/ajax/ajax.php?action=site_verw_artikel&subAction=getDesigner',
                    success: function (data) {
                        if (data && data.status) {
                            var pmo = {}, pma = {}, aaa = 0, side;
                            $('#contenthere').html('');
                            $('#contenthere').html(data.status);
                            $.initDesigner();
                            //$.buildSlider();
                        }
                    },
                    error: function (msg) {
                        $.setInfo('geht nicht');
                    }
                });

                return true;
            }
            if (!$.isEmptyObject(pmo)) {
                $.each(pmo, function (a) {
                    $.each(pmo[a], function (b) {
                        if (!pmo[a][b].aoData.defMot) {
                            hasMotives = true;
                        }
                    })
                });
                if (hasMotives) {
                    e.preventDefault();
                    title = 'Artikel wechseln';
                    if (sprache.ArtikelWechseln) {
                        title = sprache.ArtikelWechseln;
                    }
                    link = this;
                    origlink = $(this).attr('data-ll');
                    if ($(this).closest('li').hasClass('sel')) {
                        return;
                    }
                    if ($(this).attr('data-fuer-stick')) {
                        stickable = '<br />Stickmotive werden übernommen.';
                        if (sprache.StickmotiveWerdenUebernommen) {
                            stickable = '<br />' + sprache.StickmotiveWerdenUebernommen;
                        }
                    }
                    if ($(this).attr('data-fuer-druck')) {
                        printable = '<br />Druckmotive werden übernommen.';
                        if (sprache.DruckmotiveWerdenUebernommen) {
                            printable = '<br />' + sprache.DruckmotiveWerdenUebernommen;
                        }
                    }
                    div = $('<div />');
                    div.addClass('changeArticle');
                    div.html('<p><b>' + $(this).attr('data-ptitle') + '</b></p><p>' + printable + stickable + '</p>');
                    b1 = 'Motive übernehmen';
                    if (sprache.MotiveUebernehmen) {
                        b1 = sprache.MotiveUebernehmen;
                    }
                    b2 = 'Motive nicht übernehmen';
                    if (sprache.MotiveNichtUebernehmen) {
                        b2 = sprache.MotiveNichtUebernehmen;
                    }
                    b3 = 'Abbrechen';
                    if (sprache.Abbrechen) {
                        b3 = sprache.Abbrechen;
                    }
                    $(div).dialog({
                        autoOpen: true,
                        modal: true,
                        title: title,
                        resizable: false,
                        draggable: false,
                        closeText: 'schließen',
                        maxWidth: $('#designer').innerWidth(),
                        position: {my: 'center top', at: 'center top', of: '.ctmain'},
                        width: $('#designer').innerWidth() - 6,
                        show: {effect: 'puff', duration: 222},
                        hide: {effect: 'clip', duration: 222},
                        close: function () {
                            $('.changeArticle').remove();
                            return true;
                        },
                        buttons: [{
                            text: b1,
                            click: function() {
                                window.location = $(link).attr('href');
                            }
                        },{
                            text: b2,
                            click: function() {
                                //window.location = $(link).find('.nproduct').attr('data-href');
                                window.location = origlink;
                           }
                        },{
                            text: b3,
                            click: function() {
                                $(this).dialog('close');
                            }
                        }]
                    });
                }
            }
        });
        $(document).on('click', '#fbsharer', function (e) {
            e.preventDefault();
            var url, uuid = $(this).attr('data-id');
            url = $(this).attr('href');
            $.ajax({
                data: 'u=' + uuid,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=uf&language=' + $('html').attr('lang')
            });
            window.open(url);
        });
        $(document).on('click', '#twsharer', function (e) {
            e.preventDefault();
            var url, uuid = $(this).attr('data-id');
            url = $(this).attr('href');
            $.ajax({
                data: 'u=' + uuid,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=ut&language=' + $('html').attr('lang')
            });
            window.open(url);
        });
        $(document).on('click', '#insharer', function (e) {
            e.preventDefault();
            var url, uuid = $(this).attr('data-id');
            url = $(this).attr('href');
            $.ajax({
                data: 'u=' + uuid,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=up&language=' + $('html').attr('lang')
            });
            window.open(url);
        });
        $(document).on('click', '#bthp', function (e) {
            e.preventDefault();
            var uuid = $(this).attr('data-id');
            if (!uuid) {
                $.setInfo('Ein nicht gestalteter Artikel kann nicht gespeichert werden', 'error');
                return;
            }
            $.ajax({
                data: 'u=' + uuid,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=hp&language=' + $('html').attr('lang'),
                success: function () {
                    $.setInfo('Kreation wurde gespeichert');
                }
            });
        });
        $(document).on('click', '#bthpp', function (e) {
            e.preventDefault();
            var uuid = $(this).attr('data-id');
            if (!uuid) {
                $.setInfo('Ein nicht gestalteter Artikel kann nicht gespeichert werden', 'error');
                return;
            }
            $.ajax({
                data: 'u=' + uuid,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=hpp&language=' + $('html').attr('lang'),
                success: function () {
                    $.setInfo('Kreation wurde gespeichert');
                }
            });
        });


        $(document).on('click', '.saco', function (e) {
            $('input[name="selcol[]"]').each(function() {
                $(this).prop('checked', true);
            });
        });
        $(document).on('click', '#sasa', function (e) {
            e.preventDefault();
            var collisionHtml = '', hasCollision = false, uuid = $(this).attr('data-id'), am;
            am = ($('INPUT[name="settings_am"]').length > 0 && $('INPUT[name="settings_am"]').val() == 1) ? 1 : 0;
            if (pmo) {
                $.each(pmo, function (a) {
                    $.each(pmo[a], function (b) {
                        if (pmo[a][b].hasCollision === true) {
                            hasCollision = true;
                        }
                    });
                });
            }
            if (hasCollision === true) {
                $.each(pmo, function (a) {
                    $.each(pmo[a], function (b) {
                        var posLabel = $('#pos_' + a).attr('data-label'), typLabel = pmo[a][b].label, templatelabel = pmo[a][b].templatelabel;
                        if (pmo[a][b].hasCollision === true) {
                            collisionHtml += '<br />' + typLabel + ' ' + templatelabel + ' ' + posLabel;
                        }
                    });
                });
                $.setInfo(sprache.motivDesigner_positioncheck + '<span class="smaller">' + collisionHtml + '</span>');
                return false;
            }
            $.loadOverlay();
            $.ajax({
                data: 'u=' + uuid + '&am=' + am + '&saId=' + $('INPUT[name="settings_said"]').val(),
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax.php?action=site_produkte&subAction=loadColors',
                success: function (data) {
                    var div;
                    if (data && data.status === true && data.html) {
                        div = $('<div />');
                        div.addClass('sasacolors');
                        div.html(data.html);
                        $(div).dialog({
                            autoOpen: true,
                            modal: true,
                            title: 'Farben auswählen',
                            resizable: false,
                            draggable: false,
                            closeText: 'schließen',
                            position: {my: 'center top', at: 'center top', of: '#mainwrapper'},
                            width: 1000,
                            show: {effect: 'puff', duration: 222},
                            hide: {effect: 'clip', duration: 222},
                            close: function () {
                                $('.sasacolors').remove();
                                return true;
                            },
                            buttons: {
                                'Vorhandenen Artikel speichern': function () {
                                    var that = this, selected, pdata = {}, cdata = [];
                                    pdata.u = uuid;
                                    pdata.overwrite = true;
                                    $('input[name="selcol[]"]:checked').each(function() {
                                       cdata.push($(this).val());
                                    });
                                    pdata.colors = cdata;
                                    pdata.category = $('#turl').attr('data-kid');
                                    if(!pdata.category && $('#contenthere').length > 0){
                                        pdata.category =  $('#contenthere').attr('data-katId');
                                    }
                                    pdata.saId = $('INPUT[name="settings_said"]').val();
                                    pdata.defaultColor = $('input[name="defaultColor"]:checked').val();
                                    $.ajax({
                                        data: pdata,
                                        dataType: 'json',
                                        cache: false,
                                        type: 'POST',
                                        url: '/ajax/ajax.php?action=site_produkte&subAction=saveItem',
                                        success: function (data) {
                                            if (data && data.status === true) {
                                                $.setInfo('Shop-Artikel wurde aktualisiert');
                                            } else if (data && data.status === false && data.error) {
                                                $.setInfo(data.error, 'error');
                                            }
                                            $.loadOverlay(true);
                                            $(that).dialog('close');
                                        }
                                    });
                                },
                                'Als neuen Artikel speichern': function () {
                                    var that = this, selected, pdata = {}, cdata = [];
                                    pdata.u = uuid;
                                    $('input[name="selcol[]"]:checked').each(function() {
                                       cdata.push($(this).val());
                                    });
                                    pdata.colors = cdata;
                                    pdata.category = $('#turl').attr('data-kid');
                                    if(!pdata.category && $('#contenthere').length > 0){
                                        pdata.category =  $('#contenthere').attr('data-katId');
                                    }
                                    pdata.saId = $('INPUT[name="settings_said"]').val();
                                    pdata.defaultColor = $('input[name="defaultColor"]:checked').val();
                                    $.ajax({
                                        data: pdata,
                                        dataType: 'json',
                                        cache: false,
                                        type: 'POST',
                                        url: '/ajax/ajax.php?action=site_produkte&subAction=saveItem',
                                        success: function (data) {
                                            if (data && data.status === true) {
                                                $.setInfo('Shop-Artikel wurde angelegt');
                                            } else if (data && data.status === false && data.error) {
                                                $.setInfo(data.error, 'error');
                                            }
                                            $.loadOverlay(true);
                                            $(that).dialog('close');
                                        }
                                    });
                                },
                                'Schließen': function () {
                                    $(this).dialog('close');
                                }
                            }
                        });

                    } else if (data && data.status === false && data.error) {
                        $.setInfo(data.error, 'error');
                    }
                    $.loadOverlay(true);
                }
            });
        });
        $(document).on('click', '.imgsharer a', function (e) {
            e.preventDefault();
            var imgurl, div;
            imgurl = $(this).attr('href');
            div = $('<div />');
            div.addClass('zoomify');
            div.html('<p><img src="' + imgurl + '" alt=""/></p>');
            $(div).dialog({
                autoOpen: true,
                modal: true,
                title: $('.artbasetit').text(),
                resizable: false,
                draggable: false,
                closeText: 'schließen',
                position: {my: 'center top', at: 'center top', of: '#mainwrapper'},
                width: 1000,
                show: {effect: 'puff', duration: 222},
                hide: {effect: 'clip', duration: 222},
                close: function () {
                    $('.zoomify').remove();
                    return true;
                },
                buttons: {
                    'Schließen': function () {
                        $(this).dialog('close');
                    }
                }
            });
        });
        $(document).on('mouseenter', '.detailprice li', function () {
            var id = $(this).find('.delmotive').attr('data-m');
            $('.motov[data-id="' + id + '"]').addClass('hover');
            $(this).addClass('hover');
        }).on('mouseleave', '.detailprice li', function () {
            $('.motov').removeClass('hover');
            $(this).removeClass('hover');
        });
        $(document).on('dblclick', '.ovholder', function () {
            $('input.desinput.textinput').first().focus();
            $('input.desinput.textinput').each(function () {
                if ($(this).val() && $(this).val().trim !== '') {
                    $(this).focus();
                    return false;
                }
            });
        });
        $(document).on('click', '.hcenterize', function () {
            var widget, distance, center;
            widget = $(this).closest('.ovholder');
            center = $('.motivImage').find('.drov').width() / 2;
            distance = center - widget.position().left - widget.width() / 2;
            distance = Math.ceil(distance);
            if (distance > 0 || distance < 0) {
                widget.simulate('drag', {
                    dx: distance,
                    moves: 1
                });
            }
        });
        $(document).on('focus', '.vsma input', function () {
            $(this).select();
        });
        $(document).on('click', '.activateruler', function () {
            if ($('.motruler').length) {
                $('.motruler').hide().remove();
            } else {
                $.motRuler();
                $('.ovholder').not('.active').each(function () {
                    $.motRuler($(this));
                });
            }
        });
        $.filterTemplates = function () {
            var print, stick, data = {}, sa, tw, text;
            print = $('#motfilter').find('.tfilter[data-type="2"]').hasClass('active') ? 1 : 0;
            stick = $('#motfilter').find('.tfilter[data-type="1"]').hasClass('active') ? 1 : 0;
            text = $('#motfilter').find('input[name="ftesxt"]').val();
            sa = parseInt($('#stammartikelId').attr('data-id'), 10);
            data.print = print;
            data.stick = stick;
            data.sa = sa;
            data.text = text;
            data.artFarbe = $('.jsMsColor li a.selected').attr('data-color');
            data.katId = $('#katId').attr('data-value');
            data.seoString = $('#seoString').attr('data-value');
            tw = $('select[name="thworld"]').val();
            data.tw = tw;
            $.ajax({
                dataType: 'json',
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=filterTemplate&language=' + $('html').attr('lang'),
                data: data,
                success: function (ddd) {
                    $('#designinner').find('.slidee').html(ddd.html);
                    $('#designinner').imagesLoaded().done(function (a) {
                        if ($('#designinner').data('sly')) {
                            $('#designinner').sly('reload');
                        } else {
                            $.buildVerticalScroller('#designinner');
                        }
                        $.doStuff();
                    });
                    if (!$('.jsMsPlace').find('.gebiet[data-fuer-druck="1"]').length) {
                        $('.temselect[data-type="druck"]').closest('.fuseda').hide();
                    }
                    if (!$('.jsMsPlace').find('.gebiet[data-fuer-stick="1"]').length) {
                        $('.temselect[data-type="stick"]').closest('.fuseda').hide();
                    }


                }
            });
        };
        $(document).on('click', '#motfilter .tfilter', function () {
            if ($(this).hasClass('noposs') || $('.noposs').length) {
                return;
            }
            $(this).toggleClass('active');
            $('#motfilter .tfilter').not(this).removeClass('active');
            $.filterTemplates();
        });
        $(document).on('change', 'select[name="thworld"]', function () {
            $.filterTemplates();
        });
        $(document).on('keyup', 'input[name="ftesxt"]', function () {
            var tt = 800;
            clearTimeout(ttTimer);
            ttTimer = setTimeout(function () {
                $.filterTemplates();
            }, tt);
        });
        $(document).on('click', '.tagc', function () {
            var val;
            val = $(this).text();
            $('input[name="ftesxt"]').val(val).attr('value', val);
            $.filterTemplates();
        });
        $(document).on('click touchstart', '.ovholder', function (e) {
            if ($(e.target).hasClass('outerhelper') || $(e.target).closest('.outerhelper').length) {
                return false;
            }
            $.activateMotive(this, true, true);
        });
        $(document).on('click', '.overlayload', function (e) {
            if (e.pageX < 50) {
                $.loadOverlay(true);
            }
        });
        $.getProducts = function (limit, scroll) {
            var productKatId, data = {}, loadimg, ti, gridIn, countInGrid, div, innerdiv;
            data.offset = $('#productList').find('.fuseda').length;
            data.limit = limit;
            //data.kat = $('.hastabs').find('a.active').attr('data-id');
            data.kat = $('#slideMenu').find('a.active').attr('data-id');
            productKatId = data.kat;
            data.ssId = 0;
            data.seoString = $('#seoString').attr('data-value');

            if (data.seoString == 'admin') {
                data.katId = $('#katId').attr('data-value');
            	if(!data.katId && $('#contenthere').length > 0){
                    data.katId = $('#contenthere').attr('data-katId');
            	}
            }
            if ($('#ssId').length && $('#ssId').attr('data-value') > 0) {
                data.ssId = 1;
            }
            $('.toBeRemoved').remove();
            $('.emptygrid').remove();
            if (xhrp) {
                xhrp.abort();
            }
            gridIn = $('#productList').find('.ym-grid').last();
            if (!gridIn.length) {
                gridIn = $('<div />');
                gridIn.addClass('ym-grid ym-equalize prodlist');
                $('#productList').append(gridIn);
            }
            countInGrid = gridIn.find('.fuseda').length;
            gridIn.find('.ym-g33').not('.used').remove();
            for (ti = 0; ti < limit; ti = ti + 1) {
                //checken wie viele im grid drin sind, wenn < 4, dann row adden, wenn nicht, dann neues grid erstellen
                div = $('<div />');
                innerdiv = $('<div />');
                div.addClass('relative');
                div.addClass('ym-g33');
                div.addClass('ym-gl');
                innerdiv.addClass('ym-gbox-left');
                //innerdiv.html('<div class="fuseda temporary tt' + ti + '"><span class="loadimg"></span></div>');
				innerdiv.html('<div class="fuseda ym-clearfix temporary tt' + ti + '"><span class="loadimg"></span></div>');

                div.append(innerdiv);
                if (countInGrid < 3) {
                    gridIn.append(div);
                    countInGrid = countInGrid + 1;
                    if (countInGrid == 3) {
                        div.removeClass('ym-gl');
                        div.addClass('ym-gr');
                        innerdiv.removeClass('ym-gbox-left');
                        innerdiv.addClass('ym-gbox-right');
                    } else if (countInGrid == 2) {
                        innerdiv.removeClass('ym-gbox-left');
                        innerdiv.addClass('ym-gbox');
                    }
                } else {
                    gridIn = $('<div />');
                    gridIn.addClass('ym-grid ym-equalize prodlist');
                    $('#productList').append(gridIn);
                    gridIn.append(div);
                    countInGrid = 1;
                }
            }
            if (countInGrid == 2) {
                gridIn.append('<div class="ym-g33 ym-gr emptygrid"><div class="ym-gbox-right"><div class="fuseda temporary"><span class="loadimg"></span></div></div></div>');
            } else if (countInGrid == 1) {
                gridIn.append('<div class="ym-g33 ym-gl emptygrid"><div class="ym-gbox"><div class="fuseda temporary"><span class="loadimg"></span></div></div></div>');
                gridIn.append('<div class="ym-g33 ym-gr emptygrid"><div class="ym-gbox-right"><div class="fuseda temporary"><span class="loadimg"></span></div></div></div>');
            }
            if ($('#mproductsScroller').data('sly')) {
                $('#mproductsScroller').sly('reload');
            } else {
                $.buildVerticalScroller('#mproductsScroller');
            }
            xhrp = $.ajax({
                dataType: 'json',
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=getProducts&language=' + $('html').attr('lang'),
                data: data,
                success: function (d) {
                    if (d && d.rows) {
                        $.each(d.rows, function (e) {
                            //checken wie viele im grid drin sind, wenn < 4, dann row adden, wenn nicht, dann neues grid erstellen
                            var content, temporary, img;
                            img = d.rows[e]['img'];
                            temporary = $('.temporary:first');
                            content = d.rows[e]['linkOpen'] + img + '<span class="ym-clearfix atitle">' + d.rows[e]['stammartikelName'] + '</span></a>';

                            temporary.html(temporary.html() + content);
                            if ($('#dUuid').attr('data-uuid')) {
                                temporary.find('a').attr('href', temporary.find('a').attr('data-cr') + $('#dUuid').attr('data-uuid'));
                            }
                            temporary.removeClass('temporary');
                            temporary.closest('.ym-g33').addClass('used');
                            temporary.closest('.ym-grid').addClass('used');
                        });
                        $('.otae').imagesLoaded().progress(function (a, imgd) {
                            $(imgd.img).closest('div').find('.loadimg').remove();
                        });
                        $('#productList').imagesLoaded().done(function (a) {
                            var height;
                            $('.temporary').remove();
                            $('.prodlist').find('.ym-g33').not('.used').html('');

                            if ($('#mproductsScroller').data('sly')) {
                                $('#mproductsScroller').sly('reload');
                            } else {
                                $.buildVerticalScroller('#mproductsScroller');

                            }
                            if (scroll) {
                                $('#mproductsScroller').sly('toEnd');
                            }
                            $('.emptygrid').html('');
                        });
                        $('#mproductsScroller').sly('on', 'moveEnd', function (ee, aa) {
                            if( this.pos.dest > this.pos.end - 50 ){
                                $.getProducts(9, scroll);
                            }
                        });
                    } else {
                        $('.temporary').remove();
                        $('.prodlist').find('.ym-g33').not('.used').html('');
                            if ($('#mproductsScroller').data('sly')) {
                                $('#mproductsScroller').sly('reload');
                            } else {
                                $.buildVerticalScroller('#mproductsScroller');
                            }
                    }
                    $('.prodlist').find('.ym-grid').not('.used').remove();
                }
            });
        };
        $(document).on('click', '.mtab, .goToTab', function (e) {
            if ($(this).find('.notPossible').length) {
                return;
            }
            var contentDiv = $(this).attr('data-id'), active, dataposIndex, dataacP, stickText = [], text;
            if (contentDiv == 'mproducts'){
                $(document).on('click', '.openmenu', function (e) {
                    e.preventDefault();
                    $('#slideMenu').show();
                    //$('#katSelector').show();
                });
                if (!$('#productList').find('.fuseda').length) {
                    $.getProducts(15, false);
                }
            }
            $('.mtab').removeClass('active');
            $('.mtab[data-id="' + contentDiv + '"]').addClass('active');
            $('.tabcontent').hide();
            $('#' + contentDiv).show();
            $('.hasScroller:visible').each(function () {
                var id = $(this).attr('id');
                if ($('#' + id).data('sly')) {
                    $('#' + id).sly('reload');
                } else {
                    $.buildVerticalScroller('#' + id);
                }
            });
            if (contentDiv == 'mtextmodule'){
                active = $('.motivImage').find('.ovholder.active');
                //check if active is text
                if (active && active.attr('data-isText')) {
                    dataposIndex = active.attr('data-posIndex');
                    dataacP = active.attr('data-pos');
                    $.each(pmo[dataacP][dataposIndex].text, function (a) {
                        stickText[a] = pmo[dataacP][dataposIndex].text[a].text;
                    });
                    if (!$('#sticktext').val()) {
                        $('#sticktext').val(stickText.join('\n'));
                    }
                } else {
                    $('#sticktext').val($('#sticktext').attr('placeholder'));
                    $('.clonedtf').remove();
                    $('.ovholder').removeClass('active');
                    $('.clone-type-configurator > ul > li').removeClass('active');
                    $('.ovholder').find('.activewrapper').hide();
                    $('.ovholder').find('.outerhelper').hide();
                    $('.motruler').hide().remove();
                    $.initColorpicker();
                    if ($(window).width() >= 1280) {
                        $('#sticktext').focus();
                    }
                    text = $.trim($('#sticktext').val());
                    text = text.split('\n');
                    $.setMotive(null, null, null, null, null, null, text);
                    $('#sticktext').val('');
                }
            }
            //$.removeUnusedVElements($('#mfileuploadScroller'));
        });
        $(document).on('click touchstart', '.duplicater', function () {
            var ppind = [], dataPosIndex, dataPos, newIndex = 1, newObject;
            dataPosIndex = $(this).closest('.ovholder').attr('data-posIndex');
            dataPos = $(this).closest('.ovholder').attr('data-pos');
            $.each(pmo[dataPos], function (b) {
                ppind.push(pmo[dataPos][b].posIndex);
            });
            newIndex = $.findNextNumber(ppind);
            newObject = $.extend(true, {}, pmo[dataPos][dataPosIndex]);
            pmo[dataPos][newIndex] = newObject;
            pmo[dataPos][newIndex].imageid = newIndex + '-' + pmo[dataPos][dataPosIndex].acP + '-' + pmo[dataPos][dataPosIndex].sid;
            pmo[dataPos][newIndex].isClone = true;
            $.setMotive(dataPos, newIndex, true);
        });
        $(document).on('click touchstart', '.deleter', function () {
            var id;
            id = $(this).closest('.ovholder').attr('data-id');
            $('.delmotive[data-m="' + id + '"]').trigger('click');
            $.buildTformat();
            $('#sticktext').height(150);
            $('.txtlineadded').remove();
            $('.mtab[data-id="motivselector"]').trigger('click');
            $('.clone-type-configurator > ul > li').removeClass('active');
            return false;
        });
        $(document).on('click', '.stageHolder', function (e) {
            if (($(e.target).hasClass('stageHolder') || $(e.target).hasClass('drov'))) {
            //if ($.active == 0 && ($(e.target).hasClass('stageHolder') || $(e.target).hasClass('drov'))) {
                $('.ovholder').removeClass('active');
                $('.clone-type-configurator > ul > li').removeClass('active');
                $('.ovholder').find('.activewrapper').hide();
                $('.ovholder').find('.outerhelper').hide();
                $('.motruler').hide().remove();
                $('.mtab[data-id="motivselector"]').trigger('click');
                $.checkNeededDivs();
                $('.hasScroller:visible').each(function () {
                    var id = $(this).attr('id');
                    $('#' + id).imagesLoaded().done(function (a) {
                        if ($('#' + id).data('sly')) {
                            $('#' + id).sly('reload');
                        } else {
                            $.buildVerticalScroller('#' + id);
                        }
                    });
                });
            }
        });
        $(document).on('click', '.arthead', function (e) {
            $.doExistCheck();
        });
        $.checkTextFields = function () {
            /*
            var doSomething, textElemente, allHidden;
            $('.tplelselect').each(function () {
                if ($(this).attr('data-textElemente')){
                    doSomething = true;
                    return false;
                }
            });
            if (doSomething) {
                allHidden = true;
                $('.desinput.textinput').prop('disabled', true);
                $('.desinput.textinput').closest('.ym-grid').hide();
                $('.tplelselect.selected').each(function () {
                    if ($(this).attr('data-textElemente')){
                        textElemente = $(this).attr('data-textElemente');
                        textElemente = textElemente.split(';');
                        $.each(textElemente, function (a) {
                            $('.desinput.textinput[name="text[Text_' + this + ']"]').prop('disabled', false);
                            $('.desinput.textinput[name="text[Text_' + this + ']"]').closest('.ym-grid').show();
                            allHidden = false;
                        });
                    }
                });
                if (allHidden) {
                    $('.mtatext').hide();
                } else {
                    $('.mtatext').show();

                    if ($('.desinput.textinput:visible').length > 1) {
                        $('.alltexts').show();
                    } else {
                        $('.alltexts').hide();
                    }
                }
            }
            */
        };
        $.checkNeededDivs = function () {
            var propLabel, div, templateLabel, templateTyp, label, thereIsSomething = false, dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
            //$.doStuff();
            $('.noMotSel').hide();
            $('.mtab').find('.mtabinner').removeClass('notPossible');
            if (!$('.motivImage').find('.ovholder.active').length || ($('.motivImage').find('.ovholder.active').attr('data-ptyp') == 'upload')) {
                $('.meditorFuncs').hide();
                $('.noMotSel').show();
                return;
            }
            if ($('.motivImage').find('.ovholder.active').attr('data-ptyp') == 'motive') {
                $('.mtab[data-id="motivselector"]').trigger('click');
                $('.meditorFuncs').hide();
                return;
            }
            if ($('.motivImage').find('.ovholder.active').attr('data-editable') == '0') {
                $('.mtab[data-id="motivselector"]').trigger('click');
                $('.meditorFuncs').hide();
                return;
            }
            $('.mtab[data-id="meditor"]').trigger('click');
            $('.meditorFuncs').show();
            $('.mtadetails').show();
            $('.mtacolors').show();
            $('.mtatext').show();
            if (!$('#motivColors').html()) {
                $('.mtacolors').hide();
            } else {
                $('.mtacolors').show();
                thereIsSomething = true;
            }
            if (!$('#motivElements').html()) {
                $('.mtadetails').hide();
            } else {
                $('.mtadetails').show();
                thereIsSomething = true;
            }
            if (!$('#templateTextElements').find('.textinput').length) {
                $('.mtatext').hide();
            } else {
                $('.mtatext').show();
                thereIsSomething = true;
            }
            if (thereIsSomething === false) {
                $('.mtafunc').hide();
            } else {
                $('.mtafunc').show();
                $('.meditorFuncs').show();
            }
            if (!isVisible($('.mtatext')) && !isVisible($('.mtacolors')) && !isVisible($('.mtadetails')) && !isVisible($('.mtafunc'))) {
                $('.meditorFuncs').hide();
            }
            if (thereIsSomething === false) {
                $('.mtab[data-id="motivselector"]').trigger('click');
                $('.mtab[data-id="meditor"]').find('.mtabinner').addClass('notPossible');
                return;
            }
            $('#meditorScroller').imagesLoaded().done(function (a) {
                if ($('#meditorScroller').data('sly')) {
                    $('#meditorScroller').sly('reload');
                } else {
                    $.buildVerticalScroller('#meditorScroller');
                }
            });
            dataposIndex = active.attr('data-posIndex');
            dataacP = active.attr('data-pos');
            if (pmo && pmo[dataacP] && pmo[dataacP][dataposIndex]) {
                templateTyp = capitalizeFirstLetter(pmo[dataacP][dataposIndex].templateTyp);
                if (sprache[templateTyp]) {
                    templateTyp = sprache[templateTyp];
                }
                $('.motmotiv .mottype').find('.mte').text(templateTyp);
                $('.clone-type-configurator > ul > li').removeClass('active');
                if (pmo[dataacP][dataposIndex].templateTyp == 'stick') {
                    $('.motmotiv .mottype').find('.smico').text('M');
                    $('.clone-type-configurator li.stick').addClass('active');
                } else {
                    $('.motmotiv .mottype').find('.smico').text('L');
                    $('.clone-type-configurator li.print').addClass('active');
                }
                templateLabel = pmo[dataacP][dataposIndex].templatelabel;
                $('.motmotiv .motname').text(templateLabel);
            }
            $.removeUnusedVElements($('#meditorScroller'));
            label = 'Details bearbeiten';
            if (sprache.details_tauschen) {
                label = sprache.details_tauschen;
            }
            $('.detselect[data-value="0"]').show();
            $('.mtadetails').find('.uploadTrim').hide();
            $('#qbview').hide();
            if ($('.motivImage').find('.ovholder.active').attr('data-uploaduuid')) {
                $('#qbview').show();
                if (sprache.foto_bearbeiten) {
                    label = sprache.foto_bearbeiten;
                } else {
                    label = 'Foto-Rahmen wählen';
                    div = $('<div />');
                    div.addClass('uploadTrim');
                    propLabel = sprache.BildProportionenBehalten ? sprache.BildProportionenBehalten : 'Bild-Proportionen behalten';
                    if (!$('.mtadetails').find('.uploadTrim').length) {
                        div.html('<label for="uploadTrim">' + propLabel + ' <input id="uploadTrim" checked="checked" type="checkbox" name="uploadTrim" value="1"/></label>');
                        $('.mtadetails').append(div);
                    } else {
                        $('.mtadetails').find('.uploadTrim').show();
                    }
                }
                $('.detselect[data-value="0"]').hide();
            }
            $('.mtadetails').find('.ym-label.detlable').html(label);
            $('.fusedb').each(function () {
                var selected, base64, base64holder, width, height, changit = true;
                base64holder = $('.tempPreview[data-posIndex="' + dataposIndex + '"][data-acP="' + dataacP + '"][data-element="' + $(this).find('.tplelselect').first().attr('data-motiv-id') + '"][data-template="' + active.attr('data-template') + '"]');
                selected = $('.allelementsholder[data-motiv-id="' + $(this).find('.tplelselect').first().attr('data-motiv-id') + '"][data-id="' + active.attr('data-template') + '"]').find('.selected');
                if (selected.attr('data-value') == '0') {
                    $(this).find('.tplelselect').find('img.ise').not('.forcePreview').attr('src', selected.find('img.ise').attr('src')).css('background', 'none');
                } else {
                    if (selected.find('.forcePreview').length) {
                        changit = false;
                        $(this).find('.tplelselect').find('img.ise').attr('src', selected.find('.forcePreview').attr('src'));
                    }
                }
                if (changit && base64holder) {
                    base64 = base64holder.attr('data-base64');
                    if (base64) {
                        $(this).find('.tplelselect').find('img.ise').not('.forcePreview').attr('src', 'data:image/png;base64,' + base64).css('background', 'none');
                        selected = $('.allelementsholder[data-motiv-id="' + $(this).find('.tplelselect').first().attr('data-motiv-id') + '"][data-id="' + active.attr('data-template') + '"]').find('.selected');
                        if (selected.length) {
                            width = selected.find('img.ise').width;
                            height = selected.find('img.ise').height;
                            selected.find('img.ise').not('.forcePreview').attr('src', 'data:image/png;base64,' + base64).css('background', 'none').width(width).height(height);
                        }
                    }
                }
            });
            $.checkTextFields();
        };
        $(document).on('click', '.arthead', function (e) {
            $.doExistCheck();
        });
        $.activateMotive = function (that, checkPosition, click) {
            var focusPosition, dataId, dataPosIndex, dataPos, datajson, zIndex, mottext = [];
            //if ($.active == 0) {
                realActive = $(that).attr('data-auid');
                tmpPos = null;
                dataPosIndex = $(that).attr('data-posIndex');
                if(!dataPosIndex){
                    return true;
                }
                dataPos = $(that).attr('data-pos');
                dataId = $(that).attr('data-id');
                if ($(that).attr('data-ptyp') == 'upload') {
                    $('.mtab[data-id="mfileupload"]').trigger('click');
                } else if ($(that).attr('data-ptyp') == 'text') {

                } else {
                    if (dataPosIndex && (pmo[dataPos][dataPosIndex].editable === undefined || pmo[dataPos][dataPosIndex].editable === '1')) {
                        $('.mtab[data-id="meditor"]').trigger('click');
                        $(that).attr('data-editable', '1');
                    } else {
                        $(that).attr('data-editable', '0');
                    }
                }
                if ($(that).hasClass('active') ) {
                    checkPosition = false;
                }
                $('.ovholder').removeClass('active');
                $('.clone-type-configurator > ul > li').removeClass('active');
                $('.ovholder').find('.outerhelper').hide();
                $('.ovholder').find('.activewrapper').hide();
                $(that).addClass('active');
                $(that).find('.activewrapper').show();
                $(that).find('.outerhelper').show();
                $('.temselect').removeClass('selected');
                $('.uploadselect').removeClass('selected');
                if(dataPosIndex){
                    if (pmo[dataPos][dataPosIndex].template && (!$(that).attr('data-ptyp') || ($(that).attr('data-ptyp') !== 'upload') && $(that).attr('data-ptyp') !== 'text')) {
                        $('.temselect[data-value="' + pmo[dataPos][dataPosIndex].template + '"]').addClass('selected');
                        $.activateThemelist($('#thwlist').find('a[data-theme="' + $('.temselect[data-value="' + pmo[dataPos][dataPosIndex].template + '"]').closest('.thelist').attr('data-theme') + '"]'));
                    } else if ($(that).attr('data-ptyp') == 'upload') {
                        $('.uploadselect').find('img[data-uuid="' + pmo[dataPos][dataPosIndex].sid + '"]').closest('.uploadselect').addClass('selected');
                    }
                }
                $.each(pmo[dataPos], function (a) {
                    var ttt, uuu;
                    ttt = pmo[dataPos][dataPosIndex].templateTyp;
                    if (ttt == 'upload') {
                        ttt = 'druck';
                    }
                    uuu = pmo[dataPos][a].templateTyp;
                    if (uuu == 'upload') {
                        uuu = 'druck';
                    }
                    if (pmo[dataPos][a] && ttt == uuu) {
                        if (!zIndex) {
                            zIndex = pmo[dataPos][a].zIndex;
                        } else if (zIndex < pmo[dataPos][a].zIndex) {
                            zIndex = pmo[dataPos][a].zIndex;
                        }
                    }
                });
                zIndex =  zIndex + 10;
                if(dataPosIndex){
                    pmo[dataPos][dataPosIndex].zIndex = zIndex;

                $('.motselect').find('.motov[data-id="' + $(that).attr('data-id') + '"]').css('zIndex', zIndex);
                $(that).css('zIndex', zIndex);
                if (dataPosIndex && (pmo[dataPos][dataPosIndex].template && !defaultMotives[pmo[dataPos][dataPosIndex].template])) {
                    $.loadTemplateForm(pmo[dataPos][dataPosIndex].template, dataId);
                } else {
                    if (dataPosIndex && pmo[dataPos][dataPosIndex].template) {
                        $('#meditor').html(defaultMotives[pmo[dataPos][dataPosIndex].template]);
                        datajson = $('.activeTemplate').find('span[data-id="' + dataId + '"]').attr('data-json');
                        if (datajson) {
                            $.updateDesignerElements(datajson);
                            $.initColorpicker();
                        }
                    }
                }
                if (checkPosition) {
                    $.checkPosition(true);
                }
                $('.allelementsholder').hide();
                $('#motivElements').show();
                $('.detailprice').find('li').removeClass('selected');
                $('.delmotive[data-m="' + pmo[dataPos][dataPosIndex].imageid + '"]').closest('li').addClass('selected');
                if ($(that).attr('data-ptyp') == 'text' && $('#sticktext').length) {
                    if ($('#sticktext').is(':visible')) {
                        $.each(pmo[dataPos][dataPosIndex].text, function(r) {
                            mottext[r] = this.text;
                        });

                        var textrows = $.trim($('#sticktext').val());
                        textrows = textrows.split('\n');

                        if (JSON.stringify(mottext) != JSON.stringify(textrows)) {
                            $('#sticktext').val(mottext.join('\n'));
                        }
                        $.buildTformat(pmo[dataPos][dataPosIndex]);
                        $.adjustTextField();
                        $('.textmottype').removeClass('active');
                        $('.clone-type-configurator > ul > li').removeClass('active');
                        if (pmo[dataPos][dataPosIndex].templateTyp == 'stick') {
                            $('.textmottype[data-type="stick"]').addClass('active');
                            $('.clone-type-configurator li.stick').addClass('active');
                        } else {
                            $('.textmottype[data-type="druck"]').addClass('active');
                            $('.clone-type-configurator li.print').addClass('active');
                        }
                        return;
                    }
                    //if (!$('#sticktext').is(':visible') || checkPosition === true) {
                    if (click) {
                        $('#sticktext').val('');
                    }
                        $('.mtab[data-id="mtextmodule"]').trigger('click');
                        $.initColorpicker();
                        $('.textmottype').removeClass('active');
                        $('.clone-type-configurator > ul > li').removeClass('active');
                        if (pmo[dataPos][dataPosIndex].templateTyp == 'stick') {
                            $('.textmottype[data-type="stick"]').addClass('active');
                            $('.clone-type-configurator li.stick').addClass('active');
                        } else {
                            $('.textmottype[data-type="druck"]').addClass('active');
                            $('.clone-type-configurator li.print').addClass('active');
                        }
                    $.buildTformat(pmo[dataPos][dataPosIndex]);
                    $.adjustTextField();
                    $('#sticktext').val($('#sticktext').val());
                    if ($(window).width() >= 1280) {
                        $('#sticktext').focus();
                    }
                    $('.slideholder, .fontpop').hide();
                }
                }
                $.loadMotiveDragger();
                if ($(that).attr('data-ptyp') !== 'text') {
                    $.checkNeededDivs();
                }
                if(dataPosIndex){
                if (pmo[dataPos][dataPosIndex].editable === undefined || pmo[dataPos][dataPosIndex].editable === '1') {
                    $('.hasScroller:visible').each(function () {
                        var id = $(this).attr('id');

                        $('#' + id).imagesLoaded().done(function (a) {
                            if ($('#' + id).data('sly')) {
                                $('#' + id).sly('reload');
                            } else {
                                $.buildVerticalScroller('#' + id);
                            }
                        });
                    });
                }
                }
            //}
            return false;
        };
        $.getParameterByName = function (name, string) {
            name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
            var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"), results = regex.exec(string);
            return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
        };
        $.goToMotivePosition = function (updateDesign) {
            if (updateDesign && updateDesign === true) {
                $.updateDesign();
            } else {
                $.updateOverlays();
            }
        };
        $.initToggles = function () {
            $(document).on('click', '.atoggles', function () {
            //$('.atoggles').on('click', function () {
                var that = this, dowhat;
                $('.toggles').each(function () {
                    if ($(that).data('toggles').active === true) {
                        if ($(this).data('toggles').active === true) {
                            $(this).trigger('click');
                            dowhat = true;
                        }
                        $(that).removeClass('dataon');
                        $(that).addClass('dataoff');
                    } else {
                        if ($(this).data('toggles').active === false) {
                            $(this).trigger('click');
                            dowhat = false;
                        }
                        $(that).removeClass('dataoff');
                        $(that).addClass('dataon');
                    }
                });
                $(that).data('toggles').toggle(dowhat);
            });
            $(document).on('click', '.toggles', function () {
            //$('.toggles').on('click', function () {
                var input, status, status2, myToggle = $(this).data('toggles');
                input = $(this).closest('.ym-grid').find('input.desinput');
                if (myToggle.active === true) {
                    status = false;
                    input.attr('data-pl', input.val()).attr('placeholder', input.val());
                    input.val('');
                    input.attr('value', '');
                    $(this).removeClass('dataon');
                    $(this).addClass('dataoff');
                } else {
                    input.val(input.attr('data-pl'));
                    input.attr('value', input.attr('data-pl'));
                    $(this).removeClass('dataoff');
                    $(this).addClass('dataon');
                }
                $('.toggles').not($(this)).each(function () {
                    status2 = $(this).data('toggles').active;
                });
                if (status === true && status2 === true) {
                    $('.atoggles').data('toggles').toggle(true);
                } else if (status === false && status2 === false) {
                    $('.atoggles').data('toggles').toggle(false);
                }
                clearTimeout(ttTimer);
                ttTimer = setTimeout(function () {
                    var dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
                    dataposIndex = active.attr('data-posIndex');
                    dataacP = active.attr('data-pos');
                    $.setMotive(dataacP, dataposIndex, true);
                }, 0);
            });
            $('.toggles, .atoggles').toggles({
                text: {
                    on: sprache.an,
                    off: sprache.aus
                },
                animate: 0,
                on: true,
                drag: false,
                height: 18,
                width: 45
            });
            $('.toggles').each(function () {
                if (!$(this).hasClass('dataoff')) {
                    $(this).addClass('dataon');
                }
            });
        };
        $.initColorpicker = function (eee) {
            var colHolder, textrow;
            $('.colorPicker').find('a, input[type=text]').remove();
            $('.colorPicker').find('select').attr('name', 'color');
            $('.mcpick').find('select[name="color"]').colourPicker({ico: '/images/transparent.gif', title: '', openTxt: ''});
            $('.txtColorPicker').find('select[name="color"]').colourPicker({ico: '/images/transparent.gif', title: '', openTxt: ''});

            $('.alltexts').remove();
            if ($('#templateTextElements').find('.ym-grid').length > 1) {
                textrow = $('#templateTextElements').find('.ym-grid').first().clone();
                textrow.addClass('alltexts').find('.ym-fbox-text').addClass('txtright').html('<span class="smaller">' + sprache.Alle_Texte + '</span>');
                textrow.find('input[name="color"]').remove();
                textrow.find('.toggles').addClass('atoggles').removeClass('toggles');
                textrow.find('select[name="color"]').attr('name', 'alltexts').colourPicker({ico: '/images/transparent.gif', title: '', openTxt: ''});
                $('#templateTextElements').append(textrow);
            }
            $('.elholder').find('.ise').each(function () {
                var color;
                color = $(this).closest('.elholder').find('input[name="color"]').val();
            });
            $('input[name="color"]').each(function () {
                var color;
                color = $(this).val();
                if (color == 'ffffff') {
                    $(this).css('borderColor', '#000000');
                } else if (color == '000000') {
                    $(this).css('borderColor', '#FFFFFF');
                }
            });
            $('#templateTextElements').find('select[name="color"]').colourPicker({ico: '/images/transparent.gif', title: '', openTxt: ''});
            $('.elholder').find('select[name="color"]').colourPicker({ico: '/images/transparent.gif', title: '', openTxt: ''});
            //$(document).on('click', '#templateTextElements input[name="color"], .mcpick input[name="color"], .elholder input[name="color"], .txtColorPicker input[name="color"]', function (e) {
            $('#templateTextElements, .mcpick, .elholder, .txtColorPicker').find('input[name="color"]').on('click', function (e) {
                if ($(e.target).closest('.txtColorPicker').length && $.trim($('#sticktext').val()) == '') {
                    return false;
                }
                $(this).closest('div').find('a').trigger('click');
                $('#jquery-colour-picker').find('a[rel="' + $(this).val() + '"]').addClass('selected');
                clearTimeout(ttTimer);
                return false;
            });
            $('input[name="color"]').on('change', function () {
                clearTimeout(ttTimer);
                var elementActId, colorId, color, dataacP, dataposIndex, elId, ell, active = $('.motivImage').find('.ovholder.active');
                color = $(this).val();
                colorId = $(this).closest('.colorPicker').attr('data-colorId');
                $(this).closest('.colorPicker').find('.colorico').css('backgroundColor', '#' + color);
                //$(this).closest('.colorPicker').find('.colorico').css('borderColor', '#' + color);
                if (color == 'ffffff') {
                    $(this).closest('.colorPicker').find('.colorico').css('borderColor', '#000000');
                } else if (color == '000000') {
                    $(this).closest('.colorPicker').find('.colorico').css('borderColor', '#FFFFFF');
                }
                $(this).closest('.colorPicker').find('select').find('option').prop('selected', null);
                $(this).closest('.colorPicker').find('select').find('option[value="' + $(this).val() + '"]').prop('selected', true);
                dataposIndex = active.attr('data-posIndex');
                dataacP = active.attr('data-pos');

                elId = $(this).closest('.detholder').find('.tplelselect').attr('data-motiv-id');

                ell = $('.elholder[data-motiv-id="' + elId + '"]');
                elementActId = ell.find('.fusedb').find('.detselected').attr('data-value');

                if (pmo && pmo[dataacP] && pmo[dataacP][dataposIndex]) {
                    if (pmo[dataacP][dataposIndex].templateTyp == 'stick') {
                        ell = $('.elholder');
                    }
                }
                $('.colorPicker[data-colorId="' + colorId + '"][data-element="' + elementActId + '"]').each(function () {
                    var elementId = $(this).attr('data-element');
                    $(this).find('input[name="color"]').css('backgroundColor', '#' + color);
                    $(this).find('input[name="color"]').closest('.colorPicker').find('.colorico').css('backgroundColor', '#' + color);
                    //$(this).find('input[name="color"]').closest('.colorPicker').find('.colorico').css('borderColor', '#' + color);
                    $(this).find('.colorico').css('backgroundColor', '#' + color);
                    $(this).find('.colorico').css('borderColor', '#' + color);
                    if (color == 'ffffff') {
                        $(this).find('input[name="color"]').closest('.colorPicker').find('.colorico').css('borderColor', '#000000');
                        $(this).find('.colorico').css('borderColor', '#000000');
                    } else if (color == '000000') {
                        $(this).find('input[name="color"]').closest('.colorPicker').find('.colorico').css('borderColor', '#FFFFFF');
                        $(this).find('.colorico').css('borderColor', '#FFFFFF');
                    }
                });
                clearTimeout(ttTimer);
                ttTimer = setTimeout(function () {
                    $.setMotive(dataacP, dataposIndex, true);
                    if(pmo[dataacP][dataposIndex].rotation && pmo[dataacP][dataposIndex].rotation !== 0){
                        needsMovement = true;
                    }
                }, 300);
            });
            $('input[name="alltexts"]').on('click', function () {
                $(this).closest('div').find('a').trigger('click');
                $('.slideholder, .fontpop').hide();
                return false;
            });
            $('input[name="alltexts"]').on('change', function () {
                var cval = $(this).val();
                $('#templateTextElements').find('input[name="color"]').each(function () {
                    $(this).val(cval).attr('value', cval).css('backgroundColor', '#' + cval).css('color', '#' + cval);
                    $(this).closest('.colorPicker').find('.colorico').css('backgroundColor', '#' + cval);
                    //$(this).closest('.colorPicker').find('.colorico').css('borderColor', '#' + cval);
                    if (cval == 'ffffff') {
                        $(this).closest('.colorPicker').find('.colorico').css('borderColor', '#000000');
                    } else if (cval == '000000') {
                        $(this).closest('.colorPicker').find('.colorico').css('borderColor', '#FFFFFF');
                    }
                });
                clearTimeout(ttTimer);
                ttTimer = setTimeout(function () {
                    var dcp, dpi, active = $('.motivImage').find('.ovholder.active');
                    dpi = active.attr('data-posIndex');
                    dcp = active.attr('data-pos');
                    $.setMotive(dcp, dpi, true);
                }, 0);
            });
            $('.colorPicker a').each(function (index) {
                $(this).prop('tabindex', index + 9999);
            });
            $('#jquery-colour-picker').css('zIndex', 5000);
            $('.desinput').focus(function () {
                $(this).select();
            });
            $(document).on('click', '.colorico', function () {
                $(this).closest('.colorPicker').find('input').first().trigger('click');
                $('.slideholder, .fontpop').hide();
            });
            $(document).on('click', '.colorPicker a', function () {
                var color, el;
                el = $(this).closest('.colorPicker').find('input').first();
                color = el.css('backgroundColor');
                color = $.rgb2hex(color);
                if(!color){
                    color = el.css('backgroundColor');
                }
                color = color.replace('#', '');
                $('#jquery-colour-picker').find('a[rel=' + color + ']').addClass('selected');
                colHolder = $(this).closest('div').find('input[name="color"]');
                colHolder.attr('data-id', $('#jquery-colour-picker').find('a[rel=' + color + ']').attr('data-id'));
                $('.slideholder, .fontpop').hide();
            });
            if (!$('.toggle-slide').length) {
                $.initToggles();
            }
            return true;
        };
        $.updateDesignerElements = function (json) {
            var data, val;
            if (!json) {
                return;
            }
            data = json;
            if ($.type(json) === 'string') {
                data = $.parseJSON(json);
            }
            if (data.text) {
                $.each(data.text, function (a) {
                    val = $.trim(data.text[a]);
                    $('.desinput[name="text[' + a + ']"]').val(val).attr('value', val);
                    if (val == '') {
                        $('.desinput[name="text[' + a + ']"]').closest('.ym-grid').find('.toggles').addClass('dataoff').attr('data-toggle-on', false);
                        //$('.desinput[name="text[' + a + ']"]').closest('.ym-grid').find('.cpia').removeClass('colorico').addClass('coloricoInact');
                    } else {
                        $('.desinput[name="text[' + a + ']"]').closest('.ym-grid').find('.toggles').addClass('dataon');
                        //$('.desinput[name="text[' + a + ']"]').closest('.ym-grid').find('.cpia').removeClass('coloricoInact').addClass('colorico');
                    }
                });
            }
            if (data.color) {
                $.each(data.color, function (a) {
                    var colorinfo, colorpicker;
                    val = data.color[a].split(',').join(', ').toString();
                    colorpicker = $('.desinput[name="text[' + a + ']"]').closest('.ym-grid').find('.colorPicker');
                    colorpicker.find('option').prop('selected', null);
                    colorinfo = colorpicker.find('option[data-rgb="' + val + '"]');
                    colorinfo.prop('selected', true);
                    //colorpicker.find('.colorico').css('backgroundColor', '#' + colorinfo.attr('value'));
                    //colorpicker.find('.colorico').css('borderColor', '#' + colorinfo.attr('value'));
                    colorpicker.find('.colorico').css('backgroundColor', val);
                    //colorpicker.find('.colorico').css('borderColor', val);
                    if (val == 'ffffff') {
                        colorpicker.find('.colorico').css('borderColor', '#000000');
                    } else if (val == '000000') {
                        colorpicker.find('.colorico').css('borderColor', '#FFFFFF');
                    }
                });
            }
            if (data.motivColor) {
                $.each(data.motivColor, function (a) {
                    var colorinfo, colorpicker;
                    val = data.motivColor[a];
                    colorpicker = $('.mcpick').find('.colorPicker[data-colorId="' + a + '"]');
                    colorpicker.find('option').prop('selected', null);
                    colorinfo = colorpicker.find('option[data-rgb="' + val + '"]');
                    colorinfo.prop('selected', true);
                    colorpicker.find('.colorico').css('backgroundColor', '#' + colorinfo.attr('value'));
                    //colorpicker.find('.colorico').css('borderColor', '#' + colorinfo.attr('value'));
                    if (colorinfo.attr('value') == 'ffffff') {
                        colorpicker.find('.colorico').css('borderColor', '#000000');
                    } else if (colorinfo.attr('value') == '000000') {
                        colorpicker.find('.colorico').css('borderColor', '#FFFFFF');
                    }
                });
            }
            if (data.motiv) {
                $.each(data.motiv, function (a) {
                    var colorinfo, val = data.motiv[a], el = $('.detselect[data-motiv-id="' + a + '"]');
                    el.removeClass('selected');
                    colorinfo = el.find('option[data-rgb="' + val + '"]');
                    /* data-value */

                    $('.allelementsholder[data-motiv-id="' + a + '"][data-id="' + data.templateId + '"]').find('.detselect[data-value="' + val + '"]').addClass('selected');
                    el.find('.colorico').css('backgroundColor', '#' + colorinfo.attr('value'));
                    //el.find('.colorico').css('borderColor', '#' + colorinfo.attr('value'));
                    if (colorinfo.attr('value') == 'ffffff') {
                        el.find('.colorico').css('borderColor', '#000000');
                    } else if (colorinfo.attr('value') == '000000') {
                        el.find('.colorico').css('borderColor', '#FFFFFF');
                    }
                });
            }
            if (data.elementColor) {
                $.each(data.elementColor, function (a) {
                    var colorinfo, colorpicker, colorHolder, motivId;
                    val = data.elementColor[a];
                    motivId = $('.colorHolder[data-element-colors="' + a + '"]').closest('.allelementsholder').attr('data-motiv-id');
                    colorHolder = $('.colorHolder[data-element-colors="' + a + '"]').html();
                    //colorHolder = $(this).closest('.detholder').find('.colorHolder').html();
                    $('.detselector[data-motiv-id="' + motivId + '"]').closest('.detholder').find('.elcolorholder').html(colorHolder);
                    $('.detselector[data-motiv-id="' + motivId + '"]').closest('.detholder').find('.elcolorholder').find('.mcpicka').addClass('mcpick');
                    $('.detselector[data-motiv-id="' + motivId + '"]').closest('.detholder').find('.detselector').attr('data-value', a);
                    $.each(val, function (b) {
                        var el;
                        el = $('.colorPicker[data-element="' + a + '"][data-colorId="' + b + '"]');
                        colorinfo = el.find('option[data-rgb="' + data.elementColor[a][b] + '"]');
                        $('.colorPicker[data-element="' + a + '"][data-colorId="' + b + '"]').find('.colorico').css('backgroundColor', '#' + colorinfo.attr('value'));
                        //$('.colorPicker[data-element="' + a + '"][data-colorId="' + b + '"]').find('.colorico').css('borderColor', '#' + colorinfo.attr('value'));
                        if (colorinfo.attr('value') == 'ffffff') {
                            $('.colorPicker[data-element="' + a + '"][data-colorId="' + b + '"]').find('.colorico').css('borderColor', '#000000');
                        } else if (colorinfo.attr('value') == '000000') {
                            $('.colorPicker[data-element="' + a + '"][data-colorId="' + b + '"]').find('.colorico').css('borderColor', '#FFFFFF');
                        }
                    });
                });
            }
        };
        $.replaceUrlParam = function (url, name, value) {
            var pattern, newUrl;
            if (url === undefined) {
                return false;
            }
            pattern = new RegExp('(' + name + '=).*?(&|$)');
            newUrl = url.replace(pattern, '$1' + value + '$2');
            return newUrl;
        };
        $.removeUnusedVElements = function ($wrap) {
            if ($wrap.find('.slidee').height() < $wrap.height() || $wrap.find('.slidee').height() == 0) {
                $wrap.find('.prev, .prevPage, .next, .nextPage, .pages li, .vscrollbar .handle, .vscrollbar').hide();
            } else {
                $wrap.find('.prev, .prevPage, .next, .nextPage, .pages li, .vscrollbar .handle, .vscrollbar').show();
            }
        };
        $.buildVerticalScroller = function (element) {
            var id;
            $(element).each(function () {

                id = $(this).attr('id');
                var $frame = $('#' + id), $wrap;
                //if ($('.mtab[data-id="' + $frame.closest('.tabcontent').attr('id') + '"]').hasClass('active')) {
                    $wrap  = $frame.parent();
                    $.removeUnusedVElements($wrap);

                    $(this).imagesLoaded().done(function (a) {
                        $frame.sly({
                            horizontal: false,
                            scrollBar: $wrap.find('.vscrollbar'),
                            mouseDragging: 1,
                            touchDragging: 1,
                            speed: 300,
                            releaseSwing: 1,
                            activatePageOn: 'click',
                            scrollBy: 100,
                            smart: 1,
                            dragHandle: 1,
                            dynamicHandle: 1,
                            clickBar: 1,
                            elasticBounds: false
                        });
                        $.removeUnusedVElements($wrap);
                        $frame.sly('on', 'load', function (e) {
                            $.removeUnusedVElements($wrap);
                        });
                    });
                //}
            });
        };
        function motivDesigner_setZoomElemente() {
            var tmpLeft = parseInt(($('.motivImage').width() - $('.motivImage').children('.flexible').width()) / 2, 10) + zoomLeftDiff;
            $('.motivZoom_img').find('.motivZoom_overlay').remove();
            $('.motivImage').find('.overlayImage').each(function (index) {
                var tmpOverlay = $('<img/>').addClass('motivZoom_overlay')
                                            .attr('src', $(this).attr('src'))
                                            .css('top', parseInt($(this).position().top * zoomFac, 10))
                                            .css('left', parseInt(($(this).position().left) * zoomFac, 10) - parseInt(tmpLeft * 1.85, 10))
                                            .width($(this).width() * zoomFac)
                                            .height($(this).height() * zoomFac);
                $(this).closest('.motivImage').find('.motivZoom_img').append(tmpOverlay);
            });
            $('.motivZoom_overlay').each(function () {
                var tmpSrc = $.replaceUrlParam($(this).attr('src'), 'width', parseInt($(this).width(), 10));
                tmpSrc = $.replaceUrlParam(tmpSrc, 'height', parseInt($(this).height(), 10));
                $(this).attr('src', tmpSrc);
            });
        }
        function motivDesigner_setZoomEvent() {
            $('.motivImage').children('.flexible').on('mouseenter', function () {
                if ($(this).parent().find('.motivZoom').length == 0) {
                    var tmpLeft, prodImg, tmpImgObj, tmpZoom;
                    tmpLeft = parseInt(($('.motivImage').width() - $('.motivImage').children('.flexible').width()) / 2, 10) + zoomLeftDiff;
                    prodImg = $('<img/>').addClass('motivZoom_article')
                        .attr('src', $(this).attr('src'))
                        .width($(this).width() * zoomFac)
                        .height($(this).height() * zoomFac);
                    tmpImgObj = $('<div></div>').addClass('motivZoom_img')
                        .width($(this).width() * zoomFac)
                        .height($(this).height() * zoomFac)
                        .append(prodImg);
                    tmpZoom = $('<div></div>').addClass('motivZoom')
                        .css('left', tmpLeft)
                        .width($('.motivImage').children('.flexible').width())
                        .height($('.motivImage').children('.flexible').height())
                        .append(tmpImgObj)
                        .on('mouseleave', function () {
                            $('.motivZoom').remove();
                        }).mousemove(function (e) {
                            var parentOffset = $(this).offset(), relX, relY;
                            relX = parseInt(e.pageX - parentOffset.left, 10);
                            relY = parseInt(e.pageY - parentOffset.top, 10);
                            $(this).find('.motivZoom_img').css('left', parseInt(relX, 10) * -1).css('top', parseInt(relY, 10) * -1);
                        });
                    $(this).parent().append(tmpZoom);
                    motivDesigner_setZoomElemente();
                    $('.motivZoom_article').each(function () {
                        var tmpSrc = $.replaceUrlParam($(this).attr('src'), 'width', parseInt($(this).width(), 10));
                        tmpSrc = $.replaceUrlParam(tmpSrc, 'height', parseInt($(this).height(), 10));
                        $(this).attr('src', tmpSrc);
                    });
                }
            });
        }
        $(function () {
            motivDesigner_setZoomEvent();
        });
        $(document).on('click', '.resetmotiv', function () {
            var dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active'), datajson;
            dataposIndex = active.attr('data-posIndex');
            dataacP = active.attr('data-pos');
            $('#meditor').html(defaultMotives[pmo[dataacP][dataposIndex].template]);
            datajson = $('.activeTemplate').find('span[data-defaulttemplate="' + pmo[dataacP][dataposIndex].template + '"]').attr('data-json');
            if (datajson) {
                $.updateDesignerElements(datajson);
                $.initColorpicker();
                $.setMotive(dataacP, dataposIndex, true);
                $.loadMotiveDragger();
                $('#meditorScroller').sly('reload');

            } else {
                $.setMotive(dataacP, dataposIndex, true);
                $.loadMotiveDragger();
                $('#meditorScroller').sly('reload');
            }
        });
        $(document).on('click', '.notext', function () {
            var input = $(this).closest('.ym-fbox-text').find('input.desinput'), dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
            if (input.val() === ' ') {
                return;
            }
            input.val(' ').attr('value', ' ');
            dataposIndex = active.attr('data-posIndex');
            dataacP = active.attr('data-pos');
            $.setMotive(dataacP, dataposIndex, true);
        });
        $(document).on('click', '.delmotive', function () {
            var trash, type;
            trash = $(this).attr('data-m');
            $.each(pmo, function (a) {
                $.each(pmo[a], function (b) {
                    if (pmo[a][b].imageid == trash) {
                        if (pmo[a][b].defMot == 1 && parseFloat($('.baseprice').first().attr('data-price')) > parseFloat($('.basepriceProduct').first().attr('data-price'))) {
                            $('.basepriceDefaultMotives').first().attr('data-price',  (parseFloat($('.baseprice').first().attr('data-price')) - parseFloat($('.basepriceProduct').first().attr('data-price'))));
                        }
                        type = $('.motivImage').find('.motov[data-id="' + trash + '"]').attr('data-ptyp');
                        $('.motov[data-id="' + trash + '"]').remove();
                        delete pmo[a][b];
                    }
                });
                if ($.isEmptyObject(pmo[a])) {
                    delete pmo[a];
                }
            });
            $(this).closest('li').remove();
            if (type == 'upload') {
                $('.mtab[data-id="mfileupload"]').trigger('click');
            } else if (type == 'text') {
                //$('.mtab[data-id="mtextmodule"]').trigger('click');
            } else {
                $('.mtab[data-id="motivselector"]').trigger('click');
            }
            //$.updatePriceDiv();
            $.updateCreation();
            $('.ccHolder').hide();
            $('.errorpoint').remove();
        });
        $(document).on('click', '.mottotrash', function () {
            var uuid, datad = {};
            uuid = $(this).closest('.imglist').find('.motupload').attr('data-uuid');
            datad.uuid = uuid;
            $.ajax({
                data: datad,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=delupload&language=' + $('html').attr('lang'),
                success: function (data) {
                    var ic = $('.motupload[data-uuid="' + uuid + '"]').closest('.imglist');
                    if (data.success) {
                        $.setInfo(data.success);
                        ic.remove();
                        $('#mfileuploadScroller').sly('reload');
                    }
                }
            });
        });
        $(document).on('click', '.favtotrash', function () {
            var crid, datad = {};
            crid = $(this).closest('li').find('a').attr('data-crid');
            datad.crid = crid;
            $.ajax({
                data: datad,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=delfav&language=' + $('html').attr('lang'),
                success: function (data) {
                    var ic = $('.ovholder[data-crid="' + crid + '"]').find('.addtofav');
                    if (data.success) {
                        $.setInfo(data.success);
                        ic.removeClass('isFavorite');
                        ic.removeClass('ui-state-highlight');
                        $('.favorites').trigger('click');
                    }
                }
            });
        });
        $(document).on('click', '.addtofav', function () {
            var crid, that, div, ddata = {}, title, templateId;
            that = this;
            crid = $(this).closest('.ovholder').attr('data-crid');
            templateId = $(this).closest('.ovholder').attr('data-template');
            title = $('.temselect[data-value="' + templateId + '"]').attr('data-title');
            if ($(that).hasClass('isFavorite')) {
                return false;
            }
            if (crid) {
                ddata.crid = crid;
                div = $('<div />');
                div.html('<label for="lsd34">Favoriten-Name</label><input maxlength="32" type="text" name="favname" id="lsd34" value="' + title + '"/>');
                div.addClass('add2fav');
                $(div).dialog({
                    autoOpen: true,
                    modal: true,
                    title: 'Zu Favoriten hinzufügen',
                    resizable: false,
                    draggable: false,
                    closeText: 'schließen',
                    show: {effect: 'puff', duration: 222},
                    hide: {effect: 'clip', duration: 222},
                    close: function () {
                        $('.add2fav').remove();
                        return true;
                    },
                    buttons: {
                        'Speichern': function () {
                            ddata.title = $('input[name="favname"]').val();
                            $.ajax({
                                data: ddata,
                                dataType: 'json',
                                cache: false,
                                type: 'POST',
                                url: '/ajax/ajax_update_designer.php?action=fav&language=' + $('html').attr('lang'),
                                success: function (data) {
                                    if (data.success) {
                                        $.setInfo(data.success);
                                        $(that).addClass('ui-state-highlight');
                                        $(that).addClass('isFavorite');
                                    }
                                }
                            });
                            $(this).dialog('close');
                        },
                        'Abbrechen': function () {
                            $(this).dialog('close');
                        }
                    }
                });
            } else {
                $.setInfo('nicht möglich');
            }
        });
        $(document).on('click', '.showhelp', function () {
            var div, ccontent, title;
            div = $('<div />');
            title = $('#mothelp').attr('data-title');
            ccontent = $('#mothelp').html();
            div.html(ccontent);
            div.css('border', '1px solid #ccc');
            div.css('borderTop', 'none');
            div.css('background', '#eee');
            $('.ui-dialog-content').dialog("close");
            $(div).dialog({
                autoOpen: true,
                modal: false,
                title: title,
                resizable: true,
                draggable: true,
                closeText: 'schließen',
                position: {my: 'center-20 top+20', at: 'center-20 top+20', of: '#designer'},
                width: $('#designer').innerWidth() - 6,
                show: {effect: 'puff', duration: 222},
                hide: {effect: 'clip', duration: 222},
                close: function () {
                    return true;
                }
            });
        });
        $.checkPossibility = function (clicker) {
            var iy = 0, mots = 0, ix = 0, conflictHtml, div, title, ret = true, desiredTheme, conflict = false, msg, i = 0, conflictMotivs = {};
            desiredTheme = $('select[name="thworld"]').find('option[value="' + $(clicker).attr('data-tw') + '"]').val();
            mots = $('.jsMsThumbs').find('.ovimga').length;
            if ($('select[name="thworld"]').find('option[data-nomix]').length === 0 || mots === 0) {
                return true;
            }
            $.each(pmo, function (a) {
                iy = iy + 1;
                $.each(pmo[a], function (b) {
                    if (pmo[a][b].soapId) {
                        i = i + 1;
                    }
                    ix = ix + 1;
                });
            });
            $.each(pmo, function (a) {
                $.each(pmo[a], function (b) {
                    if (!pmo[a][b].defMot && pmo[a][b].soapId && desiredTheme !== pmo[a][b].theme) {
                        if ($('select[name="thworld"]').find('option[value="' + pmo[a][b].theme + '"]').attr('data-nomix')) {
                            conflict = true;
                            msg = 'Dieses Motiv ist mit einem bereits gewählten Motiv nicht kombinierbar.';
                            if (conflictMotivs[a] == undefined) {
                                conflictMotivs[a] = {};
                            }
                            conflictMotivs[a][b] = pmo[a][b];
                        }
                        if ($('select[name="thworld"]').find(':selected').attr('data-nomix')) {
                            conflict = true;
                            msg = 'Das gewählte Motiv ist mit einem Motiv nicht kombinierbar.';
                            if (conflictMotivs[a] == undefined) {
                                conflictMotivs[a] = {};
                            }
                            conflictMotivs[a][b] = pmo[a][b];
                        }
                        ret = false;
                    }
                });
            });
            if (ret === false && conflict === true) {
                $.loadOverlay(true);
                conflictHtml = '';
                $.each(conflictMotivs, function (a) {
                    $.each(conflictMotivs[a], function (b) {
                        var posLabel = $('#pos_' + a).attr('data-label'), typLabel = conflictMotivs[a][b].label;
                        conflictHtml += '<li class="conflict"><p><img src="' + conflictMotivs[a][b].image + '"/> <span id="md_' + a + '_' + b + '_' + a + '_' + conflictMotivs[a][b].aPT + '" data-m="' + conflictMotivs[a][b].imageid + '" class="delconflict psa posidel' + a + '" data-pos="' + a + '" data-index="' + b + '" data-posTyp="' + conflictMotivs[a][b].aPT + '"><span class="icon-trash"></span> ' + typLabel + ' ' + conflictMotivs[a][b].templatelabel + ' ' + posLabel + ' löschen</span></p><hr /></li>';
                    });
                });
                msg = '<p>' + msg + '</p><ul class="noli">' + conflictHtml + '</ul>';
                div = $('<div />');
                title = 'Achtung';
                div.html(msg);
                $(div).dialog({
                    autoOpen: true,
                    modal: true,
                    title: title,
                    resizable: false,
                    draggable: false,
                    closeText: 'schließen',
                    maxWidth: $('#designer').innerWidth(),
                    position: {my: 'center top', at: 'center top', of: '#designer .ym-grid'},
                    width: $('#designer').innerWidth() - 6,
                    show: {effect: 'puff', duration: 222},
                    hide: {effect: 'clip', duration: 222},
                    close: function () {
                        if ($('.conflict').length == 0) {
                            $(clicker).trigger('click');
                            $.loadOverlay(true);
                        }
                        $('.conflict').remove();
                        $.loadOverlay(true);
                        return true;
                    }
                });
                ret = false;
                $.loadOverlay(true);
            } else {
                return true;
            }
        };
        $(document).on('click', '.delconflict', function () {
            var trash, conflicts;
            trash = $(this).attr('data-m');
            $('.delmotive[data-m="' + trash + '"]').trigger('click');
            $(this).closest('li').remove();
            conflicts = $('.conflict').length;
            if (conflicts == 0) {
                $('.ui-dialog-content').dialog('close');
            }
        });
        $.changePosition = function () {
            var selPrint, selStick, selNewPrint, selNewStick, imageHolder, dataPos, verso, dataPositionsId, origPos, origholder, wrapper, activePosTypOrig, stage, orig, origPositionsId;
            if ($(this).hasClass('selected')) {
                return false;
            }
            if ($('.motselect.ui-droppable').length) {
                $('.motselect.ui-droppable').droppable('destroy');
            }
            $('.motruler').hide().remove();
            //check gebiet for printable/stickable


            selPrint = $('#motfilter').find('.tfilter[data-type="2"]').hasClass('active') ? 1 : 0;
            selStick = $('#motfilter').find('.tfilter[data-type="1"]').hasClass('active') ? 1 : 0;
            wrapper = $(this).closest('.hastheaction');
            if (!wrapper.length) {
                wrapper = $(this).closest('.listItem');
            }
            wrapper.find('.jsMsThumbs').find('a').removeClass('selected');
            $(this).addClass('selected');
            dataPos = $(this).attr('data-pos');
            dataPositionsId = $(this).attr('data-positionsId');

            $('.tfilter[data-type="2"]').removeClass('noposs').removeClass('active');
            $('.tfilter[data-type="1"]').removeClass('noposs').removeClass('active');

            $('.mtadruck').show();
            $('.mtastick').show();
            if (!$('#motpos' + dataPos).closest('li').find('.gebiet[data-fuer-druck=1]').length) {

                    $('.mtadruck').hide();
                    //$('.tfilter[data-type="1"]').trigger('click');
                    $('.tfilter[data-type="1"]').addClass('active');
                    $('.tfilter[data-type="2"]').addClass('noposs');

                    selNewPrint = 0;
                    selNewStick = 1;
                    $.filterTemplates();
            }
            if (!$('#motpos' + dataPos).closest('li').find('.gebiet[data-fuer-stick=1]').length) {
                    $('.mtastick').hide();
                    //$('.tfilter[data-type="2"]').trigger('click');
                    $('.tfilter[data-type="1"]').addClass('active');
                    $('.tfilter[data-type="1"]').addClass('noposs');
                    selNewPrint = 1;
                    selNewStick = 0;
                    $.filterTemplates();
            }

            if((selNewPrint || selNewStick) && (selNewPrint != selPrint && selNewStick != selStick)){

            } else {
                if(selPrint){
                    $('#motfilter').find('.tfilter[data-type="2"]').addClass('active')
                }
                if(selStick){
                    $('#motfilter').find('.tfilter[data-type="1"]').addClass('active')
                }
            }
            activePosTypOrig = $('#motivDesignerForm').attr('data-activePositionsTyp');
            $('.topbox').find('.overlayimg' + dataPos).show();
            $('.topbox').find('.overlayimg' + activePosTypOrig).hide();
            $('#motivDesignerForm').attr('data-activePos', dataPositionsId);
            $('#motivDesignerForm').attr('data-activePositionsTyp', dataPos);
            $('.temselect').removeClass('selected');
            $('.uploadselect').removeClass('selected');
            imageHolder = wrapper.find('.motivImage');
            imageHolder.remove('.tmpimg').css('height', imageHolder.outerHeight());
            verso = wrapper.find('.orig' + dataPos).html();
            origPos = imageHolder.attr('data-pos');
            $('.ndimg').each(function () {
                var src, img, newSrc, bildId;
                img = $(this).find('img').first();
                src = img.attr('src');
                bildId = $(this).closest('.fleinner').find('.tapinfo[data-pos="' + dataPos + '"]').attr('data-bildId');
                newSrc = $.replaceUrlParam(src, 'id', bildId);
                if (bildId !== undefined && !imgs[newSrc]) {
                    imgs[newSrc] = true;
                }
                if (bildId !== undefined) {
                    img.attr('src', newSrc);
                    $(this).removeClass('hasMotiv' + origPos).addClass('hasMotiv').addClass('hasMotiv' + dataPos);
                }
            });
            origholder = wrapper.find('.origholder');
            stage = wrapper.find('.motivImage');
            origPos = stage.attr('data-pos');
            origPositionsId = stage.attr('data-positionsId');
            stage.removeClass('hasMotiv' + origPos).addClass('hasMotiv').addClass('hasMotiv' + dataPos);
            wrapper.find('.orig' + origPos).remove();
            orig = $('<div />')
                .addClass('orig' + origPos)
                .attr('data-positionsId', origPositionsId)
                .addClass('hideed hasMotiv medf')
                .addClass('hasMotiv' + origPos)
                .width(stage.width())
                .css('textAlign', stage.css('textAlign'))
                .html(stage.html());
            orig.find('.stageHolder').width(stage.width());
            origholder.append(orig);
            wrapper.find('.motivImage').attr('data-pos', dataPos).attr('data-positionsId', dataPositionsId);
            wrapper.find('.motivImage').html(verso);
            $('.motivImage').imagesLoaded().done(function (a) {
                motivDesigner_setZoomEvent();
                $.loadOverlay(true);
                $.loadMotiveDragger();
                //$.initColorpicker();

                $('.ovholder').removeClass('active');
                $('.clone-type-configurator > ul > li').removeClass('active');
                $('.ovholder').find('.activewrapper').hide();
                $('.ovholder').find('.outerhelper').hide();
            });
            $('.mtab[data-id="motivselector"]').trigger('click');
        };
        $(document).on('click', '.motselect', $.changePosition);
        //$('.motselect').on('click', $.changePosition);
        $(document).on('click', 'input[name="uploadTrim"]', function (e) {
            var dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
            dataposIndex = active.attr('data-posIndex');
            dataacP = active.attr('data-pos');
            $.setMotive(dataacP, dataposIndex, true);
        });
        $(document).on('click', '.detselector', function () {
            var holder, width, height, active;
            $('.allelementsholder').hide();
            $('.fusedb').removeClass('selected');
            $(this).closest('.fusedb').addClass('selected');
            width = $('#motivElements').width();
            height = $('.fusedb').first().height();
            active = $('.motivImage').find('.ovholder.active');
            holder = $('.allelementsholder[data-motiv-id="' + $(this).attr('data-motiv-id') + '"][data-id="' + active.attr('data-template') + '"]').css('minHeight', height);
            if (!holder.hasClass('added')) {
                holder.addClass('added');
                holder.appendTo($('.mtadetails'));
            }
            $('#motivElements').hide();
            holder.show();
            if ($('#meditorScroller').data('sly')) {
                $('#meditorScroller').sly('reload');
                $('#meditorScroller').sly('toStart', $('.mtadetails').eq(0), true);
            } else {
                $.buildVerticalScroller('#meditorScroller');
                $('#meditorScroller').sly('toStart', $('.mtadetails').eq(0), true);
            }
        });
        $(document).on('click', '.elcloser', function () {
            $('.allelementsholder').hide();
            if ($('#meditorScroller').data('sly')) {
                $('#meditorScroller').sly('toStart', true);
            }
            $('#motivElements').show();
            $('.fusedb').removeClass('selected');
        });
        $(document).on('click', '.detselect', function () {
            if ($(this).hasClass('selected')) {
                return false;
            }
            clearTimeout(ttTimer);
            var dataacP, newImage, motivId, dataposIndex, active = $('.motivImage').find('.ovholder.active'), colorHolder;
            $(this).closest('.allelementsholder').find('.detselect').removeClass('selected');
            $(this).addClass('selected');
            newImage = $(this).find('.ise').attr('src');
            motivId = $(this).attr('data-motiv-id');


            if ($('.colorPicker[data-element="' + $(this).closest('.detholder').find('.colorHolder').attr('data-element-colors') + '"]').attr('data-colorId')) {
                colorHolder = $(this).closest('.detholder').find('.colorHolder').html();
                $('.detselector[data-motiv-id="' + motivId + '"]').closest('.detholder').find('.elcolorholder').html(colorHolder);
            } else {
                $('.detselector[data-motiv-id="' + motivId + '"]').closest('.detholder').find('.elcolorholder').html('');
            }
            $('.detselector[data-motiv-id="' + motivId + '"]').closest('.detholder').find('.detselector').attr('data-value', $(this).attr('data-value'));

            $('.detselector[data-motiv-id="' + motivId + '"]').closest('.detholder').find('.elcolorholder').find('.mcpicka').addClass('mcpick');
            $.initColorpicker();
            $('.detselector[data-motiv-id="' + motivId + '"]').find('.ise').attr('src', newImage);
            dataposIndex = active.attr('data-posIndex');
            dataacP = active.attr('data-pos');

            if ($('#meditorScroller').data('sly')) {
                $('#meditorScroller').sly('toStart', true);
            }

            $('.allelementsholder').hide();
            $('#motivElements').show();
            $.checkTextFields();
            $.setMotive(dataacP, dataposIndex, true);
        });
        $(document).on('click', '.uploadselect .holder', function (e) {
            e.preventDefault();
            var acp;
            acp = $('#motivDesignerForm').attr('data-activePositionsTyp');
            if (!$('#motpos' + acp).closest('li').find('.gebiet[data-fuer-druck=1]').length) {
                $.setInfo('Bei diesem Artikel ist leider kein Druck möglich');
                return false;
            }
            $('.ovholder').removeClass('active');
            $('.clone-type-configurator > ul > li').removeClass('active');
            $('.outerhelper').hide();
            $('.activewrapper').hide();

            $('.temselect').removeClass('selected');
            $('.uploadselect').removeClass('selected');
            $(this).closest('.uploadselect').addClass('selected');
            $.setMotive();
            return;
        });
        $(document).on('click', '.favselect', function (e) {
            e.preventDefault();
            var template = $(this).attr('data-template'), crid = $(this).attr('data-crid'), ddata = {};
            ddata.crid = crid;
            $.ajax({
                data: ddata,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax_update_designer.php?action=getfav&language=' + $('html').attr('lang'),
                success: function (res) {
                    if (res) {
                        var motivp, motivi, renew, isReload, isMover;
                        $('.temselect').removeClass('selected');
                        $('.temselect[data-value="' + template + '"]').addClass('selected');
                        $.activateThemelist($('#thwlist').find('a[data-theme="' + $('.temselect[data-value="' + template + '"]').closest('.thelist').attr('data-theme') + '"]'));

                        $.setMotive(motivp, motivi, renew, isReload, isMover, res);
                        $.activateMotive($('.motivImage').find('.ovholder.active'));
                        $('.ovholder[data-crid="' + crid + '"]').find('.addtofav').addClass('ui-state-highlight isFavorite');
                    }
                }
            });
        });
        $(document).on('click', '.thelist div.relative', function (e) {
            if (!$(e.target).hasClass('temselect')) {
                $('.allelementsholder').hide();
                $('#motivElements').show();
                $(this).find('.temselect').trigger('click');
            }
        });
        $(document).on('click', '.temselect', function (e) {
            e.preventDefault();
            $('.ovholder').removeClass('active');
            $('.clone-type-configurator > ul > li').removeClass('active');
            $('.ovholder').find('.outerhelper').hide();
            $('.ovholder').find('.activewrapper').hide();
            $.loadOverlay();
            clearTimeout(ttTimer);
            var allow = false;
            allow = $.checkPossibility(this);
            if (allow === true) {
                $('.temselect').removeClass('selected');
                $('.uploadselect').removeClass('selected');
                $(this).addClass('selected');
                ttTimer = setTimeout(function () {
                    $.loadTemplate();
                }, 200);
            }
        });
        $(document).on('click', '.updatetext', function (e) {
            var dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
            dataposIndex = active.attr('data-posIndex');
            dataacP = active.attr('data-pos');
            $.loadOverlay(false, pmo[dataacP][dataposIndex].ajaxId);
            if (xhr && pmo && pmo[dataacP][dataposIndex].ajaxId && xhr[pmo[dataacP][dataposIndex].ajaxId]) {
                xhr[pmo[dataacP][dataposIndex].ajaxId].abort();  //tempdisabled
            } else if (xhr && ajaxId && xhr[ajaxId]) {
                xhr[ajaxId].abort();  //tempdisabled
            }
            $.setMotive(dataacP, dataposIndex, true);
        });
        $(document).on('keypress', '#motivDesignerForm input:text.textinput', function (e) {
            var code;
            code = e.keyCode || e.which;
            if (code == 9) {
                $('#motivDesignerForm input:text.textinput:eq(' + ($('#motivDesignerForm input:text.textinput').index(this) + 1) + ')').focus();
            }
        });
        /* NOTIZ, muss hier der if block sein? DT 150815 */
        //if ($('#sticktext').length) {
            $.buildSlider = function () {
                $('.tradius').each(function(){
                    var that = this;
                    if(!$(this).data('slider')){
                        $(this).slider({
                            min: -1000,
                            max: 1000,
                            step: 50,
                            value: 0,
                            orientation: 'vertical',
                            slide: function (event, ui) {
                                if (ui.value == 0){
                                    $(that).find('.ui-slider-handle').addClass('bgcol1');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-active');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-focus');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-hover');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-default');
                                } else {
                                    $(that).find('.ui-slider-handle').removeClass('bgcol1');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-active');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-focus');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-hover');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-default');
                                }
                            },
                            stop: function (event, ui) {
                                var tt = 500;
                                clearTimeout(ttTimer);
                                $('.slideholder').hide();
                                ttTimer = setTimeout(function () {
                                    var that, dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
                                    that = $('#sticktext');
                                    dataposIndex = active.attr('data-posIndex');
                                    dataacP = active.attr('data-pos');
                                    // motivp, motivi, renew, isReload, isMover, res
                                    if ($(that).val() && $.trim($(that).val())) {
                                        $.setMotive(dataacP, dataposIndex);
                                        needsMovement = true;
                                    }
                                }, tt);
                            }
                        });
                    }
                });
                $('.lineheight').each(function(){
                    var that = this;
                    if(!$(this).data('slider')){
                        $(this).slider({
                            min: 0,
                            max: 20,
                            step: 1,
                            value: 4,
                            orientation: 'vertical',
                            slide: function (event, ui) {
                                if (ui.value == 4){
                                    $(that).find('.ui-slider-handle').addClass('bgcol1');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-active');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-focus');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-hover');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-default');
                                } else {
                                    $(that).find('.ui-slider-handle').removeClass('bgcol1');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-active');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-focus');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-hover');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-default');
                                }
                            },
                            stop: function (event, ui) {
                                var tt = 500;
                                clearTimeout(ttTimer);
                                $('.slideholder').hide();
                                ttTimer = setTimeout(function () {
                                    var text, that, dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
                                    that = $('#sticktext');
                                    dataposIndex = active.attr('data-posIndex');
                                    dataacP = active.attr('data-pos');
                                    // motivp, motivi, renew, isReload, isMover, res
                                    if ($(that).val() && $.trim($(that).val())) {
                                        text = $.trim($(that).val());
                                        text = text.split('\n');
                                        //text = $.grep(text,function(n){ return(n) });
                                        if (text.length > 1) {
                                            $.setMotive(dataacP, dataposIndex);
                                            needsMovement = true;
                                        }
                                    }
                                }, tt);
                            }
                        });
                    }
                });
                /*
            widget = $('.ovholder.active');
            center = $('.motivImage').find('.drov').width() / 2;
            distance = center - widget.position().left - widget.width() / 2;
            distance = Math.ceil(distance);
            if (distance > 0 || distance < 0) {
                widget.simulate('drag', {
                    dx: distance,
                    moves: 1
                });
            }
            */
                $('.fontsize').each(function(){
                    var that = this;
                    if(!$(this).data('slider')){
                        $(this).slider({
                            min: 8,
                            max: 100,
                            step: 1,
                            value: 15,
                            orientation: 'vertical',
                            slide: function (event, ui) {
                                if (ui.value == 10){
                                    $(that).find('.ui-slider-handle').addClass('bgcol1');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-active');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-focus');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-hover');
                                    $(that).find('.ui-slider-handle').removeClass('ui-state-default');
                                } else {
                                    $(that).find('.ui-slider-handle').removeClass('bgcol1');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-active');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-focus');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-hover');
                                    $(that).find('.ui-slider-handle').addClass('ui-state-default');
                                }
                            },
                            stop: function (event, ui) {
                                var tt = 800;
                                clearTimeout(ttTimer);
                                $('.slideholder').hide();
                                ttTimer = setTimeout(function () {
                                    var text, that, dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
                                    that = $('#sticktext');
                                    dataposIndex = active.attr('data-posIndex');
                                    dataacP = active.attr('data-pos');
                                    // motivp, motivi, renew, isReload, isMover, res
                                    if ($(that).val() && $.trim($(that).val())) {
                                        $.setMotive(dataacP, dataposIndex);
                                        needsMovement = true;
                                    }
                                }, tt);

                            }
                        });
                    }
                });
            };
            $.buildTformat = function (active) {
                var text, that = $('#sticktext'), i = 1, src, isrc, rowId, row, rgb, font, lineheight, fontsize, tradius, rgb, ausrichtung, activeType;
                text = $.trim($(that).val());
                text = text.split('\n');
                //text = $.grep(text,function(n){ return(n) });
                activeType = $('.textmottype.active').attr('data-type');
                if ($('.tformat').length !== text.length) {
                    src = that.closest('.ym-grid').find('.tformat').eq(0).clone();
                    $('.clonedtf').remove();
                    src.addClass('clonedtf');
                    row = that.closest('.ym-grid').find('.tformat').eq(0);
                    font = row.find('.sfont[data-type="' + $('.textmottype.active').attr('data-type') + '"]').find('.cfont.selected').attr('data-value');
                    ausrichtung = row.find('.causrichtung.selected').attr('data-value');
                    lineheight = row.find('.lineheight').slider('value');
                    fontsize = row.find('.fontsize').slider('value');
                    //tradius = row.find('.tradius').slider('value');
                    rgb = row.find('.txtColorPicker').find('input[name="color"]').val();
                    $.each(text, function (a) {
                        if (a > 0) {
                            rowId = parseInt(a, 10) + 1;
                            isrc = src.clone();
                            isrc.attr('data-row', rowId);
                            $('.tformatholder').append(isrc);
                            $.buildSlider();
                            isrc.find('.causrichtung').removeClass('selected');
                            isrc.find('.causrichtung[data-value="' + ausrichtung + '"]').addClass('selected');
                            isrc.find('.sfont[data-type="' + $('.textmottype.active').attr('data-type') + '"]').find('.cfont').removeClass('selected');
                            isrc.find('.sfont[data-type="' + $('.textmottype.active').attr('data-type') + '"]').find('.cfont[data-value="' + font + '"]').addClass('selected');
                            isrc.find('.lineheight').slider('value', lineheight);
                            isrc.find('.tradius').slider('value', 0);
                            isrc.find('.fontsize').slider('value', fontsize);
                            $.initColorpicker();
                            isrc.find('.txtColorPicker').find('input[name="color"]').attr('value', rgb).val(rgb).css('backgroundColor', '#' + rgb);;
                            isrc.find('.txtColorPicker').find('.colorico').css('backgroundColor', '#' + rgb);
                            if (rgb == 'fff') {
                                isrc.find('.txtColorPicker').find('.colorico').css('borderColor', '#000000');
                            } else if (rgb == '000') {
                                isrc.find('.txtColorPicker').find('.colorico').css('borderColor', '#FFFFFF');
                            }
                        }
                    });
                }
                if (active && active.text) {
                    $.each(active.text, function(e) {
                        rowId = parseInt(e, 10) + 1;
                        row = $('.tformat[data-row="' + rowId + '"]');
                        if (row.length) {
                            row.find('.sfont[data-type="' + $('.textmottype.active').attr('data-type') + '"]').find('.cfont').removeClass('selected');
                            row.find('.sfont[data-type="' + $('.textmottype.active').attr('data-type') + '"]').find('.cfont[data-value="' + active.text[e].schriftartId + '"]').addClass('selected');
                            row.find('.causrichtung').removeClass('selected');
                            row.find('.causrichtung[data-value="' + active.text[e].ausrichtung + '"]').addClass('selected');

                            row.find('.causrichtung[data-value="' + active.text[e].ausrichtung + '"]').closest('.selsom').find('.selfont').text(row.find('.causrichtung[data-value="' + active.text[e].ausrichtung + '"]').find('.smico').text());

                            row.find('.lineheight').slider('value', active.text[e].zeilenabstand);
                            row.find('.tradius').slider('value', active.text[e].tradius);
                            row.find('.fontsize').slider('value', active.text[e].schrifthoehe);
                            rgb = row.find('.txtColorPicker').find('option[data-mad="' + active.text[e].farbe  + '"]').val();
                            row.find('.txtColorPicker').find('input[name="color"]').attr('value', rgb).val(rgb).css('background', '#' + rgb);

                            row.find('.txtColorPicker').find('.colorico').css('backgroundColor', '#' + rgb);
                            if (rgb == 'fff') {
                                row.find('.txtColorPicker').find('.colorico').css('borderColor', '#000000');
                            } else if (rgb == '000') {
                                row.find('.txtColorPicker').find('.colorico').css('borderColor', '#FFFFFF');
                            }
                            //$(this).attr('value', rgb).val(rgb);.find('option[value="' + $.rgb2hex(colorRgb).replace('#', '') + '"]').first().attr('data-mad')
                            if (text[e] == '') {
                                row.find('.selsom').addClass('ym-hideme');
                            } else {
                                row.find('.selsom').removeClass('ym-hideme');
                            }
                        }
                    });
                }
                if ($('#mtextmoduleScroller').data('sly')) {
                    $('#mtextmoduleScroller').sly('reload');
                } else {
                    $.buildVerticalScroller('#mtextmoduleScroller');
                }
                if (activeType == 'druck') {
                    $('.selfontrad, .nobiegung').addClass('hide');
                } else {
                    $('.selfontrad, .nobiegung').removeClass('hide');
                }
            };
            $.buildSlider();
            $.adjustTextField = function () {
                var newLines = $('#sticktext').val().split('\n'), texts = [], i = 1, elines = 1, extra = 0, height, origheight, lineheight, div;
                origheight = 150;
                $('#sticktext').height(origheight);
                $('.txtlineadded').remove();
                lineheight = origheight / 5;
                $.each(newLines, function (a) {
                    var val = newLines[a], top;
                    if (i >= 5) {
                        extra = extra + lineheight;
                        div = $('<div />');
                        div.addClass('txtline');
                        div.addClass('txtlineadded');
                        top = parseInt($('.txtline1').css('top'), 10);
                        top = top + (30 * (i - 1));
                        div.css('top', top);
                        $('#sticktext').closest('.stholder').find('.txtline').closest('div').append(div);
                        elines = elines + 1;
                    }
                    i = i + 1;
                });
                $('#sticktext').height(extra + origheight);
            };
            $(document).on('click', '.moreText', function (e) {
                var text;
                $('#sticktext').val($('#sticktext').attr('placeholder'));
                $('.clonedtf').remove();
                $('.ovholder').removeClass('active');
                $('.clone-type-configurator > ul > li').removeClass('active');
                $('.ovholder').find('.activewrapper').hide();
                $('.ovholder').find('.outerhelper').hide();
                $('.motruler').hide().remove();
                $.initColorpicker();
                if ($(window).width() >= 1280) {
                    $('#sticktext').focus();
                }
                text = $.trim($('#sticktext').val());
                text = text.split('\n');
                $.setMotive(null, null, null, null, null, null, text);
                $('#sticktext').val('');
            });
            $(document).on('click', '.slinc', function (e) {
                var slider = $(this).closest('.slideholder').find('.fontslider'), step, current;
                step = slider.slider('option', 'step');
                current = slider.slider('option', 'value');
                slider.slider('value', current + step);
                slider.slider('option', 'stop').call(slider);
            });
            $(document).on('click', '.sldec', function (e) {
                var slider = $(this).closest('.slideholder').find('.fontslider'), step, current;
                step = slider.slider('option', 'step');
                current = slider.slider('option', 'value');
                slider.slider('value', current - step);
                slider.slider('option', 'stop').call(slider);
            });
            $(document).on('click', '.openslider', function (e) {
                $('.slideholder, .fontpop').hide();
                $(this).find('.slideholder').show();
            });
            $(document).on('click', '.selfont', function (e) {
                $('.slideholder, .fontpop').hide();
                var type = $('.textmottype.active').attr('data-type');
                $(this).closest('.selsom').find('.fontpop[data-type="' + type + '"]').show();
                if ($('#mtextmoduleScroller').data('sly')) {
                    $('#mtextmoduleScroller').sly('reload');
                } else {
                    $.buildVerticalScroller('#mtextmoduleScroller');
                }
            });
            $(document).on('click', '.selaus', function (e) {
                $('.slideholder, .fontpop').hide();
                $(this).closest('.selsom').find('.fontpop').show();
                if ($('#mtextmoduleScroller').data('sly')) {
                    $('#mtextmoduleScroller').sly('reload');
                } else {
                    $.buildVerticalScroller('#mtextmoduleScroller');
                }
            });
            $(document).on('focus', '#sticktext', function (e) {
            //$('#sticktext').on('focus', function () {
                var active = $('.motivImage').find('.ovholder.active');
                $('.fontpop').hide();
                if (active && active.attr('data-ptyp') == 'text') {
                    return;
                }
                $('.ovholder').removeClass('active');
                $('.clone-type-configurator > ul > li').removeClass('active');
                $('.ovholder').find('.activewrapper').hide();
                $('.ovholder').find('.outerhelper').hide();
                $('.motruler').hide().remove();
                $.buildTformat();
                $('.fontpop').hide();
            });
            $(document).on('click', '.sfont .cfont', function () {
                var that, dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active'), type, alternate, alttype;
                that = $('#sticktext');
                $(this).closest('.sfont').find('.cfont').removeClass('selected');
                $(this).addClass('selected');
                type = $(this).closest('.sfont').attr('data-type');
                if (type == 'druck') {
                    alternate = $(this).attr('data-stick');
                    alttype = 'stick';
                } else {
                    alternate = $(this).attr('data-druck');
                    alttype = 'druck';
                }
                if ($(this).closest('.selsom').find('.sfont[data-type="' + alttype + '"]').find('.cfont[data-value="' + alternate + '"]').length) {
                    $(this).closest('.selsom').find('.sfont[data-type="' + alttype + '"]').find('.cfont').removeClass('selected');
                    $(this).closest('.selsom').find('.sfont[data-type="' + alttype + '"]').find('.cfont[data-value="' + alternate + '"]').addClass('selected fuck');
                }
                dataposIndex = active.attr('data-posIndex');
                dataacP = active.attr('data-pos');
                // motivp, motivi, renew, isReload, isMover, res
                if ($(that).val() && $.trim($(that).val())) {
                    $.setMotive(dataacP, dataposIndex, null, null, null, null);
                    needsMovement = true;
                }
                $('.fontpop').hide();
            });
            $(document).on('click', '.textmottype', function () {
                if ($(this).attr('data-type') == 'druck') {
                    $('.selfontrad, .nobiegung').addClass('hide');
                } else {
                    $('.selfontrad, .nobiegung').removeClass('hide');
                }
                if ($(this).hasClass('active')) {
                    return;
                }
                $('.textmottype').removeClass('active');
                $('.clone-type-configurator > ul > li').removeClass('active');
                if ($(this).attr('data-type') == 'druck') {
                    $('.clone-type-configurator li.print').addClass('active');
                } else {
                    $('.clone-type-configurator li.stick').addClass('active');
                }
                $(this).addClass('active');

                var that, dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
                that = $('#sticktext');
                dataposIndex = active.attr('data-posIndex');
                dataacP = active.attr('data-pos');
                // motivp, motivi, renew, isReload, isMover, res
                if ($(that).val() && $.trim($(that).val())) {
                    $.setMotive(dataacP, dataposIndex, null, null, null, null);
                    needsMovement = true;
                }
                $('.fontpop').hide();
            });
            $(document).on('click', '.sausrichtung .causrichtung', function () {
                var that, dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active');
                that = $('#sticktext');
                $(this).closest('.sausrichtung').find('.causrichtung').removeClass('selected');
                $(this).closest('.selsom').find('.selfont').text($(this).find('.smico').text());
                $(this).addClass('selected');
                dataposIndex = active.attr('data-posIndex');
                dataacP = active.attr('data-pos');
                // motivp, motivi, renew, isReload, isMover, res
                if ($(that).val() && $.trim($(that).val())) {
                    $.setMotive(dataacP, dataposIndex, null, null, null, null);
                    needsMovement = true;
                }
                $('.fontpop').hide();
            });
            $(document).on('click', '#sticktext', function (e) {
            //$('#sticktext').on('click', function (e) {
                if ($('#sticktext').val() && $('#sticktext').attr('placeholder') == $('#sticktext').val()) {
                    $('#sticktext').val('');
                }
                $.adjustTextField();
                if ($(this).val() && $.trim($(this).val())) {
                    //var focusPosition = $(this).getCursorPosition();

                    //macht im is stress, cursor geht immer nach vorne
                    //$(this).val($(this).val());

                    //$(this).selectRange(focusPosition);
                }
            });
            $(document).on('keypress', '#sticktext', function (e) {
            //$('#sticktext').on('keypress', function (e) {
                var active = $('.motivImage').find('.ovholder.active');
                if (xhr[active.attr('data-auid')]) {
                    xhr[active.attr('data-auid')].abort();
                    if (typeof xhrcc != 'undefined'){
                        xhrcc.abort();
                    }
                    if (typeof xhruc != 'undefined'){
                        xhruc.abort();
                    }
                }
                $.adjustTextField();
                $('.fontpop').hide();
            });
            $(document).on('keyup', '#sticktext', function (e) {
            //$('#sticktext').on('keyup', function (e) {
                var isiPhone, isiPad, isiPod,  tt = 500, that, lines = 5, newLines, code, dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active'), val, text;
                clearTimeout(ttTimer);
                that = this;
                code = e.keyCode || e.which;
                dataposIndex = active.attr('data-posIndex');
                dataacP = active.attr('data-pos');
                text = $.trim($(this).val());
                text = text.split('\n');
                if (pmo && pmo[dataacP] && pmo[dataacP][dataposIndex]) {

                    $.each(text, function(r) {
                        if(pmo[dataacP][dataposIndex].text[r]){
                            pmo[dataacP][dataposIndex].text[r].text = text[r];
                        }
                    });

                    $.buildTformat(pmo[dataacP][dataposIndex]);

                } else {
                    return false;
                    $.buildTformat();
                }
                if (code == 13) {
                    //tt = 4000;
                }

                isiPhone = /iphone/i.test(navigator.userAgent.toLowerCase());
                isiPad = navigator.userAgent.toLowerCase().indexOf("ipad");
                isiPod = navigator.userAgent.toLowerCase().indexOf("ipod");
                if(isiPhone){
                    return;
                }
                if (e.keyCode == 37 || e.keyCode == 38 || e.keyCode == 39 || e.keyCode == 40) {
                    return;
                }

                if (xhr[active.attr('data-auid')]) {
                    xhr[active.attr('data-auid')].abort();
                    if (typeof xhrcc != 'undefined'){
                        xhrcc.abort();
                    }
                    if (typeof xhruc != 'undefined'){
                        xhruc.abort();
                    }
                }

                //ttTimer = setTimeout(function () {
                    //if ($(that).val() && $(that).val().trim()) {


                        //text = $.grep(text,function(n){ return(n) });
                        // motivp, motivi, renew, isReload, isMover, res
                        $.setMotive(dataacP, dataposIndex, null, null, null, null, text);
                        needsMovement = true;
                    //}
                //}, tt);
            });
            $(document).on('blur', '#sticktext', function (e) {
            //$('#sticktext').on('blur', function (e) {
                var isiPhone, isiPad, isiPod, tt = 10, that, lines = 5, newLines, code, dataacP, dataposIndex, active = $('.motivImage').find('.ovholder.active'), val;
                isiPhone = /iphone/i.test(navigator.userAgent.toLowerCase());
                if(isiPhone){
                    that = this;
                    code = e.keyCode || e.which;
                    dataposIndex = active.attr('data-posIndex');
                    dataacP = active.attr('data-pos');
                    if (pmo && pmo[dataacP] && pmo[dataacP][dataposIndex]) {
                        $.buildTformat(pmo[dataacP][dataposIndex]);
                    } else {
                        $.buildTformat();
                    }
                    clearTimeout(ttTimer);
                    ttTimer = setTimeout(function () {
                        var text;
                        //if ($(that).val() && $(that).val().trim()) {
                            text = $.trim($(that).val());
                            text = text.split('\n');
                            //text = $.grep(text,function(n){ return(n) });
                            // motivp, motivi, renew, isReload, isMover, res
                            $.setMotive(dataacP, dataposIndex, null, null, null, null, text);
                            needsMovement = true;
                        //}
                    }, tt);
                }
            });
        //}
        $(document).on('keyup', '#motivDesignerForm input:text.textinput', function (e) {
            var tt = 500, code, toggler, start = this.selectionStart, end = this.selectionEnd, active = $('.motivImage').find('.ovholder.active');
            code = e.keyCode || e.which;
            if (code == 16 || code == 17 || code == 18 || e.keyCode == 37 || e.keyCode == 38 || e.keyCode == 39 || e.keyCode == 40) {
                return;
            }
            if (code == 13) {
                tt = 1;
            }
            if (xhr) {
                $.loadOverlay(true);
            }
            clearTimeout(ttTimer);
            if ($(this).hasClass('caseu')) {
                this.value = this.value.toUpperCase();
            } else if ($(this).hasClass('casel')) {
                this.value = this.value.toLowerCase();
            }
            this.setSelectionRange(start, end);
            toggler = $(this).closest('.ym-grid').find('.toggles').data('toggles');
            if ($.trim($(this).val())) {
                toggler.toggle(true);
                $(this).closest('.ym-grid').find('.toggles').addClass('dataon').removeClass('dataoff');
                //$(this).closest('.ym-grid').find('.cpia').removeClass('coloricoInact').addClass('colorico');
            } else {
                toggler.toggle(false);
                $(this).closest('.ym-grid').find('.toggles').addClass('dataoff').removeClass('dataon');
                //$(this).closest('.ym-grid').find('.cpia').removeClass('colorico').addClass('coloricoInact');
            }

            if (xhr[active.attr('data-auid')]) {
                xhr[active.attr('data-auid')].abort();
                if (typeof xhrcc != 'undefined'){
                    xhrcc.abort();
                }
                if (typeof xhruc != 'undefined'){
                    xhruc.abort();
                }
            }
            ttTimer = setTimeout(function () {
                var dataacP, dataposIndex;
                dataposIndex = active.attr('data-posIndex');
                if (typeof dataposIndex != 'undefined'){
	                dataacP = active.attr('data-pos');
	                $.loadOverlay(false, pmo[dataacP][dataposIndex].ajaxId);
	                if (xhr && pmo && pmo[dataacP][dataposIndex].ajaxId && xhr[pmo[dataacP][dataposIndex].ajaxId]) {
	                    xhr[pmo[dataacP][dataposIndex].ajaxId].abort();  //tempdisabled
	                } else if (xhr && ajaxId && xhr[ajaxId]) {
	                    xhr[ajaxId].abort();  //tempdisabled
	                }
	                $.setMotive(dataacP, dataposIndex, true);
                }
            }, tt);
        });
        $(document).on('click', '.motivDs .sizeSelect li label', function () {
            var input, val;
            input = $(this).closest('li').find('input:first');
            val = parseInt(input.val(), 10);
            if (!val) {
                val = 0;
            }
        });
        $(document).on('click', '.hasNumeric label', function () {
            var input, val;
            input = $(this).closest('div').find('input:first');
            val = parseInt(input.val(), 10);
            if (!val) {
                val = 0;
            }
            input.val(val + 1);
        });
        $('.motivDs .sizeSelect li').find('input').keyup(function (e) {
            if (/\D/g.test(this.value)) {
                this.value = this.value.replace(/\D/g, '');
            }
        });
        $('.input:text.numeric').keyup(function (e) {
            if (/\D/g.test(this.value)) {
                this.value = this.value.replace(/\D/g, '');
            }
        });
        $(function () {
            $(document).on('click', '.jsMsPlace input[type="radio"]', function () {
            //$('.jsMsPlace').find('input[type="radio"]').on('click', function () {
                $.goToMotivePosition(true);
            });
            $(function () {
                $('img.rpcol').each(function () {
                    var src;
                    src = $(this).attr('src');
                    $('<img />').attr('src', src).removeClass('tmpimg').hide().appendTo('body');
                    imgs[src] = true;
                });
                $(document).on('hover click', '.jsMsColor a', function (e) {
                //$('.jsMsColor').find('a').on('hover, click', function (e) {
                    if ($(this).hasClass('selected')) {
                        return false;
                    }
                    var newColor, newId, newSrc, posid, origColor, newColorNamed, uri, rep, selected;
                    selected = $('.motselect.selected');
                    newColor = $(this).attr('data-farbId');
                    newColorNamed = $(this).attr('data-color');
                    origColor = $('.jsMsColor li a.selected').attr('data-color');
                    if (e.type == 'click') {
                        uri = window.location.pathname.replace('/' + origColor, '/' + newColorNamed);
                        $('.langswitch').find('a').each(function () {
                            $(this).attr('href', $(this).attr('data-prefix') + $(this).attr('data-burl').replace('/' + origColor, '/' + newColorNamed));
                            $(this).attr('data-burl', $(this).attr('data-burl').replace('/' + origColor, '/' + newColorNamed));
                        });
                        if ($('#fbsharer').length) {
                            $('#fbsharer').attr('href', $('#fbsharer').attr('href').replace('/' + origColor + '/', '/' + newColorNamed + '/'));
                        }
                        if ($('#turl').length) {
                            $('#turl').attr('data-url', $('#turl').attr('data-url').replace('/' + origColor, '/' + newColorNamed));
                        }
                        if ($('#twsharer').length) {
                            $('#twsharer').attr('href', $('#twsharer').attr('href').replace('/' + origColor + '/', '/' + newColorNamed + '/'));
                        }
                        if ($('#insharer').length) {
                            $('#twsharer').attr('href', $('#twsharer').attr('href').replace('/' + origColor + '/', '/' + newColorNamed + '/'));
                        }
                        if ($('.body_motivDesigner').length && typeof (window.history.pushState) === 'function') {
                            history.pushState({id: location.pathname}, document.title, location.pathname);
                            history.pushState({id: uri}, '', uri);
                        }
                        $('.jsMsColor').find('a').removeClass('selected');
                        $(this).addClass('selected');
                        $('.artcolor').html(newColorNamed);
                        rep = $(this).attr('data-rep');
                        $('span.rpcol').each(function () {
                            $(this).removeClass().addClass('dtimg previewImg rpcol').addClass('x' + $(this).closest('a').attr('data-positionsId') + '-' + rep);
                        });
                        if ($('.motcolinfo').length) {
                            $.each(pmo, function (a) {
                                    $.each(pmo[a], function (b) {
                                        var group, acP, oldColor, oldMotive, newMotive, span, newPreview;
                                        group = pmo[a][b].gruppe;
                                        acP = pmo[a][b].acP;
                                        span = $('.motcolinfo[data-pos="' + acP + '"][data-group="' + group + '"]');
                                        if (acP && group && span.length) {
                                            if (!$('.motcolinfo[data-pos="' + acP + '"][data-group="' + group + '"][data-color="' + newColor + '"]').length) {
                                                span = $('.motcolinfo[data-pos="' + acP + '"][data-group="' + group + '"][data-color="0"]');
                                            } else {
                                                span = $('.motcolinfo[data-pos="' + acP + '"][data-group="' + group + '"][data-color="' + newColor + '"]');
                                            }
                                            newMotive = span.attr('data-motivId');
                                            newPreview = span.attr('data-preview');
                                            if (pmo[a][b].aoData.motivId != newMotive) {
                                                pmo[a][b].designId = newPreview;
                                                pmo[a][b].stickMotiv = newMotive;
                                                pmo[a][b].aoData.designId = newPreview;
                                                pmo[a][b].aoData.motivId = newMotive;
                                                //$('.motselect[data-pos="' +  pmo[a][b].aPT + '"]').trigger('click');
                                                $.setMotive(a, b, true, true);
                                                //selected.trigger('click');
                                            }
                                        }
                                    });
                            });
                        }
                        //$.updatePriceDiv();
                        $.updateCreation();
                    }
                    $('img.rpcol').each(function () {
                        posid = $(this).closest('.medf').attr('data-positionsId');
                        if (posid) {
                            newId = $('.ppf_' + newColor + '_' + posid).html();
                            newSrc = $.replaceUrlParam($(this).attr('src'), 'pCol', newColor);
                            newSrc = $.replaceUrlParam(newSrc, 'id', newId);
                            if (!imgs[newSrc]) {
                                $('<img />').hide().attr('src', newSrc).addClass('preloaded').removeClass('tmpimg').appendTo('body');
                                imgs[newSrc] = true;
                            }
                            if (e.type == 'click') {
                                $(this).attr('src', newSrc).addClass('preloaded');
                            }
                        }
                    });
                    if (e.type == 'click') {
                        $('#farbId').text(newColor);
                    }
                    return false;
                });
            });
        });
        $.changeProductLine = function (a) {
            var newLine;
            //$('.hastabs').find('a').removeClass('active');
            $('#slideMenu').find('a').removeClass('active');
            $(a).addClass('active');
            $('#productList').html('');
            $.getProducts(15, false);
        };
        $.getFavorites = function () {
            if ($('#favoritelist').length) {
                $.ajax({
                    dataType: 'json',
                    cache: false,
                    type: 'POST',
                    url: '/ajax/ajax_update_designer.php?action=getfavs&language=' + $('html').attr('lang'),
                    success: function (data) {
                        if (data.success) {
                            $('#favoritelist').html(data.html);
                            $('.mtamy').show();
                        } else if (data.html) {
                            $('#favoritelist').html(data.html);
                        }
                    }
                });
            }
            $('#favorites').show();
        };
        $.activateThemelist = function (a, update, forceTemplate) {
            return;
            if (!a || !$(a).attr('href')) {
                return;
            }
            $('.thwllist').find('li').removeClass('active');
            $(a).closest('li').addClass('active');
            var newTheme, template, acp;
            newTheme = 'theme_' + $(a).attr('data-theme');
            $('#thwlist').attr('data-active-theme', $(a).attr('data-theme'));
            $('.thelist').hide();
            $('#favorites').hide();
            if ($(a).hasClass('favorites')) {
                $.getFavorites();
            }
            $('.' + newTheme).show();
            if ($('.activeThemeTemplate').length) {
                template = $('.activeThemeTemplate').attr('data-value');
                $('.temselect').removeClass('selected');
                $('.uploadselect').removeClass('selected');
                $('.frame' + newTheme).find('.temselect[data-value="' + template + '"]').addClass('selected');
                $('.activeThemeTemplate').remove();
            }
            if (template && forceTemplate) {
                if (update === true) {
                    $.loadTemplate();
                }
            }
            $('.mtalist').each(function () {
                if (!$(this).find('.' + newTheme).length) {
                    $(this).hide();
                } else {
                    $(this).slideDown();
                }
            });
            $('.frame' + newTheme).each(function () {
                var id = $(this).attr('id');
                $('#' + id).sly('reload');
                //$('#' + id).sly('toStart', $('.temselect.selected').closest('li').index());
            });
            acp = $('#motivDesignerForm').attr('data-activePositionsTyp');
            if (!$('#motpos' + acp).closest('li').find('.gebiet[data-fuer-druck=1]').length) {
                $('.mtadruck').hide();
            }
            if (!$('#motpos' + acp).closest('li').find('.gebiet[data-fuer-stick=1]').length) {
                $('.mtastick').hide();
            }
            if ($('.' + newTheme).find('.temselect:visible').length === 0) {
                $('.motivedit').hide();
            }
            if (!$('.temselect.selected').length && (pmo[$('#motivDesignerForm').attr('data-activePos')] === undefined || $.isEmptyObject(pmo[$('#motivDesignerForm').attr('data-activePos')][1]))) {
                $('#motiveedit').hide();
                $('.mtainfo').show();
            } else {
                $('#motiveedit').show();
            }
        };
        $(document).on('focusin', 'input.datepicker', function () {
            $(this).datepicker({
                regional: 'de',
                showWeek: false,
                changeMonth: true,
                changeYear: true,
                minDate: '-99y',
                yearRange: "-100:+0"
            });
        });

        $.changeColorfilter();
        //});
        $(function () {
            var pma = {}, aaa = 0, side;
            if ($('#motivDesignerForm').length) {
                $.initDesigner();
            }
        });

		$('#slideMenu').sMultiMenu({

		});

        $(document).on('click', '#slideMenu a.nosub', function (e) {
            e.preventDefault();
            $.changeProductLine(this, true);
            $('#slideMenu').hide();
        });
        if($('#contenthere').length){
            $(function () {
                var ssId = '', farbId, mode = 'createnew', farbe = $('#contenthere').attr('data-farbe');
                $('#nav, #breadcrumbs, #mfooter, footer, header').hide();
                //$(document).on('click', '#clicktest', function () {
                $('#contenthere').html('');
                $('#nav, #breadcrumbs, #mfooter, footer, header').hide();

                if($('#contenthere').attr('data-ssId')){
                    ssId = '&ssId=' + $('#contenthere').attr('data-ssId');
                    mode = 'edit';

                    $('#sasa').attr('data-edit', 1).text('speichern');
                }
                if($('#contenthere').attr('data-farbId')){
                    farbe = $('#contenthere').attr('data-farbId');
                }
                $.ajax({
                    dataType: 'json',
                    cache: false,
                    type: 'POST',
                    url: '/ajax/ajax.php?action=site_verw_artikel&subAction=getDesigner&kId=' + $('#contenthere').attr('data-katId') + '&artNr=' + $('#contenthere').attr('data-artNr') + '&farbe=' + farbe + ssId + '&' + mode + '=1&_=1438856176639',
                    success: function (data) {
                        if (data && data.status) {
                            var pmo = {}, pma = {}, aaa = 0, side;
                            $('#contenthere').html(data.status);
                            //irgendwo admin-edit option setzen
                            $.initDesigner();
                            $.initFileuploader();
                            $('#slideMenu').sMultiMenu({

                            });

                            if (mode == 'edit') {
                                $('#mproducts, div[data-id="mproducts"]').hide().remove();
                            }
                            //$.buildSlider();
                        }
                    },
                    error: function (msg) {
                        $.setInfo('geht nicht');
                    }
                });
            });
        }
        $.initFileuploader = function () {
            if ($('#fileupload').length) {
                'use strict';
                $(document).bind('drop dragover', function (e) {
                    e.preventDefault();
                });
                // Change this to the location of your server-side upload handler:
                var url = '/ajax/ajax_update_designer.php?action=upload&language=' + $('html').attr('lang'),
                    uploadButton = $('<button/>')
                        .addClass('btna btn-primary')
                        .prop('disabled', true)
                        .text('Processing...')
                        .on('click', function () {
                            var $this = $(this),
                                data = $this.data();
                            $this
                                .off('click')
                                .text('Abort')
                                .on('click', function () {
                                    $this.remove();
                                    data.abort();
                                });
                            data.submit().always(function () {
                                $this.remove();
                            });
                        });
                $('#fileupload').fileupload({
                    url: url,
                    dataType: 'json',
                    autoUpload: true,
                    dropZone: '#fileuploader',
                    acceptFileTypes: /(\.|\/)(gif|jpe?g|png)$/i,
                    maxChunkSize: 1000000, // 1 MB
                    maxFileSize: 10000000, // 10 MB
                    disableImageResize: true,
                    previewMaxWidth: 120,
                    previewMaxHeight: 120,
                    progressall: function (e, data) {
                        var progress = parseInt(data.loaded / data.total * 100, 10);
                        $('#progress .progress-bar').css('width', progress + '%');
                    },
                    previewCrop: false
                }).on('fileuploadadd', function (e, data) {
                    data.context = $('<div/>').addClass('imglist uploadselect').appendTo('#files');
                    $.loadOverlay();
                    $.each(data.files, function (index, file) {
                        var node = $('<div/>');
                        if (!index) {
                            node.append(uploadButton.clone(true).data(data));
                        }
                        node.addClass('holder ym-clearfix');
                        node.appendTo(data.context);
                    });
                }).on('fileuploadprocessalways', function (e, data) {
                    $('#progress').show();
                    var index = data.index, file = data.files[index], node = $(data.context.children()[index]);
                    if (file.preview) {
                        node.prepend(file.preview);
                    }
                    if (file.error) {
                        $.setInfo(file.error);
                        $('.uploadselect').find('canvas').remove();
                        $.loadOverlay(true);
                    }
                    if (index + 1 === data.files.length) {
                        data.context.find('button')
                            .text('dd')
                            .addClass('hidee')
                            .prop('disabled', !!data.files.error).hide();
                    }
                }).on('fileuploaddone', function (e, data) {
                    $.each(data.result.files, function (index, file) {
                        if (file.url) {
                            $(data.context.children()[index]).find('canvas').remove();
                            if (!file.dimensions) {
                                return false;
                            }
                            $.loadOverlay(true);
                            var infoholder = $('<div/>'), img = new $('<img />'), delnode = $('<span/>'), infonode = $('<span/>'), fsize, dpi;
                            img.attr('src', file.thumbnailUrl);
                            img.attr('data-name', file.name);
                            img.attr('data-src', file.url);
                            img.attr('data-price', file.price);
                            img.attr('data-uuid', file.uuid);
                            img.attr('data-maxQuality', file.qualityInfo ? file.qualityInfo.quality : '');
                            img.attr('data-width', file.dimensions[0]);
                            img.attr('data-uuid', file.uuid);
                            img.attr('data-height', file.dimensions[1]);
                            img.attr('data-maxWidth', file.qualityInfo ? file.qualityInfo.maxWidth : '');
                            img.attr('data-maxHeight', file.qualityInfo ? file.qualityInfo.maxHeight : '');
                            img.addClass('motupload');
                            $(data.context.children()[index]).append(img);
                            delnode.addClass('ui-icon ui-icon-trash psa mottotrash inlineicon');
                            infoholder.append(delnode);
                            fsize = $.bizRound(file.size / 1024);
                            dpi = $.bizRound(file.dpi.x);
                            infonode.addClass('ui-icon ui-icon-info psa inlineicon');
                            infonode.attr('data-title', file.type + '<br />' + fsize + ' kB / ' + dpi + ' dpi<br />' + file.dimensions[0] + ' x ' + file.dimensions[1] + ' Pixel');
                            infoholder.append(infonode);
                            $(data.context.children()[index]).closest('.imglist').append(infoholder);
                            img.trigger('click');
                        } else if (file.error) {
                            $.loadOverlay(true);
                            var error = file.error;
                            $.setInfo(error);
                            $('.uploadselect').find('canvas').remove();
                        }
                        $(data.context.children()[index]).find('button').remove();
                        $('#progress').hide();
                        $('.hasScroller:visible').each(function () {
                            var id = $(this).attr('id');
                            //$('#' + id).imagesLoaded().done(function (a) {
                                $('#' + id).sly('reload');
                            //});
                        });
                    });
                    $.loadOverlay(true);

                    var copyrightFileuploadText,
                        copyrightFileuploadTitle,
                        copyrightFileuploadButton;

                    copyrightFileuploadTitle  = 'Hinweis zum Urheber- und Markenrecht:';
                    copyrightFileuploadText  = '<p>Um bei Smake ein Motiv hochladen zu können, musst Du alleiniger Inhaber der Rechte an dem Motiv sein. Um Klarheit über die Rechte Dritter zu erlangen, erfrage den rechtlichen Status des Motivs bzw. bemühe Dich um ein uneingeschränktes Nutzungsrecht. In Zweifelsfällen solltest Du,  - zur Vermeidung von Verstößen gegen geltendes Urhaber-, Persönlichkeits- oder Markenrecht - auf die Verwendung des Motivs verzichten. Es wird darauf hingewiesen, dass die Verwendung bekannter Markennamen, Firmenlogos oder Personen regelmäßig eine Verletzung der Markenrechte des jeweiligen Inhabers darstellt. Soweit Dritte Ansprüche wegen der Verletzung von Urheberrechten oder gewerblichen Schutzrechten gegenüber Smake geltend machen, bist Du verpflichtet, Smake von berechtigten Ansprüchen freizustellen und die Kosten der Rechtsverteidigung zu erstatten.</p>';
                    copyrightFileuploadText += '<p><input class="copyright-fileupload-check-de" type="checkbox"> Hiermit bestätige ich, dass ich den Hinweis gelesen habe und dazu einverstanden bin.</p>';
                    copyrightFileuploadButton = 'Bestätigen';
                    if ($('html').attr('lang') == 'en') {
                        copyrightFileuploadTitle  = 'Copy Right and Design Notice:';
                        copyrightFileuploadText  = '<p>In order to upload designs to Smake, you must have the right to use the design. If you are not sure about, a design from a third party, please check the status of the design as well as whether or not it is legal. If in doubt, do not upload the design to Smake to avoid any problems from the rightful owner of the design. Please note that illegal use of known brands and labels is a violation of the rights of the respective owners. Should any of these rights be violated, Smake will not take any responsibility. You will be held solely responsible for any misuse of third party designs, images, persons or anything that you do not have the right to print, or use., Uploading Information, The data that you upload is only scalable to the resolution that it is able to handle. If you would like to have your graphic printed larger and still maintain a high quality print then you must upload it at a higher resolution.</p>';
                        copyrightFileuploadText += '<p><input class="copyright-fileupload-check-en" type="checkbox"> I hereby confirm that I have read the notice and to agree.</p>';
                        copyrightFileuploadButton = 'Confirm';
                    }

                    $('body').append('<div class="copyright-fileupload" style="display:none">' + copyrightFileuploadText + '</div>');

                    $('.copyright-fileupload').dialog({
                        autoOpen: true,
                        modal: true,
                        title: copyrightFileuploadTitle,
                        resizable: false,
                        draggable: false,
                        closeOnEscape: false,
                        maxWidth: $('#designer').innerWidth(),
                        position: {my: 'center top', at: 'center top', of: '.ctmain'},
                        width: $('#designer').innerWidth() - 6,
                        show: {effect: 'puff', duration: 222},
                        hide: {effect: 'clip', duration: 222},
                        open: function(event, ui) { $('.ui-dialog-titlebar-close', ui.dialog | ui).hide(); },
                        buttons: [{
                            text: copyrightFileuploadButton,
                            click: function() {
                                if ($('.copyright-fileupload-check-' + $('html').attr('lang')).is(':checked')) {
                                    $(this).dialog('close');
                                }
                            }
                        }]
                    });

                }).on('fileuploadfail', function (e, data) {
                    $('.uploadselect').find('canvas').remove();
                    $.each(data.files, function (index) {
                        var error = $('<span class="text-danger"/>').text('File upload failed.');
                        $(data.context.children()[index])
                            .append(error);
                        $.loadOverlay(true);
                    });
                    $('#progress').hide();
                    $('.hasScroller:visible').each(function () {
                        var id = $(this).attr('id');
                        $('#' + id).sly('reload');
                    });
                    $.loadOverlay(true);
                }).prop('disabled', !$.support.fileInput)
                    .parent().addClass($.support.fileInput ? undefined : 'disabled');

            }
        };
        $.initDesigner = function () {
                var pma = {}, aaa = 0, side;
                initStageWidth = $('.motivImage').find('.stageHolder').first().width();
                $('#designinner').find('.hidee').show();
                $(document).on('click', '#mproducts .mpbutton', function (e) {
                //$(document).on('click', '#slideMenu a.noSub', function (e) {
                    e.preventDefault();
                    $.changeProductLine(this, true);
                    //$('#katSelector').hide();
                    $('#slideMenu').hide();
                });
                if ($('.mtab[data-id="motivselector"]').length) {
                    $('.mtab[data-id="motivselector"]').trigger('click');
                } else if ($('.mtab[data-id="mproducts"]').length) {
                    $('.mtab[data-id="mproducts"]').trigger('click');
                }
                if ($('select[name="thworld"]').find('option[data-themeId]:not(.hide)').length < 2) {
                    $('select[name="thworld"]').val($('select[name="thworld"]').find('option[data-themeId]').first().val());
                    $('select[name="thworld"]').hide();
                    $('#mtadf select ~ .select-click-icon').hide();
                    //$.filterTemplates();
                }

                if (!$('.jsMsPlace').find('.gebiet[data-fuer-druck="1"]').length) {
                    $('.mtadruck').hide();
                    $('.tfilter[data-type="1"]').trigger('click');
                    $('.tfilter[data-type="2"]').addClass('noposs');
                    $('.temselect[data-type="druck"]').closest('.fuseda').hide();
                }
                if (!$('.jsMsPlace').find('.gebiet[data-fuer-stick="1"]').length) {
                    $('.mtastick').hide();
                    $('.tfilter[data-type="2"]').trigger('click');
                    $('.tfilter[data-type="1"]').addClass('noposs');
                    $('.temselect[data-type="stick"]').closest('.fuseda').hide();
                }
                if ($('select[name="thworld"]').find(':selected') && $('select[name="thworld"]').find(':selected').val()) {
                    $.filterTemplates();
                }
                $.buildSlider();
                $.doStuff();
                if ($('#creation').length) {
                    pmo = {};
                    pma = $.parseJSON($('#creation').attr('data-json'));
                    $('.mtainfo').hide();
                    $('#meditor').hide();
                    if (pma) {
                        $.loadOverlay();
                        $.each(pma, function (a) {
                            $.each(pma[a], function (b) {
                                var aa = pma[a][b].acP;
                                if (!pmo[aa]) {
                                    pmo[aa] = {};
                                }
                                pmo[aa][b + 1] = pma[a][b];
                            });
                        });
                        $.each(pmo, function (a) {
                            var newAcP;
                            if (!$('.motselect[data-positionsId="' + a + '"]').length) {
                                $.each(pmo[a], function (b) {
                                    var posindex = pmo[a][b].aPT, ttyp = pmo[a][b].templateTyp;
                                    if (ttyp == 'upload') {
                                        ttyp = 'druck';
                                    }
                                    if (!$('.jsMsPlace').find('.gebiet[data-fuer-' + ttyp + '="1"]').length) {
                                        delete pmo[a][b];
                                    } else {
                                        if ($('.motselect[data-pos="' + posindex + '"]').length) {
                                            newAcP = $('.motselect[data-pos="' + posindex + '"]').attr('data-positionsId');
                                            pmo[a][b].acP = $('.motselect[data-pos="' + posindex + '"]').attr('data-positionsId');
                                        }
                                    }
                                });
                                if (newAcP && !pmo[newAcP]) {
                                    pmo[newAcP] = {};
                                }
                                if (newAcP) {
                                    $.each(pmo[a], function (ab) {
                                        pmo[newAcP][ab] = pmo[a][ab];
                                    });
                                }
                                delete pmo[a];
                            }
                        });
                        $.each(pmo, function (a) {
                            aaa = aaa + 1;
                            var left, top, nleft, ntop;
                            $.each(pmo[a], function (b) {
                                if ((!pmo[a][b].defMot) && (pmo[a][b].templateTyp != 'upload') && (!pmo[a][b].text)) {
                                    if (!$('.temselect[data-value="' +  pmo[a][b].template + '"]').length) {
                                        delete pmo[a][b];
                                    }
                                }
                                if((pmo[a][b].sid && pmo[a][b].sid == '50918896' && pmo[a][b].template == 1346) || (pmo[a][b].template == 1346 && !pmo[a][b].uploaduuid)){
                                    delete pmo[a][b];
                                }
                                if (pmo[a][b] && pmo[a][b].defMot == 1){
                                    left = pmo[a][b].aktLeft_px;
                                    top = pmo[a][b].aktTop_px;
                                } else {
                                    if(pmo[a][b] && left && top){
                                        nleft = pmo[a][b].aktLeft_px;
                                        ntop = pmo[a][b].aktTop_px;
                                        if(left - nleft < 10 && left - nleft > -10 && top - ntop < 10 && top - ntop > -10){
                                            pmo[a][b].aktTop_px = pmo[a][b].aktTop_px + 20;
                                            pmo[a][b].aktLeft_px = pmo[a][b].aktLeft_px + 20;
                                        }
                                    }
                                }
                            });
                        });
                        $.each(pmo, function (a) {
                            aaa = aaa + 1;
                            $.each(pmo[a], function (b) {
                                $.setMotive(a, b, true, true);
                                if(pmo[a][b].rotation && pmo[a][b].rotation !== 0){
                                    //needsMovement = true;
                                }

                                if (!side) {
                                    side = a;
                                }
                            });
                        });
                        if (side) {
                            $('.origholder').imagesLoaded().done(function (a) {
                                //$('.motselect[data-positionsId="' + side + '"]').trigger('click');
                            });
                        }
                        //$.initColorpicker();
                        $.updateCreation(true);
                        //$.updatePriceDiv();
                    }
                    $('#creation').remove();
                    $.loadMotiveDragger();
                    $('.drov.ui-droppable').trigger('click');
                } else {
                    $(function () {
                        if ($('.thwllist').find('li.active').length) {
                            $.activateThemelist($('.thwllist').find('li.active').find('a').first(), true, true);
                        }
                    });
                    $('#motivColors').show();
                    if (!$('.activeTemplate').length) {
                        $('.motivImage').find('motpos').remove();
                    }
                }



        };
        $.initFileuploader();
    });

    $(function () {
        var active;
        active = $('#tabs').find('.selected').index();
        if (active === -1) {
            active = 0;
        }
        $('#tabs').tabs({
            hide: {effect: 'fade', duration: 333},
            show: {effect: 'fade', duration: 333},
            active: active
        });
    });
    $(document).on('click', '.smakeModal', function (e) {
        e.preventDefault();
        var div = $(this).attr('data-smakemodalurl'), title = $(this).text();

        var tmpLink = $(this).attr('href');
        var tmpSplit= tmpLink.split('#');

        $(div).dialog({
            autoOpen: true,
            modal: true,
            title: title,
            resizable: false,
            closeText: 'schließen',
            maxWidth: 600,
            width: 600,
            height: $(window).height() - 100,
            show: {effect: 'puff', duration: 500},
            hide: {effect: 'clip', duration: 500},
            open: function( event, ui ) {
            	var tmpWin = $(this);
            	setTimeout(function(){
            		tmpWin.scrollTop(0);
            		if(tmpSplit && tmpSplit[1] && tmpSplit[1] != ''){
            			$(div).animate({
            		        scrollTop: $('#' + tmpSplit[1]).offset().top - 150
            		    }, 500);
            		}
            	}, 500);
            }
        });
    });
    $(window).resize();
    $(function () {
        $(document).on('click', '.recart', function () {
            var positions = [], doit = false;
            $('.hasrecart').each(function (e) {
                var pdata = {};
                if ($(this).find('input[name="doit"]').is(':checked') === true) {
                    pdata.bposid = $(this).find('input[name="bposid"]').val();
                    pdata.anzahl = $(this).find('input[name="anzahl"]').val();
                    positions.push(pdata);
                    doit = true;
                }
            });
            if (doit === true) {
                $('.recart').after('<span class="loadimg" style="position:relative;float:left"/>');
                $.ajax({
                    data: 'data=' + JSON.stringify(positions),
                    dataType: 'json',
                    cache: false,
                    type: 'POST',
                    url: '/ajax/ajax.php?action=recart',
                    success: function (data) {
                        var msg, tmpCount = 0, i;
                        if (data.success) {
                            msg = data;
                            for (i = 0; i < Object.size(msg.shop_warenkorbItems); i = i + 1) {
                                tmpCount += parseInt(msg.shop_warenkorbItems[i].anzahl, 10);
                            }
                            warenkorb_updateCount(tmpCount, msg.warenkorb_preis);
                            warenkorb_updateItems(msg.shop_warenkorbItems, msg.warenkorb_preis);
                            $.setInfo(sprache.warenkorb_wurde_aktualisiert);
                            $('input[name="doit"]').attr('checked', false);
                            $('.loadimg').remove();
                        }
                    }
                });
            }
        });
    });
    $(function () {
        var xhh, disableCart = false, imgs = [];
        function imgTime() {
            var d = new Date();
            return '&' + d.getTime();
        }
        if ($('.personer').length) {
            $('.personer').validationEngine({
                showOneMessage: true
            });
        }
        $(document).on('submit', '.personer', function (e) {
            if (xhh) {
                xhh.abort();
            }
            e.preventDefault();
            var valid, form, doit = false, arr = {}, tmpStickObj = {}, i = 0, ii = 0, fontFamilyId = 1, textAlign = 'left';
            $('.hastheaction').each(function () {
                $(this).find('.motselect:first').trigger('click');
            });
            valid = $(this).validationEngine('validate');
            if (valid !== true) {
                return;
            }
            form = this;
            $('.hastheaction').each(function () {
                $(this).find('.motivImage').append('<span class="loadimg"/>');
                var color, template;
                template = $(this).find('.lineInfo').attr('data-template');
                if (template) {
                    tmpStickObj = {};
                    tmpStickObj.items = {};
                    tmpStickObj.drehung = 0;
                    tmpStickObj.objId = 1;
                    tmpStickObj.template = template;
                    tmpStickObj.type = 'dekra';
                    tmpStickObj.recipe = 'NormalTrim2MM';
                    tmpStickObj.textFactor = 1;
                    tmpStickObj.items[i] = {};
                    tmpStickObj.items[i].rows = {};
                    $(this).find('.lineInfo').find('span').each(function () {
                        var rowtext = '', sep, fc, origRow = [];
                        ii = $(this).attr('data-line');
                        if ($(form).find(':input[name=row' + ii + ']').val()) {
                            rowtext = $.trim($(form).find(':input[name=row' + ii + ']').val());
                            origRow.push({'name': $(form).find(':input[name=row' + ii + ']').attr('name'), 'value': rowtext});
                        } else {
                            if ($(form).find(':input[name^=row' + ii + ']')) {
                                $(form).find(':input[name^=row' + ii + ']').each(function () {
                                    if ($(this).val()) {
                                        sep = '';
                                        if ($(this).attr('data-prefix')) {
                                            sep = $(this).attr('data-prefix');
                                        }
                                        rowtext = rowtext + sep + $.trim($(this).val());
                                        origRow.push({'name': $(this).attr('name'), 'value': $.trim($(this).val())});
                                    } else {
                                        origRow.push({'name': $(this).attr('name'), 'value': ''});
                                    }
                                });
                                rowtext = $.trim(rowtext);
                                fc = rowtext.slice(0, 2);
                                if (fc == '.-') {
                                    rowtext = rowtext.slice(2, rowtext.length);
                                }
                                fc = rowtext.slice(0, 1);
                                if (fc == '.') {
                                    rowtext = rowtext.slice(1, rowtext.length);
                                }
                            }
                        }
                        if (rowtext) {
                            doit = true;
                        }
                        color = $(this).attr('data-color');
                        tmpStickObj.items[i].scale = 1;
                        tmpStickObj.items[i].isText = 1;
                        tmpStickObj.items[i].rows[ii] = {};
                        tmpStickObj.items[i].rows[ii].origRow = origRow;
                        tmpStickObj.items[i].rows[ii].textContent = rowtext;
                        tmpStickObj.items[i].rows[ii].typ = 'normal';
                        tmpStickObj.items[i].rows[ii].fontSize = $(this).attr('data-fontsize');
                        tmpStickObj.items[i].rows[ii].textAlign = textAlign;
                        tmpStickObj.items[i].rows[ii].fontFamilyId = fontFamilyId;
                        tmpStickObj.items[i].rows[ii].textAbstand = $(this).attr('data-textAbstand');
                        tmpStickObj.items[i].rows[ii].textColorId = color;
                        tmpStickObj.items[i].rows[ii].maxzeilenbreite = $(this).attr('data-maxzeilenbreite');
                        tmpStickObj.items[i].rows[ii].envelopeStr = 'rectangle';
                        tmpStickObj.items[i].rows[ii].kompJN = $(this).attr('data-kompJN');
                    });
                    arr[template] = tmpStickObj;
                }
            });
            if (!doit) {
                $('#nprev').html('');
                $('.tmpimg, .overlayimg').remove();
                disableCart = false;
                $('.loadimg').remove();
                return false;
            }
            xhh = $.ajax({
                data: 'tmp=' + JSON.stringify(arr, 2, null),
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/getStick.php',
                success: function (data) {
                    var imgUrl, widthPx, heightPx, type, img, overlayImage, option, val, tmps = [], dimensions = [];
                    $('#nprev').html('');
                    $('.tmpimg, .overlayimg').remove();
                    $('.mtt').each(function () {
                        $(this).addClass('hasMotiv').addClass('hasMotiv' + $(this).attr('data-pos'));
                    });
                    $.each(data, function (e) {
                        tmps[data[e].template] = data[e].soapId;
                        dimensions.width = data[e].width;
                        dimensions.height = data[e].height;
                        type = 'stick';
                        widthPx = 190;
                        heightPx = 40;
                        imgUrl = 'https://imaging4.smake.com/imaging/scripts/image.php' + '?imgType=' + type + '&id=' + data[e].id + '&width=' + widthPx + '&height=' + heightPx + imgTime();
                        img = $('<img />');
                        img.attr('src', imgUrl);
                        img.attr('data-id', data[e].template);
                        $('#nprev').append(img);
                        $('#nprev').append('<hr />');
                        overlayImage = $('<img/>').addClass('tmpimg').addClass('overlayimg').addClass('overlayimg' + data[e].template)
                            .attr('src', imgUrl).attr('data-id', data[e].template)
                            .css('position', 'absolute').css('zIndex', '3000');
                        $('body').append(overlayImage.clone().hide());
                    });
                    $('select[name=nameselect]').find('option').attr('selected', false);
                    val = (data[0].usedNameArray);
                    if (!$('select[name=nameselect]').find("option[value='" + val + "']").length) {
                        option = $('<option></option>').val(val).html(data[0].usedName).attr('selected', true);
                        $('select[name=nameselect]').append(option);
                    }
                    $('select[name=nameselect]').append($('select[name=nameselect] option').remove().sort(function (a, b) {
                        var at = $(a).text().toLowerCase(), bt = $(b).text().toLowerCase();
                        return (at > bt) ? 1 : ((at < bt) ? -1 : 0);
                    }));
                    if ($('select[name=nameselect]').find("option[value='" + val + "']").length) {
                        $('select[name=nameselect]').find("option[value='" + val + "']").attr('selected', true);
                    }
                    $('.hastheaction').each(function () {
                        var input, tmpl;
                        tmpl = $(this).find('.lineInfo').attr('data-template');
                        $.updateOverlays(null, null, '#' + $(this).attr('id'));
                        $(this).find('.soapId').remove();
                        input = $('<input>');
                        input.attr('type', 'hidden')
                             .attr('name', 'soapId')
                             .attr('data-width', dimensions.width)
                             .attr('data-height', dimensions.height)
                             .addClass('soapId')
                             .val(tmps[tmpl]);
                        $(this).find('.listaddwk').find('.ym-form').append(input);
                    });
                    $('.loadimg').remove();
                }
            });
        });
        $(document).on('change', '#ptitle', function (e) {
            if ($(this).val() == 'Praktikant' || $(this).val() == 'Praktikantin') {
                //$('#pfirstname').removeClass('validate[required]');
                $('#plastname').removeClass('validate[required]');
                $('#pfirstname').val('');
                $('#plastname').val('');
                $('#pfirstname').closest('.ym-fbox').hide();
                $('#pfirstname').removeClass('validate[custom[onlyLetterSp]]');
            } else {
                //$('#pfirstname').addClass('validate[required]');
                $('#plastname').addClass('validate[required]');
                $('#pfirstname').closest('.ym-fbox').show();
                $('#pfirstname').addClass('validate[custom[onlyLetterSp]]');
            }
        });

        $(document).on('change', 'select[name=nameselect]', function (e) {
            var vals;
            vals = $(this).val();
            $('.personer').find(':input').not('input[type="submit"]').val('');
            if (vals) {
                vals = $.parseJSON(vals);
                $.each(vals, function () {
                    $('.personer').find(':input[name="' + this.col + '"]').val(this.val);
                });
            }
            $('.personer').submit();
        });
        $.updateOverlays = function (element, position, parent) {
            var el, aPT, overlayImage, leftPos, topPos, drWidthPx, drHeightPx, drLeftPx, drTopPx, tzWidthPx, tzHeightPx, tzLeftPx, tzTopPx, drgebiet, gebiet;
            aPT = $('#motivDesignerForm').attr('data-activePositionsTyp');
            overlayImage = $('.overlayimg' + aPT);
            if (parent) {
                overlayImage = $('.overlayimg' + $(parent).find('.lineInfo').attr('data-template'));
            }
            if (!parent) {
                el = $('.motpos');
            } else {
                el = $(parent).find('.motpos');
            }
            el.each(function () {
                var pos, relImage, toDealWith, posi;
                pos = $(this).attr('data-pos');
                $('.mtt').width($('.motivImage').width()).css('textAlign', $('.motivImage').css('textAlign'));
                if ($(this).is(':checked') || $(this).hasClass('dMotiv')) {
                    posi = this;
                    toDealWith = '.hasMotiv' + pos;
                    if (element) {
                        toDealWith = element;
                    }
                    if (position && position !== pos) {
                        return false;
                    }
                    if (parent) {
                        toDealWith = parent + ' ' + toDealWith;
                    }
                    toDealWith = toDealWith + ':not(.ym-hideme)';
                    $(toDealWith).each(function () {
                        var templateTyp, pxFactor, widthMM, stickWidth, stickHeight, posiInfo, posId, sizeId, that, dimage, maxWidth, drHolder, maxHeight, zeroLeft, zeroTop, ndrWidthPx, ndrHeightPx, ndrLeftPx, ndrTopPx, tzndrWidthPx, tzndrHeightPx, tzndrLeftPx, tzndrTopPx, imgWidth, factor, ooWidth = 520, area, mglft, mgtop, tzone;
                        that = this;
                        templateTyp = $('.temselect.selected').first().attr('data-type');
                        relImage = $(that).find('img').first();

                        if ($(posi).closest('li').find('.drgebiet') && relImage.is(':visible')) {
                        relImage.imagesLoaded().progress(function (t, img) {
                            drgebiet = $(posi).closest('li').find('.drgebiet');
                            drWidthPx = drgebiet.attr('data-drWidthPx');
                            drHeightPx = drgebiet.attr('data-drHeightPx');
                            drLeftPx = drgebiet.attr('data-drLeftPx');
                            drTopPx = drgebiet.attr('data-drTopPx');
                            gebiet = $(posi).closest('li').find('.gebiet[data-fuer-stick=1]');
                            tzWidthPx = gebiet.attr('data-widthPx');
                            tzHeightPx = gebiet.attr('data-heightPx');
                            tzLeftPx = gebiet.attr('data-leftPx');
                            tzTopPx = gebiet.attr('data-topPx');
                            relImage = $(img.img);
                            that = relImage.closest(toDealWith);
                            if ($(that).hasClass('ndimg')) {
                                drHolder = $(that).closest('.fleinner').find('.tainfo').find('.tapinfo[data-pos="' + pos + '"]');
                                drgebiet = drHolder.find('.drgebiet');
                                drWidthPx = drgebiet.attr('data-drWidthPx');
                                drHeightPx = drgebiet.attr('data-drHeightPx');
                                drLeftPx = drgebiet.attr('data-drLeftPx');
                                drTopPx = drgebiet.attr('data-drTopPx');
                                gebiet = null;
                                if (templateTyp == 'stick') {
                                    gebiet = drHolder.find('.gebiet[data-fuer-stick=1]');
                                } else if (templateTyp == 'druck' || templateTyp == 'upload') {
                                    gebiet = drHolder.find('.gebiet[data-fuer-druck=1]');
                                }
                                tzWidthPx = gebiet.attr('data-widthPx');
                                tzHeightPx = gebiet.attr('data-heightPx');
                                tzLeftPx = gebiet.attr('data-leftPx');
                                tzTopPx = gebiet.attr('data-topPx');
                            }
                            if (tzWidthPx !== undefined) {
                                imgWidth = relImage.width();
                                if (imgWidth == 0) {
                                    return false;
                                }
                                factor = ooWidth / imgWidth;
                                mglft = parseInt(relImage.css('marginLeft'), 10);
                                mgtop = parseInt(relImage.css('marginTop'), 10);
                                ndrWidthPx = parseInt(drWidthPx / factor, 10);
                                ndrHeightPx = parseInt(drHeightPx / factor, 10);
                                ndrLeftPx = drLeftPx / factor;
                                ndrTopPx = drTopPx / factor;
                                tzndrWidthPx = parseInt(tzWidthPx / factor, 10);
                                tzndrHeightPx = parseInt(tzHeightPx / factor, 10);
                                tzndrLeftPx = tzLeftPx / factor;
                                tzndrTopPx = tzTopPx / factor;
                                zeroLeft = relImage.position().left + ndrLeftPx + mglft;
                                zeroTop = relImage.position().top + ndrTopPx + mgtop;
                                area = $('<div />')
                                    .width(ndrWidthPx)
                                    .height(ndrHeightPx)
                                    .attr('data-drLeftPx', ndrLeftPx)
                                    .attr('data-drTopPx', ndrTopPx)
                                    .attr('data-drWidthPx', ndrWidthPx)
                                    .attr('data-drHeightPx', ndrHeightPx)
                                    .css('left', zeroLeft)
                                    .css('top', zeroTop)
                                    .css('background', 'red')
                                    .css('opacity', '.2')
                                    .addClass('tmpimg')
                                    .addClass('absolute')
                                    .addClass('area')
                                    .addClass('tmp' + aPT);
                                $(that).append(area.hide());
                                leftPos = zeroLeft + tzndrLeftPx;
                                topPos = zeroTop + tzndrTopPx;
                                tzone = $('<div />')
                                    .width(tzndrWidthPx)
                                    .height(tzndrHeightPx)
                                    .css('left', leftPos)
                                    .css('top', topPos)
                                    .css('background', '#ccc')
                                    .css('opacity', '.3')
                                    .addClass('tmpimg')
                                    .addClass('absolute')
                                    .addClass('tzone')
                                    .addClass('tmp' + aPT);
                                $(that).append(tzone.hide());
                                dimage = overlayImage.attr('src') + '&width=' + parseInt(tzndrWidthPx, 10);
                                dimage = $.replaceUrlParam(overlayImage.attr('src'), 'width', parseInt(tzndrWidthPx, 10));
                                if (!imgs[dimage]) {
                                    $('<img />').attr('src', dimage).removeClass('tmpimg').appendTo('body').hide();
                                    imgs[dimage] = true;
                                }
                                overlayImage.attr('src', dimage);
                                sizeId = $(parent).find(':input[name="basketsize"]').val();
                                posId = $(parent).find('.jsMsPlace').find('.selected').find('input:checked').val();
                                posiInfo = $(parent).find('.shop_prodDetails_frinfo_' + posId + '_' + sizeId);
                                widthMM = posiInfo.attr('data-width-mm');
                                stickWidth = $(parent).find('.soapId').attr('data-width');
                                stickHeight = $(parent).find('.soapId').attr('data-height');
                                pxFactor = widthMM / drWidthPx;
                                maxWidth = stickWidth / 10 / pxFactor / factor;
                                maxHeight = stickHeight / 10 / pxFactor / factor;
                                overlayImage.width(maxWidth);
                                overlayImage.height(maxHeight);
                                leftPos = leftPos + tzone.width() / 2 - overlayImage.width() / 2;
                                if (gebiet.attr('data-align') == 'bc' || gebiet.attr('data-align') == 'bl' || gebiet.attr('data-align') == 'br') {
                                    topPos = topPos + tzone.height() - overlayImage.height();
                                }
                                overlayImage
                                    .css('left', Math.ceil(leftPos))
                                    .css('top', Math.ceil(topPos))
                                    .addClass('overlayImage ttttt')
                                    .attr('data-aktLeft_px', leftPos - zeroLeft)
                                    .attr('data-aktTop_px', topPos - zeroTop)
                                    .attr('data-relLeft_px', leftPos - zeroLeft - tzndrLeftPx)
                                    .attr('data-relTop_px', topPos - zeroTop - tzndrTopPx);
                                $(that).append(overlayImage.clone().removeClass('overlayimg').show());
                                $('.motivZoom').remove();
                            }
                        }).done(function () {
                            $(that).find('.overlayImage').not(':last').remove();
                            $.loadOverlay(true);
                        });
                        }
                    });
                }
            });
            disableCart = false;
        };
        $.addListToCart = function (holder) {
            var prod = {}, i, hm, needsdesign, artikelId, anzahl, items = {}, position, positions = {}, motiv = {}, productImage, motpos, produktDetails = {}, produktAnzahl = {}, overwrite = false;
            holder.find('.motselect:first').trigger('click');
            motpos = holder.find('.jsMsPlace').find('.selected').find('input:checked').attr('data-pos');
            productImage = holder.find('.motivImage.hasMotiv' + motpos).find('.rpcol');
            produktDetails.stammartikelId = parseInt(holder.find('input[name=stammartikel_id]').val(), 10);
            produktDetails.farbId = parseInt(holder.find('.jsMsColor').find('.selected').attr('data-farbId'), 10);
            produktDetails.imageWidthPx = productImage.width();
            produktDetails.imageHeightPx = productImage.height();
            produktDetails.positionen = {};
            if (disableCart === true) {
                return;
            }
            i = 0;
            anzahl = holder.find('input[name=quantity]').val();
            items.anzahl = anzahl;
            artikelId = holder.find('.shop_prodDetails_preise_' + produktDetails.farbId + '_' + holder.find(':input[name=basketsize]').val()).find('.id').text();
            items.artikelId = artikelId;
            needsdesign = false;
            if (holder.find('input[name=needsdesign]').length && holder.find('input[name=needsdesign]').val() === '1') {
                needsdesign = true;
            }
            produktAnzahl[i] = items;
            if (anzahl < 1) {
                $.setInfo(sprache.motivDesigner_bitteweahlengroesse);
                holder.find('input[name=quantity]').focus();
                disableCart = false;
                return false;
            }
            //positionen
            position = holder.find('.jsMsPlace').find('.selected').find('input:checked').val();
            if (!position) {
                position = holder.find('.jsMsThumbs').find('a').first().attr('data-positionsId');
            }
            if (!position && needsdesign === true) {
                $.setInfo(sprache.check_motiv);
                disableCart = true;
                return false;
            }
            hm = holder.find('.motivImage.hasMotiv1').find('.area');
            positions.positionId = parseInt(position, 10);
            positions.drTopPx = parseInt(hm.attr('data-drTopPx'), 10);
            positions.drTopPx = parseInt(hm.attr('data-drTopPx'), 10);
            positions.drLeftPx = parseInt(hm.attr('data-drLeftPx'), 10);
            positions.drWidthPx = parseInt(hm.attr('data-drWidthPx'), 10);
            positions.drHeightPx = parseInt(hm.attr('data-drHeightPx'), 10);
            //template
            motiv.typ = {};
            motiv.typ.istDruck = 1;
            motiv.typ.istTemplate = 1;
            motiv.idx = 0;
            //motivdetails
            motiv.details = {};
            hm = holder.find('.motivImage.hasMotiv' + motpos).find('.overlayImage');
            if (needsdesign === true && !holder.find('.soapId').val()) {
                $.setInfo(sprache.check_motiv);
                disableCart = false;
                $('html,body').animate({
                    scrollTop: 0
                }, 300);
                return false;
            }
            positions.motive = {};
            if (needsdesign === true) {
                motiv.details.soapId = parseInt(holder.find('.soapId').val(), 10);
                motiv.details.aktLeft_px = parseInt(hm.attr('data-aktLeft_px'), 10);
                if (!motiv.details.aktLeft_px) {
                    holder.find('.motselect:first').trigger('click');
                    $.setInfo(sprache.motivDesigner_bitteweahlengroesse);
                    disableCart = false;
                    return;
                }
                motiv.details.aktTop_px = parseInt(hm.attr('data-aktTop_px'), 10);
                motiv.details.aktWidth_px = hm.width();
                motiv.details.aktHeight_px = hm.height();
                motiv.details.grundWidth_mm = holder.find('.soapId').attr('data-width') / 10;
                motiv.details.grundHeight_mm = holder.find('.soapId').attr('data-height') / 10;
                motiv.details.defMot = 0;

                positions.motive[0] = motiv;
            }
            produktDetails.positionen[0] = positions;
            prod.produktDetails = JSON.stringify(produktDetails);
            prod.produktAnzahl = JSON.stringify(produktAnzahl);
            prod.overwrite = overwrite;
            disableCart = true;
            $.ajax({
                data: prod,
                dataType: 'json',
                cache: false,
                type: 'POST',
                url: '/ajax/ajax.php?action=set_designer_produkt2Warenkorb',
                success: function (msg) {
                    if (msg !== null) {
                        var tmpCount = 0;
                        for (i = 0; i < Object.size(msg.shop_warenkorbItems); i = i + 1) {
                            tmpCount += parseInt(msg.shop_warenkorbItems[i].anzahl, 10);
                        }
                        warenkorb_updateCount(tmpCount, msg.warenkorb_preis);
                        warenkorb_updateItems(msg.shop_warenkorbItems, msg.warenkorb_preis);
                        $.setInfo(sprache.designer_produktInWarenkorb);
                        holder.find('input[name=quantity]').val('');
                        disableCart = false;
                        return false;
                    } else {
                        $.setInfo(sprache.designer_produktInWarenkorb_error, 'error');
                        $('.loadimg').remove();
                        disableCart = false;
                    }
                },
                error: function () {
                    $.setInfo(sprache.designer_produktInWarenkorb_error, 'error');
                    $('.loadimg').remove();
                    disableCart = false;
                }
            });
        };    });
    $(function () {
        var $cr=$;var old_src;$cr(document).ready(function () {$cr(".cr_form").submit(function () {$cr(this).find('.clever_form_error').removeClass('clever_form_error');$cr(this).find('.clever_form_note').remove();$cr(this).find(".musthave").find('input, textarea').each(function () {if (jQuery.trim($cr(this).val())==""||($cr(this).is(':checkbox'))||($cr(this).is(':radio'))) {if ($cr(this).is(':checkbox')||($cr(this).is(':radio'))) {if (!$cr(this).parent().find(":checked").is(":checked")) {$cr(this).parent().addClass('clever_form_error')}} else {$cr(this).addClass('clever_form_error')}}});if ($cr(this).attr("action").search(document.domain)>0&&$cr(".cr_form").attr("action").search("wcs")>0) {var cr_email=$cr(this).find('input[name=email]');var unsub=false;if ($cr("input['name=cr_subunsubscribe'][value='false']").length) {if ($cr("input['name=cr_subunsubscribe'][value='false']").is(":checked")) {unsub=true}}if (cr_email.val()&&!unsub) {$cr.ajax({type:"GET",url:$cr(".cr_form").attr("action").replace("wcs","check_email")+$cr(this).find('input[name=email]').val(),success:function (data) {if (data) {cr_email.addClass('clever_form_error').before("<div class='clever_form_note cr_font'>"+data+"</div>");return false}},async:false})}var cr_captcha=$cr(this).find('input[name=captcha]');if (cr_captcha.val()) {$cr.ajax({type:"GET",url:$cr(".cr_form").attr("action").replace("wcs","check_captcha")+$cr(this).find('input[name=captcha]').val(),success:function (data) {if (data) {cr_captcha.addClass('clever_form_error').after("<div  class='clever_form_note cr_font'>"+data+"</div>");return false}},async:false})}}if ($cr(this).find('.clever_form_error').length) {return false}return true});$cr('input[class*="cr_number"]').change(function () {if (isNaN($cr(this).val())) {$cr(this).val(1)}if ($cr(this).attr("min")) {if (($cr(this).val()*1)<($cr(this).attr("min")*1)) {$cr(this).val($cr(this).attr("min"))}}if ($cr(this).attr("max")) {if (($cr(this).val()*1)>($cr(this).attr("max")*1)) {$cr(this).val($cr(this).attr("max"))}}});old_src=$cr("div[rel='captcha'] img").attr("src");if ($cr("div[rel='captcha'] img").length!=0) {captcha_reload()}});function captcha_reload() {var timestamp=new Date().getTime();$cr("div[rel='captcha'] img").attr("src","");$cr("div[rel='captcha'] img").attr("src",old_src+"?t="+timestamp);return false}
    });
    $(document).on('mouseenter', '.hasHidden', function (e) {
        var box, left, top, width, boxwidth;
        top = $(this).height() * -1 - 1;
        left = $(this).width();
        $(this).find('.schd').stop().addClass('active shadow');
        box = $(this).find('.showonhover');
        width = $(window).width();
        boxwidth = box.width();
        if (left + boxwidth >= width) {
            box.width(width);
            left = 0;
            top = 0;
        }
        box.stop().css('left', left).css('top', top).fadeIn();
    }).on('mouseleave', '.hasHidden', function (e) {
        $(this).find('.schd').stop().delay(200).removeClass('active shadow').css('marginLeft', '0');
        $(this).find('.showonhover').stop().delay(200).fadeOut();
    });
    $(document).on('mouseenter', '.topbox .fle', function (e) {
        e.preventDefault();
        var extraheight = 0, height;
        //$(this).find('.colbubble').stop().css('width', '12px').css('height', '12px');
        extraheight = $(this).find('.avcols').height();
        height = 120 + extraheight;
        $(this).find('.s_produkte_item_detailFrm')
            .stop()
            .animate({
                height: height
            }, 250).css('overflow', 'visible');

        $(this).find('.s_produkte_item_detailHover, .s_produkte_item_detailBtn')
            .stop()
            .slideDown(200);
    }).on('mouseleave', '.topbox .fle', function (e) {
        e.preventDefault();
        $(this).find('.colbubble').stop()
        .animate({
            width: '6px',
            height: '6px'
        });
        $(this).find('.s_produkte_item_detailFrm')
            .stop()
            .delay(200)
            .animate({
                height: '25px'
            }, 250).css('overflow', 'visible');
        $(this).find('.s_produkte_item_detailHover, .s_produkte_item_detailBtn')
            .stop()
            .delay(200)
            .slideUp(200);
    });
    if ($('.seq .active').length) {
        $(function () {
            $.cycleImages = function (cycler) {
                var $active, $next;
                $active = $( cycler ).find('.active');
                $next = ($active.next().length > 0) ? $active.next() : $( cycler ).find( 'img:first' );
                $next.css('z-index',2);//move the next image up the pile
                $active.fadeOut(1500,function () {//fade out the top image
                    $(cycler).find('img').removeClass('hidee');
                    $active.css('z-index',1).show().removeClass('active');//reset the z-index and unhide the image
                    $next.css('z-index',3).addClass('active');//make the next image the top one
                    $next.closest('a').attr('href', $next.attr('data-url'));
                });
            };
            var intervalId;
            $('.seq').each(function () {
                var cycler = this;
                    $(cycler).css('position', 'relative');
                    $(cycler).find('img').css('position', 'absolute').css('top', '0').css('left', '0');
                    $(cycler).height(140).width(120).css('overflow', 'hidden');
                if ($(this).find('img').length > 1) {
                    intervalId = setInterval( function () {
                        $.cycleImages( cycler );
                    }, $(cycler).attr('data-speed'));
                }
            });
        });
    }

});
