// JavaScript Document


/*
----------------------------(    Description    )----------------------------------------------
Create popup using this format:

<a href="pagename.php" onClick="return popup(this.href, 'type')" target="_blank">

where pagename.php is the path to the page to display in the popup and 'type' is the keyword to specify which type of popup is needed
If Javascript is enabled, the browser will follow the link in the onClick statement
If Javascript is disabled, the browser will open a popup using the user's default settings

Examples:

This will display an informational popup:
<a href="key.php" onClick="return popup(this.href, 'info')" target="_blank">

This will display a document popup:
<a href="financial.pdf" onClick="return popup(this.href, 'doc')" target="_blank">

---------------------------(    Specifications    )--------------------------------------------

Window Width specifies the width of the window in pixels.

Window Height specifies the height of the window in pixels.

Directories specifies whether the directories toolbar is shown (Links toolbar in IE).

Navigation Toolbar is the row of browser buttons that includes Back, Forward, Home, and Reload.

Location Toolbar is the row of browser options that includes the location text box.

Status Bar is the area at the bottom of the browser window in which messages (such as the load time remaining and the URLs associated with links) appear.

Menu Bar is the area of the browser window (Windows) or the desktop (Macintosh) where menus such as File, Edit, View, Go, and Help appear. You should explicitly set this option if you want visitors to be able to navigate from the new window. If you do not set this option, the user can only close or minimize the window (Windows) or close the window or quit the application (Macintosh) from the new window.

Scrollbars as Needed specifies that scroll bars should appear if the content extends beyond the visible area. If you do not explicitly set this option, scroll bars do not appear. If the Resize Handles option is also turned off, visitors have no easy way of seeing content that extends beyond the original size of the window. (Though they may be able to make the window scroll by dragging off the edge of the window.)

Resize Handles specifies that the user should be able to resize the window, either by dragging the lower-right corner of the window or by clicking the maximize button (Windows) or size box (Macintosh) in the upper-right corner. If this option is not explicitly set, the resize controls are unavailable and the lower-right corner is not draggable.

Window Name is the name of the new window. You should name the new window if you want to target it with links or control it with JavaScript. This name cannot contain spaces or special characters.

Reference: Open Browser Window, Dreamweaver 8

--------------------------------------------------------------------------------------------------
*/

function popup(page, type)
{
	/*Create the appropriate pop-up based on the type that was passed*/
	
	if(type == 'info')
	{
		createPopup_Info(page);
	}
	else if(type == 'doc')
	{
		createPopup_Doc(page);
	}
	else if(type =='external')
	{
		createPopup_External(page);
	}
	else if(type == 'video')
	{
		createPopup_Video(page);
	}
	else
	{
		/*use this profile if type is incorrectly specified*/
		createPopup_Default(page);
	}
	
	return false;
}

/*INFORMATION PROFILE: for displaying informational popups*/
function createPopup_Info(page)
{
	/*Set the window properties and then display the pop-up*/
	
	/*specify height and width of the popup window*/
	var width = 600;
	var height = 600;
	
	/*values used to center the window on screen*/
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;

	/*windowName is set so that new info popups will load into an already existing info popup window*/
	var windowName = 'infoPopup';

	/*specify the display properties for the window*/
	var properties = 'width='+width+',height='+height+',left='+left+',top='+top+',directories=no,location=no,menubar=yes,scrollbars=yes,status=yes,toolbar=no,resizable=yes';

	/*display the popup window*/
	var info = window.open (page, windowName, properties);
	
	/*ensure the popup is on top of any other windows*/
	if(window.focus)
	{
		info.focus();
	}
}

/*DOCUMENT PROFILE: for displaying documents*/
function createPopup_Doc(page)
{
	/*Set the window properties and then display the pop-up*/

	/*use '_blank' to open each popup in a new window*/
	var windowName = '_blank';
	
	/*display the popup window*/
	window.open (page, windowName);
}

/*EXTERNAL PROFILE: for displaying external web pages*/
function createPopup_External(page)
{
	/*Set the window properties and then display the pop-up*/
	
	/*use '_blank' to open each popup in a new window*/
	var windowName = '_blank';
	
	/*display the popup window*/
	window.open (page, windowName);
}

/*VIDEO PROFILE: for displaying video in a popup*/
function createPopup_Video(page)
{
	/*Set the window properties and then display the pop-up*/
	
	/*specify height and width of the popup window*/
	var width = 800;
	var height = 700;
	
	/*values used to center the window on screen*/
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;

	/*use '_blank' to open each popup in a new window*/
	var windowName = '_blank';

	/*specify the display properties for the window*/
	var properties = 'width='+width+',height='+height+',left='+left+',top='+top+',directories=no,location=no,menubar=no,scrollbars=no,status=no,toolbar=no,resizable=no';
	
	/*display the popup window*/
	window.open (page, windowName, properties);
}


/*DEFAULT PROFILE: has all settings enabled*/
function createPopup_Default(page)
{
	/*Set the window properties and then display the pop-up*/
	
	/*specify height and width of the popup window*/
	var width = 300;
	var height = 300;
	
	/*values used to center the window on screen*/
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;

	/*use '_blank' to open each popup in a new window*/
	var windowName = '_blank';

	/*specify the display properties for the window*/
	var properties = 'width='+width+',height='+height+',left='+left+',top='+top+',directories=yes,location=yes,menubar=yes,scrollbars=yes,status=yes,toolbar=yes,resizable=yes';
	
	/*display the popup window*/
	window.open (page, windowName, properties);
}
