﻿// 对联广告脚本
//程序：马骏
//日期：2007-1-15

//对联广告申明
//程序：马骏
//日期：2007-1-15
CoupletTop = 120;
CoupletWidth = 120;
CoupletHeight = 250;
CoupletLeftCode = "";
CoupletRightCode = "";

lastScrollY=0;

//设置对联参数
//程序：马骏
//日期：2007-1-15
function SetCoupletParams(CTop,CWidth,CHeight,LeftCode,RightCode)
{
    CoupletTop = CTop;
    CoupletWidth = CWidth;
    CoupletHeight = CHeight;
    CoupletLeftCode = LeftCode;
    CoupletRightCode = RightCode;
}

//每次滚动的时候都改变当前广告条位置
function OnScrollSetNewPosition()
{ 
    //获取相对位置
    var diffY;
    if (document.documentElement && document.documentElement.scrollTop)
        diffY = document.documentElement.scrollTop;
    else if (document.body)
        diffY = document.body.scrollTop;
    else
        {/*Netscape stuff*/}
 
    //计算相对位置
    percent=.1*(diffY-lastScrollY); 
    
    if(percent>0)
    {
        percent=Math.ceil(percent); 
    }
    else 
        percent=Math.floor(percent); 
    
    //根据相对位置修改对联的位置
    document.getElementById("AirfeelingCoupletLeft").style.top=parseInt(document.getElementById
    ("AirfeelingCoupletLeft").style.top)+percent+"px";
    document.getElementById("AirfeelingCoupletRight").style.top=parseInt(document.getElementById
    ("AirfeelingCoupletRight").style.top)+percent+"px";
    
    //保存当前为位置
    lastScrollY=lastScrollY+percent;     
}

//显示对联
//程序：马骏
//日期：2007-1-15
function ShowCouplet()
{
    AirfeelingCoupletLeft="<DIV id=\"AirfeelingCoupletLeft\" style='left:2px;background-color:#e5e5e5;POSITION:absolute;TOP:" + CoupletTop + "px;width:" + CoupletWidth + "px;height:" + CoupletHeight + "px'>" + CoupletLeftCode + "</div>";
    AirfeelingCoupletRight="<DIV id=\"AirfeelingCoupletRight\" style='right:2px;background-color:#e5e5e5;POSITION:absolute;TOP:"+ CoupletTop + "px;width:" + CoupletWidth + "px;height:" + CoupletHeight + "px;'>" + CoupletRightCode + "</div>";
    
    //输出内容
    document.write(AirfeelingCoupletLeft); 
    document.write(AirfeelingCoupletRight); 
    
    window.setInterval("OnScrollSetNewPosition()",1);
}

