﻿// JScript File: Popup a Window
function Popup(url, windowName, windowAttributes, htmlWindowContent) 
{
    //opens a popup after checking to see if one already open
    // parameters: url, window name, attribute string, htmlWindowContent (string of the html content for the popup  
    
    
    // example use <input type="button" value="test" onclick="Popup19_04_2006('TestContentRed.htm', 'newWindow', 'width=500,height500,left=250,top=200,resizable=no,scrollbars=no,toolbar=yes,location=no,status=no,menubar=no,copyhistory=no', 'htmlWindowContent')" />

    //width=300
    //Use this to define the width of the new window. 

    //height=200
    //Use this to define the height of the new window. 

    //resizable=yes or no
    //Use this to control whether or not you want the user to be able to resize the window. 

    //scrollbars=yes or no
    //This lets you decide whether or not to have scrollbars on the window. 

    //toolbar=yes or no
    //Whether or not the new window should have the browser navigation bar at the top (The back, foward, stop buttons..etc.). 

    //location=yes or no
    //Whether or not you wish to show the location box with the current url (The place to type http://address). 

    //directories=yes or no
    //Whether or not the window should show the extra buttons. (what's cool, personal buttons, etc...). 

    //status=yes or no
    //Whether or not to show the window status bar at the bottom of the window. 

    //menubar=yes or no
    //Whether or not to show the menus at the top of the window (File, Edit, etc...). 

    //copyhistory=yes or no
    //Whether or not to copy the old browser window's 


    if ( url != "" )
    {    
        //if "popupWindow" doesn't exist or has been closed closed
        if( typeof( popupWindow ) == "undefined" || popupWindow.closed )
        {    
            popupWindow = window.open( url, windowName, windowAttributes );
        }
        else //else if window already exists, just load URL into it
        {
            popupWindow.location=url;
        }
    }
    else if ( htmlWindowContent != "" )
    {
        //if "popupWindow" doesn't exist or has been closed closed
        if( typeof( popupWindow ) == "undefined" || popupWindow.closed )
        {    
            popupWindow = window.open( '', windowName, windowAttributes );
        }
        
        popupWindow.document.open();
        popupWindow.document.write(htmlWindowContent);
        popupWindow.document.close();
    }
    popupWindow.focus();
    return;

} 


function Popup_Image(src, width, height)
{
    if(typeof(imgWindow) != "undefined" && !imgWindow.closed){imgWindow.close()}
       
    var winAttributes = "width=" + width + ",height=" + height + ",resizable=no,scrollbars=no,toolbar=no,location=no,status=no,menubar=no,copyhistory=no"; 
    imgWindow = window.open( src, "imageWindow", winAttributes );

	return false;

} 


function ClosePopupImage_Onunload()
{
    if(typeof(imgWindow) != "undefined" && !imgWindow.closed){imgWindow.close()}
}

/* Standard function for backwards compatibility */
function popup(s,x,y) {
  window.open(s, 'popup'+x, 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width='+x+',height='+y);
}
