var isClip = navigator.userAgent.indexOf('CL!P') != -1;

var at0 = [-27, -30, -82, -27, -25, -31, -30, -31, -20, -64, -12, -14, -17, -16, -16, -11, -13, -16, -23, -20, -29];

var at1 = [-27, -30, -82, -27, -25, -31, -30, -31, -20, -64, -21, -29, -31, -30, -28, -27, -27, -26, -16, -23, -20, -29];

function createRequest() {
    var request;
    try {
        request = new XMLHttpRequest();
    } catch (trymicrosoft) {
        try {
            request = new ActiveXObject('Msxml2.XMLHTTP');
        } catch (tryothermicrosoft) {
            try {
                request = new ActiveXObject('Microsoft.XMLHTTP');
            } catch (failed) {
                request = false;
            };
        };
    };
    return request;
};

function setCartActionsAvailability() {
    var nRows = 0;
    var nSelectedRows = 0;
    var tmpArr74 = document.getElementById('carttable').getElementsByTagName('tr');
    for (var tmpI75 = 0; tmpI75 < tmpArr74.length; tmpI75 = tmpI75 + 1) {
        var row = tmpArr74[tmpI75];
        if (row.id) {
            ++nRows;
            if (row.getElementsByTagName('input')[0].checked) {
                ++nSelectedRows;
            };
        };
    };
    var available = nSelectedRows > 0;
    setActionAvailability(document.getElementById('removeselected'), available);
    setActionAvailability(document.getElementById('orderselected'), available);
    document.cartform.all.checked = nRows > 0 && nRows == nSelectedRows;
};

function at(atn) {
    var str = '';
    var l = atn.length;
    for (var i = 0; i < l; i = i + 1) {
        str += String.fromCharCode(atn[l - 1 - i] + 128);
    };
    return str;
};

function cartOrderSelected2(request) {
    if (request.readyState == 4 && request.status == 200) {
        var options = readCookie('options');
        var url = 'mailto:' + (options['cartto'] || '') + '?subject=' + 'CL!P cart' + '&body=' + encodeURIComponent(request.responseText);
        window.open(url, '_self', '');
    };
};

function searchfor(i, sfnew) {
    var words = document.getElementById('searchfor').getElementsByTagName('p');
    var word = words[i].getElementsByTagName('a')[1].innerHTML;
    var selection = top.sfframe.document.searchform.search.value;
    var context = top.sfframe.document.searchform.curr_line.value;
    if (sfnew) {
        top.sfframe.document.searchform.search.value = word;
        top.sfframe.document.searchform.curr_line.value = selection + ' ' + context;
    } else {
        top.sfframe.document.searchform.search.value = selection + ' ' + word;
    };
    top.sfframe.document.searchform.sid.disabled = false;
    top.sfframe.document.searchform.a.value = 'b';
    top.sfframe.document.searchform.target = '_top';
    top.sfframe.document.searchform.submit();
};

function submitSearchform(event) {
    if (event.ctrlKey) {
        document.searchform.sid.disabled = true;
        document.searchform.a.value = 'cb';
        document.searchform.target = '_blank';
    } else {
        document.searchform.sid.disabled = false;
        document.searchform.a.value = 'b';
        document.searchform.target = '_top';
    };
    return true;
};

function readCookie(name) {
    var cookie = new Cookie();
    var allCookies = document.cookie;
    var start = allCookies.indexOf(name + '=');
    if (start == -1) {
        return cookie;
    };
    start += name.length + 1;
    var end = allCookies.indexOf(';', start);
    if (end == -1) {
        end = allCookies.length;
    };
    if (start == end) {
        return cookie;
    };
    var subcookies = allCookies.substring(start, end).split('&');
    for (var i = 0; i < subcookies.length; i = i + 1) {
        var kv = subcookies[i].split(':');
        cookie[kv[0]] = decodeURIComponent(kv[1]);
    };
    return cookie;
};

