// OfficePreviews shared code

function OpenPreview(s_url) 
{
    var w_s = 50;
    var h_s = 50;
    var w = window.screen.width;
    var h = window.screen.height;
    return popUp(s_url,'PreviewWin', w_s, h_s, w-2*w_s, h-2*h_s-50);
}

function OpenImages(id,f)
{
  var url = window.ffURL + 'index.php?page=images&id='+id+'&f='+f;
  var w = OpenPreview('');
  var d = w.document;
  var s = '<html>' +
            '<body style="overflow:auto;margin:0;padding:0;">' +
            '<ifr' + 'ame' +
            ' name="images_frame"' +
            ' width="100%"' +
            ' height="100%"' +
            ' frameborder=0' +
            ' src="' + url + '" ' +
            ' marginwidth="0"' +
            ' marginheight="0"' +
            ' vspace="0"' +
            ' hspace="0"' +
            ' allowtransparency="true"' +
            ' scrolling="yes">' +
            '</ifr' + 'ame>' +
            '</body>' +
            '</html>';
   d.write(s);
   d.close();
}

window.popupWins = new Array();

function popUp (sURL, sName, x, y, dx, dy) {

    if ( typeof( window.popupWins[sName] ) != "object" ){
        window.popupWins[sName] = 
            window.open(sURL, sName, 'left='+x+',top='+y+',width='+dx+',height='+dy+',scrollbars=1,resizable=1');
    } else {
        if (!window.popupWins[sName].closed) {
            if (sURL != '')
                window.popupWins[sName].location.href = sURL;
        } else {
            window.popupWins[sName] = 
                window.open(sURL, sName, 'left='+x+',top='+y+',width='+dx+',height='+dy+',scrollbars=1,resizable=1');
        }
    }

    window.popupWins[sName].focus();
    return window.popupWins[sName];

}

