/* RS Js Framework 1.0 by Rolin 2008/6/2 @reeyee.cn */ function byId() {return document.getElementById(arguments[0])} function byTag(elem, tag) {if (!tag) {tag = elem; elem = document}return elem.getElementsByTagName(tag);} function byClass(classname, type, elem) { var r = [];if (!type) type = "*"; var arr = elem ? byTag(elem, type) : byTag(type); var re = new RegExp("(^|\\s)" + classname + "(\\s|$)"); for (var i=0; i0){offset=document.cookie.indexOf(I);if(offset!=-1){offset+=I.length;end=document.cookie.indexOf(";",offset);if(end==-1)end=document.cookie.length;i=unescape(document.cookie.substring(offset,end))}};return i}, writeCookie : function(O,o,l,I){var i="",c="";if(l!=null){i=new Date((new Date).getTime()+l*3600000);i="; expires="+i.toGMTString()};if(I!=null){c=";domain="+I};document.cookie=O+"="+escape(o)+i+c} } var Elem = { prev:function(elem) { do {elem = elem.previousSibling;} while(elem && elem.nodeType != 1); return elem; }, next:function(elem) { do {elem = elem.nextSibling;} while(elem && elem.nodeType != 1); return elem; }, first:function(elem) { elem = elem.firstChild; return elem && elem.nodeType != 1 ? Elem.next(elem) : elem; }, last:function(elem) { elem = elem.lastChild; return elem && elem.nodeType != 1 ? Elem.prev(elem) : elem; }, setAlpha:function(elem, alpha) { if (typeof elem.style.filter != 'undefined') { elem.style.filter = 'alpha(opacity='+alpha+')'; } else { elem.style.opacity = alpha/100; } }, pageX:function(elem) { return elem.offsetParent?(elem.offsetLeft+Elem.pageX(elem.offsetParent)):elem.offsetLeft; }, pageY:function(elem){ return elem.offsetParent?(elem.offsetTop+Elem.pageY(elem.offsetParent)):elem.offsetTop; }, stageHeight:function() { var h1 = document.body.scrollHeight; var h2 = document.body.parentNode.clientHeight; var h3 = document.body.parentNode.scrollHeight; var h = h1 > h2 ? h1 : h2; return h > h3 ? h : h3; }, getStyle:function(elem,name){ if(elem.style[name]){ return elem.style[name]; }else if(elem.currentStyle){ return elem.currentStyle[name]; }else if(document.defaultView&&document.defaultView.getComputedStyle){ name=name.replace(/([A-Z])/g,"-$1"); name=name.toLowerCase(); var s=document.defaultView.getComputedStyle(elem,""); return s&&s.getPropertyValue(name); }else { return null; } }, getAlpha:function(elem) { var result; if (elem.style.filter || elem.style.filter == '') { result = Number(elem.style.filter.split("=").pop().replace(")", '')); } else { result = elem.style.opacity*100; } return result; }, setAlpha:function(elem, alpha) { if (elem.style.filter || elem.style.filter == '') { elem.style.filter = "alpha(opacity="+alpha+")"; } else if (elem.style.opacity || elem.style.opacity == '') { elem.style.opacity = alpha/100; } }, remove: function(elem) { if (!elem) return; elem.parentNode.removeChild(elem); } } function ajax( options ) { options = { type: options.type || "POST", url: options.url || "", timeout: options.timeout || 5000, onComplete: options.onComplete || function(){}, onError: options.onError || function(){}, onSuccess: options.onSuccess || function(){}, data: options.data || "" } if (typeof XMLHttpRequest == 'undefined') { XMLHttpRequest = function() { return new ActiveXObject( navigator.appVersion.indexOf("MSIE 5.5")>=0 ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP" ) } } var xml = new XMLHttpRequest(); xml.open(options.type == "POST" ? "POST" : "GET", options.url, true); var timeoutLength = options.timeout; var requestDone = false; setTimeout(function(){ requestDone = true; }, timeoutLength); xml.onreadystatechange = function(){ if ( xml.readyState == 4 && !requestDone ) { if ( httpSuccess( xml ) ) { options.onSuccess( httpData( xml, options.type ) ); } else { options.onError(); } options.onComplete(); xml = null; } } xml.send(null); function httpSuccess(r) { try { return !r.status && location.protocol == "file:" || ( r.status >= 200 && r.status < 300 ) || r.status == 304 || navigator.userAgent.indexOf("Safari") >= 0 && typeof r.status == "undefined"; } catch(e){} return false; } function httpData(r,type) { var ct = r.getResponseHeader("content-type"); var data = !type && ct && ct.indexOf("xml") >= 0; data = type == "xml" || data ? r.responseXML : r.responseText; if ( type == "script" ) eval.call( window, data ); return data; } }