/*
RotatorAD V3.7 2009-5-14
Author: Dakular <shuhu@staff.sina.com.cn>
格式: new RotatorAD(商业广告数组, 非商业广告数组, 层id)
说明: 第一次访问随机出现，以后访问顺序轮播；自动过滤过期广告；cookie时间24小时；商业广告数量不足时，从非商业广告中补充
	  限制最少轮播数量，广告少于限制数时，才从垫底里补充，否则不补垫底
*/
if(typeof(RotatorAD)!='function'){
var RotatorAD = function(rad,nad,div_id){

var date = new Date();
var id = 0;
var max = 99;
var url = document.location.href;
var cookiename = 'SinaRot'+escape(url.substr(url.indexOf('/',7),2)+url.substring(url.lastIndexOf('/')));
var timeout = 1440; //24h
var w = rad.width;
var h = rad.height;
var num = rad.num;
var num2 = rad.num2;
var ary = new Array();
//过滤无效商广
for(var i=0; i<rad.length; i++){
	var start = strToDate(rad[i][2].replace('<startdate>','').replace('</startdate>',''));
	var end = strToDate(rad[i][3].replace('<enddate>','').replace('</enddate>',''),true);
	if(date>start && date<end){
		ary.push([rad[i][0], rad[i][1], rad[i][4], rad[i][5]?rad[i][5]:'0']);
	}
}
//过滤无效垫底
var vnad = new Array();
for(var i=0; i<nad.length; i++){
	if(nad[i][2]==null){
		vnad.push([nad[i][0], nad[i][1], '', '0']);
	}else{
		var start = strToDate(nad[i][2].replace('<startdate>','').replace('</startdate>',''));
		var end = strToDate(nad[i][3].replace('<enddate>','').replace('</enddate>',''),true);
		if(date>start && date<end){
			vnad.push([nad[i][0], nad[i][1], '', '0']);
		}
	}
}
//补位
var nn = 0;
if(vnad.length>0 && (num2==null || ary.length<num2)){
	for(var i=0; i<(num2==null?rad.num:num2); i++){
		if(i>ary.length-1){
			ary.push([vnad[nn][0], vnad[nn][1], '', '0']);
			if(++nn > nad.length-1) nn = 0;
		}
	}
}
num = ary.length<num?ary.length:num;
//排序(同步有序号的广告)
ary.sort(function(x,y){return x[3]-y[3];});
//取id
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+1;
//Show AD
if(id==0 || ary.length==0) return; //如果没有广告则不显示
if(id==-1) id=1; //当只有一个广告时：始终显示第一个
var n = id-1;
var type = ary[n][0].substring(ary[n][0].length-3).toLowerCase();
var od = document.getElementById(div_id);
if(type=='swf'){
	var of = new sinaFlash(ary[n][0], div_id+'_swf', w, h, "7", "", false, "High");
	of.addParam("wmode", "opaque");
	of.addParam("allowScriptAccess", "always");
	of.addVariable("adlink", escape(ary[n][1]));
	of.write(div_id);
	document.write('<iframe src="" style="display:none"></iframe>'); //for FF bug
}else if(type=='jpg' || type=='gif'){
	od.innerHTML = '<a href="'+ary[n][1]+'" target="_blank"><img src="'+ary[n][0]+'" border="0" width="'+w+'" height="'+h+'" /></a>';
	document.write('<iframe src="" style="display:none"></iframe>'); //for FF bug
}else if(type=='htm' || type=='tml'){
	od.innerHTML = '<iframe id="ifm_'+div_id+'" frameborder="0" scrolling="no" width="'+w+'" height="'+h+'"></iframe>';
	document.getElementById('ifm_'+div_id).src = ary[n][0];
}else if(type=='.js'){ //js
	document.write('<script language="javascript" type="text/javascript" src="'+ary[n][0]+'"></scr'+'ipt>');
	document.write('<iframe src="" style="display:none"></iframe>'); //for FF bug
}else{ //textlink
	document.write('<a href="'+ary[n][1]+'"  target="_blank">'+ary[n][0]+'</a>');
}
if(ary[n][2]!="" && ary[n][2]!=null){ //ad tracker
	var oImg = new Image();
	oImg.src = ary[n][2];
}
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()+";";
};
function strToDate(str,ext){
	var arys = new Array();
	arys = str.split('-');
	var newDate = new Date(arys[0],arys[1]-1,arys[2],9,0,0);
	if(ext){
		newDate = new Date(newDate.getTime()+1000*60*60*24);
	}
	return newDate;
}

}
}

