/*--------------------------------------------------|
| img-float 1.0.5   http://www.bluestar-cn.com      |
|---------------------------------------------------|
| Copyright (c) 2002-2006                           |
|                                                   |
| Author : wuyang                                   |
|                                                   |
| Updated: 2005.12.10                               |
|--------------------------------------------------*/
///////////////////////////////////////////////////
//窗口左右滚动图片
//
//调用方法：
//var img = new ImgFloat("IMG");
//img.SetLeftImg("images/cddjd2.gif","","5","130");//图片位置、链接地图、默认left位置，top位置
//img.SetRightImg("images/cddjd2.gif","","5","130");//图片位置、链接地图、默认right位置，top位置
//img.run();
//
//参数说明：
//var img = new ImgFloat("IMG");//可以是两种图片方式，值只能是IMG,SWF
////////////////////////////////////////////////

var lastScrollX = 0,lastScrollY = 0;

document.ns = navigator.appName == "Microsoft Internet Explorer"
function CloseDivLeft() {
    couplet_left.style.display = 'none';
}
function CloseDivRight() {
    couplet_right.style.display = 'none';
}

function startAD() {
    var diffY = document.body.scrollTop,diffX = document.body.scrollLeft;
    if (diffY != lastScrollY) {
        percent = .1 * (diffY - lastScrollY);
        if (percent > 0) percent = Math.ceil(percent);
        else percent = Math.floor(percent);
        couplet_left.style.pixelTop += percent;
        couplet_right.style.pixelTop += percent;
        lastScrollY = lastScrollY + percent;
    }
    if (diffX != lastScrollX) {
        percent = .1 * (diffX - lastScrollX);
        if (percent > 0) percent = Math.ceil(percent);
        else percent = Math.floor(percent);
        couplet_left.style.pixelTop += percent;
        couplet_right.style.pixelTop += percent;
        lastScrollX = lastScrollX + percent;
    }
    setTimeout(startAD, 4);
}


function doCouplet() {
    if (document.ns) {
		try{
        couplet_left.style.visibility = 'visible';
        couplet_right.style.visibility = 'visible';
        startAD();
		}catch(err){}
    }
}

/////////////////////////////
function ImgFloat(imgtype) {
    this.ImgType = imgtype == "SWF"?"SWF":"IMG";
    this.ImgWidth = 50;
    this.ImgHeight = 150;
}

function ImgFloat(imgtype, width, height) {
    this.ImgType = imgtype == "SWF"?"SWF":"IMG";
    this.ImgWidth = width;
    this.ImgHeight = height;
}

ImgFloat.prototype.SetLeftImg = function(ImgSrc, ImgLink, ImgLeft, ImgTop) {
    if (ImgSrc.indexOf(".swf") > -1 || ImgSrc.indexOf(".SWF") > -1) {
        document.write('<DIV id=couplet_left style="Z-INDEX: 1; VISIBILITY: hidden; POSITION: absolute;top:' + ImgTop + ';left:' + ImgLeft + '"><EMBED id=sinadl  pluginspage=http://www.macromedia.com/go/getflashplayer src=' + ImgSrc + ' type=application/x-shockwave-flash wmode="opaque" quality="high" width=' + this.ImgWidth + ' height=' + this.ImgHeight + '></EMBED><br><center><a href=# onclick="CloseDivLeft()" style="font-size:12px">关闭</a></center></DIV>');
    } else {
        document.write('<DIV id=couplet_left style="Z-INDEX: 1; VISIBILITY: hidden; POSITION: absolute;top:' + ImgTop + ';left:' + ImgLeft + '"><a href="' + ImgLink + '" target=_blank><img src="' + ImgSrc + '" border=0 width=' + this.ImgWidth + ' height=' + this.ImgHeight + '></a><br><center><a href="#" onclick="CloseDivLeft()" style="font-size:12px">关闭</a></center></DIV>');
    }
}

ImgFloat.prototype.SetRightImg = function(ImgSrc, ImgLink, ImgRight, ImgTop) {
    var top1 = ImgTop == ""?"130":ImgTop;
    if (ImgSrc.indexOf(".swf") > -1 || ImgSrc.indexOf(".SWF") > -1) {
        document.write('<DIV id=couplet_right style="Z-INDEX: 1; VISIBILITY: hidden; POSITION: absolute;top:' + ImgTop + ';right:' + ImgRight + '""><EMBED id=sinadl  pluginspage=http://www.macromedia.com/go/getflashplayer src=' + ImgSrc + '  width=' + this.ImgWidth + ' height=' + this.ImgHeight + ' type=application/x-shockwave-flash wmode="opaque" quality="high"></EMBED><br><center><a href=# onclick="CloseDivRight()" style="font-size:12px">关闭</a></center></DIV>');
    } else {
        document.write('<DIV id=couplet_right style="Z-INDEX: 1; VISIBILITY: hidden; POSITION: absolute ;top:' + ImgTop + ';right:' + ImgRight + '"><a href="' + ImgLink + '" target=_blank><img src="' + ImgSrc + '" border=0 width=' + this.ImgWidth + ' height=' + this.ImgHeight + '></a><br><center><a href=# onclick="CloseDivRight()" style="font-size:12px">关闭</a></center></DIV>');
    }
}

ImgFloat.prototype.run = function() {
    //开始控制flash关闭钮
    document.write('<SCRIPT language=JavaScript event=FSCommand() for=sinadl>');
    document.write('couplet_left.style.visibility="hidden";');
    document.write('couplet_right.style.visibility="hidden";');
    document.write('</SCRIPT>');
    //结束控制flash关闭钮
    doCouplet();
}

