function AdvertHelper(ShowAd,kind,callBack) { this.link = "/redirect/?id="; this.items = new Object(); this.setTxt = function (idName, onefunc) { var json = this.items; if (!!json[idName] && json[idName].length > 0) { setHtml(idName, onefunc(json[idName][0])); } } this.getItem=function(name,defaultValue) { if (typeof (defaultValue) == "undefined") defaultValue = []; var arr = this.items[name]; if (!arr) return defaultValue; else return arr; } this.setEachTxt = function (idName, onefunc) { var json = this.items; if (!!json[idName]) { var tempObj = json[idName]; for (var i = 0; i < tempObj.length; i++) { var oneTemp = tempObj[i]; setHtml(idName + "[" + i + "]", onefunc(oneTemp,i)); } } } this.setEachImg = function (idName, onefunc, dividedStr) { var html = this.getEachImg(idName, onefunc, dividedStr); if(!!html) setHtml(idName, html); } this.setSpecialImg = function (idName, imageName, onefunc, dividedStr) { var html = this.getEachImg(imageName, onefunc, dividedStr); if (!!html) setHtml(idName, html); } this.getEachImg = function (idName, onefunc, dividedStr) { var json = this.items; if (typeof (dividedStr) == "undefined") dividedStr = ""; if (!!json[idName]) { var tempObj = json[idName]; var htmlArr = new Array(); for (var i = 0; i < tempObj.length; i++) { var oneTemp = tempObj[i]; htmlArr.push('
' + onefunc(oneTemp) +'
'); } return htmlArr.join(dividedStr); } else return ""; } if (window.location.href.indexOf("my=ad") > 0) ShowAd = true; this.ShowAd = ShowAd; if (!ShowAd) return; function setHtml(idName,html) { var dom = document.getElementById(idName); if (!!dom) dom.innerHTML = html; } var thisObj = this; var config = { type: "get", async: true, url: "/script/adv.js", //data: { 'fromID': '0', 'kind': kind }, dataType: "jsonp", jsonp: "callback", success: function (json) { if (typeof callBack === "function") callBack(json); }, error: function () { } } var callBackName = callBack.name || callBack.toString().match(/function\s*([^(]*)\(/)[1]; if (!!callBackName && typeof window[callBackName] == "function") config.jsonpCallback = callBackName; if (ShowAd) jQuery.ajax(config); }