/*******************************************************************************
 *  Abacast ADSP JavaScript Functions
 *  Implements Abacast Plugin Control
 *
 *  Copyright (c) 2001-2005 Abacast, Inc. All rights reserved World Wide.
 *  Version 2.44
 *******************************************************************************/

var aba_alert_noClient   = 'Before the stream can begin, you will need to download \n'+ 
                           'and install the Abacast streaming media software. Please\n'+
                           'click OK below to download the current Abacast software.';

var aba_alert_noClientIE = 'Before the stream can begin, you will need to download\n'+ 
                           'and install the Abacast streaming media software. Please\n'+
                           'click OK below, then choose OPEN or RUN FROM LOCATION to\n'+
			     		   'install the current Abacast software.';

var aba_alert_noClientIESP2 = 'You are attempting to tune into an Abacast Enabled stream.\n\n'+
						   'Abacast Enabled means...\n'+
						   '  * Higher Quality Stream\n'+
						   '  * More stable connection\n'+
						   '  * No "Server Full" messages\n'+
						   '  * Sharing the experience!\n\n'+
						   'To Install the FREE Abacast streaming media plugin complete the following:\n'+
						   '  1) Click the OK button on this dialogue.\n'+
						   '  2) Click the RUN button on the following dialogue.\n'+
						   '  3) Click the RUN button on the next dialogue\n\n'+
						   'If you have questions or comments, please contact us at support@abacast.com\n'+
						   'or to find out more, visit us at www.abacast.com!';

var aba_alert_noClientNS = 'You are attempting to tune into an Abacast Enabled stream.\n\n'+
						   'Abacast Enabled means...\n'+
						   '  * Higher Quality Stream\n'+
						   '  * More stable connection\n'+
						   '  * No "Server Full" messages\n'+
						   '  * Sharing the experience!\n\n'+
						   'To Install the FREE Abacast streaming media plugin complete the following:\n'+
						   '  1) Click the OK button on this dialogue.\n'+
						   '  2) Click the SAVE button on the following dialogue.\n'+
						   '  3) Click the OPEN or RUN to install the file once it has downloaded. You may need to open the download manager first by pressing ctrl+j on your keyboard\n\n'+
						   'If you have questions or comments, please contact us at support@abacast.com\n'+
						   'or to find out more, visit us at www.abacast.com!\n\n'+
						   'Please note: you may have to click the stream link again to start the stream\n'+
						   'after installation.';
			   
var aba_alert_WrongOS   =  'Abacast streaming media software currenly\n'+
                           'only supports the Windows 98 and above.';
						   
var aba_alert_WrongBrow =  'The Abacast streaming media software currently Supports\n'+
                           'MS Internet Explorer and Netscape Browsers versions 4.0+.\n'+
                           'Please update your browser to listen to the Abacast Stream.';

var aba_alert_MacNoWMP =   'Before the stream can begin, you must first download\n' +
                           'and install Windows Media Player for Mac. Please go to n' +
                           'http://windowsmedia.com/download to get Media Player for Mac.';
					 
var aba_alert_MacNoSupport='Abacast is committed to Macintosh users.  Development' +
                           'of a Macintosh client is planned, but not yet complete.' +
                           'Thank you for your patience.';

var aba_alert_NOWMPNS =    'Your Browser does not support this Embedded Windows Media Player.\n'+
                           'A Stand-Alone media player will now open.';

var aba_alert_AOL9    =    'Dear AOL 9.0 Listener,\n\n'+
                           'AOL version 9.0 software may impair your ability to tune into\n'+
                           'this broadcast.  If so, please try using AOL version 8.0.\n\n'+
                           'If you would like additional information please contact us\n'+
                           'by clicking on support.abacast.com.  Thank you.'; 
		   
var aba_alert_NoFou    =   'This stream is currently offline or unreachable.\n' +
                           'Please contact the stream provider.\n\n' +
                           'Thank you'; 
						   
var aba_alert_Popup    =   'This stream requires that we open a new window. ' +
                           'This is NOT used for advertising or SPAM.\n\n' +
						   'If the stream has failed to start, please allow '+
                           'popups from this web page to connect to the stream.\n\n' + 
						   'Thank you!'; 
						   
var aba_alert_Embedded =   'Streaming Media...\n\n'+
                           'A bug in this browser impares streaming operation.\n'+
						   'Windows Media Player will now open to play the stream.';
						   
var aba_alert_NeedClient = 'This stream requires a FREE media player plug-in.\n'+
                           'If you choose not to install or are unable to install\n'+
						   'the plug-in you will not be able to connect to the stream.';
						   
function alert_WrongOSasx(asx){
  var str =  'Abacast streaming media software currenly \n'+
             'only supports the Windows Operating System.\n'+
             'To manually connect to the stream, open\n'+
             ' ' + asx + '\n'+
             'with your favorite asx file interpreter.';						   
  alert(str);
}		   


//////////////////////  GLOBAL VARIABLES  /////////////////////////////
var CABDownloadFailed  = false;
var aba_done_loading   = false;
var aba_has_wmp7_up    = null;
var aba_has_wmp9_up    = null;
var g_update_flag      = false;
var g_gateway_asx      = null;
var g_gateway_done     = false;
var g_gateway_running  = false;
var g_gateway_launched = false;
var g_gateway_launch_error_count = 0;
var g_wmp_overlay      = false;
var g_wmp_uimode       = "full";
var g_abc_mp3          = false;
var g_aba_downloading  = false;
var g_popup_open       = false;
var g_InstallTimer    = null;
var g_PopupTimer      = null;
var g_tmo_stop        = null;
var g_tmo_playchk     = null;
var g_tmo_unitest     = null;
var g_tmo_launchasx   = null;
var g_tmo_startplayer = null;
var g_tmo_estatecheck = null;
var g_tmo_cookiecheck = null;
var g_adsps       = false;
var g_timesup     = false;
var g_uofc        = false;
var g_WMPVersion  = null;
var g_asxurl      = null;
var g_do_unicast  = true;
var g_go_abacast  = null;
var g_uniasxurl   = null;
var g_url         = null;
var g_aba_Popup   = null;
var g_mp_embed    = null;
var g_secure      = false;
var g_mp_hidden   = false;
var g_using_wmp7  = false;
var g_use_wmp7    = false;
var g_trialstream = false;
var g_mp_playing  = false;
var g_mp_embed_firefox = false;
var g_mp_port     = 4001;
var g_mp_attempt  = 0;
var g_streaming   = false;
var g_timeout     = false;
var g_unicastasx	= null;
var g_version       = null;
var g_version_major = null;
var g_version_minor = null;
var g_abci_rc       = null;
var g_is_installed  = false;
var g_registry      = true;
var g_displayerrors = false;
var g_dirty_version = true;
var g_AltDownloadID = "";

// wmp visual modifiers
var g_mp_stretchtofit  = false;
var g_mp_fullscreen    = false;
var g_mp_style         = null;
var g_mp_autosize      = false;

var g_version_forced  = false;
var aba_is_ie_patched = false; 
var call_off_launch   = false;
var g_enable_context_menu = true;
var g_uof_cookie      = 'abc_install';
var g_uof_cookie_inst = aba_has_uofc();
var g_ForceClientUpdate  = true;
var g_ClientVersionArray = null;
var g_CabDownloadURL  = 'http://www0.abacast.com/download/webinstall.php';
var g_WebInstallURL   = 'http://www0.abacast.com/download/webinstall/index.php';
var g_CabDownloadPath = 'http://download.abacast.com/download/files/';
var g_ExeDownloadPath = 'http://download.abacast.com/download/files/';
var g_ScriptURL     = 'http://scripts.abacast.com/scripts/';
var g_ASXServerURL  = 'http://asx.abacast.com/';
var g_ExeFilename   = 'abasetup.exe';
var g_NSExeFilename = 'ns_abasetup.exe';
var g_BetaStreamArray = new Array('digitalrapids','synapse','sunplus','kcxx-wm-64',':80/smoothjazz','abacast-beta-548','jetmultimedia','planetarygrid','k104fm','heritage','foreverofpa-woginet-64','megstreamtest-megstreamtest-1200','spur_tree_corp','tphdirekt','canadiancopticcentre','miratv-miratv-500', 'futurestream','sportsjuice','247mgivideo','glory_star','idhun', 'abacast-mars2','blackfunnel-wede-300','blackfunnel-wjys-300','tvworldwide','wpt-wpt-250','wpt-test-250','steveweedproductions-stream1-300','knm-live100-100','knm-live150-150','dtt-dttstream-150','tvnet','pando_networks','ondemandvideo','edgewoodproductions','mariovideo','nexcast','shopsandsalons','dlivetv','vinagame');

