﻿function micl(id, obj) {
    var container = document.getElementById(id), o;
    if (new Number(container.sID) != 0 && (o = document.getElementById(id + '_' + container.sID)) != null) o.className = 'trtc';

    while (obj.tagName != 'TABLE') obj = obj.parentNode;
    obj.rows.item(0).cells.item(1).className = 'trtc2';

    var s = obj.rows.item(0).cells.item(1).id.split('_');
    container.sID = s[s.length - 1];

    var table = obj.nextSibling;
    if (table == null || table.tagName != 'TABLE' || table.style.marginLeft != '13px') {
        try { obj.rows.item(0).cells.item(1).firstChild.click(); }
        catch (e) { }
        return false;
    }

    if (table.style.display == '') {
        table.style.display = 'none';
        obj.rows.item(0).cells.item(0).firstChild.src = imPlus.src;
    }
    else {
        table.style.display = '';
        obj.rows.item(0).cells.item(0).firstChild.src = imMinus.src;
    }

    return false;
}

function miov(obj) {
    obj.baC_ = obj.style.backgroundColor;
    obj.boC_ = obj.style.borderColor;
    obj.style.backgroundColor = '#CCCCCC';
    obj.style.borderColor = '#999999';
}

function miou(obj) {
    obj.style.backgroundColor = obj.baC_;
    obj.style.borderColor = obj.boC_;
}

function mido(obj) {
    obj.baC1_ = obj.style.backgroundColor;
    obj.style.backgroundColor = '#999999';
}

function miup(obj) {
    obj.style.backgroundColor = obj.baC1_;
}

function urlEncode(value) {
    var s = '', ch, s1 = new Array(' ', '"', '#', '$', '%', '&', '+', ',', '/', ':', ';', '<', '=', '>', '?', '@', '[', '\\', ']', '^', '`', 'ß', 'á', 'ä', 'č', 'ď', 'é', 'ě', 'í', 'ň', 'ó', 'ö', 'ř', 'š', 'ť', 'ú', 'ů', 'ü', 'ý', 'ž', 'Á', 'Ä', 'Č', 'Ď', 'É', 'Ě', 'Í', 'Ň', 'Ó', 'Ö', 'Ř', 'Š', 'Ť', 'Ú', 'Ů', 'Ü', 'Ý', 'Ž'), s2 = new Array('%20', '%22', '%23', '%24', '%25', '%26', '%2b', '%2c', '%2f', '%3a', '%3b', '%3c', '%3d', '%3e', '%3f', '%40', '%5b', '%5c', '%5d', '%5e', '%60', '%c3%9f', '%c3%a1', '%c3%a4', '%c4%8d', '%c4%8f', '%c3%a9', '%c4%9b', '%c3%ad', '%c5%88', '%c3%b3', '%c3%b6', '%c5%99', '%c5%a1', '%c5%a5', '%c3%ba', '%c5%af', '%c3%bc', '%c3%bd', '%c5%be', '%c3%81', '%c3%84', '%c4%8c', '%c4%8e', '%c3%89', '%c4%9a', '%c3%8d', '%c5%87', '%c3%93', '%c3%96', '%c5%98', '%c5%a0', '%c5%a4', '%c3%9a', '%c5%ae', '%c3%9c', '%c3%9d', '%c5%bd');
    for (var i = 0; i < value.length; i++) {
        ch = value.substr(i, 1);
        for (var j = 0; j < s1.length; j++) if (ch == s1[j]) { ch = s2[j]; break; }
        s += ch;
    }
    return s;
}

function go(reset) {
    var url = '';
    if (reset == null)
    {
        var o = document.getElementById('DDLManufacturer');
        if (o.selectedIndex != -1) {
            url += '&m=' + o.options[o.selectedIndex].value;
        }

        var o = document.getElementById('DDLCategory');
        if (o.selectedIndex != 0) {
            url += '&c=' + o.options[o.selectedIndex].value;
        }

        var o = document.getElementById('DDLFrequency');
        if (o.selectedIndex != 0) {
            url += '&f=' + o.options[o.selectedIndex].value;
        }

        var o = document.getElementById('DDLSpeed');
        if (o.selectedIndex != 0) {
            url += '&s=' + o.options[o.selectedIndex].value;
        }

        var o = document.getElementById('DDLRozmer1');
        if (o.selectedIndex != 0) {
            url += '&a1=' + o.options[o.selectedIndex].value;
        }

        var o = document.getElementById('DDLRozmer2');
        if (o.selectedIndex != 0) {
            url += '&a2=' + o.options[o.selectedIndex].value;
        }

        for (var i = 0; i < 20; i++) {
            var o = document.getElementById('svorkovnice_' + i);
            if (o == null) break;
            if (o.checked) {
                url += '&svorkovnice=' + i.toString();
                break;
            }
        }
        
        for (var i = 0; i < 100; i++) {
            var o = document.getElementById('prislusenstvi_' + i);
            if (i == 0) {
                if (o == null) { break; }
                else { 
                    url += '&prislusenstvi=';
                    url += o.value;
                }
            } else {
                if (o == null) { break; }
                else {
                    url += ',' + o.value;
                }
            }
        }
    }

    location = 'Configurator.aspx?' + url.substr(1);
}

