(function(n){n.fn.waitMe=function(t){return this.each(function(){function p(){var n=u.attr("data-waitme_id");u.removeClass(f+"_container").removeAttr("data-waitme_id");u.find("."+f+'[data-waitme_id="'+n+'"]').remove()}var u=n(this),f="waitMe",y,e,r,o=!1,s="background-color",h="",c="",l,i,a,v={init:function(){function rt(n){k.css({top:"auto",transform:"translateY("+n+"px) translateZ(0)"})}var st={effect:"win8_linear",text:"",bg:"rgba(255,255,255,0.7)",color:"#2f6193",maxSize:"",textPos:"vertical",fontSize:"",source:"",onClose:function(){}},d,v,ft,w,it,k,ot,nt;i=n.extend(st,t);a=(new Date).getMilliseconds();l=n('<div class="'+f+'" data-waitme_id="'+a+'"><\/div>');switch(i.effect){case"none":r=0;break;case"bounce":r=3;break;case"rotateplane":r=1;break;case"stretch":r=5;break;case"orbit":r=2;o=!0;break;case"roundBounce":r=12;break;case"win8":r=5;o=!0;break;case"win8_linear":r=5;o=!0;break;case"ios":r=12;break;case"facebook":r=3;break;case"rotation":r=1;s="border-color";break;case"timer":r=2;v=n.isArray(i.color)?i.color[0]:i.color;h="border-color:"+v;break;case"pulse":r=1;s="border-color";break;case"progressBar":r=1;break;case"bouncePulse":r=3;break;case"img":r=1}if(h!==""&&(h+=";"),r>0){if(i.effect==="img")c='<img src="'+i.source+'">';else for(d=1;d<=r;++d)n.isArray(i.color)?(v=i.color[d],v==undefined&&(v="#000")):v=i.color,c+=o?'<div class="'+f+"_progress_elem"+d+'"><div style="'+s+":"+v+'"><\/div><\/div>':'<div class="'+f+"_progress_elem"+d+'" style="'+s+":"+v+'"><\/div>';e=n('<div class="'+f+"_progress "+i.effect+'" style="'+h+'">'+c+"<\/div>")}if(i.text&&(v=n.isArray(i.color)?i.color[0]:i.color,ft=i.fontSize!=""?"font-size:"+i.fontSize:"",y=n('<div class="'+f+'_text" style="color:'+v+";"+ft+'">'+i.text+"<\/div>")),w=u.find("> ."+f),w&&w.remove(),it=n('<div class="'+f+"_content "+i.textPos+'"><\/div>'),it.append(e,y),l.append(it),u[0].tagName=="HTML"&&(u=n("body")),u.addClass(f+"_container").attr("data-waitme_id",a).append(l),w=u.find("> ."+f),k=u.find("."+f+"_content"),w.css({background:i.bg}),i.maxSize!==""&&i.effect!="none"){var ht=e.outerHeight(),ct=e.outerWidth(),et=ht;i.effect==="img"?(e.css({height:i.maxSize+"px"}),e.find(">img").css({maxHeight:"100%"}),k.css({marginTop:-k.outerHeight()/2+"px"})):i.maxSize<et&&(i.effect=="stretch"?(e.css({height:i.maxSize+"px",width:i.maxSize+"px"}),e.find("> div").css({margin:"0 5%"})):(ot=i.maxSize/et-.2,nt="-50%",i.effect=="roundBounce"?nt="-75%":i.effect=="win8"||i.effect=="timer"||i.effect=="orbit"?nt="-20%":i.effect=="ios"&&(nt="-15%"),e.css({transform:"scale("+ot+") translateX("+nt+")",whiteSpace:"nowrap"})))}if(k.css({marginTop:-k.outerHeight()/2+"px"}),u.outerHeight()>n(window).height()){var tt=n(window).scrollTop(),b=k.outerHeight(),g=u.offset().top,ut=u.outerHeight(),p=tt-g+n(window).height()/2;p<0&&(p=Math.abs(p));p-b>=0&&p+b<=ut?(g-tt>n(window).height()/2&&(p=b),rt(p)):(p=tt>g+ut-b?tt-g-b:tt-g+b,rt(p));n(document).scroll(function(){var i=n(window).scrollTop(),t=i-g+n(window).height()/2;t-b>=0&&t+b<=ut&&rt(t)})}w.on("destroyed",function(){i.onClose&&n.isFunction(i.onClose)&&i.onClose();w.trigger("close")});return n.event.special.destroyed={remove:function(n){n.handler&&n.handler()}},w},hide:function(){p()}};return v[t]?v[t].apply(this,Array.prototype.slice.call(arguments,1)):typeof t=="object"||!t?v.init.apply(this,arguments):void 0})};n(window).on("load",function(){n("body.waitMe_body").addClass("hideMe");setTimeout(function(){n("body.waitMe_body").find(".waitMe_container:not([data-waitme_id])").remove();n("body.waitMe_body").removeClass("waitMe_body hideMe")},200)})})(jQuery)