function screenSize() {
    var w, h; // Объявляем переменные, w - длина, h - высота
    w = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
    h = (window.innerHeight ? window.innerHeight : (document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.offsetHeight));
    return {
        w:w,
        h:h
    };
}


function getScrollTop()
{
    var result = 0;

    if (document.documentElement.scrollTop)
        result = document.documentElement.scrollTop;

    if (document.body.scrollTop)
        result = document.body.scrollTop;

    return result;
}
/**
 * Функция для получения абсолютного смещения элемента относительно левого верхнего угла
 */
function absPosition(obj) {
    var x = y = 0;
    while(obj) {
        x += obj.offsetLeft;
        y += obj.offsetTop;
        obj = obj.offsetParent;
    }
    return {
        x:x,
        y:y
    };
}

function getUnsureElement (el)
{
    if ( typeof(el) == "string" )
        el = document.getElementById(el);
    return el;
}

function showOrHide (el, hide)
{
   el = getUnsureElement (el);
   if (hide)
       el.style.display = "none";
   else
       el.style.display = "";
}

function doOnLoad (funct, params)
{
    var onLoad = window.onload;
    window.onload = function () {if (onLoad != null) onLoad();funct(params);};
}

var floatTimer;
// float efect
function floatEffect (from, to, setHeghtFnc, scrollEnd)
{
    var ua = navigator.userAgent.toLowerCase();
    var multiplier = 20;
    // ie в 3 раза медленее
    if ( ua.indexOf( "msie" ) != -1 ) multiplier = multiplier/2.5;
    var hep = (to - from) / multiplier;
    //защита от зацикливания
    if (hep < 0.5 && hep > 0 ) hep = 0.5;
    if (hep < 0 && hep > -0.5 ) hep = -0.5;

    var halfTo = from + hep;
    setHeghtFnc(halfTo);// this.obj.style.top = halfTo + "px";
    if (hep > 0 && halfTo < to || hep < 0 && halfTo > to)
        floatTimer = setTimeout(function ()
        {
            floatEffect(halfTo, to, setHeghtFnc, scrollEnd);
        }, 20);
    else if (scrollEnd != null) scrollEnd();
}
// Insert newElement node after targetElement
function insertAfter(newElement,targetElement) {
    var parent = targetElement.parentNode;
    parent.insertBefore(newElement, targetElement.nextSibling);
}

function removeElement(id) {
  var element = document.getElementById(id);
  element.parentNode.removeChild(element);
}

