(function(){var k=false;if(k){Log.init("./",10,{width:850,height:600})}else{Log=function(){return false}}var e={};e.PUBLISHNAME="JsLoader";e.MAXSTORE=30;e.INDEXSTARTWITH=10;e.DATAPREFIX="userdata";e.VERSIONFILENAME=e.DATAPREFIX+0;e.INDEXTABLENAME=e.DATAPREFIX+1;e.DEFAULTCOMPRESSLEVEL=2;var n=2;var m=navigator.userAgent.toLowerCase();var g={version:(m.match(/.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/)||[])[1],safari:/webkit/.test(m),opera:/opera/.test(m),msie:/msie/.test(m)&&!/opera/.test(m),mozilla:/mozilla/.test(m)&&!/(compatible|webkit)/.test(m)};var d=g.msie;var c=g.mozilla;function i(o,s){if(o instanceof Array){for(var r=0,q=o.length;r<q;r++){s(o[r],r)}return false}else{if(o instanceof Object){for(var t in o){s(o[t],t)}return false}}}var l=new function(){if(d){Log("debug","UserData::init:isIE");document.documentElement.style.behavior="url('#default#userData')";document.documentElement.addBehavior("#default#userdata")}this.set=function(q,p){p=p+"";if(d){try{var o=document.documentElement;o.load(q);o.setAttribute("value",p);o.save(q);Log("info","Set Succeed");return true}catch(r){return false}}else{if(c){try{window.globalStorage[document.domain][q]=p;return true}catch(r){return false}}else{return false}}return false};this.get=function(p){if(d){try{var o=document.documentElement;o.load(p);var q=o.getAttribute("value");return q}catch(r){return null}}else{if(c){try{return window.globalStorage[document.domain][p].value}catch(r){return null}}else{return null}}return null};this.del=function(p){if(d){try{var o=document.documentElement;o.load(p);o.setAttribute("value","");o.save(p);return true}catch(q){return false}}else{if(c){try{delete window.globalStorage[document.domain][p];return true}catch(q){return false}}else{return false}}}};function a(o){var s=o;var v=l.get(o);var r=[];if(v){u()}function u(){Log("debug","Enter IndexTable::_iniRows_");var w=f.LineSplit(v);i(w,function(x,y){w[y]=f.RowSplit(x)});i(w,function(x,y){Log("info","("+y+")",x[0],x[1],x[2])});r=w}function q(w){return"{"+w+"}"}function t(x,w){x=parseInt(x,10);w=parseInt(w,10);if(x<w){return -1}if(x==w){return 0}if(x>w){return 1}}function p(){var x=[];i(r,function(y,z){x.push(f.RowJoin(y))});var w=f.LineJoin(x);if(!w){w=" "}l.set(s,w)}this.deleteAll=function(){r=[];p()};this.insert=function(w,x){w=q(w);r.push([w,x,new Date().getTime()]);p()};this.getSaveKey=function(w){Log("debug","Enter IndexTable::getSaveKey");Log("info","Arguments->key:",w);w=q(w);Log("info","WrapedKey:",w);var x=null;i(r,function(y,z){if(y[0]==w){y[2]=new Date().getTime();x=y[1];p()}});Log("info","Get Save Key:",x);return x};this.getNewSaveKey=function(){Log("debug","Enter IndexTable::getNewSaveKey");var B=null;var w=null;var A=null;if(r.length>=(e.MAXSTORE-e.INDEXSTARTWITH)){i(r,function(C,D){if(!w||t(C[2],w)<0){w=C[2];B=D;A=C[1]}});if(B!==null){r[B]="";return A}return false}var x=[];i(r,function(C,D){var E=parseInt(C[1],10);x[E]=true});for(var z=e.INDEXSTARTWITH,y=e.MAXSTORE;z<=y;z++){if(!x[z]){Log("info","Get A New Save Key:",z);return z}}}}var f=new function(){};f.RowJoin=function(o){var p=[];i(o,function(q,r){p.push(encodeURIComponent(q))});return p.join(" ")};f.RowSplit=function(o){var p=o.split(" ");i(p,function(q,r){p[r]=decodeURIComponent(q)});return p};f.LineJoin=function(o){var p=[];i(o,function(q,r){if(q){p.push(q)}});return p.join("\n")};f.LineSplit=function(o){return o.split("\n")};function j(o){var p=o;var q=l.get(o);this.getVersion=function(){if(!q||q.indexOf(j.FLAG)!=0){return false}var s=q.split("\n");var r=parseInt(s[1],10);return r};this.setVersion=function(r){var s=j.FLAG+"\n"+r;l.set(p,s)};this.versionCompare=function(){}}j.FLAG="%^&var#$;*@;!#_PPLIVE_USERDATAFILE_VERSION_1.1";function h(){var r=new j(e.VERSIONFILENAME);var o=r.getVersion();if(!o||o!=n){Log("warn","Version Not Match");q();r.setVersion(n)}var s=new a(e.INDEXTABLENAME);function p(){}function q(){var v;for(var u=0,t=e.MAXSTORE;u<=t;u++){v=e.DATAPREFIX+u;l.del(v)}}this.get=function(v){Log("debug","Enter CacheControl::get");Log("info","Arguments->url:",v);var t=s.getSaveKey(v);if(t!==0&&!t){return false}var w=e.DATAPREFIX+t;var u=l.get(w);return u};this.set=function(v,u){Log("debug","Enter CacheCotrol::set");Log("info","Arguments->url",v);var w=s.getNewSaveKey();Log("info","Get SaveKey From IndexTable:",w);if(!w){return false}var x=e.DATAPREFIX+w;Log("info","Produce realKey:",x);Log("info","Cache Length To Save:",u.length);var t=l.set(x,u);Log("info","Save Result:",t);if(t){s.insert(v,w)}};this.testfn=function(){l.set("test","kkkkkkkkddddd")};this.testfn2=function(){alert(l.get("test"))}}var b=new function(){var s=0;var p={"{0}":"","{1}":"[min]","{2}":"[packed]"};var r=e.DEFAULTCOMPRESSLEVEL;var q=null;function t(){q=new h()}function v(y){function x(C){var B=p["{"+C+"}"];return B?B:""}var z=y.split(".");var w=z.pop();var A=x(r);if(A){z.push(A)}z.push(w);return z.join(".")}function u(w,y){function x(z){var A=['<script type="text/javascript" '];A.push('src="'+z+'" ');if(!s&&!y){A.push('onload="'+e.PUBLISHNAME+'.scriptLoaded(this);" ');A.push('onreadystatechange="'+e.PUBLISHNAME+'.scriptLoaded(this);" ')}A.push("><\/script>");return A.join("")}document.write(x(w))}this.js=function(y,z){Log("debug","Enter loader:js");Log("info","Arguments->url:",y);if(z){Log("info","Direct Output the url");u(y,true);return false}var w=v(y);Log("info","reqUrl:",w);if(s){u(w);return false}if(!q){t()}var x=q.get(w);Log("info","cache:",x&&x.length);if(x){document.write('<script type="text/javascript">'+x+"<\/script>")}else{u(w)}};this.css=function(y){var w=v(y);if(s){u(w);return false}if(!q){t()}var x=q.get(w);if(x){UnpackCss(x)}else{u(w)}};this.switchSafeMode=function(w){w=!!w;s=w};this.setCompressLevel=function(w){r=w};var o;this.setTemp=function(w){Log("debug","Enter Loader::setTemp");if(s){return false}o=w;Log("info","set temp:",o.fileName)};this.scriptLoaded=function(x){Log("debug",x.readyState,x.src);if(s){return false}if(!o||!o.fileName){return false}var w,y;if(c||(d&&x.readyState=="complete")){Log("debug","Begin doing scriptLoaded");w=decodeURIComponent(x.src);y=o.fileName;Log("info","url:",w);Log("info","fileName",y);if(w.indexOf(y)==-1){Log("info","Url do not match the filename");return false}q.set(w,o.cache);o.cache="";o=null;return false}};this.testfn=function(){t();q.testfn()};this.testfn2=function(){q.testfn2()}};window[e.PUBLISHNAME]=b;window.UserData=l})();