/*********************************/

/*
轮播背投类 RotatorPB v3.1
Update by Dakular <shuhu@staff.sina.com.cn> 2008-8-25
格式：new RotatorPB(广告数组)
说明：第一次访问随机出现，以后访问顺序轮播；自动过滤过期广告；cookie时间24小时；商业广告数量不足时不显示
*/
if(typeof(RotatorPB)!='function'){
	var RotatorPB=function (rad){
		this.ary = new Array();
		this.date = new Date();
		this.w = rad.width;
		this.h = rad.height;
		this.num = rad.num;
		this.o = rad.length;
		this.id = RotatorPB.id++;
		this.m = 'rpb_'+this.id;
		this.n = new Array();
		this.L = new Date();
		this.e = 0;
		var f;
		var D = false;
		var nn = 0;
		//过滤无效广告
		for(var i=0; i<rad.length; i++){
			var start = RotatorPB.strToDate(rad[i][2].replace('<startdate>','').replace('</startdate>',''));
			var end = RotatorPB.strToDate(rad[i][3].replace('<enddate>','').replace('</enddate>',''),true);
			if(this.date>start && this.date<end && (this.num==null || this.ary.length<this.num) ){
				this.ary.push([rad[i][0], rad[i][1], rad[i][4]]);
			}
		}
		this.o = this.ary.length;
		//取id
		for(var i=0;i<this.o;i++){
			f=this.m+'_'+(i+1);
			g=RotatorPB.G(f);
			if(g!=''){
				this.n[i]=g;
				D=true;
			}else {
				this.n[i]=0;
			}
		}
		if(!D){
			var r=Math.ceil(Math.random()*this.o);
			var t=this.m+'_'+r;
			RotatorPB.S(t,this.L.getTime(),1440);
			this.e=r;
			if(this.o==1){RotatorPB.S('s_dl',r,1440);}
			//return r;
		}else {
			var R=this.n.join(',').split(',');
			var k=R.sort();
			var max=Number(k[k.length-1]);
			var min=Number(k[0]);
			var F;
			for(var i=0;i<this.n.length;i++){
				if(max==this.n[i]){
					F=i+1;
					break;
				}
			}
			if(typeof(F)!='undefined'){
				G=this.m+'_'+F;
				H=Number(RotatorPB.G(G));
				I=F%this.o+1;
				J=this.m+'_'+I;
				RotatorPB.S(J,this.L.getTime(),1440);
				if(this.o==1){
					I=-RotatorPB.G('s_dl');
					if(I==0){I=1;RotatorPB.S('s_dl',1,1440);}
					RotatorPB.S('s_dl',I,1440);
				}
				this.e=I;
				//return I;
			}
		}
		//Show AD
		if(this.e==0 || this.ary.length==0) return; //如果没有广告则不显示
		if(this.e==-1) return; //当只有一个广告时：始终显示第一个/奇数次刷新显示
		var n = this.e-1;
		var btsrc = this.ary[n][0];
		var bturl = this.ary[n][1];
		var bttype = btsrc.substring(btsrc.length-3).toLowerCase();
		if(bttype=='.js'){ //js
			document.write('<script language="javascript" type="text/javascript" src="'+btsrc+'"></scr'+'ipt>'); return;
		}else if(bttype!='htm' && bttype!='tml'){
			sinabturl = "http://d1.sina.com.cn/d1images/pb/pbv4.html?"+bturl+"${}"+bttype+"${}"+btsrc;
		}else{
			sinabturl = btsrc;
		}
		try{
			aryADSeq.push("openWindowBack()");
		}catch(e){
			openWindowBack();
		}
		if(this.ary[n][2]!=""){ //监测计数
			var oImg = new Image();
			oImg.src = this.ary[n][2];
		}
	};
	RotatorPB.id=1;
	RotatorPB.G=function (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 '';
	};
	RotatorPB.S=function (N,V,Q){
		var L=new Date();
		var z=new Date(L.getTime()+Q*60000);
		document.cookie=N+"="+escape(V)+"; path=/; expires="+z.toGMTString()+";";
	};
	RotatorPB.strToDate = function(str,ext){
		var arys = new Array();
		arys = str.split('-');
		var newDate = new Date(arys[0],arys[1]-1,arys[2],9,0,0);
		if(ext){
			newDate = new Date(newDate.getTime()+1000*60*60*24);
		}
		return newDate;
	}
	var openWindowBack = function(){
		var popUpWin2 = open(sinabturl, (window.name!="popUpWin2")?"popUpWin2":"", "width=1,height=1,top=4000,left=3000");
	}
};

