var strSWFName='SoftSim_Demo_-_2007.swf';
var windowWidth = 1024, windowHeight = 768;
var leftPane = 0;
var rightPane = 0;
var bottomPane = 1;
var AssNarrationPosition = 0;
var QuizNarrationPosition = 0;

var strTemp = "";
var startStep = "1";
var strHREF = document.location.href;
strHREF = unescape(strHREF);
strTemp = getParam(strHREF, "startstep");
if (strTemp != "") startStep = strTemp;
strTemp = getParam(strHREF, "playmode");
if (strTemp != "") playMode = strTemp;
var strTempHREF = document.location.href;
var strAutoStart = getParam(strTempHREF, "autostart");
var bAutoStart = ((strAutoStart != "" && strAutoStart == "0") ? false : true);
var StepTraceItem = new StepTrace();
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var SoftSimCourse = "true";
var HTMLResizable = 1;
function replaceStringEx(sourceStr, oldStr, newStr) {
	if (sourceStr==null || oldStr==null || 
		newStr==null || oldStr.length<=0) {
		return sourceStr;
	}
	
	var pos = 0;
	while((pos = sourceStr.indexOf(oldStr,pos)) >= 0)
	{
		sourceStr = sourceStr.substring(0,pos)+newStr+sourceStr.substring(pos+oldStr.length);
		pos += newStr.length;
	}
	return sourceStr;
}
function indexOfNoCase(str1,str2)
{
	return str1.toUpperCase().indexOf(str2.toUpperCase());
}
function getParam(strParam, strParamName) {
	var index = indexOfNoCase(strParam, strParamName);
	if(index<0) return "";
	if((index=strParam.indexOf("=",index))<0) return "";
	var endIndex=strParam.indexOf("&",index);
	if(endIndex<0)endIndex=strParam.length;
	return strParam.substring(index+1,endIndex);
}
document.write('<div id="FlashWnd"></div>');
function LaunchFlash(str) {
if (isInternetExplorer) {
window.document.all['FlashWnd'].innerHTML = str;
}
else {
rng = window.document.createRange();
el = window.document.getElementById('FlashWnd');
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragment(str);
while(el.hasChildNodes()) el.removeChild(el.lastChild);
el.appendChild(htmlFrag);
}
}
//for intergrate with old version of Trainer
function showPlayback(mode) 
{
	switch (mode) {
	case 1: 
		{	
		openPlayback('playshowme.htm');
		break;
		}
	case 2: 
		{	
		openPlayback('playguideme.htm');
		break;
		}
	case 3: 
		{
		openPlayback('playquiz.htm');
		break;
		}
	case 4:
		{
		openPlayback('playassessment.htm');
		break;
		}		
	}
}
function openPlayback(playmode)
{
	var playbackWidth = windowWidth;
	var playbackHeight = windowHeight;
	var windowWidth1;
	var windowHeight1;
	if(playbackWidth == -1){
		playbackWidth=window.screen.availWidth-10;
		playbackHeight=window.screen.availHeight-30;
	}
	//optimize option --> windowWidth, windowHeight will be minus size

	var desktop_width = window.screen.availWidth;
	var	desktop_height = window.screen.availHeight;
	var	Description_pane_height;
	var	Browser_titlebar_height;
	var	Browser_window_width;
	var	Browser_window_heigh;
	if(windowWidth < -1) {
		windowWidth1 = Math.abs(windowWidth);
		windowHeight1 = Math.abs(windowHeight);
		Steps_pane_width = Math.min(Math.max(desktop_width - windowWidth1-10, 204), 450);
		Description_pane_height = 60;
		Browser_titlebar_height = 25;
		if(((leftPane == 0)&&(rightPane == 0))||
			(playmode == 'playquiz.htm' && (QuizNarrationPosition == 0 || QuizNarrationPosition == 3)) ||
			(playmode == 'playassessment.htm' && (AssNarrationPosition == 0 || AssNarrationPosition == 3))){
			Steps_pane_width = 30;
		}

		playbackWidth = Math.min(Steps_pane_width + windowWidth1, desktop_width);
		if(bottomPane){
			playbackHeight = Description_pane_height + windowHeight1 + Browser_titlebar_height;
		} else {
			playbackHeight = windowHeight1 + Browser_titlebar_height;
		}
		playbackHeight = Math.min(playbackHeight, desktop_height);
	}//end optimize

	var resizable = 1;
	if (window.navigator.appName.indexOf("Netscape") != -1){
		resizable = 0;
	} 
//	if (playbackHeight>window.screen.availHeight-30) {
//		playbackHeight = window.screen.availHeight-30;
//	}
	if (playbackWidth>window.screen.availWidth-10) {
		playbackWidth = window.screen.availWidth-10;
	}
	window.open(playmode, null, "width="+(Math.abs(playbackWidth))+",height="+(Math.abs(playbackHeight))+",resizable="+resizable+",scrollbars=0,status=0,toolbar=0,menubar=0,location=0,top=0,left=0");
}
function SendAICC(args) {
	if (typeof StepTraceItem == "undefined") return;
	OpenAICCForm(StepTraceItem);
}
function SendSCORM(args) {
var wopener ;
var found = false;
var index = 0;
	if (typeof StepTraceItem == "undefined") return;
	
	FinalData(args);

	if (blnInitialized == "false") {
		wopener = window.parent.opener;
		if (wopener != null) {
			if (!wopener.closed) {
				if (wopener.blnInitialized == "true") {
					found = true;
				}
			}
		}
	} else {
		found = true ;
		wopener = window;
	}

	if (found) {
		wopener.score(StepTraceItem);
		wopener.sendLocation(StepTraceItem);
		wopener.interaction(StepTraceItem);
		wopener.clearSuspendData();
	}
}
//------------------------------------------------------------------------
function SetFlashExitStatus(args) {
	if (typeof StepTraceItem == "undefined") return;
	StepTraceItem.setExitStatus(args);
}
function getFlashState() {
var result ;
	result = document.FlashPlayback.GetVariable("_global.State") ;
	return (result) ;
}
//------------------------------------------------------------------------
function getFlashSessionTime() {
var result = "" ;
	result = document.FlashPlayback.GetVariable("_global.SessionTime") ;
	return (result) ;
}
//------------------------------------------------------------------------
function SetFlashSessionTime(args) {
	if (typeof StepTraceItem == "undefined") return;
	StepTraceItem.sessiontime = args;
}
function getLaunchData()
{
var found = false ;
var wopener ;
	if (typeof StepTraceItem == "undefined") return;
	if (blnInitialized == "false") {
		wopener = window.parent.opener;
		if (wopener != null) {
			if (!wopener.closed) {
				if (wopener.blnInitialized == "true") {
					found = true;
				}
			}
		}
	} else {
		found = true ;
		wopener = window;
	}
	if (found) {
		return wopener.scormGetLaunchData() ;
	}
	else return "";
}
//------------------------------------------------------
function exitFlashSimulation() {
var found = false ;
var wopener ;
var func = null;
	if ((typeof StepTraceItem == "undefined") || (typeof blnInitialized == "undefined"))return;
	if (blnInitialized == "false") {
		wopener = window.parent.opener;
		if (wopener != null) {
			if (!wopener.closed) {
				if (wopener.blnInitialized == "true") {
					found = true;
				}
			}
		}
	} else {
		found = true ;
		wopener = window;
	}
	if (found) {
		if (StepTraceItem.getExitStatus() == "suspend") {
			wopener.sendSuspendData(StepTraceItem);
		}
		wopener.setExitStatus(StepTraceItem) ;
	}
}
//------------------------------------------------------------------------
function openViewPrintable() {
var strBase = document.location.href;
    strBase = strBase.substring(0, strBase.lastIndexOf("/")+1);
    window.open(strBase + "html/index.htm","ssPrintable");
}
//------------------------------------------------------------------------
function traceStep(args) {
	if (typeof StepTraceItem == "undefined") return;
	args = "" + args;	
var 	str = replaceStringEx(args, "\%22", "\"");
	str = replaceStringEx(str, "\%27", "\'");
	StepTraceItem.InsertStepStr(str);
}
//------------------------------------------------------------------------
function SimData(args) {
	if (typeof StepTraceItem == "undefined") return;
	StepTraceItem.parseSimData(args);
}
//------------------------------------------------------------------------
function FinalData(args) {
	if (typeof StepTraceItem == "undefined") return;
	StepTraceItem.parseFinalData(args);
}
//------------------------------------------------------------------------
function ObjectiveData(args) {
	if (typeof StepTraceItem == "undefined") return;
	StepTraceItem.InsertObjective(args);
}