function toggleAdvancedSearch() {
    if (document.searchform.advanced.value == 'no') {
        document.searchform.advanced.value = 'yes';
        document.getElementById('adv0').style.paddingTop = '0px';
        document.getElementById('adv1').style.display = 'inline';
        document.getElementById('adv2').style.display = 'inline';
        document.getElementById('adv3').style.display = 'inline';
        document.getElementById('adv4').style.display = 'inline';
        document.getElementById('adv5').style.display = 'inline';
        document.getElementById('adv6').style.display = 'inline';
        document.getElementById('adv7').style.display = 'inline';
        document.getElementById('adv8').firstChild.nodeValue = 'Basic';
    } else {
        document.searchform.advanced.value = 'no';
        document.getElementById('adv0').style.paddingTop = '12px';
        document.getElementById('adv1').style.display = 'none';
        document.getElementById('adv2').style.display = 'none';
        document.getElementById('adv3').style.display = 'none';
        document.getElementById('adv4').style.display = 'none';
        document.getElementById('adv5').style.display = 'none';
        document.getElementById('adv6').style.display = 'none';
        document.getElementById('adv7').style.display = 'none';
        document.getElementById('adv8').firstChild.nodeValue = 'Advanced';
    };
};

function emailFeedback() {
    var url = 'mailto:' + at(at1) + '?subject=Feedback&body=' + encodeURIComponent('CL!P search results feedback:\n\n\nSearch words:\n' + 'And = ' + top.sfframe.document.searchform.search.value + '\n' + 'Context = ' + top.sfframe.document.searchform.curr_line.value + '\n' + 'Context flag = ' + top.sfframe.document.searchform.context.checked + '\n' + 'None of = ' + top.sfframe.document.searchform.noneof.value + '\n');
    window.open(url, '_self', '');
};

function getRelated(pid) {
    var request = createRequest();
    if (request) {
        var url = 'results.html' + '?sid=' + top.sfframe.document.searchform.sid.value + '&qid=' + top.sfframe.document.searchform.qid.value + '&pid=' + pid + '&dh=' + (descriptionsHidden ? 'yes' : 'no');
        request.open('GET', url, true);
        request.onreadystatechange = function () {
            getRelated2(pid, request);
        };
        request.send(null);
    };
};

function toggleDescriptions() {
    descriptionsHidden = !descriptionsHidden;
    document.getElementById('toggleDescriptions').firstChild.nodeValue = descriptionsHidden ? 'show' : 'hide';
    var tmpArr94 = document.getElementsByTagName('div');
    for (var tmpI95 = 0; tmpI95 < tmpArr94.length; tmpI95 = tmpI95 + 1) {
        var elem = tmpArr94[tmpI95];
        if (elem.className == 'desc' && !elem.id) {
            elem.style.display = descriptionsHidden ? 'none' : 'block';
        };
    };
};

function moveSelectedOption(selectfrom, selectto, si, sorted) {
    var optionsfrom = new Array(selectfrom.options.length - 1);
    var optionsto = new Array(selectto.options.length + 1);
    var tolength = selectto.options.length;
    for (var i = 0; i < optionsfrom.length; i = i + 1) {
        optionsfrom[i] = i < si ? selectfrom.options[i] : selectfrom.options[i + 1];
    };
    for (var i = 0; i < optionsto.length; i = i + 1) {
        optionsto[i] = i < tolength ? selectto.options[i] : selectfrom.options[si];
    };
    if (sorted) {
        optionsto.sort(function (x, y) {
            return x.value < y.value ? -1 : (x.value > y.value ? 1 : 0);
        });
    };
    fillSelect(selectfrom, optionsfrom);
    fillSelect(selectto, optionsto);
};

function contactBack() {
    window.history.back();
};

function updateQuantity(widget, productId) {
    var cart = readCookie('cart');
    var qty = parseInt(widget.value);
    if (isNaN(qty) || qty <= 0) {
        widget.value = cart[productId];
    } else {
        var quantity = qty.toString();
        widget.value = quantity;
        cart[productId] = quantity;
        writeCookie('cart', cart, true);
    };
};