if (typeof (g_use_https) == 'undefined') {
	var g_use_https = false;
} 

function setBetaParms ()
{
	g_ExeFilename   = 'AbacastClient2.1.20.3.exe';	
	var g_NSExeFilename = 'AbacastClient2.1.20.3.exe';
}

// these are the stations that will NOT get the frame download
var g_DownloadUpdateList = new Array ('_wxrv_','kblg','kxtl','insidesports','internet_solutions','internetsportsnetwork','iptv','prophet_yahweh','qtinfo','north','south','webfxserver','xxxsmoothjazz','jazztrax','KJAC','radiovouzela');
var g_DownloadUpdateListEmbedded = new Array ('countrybear');
var DEBUG = false;



////////////// Browser, OS and WMP Detection Code /////////////////////
var aba_CSAg = window.navigator.userAgent;
var aba_agt = navigator.userAgent.toLowerCase();
var aba_appVer = navigator.appVersion.toLowerCase();
var aba_iePos  = aba_appVer.indexOf('msie');
var aba_is_opera = (aba_agt.indexOf("opera") != -1);
var aba_is_ie    = ((aba_iePos!=-1) && !aba_is_opera);
var aba_is_sp2   = (window.navigator.userAgent.indexOf("SV1") != -1);
var aba_is_win   = ((aba_agt.indexOf("win")!=-1) || (aba_agt.indexOf("16bit")!=-1));
var aba_is_vista = (aba_agt.indexOf("nt 6.0") != -1);
var aba_is_wince = ((aba_agt.indexOf("wince")!=-1) || (aba_agt.indexOf("windows ce")!=-1));
var aba_is_win95 = ((aba_agt.indexOf("win95")!=-1) || (aba_agt.indexOf("windows 95")!=-1));
var aba_is_minor = parseFloat(aba_appVer);
var aba_is_major = parseInt(aba_is_minor);
var aba_is_Netscape = (navigator.appName); //returns 'Netscape' if true
var aba_nav6Pos = aba_agt.indexOf('netscape6');

var aba_is_webtv = (aba_agt.indexOf("webtv") != -1);
var aba_is_msntv = (aba_agt.indexOf("msntv") != -1);
var aba_is_gecko = ((navigator.product)&&(navigator.product.toLowerCase()=="gecko"))?true:false;

var aba_is_moz = ((aba_agt.indexOf('mozilla/5')!=-1) && (aba_agt.indexOf('spoofer')==-1) &&
                 (aba_agt.indexOf('compatible')==-1) && (aba_agt.indexOf('opera')==-1)   &&
                 (aba_agt.indexOf('webtv')==-1)      && (aba_agt.indexOf('hotjava')==-1) &&
                 (aba_is_gecko) && ((navigator.vendor=="")||(navigator.vendor=="Mozilla")));
var aba_is_firefox = aba_agt.indexOf("firefox") != -1;
var aba_is_chrome = aba_agt.indexOf("chrome") != -1;
var aba_is_nav = ((aba_agt.indexOf('mozilla')!=-1) && (aba_agt.indexOf('spoofer')==-1)
                 && (aba_agt.indexOf('compatible') == -1) && (aba_agt.indexOf('opera')==-1)
                 && (aba_agt.indexOf('webtv')==-1) && (!aba_is_moz));
				 
var aba_is_navonly = (aba_is_nav && ((aba_agt.indexOf(";nav") != -1) || (aba_agt.indexOf("; nav") != -1)) );

if ((navigator.vendor)&&((navigator.vendor=="Netscape6")||(navigator.vendor=="Netscape"))&&(aba_is_nav)) {
	aba_is_major = parseInt(navigator.vendorSub);
	aba_is_minor = parseFloat(navigator.vendorSub);
}
// set real IE version
if (aba_iePos !=-1) {
	aba_is_minor = parseFloat(aba_appVer.substring(aba_iePos+5,aba_appVer.indexOf(';',aba_iePos)))
	aba_is_major = parseInt(aba_is_minor);
	aba_ie_minorvers = navigator.appMinorVersion
}


var aba_is_nav4   = (aba_is_nav && (parseInt(navigator.appVersion)==4))?true:false;
var aba_is_nav6up = (aba_is_nav && aba_is_minor >= 6);
var aba_is_nav7up = (aba_is_nav && aba_is_minor >= 7);
var aba_is_nav7   = (aba_is_nav && aba_is_major == 7);

var aba_is_mac     = (aba_agt.indexOf("mac")!= -1);
var aba_is_ie4     = (aba_is_ie && aba_is_major == 4);
var aba_is_ie5_up  = (aba_is_ie && aba_is_minor >= 5);
var aba_is_ie7_up  = (aba_is_ie && aba_is_minor >= 7);
var aba_is_ie5_5up = (aba_is_ie && aba_is_minor >= 5.5);

var aba_is_aol   = (aba_agt.indexOf("aol") != -1);
var aba_is_aol9  = (aba_agt.indexOf("aol 9") != -1);

var g_do_silverlight = !(aba_is_win && aba_is_ie);

// jwm 1/16/2007
if (aba_is_ie7_up) aba_is_sp2 = true;


var fHasWMP7 = navigator.mimeTypes && navigator.mimeTypes["application/x-drm-v2"] && navigator.mimeTypes["application/x-drm-v2"].enabledPlugin;

var aba_ns_has_plugin = (navigator.mimeTypes && navigator.mimeTypes["video/x-ms-wm"] && navigator.mimeTypes["video/x-ms-wm"].enabledPlugin && navigator.mimeTypes["video/x-ms-wmv"] && navigator.mimeTypes["video/x-ms-wmv"].enabledPlugin) ? true : false;
			

//////////////      CODE TO RUN ON PAGE LOAD      /////////////////////

/* write VB for abci_rc detection */
if (aba_is_win) {
	var s = '';
	s +='<script language="VBScript">\n';
	s +=' Function VB_Abacheck2()\n';
	s +='  On Error Resume Next\n';
	s +='  Set g_abci_rc = CreateObject("abci_rc3.TAbacastClientX")\n';
	s +='  If IsObject(g_abci_rc) Then \n';
	s +='    g_is_installed = True\n';	
	s +='  Else\n';
	s +='    Set g_abci_rc = CreateObject("abci_rc2.TAbacastClientX")\n';
	s +='    If IsObject(g_abci_rc) Then \n';
	s +='      g_is_installed = True\n';
	s +='    Else\n';
	s +='      Set g_abci_rc = CreateObject("abci_rc.TAbacastClientX")\n';
	s +=' 	   g_is_installed = IsObject(g_abci_rc)\n';
	s +='    End If\n';
	s +='  End If\n';	
	s +=' End Function\n';
	s +='</script>\n';
	document.writeln(s);
}


/* check for install on page load */
if (aba_is_ie) VB_Abacheck2();
var g_connecting = false;


/* write the iframe if the hidden frame isn't present */
try {
	if (!parent.aba_hiddenFrame) 
	{
		if (g_use_https) document.write('<iframe name="aba_iframe" frameborder=0 width=0 height=0 scrolling="no" src="https://secure.abacast.com/scripts/iframe/"></iframe>');
		else document.write('<iframe name="aba_iframe" frameborder=0 width=0 height=0 scrolling="no"></iframe>');		
		if ((document.all && document.all.aba_iframe) || window.frames['aba_iframe']) {
			if (aba_is_ie5_up) {	
				ed = document.getElementById("aba_iframe");
				if (g_use_https) ed.setAttribute("src", "/blank.html");
				else ed.setAttribute("src", "http://scripts.abacast.com/scripts/iframe/");
			}
		}
	}
} catch (e) 
{
	//ignore
	//alert ('iframe issue');
}
/* stop the state check interval and start the unicast stream if necessary */
function aba_EndStateCheck() {

	/* fields */
	var dbgmsg = 'ok';
	var launchfailed = false;

	/* clear the intercvals */
	if (g_tmo_unitest) clearInterval(g_tmo_unitest);
	if (g_tmo_estatecheck) clearTimeout(g_tmo_estatecheck);
	if (g_tmo_cookiecheck) clearTimeout(g_tmo_cookiecheck);

	/* embedded player */
	if (!g_streaming) { 
		g_timeout = true;
		if (g_mp_embed) {
			if (g_uniasxurl && !g_streaming) {
				aba_LaunchASX(g_uniasxurl);	
				dbgmsg = 'embedded player failed';
			}
		}
	
		/* stand-alone player - only need to act if FOU wasn't received */
		else if (g_abci_rc) {
			var fou  = g_abci_rc.ReadRegistry('FailOverURL');
			var len = fou.indexOf('?'); if (len == -1) len = fou.length;
			var asx1 = fou.slice(0, len);
			if (len > 0) {
				var asx2 = (g_uniasxurl) ? g_uniasxurl.slice(0, len) : "";
			} else {
				var asx2 = (g_uniasxurl) ? g_uniasxurl : "";
			}

			if ((asx1 != asx2) && g_uniasxurl) {
				g_abci_rc.OpenURL(g_uniasxurl);
				dbgmsg = 'fou failed';
			}
		} else if (g_uniasxurl) {
			aba_OpenURL(g_uniasxurl);
		} else {
			alert(aba_alert_NoFou);
		}
		
		// post message to event notifying failure
		if (typeof (abacastFailoverEvent) != 'undefined') {
			abacastFailoverEvent ();
		} 
	}
	
	if (typeof (abacastLaunchEvent) != 'undefined') {
		abacastLaunchEvent ();
	} 	
	
	if (DEBUG) window.status += 'EndStateCheck: '+dbgmsg;
}


