/* My Javascript zongliang Update Time 2012-12-31 10:41 */ (function(window,undefined){ var document = window.document; var navigator = window.navigator; var location = window.location; var undefined = undefined; var zl = function(id,dom,win){return zl.$(id,dom,win);}; zl.version = '1.0.0.5'; /* zl.$ get Dom Object id:name,dom:parentNode Dom,win:window. */ zl.$ = function(obj,dom,win){ try{ document = (win == undefined) ? window.document : win.document; if(typeof obj == 'string'){ if(obj == '*'){ return (dom == undefined) ? document.getElementsByTagName('*') : zl.$(dom,undefined,win).getElementsByTagName('*'); } var _obj = obj.split(' '); if(_obj.length > 1){ var pdom = zl.$(_obj[0], dom); if(pdom != null){ if(zl.isset(pdom.length)){ var reary = []; for(var i = 0; i < pdom.length; i++){ var _tmp = zl.$(obj.substr(_obj[0].length+1), pdom[i], win); if(_tmp != null){ if(zl.isset(_tmp.length)){ for(var _i = 0; _i < _tmp.length; _i++){ if(_tmp[_i] != null) reary[reary.length] = _tmp[_i]; } }else{ reary[reary.length] = _tmp; } } //reary[reary.length] = zl.$(obj.substr(_obj[0].length+1), pdom[i], win); } return (reary.length != 0) ? reary : null; }else{ return zl.$(obj.substr(_obj[0].length+1), pdom, win); } }else{ return null; } } else if(obj.charAt(0) == '<' && obj.charAt(obj.length-1) == '>' && obj.length >= 3){ obj = obj.substr(1, obj.length-2); return (dom == undefined) ? document.getElementsByTagName(obj) : zl.$(dom,undefined,win).getElementsByTagName(obj); } else if(obj.charAt(0) == '.' && obj.length >= 2){ obj = obj.substr(1, obj.length-1); if(zl.isset(document.getElementsByClassName)){ return (dom == undefined) ? document.getElementsByClassName(obj) : zl.$(dom,undefined,win).getElementsByClassName(obj); }else{ var oElm = (dom == undefined) ? document : zl.$(dom,undefined,win); var arrElements = (oElm.all)? oElm.all : oElm.getElementsByTagName('*'); var arrReturnElements = new Array(); obj = obj.replace(/\-/g, "\\-"); var oRegExp = new RegExp('(^|\\s)' + obj + '(\\s|$)'); var oElement; for(var i=0; i < arrElements.length; i++){ oElement = arrElements[i]; if(oRegExp.test(oElement.className)){ arrReturnElements.push(oElement); } } return (arrReturnElements); } } else if(obj.charAt(0) == '#' && obj.length >= 2){ obj = obj.substr(1, obj.length-1); if(zl.isset(document.getElementsByName)){ return (dom == undefined) ? document.getElementsByName(obj) : zl.$(dom,undefined,win).getElementsByName(obj); }else{ var oElm = (dom == undefined) ? document : zl.$(dom,undefined,win); var arrElements = (oElm.all)? oElm.all : oElm.getElementsByTagName('*'); var arrReturnElements = new Array(); var oElement; for(var i=0; i < arrElements.length; i++){ oElement = arrElements[i]; if(oElement.getAttribute('name') == obj){ arrReturnElements.push(oElement); } } return (arrReturnElements); } } else if(obj.charAt(0) == '[' && obj.charAt(obj.length-1) == ']' && obj.length >= 3){ _tmp = obj.substr(1, obj.length-2); var _att = _tmp.split('='); if(dom == undefined){ return zl.$('* '+obj,undefined,win); }else{ return (zl.att(dom,_att[0]) == _att[1]) ? dom : null; } } else { return (dom == undefined) ? document.getElementById(obj) : zl.$(dom,undefined,win).getElementById(obj); } } else if(typeof obj == 'function'){ zl.readyCallBacks[zl.readyCallBacks.length] = obj; zl.ready(); //window.onload = function(){zl.ready();} } else { return obj; } }catch(e){ zl.log('[Function][$] Get $ '+obj+' Error! '+e.message); return null; } }; /* is Internet Explorer */ zl.isIE = !!window.ActiveXObject; // close page zl.close = function(){window.opener = null; window.close();}; // get rand int zl.r = zl.rand = function(rmin,rmax){ if(!zl.isset(rmin)) rmin = 0; if(!zl.isset(rmax)) rmax = 100; return Math.round(rmin+(Math.random()*(rmax-rmin))); }; // new error zl.e = zl.error = function(msg){throw new Error(msg);}; // Check Obj Is defined zl.isset = zl.isdefined = function(obj){ return (typeof obj != 'undefined'); }; // log con:content ,e:error zl.log = function(con,e){ if(window.console && window.console.log){ if(e != undefined && e.message != undefined){ console.log(con + '\r\n\t [Error: ' + e.message + ' ]\r\n'); } else { console.log(con); } } }; /* Show Error Msg msg Error Content */ zl.showError = function(msg){ var showEr = zl.create({id:'show_Error_Msg',cssText:'border: 1px solid #CCC;background: #FFF;width:200px;min-height:50px;z-index:9999; filter:alpha(opacity=70);opacity:0.7;position:fixed;_position:absolute;right:5px;bottom:0px;_bottom:0px;'}); zl.create({cssText:'width:100%;height:24px;background:#ccc;color:red;font-size:14px;',pdom:showEr,content:'\u9519\u8bef\u63d0\u793aClose'}); zl.create({cssText:'width:100%;background:#FFF;color:red;font-size:13px;padding:10px;overflow:hidden;display:block;',pdom:showEr,content:'' + msg + ''}); setTimeout(function(){zl._fade(showEr,0,3,function(){zl.remove(this);});},3000); }; /* remove object dom */ zl.remove = zl.del = function(name,time){ var obj = zl.$(name); if(time){ zl._fade(obj,0,time,function(){zl.remove(this);}); } else { if(obj != null){ try{ obj.parentNode.removeChild(obj); zl.log('Remove Object ' + obj + ' Success'); }catch(e){ zl.log('Remove Object ' + obj + ' Failure! ', e); return e.message; } }else{ zl.log('[Function][remove]Remove Object ' + obj + ' Failure! [Error: Is Null! ]'); } } }; /* Verify CSS Style Att */ zl.isCss = function(elem,css,val){ try{ elem = zl.$(elem); if(css in elem.style){ if(zl.isset(val)){ elem.style[css] = val; return elem.style[css] === val; } return true; } return false; }catch(e){ zl.log('[Function][isCss] Get Elem ['+elem+'] CSS ['+css+'] Style Failure! ', e); return false; } }; /* Set Dom CSS Style */ zl.css = function(elem,css){ try{ elem = zl.$(elem); if(css.charAt(0) == '.'){ zl.att(elem, 'class', css.substr(1, css.length-1)); }else{ zl.att(elem, 'style', css); } }catch(e){ zl.log('[Function][css] Set Elem ['+elem+'] CSS ['+css+'] Style Failure! ', e); return false; } }; /* Load JavaScript */ zl.loadjs = zl.loadScript = function(src,charset,callback,kill){ try{ var h = zl.$('
')[0]; var ss = zl.$('