// iStrip popup library 1.3.0

// Window specs
WIN_NARROWEST		= 80;	// Don't allow windows to be narrower than this width
WIN_SHORTEST		= 80;	// Don't allow windows to be shorter than this height
WIN_OFFSET_TOP		= 25;	// How far from the top of the screen to place windows
WIN_OFFSET_RIGHT	= 25;	// How far from the right of the screen to place windows
WIN_BORDER			= 6;	// Size of win-xp window borders
WIN_TITLE			= 30;	// Height of win-xp window titlebar
WIN_TASKBAR			= 30;	// Height of win-xp task bar
WIN_PS_NEWS_WIDTH	= 50;	// Width of news popup window, as a percentage of maximum width
WIN_PS_NEWS_HEIGHT	= 75;	// Height of news popup window, as a percentage of maximum height
WIN_PS_HELP_WIDTH	= 50;	// Width of help popup window, as a percentage of maximum width
WIN_PS_HELP_HEIGHT	= 90;	// Height of help popup window, as a percentage of maximum height

// Scripts to execute for generating popup content
SCRIPT_HELP			= 'help/index.html';
SCRIPT_STRIP		= 'viewfile.php?mode=strip&strip_id=';
SCRIPT_NEWS			= 'viewfile.php?mode=news&strip_id=';

function popup(theURL,winName,features)
{
	// Pop up window
	window.open(theURL,winName,features);
}

function popstrip (strip_id,win_width,win_height)
{
	need_sb = 'no';
	// Prevent window exceeding screen size limits, enable scrollbars if it would have
	if (win_width > screen.width - (WIN_BORDER * 2) - (WIN_OFFSET_RIGHT * 2))
	{
		win_width = screen.width - (WIN_BORDER * 2) - (WIN_OFFSET_RIGHT * 2);
		need_sb = 'yes';
	}
	if (win_height > screen.height - WIN_TITLE - WIN_BORDER - WIN_TASKBAR - (WIN_OFFSET_TOP * 2))
	{
		win_height = screen.height - WIN_TITLE - WIN_BORDER - WIN_TASKBAR - (WIN_OFFSET_TOP * 2);
		need_sb = 'yes';
	}
	// Prevent window opening below minimim size
	if (win_width < WIN_NARROWEST)
		win_width = WIN_NARROWEST;
	if (win_height < WIN_SHORTEST)
		win_height = WIN_SHORTEST;
	// Calculate top-left corner of window
	win_left = screen.width - win_width - (WIN_BORDER * 2) - WIN_OFFSET_RIGHT;
	win_top = WIN_OFFSET_TOP;
	// Pop up window
	popup (SCRIPT_STRIP + strip_id,'strip' + strip_id,'resizable=yes,scrollbars=' + need_sb + ',width=' + win_width + ',height=' + win_height + ',top=' + win_top + ',left=' + win_left);
}

function popnews (news_id)
{
	// Calculate window size and pos
	win_width	= ((screen.width - (WIN_BORDER * 2) - (WIN_OFFSET_RIGHT * 2)) / 100) * WIN_PS_NEWS_WIDTH;
	win_height	= ((screen.height - WIN_TITLE - WIN_BORDER - WIN_TASKBAR - (WIN_OFFSET_TOP * 2)) / 100) * WIN_PS_NEWS_HEIGHT;
	win_left 	= screen.width - win_width - (WIN_BORDER * 2) - WIN_OFFSET_RIGHT;
	win_top 	= WIN_OFFSET_TOP;
	// Pop up window
	popup (SCRIPT_NEWS + news_id,'news' + news_id,'resizable=yes,scrollbars=yes,width=' + win_width + ',height=' + win_height +',top='+ win_top +',left=' + win_left);
}

function pophelp (help_id)
{
	// Calculate window size and pos
	win_width	= ((screen.width - (WIN_BORDER * 2) - (WIN_OFFSET_RIGHT * 2)) / 100) * WIN_PS_HELP_WIDTH;
	win_height	= ((screen.height - WIN_TITLE - WIN_BORDER - WIN_TASKBAR - (WIN_OFFSET_TOP * 2)) / 100) * WIN_PS_HELP_HEIGHT;
	win_left 	= screen.width - win_width - (WIN_BORDER * 2) - WIN_OFFSET_RIGHT;
	win_top 	= WIN_OFFSET_RIGHT;
	// Add the hash mark as needed
	if (help_id != '')
		help_id = '#' + help_id;
	// Pop up window
	popup (SCRIPT_HELP + help_id,'help','resizable=yes,scrollbars=yes,width=' + win_width + ',height=' + win_height +',top='+ win_top +',left=' + win_left);
}