/**
 * aba_StateCheck() -> void
 *
 * Called by aba_OpenAdsp to check for successful launch
 * If a launch has failed, start an alternate stream if present.
 */
function aba_StateCheck() {
	if (!aba_is_ie) {
		g_streaming = true;
		if (g_tmo_unitest) clearInterval(g_tmo_unitest);
		return;
	}
	if (g_is_installed) {
		var cstate = g_abci_rc.ClientState;
		var estate = g_abci_rc.ErrorState;
		if (DEBUG) window.status += ' '+cstate+' : '+estate+' ';
		if (estate != 0) {
			g_do_unicast = true;
		} else {
			if (cstate==0 && g_connecting==true) {
				// connect failed
				cstate=7;
			}
			if (cstate==1) {
				// entered connecting
				g_connecting = true;
			}
			else if (cstate==7) {
				// client flagged time for uc
				g_do_unicast = true;
			}
			else if (cstate>1) {
				// client has entered streaming mode
				if (g_tmo_unitest) clearInterval(g_tmo_unitest);
				g_streaming = true;
			}
		}
	}
	/* end the check */
	if (g_do_unicast)	{
		aba_EndStateCheck();
	}
}

// set cookie state on page load, check it periodically to see if its changed.
function aba_checkCookie (){
	if (g_mp_embed && (g_uof_cookie_inst != aba_has_uofc())) {
		document.location.reload(true);
	}
}
/////////////////////////// URL Functions /////////////////////////////
//
// v2.08 modified to search the local, parent, then top document with exception handling
//
function getURLParm(parm, seperator) {
	if (!parm) return ''; parm += '=';
	if (!seperator) seperator = '&';
	
	/* search this doc */
	var s = String(window.location).toLowerCase();
	var i = s.indexOf(parm,0);
	
	/* search the parent frameset */
	if (i == -1) {
		try {
			s = String(parent.window.location).toLowerCase();
			i = s.indexOf(parm,0);
		} catch (e) {
			i = -1;
		}
	}

	/* search the top frameset */
	if (i == -1) {
		try {
			s = String(top.window.location).toLowerCase();
			i = s.indexOf(parm,0);
		} catch (e) {
			i = -1;
		}
	}

	/* found parm, now get the value */
	if (i != -1) {
		/* move the index to the end of the parm */
		i += parm.length;
		if (i == s.length) return '';
		
		/* find the ampersand */
		ii = s.indexOf(seperator, i);
		if (ii == -1) ii = s.length;
		
		/* return the value */
		return s.substring(i, ii);
	}
	else return '';
}

//
// v2.08 modified to search the local, parent, then top document with exception handling
//
function aba_getURLParm(parm, seperator) {
	if (!parm) return ''; parm += '=';
	if (!seperator) seperator = '&';
	
	/* search this doc */
	var s = String(window.location);
	var i = s.indexOf(parm,0);
	
	/* search the parent frameset */
	if (i == -1) {
		try {
			s = String(parent.window.location);
			i = s.indexOf(parm,0);
		} catch (e) {
			i = -1;
		}
	}

	/* search the top frameset */
	if (i == -1) {
		try {
			s = String(top.window.location);
			i = s.indexOf(parm,0);
		} catch (e) {
			i = -1;
		}
	}

	/* found parm, now get the value */
	if (i != -1) {
		/* move the index to the end of the parm */
		i += parm.length;
		if (i == s.length) return '';
		
		/* find the ampersand */
		ii = s.indexOf(seperator, i);
		if (ii == -1) ii = s.length;
		
		/* return the value -- preserving case */
		return s.substring(i, ii);
	}
	else return '';
}

//
// v2.08 modified to search the local, parent, then top document with exception handling
//
function aba_HasURLParam(sz_name){
	if(!sz_name) return;
	var parmarray    = sz_name.split('=');
	var parm         = parmarray[0] + '='; 
	
	/* check this document address space */
	var s            = String(window.location).toLowerCase();
	var i            = s.indexOf(sz_name.toLowerCase(),0);
	var parmexists   = s.indexOf(parm.toLowerCase(),0);
	
	/* check the parent if the term or the paramater isnt found */
	if(i == -1) {
		try {		
			s = String(parent.window.location).toLowerCase();		
			i = s.indexOf(sz_name.toLowerCase(),0);
		} catch (e) {
			i = -1;
		}
	}
	
	/* check the top if the term or the paramater isnt found */
	if(i == -1) {
		try {
			s = String(top.window.location).toLowerCase();		
			i = s.indexOf(sz_name.toLowerCase(),0);
		} catch (e) {
			i = -1;
		}
	}
	
	return(i != -1);
}

function aba_has_local_parm(parm){
	if(!parm) return;
	var s = String(window.location).toLowerCase();
	var r = s.indexOf(parm.toLowerCase(),0);
	return(r != -1);
}

function aba_UrlContains (str)
{
	try {
		var s = String(window.location).toLowerCase();
		var r = s.indexOf(str.toLowerCase(),0);
		if (r != -1) return s;
	} catch (e) { 
		// ignore
	}
	
	try {
		var s = String(parent.window.location).toLowerCase();
		var r = s.indexOf(str.toLowerCase(),0);
		if (r != -1) return s;
	} catch (e) { 
		// ignore
	}
	
	try {
		var s = String(top.window.location).toLowerCase();
		var r = s.indexOf(str.toLowerCase(),0);
		if (r != -1) return s;
	} catch (e) { 
		// ignore
	}
	
	return false;
}

function aba_OpenURL(url, name, mode){ 
	var daf = null; 
	if(document.all) daf = document.all.aba_iframe;

	/* try the hidden frame first */
	try {
		if (parent.aba_hiddenFrame) {
			parent.aba_hiddenFrame.location.href = url;
			return;
		}
	} catch (e) {
	}
	
	// jm moving abc.openurl to the top of the list.
	// seems that using the iframe ruins the window.onload events.
	if (g_abci_rc) {
		g_abci_rc.OpenURL(url);
	}
	else if (aba_is_ie5_5up && daf) {
		daf.src=url;
	}
	else if (!aba_is_win && aba_is_moz) {
		win = window.open( url,name,'width=300,height=200,left=3000,top=0');
	}
	// this is throwing a perm issue in FF3 on mac.
	else if ((aba_is_moz || aba_is_nav6up) && window.frames['aba_iframe']) {
		setTimeout("window.frames['aba_iframe'].document.location.href='"+url+"';",100);
	}
	else if(mode=='hidden') {
		/* open a small window _off screen_ and close it after 5 seconds */
		if (!name) name='hwin';
		win = window.open( url,name,'width=101,height=101,left=3000,top=0');
		setTimeout('if(win && !win.closed) win.close()', 5000);
	}
	else if(mode=='download') {
		/* open a small window _off screen_ */
		if (!name) name='hwin';
		win = window.open( url,name,'width=101,height=101,left=3000,top=0');
	}
	else if(mode=='cabdownload'){
		/* open the cab download popup in the upper left hand corner */
		window.open(url,name, 'width=450,height=290,menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=yes,top=81,left=2');
	}
	else if (aba_is_opera) {
		document.location.href = url;
	}
	else {
		window.open(url);
	}
}

function aba_getAbsURL(file) {	
	if (!file) return '';
	if (file.indexOf('http://',0)!= -1) return file;
	if (file.indexOf('https://',0)!= -1) return file;
	
	var s = String(document.location);	
	var i = s.lastIndexOf('/', s.length);
	var r = s.substring(0,(i+1)) + file;
	return r;	
}


function aba_PrepareUrl (s) {
	if (!s) {
		var s = String (window.location);
	}	
	var c = s.charAt (s.length);
	
	if (s.indexOf ('&', 0) != -1) {
		if (c != '&') {
			s += '&';
		}
	} else if (s.indexOf ('?', 0) != -1) {
		if (c != '?') {
			s += '&';
		}	
	} else {
		s += '?';
	}
	
	return s;
}


