var floatDivs = new Array();
var floatDivTops=new Array();

var currentModule=0;
function startFloat(){

    for (i = 0; i < floatDivs.length; i += 1) {
        initFloat(floatDivs[i],i);
    }
}

//function closeFloat(id){
//	document.getElementById(id).style.visibility="hidden";
//}

function addFloat(id){

    floatDivs.push(id);
	floatDivTops.push(document.getElementById(id).style.top);
	initFloat(id,currentModule);
	currentModule+=1;
}

function initFloat(id,i){

    var s = document.getElementById(id);
	s.style.position="absolute";
    s.style.top = parseInt(floatDivTops[i]) + getScroll("getTop");
//    var closeBtn="<div style=\"background-color:#4499ee;background-image:url(../userfiles/image/float_close.gif);position:absolute;width:45px;height:9px\" onclick=\"closeFloat('"+id+"')\"></div>";
//    s.innerHTML=s.innerHTML+closeBtn;
}

/** 
 * type:
 * getTop
 * getLeft
 * getWidth
 * getHeight
 **/
function getScroll(type){
    var t, l, w, h;
    
    if (document.documentElement && document.documentElement.scrollTop) {
        t = document.documentElement.scrollTop;
        l = document.documentElement.scrollLeft;
        w = document.documentElement.scrollWidth;
        h = document.documentElement.scrollHeight;
    }
    else 
        if (document.body) {
            t = document.body.scrollTop;
            l = document.body.scrollLeft;
            w = document.body.scrollWidth;
            h = document.body.scrollHeight;
        }
    
    if (type == "getTop") {
        return t;
    }
    else 
        if (type == "getLeft") {
            return l;
        }
        else 
            if (type == "getWidth") {
                return w;
            }
            else 
                if (type == "getHeight") {
                    return h;
                }
                else {
                    return -1;
                }
}

window.onscroll = startFloat;
