/***********************
FSP version 2.0.0.1
Created by Daniel Niland
Copyright 2006 Disney
**************************/

//FLASH DETECTIONS SYSTEM
//based on Adobe's Flash Player version detection v 1.5
var fspisIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
var fspisWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
var fspisOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;

var fspPageIsLoaded = false;
var targetDiv=null;

function fspControlVersion()
{
	var version;
	var axo;
	var e;

	try {
		// version will be set for 7.X or greater players
		axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
		version = axo.GetVariable("$version");
	} catch (e) {
	}

	if (!version)
	{
		try {
			// version will be set for 6.X players only
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
			
			// default to the first public version
			version = "WIN 6,0,21,0";

			// throws if AllowScripAccess does not exist (introduced in 6.0r47)		
			axo.AllowScriptAccess = "always";

			// safe to call for 6.0r47 or greater
			version = axo.GetVariable("$version");

		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 4.X or 5.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = axo.GetVariable("$version");
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 3.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
			version = "WIN 3,0,18,0";
		} catch (e) {
		}
	}

	if (!version)
	{
		try {
			// version will be set for 2.X player
			axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
			version = "WIN 2,0,0,11";
		} catch (e) {
			version = -1;
		}
	}
	
	return version;
}

// JavaScript helper required to detect Flash Player PlugIn version information
function fspGetSwfVer(){
	// NS/Opera version >= 3 check for Flash plugin in plugin array
	var flashVer = -1;
	
	if (navigator.plugins != null && navigator.plugins.length > 0) {
		if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
			var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
			var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;			
			var descArray = flashDescription.split(" ");
			var tempArrayMajor = descArray[2].split(".");
			var versionMajor = tempArrayMajor[0];
			var versionMinor = tempArrayMajor[1];
			if ( descArray[3] != "" ) {
				tempArrayMinor = descArray[3].split("r");
			} else {
				tempArrayMinor = descArray[4].split("r");
			}
			var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
			var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
		}
	}
	// MSN/WebTV 2.6 supports Flash 4
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
	// WebTV 2.5 supports Flash 3
	else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
	// older WebTV supports Flash 2
	else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
	else if ( fspisIE && fspisWin && !fspisOpera ) {
		flashVer = fspControlVersion();
	}	
	return flashVer;
}

// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
function fspDetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
{
	var versionStr = fspGetSwfVer();
	if (versionStr == -1 ) {
		return false;
	} else if (versionStr != 0) {
		if(fspisIE && fspisWin && !fspisOpera) {
			// Given "WIN 2,0,0,11"
			tempArray         = versionStr.split(" "); 	// ["WIN", "2,0,0,11"]
			tempString        = tempArray[1];			// "2,0,0,11"
			versionArray      = tempString.split(",");	// ['2', '0', '0', '11']
		} else {
			versionArray      = versionStr.split(".");
		}
		var versionMajor      = versionArray[0];
		var versionMinor      = versionArray[1];
		var versionRevision   = versionArray[2];

        	// is the major.revision >= requested major.revision AND the minor version >= requested minor
		if (versionMajor > parseFloat(reqMajorVer)) {
			return true;
		} else if (versionMajor == parseFloat(reqMajorVer)) {
			if (versionMinor > parseFloat(reqMinorVer))
				return true;
			else if (versionMinor == parseFloat(reqMinorVer)) {
				if (versionRevision >= parseFloat(reqRevision))
					return true;
			}
		}
		return false;
	}
}

function fspAC_AddExtension(src, ext)
{
  if (src.indexOf('?') != -1)
    return src.replace(/\?/, ext+'?'); 
  else
    return src + ext;
}

function fspAC_Generateobj(objAttrs, params, embedAttrs) 
{ 
    var str = '';
    if (fspisIE && fspisWin && !fspisOpera)
    {
  		str += '<object ';
  		for (var i in objAttrs)
  			str += i + '="' + objAttrs[i] + '" ';
  		for (var i in params)
  			str += '><param name="' + i + '" value="' + params[i] + '" /> ';
  		str += '></object>';
    } else {
  		str += '<embed ';
  		for (var i in embedAttrs)
  			str += i + '="' + embedAttrs[i] + '" ';
  		str += '> </embed>';
    }


if (targetDiv==null){
document.write(str);
} else {
document.getElementById(targetDiv).innerHTML=str;
}
}

function fspAC_FL_RunContent(){
  var ret = 
    fspAC_GetArgs
    (  arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
     , "application/x-shockwave-flash"
    );
  fspAC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
}