function getCMIBookMask() {
var found = false ;
var wopener ;
var str;
	if (typeof StepTraceItem == "undefined") return;
	if (blnInitialized == "false") {
		wopener = window.parent.opener;
		if (wopener != null) {
			if (!wopener.closed) {
				if (wopener.blnInitialized == "true") {
					found = true;
				}
			}
		}
	} else {
		found = true ;
		wopener = window;
	}
	if (found) {
		str = wopener.getCMISuspendData();
		if (str != "") {
			StepTraceItem.clearAll();
			StepTraceItem.getFromSuspendData(str);
			setPlayBack(StepTraceItem);
		}
	}
}
function setPlayBack(StepTraceItem) {
	if (typeof StepTraceItem == "undefined") return;
	if (playMode == StepTraceItem.playmode) {
		startStep = StepTraceItem.currStep;
		asmTimeSpent = StepTraceItem.timespent;
		asmCorrectStep = StepTraceItem.NumOfcorrectStep;
		asmIncorrectStep = StepTraceItem.NumOfincorrectStep;
		asmYourPoint = StepTraceItem.yourPoint;
		asmTotalPoint = StepTraceItem.totalPoint;
	} else {
		StepTraceItem.playmode = playMode;
	}
}
function ARestart() {
	if (typeof StepTraceItem == "undefined") return;
	StepTraceItem.clearAll();
}
function flashswf_DoFSCommand(command, args) {
	var FlashObj = isInternetExplorer ? document.all.flashswf : document.flashswf;
	if (command == "closeWindow") {
		closeWindow();
	}else if (command == "SendSCORM") {
		SendSCORM(args) ;
	}
	else if (command == "SetExitStatus") {
		SetFlashExitStatus(args);
	}
	else if (command == "SetFlashSessionTime") {
		SetFlashSessionTime(args);
	}
	else if (command == "StepData") {
		traceStep(args);
	}
	else if (command == "SimData") {
		SimData(args);
	}
	else if (command == "ARestart") {
		ARestart();
	}
	else if (command == "FinalData") {
		FinalData(args);
	}
	else if (command == "ObjectiveData") {
		ObjectiveData(args);
	}
	else if (command == "SendAICC") {
		SendAICC(args);
	}
}
function closeWindow(){
	window.setTimeout('Callback();',100);
}
function Callback() {
	if ((typeof strCallbackFunctionName != "undefined") && (strCallbackFunctionName != "")) {
		var funcName = unescape(strCallbackFunctionName);
		eval(funcName);
	} else {
		window.top.close();
	}
}
function setFlashFocus() {
	if ((typeof document.flashswf != 'undefined') && (typeof document.flashswf.focus != 'undefined'))	{
		document.flashswf.focus();
	}
}
function maximize(){
if (HTMLResizable == 1) {
	top.window.moveTo(0,0); 
	if (document.all) { 
		top.window.resizeTo(screen.availWidth,screen.availHeight); 
	} else 
		if (document.layers || document.getElementById) { 
			if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) { 
	   			top.window.outerHeight = top.screen.availHeight; 
				top.window.outerWidth = top.screen.availWidth;
			 } 
		   } 
}
}
function resize(nWidth,nHeight){
	if (HTMLResizable == 1) {
		window.top.resizeTo(nWidth,nHeight);
	}
}
function beforeUnload() {
	callFlashFunction("ReleaseResources");
	var j = 0;
	for (i = 0; i < 10000; i++) {
		j = j + 1;		
	}
}
function callFlashFunction(functionName, params) {
	if (!isInternetExplorer) return;
	if (typeof document.flashswf == 'undefined') return;
	if (typeof document.flashswf.SetVariable == 'undefined' 
		|| typeof document.flashswf.TGotoLabel == 'undefined') return;
		
	document.flashswf.SetVariable("AS_FunctionName", functionName);
	if (typeof params != "undefined") {
		document.flashswf.SetVariable("AS_FunctionParams", params);
	}
	document.flashswf.TGotoLabel("_level0/", "functionFrame");
}
function LaunchFlash(str) {
if (isInternetExplorer) {
window.document.all['FlashWnd'].innerHTML = str;
}
else {
rng = window.document.createRange();
el = window.document.getElementById('FlashWnd');
rng.setStartBefore(el);
htmlFrag = rng.createContextualFragment(str);
while(el.hasChildNodes()) el.removeChild(el.lastChild);
el.appendChild(htmlFrag);
}
}
function getFlashParams() {
var strSuspendData = replaceStringEx(StepTraceItem.StepStr,"\"","%22");
	strSuspendData = replaceStringEx(strSuspendData,"\%","%37");
var str = "";
	if (strSuspendData != "") {
		str += '&SuspendData=' + strSuspendData;
	}
	if (stepPanelLocation != "") {
		str += '&PanelLocation=' + stepPanelLocation;
	}
	if (strDisplayStepPanel != "") {
		str += '&DisplayStepPanel=' + strDisplayStepPanel;
	}
	if (strDisplayStatus != "") {
		str += '&DisplayStatus=' + strDisplayStatus;
	}
	if (strDisplayNarrPane != "") {
		str += '&DisplayNarrPane=' + strDisplayNarrPane;
	}
	if (bAudioLesson != "") {
		str += '&HasAudio=' + bAudioLesson;
	}
	if (desktopcolor != "") {
		str += '&DesktopColor=' + desktopcolor;
	}
	if (rBColor != "") {
		str += '&RBColor=' + rBColor;
	}
	if (rBFlash != "") {
		str += '&RBFlash=' + rBFlash;
	}
	if (blnMouseTrack != "") {
		str += '&MouseTrack=' + blnMouseTrack;
	}
	if (waitTime != "") {
		str += '&WaitTime=' + waitTime;
	}
	if (textDirection != "") {
		str += '&TextDirection=' + textDirection;
	}
	if (strRCEmailTo != "") {
		str += '&RCEmailTo=' + strRCEmailTo;
	}
	if (bReviewMode != "") {
		str += '&ReviewMode=' + bReviewMode;
	}
	if (strFocusPoint != "") {
		str += '&FocusPoint=' + strFocusPoint;
	}
	if (bCompliant508 != "") {
		str += '&Compliant508=' + bCompliant508;
	}
	return (str);
}