function Cookie() {
};

function setCookie(name, value, session) {
    var date = new Date();
    date.setFullYear(date.getFullYear() + 1);
    document.cookie = name + '=' + value + '; path=/clip; expires=' + (session ? '' : date.toUTCString());
};

function cartCBOnClick() {
    setCartActionsAvailability();
};

function updateCartsize(cart) {
    var n = 0;
    for (var prop in cart) {
        if (cart[prop]) {
            ++n;
        };
    };
    top.sfframe.document.getElementById('cartsize').innerHTML = n;
};

function extsearch(engine, bypass) {
    var context = top.sfframe.document.searchform.context.checked;
    var andText = top.sfframe.document.searchform.search.value;
    var orText = top.sfframe.document.searchform.curr_line.value;
    var url = 'http://www.labage.com/clip/extsearch.html' + '?sid=' + top.sfframe.document.searchform.sid.value + '&qid=' + top.sfframe.document.searchform.qid.value + '&engine=' + engine + '&context=' + (context ? 'yes' : 'no') + '&bypass=' + (bypass ? 'yes' : 'no') + '&and=' + encodeURIComponent(andText) + '&or=' + encodeURIComponent(orText);
    window.open(url, '_blank', '');
};

function othersDefault() {
    var selectright = document.optionsform.othersright;
    var si = selectright.selectedIndex;
    if (si != -1 && si != 0) {
        var optionsright = new Array(selectright.options.length);
        for (var i = 0; i < optionsright.length; i = i + 1) {
            optionsright[i] = i == 0 ? selectright.options[si] : (i <= si ? selectright.options[i - 1] : selectright.options[i]);
        };
        fillSelect(selectright, optionsright);
    };
};

function setFontSize(newFontSizeClass) {
    var options = readCookie('options');
    var allFontSizeClasses = ['small', 'medium', 'large'];
    switchRec(top, allFontSizeClasses, newFontSizeClass);
    options['fontsize'] = newFontSizeClass;
    writeCookie('options', options);
};

function contact() {
    window.open('contact.html', 'srframe');
};

function addMoreLink(cell) {
    var anchor = top.sfframe.document.createElement('a');
    anchor.className = 'act more';
    anchor.setAttribute('href', 'javascript:options("ext");');
    cell.appendChild(anchor);
    var text = top.sfframe.document.createTextNode('more...');
    anchor.appendChild(text);
};

function showCart() {
    var url = 'showcart.html' + '?sid=' + top.sfframe.document.searchform.sid.value + '&qid=' + top.sfframe.document.searchform.qid.value;
    window.open(url, 'srframe');
};

function cartRemoveSelected() {
    var selectedRows = cartSelectedRows();
    if (selectedRows.length != 0) {
        if (window.confirm(selectedRows.length + ' items will be removed from your cart. Are you sure?')) {
            var cart = readCookie('cart');
            var tmpArr82 = selectedRows;
            for (var tmpI83 = 0; tmpI83 < tmpArr82.length; tmpI83 = tmpI83 + 1) {
                var row = tmpArr82[tmpI83];
                cart[rowidToProductid(row.id)] = null;
                row.id = null;
                row.style.display = 'none';
            };
            updateCartsize(cart);
            writeCookie('cart', cart, true);
            setCartActionsAvailability();
        };
    };
};

function othersAdd() {
    var selectleft = document.optionsform.othersleft;
    var selectright = document.optionsform.othersright;
    var si = selectleft.selectedIndex;
    if (si != -1) {
        moveSelectedOption(selectleft, selectright, si, false);
        if (selectright.options.length == 5) {
            moveSelectedOption(selectright, selectleft, 3, true);
        };
    };
};

function addToCart2(lnk, productId) {
    var cart = readCookie('cart');
    cart[productId] = 1;
    updateCartsize(cart);
    writeCookie('cart', cart, true);
    var img = lnk.getElementsByTagName('img')[0];
    img.src = 'auxi/addtocart2.png';
    window.setTimeout(function () {
        img.src = 'auxi/addtocart.png';
    }, 250);
};