function fspAC_GetArgs(args, ext, srcParamName, classid, mimeType){
  var ret = new Object();
  ret.embedAttrs = new Object();
  ret.params = new Object();
  ret.objAttrs = new Object();
  for (var i=0; i < args.length; i=i+2){
    var currArg = args[i].toLowerCase();    

    switch (currArg){	
      case "classid":
        break;
      case "pluginspage":
        ret.embedAttrs[args[i]] = args[i+1];
        break;
      case "src":
      case "movie":	
        args[i+1] = fspAC_AddExtension(args[i+1], ext);
        ret.embedAttrs["src"] = args[i+1];
        ret.params[srcParamName] = args[i+1];
        break;
      case "type":
      case "codebase":
      case "id":
        ret.objAttrs[args[i]] = args[i+1];
        break;
      case "width":
      case "height":
      case "align":
      case "vspace": 
      case "hspace":
      case "class":
      case "title":
      case "accesskey":
      case "name":
      case "tabindex":
        ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
        break;
      default:
        ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
    }
  }
  ret.objAttrs["classid"] = classid;
  if (mimeType) ret.embedAttrs["type"] = mimeType;
  return ret;
}
// Major version of Flash required
var fsprequiredMajorVersion = 8;
// Minor version of Flash required
var fsprequiredMinorVersion = 0;
// Minor version of Flash required
var fsprequiredRevision = 0;

//FSP OBJECT
var fspcId = 0;
var synchIF;
var fspobjs = new Object();
var externalProbSet = false;
synchIF = null;//synch iframe reference via frames[]
synchID = null;//synch iframe ref via getElementByID
var firstRendered = false;


function fspObj() {
	fspcId += 1;
	//variables for the embedding of the fsp .swf
	this.flashFile = null;
	this.height = "400";
	this.width = "300";
    this.redirect = null;
	this.altImg = "";
	this.altTxt = null;
	this.flashVars = null;
	this.name = "fspFlash"+ fspcId;
	this.webTV = "true";
	this.wmode = null;
	this.playQueue = new Array();
	this.waiting = true;
	
	//variables for flashvars
	this.session = "fsp_" + Math.round(Math.random()*10000);
	this.ID = this.session;
	this.defaultData = "default";
	this.clearSynchedAd = true;
	
	//status variables
	this.bw = null;
	this.hasConnection = null;//streaming connection
	this.hasPlaylistViewer = null;
	this.hasControls = null;
	this.hasMovieViewer = null;
	this.version = null;
	this.statusCall = null;
	this.pageDelay = 50;
	this.rendered = false;
	
	//API functions
	this.addListener = fspSetEventListener;
	this.createSynchFrame = createSynchIFrame;
	this.enableFullScale = uiEnableFullScale;
	this.getPlaylist = uiNewPlaylist;
	this.initSynch = fspInitSynch;
	this.initSynchCallback = fspInitSynchCallback;
	this.mute = uiMute;
	this.next = uiNext;
	this.nextTimer = uiNextTimer;
	this.overrideAdPattern = fspOverridePattern;
	this.pause = uiPause;
	this.prev = uiPrev;
	this.prevTimer = uiPrevTimer;
	this.play = uiPlay;
	this.playCategory = uiPlayCategory;
	this.removeListener = fspRemoveEventListener;
	this.ready = fspReady;
	this.render = writeFSPComponent;
	this.replay = uiReplay;
	this.seek = uiSeek;
	this.setBG = fspSetBG;
	this.setBwLevel = uiSetBwLevel;
	this.setBuffer = uiSetBuffer;
	this.setCurrentPatternPos = fspSetCurrentPatternPos;
	this.setDefaultIcon = fspSetDefaultIcon;
	this.setSessionID = fspSessionID;
	this.setVolume = uiSetVolume;
	this.stop = uiStop;
	this.synchVisible = fspSynchIFVisible;
	//private functions
	this.broadcast = execFlashMethod;
	this.handleEvt = fspHandleEvt;
	this.handleSynch = fspHandleSynch;
	this.sendMethod = sendFSPMethod;
	this.setStatus = fspSetStatus;
	this.synchIFDisplay = fspSynchIFDisplay;
	
	fspobjs[this.session] = this;
	if (window.attachExtFunctions)//check to see if external functions need to be attached
	{
		attachExtFunctions(this);
	}
}

