window.bezen=window.bezen||(function(){var nix=function(){};var $=function(id){return document.getElementById(id)};return{$:$,nix:nix,_:{}}}());bezen.object=(function(){var beget=function(prototype){var F=function(){};F.prototype=prototype;return new F()};var exists=function(object){if(object===null||object===undefined){return false}for(var i=1;i<arguments.length;i++){object=object[arguments[i]];if(object===null||object===undefined){return false}}return true};var isArray=function(that){var result=that&&typeof that==='object'&&typeof that.length==='number'&&typeof that.splice==='function'&&!(that.propertyIsEnumerable('length'));return result?true:false};var isString=function(that){return typeof that==='string'||that instanceof String};return{beget:beget,exists:exists,isArray:isArray,isString:isString,_:{}}}());bezen.array=(function(){var ARRAY=[];var empty=function(array){array.length=0};var last=function(array){if(!array||array.length===0){return null}return array[array.length-1]};var push=function(array,item){if(Array.push){return Array.push(array,item)}else{return ARRAY.push.call(array,item)}};var pop=function(array){if(Array.pop){return Array.pop(array)}else{return ARRAY.pop.call(array)}};var shift=function(array){if(Array.shift){return Array.shift(array)}else{return ARRAY.shift.call(array)}};var unshift=function(array,item){if(Array.unshift){return Array.unshift(array,item)}else{return ARRAY.unshift.call(array,item)}};var copy=function(array){if(!array){return null}var duplicate=[];for(var i=0;i<array.length;i++){duplicate.push(array[i])}return duplicate};var hash=function(array){if(!array){return null}var arrayhash={};for(var i=0;i<array.length;i++){arrayhash[array[i]]=true}return arrayhash};return{empty:empty,last:last,push:push,pop:pop,shift:shift,unshift:unshift,copy:copy,hash:hash,_:{}}}());bezen.log=(function(){var $=bezen.$,exists=bezen.object.exists,pop=bezen.array.pop,unshift=bezen.array.unshift;var MAX_RECORDS=100;var DOM_LOG_ID='bezen.log';var records=[];var ON=true;var OFF=false;var globalOnOff=OFF;var on=function(){globalOnOff=ON};var off=function(){globalOnOff=OFF};var isOn=function(localOnOff){if(localOnOff===ON){return true}if(localOnOff===OFF){return false}return globalOnOff};var log=function(){var message=arguments[0];for(var i=1;i<arguments.length;i++){message+=arguments[i]}if(records.length<MAX_RECORDS){records.push(message)}if(exists(window,'jash','print')){window.jash.print(message)}if(exists(window,'console','log')){var console=window.console;if(exists(console,'firebug')){console.log.apply(this,arguments)}else{console.log(message)}}var logDiv=$(DOM_LOG_ID);if(exists(logDiv)){logDiv.appendChild(document.createTextNode(message));logDiv.appendChild(document.createElement('br'))}};var logIfOn=function(){if(arguments.length>1&&typeof arguments[arguments.length-1]==='boolean'){var localOnOff=arguments[arguments.length-1];if(isOn(localOnOff)){pop(arguments);log.apply(null,arguments)}}else{if(isOn()){log.apply(null,arguments)}}};var info=function(){logIfOn.apply(null,arguments)};var warn=function(message,localOnOff){unshift(arguments,'Warning: ');logIfOn.apply(null,arguments)};var error=function(message,localOnOff){unshift(arguments,'[ERROR] ');logIfOn.apply(null,arguments)};var view=function(offset,end){offset=offset||0;end=end||records.length;if(end>records.length){end=records.length}var lines='';for(var i=offset;i<end;i++){lines+=(i+1)+'. '+records[i]+'\n'}return lines};return{on:on,off:off,info:info,warn:warn,error:error,view:view,_:{isOn:isOn,log:log,logIfOn:logIfOn,globalOnOff:globalOnOff,records:records}}}());
window.bezen=window.bezen||(function(){var a=function(){};var b=function(c){return document.getElementById(c)};return{$:b,nix:a,_:{}}}());bezen.error=(function(){var g=window.setTimeout,f=window.setInterval;var h=function(k,j,i){if(!bezen.log){return}if(typeof k==="object"){h(k.message,k.fileName,k.lineNumber);return}bezen.log.error(k+" at "+j+"["+i+"]",true)};var c=function(k,j,i){h("window.onerror: "+k,j,i);return true};var d=function(k,j){j=j||"error.catchError";if(typeof k!=="function"){h(j+": A function is expected, found "+typeof k);return bezen.nix}var i=function(){try{return k.apply(this,arguments)}catch(l){if(window.onerror){window.onerror(j+": "+l.message+" in "+k,l.fileName,l.lineNumber,true)}}};return i};var e=function(j,i){if(typeof j==="string"){if(bezen.log){bezen.log.warn('window.setTimeout: eval is evil: "'+j+'"')}j=new Function(j)}return g(d(j,"window.setTimeout"),i)};var b=function(j,i){if(typeof j==="string"){if(bezen.log){bezen.log.warn('window.setInterval: eval is evil: "'+j+'"')}j=new Function(j)}return f(d(j,"window.setInterval"),i)};var a=function(){window.onerror=c;window.setTimeout=e;window.setInterval=b};return{reportError:h,onerror:c,safeSetTimeout:e,safeSetInterval:b,catchError:d,catchAll:a,_:{}}}());bezen.object=(function(){var c=function(e){var f=function(){};f.prototype=e;return new f()};var d=function(e){if(e===null||e===undefined){return false}for(var f=1;f<arguments.length;f++){e=e[arguments[f]];if(e===null||e===undefined){return false}}return true};var b=function(f){var e=f&&typeof f==="object"&&typeof f.length==="number"&&typeof f.splice==="function"&&!(f.propertyIsEnumerable("length"));return e?true:false};var a=function(e){return typeof e==="string"||e instanceof String};return{beget:c,exists:d,isArray:b,isString:a,_:{}}}());bezen.string=(function(){var a=function(d){d=d.replace(/^\s\s*/,"");return d.replace(/\s\s*$/,"")};var c=function(d,e){e=String(e);return d.slice(0,e.length)===e};var b=function(d,e){e=String(e);return d.slice(d.length-e.length)===e};return{trim:a,startsWith:c,endsWith:b,_:{}}}());bezen.array=(function(){var c=[];var f=function(j){j.length=0};var h=function(j){if(!j||j.length===0){return null}return j[j.length-1]};var g=function(k,j){if(Array.push){return Array.push(k,j)}else{return c.push.call(k,j)}};var i=function(j){if(Array.pop){return Array.pop(j)}else{return c.pop.call(j)}};var b=function(j){if(Array.shift){return Array.shift(j)}else{return c.shift.call(j)}};var d=function(k,j){if(Array.unshift){return Array.unshift(k,j)}else{return c.unshift.call(k,j)}};var a=function(l){if(!l){return null}var k=[];for(var j=0;j<l.length;j++){k.push(l[j])}return k};var e=function(l){if(!l){return null}var k={};for(var j=0;j<l.length;j++){k[l[j]]=true}return k};return{empty:f,last:h,push:g,pop:i,shift:b,unshift:d,copy:a,hash:e,_:{}}}());bezen.dom=(function(){var j=bezen.error.catchError;var c=1,k=2,b=3;var e=function(m,l){var o=document.createElement(m);if(!l){return o}for(var p in l){if(l.hasOwnProperty(p)){o.setAttribute(p,l[p])}}if(o.canHaveChildren===false){return o}for(var n=2;n<arguments.length;n++){var q=arguments[n];if(typeof q==="string"){q=document.createTextNode(q)}o.appendChild(q)}return o};var f=function(l){if(l.canHaveChildren===false){return}l.innerHTML=""};var h=function(n,l){var m=n.parentNode;m.insertBefore(l,n)};var g=function(n,l){var m=n.parentNode;m.insertBefore(l,n.nextSibling)};var d=function(l){if(l.parentNode&&l.parentNode.innerHTML){l.parentNode.removeChild(l)}};var a=function(n,l){if(n.hasAttribute){return n.hasAttribute(l)}var m=n.getAttributeNode(l);if(m===null){return false}return m.specified};var i=function(m,o,n){var l=j(n,"script.onload");if(o.readyState&&o.onload!==null){o.onreadystatechange=function(){if(o.readyState==="loaded"||o.readyState==="complete"){o.onreadystatechange=null;o.onerror=null;l()}}}else{o.onload=l}m.appendChild(o)};return{ELEMENT_NODE:c,ATTRIBUTE_NODE:k,TEXT_NODE:b,element:e,clear:f,insertBefore:h,insertAfter:g,remove:d,hasAttribute:a,appendScript:i,_:{}}}());bezen.domwrite=(function(){var a=bezen.nix,p=bezen.string.trim,h=bezen.array.empty,d=bezen.dom.hasAttribute,g=bezen.dom.appendScript,f=document.write,o=document.writeln;var b=[];var n=function(s){b.push(s)};var i=function(s){n(s+"\n")};var e=function(){if(b.length===0){return null}var s=b.join("");h(b);return s};var c=function(t){var s=document.createElement("div");s.innerHTML="<br/>"+t;s.removeChild(s.firstChild);return s.firstChild};var l=function(s){if(s.nodeName!=="SCRIPT"){return false}if(s.language&&s.language.toLowerCase()!=="javascript"){return false}if(s.type&&p(s.type).toLowerCase()!=="text/javascript"){return false}return true};var k=function(u,x,w){if(d(x,"src")){var s=document.createElement("script");for(var t=0;t<x.attributes.length;t++){var v=x.attributes[t];if(d(x,v.name)){s.setAttribute(v.name,v.value)}}s.text=x.text;g(u,s,w)}else{var y=x.cloneNode(false);y.text=x.text;y.type="any";u.appendChild(y);if(d(x,"type")){y.setAttribute("type",x.type)}else{y.removeAttribute("type")}(new Function(y.text))();w()}};var r;var j=function(y,x,z){if(x===null){z();return}var v=null;var s=y;var t=function(){j(s,v,z)};if(l(x)){setTimeout(function(){k(y,x,function(){r(y,t)})},0)}else{var w=x.cloneNode(false);y.appendChild(w);setTimeout(t,0);if(x.firstChild){var u=x.getElementsByTagName("script").length;if(u===0){w.innerHTML=x.innerHTML}else{v=x.firstChild;s=w}}}if(v===null){v=x.nextSibling}var A=x.parentNode;while(v===null&&A!==null){v=A.nextSibling;s=s.parentNode;A=A.parentNode}return};var m=function(){var s=document;if(s.write===f){s.write=n}if(s.writeln===o){s.writeln=i}};r=function(t,u){if(t instanceof Function){u=t;t=document.body}else{t=t||document.body;u=u||a}var s=e();if(s===null){u()}else{j(t,c(s),u)}};var q=function(){document.write=f;document.writeln=o};return{capture:m,parseMarkup:c,render:r,restore:q,_:{markupArray:b,domWrite:n,domWriteln:i,collectMarkup:e,isJavascriptScript:l,appendScriptClone:k,loadPiecemeal:j}}}());bezen.load=(function(){var c=bezen.nix,b=bezen.object.isString,f=bezen.array.unshift,d=bezen.dom.appendScript,g=bezen.dom.element;var h=function(k,i,l,j){if(k&&!k.nodeType){f(arguments,null);return h.apply(null,arguments)}if(b(i)){return h(k,{src:i},l,j)}l=l||c;k=k||document.body;j=j||0;setTimeout(function(){d(k,g("script",i),l)},j)};var a=function(j,k){if(!k){return c}var i=0;return function(){i++;if(i<j){return}k()}};var e=function(m,n,o,k){if(m&&!m.nodeType){f(arguments,null);return e.apply(null,arguments)}var j=a(n.length,o);for(var l=0;l<n.length;l++){h(m,n[l],j,k)}};return{script:h,scripts:e,_:{getSingleCallback:a}}}());bezen.ready=(function(){var m=bezen.domwrite,f=m.parseMarkup,i=bezen.dom.hasAttribute,A,B,s,g,v,n;var q=[];var b=[];var w=function(){A=window.addEventListener;B=document.addEventListener;s=window.attachEvent;g=document.attachEvent};var r=function(){return document.readyState==="complete"};var y=function(){if(document.readyState){return}document.readyState="complete"};var l=function(F,E){if(!F||(typeof F==="object"&&!F.handleEvent)){return}F=F.handleEvent||F;E=E||"bezen.onready";var D=bezen.error?bezen.error.catchError(F,E):F;q.push(D)};var p=function(){var F=function(G,H){return function(){G.readyState="complete";H.apply(G,arguments)}};while(b.length>0){var D=b.pop();var E=D.onreadystatechange;if(typeof E==="function"){l(F(D,E))}}};var u=function(D,E){if(D==="onload"){l(E,"window.onload");return true}else{if(s){return s(D,E)}else{return false}}};var j=function(E,F,D){if(E==="load"){l(F,"window.load")}else{if(A){A.apply(window,arguments)}}};var c=function(E,F,D){if(E==="load"||E==="DOMContentLoaded"){l(function(){F.apply(document,arguments)},"document."+E)}else{if(B){B.apply(document,arguments)}}};var a=function(D,E){if(D==="onreadystatechange"){l(E,"document.onreadystatechange");return true}else{if(g){return g(D,E)}else{return false}}};var z;var e=function(){var D=window.onload;if(D&&D!==z){l(D,"window.onload")}window.onload=z};z=function(E){E=E||window.event;y();if(!r()){return}if(window.detachEvent){window.detachEvent("onload",z)}if(document.detachEvent){document.detachEvent("onreadystatechange",z)}if(!E){if(document.createEvent){E=document.createEvent("HTMLEvents");E.initEvent("load",false,false)}else{if(document.createEventObject){E=document.createEventObject();var D=document.createDocumentFragment();D.attachEvent("onreadystatechange",function(){D.detachEvent("onreadystatechange",arguments.callee);window.event.type="load";z(E)});D.fireEvent("onreadystatechange",E);return}}}e();p();while(q.length>0){q.shift()(E)}};var k=function(){if(q.length>0){return true}if(b.length>0){return true}if(window.onload){if(window.onload!==z){return true}}return false};var t=function(){w();e();if(A&&window.addEventListener!==j){window.addEventListener("load",z,false);window.addEventListener=j}if(B&&document.addEventListener!==c){document.addEventListener("load",z,false);document.addEventListener("DOMContentLoaded",z,false);document.addEventListener=c}if(s&&window.attachEvent!==u){window.attachEvent("onload",z);window.attachEvent=u}if(g&&document.attachEvent!==a){document.attachEvent("onreadystatechange",z);document.attachEvent=a}};var C=function(D){if(typeof D==="string"){var E=f(D);if(E&&E.nodeName==="SCRIPT"&&E.nextSibling===null&&i(E,"id")&&i(E,"defer")){var F="javascript";F+=":void(0)";var G=E.getAttribute("src");if(G==="//:"||G==="//0"||G===F){b.push(E);return}}}v(D)};var o=function(F){for(var E=b.length;E>=0;E--){var D=b[E];if(D&&D.id===F){return D}}if(n.apply){return n.apply(document,arguments)}else{return n(F)}};var d=function(){m.capture();var D=document;v=D.write;D.write=C;n=document.getElementById;document.getElementById=o};var h=function(){if(r()){z()}};var x=function(){m.restore();if(A){window.addEventListener=A}if(B){document.addEventListener=B}if(s){window.attachEvent=s}if(g){document.attachEvent=g}if(n){document.getElementById=n}};return{isReady:r,beReady:y,addListener:l,hasListeners:k,capture:t,captureScriptDeferHack:d,simulate:h,restore:x,_:{listeners:q,deferScripts:b,init:w,onready:z,captureWindowOnload:e,filterWindowAttachEvent:u,filterWindowAddEventListener:j,filterDocumentAddEventListener:c,filterDocumentAttachEvent:a,collectScriptDeferHack:p,filterDomWrite:C,filterDocumentGetElementById:o}}}());