///////////////////////////////////////////////////////////////////////
////////////////////////// Misc Functions /////////////////////////////
function aba_EmbedPlayer7() {
	if (aba_has_wmp7_up) return;
	document.write("<object ID='aba_MediaPlayer1' WIDTH='1' HEIGHT='1' CLASSID='CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6' CODEBASE='#Version=7,0,0,1954'></object>");
	g_WMPVersion = aba_MediaPlayer1.versionInfo; 
	aba_has_wmp7_up = (parseInt(g_WMPVersion) >= 7);
	aba_has_wmp9_up = (parseInt(g_WMPVersion) >= 9);	
}


function aba_DoUnicast() {
	var b1 = g_do_unicast;
	var b2 = aba_is_opera;
	var b3 = aba_is_win95;
	var b4 = aba_has_uofc();
	var b5 = aba_HasURLParam('fou=true');
	var b6 = aba_is_nav7up && g_mp_embed;
	var b7 = aba_is_mac; 			//added 08/19/04 by JF
	var b8 = aba_is_wince;			//added 12/20/04 by JM
	var b9 = aba_is_firefox && g_mp_embed;;	    //added 01/06/2004
	var b10 = aba_is_msntv;
	var b11 = aba_is_webtv;
	var b12 = aba_is_vista && g_abc_mp3;
	var b13 = aba_is_chrome;
	return (b1 || b2 || b3 || b4 || b5 || b6 || b7 || b8 || b9 || b10 || b11 || b12 || b13);
}

function aba_HasNsPlugin () {
	navigator.plugins.refresh(false);
	for (i = 0; i < navigator.plugins.length; i++) {
		if (navigator.plugins.item(i).name.indexOf ("Abacast v") != -1) {
			//alert ('found: '+navigator.plugins.item(i).name);
			var s = navigator.plugins.item(i).name.split (' ');
			if (s.length > 1) g_version = s[1];
			else g_version = 'v1.55'
			return true;
		}
	}
	return false;
}


//
// this method sets version requirements for stream, 
// checks installation state, unicast flags and 
// client version.
//
function aba_IsClientReady(name) {
	g_url = name;
	aba_SetVersionRequirements ();
	return (aba_VersionCheck() && !g_do_unicast);
}


function aba_IsClientInstalled() {
	if (aba_is_ie) {
		if (!g_is_installed) VB_Abacheck2();
		return (g_is_installed && g_version != '');
	}
	else {
		return aba_HasNsPlugin ();
	}
}


function aba_Download() {
	if (donew()){	
		abaNewDownload ();
		return;
	}
	aba_StartTimer();
	if (aba_is_ie) downurl = g_ExeDownloadPath + g_ExeFilename;
	else downurl = g_ExeDownloadPath + g_NSExeFilename;
	aba_OpenURL(downurl, 'download','download');
	g_dirty_version = true;
}


function aba_CABDownloadIE () {
	if (donew()){
		abaNewDownload ();
		return;
	}

	// updated webinstall.php page for iesp2 downloads, only supported for embedded players
	if (aba_is_sp2 && !g_mp_embed) {
		alert(aba_alert_noClientIESP2);
		//setTimeout("window.navigate('http://www.abacast.com/download/');",1);
		aba_Download();
	} else {
		stats = aba_getStats();	
		aba_OpenURL(g_CabDownloadURL+stats, 'download','cabdownload');
		aba_StartTimer();
		g_dirty_version = true;		
	}
}

// determines whether or not to run the new installation process
function donew () {

	// quicklaunch and secure stream unsupported at this time
	if (aba_UrlContains ("quicklaunch")) return false;
	if (g_url.indexOf ("token") != -1) {
		return false;
	}

	var url = g_url.toLowerCase();
	if (g_mp_embed) {
		for (i = 0; i < g_DownloadUpdateListEmbedded.length; i++) {
			if (url.indexOf (g_DownloadUpdateListEmbedded[i]) != -1) return false;
		}
	} else {
		for (i = 0; i < g_DownloadUpdateList.length; i++) {
			if (url.indexOf (g_DownloadUpdateList[i]) != -1) return false;
		}
	}
	return true;
}	


function abaNewDownload ()
{
	var url = g_WebInstallURL + aba_getStats();
	setTimeout("aba_ChangeTopLocation('"+url+"')", 1);
}

function aba_ChangeTopLocation (url) 
{
	try {
		top.document.location = url;
		return;
	} catch (e) {
	}
	
	try {
		parent.document.location = url;
		return;
	} catch (e) {
	}
	
	try {
		document.location = url;
	} catch (e) {
	}
}


function aba_OnCabDownloadFail(){
	CABDownloadFailed = true;
	CallGoAbacast();
}


function aba_getStats() {
	var width  = 760;
	var height = 480;
	var sid = g_url.split('/');
	var refid = (sid[1]) ? sid[1] : sid[0];
	
	
	try {
		var url = escape(top.document.location);
	} catch (e) {
		var url = escape(document.location);
	}
	
	// calculate frame size
	try {
		if (aba_is_ie) {
			width  = top.document.body.offsetWidth;
			height = top.document.body.offsetHeight;
			
			// width-height corrections
			if (height==0) {
				height = 480;	
			}
			if (width==0) {
				width = 760;	
			}			
			if (aba_is_ie7_up) {
				height += 55;
			}
		}
		else if (aba_is_nav) {
			width  = top.window.innerWidth;
			height = top.window.innerHeight;
		}
	} catch (e) {
		abaDebug ('exception reading frame size');
		width  = 760;
		height = 480;
	}
	
	// firefox's embedded player status is hacked, correct it here for proper download
	var embed;
	if (g_mp_embed_firefox) embed = g_mp_embed_firefox;
	else embed = g_mp_embed;
	
	// build stats
	var s  = '?refid='+refid+'&version='+g_version+'&url='+url;
	    s += '&a='+g_url+'&b='+escape(g_unicastasx)+'&c='+embed+'&d='+g_asxurl;
		s += '&t=' + (new Date()).getTime();
		s += '&w=' + width;
		s += '&h=' + height;
		
	return (s);
}


function aba_StartTimer() {
	g_InstallTimer = setInterval('aba_InstallCheck();',3000);
}


function aba_StopTimer() {
	clearInterval(g_InstallTimer);
}


function aba_InstallCheck() {

	// check for failure cookie
	if (aba_has_uofc()) {
		aba_StopTimer();
		setTimeout("CallGoAbacast();", 1);
		return;
	}

	// check for installation
	if (aba_IsClientInstalled()) {
		if (aba_is_ie) {
			g_dirty_version = true;
			if (aba_VersionCheck()) {			
				aba_StopTimer();
				setTimeout("CallGoAbacast();", 4000);
			}
		}
		else {
			aba_StopTimer();
			setTimeout("CallGoAbacast();", 4000);
		}
	}
}


function aba_resetPlayerState(){
	g_gateway_launched = false;
	g_gateway_done     = false;
	g_gateway_running  = false;
	g_connecting       = false
	g_gateway_launch_error_count = 0;
}


function aba_resetScriptState() {
	/* reset globals */
	port = 4001; 
	attempt = 0;
	g_timesup = false;
	g_streaming = false;
	g_dirty_version = true;

	/* reset timers and intervals */
	if (g_tmo_stop) clearTimeout(g_tmo_stop);
	if (g_tmo_playchk) clearTimeout(g_tmo_playchk);
	if (g_tmo_unitest) clearTimeout(g_tmo_unitest);
	if (g_InstallTimer) clearInterval(g_InstallTimer);
	if (g_tmo_launchasx) clearTimeout(g_tmo_launchasx);
	if (g_tmo_startplayer) clearTimeout(g_tmo_startplayer);
	if (g_tmo_estatecheck) clearTimeout(g_tmo_estatecheck);
	if (g_tmo_cookiecheck) clearTimeout(g_tmo_cookiecheck);	
}


function aba_getUnicastAsxUrl(asx) {
	aba_setUnicastAsxUrl (asx)
	return g_uniasxurl;
}


function setUnicastASX(asx) {
	aba_setUnicastAsxUrl(asx);
}

function aba_setUnicastAsxUrl(asx) {
	var s,p='';
	if (!asx || asx=='null') {
		g_uniasxurl = null;
		return;
	} 	
	
	if ((asx.indexOf('http://',0) != -1) || (asx.indexOf('.asx',0) != -1)) {
		g_uniasxurl = asx;
	} 
	else {
		g_uniasxurl = g_ASXServerURL + asx + '.asx';
	
		/* add query string for tracking purposes */
		if (g_mp_embed) s = 'true'; else s = 'false';
		if (g_timeout)  t = 'true'; else t = 'false';
 
		g_uniasxurl += '?ref=js&embedded='+s+'&timeout='+t+'&uofc='+aba_has_uofc();
	}
}