function writeFSPComponent(altFlashFile) {
	// Version check for the Flash Player that has the ability to start Player Product Install (6.0r65)
	var hasProductInstall = fspDetectFlashVer(6, 0, 65);
	// Version check based upon the values defined in globals
	var hasRequestedVersion = fspDetectFlashVer(fsprequiredMajorVersion, fsprequiredMinorVersion, fsprequiredRevision);

	
	this.flashFile = this.fspRoot + '/FSPContainer';
	if (altFlashFile != undefined && altFlashFile != ""){if (checkForSystem()) this.flashFile = altFlashFile;}
	//alert(this.flashFile);
	if ( hasProductInstall && !hasRequestedVersion ) 
	{
		var MMPlayerType = (fspisIE == true) ? "ActiveX" : "PlugIn";
		var MMredirectURL = window.location;
		var MMdoctitle = document.title;

		fspAC_FL_RunContent(
			"src", this.fspRoot + "/playerProductInstall",
			"FlashVars", "MMredirectURL="+MMredirectURL+'&MMplayerType='+MMPlayerType+'&MMdoctitle='+MMdoctitle+"",
			"width", this.width,
			"height", this.height,
			"align", "middle",
			"id", this.session,
			"quality", "high",
			"bgcolor", "#000000",
			"name", this.session,
			"allowScriptAccess","sameDomain",
			"type", "application/x-shockwave-flash",
			"pluginspage", "http://www.adobe.com/go/getflashplayer"
		);
	} 
	else if (hasRequestedVersion) 
	{		
		// assemble flashvars:
		this.flashVars = "session=" + this.session + "&domain=" + this.defaultData + "&fspRoot=" + this.fspRoot;
		
		if (this.streamServer != null) this.flashVars += "&streamServer=" + this.streamServer;
		if (this.progressiveServer != null) this.flashVars += "&progressiveServer=" + this.progressiveServer;
		if (this.bgColor != null) this.flashVars += "&bgColor=" + this.bgColor;		
		if (this.bgImage != null) this.flashVars += "&bgImage=" + this.bgImage;
		if (this.textColor != null) this.flashVars += "&textColor=" + this.textColor;
		if (this.linkColor != null) this.flashVars += "&linkColor=" + this.linkColor;
		if (this.subtextColor != null) this.flashVars += "&subtextColor=" + this.subtextColor;
		if (this.controlBgColor != null) this.flashVars += "&controlBgColor=" + this.controlBgColor;
		if (this.controlTextColor != null) this.flashVars += "&controlTextColor=" + this.controlTextColor;
		if (this.controlForeColor != null) this.flashVars += "&controlForeColor=" + this.controlForeColor;
		if (this.listBgColor != null) this.flashVars += "&listBgColor=" + this.listBgColor;
		if (this.listBorderColor != null) this.flashVars += "&listBorderColor=" + this.listBorderColor;
		if (this.listOverColor != null) this.flashVars += "&listOverColor=" + this.listOverColor;
		if (this.listSelectedColor != null) this.flashVars += "&listSelectedColor=" + this.listSelectedColor;
		if (this.language != null) this.flashVars += "&language=" + this.language;
		if (this.nocache != null) this.flashVars += "&nocache=" + this.nocache;
		if (this.movieRatio != null) this.flashVars += "&movieRatio=" + this.movieRatio;
		if (this.fullScale != null) this.fullScale += "&fullScale=" + this.fullScale;
		if (this.padding != null) this.flashVars += "&padding=" + this.padding;
		if (this.hitType != null) this.flashVars += "&hitType=" + this.hitType;
		if (this.hitUrl != null) this.flashVars += "&hitUrl=" + this.hitUrl;
		if (this.hitAccount != null) this.flashVars += "&hitAccount=" + this.hitAccount;
		if (this.hitSendType != null) this.flashVars += "&hitSendType=" + this.hitSendType;
		if (this.playlistURL != null) this.flashVars += "&playlistURL=" + this.playlistURL;
		if (this.playlistViewer != null) this.flashVars += "&playlistViewer=" + this.playlistViewer;
		if (this.playlistParser != null) this.flashVars += "&playlistParser=" + this.playlistParser;
		if (this.playlistPosition != null) this.flashVars += "&playlistPosition=" + this.playlistPosition;
		if (this.systemComponent != null) this.flashVars += "&systemComponent=" + this.systemComponent;
		if (this.playlistMin != null) this.flashVars += "&playlistMin=" + this.playlistMin;
		if (this.autoplay != null) this.flashVars += "&autoplay=" + this.autoplay;
		if (this.bufferSize != null) this.flashVars += "&bufferSize=" + this.bufferSize;
		if (this.movieViewer != null) this.flashVars += "&movieViewer=" + this.movieViewer;
		if (this.controlViewer != null) this.flashVars += "&controlViewer=" + this.controlViewer;
		if (this.helpUrl != null) this.flashVars += "&helpUrl=" + this.helpUrl;
		if (this.adType != null) this.flashVars += "&adType=" + this.adType;
		if (this.adUrl != null) this.flashVars += "&adUrl=" + this.adUrl;
		if (this.adOnlySynch != null) this.flashVars += "&adOnlySynch=" + this.adOnlySynch;
		if (this.adPattern != null) this.flashVars += "&adPattern=" + this.adPattern;
		if (this.adPauseEnabled != null) this.flashVars += "&adPauseEnabled=" + this.adPauseEnabled;
		if (this.adStream != null) this.flashVars += "&adStream=" + this.adStream;
		if (this.ncManager != null) this.flashVars += "&ncManager=" + this.ncManager;
		if (this.bwLevel != null) this.flashVars += "&bwLevel=" + this.bwLevel;
		if (this.bwThreshhold != null) this.flashVars += "&bwThreshhold=" + this.bwThreshhold;
		if (this.largeFormat != null) this.flashVars += "&largeFormat=" + this.largeFormat;
		if (this.truncation != null) this.flashVars += "&truncation=" + this.truncation;
		if (this.useExternal != null) this.flashVars += "&useExternal=" + this.useExternal;
		if (this.optimize != null) this.flashVars += "&optimize=" + this.optimize;
		if (this.nonRepeatableAd != null) this.flashVars += "&nonRepeatableAd=" + this.nonRepeatableAd;
		var wmodeType = this.wmode != null ? this.wmode : "Window";
		fspAC_FL_RunContent(
			"src", this.flashFile,
			"FlashVars", this.flashVars,
			"width", this.width,
			"height", this.height,
			"align", "middle",
			"id", this.session,
			"quality", "high",
			"bgcolor", "#000000",
			"wmode", wmodeType,
			"scale", "noscale",
			"name", this.session,
			"menu", "false",
			"allowScriptAccess","always",
			"type", "application/x-shockwave-flash",
			'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab',
			"pluginspage", "http://www.adobe.com/go/getflashplayer"
			);
		if (!firstRendered)
		{
			var sCR = "";	
			//put in Iframes for possible use in ad tracking and hit tracking
			sCR +=	"<IFRAME id='logIF' name='ads' scrolling='no' style='position:absolute;overflow:hidden;width:0;height:0;top:0;left:0;z-index:1001;border:0px'></IFRAME>";
document.write(sCR);
		}
	} 
	else 
	{  // flash is too old or we can't detect the plugin
		var alternateContent = this.altTxt == null ? 'The Disney Flash Standard Player requires the Adobe Flash Player 8 or higher <a href=http://www.adobe.com/go/getflash/>Get Flash</a>' : this.altTxt;
if (targetDiv==null){
document.write(alternateContent);
} else {
document.getElementById(targetDiv).innerHTML=alternateContent;
}
	}	
	firstRendered = true;
	this.rendered = true;
	
}