function getFlashAsmParams() {
var str= "";
	if (asmAttemptsPerStep != "") {
		str += '&AsmAttemptsPerStep=' + asmAttemptsPerStep;
	}
	if (asmInformIncorrect != "") {
		str += '&AsmInformIncorrect=' + asmInformIncorrect;
	}
	if (asmPassScore != "") {
		str += '&AsmPassScore=' + asmPassScore;
	}
	if (asmScoreCard != "") {
		str += '&AsmScoreCard=' + asmScoreCard;
	}
	if (asmScoreCardDispPassingScore != "") {
		str += '&AsmScoreCardDispPassingScore=' + asmScoreCardDispPassingScore;
	}
	if (asmRestart != "") {
		str += '&AsmRestart=' + asmRestart;
	}
	if (asmStepValue != "") {
		str += '&AsmStepValue=' + asmStepValue;
	}
	if (asmTimeLimit != "") {
		str += '&AsmTimeLimit=' + asmTimeLimit;
	}
	if (asmTimeColor != "") {
		str += '&AsmTimeColor=' + asmTimeColor;
	}
	if (asmDisplayPF != "") {
		str += '&AsmDisplayPF=' + asmDisplayPF;
	}
	if (asmEnablePrintSC != "") {
		str += '&AsmEnablePrintSC=' + asmEnablePrintSC;
	}
	if (asmNote != "") {
		str += '&AsmNote=' + asmNote;
	}
	if (asmStepAudio != "") {
		str += '&AsmStepAudio=' + asmStepAudio;
	}
	if (asmActionAudio != "") {
		str += '&AsmActionAudio=' + asmActionAudio;
	}
	if (asmNarration != "") {
		str += '&AsmNarration=' + asmNarration;
	}
	if (asmAllowEmail != "") {
		str += '&AsmAllowEmail=' + asmAllowEmail;
	}
	if (asmEmailTo != "") {
		str += '&AsmEmailTo=' + asmEmailTo;
	}
	if (asmAutoEmail != "") {
		str += '&AsmAutoEmail=' + asmAutoEmail;
	}
	if (asmTimeSpent != "") {
		str += '&AsmTimeSpent=' + asmTimeSpent;
	}
	if (asmCorrectStep != "") {
		str += '&AsmCorrectStep=' + asmCorrectStep;
	}
	if (asmIncorrectStep != "") {
		str += '&AsmIncorrectStep=' + asmIncorrectStep;
	}
	if (asmYourPoint != "") {
		str += '&AsmYourPoint=' + asmYourPoint;
	}
	if (asmTotalPoint != "") {
		str += '&AsmTotalPoint=' + asmTotalPoint;
	}
	return (str);
}	
function getFlashQuizParams() {
var str = "";
	if (QuizAttemptsPerStep != "") {
		str += '&QuizAttemptsPerStep=' + QuizAttemptsPerStep;
	}
	if (QuizInformIncorrect != "") {
		str += '&QuizInformIncorrect=' + QuizInformIncorrect;
	}
	if (QuizPassScore != "") {
		str += '&QuizPassScore=' + QuizPassScore;
	}
	if (QuizScoreCard != "") {
		str += '&QuizScoreCard=' + QuizScoreCard;
	}
	if (QuizScoreCardDispPassingScore != "") {
		str += '&QuizScoreCardDispPassingScore=' + QuizScoreCardDispPassingScore;
	}
	if (QuizRestart != "") {
		str += '&QuizRestart=' + QuizRestart;
	}
	if (QuizStepValue != "") {
		str += '&QuizStepValue=' + QuizStepValue;
	}
	if (QuizTimeLimit != "") {
		str += '&QuizTimeLimit=' + QuizTimeLimit;
	}
	if (QuizTimeColor != "") {
		str += '&QuizTimeColor=' + QuizTimeColor;
	}
	if (QuizDisplayPF != "") {
		str += '&QuizDisplayPF=' + QuizDisplayPF;
	}
	if (QuizEnablePrintSC != "") {
		str += '&QuizEnablePrintSC=' + QuizEnablePrintSC;
	}
	if (QuizNote != "") {
		str += '&QuizNote=' + QuizNote;
	}
	if (QuizTextWindow != "") {
		str += '&QuizTextWindow=' + QuizTextWindow;
	}
	if (QuizStepAudio != "") {
		str += '&QuizStepAudio=' + QuizStepAudio;
	}
	if (QuizActionAudio != "") {
		str += '&QuizActionAudio=' + QuizActionAudio;
	}
	if (QuizNarration != "") {
		str += '&QuizNarration=' + QuizNarration;
	}
	if (QuizAllowEmail != "") {
		str += '&QuizAllowEmail=' + QuizAllowEmail;
	}
	if (QuizEmailTo != "") {
		str += '&QuizEmailTo=' + QuizEmailTo;
	}
	if (QuizAutoEmail != "") {
		str += '&QuizAutoEmail=' + QuizAutoEmail;
	}
	if (QuizTimeSpent != "") {
		str += '&QuizTimeSpent=' + QuizTimeSpent;
	}
	if (QuizCorrectStep != "") {
		str += '&QuizCorrectStep=' + QuizCorrectStep;
	}
	if (QuizIncorrectStep != "") {
		str += '&QuizIncorrectStep=' + QuizIncorrectStep;
	}
	if (QuizYourPoint != "") {
		str += '&QuizYourPoint=' + QuizYourPoint;
	}
	if (QuizTotalPoint != "") {
		str += '&QuizTotalPoint=' + QuizTotalPoint;
	}
	return (str);
}
function getFlashContent(playmode) {
	var strVars = getFlashParams();
	if (playmode == 4) {
		strVars += getFlashAsmParams();
	}
	if (playmode == 3) {
		strVars += getFlashQuizParams();
	}
	return (strVars);
}
function playSWF(playMode, nWidth, nHeight)
{
	var SimWidth = -1;
	var SimHeight = -1;
	var windowWidth1, windowHeight1;
	if (typeof StepTraceItem != "undefined") {
		StepTraceItem.playmode = playMode;
	}
	if (isInternetExplorer) {
		if(nWidth == -1) {
			maximize();
			SimWidth = document.body.clientWidth;
			SimHeight = document.body.clientHeight;
		} else if(nWidth<0) {
			SimWidth = Math.abs(nWidth);
			SimHeight = Math.abs(nHeight);
			windowWidth1 = Math.abs(nWidth);
			windowHeight1 = Math.abs(nHeight);
			Steps_pane_width = Math.min(Math.max(window.screen.availWidth - windowWidth1-10, 204), 450);
			Description_pane_height = 60;
			Browser_titlebar_height = 55;
			if(((leftPane == 0)&&(rightPane == 0))||
				(playMode == '3' && (QuizNarrationPosition == 0 || QuizNarrationPosition == 3)) ||
				(playMode == '4' && (AssNarrationPosition == 0 || AssNarrationPosition == 3))){
				Steps_pane_width = 30;
			}

			SimWidth = Math.min(Steps_pane_width + windowWidth1+6, window.screen.availWidth);
			if(bottomPane){
				SimHeight = Description_pane_height + windowHeight1 + Browser_titlebar_height;
			} else {
				SimHeight = windowHeight1 + Browser_titlebar_height;
			}
			SimHeight = Math.min(SimHeight, window.screen.availHeight);
		} else {
			SimWidth = nWidth;
			SimHeight = nHeight;
		}
	} else {
		if(nWidth<0) {
			SimWidth = window.innerWidth - 2;
			SimHeight = window.innerHeight - 2;
		} else {
			SimWidth = nWidth;
			SimHeight = nHeight;
		}
	}

	var   strVars = 'IsIntegrate=1&PlayMode=' + playMode + 
			'&StartStep=' + startStep + 
			'&SimWidth=' + (SimWidth-6) + 
			'&SimHeight=' + (SimHeight-6);
		if (!bAutoStart) {
			strVars += getFlashContent(playMode);
		}
	detectFlash();
	var FlashWidth = SimWidth; 
	var FlashHeight = SimHeight;
	if(nWidth < -1) {
		FlashWidth -= 16;
		FlashHeight -= 31;
	}
	var tempWidth=window.screen.availWidth-10;
	var tempHeight=window.screen.height - 30;

	if(FlashWidth > tempWidth) FlashWidth = tempWidth;
	if(FlashHeight > tempHeight) FlashHeight = tempHeight;
	strVars += '&clientWidth=' + FlashWidth; 
	strVars += '&clientHeight=' + FlashHeight;
	var str = "<table><tr><td align=\"top\">";

	str +=  '<object width="' + (FlashWidth) + '" height="' + (FlashHeight) + '" '+
			'classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" '+
			'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#4,0,0,0" id="flashswf">'+
			'<param name="movie" value="' + strSWFName + '">'+
			'<param name="flashvars" value="' + strVars + '"/>' +
			'<embed src="' + strSWFName + '" swLiveConnect=true quality="high" bgcolor="#ffffff" ' +
			'width="' + SimWidth + '" height="' + SimHeight + '" id="flashswf" name="flashswf" ' +
			'align="middle" allowScriptAccess="sameDomain" ' +
			'type="application/x-shockwave-flash" ' +
			'pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="' + strVars + '"/>' +
			'</object>' + 
			'</td></tr></table>';
	LaunchFlash(str);
	window.setTimeout('setFlashFocus()',500);
	if(nWidth < -1) {
		var strResize = 'resize('+(SimWidth)+','+(SimHeight)+')';
		window.setTimeout(strResize,100);
	} else {
//		window.setTimeout('maximize()',100);
	}
	if (nWidth>0) {
		// Operner is not index page
		var indPage = 0;
		if ((window.opener != null) && (typeof window.opener != 'undefined')) {
			if (typeof window.opener.SoftSimCourse != 'undefined') {
				indPage = 1;
			}
		} 
		if (indPage != 1)  {
			SimHeight += 40; 
			if (SimHeight>window.screen.availHeight) {
				SimHeight = window.screen.availHeight;
			}
			SimWidth += 20;
			if (SimWidth>window.screen.availWidth) {
				SimWidth = window.screen.availWidth;
			}
			var strResize = 'resize('+(SimWidth)+','+(SimHeight)+')';
			window.setTimeout(strResize,100);
		}
	}	
	window.onbeforeunload = beforeUnload;
	window.onunload = exitFlashSimulation;
}
//detect flash player to inform user should play playback wirh flash player 7
//Date: 6/18/2004
//Added by Vietle
var flash2Installed = false;    // boolean. true if flash 2 is installed
var flash3Installed = false;    // boolean. true if flash 3 is installed
var flash4Installed = false;    // boolean. true if flash 4 is installed
var flash5Installed = false;    // boolean. true if flash 5 is installed
var flash6Installed = false;    // boolean. true if flash 6 is installed
var flash7Installed = false; 
var flash8Installed = false; 
var flash9Installed = false; 
var flash10Installed = false; 
var maxVersion = 10;             // highest version we can actually detect
var actualVersion = 0;          // version the user really has
var hasRightVersion = false;    // boolean. true if it's safe to embed the flash movie in the page
var jsVersion = 1.0;            // the version of javascript supported