/*********************************/

/*赞助生成工具*/
try{if(typeof(SinaDotColumnBarCreativeClass)!="function"){var SinaDotColumnBarCreativeClass=function(o){if(typeof(o)!="undefined"&&o!=""){var pthis=this;this.$=function(id){if(document.getElementById){return eval('document.getElementById("'+id+'")')}else{return eval("document.all."+id)}};this.initWrap=function(mod,id,v,w,h,po,l,r,t,b,z,m,p,bg,dsp){var lst="";if(mod==1){lst+="var "+v+' = document.createElement("'+id+'");'}else{if(mod==2){lst+="var "+v+' = document.getElementById("'+id+'");'}else{return}}if(v!=""){lst+=v+'.id = "'+v+'";'}if(w!=""){lst+=v+".style.width = "+w+' + "px";'}if(h!=""){lst+=v+".style.height = "+h+' + "px";'}if(po!=""){lst+=v+'.style.position = "'+po+'";';if(l!=""){lst+=v+".style.left = "+l+' + "px";'}else{if(l==""||r!=""){lst+=v+".style.right = "+r+' + "px";'}}if(t!=""){lst+=v+".style.top = "+t+' + "px";'}else{if(t==""||b!=""){lst+=v+".style.bottom = "+b+' + "px";'}}if(z!=""){lst+=v+'.style.zIndex = "'+z+'";'}}if(bg!=""){lst+=v+'.style.background = "'+bg+'";'}if(m!=""){lst+=v+'.style.margin = "'+m+'";'}if(p!=""){lst+=v+'.style.padding = "'+p+'";'}if(dsp!=""){lst+=v+'.style.display = "'+dsp+'";'}return lst};this.initObj=function(id,s,u,w,h){var lst=s.substring(s.length-3).toLowerCase();switch(lst){case"tml":case"htm":var to=document.createElement("iframe");to.id=id;to.style.width=w+"px";to.style.height=h+"px";to.src=s;to.frameBorder=0;to.scrolling="no";to.marginheight=0;to.marginwidth=0;break;case"swf":var to=document.createElement("div");var fo=new sinaFlash(s,id,w,h,"7","",false,"High");fo.addParam("wmode","transparent");fo.addParam("allowScriptAccess","always");fo.addParam("menu","false");fo.write(to);break;case"jpg":case"gif":case"png":if(u!=""){var to=document.createElement("a");to.href=u;to.target="_blank";var io=new Image();io.id=id;io.style.width=w+"px";io.style.height=h+"px";io.style.border="none";io.src=s;to.appendChild(io)}else{var to=new Image();to.id=id;to.style.width=w+"px";to.style.height=h+"px";to.style.border="none";to.style.cursor="pointer";to.src=s}break;default:var to=document.createElement("a");to.id=id;to.href=u;to.target="_blank";to.innerText=s}return to};this.getAdCookie=function(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""};this.setAdCookie=function(N,V,Q){var L=new Date();var z=new Date(L.getTime()+Q*60000);document.cookie=N+"="+escape(V)+";path=/;expires="+z.toGMTString()+";"};this.addEvent=function(obj,event,func){var MSIE=navigator.userAgent.indexOf("MSIE");var OPER=navigator.userAgent.indexOf("Opera");if(document.all&&MSIE!=-1&&OPER==-1){obj.attachEvent("on"+event,func)}else{obj.addEventListener(event,func,false)}};var btimer;var showTag=false;var bo=pthis.$("SinaDotColumnBarCreativeTmpWrap_"+o.id);bo=bo.parentNode;bo.style.position="relative";eval(pthis.initWrap(1,"div","b_"+o.id,o.b.w,o.b.h,"absolute",o.b.p[0],o.b.p[1],o.b.p[2],o.b.p[3],o.b.z,0,0,"","block"));eval("pthis.bWrap = b_"+o.id+"");var bObj=pthis.initObj("bo_"+o.id,o.b.s,o.b.u,o.b.w,o.b.h);pthis.bWrap.appendChild(bObj);bo.appendChild(pthis.bWrap);pthis.eWrap=document.createElement("div");pthis.eWrap.innerHTML="";pthis.showE=function(){var apthis=pthis;clearTimeout(btimer);apthis.eWrap.innerHTML="";if(o.e.s!=""){eval(pthis.initWrap(1,"div","e_"+o.id,o.e.w,o.e.h,"absolute",o.e.p[0],o.e.p[1],o.e.p[2],o.e.p[3],o.e.z,0,0,"","none"));eval("apthis.eWrap = e_"+o.id+"");var eObj=pthis.initObj("eo_"+o.id,o.e.s,o.e.u,o.e.w,o.e.h);apthis.eWrap.appendChild(eObj);bo.appendChild(apthis.eWrap);apthis.eWrap.style.display="block";if(o.c.w!=""||o.c.h!=""){eval(pthis.initWrap(1,"div","c_"+o.id,o.c.w,o.c.h,"absolute",o.c.p[0],o.c.p[1],o.c.p[2],o.c.p[3],o.c.z,0,0,o.c.b,"block"));eval("apthis.cWrap = c_"+o.id+"");apthis.cWrap.onclick=function(){apthis.eWrap.style.display="none";showTag=false};apthis.cWrap.style.background=(o.c.b=="")?"url(http://d1.sina.com.cn/shh/SinaDotColumnBarCreativeTool/spc.gif) repeat":o.c.b;apthis.cWrap.innerHTML=o.c.inn;apthis.cWrap.style.textAlign="center";apthis.cWrap.style.overFlow="hidden";apthis.cWrap.style.cursor="pointer";apthis.cWrap.style.color=o.c.c;apthis.eWrap.appendChild(apthis.cWrap)}if(o.e.t!=""){btimer=setTimeout(function(){apthis.eWrap.style.display="none";showTag=false},o.e.t)}if(o.e.tr!=""){var tro=new Image();tro.src=o.e.tr+"&"+Math.random()}if(o.o.ahd){apthis.eWrap.onmouseover=function(){apthis.eWrap.style.display="block"};pthis.bWrap.onmouseout=function(){apthis.eWrap.style.display="none";showTag=false};apthis.eWrap.onmouseout=function(){apthis.eWrap.style.display="none";showTag=false}}}};var currTimes=1;var clcExt=typeof(o.o.cle)=="undefined"?0:o.o.cle;pthis.bWrap.onmouseover=function(){if(!showTag){showTag=true;if(clcExt==0){var tmpeip=true;try{if(typeof(o.o.eip)!="undefined"&&typeof(o.o.eti)!="undefined"){if(o.o.eip!=""&&!isNaN(o.o.eip)){var tmpeti=(o.o.eti=="")?1440:eval(o.o.eti*60);var cepcookie=pthis.getAdCookie("ceCookie"+o.id);cepcookie=(cepcookie==""||cepcookie=="undefined")?0:cepcookie;cepcookie++;pthis.setAdCookie("ceCookie"+o.id,cepcookie,tmpeti);if(cepcookie>o.o.eip){tmpeip=false}}}}catch(e){}if(tmpeip){if(o.o.enm!=""&&!isNaN(o.o.enm)){if(currTimes<=o.o.enm){pthis.showE();++currTimes}}else{pthis.showE()}}}}};pthis.bWrap.onclick=function(){if(clcExt==1){var tmpeip=true;try{if(typeof(o.o.eip)!="undefined"&&typeof(o.o.eti)!="undefined"){if(o.o.eip!=""&&!isNaN(o.o.eip)){var tmpeti=(o.o.eti=="")?1440:eval(o.o.eti*60);var cepcookie=pthis.getAdCookie("ceCookie"+o.id);cepcookie=(cepcookie==""||cepcookie=="undefined")?0:cepcookie;cepcookie++;pthis.setAdCookie("ceCookie"+o.id,cepcookie,tmpeti);if(cepcookie>o.o.eip){tmpeip=false}}}}catch(e){}if(tmpeip){if(o.o.enm!=""&&!isNaN(o.o.enm)){if(currTimes<=o.o.enm){pthis.showE();++currTimes}}else{pthis.showE()}}}};if(o.o.anm!=""&&!isNaN(o.o.anm)){var cbpcookie=pthis.getAdCookie("cbCookie"+o.id);cbpcookie=(cbpcookie==""||cbpcookie=="undefined")?1:cbpcookie;setTimeout(function(){if(cbpcookie<=o.o.anm){pthis.showE();++cbpcookie;pthis.setAdCookie("cbCookie"+o.id,cbpcookie,1440)}},o.o.adl)}else{if(o.o.anm=="auto"&&isNaN(o.o.anm)){setTimeout(function(){pthis.showE()},o.o.adl)}else{}}}}}}catch(e){};