if (typeof(iPad) === "undefined") { iPad = {} } iPad.Detector = { getAgent: function() { return navigator.userAgent.toLowerCase() }, isWebKit: function(b) { if (this._isWebKit === undefined) { var a = b || this.getAgent(); this._isWebKit = !!a.match(/AppleWebKit/i); this.isWebKit = function() { return this._isWebKit } } return this._isWebKit }, isiPad: function(b) { var a = b || this.getAgent(); return !! (this.isWebKit(a) && a.match(/ipad/i)) }, hasLoaded: function(obj, fCallback) { if (this.ie) { obj.onreadystatechange = function() { if (this.readyState == 'loaded' || this.readyState == 'complete') { fCallback() } } } else if (this.moz) { obj.onload = function() { fCallback() } } else { fCallback() } }, _hasLocalStorage: null, hasLocalStorage: function() { if (this._hasLocalStorage !== null) { return this._hasLocalStorage } try { if (typeof localStorage !== "undefined" && "setItem" in localStorage) { localStorage.setItem("ipad_browser_detect", "test"); this._hasLocalStorage = true; localStorage.removeItem("ipad_browser_detect", "test") } else { this._hasLocalStorage = false } } catch(a) { this._hasLocalStorage = false } return this._hasLocalStorage }, _hasCookies: null, hasCookies: function() { if (this._hasCookies !== null) { return this._hasCookies } this._hasCookies = ("cookie" in document && !!navigator.cookieEnabled) ? true: false; return this._hasCookies } } iPad.Operating = iPad.prototype = { $: function(id) { return document.getElementById(id) }, $$: function(o, e) { return this.$(o).getElementsByTagName(e) }, setCookie: function(c_name, value, expiredays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + expiredays); document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "": ";expires=" + exdate.toGMTString()); }, getCookie: function(c_name) { if (document.cookie.length > 0) { c_start = document.cookie.indexOf(c_name + "="); if (c_start != -1) { c_start = c_start + c_name.length + 1; c_end = document.cookie.indexOf(";", c_start); if (c_end == -1) c_end = document.cookie.length return unescape(document.cookie.substring(c_start, c_end)); } } return "" }, removeCookie : function(a) { var b = "; expires=" + (new Date).toGMTString(); document.cookie = a + "=" + b + "; domain=xinhuanet.com; path=/" }, setLS : function(a, b) { if(iPad.Detector.hasLocalStorage()){ localStorage.setItem(a, b); } }, getLS : function(a) { if(iPad.Detector.hasLocalStorage()){ return localStorage[a]; } }, removeLS : function(a, b) { if(iPad.Detector.hasLocalStorage()){ localStorage.removeItem(a, b); } }, addEvent: function(l, i, I) { if (l.attachEvent) { l.attachEvent("on" + i, I) } else { l.addEventListener(i, I, false) } }, delEvent: function(l, i, I) { if (l.detachEvent) { l.detachEvent("on" + i, I) } else { l.removeEventListener(i, I, false) } } }