function gEBI(id) {
    if (Boolean(document.getElementById)) {
        return document.getElementById(id);
    } else if (Boolean(document.all)) {
        return eval('document.all.' + id);
    }
}

function expup(artno, wid) {
    window.open('product_expectation.jsp?artno=' + artno + (typeof(wid) != 'undefined' ? '&w=' + wid : ''), artno, 'width=545,height=220,pixelstoolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0');
}

function picup(unid) {
    window.open('./product_image.jsp?fr=1&doc=' + unid, 'picture', 'scrollbars=yes,resizable=yes,toolbar=no,status=no');
}

function addFavouriteToBasket(siCode){
    var qtyField = gEBI('qty_' + siCode);
    if (qtyField){
        window.location = 'basket_add.jsp?prd=' + siCode + '&qty=' + qtyField.value +'&from=favourite.jsp';
    }
}

function popup(url,x,y) {
	var winopened = window.open(url,'popup','toolbar=no,status=no,width='+x+',height='+y + ',resizable=yes,scrollbars=yes');
    winopened.focus();
}

var  picOrder = 1;
var  picSelected = 1;
var  picCount = 0;
var  picShow = 0;
var picUrlPrefix = '';

function cursorPic(pic, selected) {
    if (selected == picSelected) {
        pic.style.cursor='default';
    } else {
        pic.style.cursor='pointer';
    }
}

function selectPic(pic, selected){
    picSelected = selected;
    img = gEBI('img_selected');
    img.src = picUrlPrefix + '_ss02_o' + picSelected;
    link = gEBI('img_link');
    link.href = picUrlPrefix + '_ss03_o' + picSelected;
    pic.style.cursor='default';
}

function showNextPic(){
    // neco delame, jen pokud jsou dalsi obrazky pro posunuti v pasu
    if (picOrder + picShow - 1 < picCount){
        // skryjeme prvni obrazek
        img = gEBI('img_thumb_' + picOrder);
        img.style.display = 'none';

        // zobrazime dalsi obrazek v poradi
        img = gEBI('img_thumb_' + (picOrder + picShow));
        img.style.display = 'inline';
        picOrder++;
    }
}

function showPrevPic(){
    if (picOrder > 1){
        picOrder--;

        // skryjeme posledni obrazek
        img = gEBI('img_thumb_' + (picOrder + picShow));
        img.style.display = 'none';

        // zobrazime predchozi obrazek
        img = gEBI('img_thumb_' + picOrder);
        img.style.display = 'inline';
    } 
}

function popupPic(){
    popup(picUrlPrefix + '_ss03_o' + picSelected, 800, 500);
}

function initPic(show, count, urlPrefix){
    picCount = count;
    picShow = show;
    picOrder = 1;
    picUrlPrefix = urlPrefix;
    for (i = 1; i <= picCount; i++){
        img = gEBI('img_thumb_' + i);
        if (i <= picShow){
            img.style.display = 'inline';
        } else {
            img.style.display = 'none';
        }
    }

    link = gEBI('img_link');
//    link.href = 'javascript:popupPic();';
}


var formSent = false;
function sendForm() {
    if (formSent) {
        return false;
    } else {
        formSent = true;
        return true;
    }
}

var helpCount = 0;
function initHelps(count) {
    helpCount = count;
    hideHelps();
}

function showHelp(help) {
    hideHelps();

    helpBox = gEBI('help_' + help);

    if (helpBox) {
        setTimeout(function foo(){
            helpBox = gEBI('help_' + help);
            helpBox.style.display = 'inline';
        }, 100);
    }
}

function hideHelp(help) {
    helpBox = gEBI('help_' + help);

    if (helpBox) {
        if (helpBox.style.display == 'inline') {
            helpBox.style.display = 'none';
        }
    }
}

function hideHelps() {
    for (i = 0; i < helpCount; i++) {
        hideHelp(i);
    }

    hideDwnldHelpBox();
}

function initDwnldHelpBox() {
    helpBox=gEBI('dwnld-help-box');

    if (helpBox) {
        helpBox.style.display = 'none';
    }
}

function hideDwnldHelpBox() {
    helpBox=gEBI('dwnld-help-box');

    if (helpBox) {
        if (helpBox.style.display == 'block') {
            helpBox.style.display = 'none';
        }
    }
}

function showDwnldHelpBox() {
    hideHelps();

    helpBox=gEBI('dwnld-help-box');

    if (helpBox) {
        setTimeout(function foo(){
            helpBox=gEBI('dwnld-help-box');
            helpBox.style.display = 'block';
        }, 100);
    }
}