﻿// JScript File
var sss = '.';


function ovr2(obj, sId) {
    ovr(obj);
    ovr1(sId);
}
function out2(obj, sId, css1) {
    out(obj, css1);
    out1(sId, css1);
}

function ovr(obj) {
    obj.className = "selected";
}
function out(obj, css1) {
    obj.className = css1;
}
function ovr1(objId) {
    if (document.getElementById(objId) != null) document.getElementById(objId).className = "selected";
}
function out1(objId, css1) {
    if (document.getElementById(objId) != null) document.getElementById(objId).className = css1;
}

function chCSS(obj, css1)
{
    obj.className = css1;
}
function OrdInf(s1, s2){
    window.open(s1,'mywindow','width=480,height=400,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=yes', false);
}

function ProdInf(s1){
    window.open(s1,'mywindow','width=550,height=550,toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=no,resizable=yes', false);
}

function newWin(h, s1, s2){
	window.open(s1,'mywindow','width=450,height='+h+',toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,copyhistory=yes,resizable=yes');
}
 
function doPostback( eTarget, eArgument, tb, sel ){
    s1 = '';
    s = '';

    if (document.getElementById(tb) != null) s = document.getElementById(tb).value;

    objSel = document.getElementById(sel);
    if (objSel != null)
    {
        try
        {
            s1 = objSel.options[objSel.selectedIndex].value;        
        }
        catch (err) {
        }
    }
        
    __doPostBack(eTarget, eArgument+"|"+s+"|"+s1);
}

function redirect( trueRedirect ){
    if ( confirm('Это действие необратимо, Вы уверены?') == true ) window.location = trueRedirect;
}
function redirectTo( trueRedirect ){
    window.location = trueRedirect;
}

function switchVis(sKey)
{
    if (document.getElementById('catState' + sKey) != null) 
    {
        if (document.getElementById('catState' + sKey).innerHTML == '+') {
            try
            {
                if (document.getElementById('catList' + sKey) != null) document.getElementById('catList' + sKey).style.display = "";
                if (document.getElementById('catState' + sKey) != null) document.getElementById('catState' + sKey).innerHTML = '–';

                currCat = getCookie('currCat');
                setCookie('currCat', currCat + '.' + sKey + '.', 1);
            }
            catch (err) {
            }
        }
        else
            if (document.getElementById('catState' + sKey).innerHTML == '–') {
                try
                {
                    if (document.getElementById('catList' + sKey) != null) document.getElementById('catList' + sKey).style.display = "none";
                    if (document.getElementById('catState' + sKey) != null) document.getElementById('catState' + sKey).innerHTML = '+';

                    currCat = getCookie('currCat');
                    setCookie('currCat', currCat.replace('.' + sKey + '.', '').replace('.' + sKey + '.', '').replace('.' + sKey + '.', '').replace('.' + sKey + '.', ''), 1);
                }
                catch (err) {
                }
            }
    }
}

function ShowCatalog() {
    var sCurrCat = getCookie('currCat');

    //alert(sCurrCat);
    
    while (sCurrCat.indexOf('..', 0) > -1) sCurrCat = sCurrCat.replace('..', '|');
    sCurrCat = sCurrCat.replace('.', '').replace('.', '');
    
    for (ii in sCurrCat.split('|')) {
        if (document.getElementById('catList' + sCurrCat.split('|')[ii]) != null) document.getElementById('catList' + sCurrCat.split('|')[ii]).style.display = "";
        if (document.getElementById('catState' + sCurrCat.split('|')[ii]) != null) document.getElementById('catState' + sCurrCat.split('|')[ii]).innerText = '–';
    }
    
}

function getCookie(c_name) {
    if (document.cookie.length > 0) {
        c_start = document.cookie.indexOf(c_name + "=");
        if (c_start != -1) {
            c_start = c_start + c_name.length + 1;
            c_end = document.cookie.indexOf(";", c_start);
            if (c_end == -1) c_end = document.cookie.length;
            return unescape(document.cookie.substring(c_start, c_end));
        }
    }
    return "";
}

function setCookie(c_name, value, expiredays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + expiredays);
    document.cookie = c_name + "=" + escape(value) + ((expiredays == null) ? "" : ";expires=" + exdate.toGMTString());
}

function chImg(objName, sNewImgSrc) {
    try {
        if (document.getElementById(objName) != null) document.getElementById(objName).src = sNewImgSrc;
    }
    catch (err) {
    }

    //alert(objName);
}
