(function(b){b.xLazyLoader=function(e,d){if(typeof e=="object"){d=e;e="init"}new c()[e](d)};b.xLazyLoader.defaults={js:[],css:[],img:[],name:null,timeout:20000,success:function(){},error:function(){},complete:function(){},each:function(){}};var a=document.getElementsByTagName("head")[0];function c(){var m=this,o,i=[],k=[],j,d,f,e=[];this.init=function(p){if(!p){return}o=b.extend({},b.xLazyLoader.defaults,p);f={js:o.js,css:o.css,img:o.img};b.each(f,function(q,r){if(typeof r=="string"){r=r.split(",")}e=e.concat(r)});if(!e.length){h("error");return}if(o.timeout){j=setTimeout(function(){var q=i.concat(k);b.each(e,function(s,r){b.inArray(r,q)==-1&&k.push(r)});h("error")},o.timeout)}b.each(f,function(q,r){if(b.isArray(r)){b.each(r,function(t,s){l(q,s)})}else{if(typeof r=="string"){l(q,r)}}})};this.js=function(u,v,q){var t=b('script[src*="'+u+'"]');if(t.length){t.attr("pending")?t.bind("scriptload",v):v();return}var r=document.createElement("script");r.setAttribute("type","text/javascript");r.setAttribute("src",u);r.setAttribute("id",q);r.setAttribute("pending",1);r.onerror=n;b(r).bind("scriptload",function(){b(this).removeAttr("pending");v();setTimeout(function(){b(r).unbind("scriptload")},10)});var p=false;r.onload=r.onreadystatechange=function(){if(!p&&(!this.readyState||/loaded|complete/.test(this.readyState))){p=true;r.onload=r.onreadystatechange=null;b(r).trigger("scriptload")}};a.appendChild(r)};this.css=function(q,u,r){if(b('link[href*="'+q+'"]').length){u();return}var s=b('<link rel="stylesheet" type="text/css" media="all" href="'+q+'" id="'+r+'"></link>')[0];if(b.browser.msie){s.onreadystatechange=function(){/loaded|complete/.test(s.readyState)&&u()}}else{if(b.browser.opera){s.onload=u}else{var p=location.hostname.replace("www.",""),t=/http:/.test(q)?/^(\w+:)?\/\/([^\/?#]+)/.exec(q)[2]:p;p!=t&&b.browser.mozilla?u():(function(){try{s.sheet.cssRules}catch(v){d=setTimeout(arguments.callee,20);return}u()})()}}a.appendChild(s)};this.img=function(q,r){var p=new Image();p.onload=r;p.onerror=n;p.src=q};this.disable=function(p){b("#lazy-loaded-"+p,a).attr("disabled","disabled")};this.enable=function(p){b("#lazy-loaded-"+p,a).removeAttr("disabled")};this.destroy=function(p){b("#lazy-loaded-"+p,a).remove()};function l(q,p){m[q](p,function(r){r=="error"?k.push(p):i.push(p)&&o.each(p);g()},"lazy-loaded-"+(o.name?o.name:new Date().getTime()))}function h(p){o.complete(p,i,k);o[p](p=="error"?k:i);clearTimeout(j);clearTimeout(d)}function g(){if(i.length==e.length){h("success")}else{if(i.length+k.length==e.length){h("error")}}}function n(){k.push(this.src);g()}}})(jQuery);