// Decide whether browser is IE 
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;

// Handle all the FSCommand messages in a Flash movie.
function bdm_DoFSCommand(command, args)
	{
	var bdmObj = isInternetExplorer ? document.all.bdm : document.bdm;
	var bdm = window.document.bdm;
	
	//alert(command);

	// Split the incoming FSCommand into its components
	var parts = command.split(':');
	
	// Process the code for Windows (Firefox, IE)
	if (parts[0] == 'FSCommand')
		{
		var mode = parts[1];
		var param = parts[2];
		}
		
	// Process the code for Mac (Firefox, Safari, Opera)
	else
		{
		var mode = parts[0];
		var param = parts[1];
		}

	// Determine if command applies to the Blog or the Calendar
	switch (mode)
		{
		// Process Blog Home Page event.
		case 'calHomeEvent':
			var calList = bdm.GetVariable('calList');
			bdm.GotoFrame(40);
			bdm.SetVariable( 'mainCalendar_txt.htmlText', calList );
			// no break is included here because we want to continue 
			// processing the statements in calEvent
			
		// Process Calendar event
		case 'calEvent':
			var titleValues = bdm.GetVariable('calTitle');
			var dateValues = bdm.GetVariable('calDate');
			var descValues = bdm.GetVariable('calDesc');
			var linkValues = bdm.GetVariable('calLink');
			var imageValues = bdm.GetVariable('calImage');
			var thumbValues = bdm.GetVariable('calThumb');
			var theTitle = titleValues.split('|');
			var theDate = dateValues.split('|');
			var theDesc = descValues.split('|');
			var theLink = linkValues.split('|');
			var theImage = imageValues.split('|');
			var theThumb = thumbValues.split('|');
			if (theTitle[param].indexOf(",") == 0) theTitle[param] = theTitle[param].substr(1);
			if (theDate[param].indexOf(",") == 0) theDate[param] = theDate[param].substr(1);
			if (theDesc[param].indexOf(",") == 0) theDesc[param] = theDesc[param].substr(1);
			if (theLink[param].indexOf(",") == 0) theLink[param] = theLink[param].substr(1);
			if (theImage[param].indexOf(",") == 0) theImage[param] = theImage[param].substr(1);
			if (theThumb[param].indexOf(",") == 0) theThumb[param] = theThumb[param].substr(1);
			var whichVar = theImage[param] + theTitle[param] + theDate[param] + theDesc[param] + theLink[param];
			bdm.SetVariable( 'detailCalendar_txt.htmlText', whichVar );
			break;			
		
		// Process Blog Home Page event.
		case 'blogHomeEvent':
			var blogList = bdm.GetVariable('blogList');
			bdm.GotoFrame(69);
			bdm.SetVariable( 'listBlog_txt.htmlText', blogList );
			// no break is included here because we want to continue 
			// processing the statements in blogEvent
			
		// Process Blog event
		case 'blogEvent':
			var headlineValues = bdm.GetVariable('blogHeadline');
			var dateValues = bdm.GetVariable('blogDate');
			var contentValues = bdm.GetVariable('blogContent');
			var imageValues = bdm.GetVariable('blogImage');
			//var thumbValues = bdm.GetVariable('blogThumb');
			var theHeadline = headlineValues.split('|');
			var theDate = dateValues.split('|');
			var theContent = contentValues.split('|');
			var theImage = imageValues.split('|');
			//var theThumb = thumbValues.split('|');
			if (theHeadline[param].indexOf(",") == 0) theHeadline[param] = theHeadline[param].substr(1);
			if (theDate[param].indexOf(",") == 0) theDate[param] = theDate[param].substr(1);
			if (theContent[param].indexOf(",") == 0) theContent[param] = theContent[param].substr(1);
			if (theImage[param].indexOf(",") == 0) theImage[param] = theImage[param].substr(1);
			//if (theThumb[param].indexOf(",") == 0) theThumb[param] = theThumb[param].substr(1);
			//if (theId[param].indexOf(",") == 0) theId[param] = theId[param].substr(1);
			var whichVar = theImage[param] + theHeadline[param] + theDate[param] + theContent[param];
			bdm.SetVariable( 'detailBlog_txt.htmlText', whichVar );
			break;
			
		// Process Newsletter event
		case 'newsEvent':
			bdm.GotoFrame(100);
			var headlineValues = bdm.GetVariable('newsHeadline');
			var dateValues = bdm.GetVariable('newsDate');
			var contentValues = bdm.GetVariable('newsContent');
			var imageValues = bdm.GetVariable('newsImage');
			var thumbValues = bdm.GetVariable('newsThumb');
			var theHeadline = headlineValues.split('|');
			var theDate = dateValues.split('|');
			var theContent = contentValues.split('|');
			var theImage = imageValues.split('|');
			var theThumb = thumbValues.split('|');
			if (theHeadline[param].indexOf(",") == 0) theHeadline[param] = theHeadline[param].substr(1);
			if (theDate[param].indexOf(",") == 0) theDate[param] = theDate[param].substr(1);
			if (theContent[param].indexOf(",") == 0) theContent[param] = theContent[param].substr(1);
			if (theImage[param].indexOf(",") == 0) theImage[param] = theImage[param].substr(1);
			if (theThumb[param].indexOf(",") == 0) theThumb[param] = theThumb[param].substr(1);
			//if (theId[param].indexOf(",") == 0) theId[param] = theId[param].substr(1);
			var whichVar = theImage[param] + theHeadline[param] + theDate[param] + theContent[param];
			bdm.SetVariable( 'newsDetail_txt.htmlText', whichVar );
			break;
			
		// Error Handling: comment out the alert() if desired.
		default:
			alert("Processing Error");
			break;		
		}
	}
	
// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1)
	{
	document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub bdm_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call bdm_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
	}