
function GoToURL(sender) {
    if (sender.value)
        document.location = sender.value;
}
function GetFavorite() {
    window.open('/handlers/favorite.ashx?title=' + escape(document.title) + '&path=' + escape(location.href), '', '');
}
function SetCookie(name, value, expires) {
    //alert(value);
    var dt = new Date();
    var dtt = "";
    dt.setTime(dt.getTime() + expires * 24 * 60 * 60 * 1000);
    dtt = dt.toGMTString();
    document.cookie = name + "=" + value + ";expires=" + dtt + ";path=/";
}
function getCookie(name) {
    var prefix = name + "=";
    var cookieStartIndex = document.cookie.indexOf(prefix);
    if (cookieStartIndex == -1)
        return null;
    var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length);
    if (cookieEndIndex == -1)
        cookieEndIndex = document.cookie.length;
    return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex));
}
function deleteCookie(name) {
    if (getCookie(name)) {
        document.cookie = name + "=" + "; expires=Thu, 01-Jan-70 00:00:01 GMT;path=/";
    }
}

function Expand_Or_CollapseDiv(sender, divForExpandID, lnkForExpandTextID, hideText, openText) {
    var divForExpand = document.getElementById(divForExpandID);
    var lnkForExpandText = document.getElementById(lnkForExpandTextID);

    if (divForExpand.style.display == 'none') {
        divForExpand.style.display = "block";
        divForExpand.style.visibility = "visible";
        if (lnkForExpandTextID) {
            lnkForExpandText.innerHTML = hideText;
            lnkForExpandText.style.backgroundImage = "url(/i/minus_blue.gif)";
        }
    }
    else {
        divForExpand.style.display = "none";
        divForExpand.style.visibility = "hidden";
        if (lnkForExpandTextID) {
            lnkForExpandText.innerHTML = openText;
            lnkForExpandText.style.backgroundImage = "url(/i/plus_blue.gif)";
        }
    }
}

function Show_News_TabSheet(sender, NameForShow, NameForHide, tagNameForClassChange) {
    var divForShow = document.getElementById("div" + NameForShow);
    var tagForShow = document.getElementById(tagNameForClassChange + NameForShow);
    var class_name = sender.className.replace("active", "");
    if (class_name == tagNameForClassChange)
        class_name = "";
    if (divForShow) {
        if (NameForHide) {
            var divForHide = document.getElementById("div" + NameForHide);
            var tagForHide = document.getElementById(tagNameForClassChange + NameForHide);
            divForHide.style.display = "none";
            divForShow.style.visibility = "hidden";
            tagForHide.className = class_name;
        }
        if (divForShow.style.display == "none") {
            divForShow.style.display = "block";
            divForShow.style.visibility = "visible";
            tagForShow.className = class_name + "active";
        }
        else {
            divForShow.style.display = "none";
            divForShow.style.visibility = "hidden";
            tagForShow.className = class_name;
        }
    }
}

function Expand_Or_CollapseTabSheet(sender, otherSenderIDForHide, IDForShow, IDForHide, sndr_css_active, sndr_css_inactive, trgt_css_active, trgt_css_inactive,
    divAdditID, addit_css_inactive, addit_css_active) {
    var divForExpand = document.getElementById(IDForShow);
    var divForClose = document.getElementById(IDForHide);
    var divAddit = document.getElementById(divAdditID);
    if (divForExpand.style.display == 'none') {
        divForExpand.style.display = "block";
        divForExpand.className = trgt_css_active;
        if (sender) {
            sender.className = sndr_css_active;
        }
        var divForClose = document.getElementById(IDForHide);
        var sndrForClose = document.getElementById(otherSenderIDForHide);
        if (divForClose) {
            divForClose.className = trgt_css_inactive;
            divForClose.style.display = "none";
        }
        if (sndrForClose) {
            sndrForClose.className = sndr_css_inactive;
            //alert( sndrForClose.className);
        }
        if (divAddit) {
            divAddit.className = addit_css_active;
        }
    }
    else {
        divForExpand.style.display = "none";
        divForExpand.className = trgt_css_inactive;
        if (sender) {
            sender.className = sndr_css_inactive;
        }
        if (divAddit) {
            divAddit.className = addit_css_inactive;
        }
    }
    // if(sender!=null)
    //alert(sender.className);

}

//Показ всплывающего div-а
function ShowDiv(divID) {
    var div = document.getElementById(divID);

    if (div) {
        var x1 = (document.all) ? window.event.x + document.body.scrollLeft : undefined;
        var y1 = (document.all) ? window.event.y + document.body.scrollTop : undefined;

        div.style.left = (x1 + 20) + "px";
        div.style.top = (y1) + "px";
        div.style.display = "block";
        div.style.visibility = "visible";
    }
}
function ShowDivWithFocus(divID, inputID) {
    var div = document.getElementById(divID);
    if (div) {
        div.style.display = "block";
        div.style.visibility = "visible";
        var inpt = document.getElementById(inputID);
        if (inpt)
            inpt.focus();

    }
}
function HideDiv(divID) {
    var div = document.getElementById(divID);
    if (div) {

        div.style.display = "none";
        div.style.visibility = "hidden";
    }
}
var ajaxTargetCtrlID;
function Return_AjaxResult() {

    if (req.readyState == 4) {

        document.getElementById(ajaxTargetCtrlID).innerHTML = req.responseText;
        //alert(req.responseText);
        delete req;
        req = null;
    }

}
var req;
function connect(url, u_function) {
    if (window.XMLHttpRequest) {
        req = new XMLHttpRequest();
        req.onreadystatechange = eval(u_function);
        req.open("GET", url, true);
        req.send(null);
    } else if (window.ActiveXObject) {
        req = new ActiveXObject("Microsoft.XMLHTTP");
        if (req) {
            req.onreadystatechange = eval(u_function);
            req.open("GET", url, true);
            req.send();
        } else {
            alert('Не удалось создать экземпляр объекта: ActiveXObject.');
        }
    }
}
function getOffsetTop(win) {
    if (!win)
        win = window;
    if (win.innerWidth)  // All browsers but IE
        return win.pageYOffset;
    else if (win.document.documentElement && win.document.documentElement.clientWidth)
        return win.document.documentElement.scrollTop;
    else if (win.document.body.clientWidth) // These are for IE4, IE5, and IE6 without a DOCTYPE
        return win.document.body.scrollTop;
}
