function XPlatform() { } // detect Internet Explorer XPlatform.isIE = document.all && window.ActiveXObject && (navigator.userAgent.toLowerCase().indexOf('msie') > -1); XPlatform.httpGet = function httpGet(url) { var req; if (XPlatform.isIE) { req = new ActiveXObject('Microsoft.XMLHTTP'); } else { req = new XMLHttpRequest(); } req.open('GET', url, false); req.setRequestHeader('Cache-Control', 'no-cache'); req.setRequestHeader('Expires', 'Fri, 30 Oct 1998 14:19:41 GMT'); req.send(null); return req.responseText; } XPlatform.setClass = function setClass(node, val) { var attrName = (XPlatform.isIE ? 'className' : 'class'); node.setAttribute(attrName, val); } XPlatform.setAttribute = function setAttribute(element, attrName, val) { if (XPlatform.isIE) { if (attrName == 'class') attrName = 'className'; else if (attrName == 'for') attrName = 'htmlFor'; } element.setAttribute(attrName, val); } XPlatform.getAttribute = function getAttribute(element, attrName) { if (XPlatform.isIE) { if (attrName == 'class') return element.className; else if (attrName == 'for') return element.htmlFor; } return element.getAttribute(attrName); } XPlatform.setStyle = function setStyle(element, styleAttribute, val) { if (element.style.setAttribute) { element.style.setAttribute(styleAttribute, val); } else { element.style[styleAttribute] = val; } } XPlatform.getStyle = function getStyle(element, styleAttribute) { if (element.style.getAttribute) { return element.style.getAttribute(styleAttribute); } else { return element.style[styleAttribute]; } } XPlatform.setOpacity = function setOpacity(element, opacity) { if (element.filters) { try { element.filters.alpha.opacity = opacity * 100; } catch (e) { } } else if (element.style.MozOpacity !== (void 0)) { var val = parseFloat(opacity); if (val > .99) val = .99; element.style.MozOpacity = val; } else if (element.style.opacity !== (void 0)) element.style.opacity=opacity; } XPlatform.getOpacity = function getOpacity(element) { return element.filters ? element.filters.alpha.opacity*100 : element.style.MozOpacity ? element.style.MozOpacity : element.style.opacity ? element.style.opacity : 0.0; }