﻿/***************************************************************
* Scrolling                                                    *
* -----------                                                  *
* Version 0.1 (initial version)                                *
* Copyright (c) 2009 AssureInfotech                            *
* Website: http://www.assureinfotech.com/                      *
* E-Mail: assureindia@hotmail.com                              *
* Developer: Nimesh Patel                                       *
***************************************************************/ 

function AssureScrolling(strEleID) {
    elem = document.getElementById(strEleID);
    if (elem == null)
        return;
    //var left = parseInt(elem.offsetWidth / 2);

    var intH = 0, intW = 0;
    if (self.innerHeight) {
        intH = window.innerHeight;
        intW = window.innerWidth;
    }
    else {
        if (document.documentElement && document.documentElement.clientHeight) {
            intH = document.documentElement.clientHeight;
            intW = document.documentElement.clientWidth;
        }
        else {
            if (document.body) {
                intH = document.body.clientHeight;
                intW = document.body.clientWidth;
            }
        }
    }

    //var top = parseInt(elem.offsetHeight / 2);
    if (intH < elem.offsetHeight)
        return;
    var top = (intH == 0) ? 50 : parseInt((intH - elem.offsetHeight) / 2, 10);
    //elem.style.left = left + 'px';
    var scrOfX = 0, scrOfY = 0;
    if (typeof (window.pageYOffset) == 'number') {
        //Netscape compliant
        scrOfY = window.pageYOffset;
        scrOfX = window.pageXOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop)) {
        //DOM compliant
        scrOfY = document.body.scrollTop;
        scrOfX = document.body.scrollLeft;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
        //IE6 standards compliant mode
        scrOfY = document.documentElement.scrollTop;
        scrOfX = document.documentElement.scrollLeft;
    }
    elem.style.top = top + scrOfY + 'px';
}

//window.scrollTo(0, 0);
