2005-3-1/*
广告条处理脚本
编写人：shansong.shi
编写时间:2005.02.23
*/
	 var closeDate ;
	 ////closeDate='2005-03-02';
	 function initAd() {
//	　　 document.all.AdLayer.style.posTop = -200;//设置onLoad事件激发以后，广告层相对于固定后的y方向位置
　　	    if (!ifShowAd(closeDate)){
	        return;
		}
		showAd();//设置层为可见
    	resizeMove();
　　 }

	function resizeMove(){
		//alert(document.all.AdLeft.style.posTop);
		moveLayer('resize');
	}
　　 function scrollMove() {
	    moveLayer('scroll');
　　 }

	function moveLayer(eventType){
	    if (!ifShowAd(closeDate))
	    {
			return;
	    }
		var winScrollTop =  document.body.scrollTop;//滚动条滑块上部位置
		var winBottom = document.body.offsetHeight - document.body.offsetTop;
		//document.write("document.body.scrollTop:"+document.body.scrollTop);
	    var divWidth = eval(document.all.AdRight.scrollWidth);//
	    var divHeight = eval(document.all.AdRight.scrollHeight);//
		var x = document.body.offsetWidth-divWidth-20;//600;//浮动广告层固定于浏览器的x方向位置

		var y;
		var y=300;
		if (eventType=='resize')
		{//alert('resize...'+window.screen.height);//screen.height是一成不变的。
			y = document.body.offsetHeight-divHeight+document.body.scrollTop;
			//y = window.height+divHeight;
			//y = (document.body.scrollBottom-divHeight);
		}else if(eventType=='scroll'){
			//y = document.body.scrollBottom + y ;
			var diff = (document.body.scrollTop + y - document.all.AdRight.style.posTop)*.40;
			y = document.body.scrollTop + y - diff-100;
		}

	　　 //eval("document.all." + layerName + ".style.posTop = y");
    	document.all.AdLeft.style.posTop = y;
       	document.all.AdRight.style.posTop = y;
	　　 document.all.AdRight.style.posLeft = x;//移动广告层
    	//eval("document.all." + layerName + ".style.left = x");//移动广告层
	　　 if (document.all.AdLeft.style.visibility=='visible') {
			//setTimeout("MoveLayer("+winBottom+");", 20);//设置20毫秒后再调用函数MoveLayer()
		}

	}
	//隐藏广告条
	function hideAd(vLayer){
		if (vLayer==1)
		{
			document.all.AdLeft.style.visibility = 'hidden';
		}else if(vLayer==2){
			document.all.AdRight.style.visibility = 'hidden';
		}
	}

	//显示广告条
	function showAd(){
		document.all.AdLeft.style.visibility = 'visible';
		document.all.AdRight.style.visibility = 'visible';
	}
	//决定什么时候停止显示广告
    function ifShowAd(){
	//var closeDate = '2005-02-26';//格式要保证正确。
		var dt = new Date();
		var year = dt.getYear();
		var month = dt.getMonth();
		month++;
		var len = month.toString().length;
		if (len ==1) {
			month = '0'+month; 
		}
		var day = dt.getDate();
		var len = day.toString().length;
		if (len == 1) {
			day = '0'+day; 
		}
		var sDate = year+'-'+month+'-'+day;
		return  (sDate<=closeDate);
	}
	//设置广告关闭时间
	function setCloseDate(clsDate){
		closeDate = clsDate;
	}


		//显示浮动广告
	this.showFloatAd = function(sLeftUrl,sRightUrl,iTop,iWidth,iHeight){
		
		document.write('<div id=AdLeft style="position:absolute; width:'+iWidth+'px; height:'+iHeight+'px; z-index:20; visibility:hidden; left: 0px; top: '+iTop+'px"> ');
		document.write('<a href="javascript:hideAd(1);"><img src="http://image.psychcn.com/adv/duilian/2005/close.jpg" border="0" ></a>');
		//document.write('	<iframe scrolling="yes" name="content_frame_left" marginwidth=0 marginheight=0  src="'+sUrl+'" frameborder=0 style="position:absolute; width:'+iWidth+'px; height:'+iHeight+'px; z-index:20;  left: 0px; top: '+iTop+'px"> </iframe> ');
		
		document.write('	<iframe scrolling="no" name="content_frame_left" marginwidth=0 marginheight=0 width='+iWidth+'px height=100% src="'+sLeftUrl+'" frameborder=0></iframe> ');
		document.write('</div>');
		document.write('<div id=AdRight style="position:absolute; width:'+iWidth+'px; height:'+iHeight+'px; z-index:20; visibility:hidden; left: 600px; top: '+iTop+'px"> ');
		//document.write('<div id=AdRight style="position:absolute; width:113px; height:159px; z-index:20; visibility:hidden; left: 600px; top: 300px"> ');
		document.write('	<a href="javascript:hideAd(2);"><img src="http://image.psychcn.com/adv/duilian/2005/close.jpg" border="0" ></a>');
		document.write('	<iframe scrolling="no" name="content_frame_right" marginwidth=0 marginheight=0 width=100% height=100% src="'+sRightUrl+'" frameborder=0></iframe> ');
		document.write(' </div>');
	}
	//var vLeftAdUrl='http://image.psychcn.com/adv/ad-image/edu-20050201.gif';
	//var vLeftAdUrl='http://image.psychcn.com/adv/duilian/2005/adleft.gif';
	//var vRightAdUrl='http://image.psychcn.com/adv/duilian/2005/adRight.gif';
	var vLeftAdUrl='http://image.psychcn.com/adv/duilian/2005/adleft.htm';
	var vRightAdUrl='http://image.psychcn.com/adv/duilian/2005/adright.htm';

	setCloseDate('2005-06-25');
	//iTop,iWidth,iHeight
	showFloatAd(vLeftAdUrl,vRightAdUrl,500,113,312);