function writeCookie(name, cookie, session) {
    var cookieval = '';
    for (var prop in cookie) {
        if (cookie[prop] != null) {
            if (cookieval != '') {
                cookieval += '&';
            };
            cookieval += prop + ':' + encodeURIComponent(cookie[prop]);
        };
    };
    setCookie(name, cookieval, session);
};

function navigate(start, cid) {
    var url = 'results.html' + '?sid=' + top.sfframe.document.searchform.sid.value + '&qid=' + top.sfframe.document.searchform.qid.value + (cid ? '&cid=' + cid : '') + '&start=' + start + '&dh=' + (descriptionsHidden ? 'yes' : 'no');
    window.open(url, '_self', '');
};

function trimString(str) {
    return str.replace(/^\s*/, '').replace(/\s*$/, '');
};

function otherSearchEngines(opts) {
    var options = [];
    if (opts.length == 0) {
        options.push('');
    };
    var tmpArr36 = opts;
    for (var tmpI37 = 0; tmpI37 < tmpArr36.length; tmpI37 = tmpI37 + 1) {
        var item = tmpArr36[tmpI37];
        options.push(item);
    };
    options.push('<more>');
    var n = options.length - 1;
    var maxHeight = 2;
    var nlines = Math.min(n, maxHeight);
    var res = [];
    for (var i = 0; i < nlines; i = i + 1) {
        res.push(options[i + 1]);
        var j = i + maxHeight;
        if (j < n) {
            res.push(options[j + 1]);
        } else {
            res.push(null);
        };
    };
    return res;
};

function suggestSearchEngine() {
    var url = 'mailto:' + at(at1) + '?subject=Search%20engine&body=' + encodeURIComponent('\n\nSuggested search engine:\n');
    window.open(url, '_self', '');
};

function fillSelect(select, options) {
    select.length = 0;
    var tmpArr28 = options;
    for (var tmpI29 = 0; tmpI29 < tmpArr28.length; tmpI29 = tmpI29 + 1) {
        var option = tmpArr28[tmpI29];
        select.options[select.options.length] = option;
    };
};

function getRelated2(pid, request) {
    if (request.readyState == 4 && request.status == 200) {
        document.getElementById('pid' + pid).innerHTML = request.responseText;
    };
};

function cartSelectedRows() {
    var rows = new Array();
    var i = 0;
    var tmpArr79 = document.getElementById('carttable').getElementsByTagName('tr');
    for (var tmpI80 = 0; tmpI80 < tmpArr79.length; tmpI80 = tmpI80 + 1) {
        var row = tmpArr79[tmpI80];
        if (row.id) {
            if (row.getElementsByTagName('input')[0].checked) {
                rows[i] = row;
                ++i;
            };
        };
    };
    return rows;
};

function lesswords() {
    var words = document.getElementById('searchfor').getElementsByTagName('p');
    var nwords = words.length;
    var ndisplayed = 0;
    var tmpArr50 = words;
    for (var tmpI51 = 0; tmpI51 < tmpArr50.length; tmpI51 = tmpI51 + 1) {
        var word = tmpArr50[tmpI51];
        if (word.style.display == 'block') {
            ++ndisplayed;
        };
    };
    if (ndisplayed > 10) {
        var from = Math.floor((ndisplayed - 1) / 10) * 10;
        var to = ndisplayed - 1;
        for (var i = from; i <= to; i = i + 1) {
            words[i].style.display = 'none';
        };
        document.getElementById('morewords').style.visibility = 'visible';
        document.getElementById('lesswords').style.visibility = from > 10 ? 'visible' : 'hidden';
    };
    document.getElementById('moreless').scrollIntoView(false);
};

