/*--------------------------------------------------|
| img-float 1.0.5   http://www.huisi-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 vlastScrollX = 0,vlastScrollY = 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 vdiffY = document.body.scrollTop,vdiffX = document.body.scrollLeft;
    if (vdiffY != vlastScrollY) {
        vpercent = .1 * (vdiffY - vlastScrollY);
        if (vpercent > 0) vpercent = Math.ceil(vpercent);
        else vpercent = Math.floor(vpercent);
        if(document.all("couplet_left"))couplet_left.style.pixelTop += vpercent;
        if(document.all("couplet_right"))couplet_right.style.pixelTop += vpercent;
        vlastScrollY = vlastScrollY + vpercent;
    }
    if (vdiffX != vlastScrollX) {
        vpercent = .1 * (vdiffX - vlastScrollX);
        if (vpercent > 0) vpercent = Math.ceil(vpercent);
        else vpercent = Math.floor(vpercent);
        if(document.all("couplet_left"))couplet_left.style.pixelTop += vpercent;
        if(document.all("couplet_right"))couplet_right.style.pixelTop += vpercent;
        vlastScrollX = vlastScrollX + vpercent;
    }
    setTimeout(startAD, 4);
}


function doCouplet() {
    if (document.ns) {
		try{
        if(document.all("couplet_left"))couplet_left.style.visibility = 'visible';
        if(document.all("couplet_right"))couplet_right.style.visibility = 'visible';
        startAD();
		}catch(err){alert(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 ></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 ></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>');
    if(document.all("couplet_left"))document.write('couplet_left.style.visibility="hidden";');
    if(document.all("couplet_right"))document.write('couplet_right.style.visibility="hidden";');
    document.write('</SCRIPT>');
    //结束控制flash关闭钮
    doCouplet();
}


