//-------------------------------------------------
// Name: getDocInnerWidth
// Purpose:  Get total document inner width (actual width of the document shown in the browser window, a.k.a viewport).
// Return value: nr of pixels for inner width
//-------------------------------------------------
function getDocInnerWidth(){
            var x = null;
            if(self.innerWidth){ //all except IE
                x = self.innerWidth;
            }else if(document.documentElement && document.documentElement.clientWidth){
                x = document.documentElement.clientWidth;
            }else if(document.body){ //IE quirksmode
                x = document.body.clientWidth;
            }
            return x;
}
//-------------------------------------------------
// Name: getDocInnerHeight
// Purpose:  Get total document inner height (actual height of the document shown in the browser window, a.k.a viewport).
// Return value: nr of pixels for inner height
//-------------------------------------------------
function getDocInnerHeight(){
            var y = null;
            if(self.innerHeight){ //all except IE
                y = self.innerHeight;
            }else if(document.documentElement && document.documentElement.clientHeight){
                y = document.documentElement.clientHeight;
            }else if(document.body){ //IE quirksmode
                y = document.body.clientHeight;
            }
            return y;
}
//-------------------------------------------------
// Name: getDocScrollTop
// Purpose:  Get scrolltop for document (how many pixels the user has scrolled down)
// Return value: nr of pixels scrolled vertically
//-------------------------------------------------
function getDocScrollTop(){
            var y = null;
            if(self.scrollTop){ //all except IE
                y = self.scrollTop;
            }else if(document.documentElement && document.documentElement.scrollTop){
                y = document.documentElement.scrollTop;
            }else if(document.body){ //IE quirksmode
                y = document.body.scrollTop;
            }
            return y;
}
//-------------------------------------------------
// Name: setDocScrollTop
// Purpose:  Set scrolltop for document (how many pixels the window should scroll down)
// Parameters:
//           y - number of pixels from the top of the screen to scroll down to
//-------------------------------------------------
function setDocScrollTop(y){
    if(window.scrollTo) {
      window.scrollTo(0, y);
    }
}
//-------------------------------------------------
// Name: getDocScrollLeft
// Purpose:  Get scrollleft for document (how many pixels the user has scrolled right)
// Return value: nr of pixels scrolled horizontally
//-------------------------------------------------
function getDocScrollLeft(){
            var x = null;
            if(self.scrollLeft){ //all except IE
                x = self.scrollLeft;
            }else if(document.documentElement && document.documentElement.scrollLeft){
                x = document.documentElement.scrollLeft;
            }else if(document.body){ //IE quirksmode
                x = document.body.scrollLeft;
            }
            return x;
}
//-------------------------------------------------
// Name: getDocScrollWidth
// Purpose:  Get scrollwidth for document
//(the total width of the document, even the area outside the viewport that isn't shown if scrollbars are present)
// Return value: width of the document (viewport + area outside it) in pixels
//-------------------------------------------------
function getDocScrollWidth(){
    var width = null;
    if(document.documentElement && document.documentElement.scrollWidth){
        width = document.documentElement.scrollWidth;
    }else if(document.body && document.body.scrollWidth){ //IE quirksmode
        width = document.body.scrollWidth;
    }
    return width;
}
//-------------------------------------------------
// Name: getDocScrollHeight
// Purpose:  Get scrollheight for document
//(the total height of the document, even the area outside the viewport that isn't shown if scrollbars are present)
// Return value: height of the document (viewport + area outside it) in pixels
//-------------------------------------------------
function getDocScrollHeight(){
    var height = null;
    if(document.documentElement && document.documentElement.scrollHeight){
        height = document.documentElement.scrollHeight;
    }else if(document.body && document.body.scrollHeight){ //IE quirksmode
        height = document.body.scrollHeight;
    }
    return height;
}

//-------------------------------------------------
// Name: getElemWidth
// Purpose:  Get an elements actual width, borders and padding included.
// Return value: elementwidth in pixels
//-------------------------------------------------
function getElemWidth(elem){
    //alert(elem.offsetWidth);
    if(elem.offsetWidth){
        return elem.offsetWidth;
    }
    return null;
}
//-------------------------------------------------
// Name: getElemHeight
// Purpose:  Get an elements actual height, borders and padding included.
// Return value: elementheight in pixels
//-------------------------------------------------
function getElemHeight(elem){
    if(elem.offsetHeight){
        return elem.offsetHeight;
    }

    return null;
}
//-------------------------------------------------
// Name: posElem
// Purpose:  Move a HTML-element to wanted position.
// Parameters:
//		elem - objectrepresentation of an HTML-element.
//		x - wanted horizontal position in pixels.
//		y - wanted vertical position in pixels.
// Return value: none
//-------------------------------------------------
function posElem(elem, x, y){
    //alert("posElemComplaint(elem, x, y):" + elem.id + "," + x + "," + y);
    try{
        if(elem && elem.style){
            elem.style.left = x + "px";
            elem.style.top = y + "px";
        }
    }catch(e){
        //Failed to position element.
        //alert("posElemComplaint, error:" + e);
    }
}
//-------------------------------------------------
// Name: findPos
// Purpose:  Get the coordinates (position) for element elem on page.
// Parameter: elem - objectrepresentation of an HTML-element.
// Return value: array with coordinates [x-coordinate,y-coordinate]
//-------------------------------------------------
function findPos(elem) {
    var curleft = curtop = 0;
    if (elem.offsetParent) {
        do {
            curleft += elem.offsetLeft;
            curtop += elem.offsetTop;
        } while (elem = elem.offsetParent);
        return [curleft,curtop];
    }
}