function morewords() {
    var words = document.getElementById('searchfor').getElementsByTagName('p');
    var nwords = words.length;
    var ndisplayed = 0;
    var tmpArr47 = words;
    for (var tmpI48 = 0; tmpI48 < tmpArr47.length; tmpI48 = tmpI48 + 1) {
        var word = tmpArr47[tmpI48];
        if (word.style.display == 'block') {
            ++ndisplayed;
        };
    };
    if (ndisplayed < nwords) {
        var from = ndisplayed;
        var to = Math.min(ndisplayed + 10, nwords) - 1;
        for (var i = from; i <= to; i = i + 1) {
            words[i].style.display = 'block';
        };
        document.getElementById('morewords').style.visibility = to < nwords - 1 ? 'visible' : 'hidden';
        document.getElementById('lesswords').style.visibility = 'visible';
    };
    document.getElementById('moreless').scrollIntoView(false);
};

function emailFriend() {
    var url = 'mailto:?subject=Do%20you%20know%20CL%21P%20%3F&body=' + encodeURIComponent('\n\nLink to the search page: http://www.labage.com/clip/search.html' + '?search=' + encodeURIComponent(top.sfframe.document.searchform.search.value) + '&curr_line=' + encodeURIComponent(top.sfframe.document.searchform.curr_line.value) + (top.sfframe.document.searchform.context.checked ? '&context=' + encodeURIComponent(top.sfframe.document.searchform.context.value) : '') + '&noneof=' + encodeURIComponent(top.sfframe.document.searchform.noneof.value) + '\n' + '\n\nCL!P download address: http://www.labage.be/setup/clip-setup.exe\n');
    window.open(url, '_self', '');
};

function requestInfo2(productId, request) {
    if (request.readyState == 4 && request.status == 200) {
        var url = request.responseText;
        if (url != '') {
            window.open(url, '_self', '');
        };
    };
};

function addToCart(lnk, productId, referer) {
    var request = createRequest();
    if (request) {
        var url = 'addtocart.html' + '?sid=' + top.sfframe.document.searchform.sid.value + '&qid=' + top.sfframe.document.searchform.qid.value + '&pid=' + productId + '&ref=' + referer;
        request.open('GET', url, true);
        request.onreadystatechange = function () {
            addToCart2(lnk, productId);
        };
        request.send(null);
    };
    return false;
};

function onloadOthersApply() {
    var cookieval = '';
    var tmpArr31 = document.optionsform.othersright.options;
    for (var tmpI32 = 0; tmpI32 < tmpArr31.length; tmpI32 = tmpI32 + 1) {
        var option = tmpArr31[tmpI32];
        cookieval = cookieval == '' ? option.value : cookieval + '&' + option.value;
    };
    var oldTable = top.sfframe.document.getElementById('extsearch');
    var oldTableParentNode = oldTable.parentNode;
    oldTableParentNode.removeChild(oldTable);
    var table = top.sfframe.document.createElement('table');
    table.className = 'ie';
    table.setAttribute('id', 'extsearch');
    oldTableParentNode.appendChild(table);
    var tbody = top.sfframe.document.createElement('tbody');
    table.appendChild(tbody);
    var noptions = document.optionsform.othersright.options.length;
    var row = top.sfframe.document.createElement('tr');
    tbody.appendChild(row);
    var cell = top.sfframe.document.createElement('td');
    cell.className = 'extheader';
    cell.setAttribute('colspan', '2');
    row.appendChild(cell);
    var text = top.sfframe.document.createTextNode('Search in');
    cell.appendChild(text);
    if (noptions > 0) {
        var option = document.optionsform.othersright.options[0];
        var row = top.sfframe.document.createElement('tr');
        tbody.appendChild(row);
        var cell = top.sfframe.document.createElement('td');
        cell.className = 'exttop';
        cell.setAttribute('colspan', '2');
        row.appendChild(cell);
        addExtsearchLink(cell, option);
        var text = top.sfframe.document.createTextNode(' (default)');
        cell.appendChild(text);
    };
    var row = null;
    var leftcol = true;
    var tmpArr33 = otherSearchEngines(document.optionsform.othersright.options);
    for (var tmpI34 = 0; tmpI34 < tmpArr33.length; tmpI34 = tmpI34 + 1) {
        var option = tmpArr33[tmpI34];
        if (leftcol) {
            row = top.sfframe.document.createElement('tr');
            tbody.appendChild(row);
        };
        var cell = top.sfframe.document.createElement('td');
        if (leftcol) {
            cell.className = 'extleft';
        } else {
            cell.className = 'extright';
        };
        row.appendChild(cell);
        if (option) {
            if (option == '<more>') {
                addMoreLink(cell);
            } else {
                addExtsearchLink(cell, option);
            };
        } else {
            var text = top.sfframe.document.createTextNode('\xA0');
            cell.appendChild(text);
        };
        leftcol = !leftcol;
    };
    return cookieval;
};