function aba_LaunchUnicastPlayer( name ){
	if (g_mp_embed) {
		if (g_uofc) {
			aba_LaunchASX(g_uniasxurl);
		}
		else return;
	} else {
		if (g_abci_rc) g_abci_rc.OpenURL(g_uniasxurl);
		else {
			if (aba_is_firefox) {
				aba_OpenURL (g_uniasxurl, 'firewin', 'hidden');
			} else {
				setTimeout("document.location=g_uniasxurl;", 2000);			
			}
		}
	}
}


function NS_AbaCheck() {

	if (aba_HasNsPlugin () && aba_VersionCheck()) {
		if (aba_is_nav6up || aba_is_moz || aba_is_firefox) {		
			aba_openADSP();			
		}
		else {
			var ip = aba_getAdspUrl();
			ip = ip.substr(7);
			//alert("aba_is_nav6up " + aba_is_nav6up + "\n" + "aba_is_moz " + aba_is_moz + "\n" + "aba_is_firefox " + aba_is_firefox);

			if (typeof(abacastInstallEvent) != 'undefined') {			
				abacastInstallEvent (ip);
			} else {			
				OpenWindow=window.open("", "newwin", 'width=278,height=100,menubar=no,scrollbars=no,toolbar=no,location=no,directories=no,resizable=yes,top=81,left=2');
				OpenWindow.document.write("<TI"+"TLE>Abacast Client...</TI"+"TLE>")
				OpenWindow.document.write("<BO"+"DY bgcolor=\"#C6D3DE\" background=\"http://www.abacast.com/images/loading_stream.gif\" >")
				OpenWindow.document.write("<em"+"bed hidden=true src=\"http://www.abacast.com/netscape/Abacast.aba\" AbaservIP="+ip+" type=\"application/x-plugin\" ");
				OpenWindow.document.write("></em"+"bed></BO"+"DY></HT"+"ML>");
				OpenWindow.document.close();
				setTimeout("if(!OpenWindow.closed) OpenWindow.close();", 2000);
			}			
			// start the embedded player if needed
			if (g_mp_embed) {
				g_tmo_startplayer = setTimeout("aba_StartPlayer()",1000); 
			}

		}
	}	
	else if (!aba_HasNsPlugin() && donew()) { 	
		aba_Download();
	}
	// this mean the NS plugin was installed and we're doing new install, but the NS plugin is the wrong version
	else if (aba_HasNsPlugin() && donew()) { 
		aba_Download();
	}	
	else {
		alert(aba_alert_noClientNS); //TEST TEST	
		aba_Download();		
	}
}

function aba_LaunchNS6(){
	if (aba_DoUnicast()) return;
	if (g_asxurl) url = g_asxurl;
	else url = "http://asx.abacast.com/StandAlonePlayer.asx";
	aba_OpenURL(url, "ns6win", "hidden");
}

function aba_getAdspUrl() {
	if (g_url.indexOf('?', 0) != -1) {
		separator = '&';
	} else {
		separator = '?';
	}
	
	if (g_adsps) protocol = 'adsps://';
	else protocol = 'adsp://';
	
	var s = protocol + g_url + separator;	
	if (g_mp_embed)       s += 'launchPlayer=false&';	
	if (!g_displayerrors) s += 'displayerrors=false&';	
	if (!g_mp_embed && g_asxurl) s += 'playlist='+aba_getAbsURL(g_asxurl)+'&';

	return s;
}


function aba_openADSP() {

	/* launch unicast stream */
	if (aba_DoUnicast()) {
		if (g_uniasxurl) {
			if (!g_mp_embed) {
				aba_OpenURL(g_uniasxurl);
			}
		}
		else { 
			alert('Sorry, the Abacast Stream is unavailable.\nPlease contact Abacast Support for assistance.');
		}
	}
	/* launch abacast stream */
	else {
	
		/* set the state test to capture failing clients, kill it after 30 seconds */
		g_tmo_unitest = setInterval("aba_StateCheck();",5000);
		g_tmo_estatecheck = setTimeout("aba_EndStateCheck();",30000);

		adsp_url = aba_getAdspUrl();
		
		if (DEBUG) {
			window.status += adsp_url;
			abaDebug (adsp_url);
			abaDebug ("adsp url length: "+adsp_url.length);
		}
		
		/* launch the client */
		if (g_abci_rc && g_use_https) g_abci_rc.OpenURL(adsp_url);
		else if (g_abci_rc && !g_adsps) g_abci_rc.OpenURL(adsp_url);
		else aba_OpenURL(adsp_url, 'Abacast_Launch', 'hidden');
		
		if (g_mp_embed) {
			g_tmo_startplayer = setTimeout("aba_StartPlayer()",1000); 
		}
	}
}


function CallGoAbacast(){
	if(!g_url) return;
	
	// if ForceUpdate Check for Update Completion and set fail flag if incomplete
	if(aba_is_ie && g_ForceClientUpdate){
		if(!aba_VersionCheck()) CABDownloadFailed = true;
	}	
	// launch main stream function with internal flag
	GoAbacast(g_url, g_uniasxurl, g_mp_embed, g_asxurl, g_gateway_asx, true);
}


function aba_SetVersionInformation() {
	if (!aba_is_win || !aba_is_ie || !g_dirty_version) return;

	/* get version info */
	if (g_abci_rc) {
		g_version = String(g_abci_rc.ReadRegistry('V2'));
		
		if (g_version == '' || g_version == 'unknown') {
			g_version = String(g_abci_rc.ReadRegistry('Version'));
		}
	}	

	/* if version wasn't read, set unknown */	
	if (!g_version || g_version == "" || g_version == 'null') {
		g_version = "unknown";
		g_registry = false;
	}

	/* update version info */
	g_version_major = parseInt(g_version);
	g_version_minor = parseFloat(g_version);
	g_dirty_version = false;
	return true;
}

function aba_VersionCheck(){
	if (!aba_IsClientInstalled()) return false;
	if (!g_ForceClientUpdate) return true;
	aba_SetVersionInformation();
	
	for (i = 0; i < g_ClientVersionArray.length; i++) {
		//if we find a matching version log it and return true
		if (g_version == g_ClientVersionArray[i]) {
			logger();
			return true;
		}
	}
	return false;
}

