	var videoplayerObj = new SWFObject('swf/mediaplayer.swf','vpl','550','334','9'); // sets the dimensions of the video player. the css style dimensions should match
	var currentItemIndex;
	var currentChannelUrl;
	var newItemToPlayOnChannelChange = 0;
	var autostart = true;
	var activeColor = "0x399edd"/*9d1c14*/;
	
	var browserObj = new SWFObject('swf/rssbrowser.swf','rb','210','340','9'); // set the dimensions of the video browser on the right.  the css style dimensions should match 
	browserObj.addParam("allowScriptAccess","always");
	browserObj.addVariable("showTitles","true");  // when true, shows video titles on mouseover.  when false, hides video titles.
	browserObj.addVariable("activeColor", activeColor); // set the border color for an active video
	
	var cbObj = new SWFObject('swf/channelbrowser.swf','cb','760','160','9'); // sets the dimensions of the video browser on the right.  the css style dimensions should match
	cbObj.addParam("allowScriptAccess","always");
	cbObj.addVariable("channelDataUrl","http://dev.mediamerx.com/demo/data/api/index.php?action=getFeedsAsXml%26uid=93");
	cbObj.addVariable("activeColor",activeColor);
		
	function startPlayer()
	{
		loadPlayer();
		writePlayer();
	}

	function loadPlayer()
	{
		videoplayerObj.addParam('allowfullscreen','true');
		videoplayerObj.addParam('allowScriptAccess','always');
		videoplayerObj.addVariable("backcolor","0x000000");
		videoplayerObj.addVariable("frontcolor","0xCCCCCC");
		videoplayerObj.addVariable("lightcolor", activeColor); // color of buttons on videoplayer on mouseover
		videoplayerObj.addVariable('displaywidth','550'); // should be the same as the dimensions in the swf object code
		videoplayerObj.addVariable('displayheight','334'); // should be the same as the dimensions in the swf object code
		videoplayerObj.addVariable('thumbsinplaylist','false');
		videoplayerObj.addVariable('autostart','true');
		videoplayerObj.addVariable('shuffle','false');
		videoplayerObj.addVariable('repeat','list');
		videoplayerObj.addVariable('bufferlength','2');
		videoplayerObj.addVariable('linkfromdisplay','false');
		//videoplayerObj.addVariable('callback','analytics'); // turns on google analytics plug in
		videoplayerObj.addVariable('enablejs','true');
		videoplayerObj.addVariable('showstop','true');
		//videoplayerObj.addVariable('prefix','../content/');
	}

	function writePlayer()
	{
		browserObj.write("rssBrowser");
		videoplayerObj.write('player');
		cbObj.write("channelBrowser");
	}

	function updatePlayer(url)
	{
		//window.alert("Got update player "+url);
		
		if (autostart==true)
		{
			// executes only the first time this function is called
			// used to trigger playback of the first video in the rss feed at url 
			autostart = false;
			currentChannelUrl = url;
			thisMovie("rb").loadNewFeed(url);
			thisMovie("vpl").loadFile({file:url},0);
			updateItemDisplay(0);
		}
		else
		{
			thisMovie("rb").loadNewFeed(url);
		}	
	}
	
	function updateVideo(url,id)
	{
		thisMovie("vpl").sendEvent("stop");
		if (currentChannelUrl!=url)
		{
			currentChannelUrl = url;
			thisMovie("vpl").loadFile({file:url});
			newItemToPlayOnChannelChange = id;
		}
	
		thisMovie("vpl").sendEvent("playitem",id);
	}
		
	function getUpdate(typ,pr1,pr2,swf) 
	{
		// API function (custom)
		if (typ=="item")
		{
			updateItemDisplay(pr1);
			//window.alert("got new item: "+pr1);
		}
	}

	function updateItemDisplay(index)
	{
		// fixes bug in player where playing a nonzero index on new channel doesn't play
		if (newItemToPlayOnChannelChange > 0)
		{
			index = newItemToPlayOnChannelChange;
			newItemToPlayOnChannelChange = 0;
			currentItemIndex = index;
			thisMovie("rb").updateActiveItem(index,currentChannelUrl);
			updateVideo(currentChannelUrl,index); 
		}
		else
		{
			currentItemIndex = index;
			thisMovie("rb").updateActiveItem(index,currentChannelUrl);
			//window.alert("Current item is "+currentItemIndex);
		}
	}
	
	
	function thisMovie(swf) 
	{
		// API function
		if(navigator.appName.indexOf("Microsoft") != -1) {
    		return window[swf];
  		} else {
    		return document[swf];
  		}
  	}
  	
  	function sendEvent(swf,typ,prm)
	{
		// API function
		thisMovie(swf).sendEvent(typ,prm); 
	}