//-------------------------------------------------------------------------
// Script.js
//-------------------------------------------------------------------------


//-------------------------------------------------------------------------
// Function: openNewWindow. 
// Main benefit (with default features including all the control doodads) 
// over target="_blank" is that the new window probably doesn't 
// exactly overlay the old one.
//-------------------------------------------------------------------------

function openNewWindow(inURL, features, windowSize) {

    if (features == "") {
        features = "toolbar=yes,directories=yes,location=1,status=yes,menubar=yes,scrollbars=yes,resizable=yes";
    }
    
    var name = "X" + Math.abs((new Date()).getTime()); 
 
    var height=250;
    var width=350;
    var screenHeight = 480;
    var screenWidth = 640;

   if(windowSize == 'small')
   {
       height = 150;
       width = 200;
   }

    if (window.screen != null) // is null in really old browsers
    {
        screenHeight = window.screen.height;
        screenWidth = window.screen.width;
    }

    if (screenWidth > 640)
    {
        width = width + Math.floor((screenWidth - 640)*0.70);
    }

    if(screenHeight > 480)
    {
        height = height + Math.floor((screenHeight - 480)*0.70);
    }

    features += ",width=" + width + ",height=" + height;

    var docView = window.open (inURL, name, features);
    if (docView.focus) docView.focus();
}


function openNewPictureWindow(inURL, features, picXPix, picYPix) {

    if (features == "") {
        // Suppress toolbars b/c IE puts them INSIDE the height you specify.
        features = "toolbar=no,directories=no,location=0,status=no,menubar=yes,scrollbars=yes,resizable=yes";
    }
    
    var name = "X" + Math.abs((new Date()).getTime()); 
 
    var border_assumed = 50; // fudge
    var height=picYPix + border_assumed;
    var width=picXPix + border_assumed;
    var screenHeight = 480;
    var screenWidth = 640;

    if (window.screen != null) // is null in really old browsers
    {
        screenHeight = window.screen.height;
        screenWidth = window.screen.width;
    }

    if (screenWidth <= width)
    {
        width = Math.floor(0.9 * screenWidth);
    }

    if (screenHeight <= height)
    {
        height = Math.floor(0.8 * screenHeight);
    }

    var sizefeature = ",width=" + width + ",height=" + height;
    features += sizefeature;

    var docView = window.open (inURL, name, features);
    if (docView.focus) docView.focus();
}
