// LAB.js (LABjs :: Loading And Blocking JavaScript) | v0.8 (c) Kyle Simpson | MIT License

(function(a){var d="undefined",m="string",j="head",h="body",n=true,k=false,i=a.document,c=a.setTimeout,g=function(p){return i.getElementsByTagName(p)},f={head:g(j),body:g(h)},b={};if(typeof f[j]!==d&&f[j]!==null&&f[j].length>0){f[j]=f[j][0]}else{f[j]=null}if(typeof f[h]!==d&&f[h]!==null&&f[h].length>0){f[h]=f[h][0]}else{f[h]=null}function e(p){return(typeof p===m&&p.length)?/^([^#?]*\/)?([^?\/#]*)(\?.*)?(#.*)?$/i.exec(p)[2]:""}function o(r){var p=g("script"),s=0,q;while(q=p[s++]){if(typeof q.src===m&&r===e(q.src)){return n}}return k}function l(w,t,A){w=!(!w);t=((typeof t===m)?t:j);var y=k,v=function(){},q=k,z=null,s={},r=[];function u(B){if((this.readyState&&this.readyState!=="complete"&&this.readyState!=="loaded")||B.done){return}this.onload=this.onreadystatechange=null;B.done=n;function C(){for(var D in s){if(s.hasOwnProperty(D)&&!(s[D].done)){return k}}return(y=n)}if(C()){v()}}function p(F){var E=F.src,D=F.type,G=F.charset,B=F.allowDup,C=e(E);if(typeof D!==m){D="text/javascript"}if(typeof G!==m){G=null}B=!(!B);if(!B&&(typeof b[C]!==d||o(C))){return}if(typeof s[C]===d){s[C]={done:k}}else{s[C].done=k}b[C]=n;q=n;(function(H){c(function(){var J=null;if(((J=f[H])===null)&&(typeof(J=g(H)[0])===d||J===null)){c(arguments.callee,25);return}var I=i.createElement("script");I.setAttribute("type",D);if(typeof G===m){I.setAttribute("charset",G)}I.onload=I.onreadystatechange=function(){u.call(I,s[C])};I.setAttribute("src",E);J.appendChild(I)},0)})(t)}function x(B){if(w){r.push(B)}else{B()}}z={script:function(){var B=arguments;x(function(){for(var C=0;C<B.length;C++){if(Object.prototype.toString.call(B[C])==="[object Array]"){arguments.callee.apply(null,B[C])}else{if(typeof B[C]==="object"){p(B[C])}else{if(typeof B[C]===m){p({src:B[C]})}}}}});return z},block:function(D){if(typeof D!=="function"){D=function(){}}var E=l(n,t),B=E.trigger,C=function(){try{D()}catch(F){}B()};delete E.trigger;x(function(){if(q&&!y){v=C}else{c(C,0)}});return E},toHEAD:function(){x(function(){t=j});return z},toBODY:function(){x(function(){t=h});return z}};if(w){z.trigger=function(){for(var B=0;B<r.length;B++){r[B]()}}}return z}a.$LAB={script:function(){return l().script.apply(null,arguments)},block:function(){return l().block.apply(null,arguments)},toHEAD:function(){return l().toHEAD()},toBODY:function(){return l().toBODY()}}})(window);