function aba_SetVersionRequirements () 
{
	var secure = false;
	if (g_url.indexOf ("token") != -1) {
		secure = true;
	}
	if (g_unicastasx && (g_unicastasx.indexOf ("media/pls") != -1)) {
		g_abc_mp3 = true;
	}
	if (g_url.indexOf ('dvsolutions') != -1) {
		g_WebInstallURL = 'http://webcast.dvsolutionsinc.com/remotewebinstall.php';
	}


	if (g_url.indexOf ('jumptv') != -1) {
		aba_ReplaceHost ('jumptv-enaljaz', 'enaljaz1.jumptv.abacast.com');
		aba_ReplaceHost ('jumptv-enchile', 'enchile1.jumptv.abacast.com');
		g_adsps = true;
		g_trialstream = true;
	}
	
	
	// not modifying version information, but setting adsps flag.  this is slightly redundant but required
	// at this level to use the IsClientReady() function.
	for (i = 0; i < g_BetaStreamArray.length; i++) {
		if (g_url.indexOf(g_BetaStreamArray[i]) != -1) {
			g_adsps = true;	
			setBetaParms();		
		}
	}	
		

	
	if (g_url.indexOf ('seneweb') != -1) {
		g_adsps = true;
	}		
	
	if (g_adsps && (g_use_https || g_trialstream)) {
		g_ClientVersionArray = new Array ('unknown','v2.1.20.1','v2.1b4','v2.1b3','v2.1.20.2','v2.1b2','v2.1.20.3','v2.1b3','v2.1','v2.1b7','v2.2','v2.3','v2.1b10','v2.1b13','v2.2b1','v2.2b2','v2.2b7','v2.2b8','v2.2b12','v2.2b17','v2.2b22','v2.3b0','v2.3b1','v2.3b2','v2.3b6','v2.3b7','v2.3b8','v2.3b10');
	}
	else if (g_adsps) {
		g_ClientVersionArray = new Array ('unknown','v2.0.20.3','v2.0b3','v2.0.20.4','v2.0b4','v2.0.20.5','v2.0b5','v2.0.20.6','v2.0b6','v2.0.20.7','v2.0b7','v2.0.30.0','v2.0','v2.0.30.1','v2.01','v2.0.30.2','v2.02','v2.1b3','v2.1b2', 'v1.64b1','v2.1b4','v2.1b7','v2.1b10','v2.1b13','v2.2b1','v2.2b2','v2.2b7','v2.2b8','v2.2b12','v2.2b17','v2.2b22','v2.3b0','v2.3b1','v2.3b2','v2.3b6','v2.3b7','v2.3b8','v2.3b10');
	}
	else if (secure || g_abc_mp3) {
		g_ClientVersionArray = new Array ('unknown','v2.0','v1.70b4','v2.0.20.3', 'v2.0b3','v2.0.30.0','v2.0','v2.0.30.1','v2.01','v2.0.30.2','v2.02','v2.1b3','v2.1b2', 'v1.64b1','v2.1b4','v2.1b7','v2.1b10','v2.1b13','v2.2b1','v2.2b2','v2.2b7','v2.2b8','v2.2b12','v2.2b17','v2.2b22','v2.3b0','v2.3b1','v2.3b2','v2.3b6','v2.3b7','v2.3b8','v2.3b10');
	} 
	else {
		g_ClientVersionArray = new Array ('unknown','v2.0','v1.70','v1.70b4','v2.0.20.3','v2.0b3','v2.0.20.4','v2.0b4','v2.0.20.5','v2.0b5','v2.0.20.6','v2.0b6','v2.0.30.0','v2.0','v2.0.30.1','v2.01','v2.0.30.2','v2.02','v2.1b3','v2.1b2', 'v1.64b1','v2.1b4','v2.1b7','v2.1b10','v2.1b13','v2.2b1','v2.2b2','v2.2b7','v2.2b8','v2.2b12','v2.2b17','v2.2b22','v2.3b0','v2.3b1','v2.3b2','v2.3b6','v2.3b7','v2.3b8','v2.3b10');
	}

	for (i = 0; i < g_BetaStreamArray.length; i++) {
		if (g_url.indexOf(g_BetaStreamArray[i]) != -1) {
			g_ClientVersionArray = new Array ('v2.1b3','v2.1b3','v2.1b2','v2.1b4','v2.1b7','v2.2b1','v2.2b2','v2.2b7','v2.2b8','v2.2b12','v2.2b17','v2.2b22','v2.3b0','v2.3b1','v2.3b2','v2.3b6','v2.3b7','v2.3b8','v2.3b10');
			/*if (g_url.indexOf("abacast.com") != -1) {		
				aba_ReplaceHost (g_url, '64.62.164.210');
			}*/
			if (g_url.indexOf("dlivetv") != -1) {		
				aba_ReplacePort (g_url, '443');
			}
			g_adsps = true;	
			setBetaParms();		
		}
	}	
		
}

// a good place to use aba_ReplaceHost ()
function aba_RedirectUrl () 
{
}

// example: aba_ReplaceHost ('boomer', '204.245.196.28');
function aba_ReplaceHost (host, newhost)
{
if (g_url.indexOf (host) != -1) 
	{
		g_url = newhost + g_url.substring(g_url.indexOf(":80"), g_url.length);
	}
}

function aba_ReplacePort (host, newport)
{
if (g_url.indexOf (host) != -1) 
	{
		g_url = g_url.replace("80",newport);
	}
}

function noLaunch ()
{
	// disable stream launch 10 seconds after page load to avoid onload launches
	// this may cause problems in embedded player streams but appears to be
	// necessary on stand-alone streams that launch on page load.	
	var t1 = aba_getURLParm ('lockcode');
	var t2 = (new Date()).getTime();
	if ((t1 != '') && (t2 - t1 < 5000)) return true;
	
	// disable streamlaunch when this page is embedded into the download frameset
	else if (aba_HasURLParam ("nolaunch")) return true;
	
	// no reason to disable launch
	else return false;
}

/*
 * GoAbacastDSN (abacastserver, unicast, embed_flag, dynamicasx, depricated, internal_flag)
 *
 * Sets the Adsps Flag and calls the core GoAbacast Function.  
 */  
function GoAbacastDSN ( url, uniasxurl, embed, asxurl, gateway_asx ) {
	g_adsps = true;
	GoAbacast( url, uniasxurl, embed, asxurl, gateway_asx );
}

/*
 * GoAbacast (abacastserver, unicast, embed_flag, dynamicasx, depricated, internal_flag)
 *
 * The main driver of this script file.  
 */  
function GoAbacast( url, uniasxurl, embed, asxurl, gateway_asx, b_internal ){

	// embed flag sanity check
	if (embed && (embed != true) && (embed != false)) {
		if (embed.indexOf('http', 0) != -1) {
			asxurl = embed;
			embed = false;
		}
	}		
			
	// embedded players in aol browser not supported, force standalone wmp.
	if (aba_is_aol) embed = false;

	// beta test version control
	// if (!aba_is_ie) g_do_unicast  = true;

	// if this page is loaded for writing a cookie, dont do anything else
	if (call_off_launch || noLaunch()) return;
	
	// cracked for non-ie browsers
	if ((url.indexOf("cracked") != -1) && !aba_is_ie) return;

	// seneweb trial for non-ie browsers
	if ((url.indexOf("seneweb-trial") != -1) && !aba_is_ie) return;

	// firefox embedded player inside of a frameset is broken, force to standalone.
	if (aba_is_firefox) {
		if (embed) g_mp_embed_firefox = true;
		//embed = false;
	}
	
	g_go_abacast = "GoAbacast('"+url+"', '"+uniasxurl+"', '"+embed+"', '"+asxurl+"', '"+gateway_asx+"')";

	/* set|reset timers and script state variables */
	if (!b_internal) {
		aba_resetPlayerState();
	}
	aba_resetScriptState();
	aba_SetVersionInformation();
	
	// check for cookie creation.
	if (!aba_is_wince) g_tmo_cookiecheck = setInterval ("aba_checkCookie()", 2000);

	//
	// Set var formats and store globals 
	//
	if (!embed || embed == '' || embed == 'null') embed = false;
	if (!asxurl || asxurl == '' || asxurl == 'null') asxurl = null;
	if (!uniasxurl || uniasxurl == '' || uniasxurl == 'null') uniasxurl = null;
	if (!gateway_asx || gateway_asx == '' || gateway_asx == 'null') gateway_asx = null;
	
	g_gateway_asx = gateway_asx;
	g_asxurl      = asxurl;
	g_url         = url;
	g_mp_embed    = embed;
	g_unicastasx  = aba_getUnicastAsxUrl (uniasxurl);
	
	aba_SetVersionRequirements();
	aba_RedirectUrl ();

	// Windows
	if (aba_is_win)	{
	
		if (aba_DoUnicast()) {
			if (g_uniasxurl) {
				aba_LaunchUnicastPlayer();
				return;
			}
			else {
				alert (aba_alert_NeedClient);
				return;
			}
		}

		// Internet Explorer
		if (aba_is_ie) {
			if (aba_IsClientInstalled() && !CABDownloadFailed) { /* Client is installed, and update has not already failed */
				if (g_ForceClientUpdate) {
					g_update_flag = true;
					if (!aba_VersionCheck()) {
						if (aba_is_ie4) aba_Download();
						else {
							aba_CABDownloadIE (true);
						}
						return;
					}
				}
				/* launch client */
				aba_openADSP();
			}
	
			/* Cab installation failed - open .exe manual download */
			else if (CABDownloadFailed){ 
				alert(aba_alert_noClientIE);
				aba_Download ();
			}
	
			else {
				if (aba_is_ie4) aba_Download ();
				else {									
					aba_CABDownloadIE (g_update_flag); // Client is not Installed, Cab Download has not failed - do CAB Install
				}
			}
		}	
	
		// Netscape
		else if (aba_is_nav || aba_is_moz || aba_is_firefox) {
			NS_AbaCheck ();
		}
	
		// Not supported and not in do_unicast list
		else {
			alert(aba_alert_WrongBrow);
		}
	}
	
	// Mac 
	else if (aba_is_mac) {
		if (!g_uniasxurl || (g_uniasxurl == 'null')) alert(aba_alert_MacNoSupport);		
		else aba_LaunchUnicastPlayer(g_uniasxurl);
	}
	
	// *NIX or Other
	else {
		if (g_uniasxurl) {
			alert_WrongOSasx (g_uniasxurl);	
		} else {
			 alert (aba_alert_WrongOS);	
		}
	}
}


////////////////////////////////////////////////////////////////////
///////// Abacast Embedded Windows Media Player Functions //////////

