function flip(im) {
    var div = document.getElementById('s_' + im);
    var divb = document.getElementById('p_s_' + im);
    var path = divb.src.substring(0, divb.src.length - 9);
    if (div.style.display != 'none') {
        div.style.display = 'none';
        divb.src = path + 'tree3.gif'
    } else {
        div.style.display = '';
        divb.src = path + 'tree2.gif'
    }
}
function fliq(em) {
    if (em.style.display == 'none') em.style.display = '';
    var attvalue = em.getAttribute('id');
    var divc = document.getElementById('p_' + attvalue);
    if (divc) {
        var pathc = divc.src.substring(0, divc.src.length - 9);
        divc.src = pathc + 'tree2.gif'
    }
}
function open_window(link, w, h) {
    var win = "width=" + w + ",height=" + h + ",menubar=no,location=no,resizable=yes,scrollbars=yes";
    newWin = window.open(link, 'newWin', win);
    newWin.focus()
}
function open_printable_version(link) {
    var win = "menubar=no,location=no,resizable=yes,scrollbars=yes";
    newWin = window.open(link, 'perintableWin', win);
    newWin.focus()
}
function confirmDelete(id, ask, url) {
    temp = window.confirm(ask);
    if (temp) {
        window.location = url + id
    }
}
function setGlobalOnLoad(f) {
    var root = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null;
    if (root) {
        if (root.addEventListener) root.addEventListener("load", f, false);
        else if (root.attachEvent) root.attachEvent("onload", f)
    } else {
        if (typeof window.onload == 'function') {
            var existing = window.onload;
            window.onload = function () {
                existing();
                f()
            }
        } else {
            window.onload = f
        }
    }
}
function doLoad(forse) {
    var agt = navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.") != -1));
    if (document.getElementById('axcrt')) {
        if (!is_ie6) {
            document.getElementById('axcrt').style.left = Math.ceil((document.documentElement.clientWidth - 300) / 2) + 'px';
            document.getElementById('axcrt').style.top = Math.ceil((document.documentElement.clientHeight - 100) / 2) + 'px'
        }
        if (is_ie) {
            if (document.styleSheets.length == 0) document.createStyleSheet();
            var oSheet = document.styleSheets[0];
            oSheet.addRule(".WCHhider", "visibility:hidden")
        }
        document.getElementById('axcrt').style.display = '';
        document.getElementById('axcrt').style.visibility = 'visible'
    }
    JsHttpRequest.query('cart.php', forse, function (result, errors) {
        setTimeout('doHide()', 1500);
        doCart(result)
    }, true)
}
function doLoadcpr(forse) {
    var agt = navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.") != -1));
    if (document.getElementById('axcrt')) {
        renbox();
        if (!is_ie6) {
            document.getElementById('axcrt').style.left = Math.ceil((document.documentElement.clientWidth - 300) / 2) + 'px';
            document.getElementById('axcrt').style.top = Math.ceil((document.documentElement.clientHeight - 100) / 2) + 'px'
        }
        if (is_ie) {
            if (document.styleSheets.length == 0) document.createStyleSheet();
            var oSheet = document.styleSheets[0];
            oSheet.addRule(".WCHhider", "visibility:hidden")
        }
        document.getElementById('axcrt').style.display = '';
        document.getElementById('axcrt').style.visibility = 'visible'
    }
    JsHttpRequest.query('addcpr.php', forse, function (result, errors) {
        setTimeout('doHide()', 1500);
        doCpr(result)
    }, true)
}
function doLoadcprCL(forse) {
    var agt = navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.") != -1));
    if (document.getElementById('axcrt')) {
        renboxCL();
        if (!is_ie6) {
            document.getElementById('axcrt').style.left = Math.ceil((document.documentElement.clientWidth - 300) / 2) + 'px';
            document.getElementById('axcrt').style.top = Math.ceil((document.documentElement.clientHeight - 100) / 2) + 'px'
        }
        if (is_ie) {
            if (document.styleSheets.length == 0) document.createStyleSheet();
            var oSheet = document.styleSheets[0];
            oSheet.addRule(".WCHhider", "visibility:hidden")
        }
        document.getElementById('axcrt').style.display = '';
        document.getElementById('axcrt').style.visibility = 'visible'
    }
    JsHttpRequest.query('addcpr.php', forse, function (result, errors) {
        setTimeout('doHide()', 1500);
        doCL()
    }, true)
}
function doHide() {
    var agt = navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.") != -1));
    if (document.getElementById('axcrt')) {
        document.getElementById('axcrt').style.visibility = 'hidden';
        document.getElementById('axcrt').style.display = 'none';
        setTimeout('doreset()', 100);
        if (is_ie) {
            if (document.styleSheets.length == 0) document.createStyleSheet();
            var oSheet = document.styleSheets[0];
            oSheet.addRule(".WCHhider", "visibility:visible")
        }
    }
}
function validate() {
    if (document.subscription_form.email.value.length < 1) {
        alert(validate_act1);
        return false
    }
    if (document.subscription_form.email.value == 'Email') {
        alert(validate_act1);
        return false
    }
    document.getElementById('subscription_form').submit();
    return true
}
function validate_disc() {
    if (document.formD.nick.value.length < 1) {
        alert(validate_disc_act1);
        return false
    }
    if (document.formD.topic.value.length < 1) {
        alert(validate_disc_act2);
        return false
    }
    document.getElementById('formD').submit();
    return true
}
function validate_search() {
    if (document.AdvancedSearchInCategory.search_price_from.value != "" && ((document.AdvancedSearchInCategory.search_price_from.value < 0) || isNaN(document.AdvancedSearchInCategory.search_price_from.value))) {
        alert(validate_search_act1);
        return false
    }
    if (document.AdvancedSearchInCategory.search_price_to.value != "" && ((document.AdvancedSearchInCategory.search_price_to.value < 0) || isNaN(document.AdvancedSearchInCategory.search_price_to.value))) {
        alert(validate_search_act1);
        return false
    }
    document.getElementById('AdvancedSearchInCategory').submit();
    return true
}
function doCL() {
    if (document.getElementById('cprbox')) {
        document.getElementById('cprbox').innerHTML = doCL_act1 + doCL_act2;
        document.getElementById('axcrt').innerHTML = doCL_act3
    }
}
function renbox() {
    if (document.getElementById('axcrt')) {
        document.getElementById('axcrt').innerHTML = renbox_act1
    }
}
function renboxCL() {
    if (document.getElementById('axcrt')) {
        document.getElementById('axcrt').innerHTML = renboxCL_act1
    }
}
function doreset() {
    if (document.getElementById('axcrt')) {
        document.getElementById('axcrt').innerHTML = doreset_act1
    }
}
function printcart() {
    var agt = navigator.userAgent.toLowerCase();
    var is_major = parseInt(navigator.appVersion);
    var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
    var is_ie6 = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.") != -1));
    if (is_ie6) {
        document.write('<div id="axcrt" class="bf" align="center" style="position: absolute; display: none; visibility: hidden; z-index: 100;">' + printcart_act1 + '<\/div>')
    } else {
        document.write('<div id="axcrt" class="bf" align="center" style="position: fixed; display: none; z-index: 100; visibility: hidden; left: ' + Math.ceil((document.documentElement.clientWidth - 300) / 2) + 'px; top: ' + Math.ceil((document.documentElement.clientHeight - 100) / 2) + 'px;">' + printcart_act1 + '<\/div>')
    }
}
function confirmUnsubscribe() {
    temp = window.confirm(confirmUnsubscribe_act1);
    if (temp) {
        window.location = "index.php?killuser=yes"
    }
}
function preloadImages() {
    var d = document;
    if (d.images) {
        if (!d.massiv) d.massiv = new Array();
        var i, j = d.massiv.length,
            a = arguments;
        for (i = 0; i < a.length; i++) if (a[i].indexOf("#") != 0) {
            d.massiv[j] = new Image;
            d.massiv[j++].src = a[i]
        }
    }
}
function _formatPrice(_price, roundval) {
    var roundval_calc = 0;
    roundval_calc = Math.pow(10, Math.abs(roundval));
    _pointIndex = -1;
    for (i = 0; i < _price.length; i++) if (_price.charAt(i) == '.') {
        _pointIndex = i;
        break
    }
    if (_pointIndex == -1) _price = _price + ".00";
    else if (_price.length - 1 - _pointIndex == 1) _price = _price + "0";
    _res = "";
    i = 0;
    for (i = _price.length - 1; i >= 0; i--) {
        if (_price.charAt(i) == '.') break;
        else _res = _price.charAt(i) + _res
    }
    _res = "." + _res;
    i--;
    for (; i >= 0; i--) _res = _price.charAt(i) + _res;
    if (roundval < 0) _res = Math.round(_res / roundval_calc) * roundval_calc;
    if (roundval > 0) _res = Math.round(_res * roundval_calc) / roundval_calc;
    if (roundval == 0) _res = Math.round(_res);
    _price = new String(_res);
    _res = "";
    if (_price.indexOf(".") == -1) _price = _price + ".";
    i = 0;
    for (i = _price.length - 1; i >= 0; i--) {
        if (_price.charAt(i) == '.') break;
        else _res = _price.charAt(i) + _res
    }
    if (_res != '') _res = "." + _res;
    _digitCounter = 0;
    i--;
    for (; i >= 0; i--) {
        _digitCounter++;
        _res = _price.charAt(i) + _res;
        if (_digitCounter == 3 && i != 0) {
            _res = " " + _res;
            _digitCounter = 0
        }
    }
    return _res
}


