﻿function GetHeight()
{
    var height;
    if (typeof (window.innerWidth) == 'number')
    {
        height = window.innerHeight;
    }
    else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    {
        height = document.documentElement.clientHeight;
    }
    else if (document.body && (document.body.clientWidth || document.body.clientHeight))
    {
        height = document.body.clientHeight;
    }

    return height;
}

function GetScroll()
{
    var scroll = 0;
    if (typeof (window.pageYOffset) == 'number')
    {
        scroll = window.pageYOffset;
    } else if (document.body && (document.body.scrollLeft || document.body.scrollTop))
    {
        scroll = document.body.scrollTop;
    } else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
    {
        scroll = document.documentElement.scrollTop;
    }

    return scroll;
}

function Rand(from, to)
{
    return Math.floor(Math.random() * (to - from + 1) + from);
}


function getFirstChild(d)
{
    var firstChild = d.firstChild;

    while (firstChild != null && firstChild.nodeType == 3)
    { // skip TextNodes
        firstChild = firstChild.nextSibling;
    }

    return firstChild;
}

function getNexSibling(d)
{
    if (d == null)
        return null;
    var nextSibling = d.nextSibling;

    while (nextSibling != null && nextSibling.nodeType == 3)
    { // skip TextNodes
        nextSibling = nextSibling.nextSibling;
    }

    return nextSibling;
}

