function showPrintPreview()
{
    showHideForPrint('normal_');
    showHideForPrint('print_');
}


function showHideForPrint(element)
{
    for(i=0; i<30; ++i){
        if(eval(document.getElementById(element + i))){
            var normalTag = document.getElementById(element+i);
            var normalDisplayValue = normalTag.style.display;
            normalTag.style.display = (normalDisplayValue == "block" || normalDisplayValue == "") ? "none" : "block";
        }
    }
}

function printPage()
{
    if (window.print) {
        window.print();
    }
}


// reload only when print preview flags are set... otherwise continue with
// unUnload action.
function checkPrintPreviewState(elDocument, elPath){
    if(eval(document.getElementById('print_0'))){
        var normalTag = document.getElementById('print_0');
        var normalDisplayValue = normalTag.style.display;
        if (normalDisplayValue == 'block'){
            showPrintPreview();
            if (navigator.appName.indexOf("Netscape") != -1) {
                window.location.reload();
            }else{ // fixes IE bug
                if ('/app/mymel/shopping_basket.jsp' == elPath){
                    // fix adding to shopping basket when the app
                    // redirectcs to the Catalog servlet
                    window.location = '/app/mymel/ShoppingBasket';
                }
                else if('/app/checkout/checkout.jsp' == elPath){
                    // fix checkout page that
                    // redirects to the ShoppingBasket servlet
                    window.location = '/app/checkout/Checkout';
                }
                else{
                    window.location = elDocument.location;
                }
           }
       }
    }
}
