FD31.plugin("utils",function($){$.IE=function(){if(-1!=navigator.appVersion.indexOf("MSIE 10"))return 10;for(var undef,v=3,div=document.createElement("div"),all=div.getElementsByTagName("i");v++,div.innerHTML="<!--[if gt IE "+v+"]><i></i><![endif]-->",all[0];);return v>4?v:undef}(),$.uid=function(p,s){return(p?p:"")+Math.random().toString().replace(".","")+(s?s:"")},$.isDeferred=function(obj){return obj&&$.isFunction(obj.always)},$.distinct=function(items){var uniqueElements=$.unique;if(!(items.length<1)){if(items[0].nodeType)return uniqueElements.apply(this,arguments);
if("object"==typeof items[0]){var unique=Math.random(),uniqueObjects=[];return $.each(items,function(i){items[i][unique]||(uniqueObjects.push(items[i]),items[i][unique]=!0)}),$.each(uniqueObjects,function(i){delete uniqueObjects[i][unique]}),uniqueObjects}return $.grep(items,function(item,i){return $.inArray(item,items)===i})}},$.trimSeparators=function(keyword,separator,removeDuplicates){var s=separator;return keyword=keyword.replace(new RegExp("^["+s+"\\s]+|["+s+",\\s]+$","g"),"").replace(new RegExp(s+"["+s+"\\s]*"+s,"g"),s).replace(new RegExp("[\\s]+"+s,"g"),s).replace(new RegExp(s+"[\\s]+","g"),s),removeDuplicates&&(keyword=$.distinct(keyword.split(s)).join(s)),keyword
},$.isNumeric=function(n){return!isNaN(parseFloat(n))&&isFinite(n)},$.Number={rotate:function(n,min,max,offset){return void 0===offset&&(offset=0),n+=offset,min>n?n+=max+1:n>max&&(n-=max+1),n}},$.fn.stretchToFit=function(){return $.each(this,function(){var $this=$(this);$this.css("width","100%").css("width",2*$this.width()-$this.outerWidth(!0)-parseInt($this.css("borderLeftWidth"))-parseInt($this.css("borderRightWidth")))})},$.fn.serializeObject=function(){var obj={};return $.each($(this).serializeArray(),function(i,prop){obj.hasOwnProperty(prop.name)?($.isArray(obj[prop.name])||(obj[prop.name]=[obj[prop.name]]),obj[prop.name].push(prop.value)):obj[prop.name]=prop.value
}),obj},$.fn.serializeJSON=function(){return JSON.stringify($(this).serializeObject())},$.fn.toHTML=function(){return $("<div>").html(this).html()},function(){var Bloop=function(items){this.items=items,this.start=0,this.end=items.length-1,this.node=null,this.stopped=!1};$.extend(Bloop.prototype,{isLooping:function(){return this.stopped?!1:Math.abs(this.start-this.end)>1?(this.node=Math.floor((this.start+this.end)/2),!0):!1},flip:function(flip){flip?this.end=this.node-1:this.start=this.node+1},stop:function(){this.stop=!0
}}),$.Bloop=function(items){return new Bloop(items)}}(),$.remap=function(to,from,props){return $.each(props,function(i,prop){to[prop]=from[prop]}),obj},$.deletes=function(obj,props){$.each(props,function(i,prop){delete obj[prop]})},function(){var Threads=function(options){this.threads=[],this.threadCount=0,this.threadLimit=options.threadLimit||1,this.threadDelay=options.threadDelay||0};$.extend(Threads.prototype,{add:function(thread,type){$.isFunction(thread)&&(thread.type=type||"normal","deferred"==type&&(thread.deferred=$.Deferred().always($.proxy(this.next,this))),this.threads.push(thread),this.run())
},addDeferred:function(thread){return this.add(thread,"deferred")},next:function(){this.threadCount--,this.run()},run:function(){var self=this;setTimeout(function(){if(!(self.threads.length<1)&&self.threadCount<self.threadLimit){self.threadCount++;var thread=self.threads.shift();try{thread.call(thread,thread.deferred)}catch(e){console.error(e)}!thread.deferred&&self.next()}},self.threadDelay)}}),$.Threads=function(options){return new Threads(options)}}(),function(){var isFunction=$.isFunction,Enqueue=function(){this.lastId=0
};Enqueue.prototype.queue=function(filter){var self=this,id=$.uid();return self.lastId=id,function(){if(self.lastId===id){var args=arguments,args=isFunction(filter)?filter.apply(this,args):args;return isFunction(self.fn)?self.fn.apply(this,args):args}}},$.Enqueue=function(fn){var self=new Enqueue;$.isFunction(fn)&&(self.fn=fn);var func=$.proxy(self.queue,self);return func.reset=function(){self.lastId=0},func}}(),function(){var instance="___eventable",publicMethods=["on","off","fire"],getEventName=function(name){return name.split(".")[0]
},Eventable=function(mode){this.fnList={},this.events={},this.mode=mode};$.extend(Eventable.prototype,{createEvent:function(name){return this.events[name]=$.Callbacks(this.mode)},on:function(name,fn){if(!name||!$.isFunction(fn))return this;var fnList=this.fnList;(fnList[name]||(fnList[name]=[])).push(fn);var basename=getEventName(name);return(this.events[basename]||this.createEvent(basename)).add(fn),this},off:function(name){if(!name)return this;var basename=getEventName(name),event=this.events[basename];if(!event)return this;
var removeCallbacks=function(fnList){$.each(fnList,function(i,fn){event.remove(fn)})};return basename!==name?$.each(this.fnList,function(name,fnList){name.indexOf(basename)>-1&&removeCallbacks(fnList)}):removeCallbacks(this.fnList[name]),this},fire:function(name){var event=this.events[name];if(event)return event.fire.apply(event,$.makeArray(arguments).slice(1)),this},destroy:function(){for(name in this.events)this.events[name].disable()}}),$.eventable=function(obj,mode){var eventable=obj[instance];return eventable&&"destroy"===mode?(eventable.destroy(),$.deletes(obj,publicMethods),delete obj[instance]):(eventable=obj[instance]=new Eventable(mode),obj.on=$.proxy(eventable.on,eventable),obj.off=$.proxy(eventable.off,eventable),obj.fire=$.proxy(eventable.fire,eventable),obj)
}}(),$.Chunk=function(array,options){$.isArray(array)&&(array=[]);var options=$.extend({},{size:256,every:1e3},options),self=$.extend($.Deferred(),{size:options.size,every:options.every,from:0,to:array.length,process:function(callback){return self.process.fn=callback,self},chunkStart:function(callback){return self.chunkStart.fn=callback,self},chunkEnd:function(callback){return self.chunkEnd.fn=callback,self},start:function(){return self.stopped=!1,self.iterate(),self},iterate:function(){if(!self.stopped){var iterator=self.process.fn;
if(iterator){self.to=from.size+self.size;var max=array.length;self.to>max&&(self.to=max);var range={from:self.from,to:self.to};for(self.chunkStart.fn&&self.chunkStart.fn.call(self,range.from,range.to);self.from<self.to&&!self.stopped;)iterator.call(self,array[self.from]),self.from++;return self.chunkEnd.fn&&self.chunkEnd.fn.call(self,range.from,range.to),self.completed=self.from>=array.length-1,self.completed?self.resolveWith(self):self.nextIteration=setTimeout(self.iterate,self.every),self}}},pause:function(){return self.stopped=!0,clearTimeout(self.nextIteration),self
},restart:function(){return"rejected"===self.state()?self:(self.from=0,self.start(),self)},stop:function(){return self.pause(),self.rejectWith(self,[self.from]),self}});return self},$.fn.disabled=function(state){return void 0===state?this.is(":disabled")||this.hasClass("disabled"):this.prop("disabled",!!state).toggleClass("disabled",!!state)},$.fn.enabled=function(state){return void 0===state?!this.disabled():this.disabled(!state)},function(){var self=$.Ajax=function(options){var request=$.Deferred(),args=arguments;
return $.isPlainObject(options)&&$.isFunction(options.beforeCreate)&&options.beforeCreate(request),self.queue.addDeferred(function(queue){request.xhr=$.ajax.apply(null,args).pipe(request.resolve,request.reject,request.notify),setTimeout(queue.resolve,self.requestInterval)}),request};self.queue=$.Threads({threadLimit:1}),self.requestInterval=1200}(),$.callback=function(func,persist){if($.isFunction(func)){var funcName=$.uid("cb");return window[funcName]=function(){return persist||delete window[funcName],func.apply(null,arguments)
},funcName}if($.isString(func))switch(func){case"destroy":var funcName=persist;delete window[funcName]}},$.fn.visible=function(partial){var $t=$(this),$w=$(window);if(!($t.length<1)){var viewTop=$w.scrollTop(),viewBottom=viewTop+$w.height(),_top=$t.offset().top,_bottom=_top+$t.height(),compareTop=partial===!0?_bottom:_top,compareBottom=partial===!0?_top:_bottom;return viewBottom>=compareBottom&&compareTop>=viewTop}},$.fn.selectAll=function(){return this.each(function(){this.select()})},$.fn.unselect=function(){return this.each(function(){var input=this,value=input.value;
input.value+=" ",input.value=value})},$.fn.addTransitionClass=function(classname,duration){var $el=this.addClass(classname);return setTimeout(function(){$el.removeClass(classname)},duration||0),this},$.fn.switchClass=function(classname,delimiter){var delimiter=delimiter||"-",prefix=classname.split(delimiter)[0]+delimiter,length=prefix.length;return this.each(function(){var $el=$(this),classnames=$.map($el.attr("class").split(" "),function(classname){return classname.slice(0,length)==prefix||""==classname?null:classname
});classnames.push(classname),$el.attr("class",classnames.join(" "))})},$.sanitizeHTML=function(html){return $($.parseHTML(html)).toHTML()},$.buildHTML=function(html,keepScripts){if(html instanceof $)return html;var html=$.trim(html),scripts=[],fragment=$.buildFragment([html],document,scripts),nodes=$.merge([],fragment.childNodes);if(!keepScripts&&scripts.length>0){var script=document.createElement("script");script.text=$.callback(function(){$(scripts).remove()})+"();";for(var node,inserted,i=nodes.length-1;(node=nodes[i--])&&("SCRIPT"===node.nodeName?inserted=nodes.push(script):1===node.nodeType&&(inserted=node.appendChild(script)),!inserted););inserted||nodes.push(script),scripts.push(script)
}return $(nodes)},$.fn.filterBy=function(key,val,operator){var operator=operator||"=",selector="[data-"+key.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()+operator+val+"]";return this.filter(selector)},$.intersects=function(a,b){return $.isArray(b)&&(b={top:b.y,left:b.x,bottom:b.y,right:b.x}),b.left<=a.right&&a.left<=b.right&&b.top<=a.bottom&&a.top<=b.bottom},$.fn.intersectsWith=function(top,left,width,height){var offset=this.offset(),reference={top:offset.top,left:offset.left,bottom:offset.top+(sourceHeight=this.height()),right:offset.left+(sourceWidth=this.width()),width:sourceWidth,height:sourceHeight},subject={top:top,left:left,bottom:top+(height||(height=0)),right:left+(width||(width=0)),width:width,height:height};
return $.intersects(reference,subject)?{reference:reference,subject:subject}:!1},$.download=function(src){return $("<iframe>").hide().appendTo("body").bind("load",function(){$(this).remove()}).attr("src",src)}});