// 
// Writes Embedded Player Code into client html.  
//
function aba_EmbedPlayer(showcont, showstat, width, height, asx_name, sz_return)
{

	// seneweb trial for non-ie browsers
	if (asx_name && (asx_name.indexOf("seneweb-net") != -1) && !aba_is_ie) {g_do_unicast = true;}
	if (asx_name && (asx_name.indexOf("dvsolutions") != -1)) {g_do_unicast = true;}
	if (asx_name && (asx_name.indexOf("deer101") != -1)) {g_do_unicast = true;}

	//if (asx_name && (asx_name.indexOf("seneweb-net") != -1)) {g_do_unicast = true;}

	//
	// the player seems to be broken in NS6+ if in a frameset.
	// if in a frameset, exit the frameset.
	//
	//if (aba_is_nav6up || aba_is_mac) {
	if (aba_is_nav6up) {
		try {
			if (top.document.location.href != document.location.href) {
				top.document.location.href = document.location.href;
			}		
		} catch (e)  {
			// ignore
		}
	}
	
	var cont_height = 27;
	var stat_height = 24;
	var set_height  = false;
	var wmp = "";
	var style_text = '';

	/* check for hidden player */
	if( !width && !height && !showcont && !showstat) {
		if (aba_is_nav) { width=height=5; } // fix NS bad wont play if player size < 5
		g_mp_hidden=true;
	} 
	else g_mp_embed = true;  // needed to determine DoUnicast status
		
	if (!width && !height) { 
		width=255;
		if (showcont) { height  = cont_height; set_height = true; }
		if (showstat) { height += stat_height; set_height = true; }
	}
	else if (width && !height) {
		if (showcont) { height = cont_height; set_height = true; }
		if (showstat) { height += stat_height; set_height = true; }
	}
	if (height < stat_height) set_height = true;
	if (!width) width = 255;
	
	if (!showcont) showcont = "0"; 
	else if (!set_height) height += cont_height; // add 27px if showing controls
	if (!showstat) showstat = "0";
	else if (!set_height) height += stat_height; // add 24px if showing status
	
	aba_setUnicastAsxUrl(asx_name);
	if (call_off_launch) asx_name = null; // this prevents the player from starting when loaded inside the iframe during install...
	
	// check permission issues
	if (aba_UrlContains ("bcd23lkq09sf8d")) {
		g_do_unicast = true;		
	}
	
	if (asx_name) {
		if (asx_name.indexOf("klog") != -1) {
			g_do_unicast = true;
		}
		if ((asx_name.indexOf("cracked") != -1) && !aba_is_ie) {
			g_do_unicast = true;
		}
	}	
	
	// Gives us WM9 functions for launching stand alone player in asx mode (if it exists on the users system) and version information
	if (aba_is_ie) aba_EmbedPlayer7();  
	
	// if wmp7 is available, and we're told to use it, set the using global
	if (aba_has_wmp7_up && g_use_wmp7) g_using_wmp7 = true;
	
	// set the object filter
	if (g_mp_style && aba_is_ie) style_text = 'style='+g_mp_style; 
	
	// create the wmp object
	if (g_using_wmp7) {
		if (g_use_https) wmp += "<OBJ"+"ECT ID=\"aba_MediaPlayer\" "+style_text+" clas"+"sid=\"CLS"+"ID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" CODEBASE=\"https://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112\" TYPE=\"application/x-oleobject\" width="+width+"  height="+height+" align=\"middle\">";	// WMP 7 Control
		else wmp += "<OBJ"+"ECT ID=\"aba_MediaPlayer\" "+style_text+" clas"+"sid=\"CLS"+"ID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" CODEBASE=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,7,1112\" TYPE=\"application/x-oleobject\" width="+width+"  height="+height+" align=\"middle\">";	// WMP 7 Control
		var s = "URL";
	}
	else {
		if (g_use_https) wmp += "<OBJ"+"ECT ID=\"aba_MediaPlayer\" "+style_text+" clas"+"sid=\"CLS"+"ID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" CODEBASE=\"https://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715\" standby=\"Loading Microsoft Windows Media Player components...\" TYPE=\"application/x-oleobject\" width="+width+"  height="+height+" align=\"middle\">";	// WMP 6.4 Control
		else wmp += "<OBJ"+"ECT ID=\"aba_MediaPlayer\" "+style_text+" clas"+"sid=\"CLS"+"ID:22d6f312-b0f6-11d0-94ab-0080c74c7e95\" CODEBASE=\"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715\" standby=\"Loading Microsoft Windows Media Player components...\" TYPE=\"application/x-oleobject\" width="+width+"  height="+height+" align=\"middle\">";	// WMP 6.4 Control
		var s = "SRC";
	} 
	if (aba_DoUnicast() && asx_name) wmp += " <PAR"+"AM NAME=\""+s+"\" VALUE=\""+g_uniasxurl+"\">";

	var stretchtofit = (g_mp_stretchtofit)? "1" : "0"; 
	var contextmenu  = (g_enable_context_menu)? "1" : "0";
	var autosize = (g_mp_autosize)? "1":"0";
	
	wmp += " <PAR"+"AM NAME=\"AnimationAtStart\" VALUE=\"1\">";
	wmp += " <PAR"+"AM NAME=\"AutoRewind\" VALUE=\"1\">";
	wmp += " <PAR"+"AM NAME=\"AutoStart\" VALUE=\"true\">";		
	wmp += " <PAR"+"AM NAME=\"EnableContextMenu\" VALUE=\""+contextmenu+"\">";
	wmp += " <PAR"+"AM NAME=\"stretchToFit\" VALUE=\""+stretchtofit+"\">"; 
	wmp += " <PAR"+"AM NAME=\"AllowChangeDisplaySize\" VALUE=\"true\">"; 
	wmp += " <PAR"+"AM NAME=\"DisplaySize\" VALUE=\"4\">"; 
	wmp += " <PAR"+"AM NAME=\"showtracker\" VALUE=\"0\">";
	wmp += " <PAR"+"AM NAME=\"showpositioncontrols\" VALUE=\"0\">";
	wmp += " <PAR"+"AM NAME=\"ShowControls\" VALUE="+showcont+">";
	wmp += " <PAR"+"AM NAME=\"ShowStatusBar\" VALUE="+showstat+">";
	wmp += " <PAR"+"AM NAME=\"AutoSize\" VALUE=\""+autosize+"\">";
	wmp += " <PAR"+"AM NAME=\"defaultFrame\" value=\"default\">";
	wmp += " <PAR"+"AM NAME=\"uimode\" value=\""+g_wmp_uimode+"\">";
	wmp += " <emb"+"ed TYPE=\"application/x-mplayer2\"";
	if (g_use_https) wmp += " pluginspage=\"https://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&\"";
	else wmp += " pluginspage=\"http://www.microsoft.com/isapi/redir.dll?prd=windows&sbp=mediaplayer&ar=Media&sba=Plugin&\"";
	wmp += " ShowControls="+showcont+" ShowStatusBar="+showstat+" EnableContextMenu=1 name=\"aba_MediaPlayer\" AutoStart=1 align=\"middle\" transparentatstart=0";
	wmp += " width=\""+width+"\" height=\""+height+"\" defaultFrame=\"default\" AutoSize=\""+autosize+"\" showpositioncontrols=\"0\" showaudiocontrols=\""+showcont+"\" showtracker=\"0\"";
	wmp += " AllowChangeDisplaySize=\"0\" AutoRewind=\"1\" DisplaySize=\"4\" uimode=\""+g_wmp_uimode+"\" stretchToFit=\""+stretchtofit + "\"";
	if (aba_DoUnicast() && asx_name) wmp += " "+s+"=\""+g_uniasxurl+"\"";
	wmp += "></emb"+"ed>";
	wmp += "</OBJ"+"ECT>";

	//if (aba_is_moz) {
	if (false) {
		if (g_use_https) wmp  = "<emb"+"ed type=\"application/x-mplayer2\" pluginspage=\"http://microsoft.com/windows/mediaplayer/en/download/\"";
		else wmp  = "<emb"+"ed type=\"application/x-mplayer2\" pluginspage=\"http://microsoft.com/windows/mediaplayer/en/download/\"";
		//wmp += " id=\"aba_MediaPlayer\" name=\"aba_MediaPlayer\" autosize=\""+autosize+"\" showcontrols=\""+showcont+"\" showtracker=\"0\" showdisplay=\"0\" showstatusbar=\""+showstat+"\"";
		wmp += " id=\"aba_MediaPlayer\" name=\"aba_MediaPlayer\" autosize="+autosize+" showcontrols=\""+showcont+"\" showtracker=\"0\" showdisplay=\"0\" showstatusbar=\""+showstat+"\"";		
		wmp += " enablecontextmenu=\"1\" uimode=\""+g_wmp_uimode+"\" stretchToFit="+stretchtofit;
		if (aba_DoUnicast() && asx_name) wmp += " src=\""+g_uniasxurl+"\"";
		wmp += " autostart=\"1\" height=\""+height+"\" width=\""+width+"\">"
		wmp += "</emb"+"ed>";
	}
	
	if (sz_return) return wmp;
	else document.write(wmp);
}