function fspSessionID(id)
{
	delete fspobjs[this.session];
	if (!this.rendered)
	{
		this.ID = id;
		this.session = id;
		fspobjs[this.session] = this;
	}
}

function resolveExternalProblem()
{
	if(fspisIE && fspisWin)
	{		
		__flash_unloadHandler = function()
		{
			if (externalProbSet) return;
			externalProbSet = true;
			for (var obj in fspobjs)
			{
				var theObj = eval(obj);
				theObj.style.display = "none";
				for (var prop in theObj)
				{
					if (typeof(theObj[prop]) == "function")
					{
						theObj[prop]=null
					}
				}
			}
			if (__flash_savedUnloadHandler != null) 
			{
				__flash_savedUnloadHandler();
			}		
		}
		if (window.onunload != __flash_unloadHandler) 
		{
			__flash_savedUnloadHandler = window.onunload;
			window.onunload = __flash_unloadHandler;
		}
	} 
}
//allow the javascript to set event listeners in jscript that will fire when named events happen in the player
function fspSetEventListener(evtName, cbFunction)
{
	if (evtName == "onStatus")
	{
		this.statusCall = cbFunction;
	}
	else
	{
		this.broadcast("setJSListener", evtName + "|" + cbFunction);
	}
}
function fspRemoveEventListener(evtName){this.broadcast("removeJSListener", evtName);}
function uiPlay(po){this.broadcast("uiPlay", po.streamPath + "|" + po.progPath + "|" + po.title + "|" + po.clickUrl + "|" + po.length + "|" + po.adCat + "|" + po.emailUrl + "|" + po.ID + "|" + po.streamPath_low + "|" + po.progPath_low + "|" + po.startPoint + "|" + po.endPoint + "|" + po.hitCat + "|" + po.offset + "|" + po.image);}
function uiPlayCategory(cat1, cat2, cat3, cat4){this.broadcast("uiPlayCategory", cat1 + "|" + cat2 + "|" + cat3 + "|" + cat4);}
function uiStop(){this.broadcast("uiStop");}
function uiSeek(percent){this.broadcast("uiSeek", percent);}
function uiReplay(){this.broadcast("uiReplay");}
function uiPause(isPaused){this.broadcast("uiPause", isPaused);}
function uiNext(){this.broadcast("uiNext");}
function uiPrev(){this.broadcast("uiPrev");}
function uiNextTimer(){this.broadcast("uiNextTimer");}
function uiPrevTimer(){this.broadcast("uiPrevTimer");}
function uiNewPlaylist(url, start, isText, switchDuringAds){this.broadcast("uiNewPlaylist", url + "|" + start + "|" + isText + "|0|" + switchDuringAds);}
function uiMute(){this.broadcast("uiMute");}
function uiSetVolume(vol){this.broadcast("uiSetVolume", vol);}
function uiSetBwLevel(level){this.broadcast("uiSetBwLevel", level);}
function uiSetBuffer(streamHigh, progHigh, streamLow, progLow){this.broadcast("uiSetBuffer", streamHigh + "|" + progHigh + "|" + streamLow + "|" + progLow);}
function uiEnableFullScale(isFullScale){this.broadcast("uiEnableFullScale", isFullScale);}
function fspOverridePattern(pattern){this.broadcast("uiOverridePattern", pattern);}
function fspSetCurrentPatternPos(index){this.broadcast("uiSetCurrentPatternPos", index);}
function fspSetBG(bgUrl){this.broadcast("uiSetBG", bgUrl);}
function fspSetDefaultIcon(iconUrl, posX, posY, linkOnly){this.broadcast("uiSetDefaultIcon", iconUrl + "|" + posX + "|" + posY + "|" + linkOnly);}
function execFlashMethod(method, params)
{	
	var methObj = new Object();
	methObj.session = this.session;
	methObj.method = method;
	methObj.params = params;
	if (this.waiting)//set up a simple queue
	{
		this.playQueue[this.playQueue.length] = methObj;
	}
	else
	{
		this.waiting = true;
		this.sendMethod(methObj);
	}
}
function sendFSPMethod(methObj){thisFspMovie(methObj.session)["FSPInterface" + methObj.session](methObj.method + "~" + methObj.params);}
function thisFspMovie(theSession) 
{
    //return document.getElementById(theSession);
    
    if (navigator.appName.indexOf("Microsoft") != -1) 
    {
        return window[theSession]
    }
    else 
    {
        return document[theSession]
    }
    
}
function FSPCall(session, methString)
{
	//the entire method is sent in as a string
	if (!session)
	{
		eval(methString);
	}
	else
	{
		//this is called on an fsp instance
		eval("fspobjs['" + session + "']." + methString);
	}
}
//must be initiated by the js
function createSynchIFrame(ifname, ifid)
{	
 	synchIF = ifname;
	synchID = ifid;
	if (frames[synchIF])
	{
		//inform the flash that the frame has been set
		this.broadcast("uiSetSynchFrame", ifname);
	}
}
function fspInitSynch(synchID, divID, divName){this.broadcast("uiInitSynch", synchID + "|true|false|" + divID + "|" + divName);}
function fspInitSynchCallback(synchID, callback){this.broadcast("uiInitSynch", synchID + "|true|true|" + callback);}
function fspHandleSynch(divID, divName, isAd, synchurl, size, patternIndex)
{
	var sifn = frames[divName];
	var sifid = document.getElementById(divID);
	if (sifn)
	{
		if (isAd && synchurl != "blank")
		{
			var iWidth = 0;
			var iHeight = 0;
			if (size)
			{
				var sizes = size.split("x");
				iWidth = Number(sizes[0]);
				iHeight = Number(sizes[1]);
			}
			if(!iWidth || isNaN(iWidth)){iWidth=0}
			if(!iHeight || isNaN(iHeight)){iHeight=0}
			sifid.style.width = iWidth + "px";
			sifid.style.height = iHeight + "px";
			sifn.location.replace(synchurl);
		}
		else if (this.clearSynchedAd)
		{
			sifid.style.width = "0px";
			sifid.style.height = "0px";
		}
	}
}


