/*
FastcastMedia

Author: Unknown
Updated: Jonathan Mangano
Dependencies: BrowserInfo.js, PluginDetector.js, CookieLibrary.js
*/

function getBrowserStatus(browser) {
	if ( navigator.appName.toLowerCase().indexOf('microsoft') > -1 ) ie = true;
	else ie = false;		
		
	if (browser=="ie" && ie) return true;
	else if (browser=="netscape" && !ie) return true;
	else return false;	
}

function isMac() {
	if ( navigator.platform.indexOf ( "Mac" ) != -1 ) 
		return true;
	else
		return false;
}


function getFastCastType(PlayerType) {
	if ( PlayerType == 2 ) {
		return "Windows Media";
	} else if ( PlayerType == 3 ) {
		return "Both";
	} else if ( PlayerType == 1 ) {
		return "Real";
	}
}

var ie = getBrowserStatus("ie");
var netscape = getBrowserStatus("netscape");
var wma = hasWindowsMediaPlayer()=='u'?false:true;
var real = hasRealPlayer()=='u'?false:true;

function getFinalURL(PlayerType, FCU, RU) {
	var fcType = getFastCastType(PlayerType);	
	if ( isMac() ) {
		return null;		
	} else if ( ie && fcType=="Windows Media" ) {
		return FCU;
	} else if ( ie && fcType=="Both" ) {
		if ( wma ) return FCU;
		else if ( real ) return RU;
		else return null;		
	} else if ( netscape && fcType=="WindowsMedia" ) {
		return null;
	} else if ( netscape && fcType=="Both" ) {
		return RU;
	} else if ( fcType=="Real" ) {
		return RU;
	}	
}

function getFastcast(ID, Sequence, PlayerType, FCU, RU, WindowHeight, baseUrl) {
	var fcType = getFastCastType(PlayerType);	
	var url;	
	if ( ie && fcType=="Windows Media" ) {
		if ( wma ) url = FCU;
		else url = "/gpimgs/fastcast/shared/wmp.htm";
	} else if ( ie && fcType=="Both" ) {
		if ( wma ) url = FCU;
		else if ( real ) url = RU;
		else url = "/gpimgs/fastcast/shared/wmp.htm";		
	} else if ( netscape && fcType=="Windows Media" ) {
		url = "/gpimgs/FastCast/Shared/MSN.htm";
	} else if ( netscape && fcType=="Both" ) {
		if ( real ) url = RU;
		else url = "/gpimgs/fastcast/shared/real.htm";
	} else if ( fcType=="Real" ) {
		url = RU;
	} else if ( isMac() ) {
		url = "/gpimgs/fastcast/shared/mac.htm";
	}			

	if ( url != FCU && url != RU) {
		WindowHeight = 400;		
	} else {
		url = url + '&ref=' + fcPageType + '&video=' + Sequence + "&dist=" + distType + "&num=" + distNumber;
	}
	WindowWidth=700;
	leftPosition = (screen.width) ? (screen.width-WindowWidth)/2 : 0;
	topPosition = (screen.height) ? (screen.height-WindowHeight)/2 : 0;
	window.open(baseUrl+url,'','width=700,height='+WindowHeight+',screenX='+leftPosition+',screenY='+topPosition+',top='+topPosition+',left='+leftPosition+',menubar=no,resizable=yes,scrollbars=yes,status=yes,toolbar=no,location=no');
}

