var cheshi={};cheshi.widget={};cheshi.$=function(a){try{if(typeof a==="string"){return document.getElementById(a)}else{return false}}catch(b){return false}};cheshi.n=function(a){try{if(typeof a==="string"){return document.getElementsByName(a)}else{return[]}}catch(b){return[]}};cheshi.t=function(a){try{if(typeof a==="string"){return document.getElementsByTagName(a)}else{return[]}}catch(b){return[]}};cheshi.c=function(b,a){try{if(typeof b==="string"){b=cheshi.$(b)}if(typeof a==="string"){if(b.getElementsByClassName){return b.getElementsByClassName(a)}else{els=[];all_els=b.getElementsByTagName("*");for(i=0;i<all_els.length;i++){if(cheshi.className(all_els[i])==a){els.push(all_els[i])}}return els}}else{return[]}}catch(c){return[]}};cheshi.ready=function(a){if(document.all){window.attachEvent("onload",a)}else{window.addEventListener("load",a,false)}};cheshi.show=function(a){try{if(typeof a=="string"){a=cheshi.$(a)}a.style.display=""}catch(b){}};cheshi.hide=function(a){try{if(typeof a=="string"){a=cheshi.$(a)}a.style.display="none"}catch(b){}};cheshi.toggle=function(a){try{if(typeof a=="string"){a=cheshi.$(a)}if(a.style.display=="none"){a.style.display=""}else{a.style.display="none"}}catch(b){}};cheshi.className=function(b,a){try{if(typeof b=="string"){b=cheshi.$(b)}if(a==undefined){if(document.all){return b.className}else{return b.getAttribute("class")}}else{if(document.all){b.className=a}else{return b.setAttribute("class",a)}}}catch(c){return false}};cheshi.event=function(a,c,b){if(typeof a=="string"){a=cheshi.$(a)}if(document.all){a.attachEvent("on"+c,b)}else{a.addEventListener(c,b,false)}};cheshi.ajax=function(b){if(typeof window.$JSON=="undefined"){window.$JSON={}}$JSON._ajax=function(c){c=c[0]||{};this.url=c.url||"";this.type=c.type||"xhr";this.method=(this.type=="json")?"GET":c.method.toUpperCase()||"GET";this.param=c.param||null;this.callback=c.callback||{};this.XHR=null;if(typeof window._$JSON_callback=="undefined"){window._$JSON_callback={}}this._createRequest()};$JSON._ajax.prototype={_createXHR:function(){var d=[function(){return new XMLHttpRequest()},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];for(var f=0,c=d.length;f<c;f++){try{d[f]()}catch(g){continue}this._createXHR=d[f];return d[f]()}},_createRequest:function(){return(this.type=="json")?this._setJSONRequest():this._setXHRRequest()},_setXHRRequest:function(){var e=this;var d="";for(var c in this.param){if(d==""){d=c+"="+this.param[c]}else{d+="&"+c+"="+this.param[c]}}this.XHR=this._createXHR();this.XHR.onreadystatechange=function(){if(e.XHR.readyState==4){if(e.XHR.status==200){e.callback.success(e.XHR.responseText)}else{e.callback.failure("重新操作")}}};this.XHR.open(this.method,this.url,true);this.XHR.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=utf-8");this.XHR.send(d)},_setJSONRequest:function(){var f=document.getElementsByTagName("head")[0];var d=document.createElement("script");var c=this._setRandomFun();var h=this;var g="";for(var e in this.param){if(g==""){g=e+"="+this.param[e]}else{g+="&"+e+"="+this.param[e]}}d.type="text/javascript";d.charset="utf-8";if(f){f.appendChild(d)}else{document.body.appendChild(d)}window._$JSON_callback[c.id]=function(j){h.callback.success(j);setTimeout(function(){delete window._$JSON_callback[c.id];d.parentNode.removeChild(d)},100)};if(this.url.indexOf("?")){d.src=this.url+"&cheshicallback="+c.name+"&"+g}else{d.src=this.url+"?cheshicallback="+c.name+"&"+g}},_setRandomFun:function(){var c="";do{c="$JSON"+Math.floor(Math.random()*10000)}while(window._$JSON_callback[c]);return{id:c,name:"window._$JSON_callback."+c}}};window.$JSON.ajax=function(){return new $JSON._ajax(arguments)};var a=new $JSON.ajax(b)};cheshi.getJSON=function(a,b){cheshi.ajax({url:a,type:"json",method:"get",callback:{success:function(c){b.apply(self,[c])}}})};cheshi.filter=function(b,c){if(typeof c!=="function"){return false}if(Boolean(b)===false||b.length==0){return[]}var a=[];for(i=0;i<b.length;i++){if(c.call(this,b[i])){a.push(b[i])}}return a};cheshi.map=function(b,c){if(typeof c!=="function"){return false}if(Boolean(b)===false||b.length==0){return[]}var a=[];for(i=0;i<b.length;i++){a.push(c.apply(this,[b[i]]))}return a};cheshi.addScript=function(b,c){var a=document.getElementsByTagName("head")[0];var d=document.createElement("script");d.setAttribute("type","text/javascript");d.setAttribute("charset","utf-8");d.setAttribute("src",b);a.appendChild(d);if(typeof c==="function"){d.onload=d.onreadystatechange=function(){if(!this.readyState||d.readyState=="loaded"||d.readyState=="complete"){c.call()}}}return false};cheshi.lazyPage=function(a){this.x=0,this.y=0,this.w=0,this.h=0;this.getOffset=function(){if(typeof window.pageXOffset!="undefined"||typeof window.pageYOffset!="undefined"){this.x=window.pageXOffset;this.y=window.pageYOffset}else{if(typeof document.compatMode!="undefined"&&document.compatMode=="CSS1Compat"){this.x=document.documentElement.scrollLeft;this.y=document.documentElement.scrollTop}else{if(typeof document.body!="undefined"&&(document.body.scrollLeft||document.body.scrollTop)){this.x=document.body.scrollLeft;this.y=document.body.scrollTop}}}};this.getSize=function(){if(typeof window.innerWidth!="undefined"){this.w=window.innerWidth,this.h=window.innerHeight}else{if(typeof document.documentElement!="undefined"&&typeof document.documentElement.clientWidth!="undefined"&&document.documentElement.clientWidth!=0){this.w=document.documentElement.clientWidth,this.h=document.documentElement.clientHeight}else{this.w=document.getElementsByTagName("body")[0].clientWidth,this.h=document.getElementsByTagName("body")[0].clientHeight}}};this.getOffset();this.getSize()};cheshi.lazyElement=function(a,b){if (!Boolean(a)) return false;this.x=0,this.y=0,this.w=0,this.h=0;this.getOffset=function(){var c=a;this.x=c.offsetLeft;this.y=c.offsetTop;while(c=c.offsetParent){this.x+=c.offsetLeft;this.y+=c.offsetTop}this.y-=300};this.getSize=function(){this.w=a.offsetWidth;this.h=a.offsetHeight+300};this.load=function(){if(this.x+this.w>cheshi.lazyElement.page.x&&this.x<cheshi.lazyElement.page.x+cheshi.lazyElement.page.w&&this.y+this.h>cheshi.lazyElement.page.y&&this.y<cheshi.lazyElement.page.y+cheshi.lazyElement.page.h){b.call(this,a)}};this.getOffset();this.getSize();this.load()};cheshi.lazyElement.scroll=function(){cheshi.lazyElement.page=new cheshi.lazyPage()};if(!Array.indexOf){Array.prototype.indexOf=function(b){for(var a=0;a<this.length;a++){if(this[a]==b){return a}}return -1}};
