function BlogAd(cfg) { this.version = "0.3.3"; this.date = "Sep. 5th, 2011"; this.info = "Sina Media Strategy Center, yafeng2@staff. "; this.getAd = function(cb) { var res = new Object(); var nowTime = new Date().getTime(); var site = 'sina'; var adPos = 'ads'; var rIndex = ""; var tagList = ''; var keyList = ''; var gender = ''; var age = ''; var income = ''; var cat1 = ''; var cat2 = ''; var blogID = ''; if (typeof cfg == 'object') { if (cfg.pos != null) adPos = cfg.pos; if (cfg.rIndex != null) rIndex = cfg.rIndex; if (cfg.tagList != null) tagList = cfg.tagList; if (cfg.keyList != null) keyList = cfg.keyList; if (cfg.gender != null) gender = cfg.gender; if (cfg.age != null) age = cfg.age; if (cfg.income != null) income = cfg.income; if (cfg.cat1 != null) cat1 = cfg.cat1; if (cfg.cat2 != null) cat2 = cfg.cat2; if (cfg.blogID != null) blogID = cfg.blogID; } srcUrl = "http://blog.sina.com.cn/lm/iframe/js/blognew2011.js"; if (typeof BLOG_AD == "object") { if (BLOG_AD[adPos] == null) { res.code = '2102'; res.ads = {}; } else { res.code = '0'; var posads = BLOG_AD[adPos].ads; if (BLOG_AD[adPos].ad == 1 && typeof posads == "object") { startTime = 0; endTime = 0; if (BLOG_AD[adPos].rtt != null && BLOG_AD[adPos].rtt == 1) { var r = new RotatorAD(BLOG_AD[adPos]); if (r[0] != null ) { if (r[0].enddate != null && r[0].enddate.match(/:\d{2}$/) == null) r[0].enddate += ' 23:59:59'; if ((r[0].startdate != null && Date.parse(r[0].startdate.replace(/-/g, "/")) >= nowTime) || (r[0].enddate != null && Date.parse(r[0].enddate.replace(/-/g, "/")) <= nowTime)) { res.code = '2201'; } else { if (r[0].warp != null && r[0].warp == 1) { if (r[0].ads != null) { r[0].ads.startdate = r[0].startdate; r[0].ads.enddate = r[0].enddate; r = r[0].ads; } else { res.code = '2205'; } } if (r[0].type != 'mixed' && (r[0].ref == null || r[0].ref == '')) { res.code = '2203'; } else { if (r[0].type == 'flv') { r[0].type = 'mixed'; r[0].content = playerize(r[0]); r[0].ref = ''; } } } } else { res.code = '2111'; } posads = r; } else { var r = BLOG_AD[adPos].ads; if (r[0].enddate != null && r[0].enddate.match(/:\d{2}$/) == null) r[0].enddate += ' 23:59:59'; if ((r[0].startdate != null && Date.parse(r[0].startdate.replace(/-/g, "/")) >= nowTime) || (r[0].enddate != null && Date.parse(r[0].enddate.replace(/-/g, "/")) <= nowTime)) { res.code = '2201'; } } res.ads = posads; } else { res.code = '2101'; res.ads = {}; } } cb(res); } else { var script = document.createElement("script"); script.type = "text/javascript"; script.charset = "gb2312"; script.src = srcUrl; document.body.appendChild(script); script.onload = script.onreadystatechange = function() { if (this.readyState == null || this.readyState == "loaded" || this.readyState == "complete") { if (typeof BLOG_AD == "object") { if (BLOG_AD[adPos] == null) { res.code = '2102'; res.ads = {}; } else { res.code = '0'; var posads = BLOG_AD[adPos].ads; if (BLOG_AD[adPos].ad == 1 && typeof posads == "object") { if (BLOG_AD[adPos].rtt != null && BLOG_AD[adPos].rtt == 1) { var r = new RotatorAD(BLOG_AD[adPos]); if (r[0] != null) { if (r[0].enddate != null && r[0].enddate.match(/:\d{2}$/) == null) r[0].enddate += ' 23:59:59'; if ((r[0].startdate != null && Date.parse(r[0].startdate.replace(/-/g, "/")) >= nowTime) || (r[0].enddate != null && Date.parse(r[0].enddate.replace(/-/g, "/")) <= nowTime)) { res.code = '2201'; } else { if (r[0].warp != null && r[0].warp == 1) { if (r[0].ads != null) { r[0].ads[0].startdate = r[0].startdate; r[0].ads[0].enddate = r[0].enddate; r = r[0].ads; } else { res.code = '2205'; } } if (r[0].type != 'mixed' && (r[0].ref == null || r[0].ref == '')) { res.code = '2203'; } else { if (r[0].type == 'flv') { r[0].type = 'mixed'; r[0].content = playerize(r[0]); r[0].ref = ''; } } } } else { res.code = '2111'; } posads = r; } else { var r = BLOG_AD[adPos].ads; if (r[0].enddate != null && r[0].enddate.match(/:\d{2}$/) == null) r[0].enddate += ' 23:59:59'; if ((r[0].startdate != null && Date.parse(r[0].startdate.replace(/-/g, "/")) >= nowTime) || (r[0].enddate != null && Date.parse(r[0].enddate.replace(/-/g, "/")) <= nowTime)) { res.code = '2201'; } } res.ads = posads; } else { res.code = '2103'; res.ads = {}; } } } else { res.code = '2001'; res.ads = {}; } cb(res); } } } } } var playerize = function(obj) { return '
\
\ \ \ \ \ \ \ \ \ \ \
'; } if (typeof(RotatorAD) != 'function') { var RotatorAD = function(obj) { var date = new Date(); var id = 0; var max = 9999; var url = document.location.href; var cookiename = 'SinaRotAD'; var timeout = 1440; var num = obj.adnum; if (num == 0) num = 1; var ary = new Array(); if (typeof(globalRotatorId) == 'undefined' || globalRotatorId == null || isNaN(globalRotatorId)) { curId = G(cookiename); curId = curId == "" ? Math.floor(Math.random() * max) : ++curId; if (curId > max || curId == null || isNaN(curId)) curId = 0; S(cookiename, curId, timeout); globalRotatorId = curId; } id = globalRotatorId % num; var ad = { '0': obj.ads[id] }; return ad; function G(N) { var c = document.cookie.split("; "); for (var i = 0; i < c.length; i++) { var d = c[i].split("="); if (d[0] == N) return unescape(d[1]); } return ''; }; function S(N, V, Q) { var L = new Date(); var z = new Date(L.getTime() + Q * 60000); document.cookie = N + "=" + escape(V) + ";path=/;expires=" + z.toGMTString() + ";"; }; } }