
function popupPlayer (file, filetype) {
	if (!file) return;
	
	var
		availHeight	= screen.availHeight
	,	screenVersion = {
			h_501:	'668x501'	// 800x600
		,	h_660:	'880x660'	// 1024x768 or 1200x800
		,	h_900:	'1200x900'	// 1280x1024, 1600x1200, etc
		}
	,	size	= false
	,	height	= 'auto'
	,	width	= 'auto'
	,	type	= filetype || 'flash'
	,	URL		= '/shared/cfm/player.cfm?type='+ type
	;
	if (availHeight >= 950)			size = screenVersion.h_900;
	else if (availHeight >= 750)	size = screenVersion.h_660;
	else if (availHeight >= 550)	size = screenVersion.h_501;
	else {
		alert( 'Sorry. Your screen is too small to display the slideshow.' );
		return;
	}

	size	= size.split('x');
	width	= size[0];
	height	= size[1];

	URL += '&file='+ file +'_'+ height; // eg: ShopTrak_Overview_900
	URL += '&width='+ width +'&height='+ height;

	openWindow(
		URL
	,	{
			scrollbars:	false
		,	location:	false
		,	width:		width
		,	height:		height
		,	top:		0
		//,	fullscreen:	'yes'
		}
	);

	return false; // cancel hyperlink
}

function openWindow (URL, options) {
	if (!URL) return;
	var
		availHeight	= screen.availHeight
	,	availWidth	= screen.availWidth
	,	defaults	= {
			name:		"" // window name - optional
		,	height:		availHeight
		,	width:		availWidth
		,	top:		0
		,	left:		0
		,	resizable:	1
		,	status:		false
		,	scrollbars:	true
		,	menubar:	false
		,	toolbar:	false
		,	location:	true
		,	directories: false
		,	copyhistory: false
		,	fullscreen:	"no"
		,	dependent:	"no"
		}
	,	o		= $.extend({}, defaults, options)
	,	config	= ""
	;

	// VALIDATE width, height, top, left
	if (o.height < 1)
		o.height = Math.ceil(o.height * availHeight);
	if (o.width < 1) 
		o.width  = Math.ceil(o.width * availWidth);
	if (isNaN(o.height) || o.height > availHeight)
		o.height = availHeight;
	if (isNaN(o.width)  || o.width > availWidth)
		o.width = availWidth;
	if (o.height < availHeight && isNaN(options.top))
		o.top = Math.floor((availHeight - o.height) / 2);
	if (o.width < availWidth && isNaN(options.left))
		o.left = Math.floor((availWidth - o.width) / 2);

	// add Navigator syntax
	o.screenX = o.left;
	o.screenY = o.top;

	$.each(o, function (key, val) {
		if (key == "name") return; // SKIP 'window name'
		if (config) config += ",";
		config += key +"="+ (typeof val == "boolean" ? (val ? 1 : 0) : val);
	});
	//alert( 'openWindow - config \n\n'+ config );

	try {
		var win = window.open(URL, o.name, config);
		win.focus();
	}
	catch (e) {}
	finally { return false; } // to cancel hyperlink
};