var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;    // true if we're on ie
var isWin = (navigator.appVersion.indexOf("Windows") != -1) ? true : false; // true if we're on windows
if(isIE && isWin){
  document.write('<SCR' + 'IPT LANGUAGE=VBScript\> \n');
  document.write('on error resume next \n');
  document.write('flash2Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.2"))) \n');
  document.write('flash3Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.3"))) \n');
  document.write('flash4Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.4"))) \n');
  document.write('flash5Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.5"))) \n');  
  document.write('flash6Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.6"))) \n');  
  document.write('flash7Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.7"))) \n');  
  document.write('flash8Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.8"))) \n');  
  document.write('flash9Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.9"))) \n'); 
  document.write('flash10Installed = (IsObject(CreateObject("ShockwaveFlash.ShockwaveFlash.10"))) \n'); 
  document.write('</SCR' + 'IPT\> \n'); // break up end tag so it doesn't end our script
}

function detectFlash() {  
  // If navigator.plugins exists...
  if (navigator.plugins) {
    // ...then check for flash 2 or flash 3+.
    if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {

      var isVersion2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
      var flashDescription = navigator.plugins["Shockwave Flash" + isVersion2].description;

      var flashVersion = parseInt(flashDescription.charAt(flashDescription.indexOf(".") - 1));
     
      flash2Installed = flashVersion == 2;    
      flash3Installed = flashVersion == 3;
      flash4Installed = flashVersion == 4;
      flash5Installed = flashVersion == 5;
      flash6Installed = flashVersion == 6;
      flash7Installed = flashVersion == 7;
      flash8Installed = flashVersion == 8;
	  flash9Installed = flashVersion == 9;
	  flash10Installed = flashVersion == 10;
    }
  }
  	
	for (var i = 2; i <= maxVersion; i++) {	
		if (eval("flash" + i + "Installed") == true) actualVersion = i;
	}
//	alert(actualVersion);
	if(navigator.userAgent.indexOf("WebTV") != -1) actualVersion = 2;	
	if(actualVersion < 8) { alert("The current version of Flash player is " + actualVersion + "\n The Flash playback works correctly with version 8 or later. \n You should download new version from Adobe website: http://www.adobe.com/"); }
}
function startFlashPlayback(){
	playSWF(playMode, windowWidth, windowHeight);
}