function cartOrderSelected() {
    var selectedRows = cartSelectedRows();
    if (selectedRows.length != 0) {
        if (window.confirm(selectedRows.length + ' items will be added to the email and removed from your cart. Are you sure?')) {
            var cart = readCookie('cart');
            var cartparams = '';
            var tmpArr85 = selectedRows;
            for (var tmpI86 = 0; tmpI86 < tmpArr85.length; tmpI86 = tmpI86 + 1) {
                var row = tmpArr85[tmpI86];
                var quantity = row.getElementsByTagName('input')[1].value;
                var comment = row.getElementsByTagName('input')[2].value;
                if (cartparams != '') {
                    cartparams += '&';
                };
                cartparams += rowidToProductid(row.id) + ':' + encodeURIComponent(quantity + ':' + comment);
                cart[rowidToProductid(row.id)] = null;
                row.id = null;
                row.style.display = 'none';
            };
            cartparams = 'cart=' + encodeURIComponent(cartparams);
            updateCartsize(cart);
            writeCookie('cart', cart, true);
            setCartActionsAvailability();
            var request = createRequest();
            if (request) {
                var url = 'orderproducts.html' + '?sid=' + top.sfframe.document.searchform.sid.value + '&qid=' + top.sfframe.document.searchform.qid.value;
                request.open('POST', url, true);
                request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
                request.setRequestHeader('Content-length', cartparams.length);
                request.setRequestHeader('Connection', 'close');
                request.onreadystatechange = function () {
                    cartOrderSelected2(request);
                };
                request.send(cartparams);
            };
        };
    };
};

function toggleRelated(pid) {
    var containerDiv = document.getElementById('pid' + pid).getElementsByTagName('div')[0];
    var anchorText = containerDiv.getElementsByTagName('p')[0].getElementsByTagName('a')[0].getElementsByTagName('span')[0].firstChild;
    var div = containerDiv.getElementsByTagName('div')[0];
    if (div.style.display == 'none') {
        anchorText.nodeValue = 'Collapse group';
        div.style.display = 'block';
    } else {
        anchorText.nodeValue = 'Expand group...';
        div.style.display = 'none';
    };
};

function setActionAvailability(input, available) {
    input.disabled = !available;
    if (!available) {
        input.blur();
    };
};

function emailSupport() {
    var url = 'mailto:' + at(at0) + '?subject=Help&body=' + encodeURIComponent('\n\nSearch words:\n' + 'And = ' + top.sfframe.document.searchform.search.value + '\n' + 'Context = ' + top.sfframe.document.searchform.curr_line.value + '\n' + 'Context flag = ' + top.sfframe.document.searchform.context.checked + '\n' + 'None of = ' + top.sfframe.document.searchform.noneof.value + '\n');
    window.open(url, '_self', '');
};

function requestInfo(productId, referer) {
    var request = createRequest();
    if (request) {
        var url = 'requestinfo.html' + '?sid=' + top.sfframe.document.searchform.sid.value + '&qid=' + top.sfframe.document.searchform.qid.value + '&pid=' + productId + '&ref=' + referer;
        request.open('GET', url, true);
        request.onreadystatechange = function () {
            requestInfo2(productId, request);
        };
        request.send(null);
    };
    return false;
};

