/* LazyJS. Copyright (c) 2010 Alex Michael. MIT Licence */
var LazyJS=new function(){var f={queue:[],dir:""};var g=0;var h=0;var j={};var k=function(){var a=f.queue[h];if(!a){return}if(a.scripts.length<1){a=f.queue[++h];if(!a){f.queue.splice(0,h);h=0;g=0}else{window.setTimeout(k,a.delay)}return}var b=a.scripts.shift()();if(b&&b.__isExternal===true){(document.getElementsByTagName("head")[0]||document.body).appendChild(b.node);l(b)}else{k()}};var l=function(b){var c=b.node;function _onload(a){a.loadCallback();if(a.inSequence){k()}}c.onload=function(){if(!c.onloadDone){c.onloadDone=true;_onload(b)}};c.onreadystatechange=function(){if((c.readyState==="loaded"||c.readyState==="complete")&&!c.onloadDone){c.onloadDone=true;_onload(b)}};if(!b.inSequence){k()}};var m=function(a){var b=document.createElement('script');b.type='text/javascript';var c=["http://","https://","ftp://"];var d=c.length;b.src=f.dir+a;b.onloadDone=false;for(var i=0;i<d;++i){if(a.indexOf(c[i])>-1){b.src=a}}return b};var n=function(a,b,c){if(j[a]){return}j[a]={};var d=function(){return{node:m(a),inSequence:c,__isExternal:true,loadCallback:b}};o(d)};var o=function(a){if(!f.queue[g]){f.queue[g]={scripts:[],delay:0}}f.queue[g].scripts.push(a)};this.load=function(){var a=f.queue[h];if(a){window.setTimeout(k,a.delay)}};this.inline=function(a){if(a&&typeof a==="function"){o(a);return this}};this.external=function(a,b,c){if(a&&(a.constructor.toString().match(/string/i)||typeof a==="string")){n(a,(c||function(){}),(b||false));return this}};this.externals=function(a){if(!a){return}var b=(a.sequence||[]),parallel=(a.parallel||[]);var c=b.length,p_l=parallel.length;var d=b.concat(parallel),all_l=d.length;if(all_l===0||a.constructor.toString().match(/array/i)){d=a;all_l=d.length}var e=function(){};for(var i=0;i<all_l;++i){n(d[i],e,(i<c))}return this};this.after=function(a){var b=f.queue[g];if(b){f.queue[g].delay=a;++g;return this}};this.directory=function(a){f.dir=a;return this}};