function JsHttpRequest() {
    var t = this;
    t.onreadystatechange = null;
    t.readyState = 0;
    t.responseText = null;
    t.responseXML = null;
    t.status = 200;
    t.statusText = "OK";
    t.responseJS = null;
    t.caching = false;
    t.loader = null;
    t.session_name = "PHPSESSID";
    t._ldObj = null;
    t._reqHeaders = [];
    t._openArgs = null;
    t._errors = {
        inv_form_el: "Invalid FORM element detected: name=%, tag=%",
        must_be_single_el: "If used, <form> must be a single HTML element in the list.",
        js_invalid: "JavaScript code generated by backend is invalid!\n%",
        url_too_long: "Cannot use so long query with GET request (URL is larger than % bytes)",
        unk_loader: "Unknown loader: %",
        no_loaders: "No loaders registered at all, please check JsHttpRequest.LOADERS array",
        no_loader_matched: "Cannot find a loader which may process the request. Notices are:\n%"
    };
    t.abort = function () {
        with(this) {
            if (_ldObj && _ldObj.abort) {
                _ldObj.abort()
            }
            _cleanup();
            if (readyState == 0) {
                return
            }
            if (readyState == 1 && !_ldObj) {
                readyState = 0;
                return
            }
            _changeReadyState(4, true)
        }
    };
    t.open = function (a, b, c, d, f) {
        with(this) {
            if (b.match(/^((\w+)\.)?(GET|POST)\s+(.*)/i)) {
                this.loader = RegExp.$2 ? RegExp.$2 : null;
                a = RegExp.$3;
                b = RegExp.$4
            }
            try {
                if (document.location.search.match(new RegExp("[&?]" + session_name + "=([^&?]*)")) || document.cookie.match(new RegExp("(?:;|^)\\s*" + session_name + "=([^;]*)"))) {
                    b += (b.indexOf("?") >= 0 ? "&" : "?") + session_name + "=" + this.escape(RegExp.$1)
                }
            } catch (e) {}
            _openArgs = {
                method: (a || "").toUpperCase(),
                url: b,
                asyncFlag: c,
                username: d != null ? d : "",
                password: f != null ? f : ""
            };
            _ldObj = null;
            _changeReadyState(1, true);
            return true
        }
    };
    t.send = function (a) {
        if (!this.readyState) {
            return
        }
        this._changeReadyState(1, true);
        this._ldObj = null;
        var b = [];
        var c = [];
        if (!this._hash2query(a, null, b, c)) {
            return
        }
        var d = null;
        if (this.caching && !c.length) {
            d = this._openArgs.username + ":" + this._openArgs.password + "@" + this._openArgs.url + "|" + b + "#" + this._openArgs.method;
            var e = JsHttpRequest.CACHE[d];
            if (e) {
                this._dataReady(e[0], e[1]);
                return false
            }
        }
        var f = (this.loader || "").toLowerCase();
        if (f && !JsHttpRequest.LOADERS[f]) {
            return this._error("unk_loader", f)
        }
        var g = [];
        var h = JsHttpRequest.LOADERS;
        for (var i in h) {
            var j = h[i].loader;
            if (!j) {
                continue
            }
            if (f && i != f) {
                continue
            }
            var k = new j(this);
            JsHttpRequest.extend(k, this._openArgs);
            JsHttpRequest.extend(k, {
                queryText: b.join("&"),
                queryElem: c,
                id: (new Date().getTime()) + "" + JsHttpRequest.COUNT++,
                hash: d,
                span: null
            });
            var l = k.load();
            if (!l) {
                this._ldObj = k;
                JsHttpRequest.PENDING[k.id] = this;
                return true
            }
            if (!f) {
                g[g.length] = "- " + i.toUpperCase() + ": " + this._l(l)
            } else {
                return this._error(l)
            }
        }
        return i ? this._error("no_loader_matched", g.join("\n")) : this._error("no_loaders")
    };
    t.getAllResponseHeaders = function () {
        with(this) {
            return _ldObj && _ldObj.getAllResponseHeaders ? _ldObj.getAllResponseHeaders() : []
        }
    };
    t.getResponseHeader = function (a) {
        with(this) {
            return _ldObj && _ldObj.getResponseHeader ? _ldObj.getResponseHeader(a) : null
        }
    };
    t.setRequestHeader = function (a, b) {
        with(this) {
            _reqHeaders[_reqHeaders.length] = [a, b]
        }
    };
    t._dataReady = function (a, b) {
        with(this) {
            if (caching && _ldObj) {
                JsHttpRequest.CACHE[_ldObj.hash] = [a, b]
            }
            responseText = responseXML = a;
            responseJS = b;
            if (b !== null) {
                status = 200;
                statusText = "OK"
            } else {
                status = 500;
                statusText = "Internal Server Error"
            }
            _changeReadyState(2);
            _changeReadyState(3);
            _changeReadyState(4);
            _cleanup()
        }
    };
    t._l = function (b) {
        var i = 0,
            p = 0,
            msg = this._errors[b[0]];
        while ((p = msg.indexOf("%", p)) >= 0) {
            var a = b[++i] + "";
            msg = msg.substring(0, p) + a + msg.substring(p + 1, msg.length);
            p += 1 + a.length
        }
        return msg
    };
    t._error = function (a) {
        a = this._l(typeof(a) == "string" ? arguments : a);
        a = "JsHttpRequest: " + a;
        if (!window.Error) {
            throw a;
        } else {
            if ((new Error(1, "test")).description == "test") {
                throw new Error(1, a);
            } else {
                throw new Error(a);
            }
        }
    };
    t._hash2query = function (a, b, c, d) {
        if (b == null) {
            b = ""
        }
        if (("" + typeof(a)).toLowerCase() == "object") {
            var e = false;
            if (a && a.parentNode && a.parentNode.appendChild && a.tagName && a.tagName.toUpperCase() == "FORM") {
                a = {
                    form: a
                }
            }
            for (var k in a) {
                var v = a[k];
                if (v instanceof Function) {
                    continue
                }
                var f = b ? b + "[" + this.escape(k) + "]" : this.escape(k);
                var g = v && v.parentNode && v.parentNode.appendChild && v.tagName;
                if (g) {
                    var h = v.tagName.toUpperCase();
                    if (h == "FORM") {
                        e = true
                    } else {
                        if (h == "INPUT" || h == "TEXTAREA" || h == "SELECT") {} else {
                            return this._error("inv_form_el", (v.name || ""), v.tagName)
                        }
                    }
                    d[d.length] = {
                        name: f,
                        e: v
                    }
                } else {
                    if (v instanceof Object) {
                        this._hash2query(v, f, c, d)
                    } else {
                        if (v === null) {
                            continue
                        }
                        if (v === true) {
                            v = 1
                        }
                        if (v === false) {
                            v = ""
                        }
                        c[c.length] = f + "=" + this.escape("" + v)
                    }
                }
                if (e && d.length > 1) {
                    return this._error("must_be_single_el")
                }
            }
        } else {
            c[c.length] = a
        }
        return true
    };
    t._cleanup = function () {
        var a = this._ldObj;
        if (!a) {
            return
        }
        JsHttpRequest.PENDING[a.id] = false;
        var b = a.span;
        if (!b) {
            return
        }
        a.span = null;
        var c = function () {
            b.parentNode.removeChild(b)
        };
        JsHttpRequest.setTimeout(c, 50)
    };
    t._changeReadyState = function (s, a) {
        with(this) {
            if (a) {
                status = statusText = responseJS = null;
                responseText = ""
            }
            readyState = s;
            if (onreadystatechange) {
                onreadystatechange()
            }
        }
    };
    t.escape = function (s) {
        return escape(s).replace(new RegExp("\\+", "g"), "%2B")
    }
}
JsHttpRequest.COUNT = 0;
JsHttpRequest.MAX_URL_LEN = 2000;
JsHttpRequest.CACHE = {};
JsHttpRequest.PENDING = {};
JsHttpRequest.LOADERS = {};
JsHttpRequest._dummy = function () {};
JsHttpRequest.TIMEOUTS = {
    s: window.setTimeout,
    c: window.clearTimeout
};
JsHttpRequest.setTimeout = function (a, b) {
    window.JsHttpRequest_tmp = JsHttpRequest.TIMEOUTS.s;
    if (typeof(a) == "string") {
        c = window.JsHttpRequest_tmp(a, b)
    } else {
        var c = null;
        var d = function () {
            a();
            delete JsHttpRequest.TIMEOUTS[c]
        };
        c = window.JsHttpRequest_tmp(d, b);
        JsHttpRequest.TIMEOUTS[c] = d
    }
    window.JsHttpRequest_tmp = null;
    return c
};
JsHttpRequest.clearTimeout = function (a) {
    window.JsHttpRequest_tmp = JsHttpRequest.TIMEOUTS.c;
    delete JsHttpRequest.TIMEOUTS[a];
    var r = window.JsHttpRequest_tmp(a);
    window.JsHttpRequest_tmp = null;
    return r
};
JsHttpRequest.query = function (a, b, c, d) {
    var e = new this();
    e.caching = !d;
    e.onreadystatechange = function () {
        if (e.readyState == 4) {
            c(e.responseJS, e.responseText)
        }
    };
    e.open(null, a, true);
    e.send(b)
};
JsHttpRequest.dataReady = function (d) {
    var a = this.PENDING[d.id];
    delete this.PENDING[d.id];
    if (a) {
        a._dataReady(d.text, d.js)
    } else {
        if (a !== false) {
            throw "dataReady(): unknown pending id: " + d.id;
        }
    }
};
JsHttpRequest.extend = function (a, b) {
    for (var k in b) {
        a[k] = b[k]
    }
};
JsHttpRequest.LOADERS.script = {
    loader: function (e) {
        JsHttpRequest.extend(e._errors, {
            script_only_get: "Cannot use SCRIPT loader: it supports only GET method",
            script_no_form: "Cannot use SCRIPT loader: direct form elements using and uploading are not implemented"
        });
        this.load = function () {
            if (this.queryText) {
                this.url += (this.url.indexOf("?") >= 0 ? "&" : "?") + this.queryText
            }
            this.url += (this.url.indexOf("?") >= 0 ? "&" : "?") + "JsHttpRequest=" + this.id + "-" + "script";
            this.queryText = "";
            if (!this.method) {
                this.method = "GET"
            }
            if (this.method !== "GET") {
                return ["script_only_get"]
            }
            if (this.queryElem.length) {
                return ["script_no_form"]
            }
            if (this.url.length > JsHttpRequest.MAX_URL_LEN) {
                return ["url_too_long", JsHttpRequest.MAX_URL_LEN]
            }
            var a = this,
                d = document,
                s = null,
                b = d.body;
            if (!window.opera) {
                this.span = s = d.createElement("SCRIPT");
                var c = function () {
                    s.language = "JavaScript";
                    if (s.setAttribute) {
                        s.setAttribute("src", a.url)
                    } else {
                        s.src = a.url
                    }
                    b.insertBefore(s, b.lastChild)
                }
            } else {
                this.span = s = d.createElement("SPAN");
                s.style.display = "none";
                b.insertBefore(s, b.lastChild);
                s.innerHTML = "Workaround for IE.<s" + "cript></" + "script>";
                var c = function () {
                    s = s.getElementsByTagName("SCRIPT")[0];
                    s.language = "JavaScript";
                    if (s.setAttribute) {
                        s.setAttribute("src", a.url)
                    } else {
                        s.src = a.url
                    }
                }
            }
            JsHttpRequest.setTimeout(c, 10);
            return null
        }
    }
};