////////// GLOBAL FUNCTIONS /////////////


//called by flash client to confirm js has been received, look for next
function fspReady()
{
	if (fspcId > 1)
	{
		resolveExternalProblem();
	}	
	if (this.playQueue.length > 0)
	{		
		this.waiting = true;
		var fplay = this.playQueue[0];
		for(var i = 0; i < this.playQueue.length; i++)
		{
			this.playQueue[i] = this.playQueue[i + 1];
		}
		this.playQueue.length--;
		this.sendMethod(fplay);
	}
	else
	{
		this.waiting = false;
	}
	
}

//called from the Flash player whenever a set event has been triggered
function fspHandleEvt(e)
{
	var eargs = e.split("|");
	var str = "";
	for (var n in eargs)
	{
		str += eargs[n] + "|";
	}
	var func = eargs[0];//the callback function is always first
		
	var eobj;
	if (eargs.length > 1 && eargs[1].indexOf("**") >= 0)
	{
		eobj = new Object();
		for (var i = 1; i < eargs.length; i++)
		{
			var prop = eargs[i].split("**");
			eobj[prop[0]] = prop[1];//fill the properties
		}
	}
	else
	{
		eobj = eargs[1];//either we have nothing or a single value
	}
	eval(func)(eobj);//fire the event
}


