// cms function cms(applyTo) { this.id = document.uniqueID; window[this.id] = this; // call by template this.applyTo = applyTo; this.apply = function (id) { if (id == null && this.applyTo != null) { id = this.applyTo; } else { this.applyTo = id; } var html = this.xmlDoc.documentElement.transformNode(this.xslDoc.documentElement); document.getElementById(id).innerHTML = html; }; this.applyByDoc = function (doc,id) { if (id == null && this.applyTo != null) { id = this.applyTo; } else { this.applyTo = id; } var html = doc.documentElement.transformNode(this.xslDoc.documentElement); document.getElementById(id).innerHTML = html; }; this.applyByElement = function (element,id) { if (id == null && this.applyTo != null) { id = this.applyTo; } else { this.applyTo = id; } var html = element.transformNode(this.xslDoc.documentElement); document.getElementById(id).innerHTML = html; }; this.trans = function (xmlText, xsltFile) { var text; if (typeof (window.ActiveXObject) != "undefined") { // is IE try { var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); var xslDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); xmlDoc.async = false; xslDoc.async = false; xmlDoc.load(xmlText); xslDoc.load(xsltFile); text = xmlDoc.documentElement.transformNode(xslDoc.documentElement); } catch (e) { alert(e.name + ": " + e.message); alert("Unable to do xml/xsl processing"); alert(e.name + ": " + e.message); } } else { if (document.implementation && document.implementation.createDocument) { // is Mozilla try { var oParser = new DOMParser(); var xmlDoc = oParser.parseFromString(xmlText, "text/xml"); xslDoc = document.implementation.createDocument("", "", null); xslDoc.async = false; xslDoc.load(xsltFile); var xsltProcessor = new XSLTProcessor(); xsltProcessor.importStylesheet(xslDoc); var result = xsltProcessor.transformToDocument(xmlDoc); var xmls = new XMLSerializer(); text = xmls.serializeToString(result); } catch (e) { if (isDebug) { alert(e.name + ": " + e.message); } alert("Unable to do xml/xsl processing"); } } } return text; }; this.createDocFromXml = function (xml) { var xmlDoc; if (typeof (window.ActiveXObject) != "undefined") { xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); xmlDoc.async = false; xmlDoc.loadXML(xml); } return xmlDoc; }; this.createDoc = function (uri) { var xmlDoc; if (typeof (window.ActiveXObject) != "undefined") { xmlDoc = new ActiveXObject("Msxml2.DOMDocument.3.0"); xmlDoc.async = false; xmlDoc.setProperty("ServerHTTPRequest", true); var ret = xmlDoc.load(uri); var xmlError = xmlDoc.parseError; if (ret == false && xmlError != null) { var error = xmlError.errorCode + " " + xmlError.reason + " " + uri; alert(error); } } return xmlDoc; }; this.setParam = function(name,value){ var node = this.xslDoc.selectSingleNode("xsl:stylesheet/xsl:param[@name='" + name + "']"); if (node != null) { node.text = value; } }; this.init = function() { }; this.dyniframesize = function(controlID) { var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] //extra height in px to add to iframe in FireFox 1.0+ browsers var FFextraHeight=getFFVersion>=0.1? 16 : 0 var pTar = null; if (document.getElementById) { pTar = document.getElementById(controlID); } else { eval('pTar = ' + controlID + ';'); } if (pTar && !window.opera) { //begin resizing iframe //pTar.style.display="block" var h1=0, h2=0, h3=0; if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight)//如果用戶的瀏覽器是NetScape { //ns6 syntax h1 = pTar.contentDocument.body.offsetHeight+FFextraHeight; } else if(document.body) { h3=document.body.scrollHeight; } else if (pTar.Document && pTar.Document.body.scrollHeight)//如果用戶的瀏覽器是IE { //ie5+ syntax //alert(pTar.Document.body.scrollHeight) // pTar.height = pTar.Document.body.scrollHeight; h2=document.documentElement.scrollHeight; // pTar.height = screen.availHeight; // alert(pTar.height); } var h=Math.max(h1, h2); h=Math.max(h, h3); if(document.all) {h += 4;} if(window.opera) {h += 1;} pTar.height = h-132; //pTar.height = screen.availHeight-150; //alert(pTar.height); } }; } // cms_blog function cms_blog() { cms.call(this); cms_blog.prototype = new cms(); this.xmlDoc = this.createDoc("http://www.first-aviva.com.tw:80/cms/chn/content/tw/actNews/index.xml"); // 過濾不是 blog 的資料 var nodeList = this.xmlDoc.selectNodes("//prod_list[tpeId != 'CEO Blog']"); for(var x = 0; x < nodeList.length; x++) { nodeList[x].parentNode.removeChild(nodeList[x]); } this.xmlDoc.setProperty("SelectionLanguage", "XPath"); this.xslDoc = this.createDoc("http://www.first-aviva.com.tw:80/cms/code/blog/index.xsl"); var node = this.xslDoc.selectSingleNode("xsl:stylesheet/xsl:param[@name='callback']"); node.text = this.id; this.detail = function (p,url) { var detailDoc = this.xmlDoc.selectSingleNode("root/prod_list[position()=" + p + "]"); var detailXsl = this.createDoc("http://www.first-aviva.com.tw:80/cms/code/blog/detail.xsl"); var node = detailXsl.selectSingleNode("xsl:stylesheet/xsl:param[@name='callback']"); node.text = this.id; var html = detailDoc.transformNode(detailXsl.documentElement); document.getElementById(this.applyTo).innerHTML = html; }; } // cmd_indexNews function cms_indexNews(applyTo) { cms.call(this,applyTo); cms_indexNews.prototype = new cms(); this.xmlDoc = this.createDoc("http://www.first-aviva.com.tw:80/xmlResource?xml=news/index.xml"); this.xmlDoc.setProperty("SelectionLanguage", "XPath"); this.xslDoc = this.createDoc("http://www.first-aviva.com.tw:80/cms/code/indexNews/index.xsl"); var node = this.xslDoc.selectSingleNode("xsl:stylesheet/xsl:param[@name='callback']"); node.text = this.id; // 顯示最新的年份 this.selectYear = this.xmlDoc.selectSingleNode("//selectYear").text; this.pageNo = 0; this.detail = function(position,url) { // create frame to show the detail document.getElementById(this.applyTo).innerHTML = "