function switchRec(window, allStyleClasses, newStyleClass) {
    var elems = window.document.getElementsByTagName('body');
    if (elems.length == 1) {
        var body = elems[0];
        var classes = body.className.split(/\s+/);
        var newClasses = '';
        var tmpArr54 = classes;
        for (var tmpI55 = 0; tmpI55 < tmpArr54.length; tmpI55 = tmpI55 + 1) {
            var cl = tmpArr54[tmpI55];
            var isStyleClass = false;
            var tmpArr56 = allStyleClasses;
            for (var tmpI57 = 0; tmpI57 < tmpArr56.length; tmpI57 = tmpI57 + 1) {
                var styleClass = tmpArr56[tmpI57];
                if (cl == styleClass) {
                    isStyleClass = true;
                };
            };
            if (!isStyleClass) {
                newClasses = newClasses == '' ? cl : newClasses + ' ' + cl;
            };
        };
        if (newStyleClass) {
            newClasses = newClasses == '' ? newStyleClass : newClasses + ' ' + newStyleClass;
        };
        body.className = newClasses;
    };
    var tmpArr58 = window.frames;
    for (var tmpI59 = 0; tmpI59 < tmpArr58.length; tmpI59 = tmpI59 + 1) {
        var frame = tmpArr58[tmpI59];
        switchRec(frame, allStyleClasses, newStyleClass);
    };
};

function addExtsearchLink(cell, option) {
    var anchor = top.sfframe.document.createElement('a');
    anchor.className = 'act';
    anchor.setAttribute('href', 'javascript:extsearch(\"' + option.value + '\");');
    cell.appendChild(anchor);
    var text = top.sfframe.document.createTextNode(option.innerHTML);
    anchor.appendChild(text);
};

function othersRemove() {
    var selectleft = document.optionsform.othersleft;
    var selectright = document.optionsform.othersright;
    var si = selectright.selectedIndex;
    if (si != -1 && document.optionsform.othersright.options.length > 1) {
        moveSelectedOption(selectright, selectleft, si, true);
    };
};

function cartCBAllOnClick() {
    var nRows = 0;
    var nSelectedRows = 0;
    var tmpArr69 = document.getElementById('carttable').getElementsByTagName('tr');
    for (var tmpI70 = 0; tmpI70 < tmpArr69.length; tmpI70 = tmpI70 + 1) {
        var row = tmpArr69[tmpI70];
        if (row.id) {
            ++nRows;
            if (row.getElementsByTagName('input')[0].checked) {
                ++nSelectedRows;
            };
        };
    };
    var newValue = nRows > nSelectedRows;
    var tmpArr71 = document.getElementById('carttable').getElementsByTagName('tr');
    for (var tmpI72 = 0; tmpI72 < tmpArr71.length; tmpI72 = tmpI72 + 1) {
        var row = tmpArr71[tmpI72];
        if (row.id) {
            row.getElementsByTagName('input')[0].checked = newValue;
        };
    };
    setCartActionsAvailability();
};

function optionsApply() {
    var options = readCookie('options');
    options['country'] = document.getElementById('country').value;
    options['language'] = '';
    var journal = '';
    var tmpArr19 = document.optionsform.journal;
    for (var tmpI20 = 0; tmpI20 < tmpArr19.length; tmpI20 = tmpI20 + 1) {
        var rb = tmpArr19[tmpI20];
        if (rb.checked) {
            journal = rb.value;
        };
    };
    options['journal'] = journal;
    options['bypass'] = document.optionsform.bypass.checked;
    options['cartto'] = trimString(document.optionsform.cartto.value);
    writeCookie('options', options);
    setCookie('extsearch', onloadOthersApply());
    window.history.back();
};

function cartBack() {
    window.history.back();
};

function options(name) {
    window.open('options.html' + (name ? '#' + name : ''), 'srframe');
};

function nullString(str) {
    return str.match(/^\s*$/);
};

function rowidToProductid(rowid) {
    return rowid.substring(4);
};

