
/* ========================================================================

	dbPopWin: db Popup Windows Plugin for JQuery - 04 Jul 08
	
	HOW TO USE
	
		Step 1) Ask yourself if you really need a popup Window. If you can't
		        get around the requirement. Proceed.

		Step 2) Copy the JS. Check to options below and use the example as
		        a guide.

	OPTIONS

		.dbPopWin(
			url: string,
			{
			dbPopWinWidth:      integer, [default 400],             the width of the popup window
			dbPopWinHeight:     integer, [default 400],             the height of the popup window
			dbPopWinY:          integer, [default centered],        position of the popup window from the left of screen
			dbPopWinX:          integer, [default centered],        position of the popup window from the top of screen
			dbPopWinTarget:     string,  [default 'dbPopWin'],      the name of the popup window
			dbPopWinScrollbars: string,  [default 'yes', 'no'],     whether scrollbars are allowed in the popup window
			dbPopWinResizable:  string,  [default 'no', 'yes'],     whether the popup window is resizable
			dbPopWinMenuBar:    string,  [default 'no', 'yes'],     whether the popup window has a menu bar
			dbPopWinAddressBar: string,  [default 'yes', 'yes'],    whether the popup window has an address bar
			}
		);

	EXAMPLE

		<p>Link to the <a href="http://hypertextjunkie.com/" rel="dbPopWin">Hypertext Junkie</a> web site</p>

		<script type="text/javascript" src="jquery-1.2.6.pack.js"></script>
		<script type="text/javascript" src="jquery.dbPopWin.js"></script>

		<script type="text/javascript">
			$(document).ready(function()
				{
					$('a[rel="dbPopWin"]').click(
						function()
						{
							return $.dbPopWin( $(this).attr('href'), { dbPopWinWidth: 800, dbPopWinHeight: 600 } );
						}
					);
				}
			);
		</script>

		Opens website in new 800x600 window in middle of browser screen.

======================================================================== */

jQuery.dbPopWin = function(url, options)
{

	options = jQuery.extend(
		{
			/* default options */
			dbPopWinWidth:      400,
			dbPopWinHeight:     400,
			dbPopWinTarget:     'dbPopWin',
			dbPopWinScrollbars: 'yes',
			dbPopWinResizable:  'no',
			dbPopWinMenuBar:    'no',
			dbPopWinAddressBar: 'yes'
		},
		options
	);

	/* center the window by default. */
	if (!options.dbPopWinY)
	{
		options.dbPopWinY = screen.height / 2 - options.dbPopWinHeight / 2;
	};
	if (!options.dbPopWinX)
	{
		options.dbPopWinX = screen.width / 2 - options.dbPopWinWidth / 2;
	};

	open(
		url,
		options['dbPopWinTarget'],
		'width= '      + options.dbPopWinWidth +
		',height='     + options.dbPopWinHeight + 
		',top='        + options.dbPopWinY + 
		',left='       + options.dbPopWinX + 
		',scrollbars=' + options.dbPopWinScrollbars +
		',resizable='  + options.dbPopWinResizable +
		',menubar='    + options.dbPopWinMenuBar +
		',location='   + options.dbPopWinAddressBar
	);

	return false;

};
