/****************************************************
This funciton leverages the jquery and thickbox libraries
to create thickbox type functionality using popup
windows instead of inline div/iframe.
*****************************************************/

// Display translucent background and fire popup
function thickboxPopup(theLink, arguments)
{
	// Vars
	var height, width, leftPosition, topPosition;
	
	// Open up thickbox background effect
	tb_show(null, null, null);

	// Set thickbox to close when popup's opener gains focus again (popup closed or pushed to back)
	window.onfocus = tb_remove;
	
	// Grab link and break out params using code from Thickbox lib
	var queryString = theLink.href.replace(/^[^\?]+\??/,'');
	var params = tb_parseQuery( queryString );
	width = (params['width']*1) || 440;
	height = (params['height']*1) || 630;

	// Calculate position
	leftPosition = (screen.width-width)/2;
	topPosition = (screen.height-height-100)/2;

	// Set default arguments if none given
	if( arguments == undefined )
	{
		arguments = "toolbar=1,resizable=1,scrollbars=1";
	}

	// Pop open the window
	var win = window.open(theLink.href, "win",arguments+",width="+width+",height="+height+",left="+leftPosition+",top="+topPosition); 

	return false;
}
