function in_array(item,arr) 
{
        for(p=0;p<arr.length;p++) 
        {
                if (item == arr[p]) return true;
        }
        return false;
}

function placeFooter()
{         
        // elementID, height, yPos
        
        
        var win = window;
        if (typeof win.innerWidth != "undefined")
        {
                var innerHeight = win.innerHeight;
        }
        else
        {
                var obj = getBody(win);
                var innerHeight = parseInt(obj.clientHeight);
        }
        
        var args = placeFooter.arguments;
        var bottomElements = new Array();
        var yPos = new Array();

        var j=0;
        var minYPosBottomElements = parseInt(args[2]);
        var maxElementHeight = 0;

        for(i=0;i<(args.length-2);i+=3)
        {
                
                bottomElements[j] = args[i];      
                yPos[j] = parseInt(args[i+2]);  
                if (parseInt(args[i+2]) < minYPosBottomElements)
                {
                        minYPosBottomElements = parseInt(args[i+2]);
                } 
                if (parseInt(args[i+1]) > maxElementHeight)
                {
                        maxElementHeight = parseInt(args[i+1]);
                } 
                j++;
        }
        
        var lowestElement = 0;
        var divArray = document.getElementsByTagName("div");

        for (i=0; i<divArray.length; i++)
        {
                if (!in_array(divArray[i].id, bottomElements))
                {
                        
                        var bottomPosition = parseInt(divArray[i].style.top) + parseInt(divArray[i].offsetHeight);

                        if (bottomPosition > lowestElement)
                        {
                                lowestElement = bottomPosition;  
                        }
                }
        }

        //lowestElement = lowestElement + 20;
        var footerPositionTop = innerHeight - maxElementHeight;
        
        if (minYPosBottomElements > footerPositionTop)
        {
                footerPositionTop = minYPosBottomElements;
        }
        
        if (lowestElement > footerPositionTop)
        {
                footerPositionTop = lowestElement;
        }
        
        for (i=0; i<bottomElements.length; i++)
        {
                
                var newElementPos = footerPositionTop + yPos[i] - minYPosBottomElements;

                document.getElementById(bottomElements[i]).style.top = newElementPos+"px";
                document.getElementById(bottomElements[i]).style.visibility = "visible";  
        }
}

function getBody(w)
{
        return (w.document.compatMode && w.document.compatMode == "CSS1Compat") ? w.document.documentElement : w.document.body || null;
}