function FloatingModule() {
    this.myie = document.all;
    this.right_edge = 0; //=this.myie&&!window.opera? isiebody().clientWidth-imagewidth: window.innerWidth-imagewidth;
    this.expandState = 0;


    this.ie = document.all ? 1 : 0;
    if (isIE9()) this.ie = 0;
    this.ns = document.layers ? 1 : 0;

    this.master = new Object("element");
    this.master.curLeft = this.right_edge;
    this.master.curTop = 10;
    this.master.gapLeft = 0;
    this.master.gapTop = 0;
    this.master.timer = null;
    this.isleft = 1;
    this.myController = "";
    this.myFormID = "";
}


FloatingModule.prototype.Init = function(moduleid, strWidth, imagewidth, isLeft, myfid, top, alwaysfloating, imgheight, strHeight, left) {
    this.isleft = isLeft;
    this.myController = "Floating" + moduleid;
    this.myFormID = myfid;
    this.imageWidth = imagewidth;
    this.imageHeight = imgheight;
    this.myie = document.all;
    this.alwaysfloating = alwaysfloating;
    //this.left=(this.isiebody().clientWidth- strWidth)/2;

    if (left != null && left > 0)
        this.left = left;
    else
        this.left = 0;

    this.expandState = 0;
    if (top != null && top > 0)
        this.top = top;
    else
        this.top = 0;

    this.strWidth = strWidth;
    this.strHeight = strHeight;

    this.lastClientHeight = this.isiebody().clientHeight;

    //this.right_edge=this.myie&&!window.opera? this.isiebody().clientWidth-imagewidth: window.innerWidth-imagewidth;

    this.right_edge = this.isiebody().clientWidth - imagewidth;

    if (this.alwaysfloating == 0) {

        if (this.isleft == 1) {
            this.strleft = 0;
            this.strhleft = -strWidth;
        } else if (this.isleft == 0) {
            this.strleft = this.right_edge - strWidth;
            this.strhleft = this.right_edge;
        } else if (this.isleft == 2) {
            this.top = 0;
            this.strleft = this.left;
            this.strhleft = this.left;

        } else {
            this.top = this.isiebody().clientHeight - imgheight;
            this.strleft = this.left;
            this.strhleft = this.left;
        }
    } else {

        if (this.isleft == 3)
            this.top = this.isiebody().clientHeight - strHeight - imgheight;
        else
            this.top = top; //this.isiebody().clientHeight-strHeight-imgheight;

        if (this.isleft != 0) {
            this.strleft = this.left;
            this.strhleft = this.left;
        } else //if(this.isleft==0)
        {
            this.strleft = this.right_edge - this.left - strWidth;
            this.strhleft = this.right_edge - this.left - strWidth;
        }

        if (this.isleft == 4) {
            this.strleft = this.left;
            this.strhleft = this.left;
            this.top = top;
        }

    }

    this.containerwidth = strWidth + imagewidth;
    document.getElementById(this.myFormID).style.left = this.strhleft + "px";

    document.getElementById(this.myFormID).style.top = this.top + "px";
    document.getElementById(this.myFormID).style.width = this.containerwidth + "px";

    if (document.compatMode && document.compatMode != "BackCompat" && !isIE6())
        document.getElementById(this.myFormID).style.position = "fixed";
    else
        document.getElementById(this.myFormID).style.position = "absolute";
    document.getElementById(this.myFormID).style.zIndex = "2147483647";

    this.ie = document.all ? 1 : 0;
    if (isIE9()) this.ie = 0;
    this.ns = document.layers ? 1 : 0;


    this.master = new Object("element");

    this.master.curLeft = this.strhleft;

    this.master.curTop = this.top;
    this.master.gapLeft = 0;
    this.master.gapTop = 0;
    this.master.timer = null;

    setInterval(this.myController + '.FixY()', 100);

    if (this.alwaysfloating == 0) {
        this.expandState = 0;
        this.setPace(this.myFormID, this.strhleft, this.top, 20);
    } else {
        this.expandState = 1;
        this.setPace(this.myFormID, this.strleft, this.top, 20);
    }
};
FloatingModule.prototype.moveAlong = function(layerName, paceLeft, paceTop, fromLeft, fromTop) {
    clearTimeout(this.master.timer);
    if (this.master.curLeft != fromLeft && this.isleft <= 1) {
        if ((Math.max(this.master.curLeft, fromLeft) - Math.min(this.master.curLeft, fromLeft)) < paceLeft) {
            this.master.curLeft = fromLeft;
        } else if (this.master.curLeft < fromLeft) {
            this.master.curLeft = this.master.curLeft + paceLeft;
        } else if (this.master.curLeft > fromLeft) {
            this.master.curLeft = this.master.curLeft - paceLeft;
        }
        if (this.ie) {
            document.getElementById(layerName).style.left = this.master.curLeft;
        } else {
            document.getElementById(layerName).style.left = this.master.curLeft + "px";
        }
    }

    if (document.compatMode && document.compatMode != "BackCompat" && !isIE6()) {

        if (this.isleft == 3) {
            if (this.expandState == 0)
                this.master.curTop = this.isiebody().clientHeight - this.imageHeight;
            else
                this.master.curTop = this.isiebody().clientHeight - this.imageHeight - this.strHeight;

            if (this.ie) {
                document.getElementById(layerName).style.top = this.master.curTop;
            } else {
                document.getElementById(layerName).style.top = this.master.curTop + "px";
            }
        }
    } else {
        if (this.isleft == 3 && this.lastClientHeight != this.isiebody().clientHeight) {
            clearTimeout(this.master.timer);
            this.lastClientHeight = this.isiebody().clientHeight;

            if (this.expandState == 0)
                this.master.curTop = this.isiebody().clientHeight - this.imageHeight;
            else
                this.master.curTop = this.isiebody().clientHeight - this.imageHeight - this.strHeight;

            if (this.ie) {
                document.getElementById(layerName).style.top = this.master.curTop;
            } else {
                document.getElementById(layerName).style.top = this.master.curTop + "px";
            }
            this.top = this.master.curTop;
            this.setPace(layerName, fromLeft, this.lastClientHeight - this.imageHeight, 20);
            return;
        } else if (this.master.curTop != fromTop) {
            if ((Math.max(this.master.curTop, fromTop) - Math.min(this.master.curTop, fromTop)) < paceTop) {
                this.master.curTop = fromTop;
            } else if (this.master.curTop < fromTop) {
                this.master.curTop = this.master.curTop + paceTop;
            } else if (this.master.curTop > fromTop) {
                this.master.curTop = this.master.curTop - paceTop;
            }
            if (this.ie) {
                document.getElementById(layerName).style.top = this.master.curTop;
            } else {
                document.getElementById(layerName).style.top = this.master.curTop + "px";
            }
        }
    }
    this.master.timer = setTimeout(this.myController + '.moveAlong("' + layerName + '",' + paceLeft + ',' + paceTop + ',' + fromLeft + ',' + fromTop + ')', 30);
};
FloatingModule.prototype.setPace = function(layerName, fromLeft, fromTop, motionSpeed) {
    this.master.gapLeft = (Math.max(this.master.curLeft, fromLeft) - Math.min(this.master.curLeft, fromLeft)) / motionSpeed;
    this.master.gapTop = (Math.max(this.master.curTop, fromTop) - Math.min(this.master.curTop, fromTop)) / motionSpeed;
    this.moveAlong(layerName, this.master.gapLeft, this.master.gapTop, fromLeft, fromTop);
};
FloatingModule.prototype.FixY = function() {


    this.right_edge = this.isiebody().clientWidth - this.imageWidth;
    if (this.isleft != 1 && this.strhleft != this.right_edge) {

        this.strhleft = this.right_edge;
        this.strleft = this.right_edge - this.strWidth;

        if (this.expandState == 0)
            this.setPace(this.myFormID, this.strhleft, this.isiebody().scrollTop + this.top, 20);
        else
            this.setPace(this.myFormID, this.strleft, this.isiebody().scrollTop + this.top, 20);

        return;
    }


    var lf;
    if (this.expandState == 0) {
        lf = this.strhleft;
    } else {
        lf = this.strleft;
    }


    if (Math.abs(this.master.curTop - this.isiebody().scrollTop - this.top) >= 1)
        this.setPace(this.myFormID, lf, this.isiebody().scrollTop + this.top, 20);

};
FloatingModule.prototype.isiebody = function() {
    return (document.compatMode && document.compatMode != "BackCompat") ? document.documentElement : document.body;
};
FloatingModule.prototype.expand = function() {


    var tp;
    if (document.body.scrollTop > 0)
        tp = document.body.scrollTop + this.top;
    else
        tp = document.documentElement.scrollTop + this.top;

    if (this.expandState == 0) {
        this.setPace(this.myFormID, this.strleft, tp, 20);
        this.expandState = 1;
    } else {
        this.setPace(this.myFormID, this.strhleft, tp, 20);
        this.expandState = 0;
    }
};
FloatingModule.prototype.expand3 = function() {

    //alert(this.expandState);
    if (this.expandState == 0) {

        this.master.curTop = this.isiebody().clientHeight - this.imageHeight - this.strHeight;
        this.expandState = 1;
    } else {
        this.master.curTop = this.isiebody().clientHeight - this.imageHeight;
        this.expandState = 0;
    }
    /*
    if (this.ie) {
        document.getElementById(this.myFormID).style.top = this.master.curTop;
    }
    else {
        document.getElementById(this.myFormID).style.top = this.master.curTop + "px";
    }*/
    //this.top = this.master.curTop;
    this.setPace(this.myFormID, this.strleft, this.master.curTop, 20);

};

function isIE6() {
    var browser = navigator.appName;
    var b_version = navigator.appVersion;
    var version = b_version.split(";");
    var trim_Version = "";
    if (version[1] != null) trim_Version = version[1].replace( /[ ]/g , "");
    //alert(trim_Version);
    if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE6.0")
        return true;
    else
        return false;
}

function isIE9() {
    var browser = navigator.appName;
    var b_version = navigator.appVersion;
    var version = b_version.split(";");
    var trim_Version = "";
    if (version[1] != null) trim_Version = version[1].replace( /[ ]/g , "");
    //alert(trim_Version);
    if (browser == "Microsoft Internet Explorer" && trim_Version == "MSIE9.0")
        return true;
    else
        return false;
}