function fspSynchIFDisplay(isVis, sifUrl, iWidth, iHeight)
{
	var sifn = frames[synchIF];
	var sifid = document.getElementById(synchID);
	if (sifn)
	{	
		if (isVis)
		{			
			if(!iWidth){iWidth=0} 
			if(!iHeight){iHeight=0} 
			sifid.style.width = iWidth + "px";
			sifid.style.height = iHeight + "px";
			sifn.location.replace(sifUrl);
		}
		else if (this.clearSynchedAd)
		{
			sifid.style.width = "0px";
			sifid.style.height = "0px";
		}
	}	
}

function fspSynchIFVisible(isVis)
{
	var sifid = document.getElementById(synchID);
	if (sifid)
	{	
		if (isVis)
		{
			sifid.style.display = "inline";
		}
		else
		{
			sifid.style.display = "none";
		}
	}
}

function sendLogIF(logUrl)
{
	if (frames['ads'])
	{		
		frames['ads'].location.replace(logUrl);
	}
}

function sendHitIF(hitUrl)
{
	if (frames['hit'])
	{
		hitUrl = hitUrl.replace(/liiiid/, "lid");
		frames['hit'].location.replace(hitUrl);		
	}
}

function fspSetStatus(session, bandwidth, hasConn, hasControls, hasPlaylistViewer, hasMovieViewer, version)
{
	var obj = fspobjs[session];
	obj.bw = bandwidth;
	obj.hasConnection = hasConn;
	obj.hasControls = hasControls;
	obj.hasPlaylistViewer = hasPlaylistViewer;
	obj.hasMovieViewer = hasMovieViewer;
	obj.version = version;
	if (obj.statusCall != null) eval(obj.statusCall)(obj.version);
	
}

function fspaddEvent(obj, evType, fn)
{ 
	if (obj.addEventListener)
	{ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	} 
	else if (obj.attachEvent)
	{ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	} 
	else 
	{ 
		return false; 
	} 
}
fspaddEvent(window, 'load', fspPageLoaded);

function fspPageLoaded()
{
	fspPageIsLoaded = true;
	if (window.checkExtWait)
	{
		checkExtWait();
	}
	
}

function PlayObject(spath, ppath, ititle, iclickUrl, len, adcat, emailurl, id, spathLow, ppathLow, istartPoint, iendPoint, ihitCat, ioffset, iimage)
{
	this.streamPath = spath;
	this.progPath = ppath;
	this.title = ititle;
	this.clickUrl = iclickUrl;
	this.length = len;
	this.adCat = adcat;
	this.emailUrl = emailurl;
	this.ID = id;
	this.streamPath_low = spathLow;
	this.progPath_low = ppathLow;
	this.startPoint = istartPoint;
	this.endPoint = iendPoint;
	this.hitCat = ihitCat;
	this.offset = ioffset;
	this.image = iimage;
}