
// POPUP WINDOW
function launchUrl(url, windowname, params, blockedmessage) 
{
	var isChrome = navigator.userAgent.toLowerCase().indexOf("chrome") != -1;
	if(isChrome && url == "about:blank") 
		return;
	
	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; 
}

function isLoaded()
{
	try {
		return BrowserHistory.getPlayer(null).isLoaded();
	} catch(e) {
//		alert(e);
	}
}

function setPosition(value)
{
	try {
		BrowserHistory.getPlayer(null).setMediaPlayerPosition(value);
	} catch(e) {
//		alert(e);
	}
}

// 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(){};
			}
		}
	}
}

/* temp fix for secure cookie issue with SFA: START */

function getEventId(){
	var qstring=location.search.substring(1);
	var pairs=qstring.split("&");
	for(var i=0;i<pairs.length;++i){
		var pairsplit=pairs[i].split("=")
		if (pairsplit[0]=="eventid") return pairsplit[1];
	}
}

function setEscapedSessionCookie(escapedName, escapedValue, path, domain) 
{
	if (path + "" == "undefined") {
		path = "/";
		}

	if (domain + "" == "undefined") {
		domain = ".on24.com";
		}

	document.cookie =
		escapedName + "=" + escapedValue
		+ ";path=" + path
		+ ";domain=" + domain 
		+ ";" ;
}

function setON24CommonCookie(eventid){
	setON24SlideCookie(eventid);
}

function setON24SlideCookie(eventid){
	try {
		setEscapedSessionCookie("s"+eventid, eventid, "/", location.host.substring(location.host.indexOf(".")));
	} catch (e){}
}

try{
	var eid = getEventId();
	if(eid) setON24CommonCookie(eid);
}catch(e){}

/* temp fix for secure cookie issue with SFA: END */
