﻿function showFondo(iSiteId, iLangId, iStoreId, sCollectionCode, sArt10, sArt160){
    var bModal;
    var iX;
    var iY;
    var iW = 975;
    var iH = 580;
    var sWinName = 'fondoPopWin';
    var sUrl;
    var sParams;
    
    if(iStoreId == undefined || isNaN(iStoreId)){
        iStoreId = 0;
    }
    if(iStoreId == 0){
        bModal = false;
    }else{
        bModal = true;
    }
    
    if(!isNaN(screen.availHeight)){
        iX = parseInt((screen.availWidth - iW)/2);
        iY = parseInt((screen.availHeight - iH)/2);
        iY = Math.max(0, iY-15);
    }else{
        iX = 5;
        iY = 5;
    }

    sUrl = 'provtapetsera/FondoCore/Viewer.aspx?si=' + iSiteId + '&li=' + iLangId + '&iStoreId=' + iStoreId;
    if ((hasValue(sCollectionCode)) && (hasValue(sArt10)) && (hasValue(sArt160))) {
        sUrl += '&cs='  + sCollectionCode + 'x' + sArt10 + 'x' + sArt160 
    }
    sParams = 'directories=no,height=' + iH + ',width=' + iW + ',hotkeys=no,menubar=no,resizable=no,toolbar=no,scrollbars=yes,screenx=' + iX + ',screeny='+ iY +',left=' + iX + ',top=' + iY;
    
    
    if(!bModal){
        myWin = window.open(sUrl, sWinName, sParams);
    }else{
        if (window.showModalDialog) {
            // IE style modal
            var iDlgH = iH+50;
            myWin = window.showModalDialog(sUrl, sWinName, 'dialogWidth:' + iW + 'px;dialogHeight:' + iDlgH + 'px;scroll:no;');
        }else{
            // Generic modal
            sParams += ',modal=yes';
            myWin = window.open(sUrl, sWinName, sParams);
        }
    }
    
    if(myWin.length) {
        myWin.focus();
    }
}

function hasValue(obj) {
    if (obj != undefined) {
        if (obj != '') {
            return true;
        }
    }
    return false;
}