
// POPUP WINDOW
function launchUrl(url, windowname, params, blockedmessage) 
{
	if (!windowname || ""+windowname=="null") 
		windowname = "";
	if (!params) 
		params = "";
	if (!blockedmessage || blockedmessage=="") 
		blockedmessage = "This window has been blocked. Please enable popups for this site and continue.";
	
	var myPopup = window.open(url, windowname, params);
	
	if (myPopup)
		myPopup.focus();
	else
		alert(blockedmessage);
}

function redirect(url) {
	location.href = url;
}

// REFRESH APPLICATION:
function refreshPage()
{
	window.location.reload()
}

// CLOSE APPLICATION:
function closeConsole()
{
	window.opener = null; 
	window.close()
}

// CHANGE TITLEBAR TEXT:
var titleText = "";
function changeTitleText(inText)
{
	titleText = inText;
	document.title = inText
}

// DISABLE PRINTING
function disablePrint()
{
	BrowserHistory.getPlayer(null).showmenu = false;
}

function fixAnchorTitleBug() 
{
	document.title = titleText; 
}


// CALLED ON UNLOAD OF BROWSER:
function prepUnload() {
	try {
		BrowserHistory.getPlayer(null).clearConsoleExternally();
	} catch(e) {
//		alert(e);
	}
	__flash_unloadHandler = function(){};
	__flash_savedUnloadHandler = function(){};

// for FireFox
	if (window.addEventListener) window.addEventListener("onunload", cleanupSWFs, false);

// for IE
	if (window.attachEvent) window.attachEvent("onunload", cleanupSWFs);
}

// for FireFox
if (window.addEventListener)
{
	window.onbeforeunload = prepUnload;
}
// for IE
if (window.attachEvent) 
{
	window.attachEvent("onbeforeunload", prepUnload);
}

/* fix for video streaming bug */
function cleanupSWFs() {
	var objects = document.getElementsByTagName("OBJECT");
	for (var i = objects.length - 1; i >= 0; i--) {
		objects[i].style.display = 'none';
		for (var x in objects[i]) {
			if (typeof objects[i][x] == 'function') {
				objects[i][x] = function(){};
			}
		}
	}
}