function aba_StartPlayer() {

	if (!document.aba_MediaPlayer) {
		setTimeout("aba_StartPlayer()", 3000);
		return;
	}
	if ((aba_is_nav6up || aba_is_moz) && (g_asxurl || !g_uniasxurl || !aba_ns_has_plugin)) { 
		setTimeout("aba_LaunchNS6()", 10000); 
		return; 
	}
	
	// Internet Explorer 
	if (aba_is_ie) { 
		pstate = aba_MediaPlayer.PlayState;
		if (g_using_wmp7) {
			if (pstate == 2 || pstate == 3 || pstate == 6 || pstate == 11) {	// wmp 7+ playing, ok to exit
				if (g_mp_fullscreen) aba_MediaPlayer.DisplaySize = 3;
				return; 
			}	
		}
		else {
			if (pstate == 2 || pstate == 3) {	// wmp 6.4 playing, ok to exit
				if (g_mp_fullscreen) aba_MediaPlayer.DisplaySize = 3;
				return; 
			}	
		}
		
		var cstate = null;
		if (g_abci_rc) cstate = g_abci_rc.ClientState; 
		if (cstate == 3 || cstate == 4) {
			var MediaPort = g_abci_rc.MediaPort;
			if (g_asxurl) {
				var url = aba_PrepareUrl (g_asxurl);
				url += 'mediaport='+MediaPort;
				aba_LaunchASX (url);
				return;
			} else {
				FilenameURL = 'http://localhost:'+MediaPort;
				if(g_using_wmp7) {
					aba_MediaPlayer.URL = FilenameURL;
					aba_wmp7_play();
				} 
				else {
					aba_MediaPlayer.FileName = FilenameURL;					
				}
			}
		}
		else {
			/* client isn't ready yet */
			g_tmo_playchk = setTimeout("aba_StartPlayer()", 1000);
			return;
		}
	}

	// Netscape 
	else {
		if (g_mp_attempt > 5 ) g_mp_port++; 
		if (g_mp_attempt++ > 9) { g_mp_attempt=0; g_mp_port=4001 }
		FilenameURL = 'http://localhost:'+g_mp_port; 
		pstate = document.aba_MediaPlayer.GetPlayState();
		if (pstate == 2 || pstate == 3) { 
			if (g_asxurl) aba_LaunchASX();
			return; 
		}
		document.aba_MediaPlayer.Open (FilenameURL);
	}
	
	/* check stream for successful start */
	if (g_using_wmp7) g_tmo_playchk = setTimeout("aba_StartPlayer()", 3000);
	else g_tmo_playchk = setTimeout("aba_StartPlayer()", 3000);
}

function aba_LaunchASX (url) { 

	if ((aba_is_nav6up || aba_is_moz) && g_mp_embed) return;
	if (!document.aba_MediaPlayer) {
		setTimeout("aba_LaunchASX('"+url+"')", 3000);
		return;
	} 
	
	/* clear the startPlayer timeout */
	if (g_tmo_playchk) clearTimeout(g_tmo_playchk);

	if (url) asx_url = url;
	else asx_url = g_asxurl;
	if (!asx_url) return;
	
	/* IE */
	if(aba_is_ie) {
		if (!g_mp_embed) {
			/* stop the player, then open the asx */
			if (g_using_wmp7) aba_wmp7_stop();
			else aba_MediaPlayer.Stop();
			//if (g_abci_rc) g_abci_rc.OpenURL(asx_url);
			if (aba_has_wmp9_up) aba_MediaPlayer1.openPlayer(aba_getAbsURL(asx_url));			 
			else aba_OpenURL(asx_url,"asx","hidden");	
		}
		else if (g_mp_embed) {	
			if(g_using_wmp7) {
				aba_MediaPlayer.URL = asx_url;
				aba_wmp7_play();
			}
			else setTimeout("aba_MediaPlayer.Open('"+asx_url+"');", 100);
		}
	}
	/* Netscape not embedded  */
	else if(!g_mp_embed) {
		document.aba_MediaPlayer.Stop();
		aba_OpenURL(asx_url,"asx","hidden");	
	}
	/* Netscape embedded */
	else {
		document.aba_MediaPlayer.Open(asx_url);
	}
}

function aba_wmp7_play ()
{
	if (aba_MediaPlayer && aba_MediaPlayer.Controls) {
		setTimeout("aba_MediaPlayer.Controls.Play();", 100);
	} 
	else {
		setTimeout ("aba_wmp7_play()", 1000);
		window.status += ' p ';
		return;
	}
}

function aba_wmp7_stop ()
{
	if (aba_MediaPlayer && aba_MediaPlayer.controls) {
		aba_MediaPlayer.controls.Stop();
	}
	else {
		setTimeout ("aba_wmp7_stop()", 1000);
		window.status += ' s ';
		return;
	}		
}

function aba_has_uofc () {
	return (document.cookie.indexOf(g_uof_cookie) != -1);
}

function aba_set_uofc() {
	var g_uof_expDays = 3;						  
	var e = new Date();
	e.setTime(e.getTime() + (g_uof_expDays*24*60*60*1000));
	var c = g_uof_cookie + '=true; expires=' + e.toGMTString() + '';
	document.cookie = c;
}

var _start,_stop; 
function dbgTimerStart() {
	_start = new Date();	
	_start = _start.getTime();
}

function dbgTimerStop() {
	_stop = new Date();
	_stop = _stop.getTime();
	return(String(_stop - _start) + ' ms');
}

//if (aba_has_local_parm('ref=debug')) DEBUG = true;
var u1, u2;
if (aba_HasURLParam('stream=uc')) {
	g_do_unicast = true;
	g_uofc = true;
} //else if (aba_has_local_parm('ref=foc') || aba_has_local_parm('a2207dasc298cdc')) {	
	else if (aba_UrlContains('ref=foc') || aba_UrlContains('a2207dasc298cdc')) {
	aba_set_uofc();
	g_do_unicast = true;
	
	// remove foc parm
	var url;
	var u1 = aba_UrlContains('a2207dasc298cdc');
	if (u1) url = u1; else url = String(document.location);
	var start = url.indexOf('a2207dasc298cdc');
	if (start != -1) {
		url = url.substring (0, start);
	}
	start = url.indexOf('ref=foc');
	if (start != -1) {
		url = url.substring (0, start);
	}
	
	// remove the parms from the address - if this isn't accurate there's going to be an infinate loop
	try { top.document.location = url; } catch (e) {
		try { parent.document.location = url; } catch (e) {
			try { document.location = url; } catch (e) {
			}
		}		
	}
	
	if (aba_has_uofc()) { 
		g_uofc = true;
		call_off_launch = true;
	} else {
		var msg = 'The media player plugin installation has failed.\n\n';			
		msg += 'To start the stream, and to avoid seeing this message in the future,\n';
		msg += 'please accept cookies from this website.\n\n';
		msg += 'Thank you!';
		alert(msg);
	}
}

//This function will call a page log client version info 
function logger() {
	testver = new Image();
	if (g_version && g_url) {
		testver.src = 'http://www1.abacast.com/download/logger.php?version='+g_version+'&stream='+g_url;
	}
}

var abaDEBUG=false;
var abaDebugOpen=false;
function abaDebug(szMsg){
	if (!abaDEBUG) return;
	if (!abaDebugOpen) {
		DebugWind=window.open("", "aba_debug", 'width=200,height=790,toolbar=no,scrollbars=yes,location=no,directories=no,resizable=yes,top=180,left=2');
		DebugWind.document.close(); 
		DebugWind.document.writeln("<STY"+"LE> BODY {background: #000033; color: #00FF33;} </ST"+"YLE>");
		DebugWind.document.writeln("<font face='Verdana' size='1'>");
		abaDebugOpen=true;
	}
	if( DebugWind.closed ){ abaDebugOpen=false; abaDebug(szMsg); return;}
	DebugWind.document.writeln(szMsg);
	DebugWind.document.writeln("<br><hr>");	
	//DebugWind.focus();	
}

try {
	if (aba_HasURLParam("abadebug")) {
		abaDEBUG = true;
		abaDebug ("debug enabled...");
		//setTimeout ("AbacastAdSync ('artist=Unknown%20Artist&title=a7f06780&album=Unknown%20Title&duration=&buycd=&website=&mmss=%2D0%3A00&picture=237')", 15000);
	}
} catch (e) {
}


//******************************************************************************
//                                  END OF FILE
//******************************************************************************

