var sURLlink = "";
var bPlaySequence = 0;
var bRAccess = 0;
var bApplySystem = true;
var bSync = true;
var iCurrDivHead  = 0;
var iTOCTableWidth = 10;
var bTreeDisplay = false;
var bNormal = true;
//var sMovieFile ="";
var sMoviePath ="";
var iOldClipindex = -1;
var iClipindex = 1;
var bSwap = 0;
var iCurrSlide = 0;
var debug = false;
var bTOCVisible = true;
var bDareaVisible = false;
var g_ignoreThis = false;
var bInitVideoStatus = true;
var sTotalVideoLength = "";
var bPreviewVideoEnd = false;
var bVideoEnd = false;
var bPreviewTimelinePause = false; //check status of button in Timeline(In preview mode)
var bScormInit = 1;
var iSetScormPosTimer = -1;
var preLoopNum = 0;
var sFileURLheader = "file:///";
var bNoCount = true;
var iFirstMarkerNum = 1;
var bFirstEnter = true;
var bFirst = true;
var snowCursor = "";
var bIsCSS = true;
var DivVisible = "";
var Div1Visible = "";
var iAniIdx = 0;
var iAniIdx1 = 0;
var sbgpic = "";
var textOff;
var textOn;	
var sASXURL = "";
var bVer5 = false ; 
var iWaitTime = 1000;
var ipostponeTimer = -1;
var ievent1Timer = -1;
var ievent2Timer = -1;
var iTemplateTimer = -1;
var bHasVideo = -1;
var iTimerFontSize = 12;
var ssymbol = ":";
var impTimerID = -1;
var bIfDownload = false;
var ititleMarker = 1;
var bPressPauseButn = true;
var iLoadCSSFileCount = 0;
var igMarkerNum = 1;
var bRandom = false;
var bStop = false;
var igPlayState;
var iTOCNumbers = 0;
var bReset = false;
var Styles = new Array();
var bLoadCSSFileOK = false;
var iLoadCSSTimerID=-1;
var ipreTemplateOrder = 0;
var TemplateOrder = 1;
var templateArray = new Array();
var sImagestr = new DataArray("playerplaypause", "playerplaypause", "playerprevious", "playernext", "playerstop", "SlideMax", "VideoMax", "SwapVP", "SlideNormal", "ViewScore", "preSlide", "nextSlide", "SyncData");
var sTinfo = "";
var factor =1;
var inowFileNum = 0;
var iFileNum = 2;
var bMP7 = 1;
var buttonImage = new Array();
var bAllow = true;
var imutexTimer = -1;

var iNumTOC = 0;
var sFile1 = "";
var sFile2 = "";
var bFirst = true;
var bIfDownload = false;
var bNoEvent1 = false;
var bNoEvent2 = false;

var snowTemplateDirName = "";
var sPreTemplateDirName = "";
var sPreEvent1File = "";
var sPreEvent2File = "";
var sFileNumMap = new DataArray("0", "1", "1", "1", "1", "2", "2", "2", "0", "0");

var sTemplateAtMarker = new Array();
var sTemplateArguAtMarker = new Array();
var sTemplateOrderAtMarker = new Array();
var sEvent1AtMarker = new Array();
var sEvent1Lists = new Array();
var sEvent1Time = new Array();
var sEvent2AtMarker = new Array();
var sDareaAtMarker = new Array();
var sPenDrawAtE1 = new Array();
var sPenDrawAtE2 = new Array();
var sAniAtE1 = new Array();
var sAniAtE1Data = "0";
var sAniAtE2 = new Array();    
var sAniAtE2Data = "0";
var sTimeArray = new Array();        

var iHintTemplate = new Array();
var iHintEvent1 = new Array();
var iHintEvent2 = new Array();
var iHintDarea = new Array();
var iTOCAtMarker = new Array();
var iTOCIndexAtMarker = new Array();                    
var iTotalMarkers = 0;

var iNowCursor=1;
var iPreCursor=1;
var iTemplateIdx =1;

//for navigate control
var QuizNum = 0;  //Quiz计
var Quiz = new Array(); //Quiz祇ネ丁
var nowQuiz;  //ヘ玡Quiz祇ネ丁
var GradePass = true; //Θ罿琌の
var NumPass = true; //琌禬筁氮Ω计
var Navmessage; //璶╭癟
var InQuiz = false;     //ヘ玡TOC琌琌Quiz
var bQuizContent = false; //耞琌璹璶ЧΘQuiz
var bChangebyTOC = false; //琌ノlinkよΑэ跑TOC(ぃ続ノmedia playertime barэ跑)
var skipLQuiz = false; //琌铬筁LoadQuizevent
var nMarker;
var numMarker;
var ISQuiz = false;
var RandomaccessTime = 0;
var ScrollXp;
var ScrollYp;
var bRandomAccess = false;

var bLoadQuiz = false;
var bRaccessCallUpdate = false;

var bStopStatus = true; //for WMP7.1 issue
var absolutePath;
var MediaParam;

function continuePlaying()
{
	if (typeof(MediaPlayer1)=="object")
	{
		if (bFirst)
		{
			inowFileNum ++;	
			if (inowFileNum >= iFileNum) 
			{
		 		if (bFirst) bFirst=false;
		 		setTemplateIdx("1", sTinfo);
				/*if (bMP7) MediaPlayer1.controls.play();
				else MediaPlayer1.play();*/
				PlayFun();
				/*if (MediaPlayer1.playState != iStatePlay)
				{
					pauseTimer(0);			
					ipostponeTimer = setTimeout("postponePlaying()", iWaitTime/2);
				}*/	
				bReset = false;
			}else
			{
				if (sASXURL == "file")			
				{
					if (bMP7) MediaPlayer1.controls.pause();
					else 
						if (MediaPlayer1.PlayState != 6) MediaPlayer1.pause();		
				}	
			}
		}else	
		{
			if (igPlayState == iStatePlay && !InQuiz)
			{
				if (bMP7) MediaPlayer1.controls.play();
				else MediaPlayer1.play();	 		
				PlayFun();
				bReset = false;
			}	
		}
	}	
}    
    function DataArray()
    {
    	var args = DataArray.arguments;
    	for (var i=0;i<args.length;i++) this[i] = args[i];
    	this.length = args.length;
    }
    function SpecificArray(size)
    {
    	for (var i=1;i<=size;i++) this[i] = null;
    	this.length = size;
    }
    function printpage(iPos, iType)
    {
         try
         {

            var i;
    	    var sTOC = "";
            var sTemplate = "";
            var sFiles = "";
            var sHead = "";
            var sTemp = "";
            var s_second = "";
            var s_minute = "";
            var s_hour = "";
            var iSecond=0;
            var iMinute=0;
            var iHour=0;

            var iTemplateOrderNum = 0;
            var iTOCindex = 0;
            var iTindex = 0;
            var iE1index = 0;
            var iE2index = 0;
            var iDareaindex = 0;
            var bNoAni = true;
            var bGetFile = false;

            iNumTOC = 0;
            iTotalMarkers = iNumMarkers;
            QuizNum = 0;

            var sParamArray = new Array();
            var sNameArray = new SpecificArray(iNumMarkers);
            var sNameLink = new SpecificArray(iNumMarkers);
            var iLevel = new Array();
            var s_tempTime = "";
            var markerHeading = "";
            var BlueSection = "";           
            var iNowSlide = 0;
            
            sPreTemplateDirName = "";
            var i_ZeroSpace = 0;

	    var ParamLists = "";	
	    var mTimeLists = "";	
	    var mNameLists = "";	
	    var mNameLenLists = "";
	    var title = "";
	    var mediatitle = "";
	    var TitleFont = "";
	    var MarkerFont = "";
	    var AuthorFont = ""; 
	    var AuthorMail = "";
	    var copyright = "";
	    var getstr;
	    var getstrlength;
	    var j=0;
	    var sTOCDIVidx = "";
	    var sTOCDIVidxHead = "";
	    for (var idx=0;idx<6;idx++) iLevel[idx] = 0;   	    

	    if (!parent.bPreview)
	    {
		charsetvalue = str_asx[0];	
		AuthorMail = str_asx[1];	
		sbgpic = str_asx[2];	
		sASXURL = str_asx[3];	
		sTinfo = str_asx[4];
		sTinfo = sTinfo.substring(0, sTinfo.lastIndexOf("-"));
		TitleFont = str_asx[5];
		MarkerFont = str_asx[6];		
		AuthorFont = str_asx[7];
		DescFont = str_asx[8];
		media_bg = str_asx[9];	
		mediatitle = str_asx[10];
		Author = str_asx[11];
		copyright = str_asx[12];
		description = str_asx[13];
		if (str_asx[14] == "1") bHasVideo = -1;
		else bHasVideo = 0;

		MarkerHeading = str_asx[15];
		bTreeDisplay = parseInt(str_asx[17]);
		bApplySystem = parseInt(str_asx[18]);
		bPlaySequence = parseInt(str_asx[19]);
		bRAccess = parseInt(str_asx[20]);
		sURLlink = str_asx[21];
	    }else
	    {
		TitleFont=document.MediaPlayer1.GetMediaParameter(1,"TitleFont").split("\0")[0];
		AuthorFont=document.MediaPlayer1.GetMediaParameter(1,"AuthorFont").split("\0")[0];
		MarkerFont=document.MediaPlayer1.GetMediaParameter(1,"MarkerFont").split("\0")[0];
		DescFont=document.MediaPlayer1.GetMediaParameter(1,"DescFont").split("\0")[0];
		mediatitle =document.MediaPlayer1.GetMediaParameter(1,"movieTITLE").split("\0")[0];
		AuthorMail = document.MediaPlayer1.GetMediaParameter(1,"AuthorMail").split("\0")[0];
		Author = document.MediaPlayer1.GetMediaParameter(1,"movieAUTHOR").split("\0")[0];
		copyright = document.MediaPlayer1.GetMediaParameter(1,"movieCOPYRIGHT").split("\0")[0];
		description = document.MediaPlayer1.GetMediaParameter(1,"movieDESC").split("\0")[0];
		sASXURL = document.MediaPlayer1.GetMediaParameter(1,"link").split("\0")[0];
		sbgpic=document.MediaPlayer1.GetMediaParameter(1,"background").split("\0")[0];
		charsetvalue = document.MediaPlayer1.GetMediaParameter(1,"charset").split("\0")[0];
		sTotalVideoLength=document.MediaPlayer1.GetMediaParameter(1,"TotalVideoLength").split("\0")[0];
		if (document.MediaPlayer1.GetMediaParameter(1,"HasVideo").split("\0")[0] == "1") bHasVideo = -1;
		else bHasVideo = 0;
		media_bg = document.MediaPlayer1.GetMediaParameter(1,"Image").split("\0")[0];
		MarkerHeading = document.MediaPlayer1.GetMediaParameter(1,"MarkerHeading").split("\0")[0];
		sTinfo1=document.MediaPlayer1.GetMediaParameter(1,"Tinfo").split("\0")[0];	
		sTinfo=sTinfo1.substring(0, sTinfo1.lastIndexOf("-"));					
		bTreeDisplay = parseInt(document.MediaPlayer1.GetMediaParameter(1,"bTreeDisplay").split("\0")[0]);
		bApplySystem = parseInt(document.MediaPlayer1.GetMediaParameter(1,"bApplySystem").split("\0")[0]);		
		sQuizPassNum=document.MediaPlayer1.GetMediaParameter(1,"QuizExamMAX").split("\0")[0];
		sQuizScore=document.MediaPlayer1.GetMediaParameter(1,"QuizScore").split("\0")[0];
		sQuizWeight=document.MediaPlayer1.GetMediaParameter(1,"QuizWeight").split("\0")[0];
		bRef=parseInt(document.MediaPlayer1.GetMediaParameter(1,"bReference").split("\0")[0]);		
		if(bRef) Darea.location.reload(true);		
		var QuizPassNumToken = new Array();
		var QuizScoreToken = new Array();
		var QuizWeightToken = new Array();	
		if(sQuizScore != "")
		{
			QuizPassNumToken = sQuizPassNum.split(";");
			QuizScoreToken = sQuizScore.split(";");
			QuizWeightToken = sQuizWeight.split(";");					
			for(var nQuiz=0;nQuiz<QuizScoreToken.length;nQuiz++)
			{
				QuizInfo[nQuiz] = new Array();
				QuizInfo[nQuiz][0] = parseInt(QuizPassNumToken[nQuiz]);
				QuizInfo[nQuiz][1] = parseInt(QuizScoreToken[nQuiz]);
				QuizInfo[nQuiz][2] = parseInt(QuizWeightToken[nQuiz]);
			}
		}	
	    }	
	    bInitVideoStatus = bHasVideo;	        
	    if (bRef || bDarea) bIfDownload = true;
	    else bIfDownload = false;		
		
	    if (TitleFont=="") TitleFont = " " ;
	    if (AuthorFont=="") AuthorFont = " " ;
	    if (MarkerFont=="") MarkerFont = " " ;
	    if (DescFont=="") DescFont = " " ;
	    if (charsetvalue=="") charsetvalue = " " ;
	    if (mediatitle =="") mediatitle = " " ;
	    if (AuthorMail  =="") AuthorMail = " " ;
	    if (Author =="") Author = " " ;
	    if (copyright =="") copyright = " " ;
	    if (sASXURL =="") sASXURL = " " ;
	    if (sbgpic =="") sbgpic = " " ;
	    if (description =="") description = " " ;	        	
	    if (!bHasVideo) mppic.src = media_bg;
	    mediatitle = processStr(mediatitle);
	    AuthorMail = processStr(AuthorMail);	
	    Author = processStr(Author);
	    copyright = processStr(copyright);	
	    description = processStr(description);
            sParamArray[0] = sbgpic;
            sParamArray[1] = TitleFont ;
            sParamArray[2] = AuthorFont ;
            sParamArray[3] = MarkerFont ;
            sParamArray[4] = mediatitle ;
            sParamArray[5] = AuthorMail ;
            sParamArray[6] = Author ;
            sParamArray[7] = copyright ;
            sParamArray[8] = sASXURL ;
            sParamArray[9] = description ;
            sParamArray[10] = DescFont ;
            sParamArray[11] = charsetvalue ;
            sParamArray[12] = bMP7 ;
            sParamArray[13] = MarkerHeading;

            if (!parent.bPreview)
            	sNameArray = SAArguments;
            else
            {
            	var sGet;
            	var ActualNUM = 1;
            	for (var i = 1; i <= iNumMarkers; i++)
            	{
            		var temp = '';
            		sGet = processStr(document.MediaPlayer1.GetMarkerName(i));            		
            		//Fix-BugCode : SAR031023-0004
            		if(sGet != "-1")
            		{
            			for(var j = 0; j<= sGet.length; j++)
            			{
            				if(sGet.charAt(j) == '%')
            				{
	            				temp = temp + '%';
        	    				j = j+2;
            				}
            				else
            				{
	            				temp = temp + sGet.charAt(j);
        	    			}
            			}
            			sNameArray[ActualNUM] = sGet;
	            		sNameLink[ActualNUM] = temp;            		            		
        	    		sTimeArray[ActualNUM-1] = document.MediaPlayer1.GetMarkerTime(i).toString(10);
        	    		
        	    		ActualNUM++;
        	    	}        	    	
        	    	else
        	    	{
        	    		var NameTemp = document.MediaPlayer1.GetMarkerName(i);
        	    		var TimeTemp = document.MediaPlayer1.GetMarkerTime(i);
        	    		SAScrollINFO[iScrollNUM] = TimeTemp + "|" +  NameTemp.substring(0, NameTemp.indexOf("!!"));        	    		
        	    		iScrollNUM++;
        	    	}
        	    	
            	}
            	iNumMarkers = ActualNUM -1;	            		
            }
                                    
            TOCHeading(sParamArray[0], sParamArray[1], sParamArray[2], sParamArray[3], sParamArray[10], sParamArray[11]);
            if(bApplySystem)
            {            
	            textspace.document.writeln("<div id=\"header\" class=\"TitleStyle\">" + sParamArray[4] + "</div>");
	
		    if ( sParamArray[5] != " ")
	            {
	                textspace.document.write("<a href=\"mailto:" + sParamArray[5] + "\"><div id=\"emaillink\" class=\"AuthorStyle\">" + sParamArray[6] +"</div></a>");
	            }else
	            {
			textspace.document.writeln("<div id=\"emaillink\" class=\"AuthorStyle\">" + sParamArray[6] + "</div>");
	            }
	   	    textspace.document.writeln("<div id=\"copyright\" class=\"AuthorStyle\">" + sParamArray[7] + "</div>");
	            textspace.document.writeln("<div id=\"description\" class=\"DescStyle\">" + sParamArray[9] + "</div><br>");
		    textspace.document.writeln("<div id=\"TOCdata\" class=\"MarkerStyle\">");	
	    }else
	    {
	            textspace.document.writeln("<div id=\"header\" class=\"\">" + sParamArray[4] + "</div>");
	
		    if ( sParamArray[5] != " ")
	            {
	                textspace.document.write("<a href=\"mailto:" + sParamArray[5] + "\"><div id=\"emaillink\" class=\"\">" + sParamArray[6] +"</div></a>");
	            }else
	            {
			textspace.document.writeln("<div id=\"emaillink\" class=\"\">" + sParamArray[6] + "</div>");
	            }
	   	    textspace.document.writeln("<div id=\"copyright\" class=\"\">" + sParamArray[7] + "</div>");
	            textspace.document.writeln("<div id=\"description\" class=\"\">" + sParamArray[9] + "</div><br>");
		    textspace.document.writeln("<div id=\"TOCdata\" class=\"\">");	    	
	    } 
	   
  	    for (var j=0;j<iNumMarkers;j++)
            {
                        sTOC = "";
  			bInsert = false;
                        sNameArray[j+1] = ProcessTemplateArgu(sNameArray[j+1]);
                        if(!parent.bPreview)
                        {
                        	if (sNameArray[j+1].substring(0,2) == "|<" || sNameArray[j+1].substring(0,2) == "|\"")                      	                           	
                                	sTOC = sNameArray[j+1].substring(sNameArray[j+1].indexOf("?")+1, sNameArray[j+1].length);                           
                        }
                	else
                	{                        
                        	if(sNameArray[j+1].substring(0,2) == "|?" || sNameArray[j+1].substring(0,2) == "|\"")                        
                        		sTOC = sNameLink[j+1].substring(sNameLink[j+1].indexOf("?")+1, sNameLink[j+1].length);                        
                	}
			sTemplate = sNameArray[j+1].substring(0, sNameArray[j+1].indexOf("|"));
                        if (sTemplate == "")
                        {
     			        sTemplateAtMarker[j] = "";
                                sTemplateArguAtMarker[j] = "0";
                                sTemplateOrderAtMarker[j] = "0";
                                iHintTemplate[j] = iTindex;
                        }else
                        {
                                sTemplateArguAtMarker[j] = sTemplate.substring(sTemplate.lastIndexOf("-")+1, sTemplate.length);
                                sTemplate = sTemplate.substring(0, sTemplate.lastIndexOf("-"));
                                sTemplateAtMarker[j] = sTemplate;
     			        iTemplateOrderNum ++;
                                sTemplateOrderAtMarker[j] = iTemplateOrderNum.toString(10);
                                iTindex = j;
                                iHintTemplate[j] = -1;
                        }
			//buffer_template.append("Template [" + j + "]: "  + sTimeArray[j] + " -> " + sTemplateAtMarker[j] + " -- " + sTemplateArguAtMarker[j] + " -- " + sTemplateOrderAtMarker[j] + " -- " + iHintTemplate[j] + "\n") ;
     			if(sNameArray[j+1].substring(0,2) == "|?")
				sFiles = "";
			else
     				sFiles = sNameArray[j+1].substring(sNameArray[j+1].indexOf("|")+1, sNameArray[j+1].lastIndexOf("?"));

                        sTemp = sFiles;

                        sPenDrawAtE1[j] = "0";
                        sPenDrawAtE2[j] = "0";
                        sAniAtE1[j] = "0";
                        sAniAtE2[j] = "0";
                        bGetFile = false;
                        if ((sTemp.indexOf("<")!=-1)||(sTemp.indexOf(">")!=-1))
                        {
                        	if (sTemp.indexOf("<")!=-1)
                            	{
                                	BlueSection = sTemp.substring(sTemp.indexOf("<"), sTemp.length);
                                	sPenDrawAtE1[j] = sTemp.substring(BlueSection.indexOf("<")+1, BlueSection.indexOf(":"));
                                	if (!bGetFile)
                                	{
                                		sFiles = sTemp.substring(0,sTemp.indexOf("<"));
                                		bGetFile = true;
                                	}
                            	}
                            	if (sTemp.indexOf(">")!=-1)
                            	{
                                	BlueSection = sTemp.substring(sTemp.indexOf(">"), sTemp.length);
                                	sPenDrawAtE2[j] = BlueSection.substring(BlueSection.indexOf(">")+1, BlueSection.indexOf(":"));
                                	if (!bGetFile)
                                	{
                                    		sFiles = sTemp.substring(0,sTemp.indexOf(">"));
                                    		bGetFile = true;
                                	}
                            	}
                        }
                        //0508 : it's OK because * is the subset of **
                        if ((sTemp.indexOf("**")!=-1)||(sTemp.indexOf("*")!=-1))
                        {
                            	bNoAni = false;
                            	if (sTemp.indexOf("**")!=-1)
                            	{
                                	BlueSection = sTemp.substring(sTemp.indexOf("**"), sTemp.length);
                                	sAniAtE1[j] = BlueSection.substring(BlueSection.indexOf("**")+2, BlueSection.indexOf(":"));
                                	//AniAtE1Data data is for no ** situation use
                                	sAniAtE1Data = sAniAtE1[j];
                                	if (!bGetFile)
                                	{
                                    		sFiles = sTemp.substring(0,sTemp.indexOf("**"));
                                    		bGetFile = true;
                                	}
                                	//if (BlueSection.indexOf(":") == BlueSection.length) BlueSection = BlueSection.substring(BlueSection.indexOf(":")+1, BlueSection.length);
                                        BlueSection = BlueSection.substring(BlueSection.indexOf(":")+1, BlueSection.length);
                            	}else
                                {
                                        BlueSection = sTemp.substring(sTemp.indexOf("*")-1, sTemp.length);
                                        sAniAtE1[j] = sAniAtE1Data;
                                }
                    		//if (sTemp.indexOf("*")!=-1)
                                if (BlueSection.indexOf("*")!=-1)
                    		{
                                        if (!bGetFile)
                                        {
                                                sFiles = sTemp.substring(0,sTemp.indexOf("*"));
                                                bGetFile = true;
                                        }
                                        sAniAtE2[j] = BlueSection.substring(BlueSection.indexOf("*")+1, BlueSection.indexOf(":"));
                                        sAniAtE2Data = sAniAtE2[j];
                    		}else sAniAtE2[j] = sAniAtE2Data;

                	}else
                	{
                    		bNoAni = true;
                    		sAniAtE1[j] = sAniAtE1Data;
                    		sAniAtE2[j] = sAniAtE2Data;
                	}
                	if (sFiles == "")
                	{
                    		sEvent1AtMarker[j] = "";
                    		sEvent2AtMarker[j] = "";
                    		sDareaAtMarker[j] = "";
                    		iHintEvent1[j] = iE1index;
                    		iHintEvent2[j] = iE2index;
                    		iHintDarea[j] = iDareaindex;                    		
                	}else
                	{
		    		if (sFiles.indexOf("|")==-1)
                    		{
                        		//if ((sTemplateAtMarker[j] == "8") || (sTemplateAtMarker[j] == "9"))
                        		if ((sTemplateArguAtMarker[j] == "8") || (sTemplateArguAtMarker[j] == "9"))
                        		{
	                                    	sEvent1AtMarker[j] = "";
	                                    	iHintEvent1[j] = iE1index;
                            			sDareaAtMarker[j] = sFiles;
	                                    	iDareaindex = j;
                        		}else
                        		{
                        			//for navigate control
                        			if (sFiles.charAt(0) == '"') bQuizShowup = 1;
                        			else bQuizShowup = 0;
                        			
                            			sEvent1AtMarker[j] = sFiles;
                            			//iHintEvent1[j] = j;
                            			iE1index = j;
                            			sDareaAtMarker[j] = "";
                            			iHintDarea[j] = iDareaindex;
                    				if(!bQuizShowup)                           			
                            			{                    					
                    					if((iNowSlide == 0) || ((iNowSlide>0) && (sEvent1Lists[iNowSlide-1] != sFiles)))
                    					{
                    						bInsert = true;
                    						sEvent1Lists[iNowSlide] = sFiles;                    						                    					
                    					}
                    				}
                        		}
					sEvent2AtMarker[j] = "";
                        		iHintEvent2[j] = iE2index;
		    		}else
                    		{
	                                sEvent1AtMarker[j] = sFiles.substring(0, sFiles.indexOf("|"));
	                                
	                                //for navigate control
	                                if (sEvent1AtMarker[j].charAt(0) == '"') bQuizShowup = 1;
                        		else bQuizShowup = 0;
	                                
	                                if (sEvent1AtMarker[j] == "")
	                                	iHintEvent1[j] = iE1index;
	                                else
	                                	iE1index = j;
	                                sFiles = sFiles.substring(sFiles.indexOf("|")+1, sFiles.length);
	       			        if (sFiles.indexOf("|")==-1)
	                                {
	     				    	if ((sTemplateArguAtMarker[j] == "1") || (sTemplateArguAtMarker[j] == "2") || (sTemplateArguAtMarker[j] == "3") || (sTemplateArguAtMarker[j] == "4"))
	                                    	{
	                                        	sEvent2AtMarker[j] = "";
	                                        	iHintEvent2[j] = iE2index;
	                                        	sDareaAtMarker[j] = sFiles;
	                                        	iDareaindex = j;
	                                    	}else
	                                    	{
	                                        	sEvent2AtMarker[j] = sFiles;
	                                        	iE2index = j;
	                                        	sDareaAtMarker[j] = "";
	                                        	iHintDarea[j] = iDareaindex;
	                                    	}
	                                }else
	                                {
	       				    	sEvent2AtMarker[j] = sFiles.substring(0, sFiles.indexOf("|"));
	                                    	sDareaAtMarker[j] = sFiles.substring(sFiles.indexOf("|")+1, sFiles.length);
	                                    	if (sEvent2AtMarker[j] == "")
	                                      		iHintEvent2[j] = iE2index;
	                                    	else
	                                      		iE2index = j;
	                                    	if (sDareaAtMarker[j] == "")
	                                      		iHintDarea[j] = iDareaindex;
	                                    	else
	                                      		iDareaindex = j;
	                                }
		    		}
                	}
                        /* we will use million second to be time base. So when show correct time on TOC
                        we should re-calculate it into a proper form.
                        */
                        s_tempTime = "";
                        i_ZeroSpace = 0;
			if (!parent.bPreview)
	      			sTimeArray[j] = SATime[j+1].toString(10);
                        if (sTimeArray[j] != "0")
                        {                        	
                        	if (sTimeArray[j].indexOf(".") > -1)
                          	{
                                	i_ZeroSpace = sTimeArray[j].length - 1 - sTimeArray[j].indexOf(".") ;                                	
                                	if (i_ZeroSpace >3)
                                	{
                                      		i_ZeroSpace = 3;
                                      		s_tempTime = sTimeArray[j].substring(0,sTimeArray[j].indexOf(".")) + sTimeArray[j].substring(sTimeArray[j].indexOf(".")+1, sTimeArray[j].indexOf(".")+4);
                                	}else
                                	{
                                      		s_tempTime = sTimeArray[j].substring(0,sTimeArray[j].indexOf(".")) + sTimeArray[j].substring(sTimeArray[j].indexOf(".")+1, sTimeArray[j].length);
                                      		if (i_ZeroSpace == 2) s_tempTime = s_tempTime + "0";
                                      		if (i_ZeroSpace == 1) s_tempTime = s_tempTime + "00";
                                	}
                          	}else
                          	{
                               		i_ZeroSpace = 3;
                               		s_tempTime = sTimeArray[j] + "000";
                          	}
                          	sTimeArray[j] = s_tempTime;
                        }else s_tempTime = sTimeArray[j];
                  	if (bInsert)
                  	{
                  		sEvent1Time[iNowSlide] = s_tempTime;
                  		iNowSlide ++;
                  	}	                                           
                	var i_Time = parseInt(s_tempTime) / 1000;
                	iSecond = parseInt(i_Time % 60);
			iMinute = parseInt(i_Time / 60) % 60;
			iHour = parseInt(i_Time / 3600);
			if (iSecond < 10) s_second = "0" + iSecond;
                        else s_second = iSecond.toString(10);
			if (iMinute < 10) s_minute = "0" + iMinute;
                        else s_minute = iMinute.toString(10);
			if (iHour == 0)
				sHead = "(" + s_minute + ":" + s_second + ")";
			else
			{
				if (iHour < 10) s_hour = "0" + iHour;
                                else s_hour = iHour.toString(10);
				sHead = "(" + s_hour + ":" + s_minute + ":" + s_second + ")";
			}
                	if (sTOC == "")
                	{
                  		if (!bNoAni) iTOCAtMarker[j] = iTOCindex;
                  		else iTOCAtMarker[j] = 0;
                  		iTOCIndexAtMarker[j] = iNumTOC;
                  		iLevel[0] = iNumTOC;				
                	}else                		
                	{
                		iNumTOC ++;
                		iTOCindex = j + 1;
				sTOCTableHead = "";
				sTOCTableCell = "";				
				if (bTreeDisplay)
				{					
					if (sTOC.charAt(0) == '<') 
					{
						sTOCTableHead = "<td nowrap valign=top><img id=\"img" + iTOCindex.toString(10) + "\" src=\"ftv2mnode.gif\" onclick=\"changeicon(this, " + iTOCindex.toString(10) + ");\"></img></td>";
						sTOC = sTOC.substring(sTOC.lastIndexOf("<")+1, sTOC.length);		
						sTOCDIVidx = " id=\"div" + iTOCindex.toString(10) + "\"";
						sTOCDIVidxHead = "div" + iTOCindex.toString(10);
					}else if (sTOC.charAt(0) == '&') 
					{
						sTOCTableHead = "<td nowrap valign=top><img id=\"img" + iTOCindex + "\" src=\"ftv2blank.gif\"></img></td>";
						sTOC = sTOC.substring(1, sTOC.length);		
						sTOCDIVidx = " id=\"div" + iTOCindex.toString(10) + "\"";
						sTOCDIVidxHead = "div" + iTOCindex.toString(10);						
					}else
					{
						sTOCTableHead = "<td nowrap valign=top><img id=\"img" + iTOCindex + "\" src=\"ftv2blank.gif\"></img></td>";
						sTOCDIVidx = " id=\"" + sTOCDIVidxHead + "_" + "\"";
					}	
				}else
				{
					if (sTOC.charAt(0) == '<') sTOC = sTOC.substring(sTOC.lastIndexOf("<")+1, sTOC.length);	
					if (sTOC.charAt(0) == '&') sTOC = sTOC.substring(1, sTOC.length);	
				}
				
				if (sTOC.charAt(0) == '>') 
				{
					iLevel[1] ++ ;
					iNumTOC--;			
					if (sTOC.charAt(1) == '>')
					{
						iLevel[2] ++ ;	
						if (iLevel[1] > 1) iLevel[1]--;
						if (sTOC.charAt(2) == '>') 
						{
							iLevel[3] ++ ;							
							if (iLevel[2] > 1) iLevel[2]--;
							if (sTOC.charAt(3) == '>') 
							{
								iLevel[4] ++ ;
								if (iLevel[3] > 1) iLevel[3]--;
								if (sTOC.charAt(4) == '>')
								{
									iLevel[5] ++ ;
									if (iLevel[4] > 1) iLevel[4]--;
								}else
				 		 			iLevel[5] = 0;		 		 			 			 							 				  						 				 		 			
							}else
				 				iLevel[4] = 0;		 		 			 						 
						}else
				 			iLevel[3] = 0;		 		 	
					}else
					 	iLevel[2] = 0;		
					sTOC = sTOC.substring(sTOC.lastIndexOf(">")+1, sTOC.length);				 	 
				}else
				 	iLevel[1] = 0;
						
		
				iLevel[0] = iNumTOC;                		 			 	
				sTOCIndex = iLevel[0].toString(10);		
				for (idx=1;idx<6;idx++)
				{
					if ( iLevel[idx] != 0)
					{
						sTOCIndex = sTOCIndex + "." + iLevel[idx].toString(10);
						sTOCTableCell = sTOCTableCell + "<td nowrap width=" + iTOCTableWidth + " valign=top>&nbsp;</td>";
					}else break;
				}     
                  		                  		
                          	iTOCAtMarker[j] = iTOCindex;
                          	iTOCIndexAtMarker[j] = iNumTOC;
                          	
                          	//for nevigate control
                          	if(sFiles == "")
                          	{    
                          	        bQuizShowup = 0;                         	        
                          	}
                          	else
                          	{       
                          	 	bQuizShowup = 1;
                          	 	Quiz[QuizNum] = sTimeArray[j];  
                          	 	QuizNum++;                          	                           	 
                          	}

                          	if ((sParamArray[13] == "0")||(sParamArray[13] == "2")) markerHeading = "";
                          	else if ((sParamArray[13] == "1")||(sParamArray[13] == "3")) markerHeading = sTOCIndex + ".";
                          	if ((sParamArray[13] == "0")||(sParamArray[13] == "1")) sHead = "";
                      		if (!bMP7)
                      		{
                            		if ((sParamArray[8] == "file") || (sParamArray[0] == "mms"))
                                		textspace.document.writeln("<div" + sTOCDIVidx + " onclick=\"javascript:parent.goto("+sTimeArray[j]+ "," + bQuizShowup + ")\" style=\"cursor: hand\"><table id=title"+iTOCindex.toString(10) + " class=\"MarkerStyle\"><tr>" + sTOCTableHead + sTOCTableCell + "<td nowrap valign=top>" + markerHeading + "</td><td valign=top>" +  sTOC + " " + sHead + "</td></table></div>"); //玡ぃ传︽, ゅ传
                            		else                                		
                                		textspace.document.writeln("<div" + sTOCDIVidx + " style=\"cursor: hand\"><table id=title"+iTOCindex.toString(10) + "  class=\"MarkerStyle\"><tr>" + sTOCTableHead + sTOCTableCell + "<td nowrap valign=top>" + markerHeading + "</td><td valign=top>" +  sTOC  + " " + sHead + "</td></table></div>"); //玡ぃ传︽, ゅ传
                      		}else
                      		{
                      			if(bRAccess == FREEACCESS)
                            			textspace.document.writeln("<div" + sTOCDIVidx + " onclick=\"javascript:parent.goto("+sTimeArray[j]+ "," + bQuizShowup + ")\"  style=\"cursor: hand\"><table id=title"+iTOCindex.toString(10) + "  class=\"MarkerStyle\"><tr>" + sTOCTableHead + sTOCTableCell + "<td nowrap valign=top>" + markerHeading + "</td><td valign=top>" +  sTOC  + " " + sHead + "</td></table></div>");
                            		else
                            			textspace.document.writeln("<div" + sTOCDIVidx + "><table id=title"+iTOCindex.toString(10) + "  class=\"MarkerStyle\"><tr>" + sTOCTableHead + sTOCTableCell + "<td nowrap valign=top>" + markerHeading + "</td><td valign=top>" +  sTOC  + " " + sHead + "</td></table></div>");
					
                            	}
           		}
            	}
            	textspace.document.writeln("</div></body></html>");
            	textspace.Changefontsize();
            	
            	if(parent.bPreview)
            	{
            		if(sEvent1AtMarker[0].indexOf("questionnaire.htm") != -1)
            			InQuiz = true;
            	}

            	SetTOCNumbers(iNumTOC);
                if (iType)
            		PositionChange(iPos, 0);
            	else	
            		RandomPositionChange(iPos);            	
         } catch(e)
         {
            //buffer.append("\n printpage exception : " + e.toString()+ "\n") ;
            ShowError ("printpage exception", e);
         }
    }
    
    function TOCHeading(sparam, sparam1, sparam2, sparam3, sparam4, sparam5)
    {
          try
          {            
		TOCScript();          	    
                if (sparam5 == " ") // old version
                    textspace.document.writeln("<meta http-equiv=Content-Type content=\"text/html;\">");
                else
                    textspace.document.writeln("<meta http-equiv=Content-Type content=\"text/html; charset=" + sparam5 + "\">");

                var TitleParamToken = new Array();
                var AuthorParamToken = new Array();
                var MarkerParamToken = new Array();
                var DescParamToken = new Array();

                TitleParamToken = sparam1.split(",");
                AuthorParamToken = sparam2.split(",");
                MarkerParamToken = sparam3.split(",");
                DescParamToken = sparam4.split(",");
        
                textspace.document.writeln("<style type=\"text/css\">");
                textspace.document.writeln("a:link {  text-decoration:none;}");
                textspace.document.writeln("a:visited {  text-decoration:none;}");
                textspace.document.writeln("a:hover {  text-decoration:none;}");
                textspace.document.writeln("a:active {  text-decoration:none;}");

                //255 -> italic
                if (TitleParamToken[6] == "255")
                    textspace.document.writeln(".TitleStyle {  font-color:#000000; font-family: \"" + TitleParamToken[14] + "\"; font-size: " + TitleParamToken[0] + "pt; font-weight: " + TitleParamToken[5] + "; font-style: italic}");
                else
                    textspace.document.writeln(".TitleStyle {  font-color:#000000; font-family: \"" + TitleParamToken[14] + "\"; font-size: " + TitleParamToken[0] + "pt; font-weight: " + TitleParamToken[5] + "; font-style: normal}");                
                    
                if (AuthorParamToken[6] == "255")
                    textspace.document.writeln(".AuthorStyle {  font-color:#000000; font-family: \"" + AuthorParamToken[14] + "\"; font-size: " + AuthorParamToken[0] + "pt; font-weight: " + AuthorParamToken[5] + "; font-style: italic}");
                else
                    textspace.document.writeln(".AuthorStyle {  font-color:#000000; font-family: \"" + AuthorParamToken[14] + "\"; font-size: " + AuthorParamToken[0] + "pt; font-weight: " + AuthorParamToken[5] + "; font-style: normal}");

                if (MarkerParamToken[6] == "255")
                    textspace.document.writeln(".MarkerStyle {  font-color:#000000; font-family: \"" + MarkerParamToken[14] + "\"; font-size: " + MarkerParamToken[0] + "pt; font-weight: " + MarkerParamToken[5] + "; font-style: italic}");
                else
                    textspace.document.writeln(".MarkerStyle {  font-color:#000000; font-family: \"" + MarkerParamToken[14] + "\"; font-size: " + MarkerParamToken[0] + "pt; font-weight: " + MarkerParamToken[5] + "; font-style: normal}");

                if (DescParamToken[6] == "255")
                    textspace.document.writeln(".DescStyle {  font-color:#000000; font-family: \"" + DescParamToken[14] + "\"; font-size: " + DescParamToken[0] + "pt; font-weight: " + DescParamToken[5] + "; font-style: italic}");
                else
                    textspace.document.writeln(".DescStyle {  font-color:#000000; font-family: \"" + DescParamToken[14] + "\"; font-size: " + DescParamToken[0] + "pt; font-weight: " + DescParamToken[5] + "; font-style: normal}");

		textspace.document.writeln("</style>");

		//if no pic or color is assigned to background
		if (sparam == " ")
                        textspace.document.write("<body onload=\"Changefontsize();\" onresize=\"Changefontsize();\"  text=#000000 STYLE=\"background-color:transparent\" oncontextmenu=\"window.event.returnValue=true\">");
                        //textspace.document.write("<body onload=\"\" onresize=\"\"  text=#000000 STYLE=\"background-color:transparent\" oncontextmenu=\"window.event.returnValue=true\">");
  		else
                {
                    if (sparam.indexOf(".") == -1) // color, not image file
                    	
				textspace.document.write("<body  onload=\"Changefontsize();\" onresize=\"Changefontsize();\"  text=#000000 STYLE=\"background-color:" + sparam + "\" oncontextmenu=\"window.event.returnValue=true\">");
                    else
                        textspace.document.write("<body  onload=\"Changefontsize();\" onresize=\"Changefontsize();\"  text=#000000 STYLE=\"background-image: url(" + sparam + "); background-repeat: repeat\" oncontextmenu=\"window.event.returnValue=true\">");
                }
          } catch (e)
          {
              ShowError("background exception", e)  ;
          }
    }   
    
    function TOCScript()
    {
    	try
    	{
    		textspace.document.body.innerHTML = "";
    		
    		textspace.document.writeln("<script language=\"javascript\">");
    		textspace.document.writeln("function Changefontsize()");
		textspace.document.writeln("{");	
		textspace.document.writeln("	if (parent.factor)"); 
		textspace.document.writeln("	{");
		textspace.document.writeln("		factor = parent.factor;");
		textspace.document.writeln("		iNumMarkers = parent.iNumMarkers;");
		textspace.document.writeln("		var headerSize, emailSize, descSize, TOCSize;");		
		textspace.document.writeln("		if (factor)"); 
		textspace.document.writeln("		{");
		textspace.document.writeln("			if (parent.bApplySystem)"); 
		textspace.document.writeln("			{");		
		textspace.document.writeln("				headerSize = parseInt(document.styleSheets[0].rules(4).style.fontSize) * factor;");		
		textspace.document.writeln("				emailSize = parseInt(document.styleSheets[0].rules(5).style.fontSize) * factor;");		
		textspace.document.writeln("				descSize = parseInt(document.styleSheets[0].rules(7).style.fontSize) * factor;");		
		textspace.document.writeln("				TOCSize = parseInt(document.styleSheets[0].rules(6).style.fontSize) * factor;");								
		textspace.document.writeln("			}else");			
		textspace.document.writeln("			{");		
		textspace.document.writeln("				headerSize = parseInt(parent.document.styleSheets[1].rules(3).style.fontSize) * factor;");		
		textspace.document.writeln("				emailSize = parseInt(parent.document.styleSheets[1].rules(4).style.fontSize) * factor;");		
		textspace.document.writeln("				descSize = parseInt(parent.document.styleSheets[1].rules(5).style.fontSize) * factor;");		
		textspace.document.writeln("				TOCSize = parseInt(parent.document.styleSheets[1].rules(0).style.fontSize) * factor;");										
		textspace.document.writeln("			}");					
		textspace.document.writeln("			header.style.fontSize=headerSize+\"pt\";");
		textspace.document.writeln("			emaillink.style.fontSize=emailSize+\"pt\";");
		textspace.document.writeln("			copyright.style.fontSize=emailSize+\"pt\";");
		textspace.document.writeln("			description.style.fontSize=descSize+\"pt\";");
		textspace.document.writeln("			TOCdata.style.fontSize=TOCSize+\"pt\";");
		textspace.document.writeln("			for ( var i=1;(i<=iNumMarkers);i++)");
		textspace.document.writeln("			{");
		textspace.document.writeln("				clear_title = \"title\" + i;");
		textspace.document.writeln("				if (this.document.all(clear_title))");
		textspace.document.writeln("					this.document.all(clear_title).style.fontSize = TOCSize + \"pt\";");
		textspace.document.writeln("				if (this.document.all(\"img\" + i))");
		textspace.document.writeln("				{");
		textspace.document.writeln("					this.document.all(\"img\" + i).style.posWidth = 16 * factor;");	
		textspace.document.writeln("					this.document.all(\"img\" + i).style.posheight = 22 * factor;");
		textspace.document.writeln("				}");						
		textspace.document.writeln("			}");	
		textspace.document.writeln("		}");
		textspace.document.writeln("	}");
		textspace.document.writeln("}");
		textspace.document.writeln("function changeicon(imgobj, idx)");
		textspace.document.writeln("{");
		textspace.document.writeln("	window.event.cancelBubble=true;");
		textspace.document.writeln("	parent.iCurrDivHead = idx;");
		textspace.document.writeln("	if (imgobj.src.indexOf(\"ftv2pnode.gif\") != -1)");
		textspace.document.writeln("		ShowHideDIV(idx, 1);");				
		textspace.document.writeln("	else if (imgobj.src.indexOf(\"ftv2mnode.gif\") != -1)"); 
		textspace.document.writeln("		ShowHideDIV(idx, 0);");
		textspace.document.writeln("}");
		textspace.document.writeln("function ShowHideDIV(idx, bVisible)");
		textspace.document.writeln("{");
		textspace.document.writeln("	if (bVisible) sShow = 'block';");
		textspace.document.writeln("	else sShow = 'none';");
		textspace.document.writeln("	destDIV = \"div\"+idx+\"_\";");	
		textspace.document.writeln("	var oObject = document.all.item(destDIV);");
		textspace.document.writeln("	if (oObject != null)");
		textspace.document.writeln("	{");
		textspace.document.writeln("		imgobj = this.document.all.item(\"img\" + idx);");
		textspace.document.writeln("		if (bVisible) imgobj.src=\"ftv2mnode.gif\";");
		textspace.document.writeln("		else imgobj.src=\"ftv2pnode.gif\";");		
		textspace.document.writeln("   		if (oObject.length != null)");
		textspace.document.writeln("   		{");
		textspace.document.writeln("      			for (i = 0; i < oObject.length; i++)");
		textspace.document.writeln("         			document.all.item(destDIV)(i).style.display = sShow;");
		textspace.document.writeln("   		}");
		textspace.document.writeln("   		else");
		textspace.document.writeln("      		document.all.item(destDIV).style.display = sShow;");
		textspace.document.writeln("	}");	
		textspace.document.writeln("}");
		textspace.document.writeln("</script>");    	
	}catch (e)
        {              
        	ShowError("TOCScript exception", e)  ;
        }
    } 
    
    function PositionChange(newposition, iType)
    {
         try
         {
		if (!parent.bPreview && bChangebyTOC && (iType != 3)) GetCurrentClip(newposition);
                var bNotFound = true;
                var lowerbound = 0;
                var upperbound = -1;
                var i;
	        for (i=0;i<iTotalMarkers;i++)
                {
			if ((newposition == parseInt(sTimeArray[i])) && bNotFound)
                    	{
                        	bNotFound = false;
                        	lowerbound = i;
                  	}
		  	if ((newposition != parseInt(sTimeArray[i])) && !bNotFound)
                  	{
                        	upperbound = i-1;
                        	break;
                  	}
              	}
              	if (upperbound == -1) upperbound = iTotalMarkers-1;
              	DataChangeAtNowMarker(lowerbound, upperbound, iType);
         } catch (e)
         {              
              	ShowError("PositionChange exception", e)  ;
         }
  }

  function DataChangeAtNowMarker(lbound, ubound, iType)
  {
         try {     
              	var i;
              	var CurrAniData = "0";
                var seekindex = -1;

                var TemplateSeekIndex = -1;
                var temp = ubound-lbound;
                
                for (i=lbound;i<=ubound;i++)
                {
                        if (sTemplateAtMarker[i] != "")
                        {
                                seekindex = i;
                                break;
                        }
                }
                //find current Template
                if (seekindex == -1) seekindex = iHintTemplate[lbound];
                sNowTemplateDirName = sTemplateAtMarker[seekindex];
                if (sNowTemplateDirName.indexOf(":") != -1) bIfDownload = true;
                else bIfDownload = false;
                TemplateSeekIndex = seekindex;
                iTemplateIdx = parseInt(sTemplateArguAtMarker[TemplateSeekIndex]);
        	if (parent.bPreview) 
        	{
        		AttachTemplate(sNowTemplateDirName, TemplateSeekIndex);
        	}else
        	{                	
                        if (sNowTemplateDirName != sPreTemplateDirName)
                                AttachTemplate(sNowTemplateDirName, TemplateSeekIndex);
		}	                                
                //highlight current TOC
              	var compareData = -1;
              	var FindIdx = -1;
              	if (iNumTOC > 0)
              	{
                  	for (i=lbound;i<=ubound;i++)
                  	{
                            	if (compareData == -1)
                            	{
                                	compareData = iTOCAtMarker[i];
                                	FindIdx = i;
                            	}else if (iTOCAtMarker[i] > compareData)
                            	{
                            		if(!InQuiz || (InQuiz && i==1 && !parent.bPreview)) //first TOC is Quiz
                            		{
                                		compareData = iTOCAtMarker[i];
                                		FindIdx = i;
                                	}
                            	}
                   	}
                  	if (compareData==0)  // no TOC at current region
                  	{
                      		for (i=ubound;i>=0;i--)
                      		{
                            		if (iTOCAtMarker[i] > 0) 
                            		{
                                		compareData = iTOCAtMarker[i];                                		
                                		FindIdx = i;
                                		break;
                            		}
                      		}
                  	}
                  	if (compareData>0)
                  	{
                      		setMarkerNum(iTOCIndexAtMarker[FindIdx]);     
                      		if(bSync) HighLight(compareData)                      	

                  	}
              	}

              	//show pendraw
              	for (i=lbound;i<=ubound;i++)
              	{
                	if (sPenDrawAtE1[i] != "")
                  	{
                      		SetDivVisible(sPenDrawAtE1[i]);
                  	}
              	}
              	//show Animation
              	seekindex = -1;
              	for (i=lbound;i<=ubound;i++)
              	{             
                  	if (sEvent1AtMarker[i] != "")
                  	{ 
                  		if(!parent.bPreview)
                  		{
                   			if(!InQuiz && sEvent1AtMarker[i].charAt(0) == '"') // for random access
                   			{
                   				for(j=i-1; j>=0; j--)
                    				{
                    					if(sEvent1AtMarker[j] != "" && sEvent1AtMarker[j].charAt(0) != '"')
                    					{
                    						seekindex = j;
                    		 				break;
                    					}
                    				}
                   			}
                  			else
					{
                    		 		seekindex = i;
                    		 		break;
                    			}
                    		}
                    		else
                    		{                    			
                    			if(!InQuiz && sEvent1AtMarker[i].indexOf("questionnaire.htm") != -1) // for random access
                    			{
                    				for(j=i-1; j>=0; j--)
                    				{
                    					if(sEvent1AtMarker[j] != "" && sEvent1AtMarker[j].indexOf("questionnaire.htm") == -1)
                    					{
                    						seekindex = j;
                    		 				break;
                    					}
                    				}
                    			}
                    			else
                    			{
                    				seekindex = i;                    				
                    		 		break;
                    			}
                    		}
                    		
                  	}
              	}                                  		
             	//load current Event1 file
              	if (seekindex == -1)
                    	seekindex = iHintEvent1[lbound];
              	sFile1 = sEvent1AtMarker[seekindex];              	
              	
              	//for nevigate control
              	if (typeof(sFile1) != "undefined" && sFile1.charAt(0) == '"')
              	{
			nowQuiz = sTimeArray[seekindex];
              		sFile1 = sFile1.substring(1, sFile1.length);            		            	
              	}
              	//for next\previous slide
              	for (iTempSlide=0;iTempSlide<sEvent1Lists.length;iTempSlide++)
              	{
              		if (sEvent1Lists[iTempSlide] == sFile1) 
              		{              			
              			iCurrSlide = iTempSlide;
              			break;
              		}	
              	}              	              	
                sPreEvent1File = sFile1;
              	if (typeof(sFile1) != "undefined" && sFile1 != "")
              	{
                  	CurrAniData = sAniAtE1[seekindex];
                  	if (CurrAniData != "0")
                  	{
                      		SetiAniIdx(CurrAniData);
                  	}
                  	if ((iTemplateIdx<8) || (iTemplateIdx==10))
                        {
                            	bNoEvent1 = false;
                            	this.document.all.item("pptmain").src = sFile1;
                            	
                            	
                            	if(parent.bPreview)
                            	{                               		                         		
                            		if(sFile1.indexOf("questionnaire.htm") != -1 && !bRaccessCallUpdate)                            		                            			
                            			bLoadQuiz = true;
                           		
                           		setTimeout("UpdateFramePos()", 300);                            			
                            		bRaccessCallUpdate = false;
                            	}
                            	
    			                                    	
                            	if ((sFile1.indexOf("/HTML/") != -1) || (sFile1.indexOf("http://") != -1) || (sFile1.indexOf(".pdf") == sFile1.length-4)) 
                            		continuePlaying();
                        }else
                        {
                          	bNoEvent1 = true;
                          	continuePlaying();
                        }
              	}else
              	{
                  	for (i=lbound;i<=ubound;i++)
                  	{
                      		if (i==lbound) CurrAniData = sAniAtE1[i];
                      		else
                      		{
                          		if (parseInt(CurrAniData) < parseInt(sAniAtE1[i]))
                                		CurrAniData = sAniAtE1[i];
                      		}
                	}
                	if (CurrAniData != "0")
                	{
                      		SetiAniIdx(CurrAniData);
                	}
                	if (seekindex==0) this.document.all.item("pptmain").src = "blank.htm";
                        else continuePlaying();
              	}
                //show pendraw
                for (i=lbound;i<=ubound;i++)
                {
                        if (sPenDrawAtE2[i] != "")
                        {
                                SetDiv1Visible(sPenDrawAtE2[i]);
                        }
                }
              	CurrAniData = "0";
              	seekindex = -1;
              	for (i=lbound;i<=ubound;i++)
              	{
                  	if (sEvent2AtMarker[i] != "")
                  	{
                    		seekindex = i;
                    		break;
                  	}
              	}
              	if (seekindex == -1)
                    	seekindex = iHintEvent2[lbound];

	        sFile2 = sEvent2AtMarker[seekindex];
                sPreEvent2File = sFile2;
              	if (sFile2 != "")
              	{
                	CurrAniData = sAniAtE2[seekindex];
                  	if (CurrAniData != "0")
                  	{
                      		SetiAni1Idx(CurrAniData);
                  	}
                        if ((iTemplateIdx >= 5) && (iTemplateIdx <= 8))
                        {
                            	bNoEvent2 = false;
                            	this.document.all.item("event2").src = sFile2;
                            	if ((sFile2.indexOf("/HTML/") != -1) || (sFile2.indexOf("http://") != -1) || (sFile2.indexOf(".pdf") == sFile2.length-4)) 
                            		continuePlaying();
                        }else
                        {
                            	bNoEvent2 = true;
                            	continuePlaying();
                        }
              	}else
              	{
                  	for (i=lbound;i<=ubound;i++)
                  	{
                      		if (i==lbound) CurrAniData = sAniAtE2[i];
                      		else
                      		{
                          		if (parseInt(CurrAniData) < parseInt(sAniAtE2[i]))
                              			CurrAniData = sAniAtE2[i];
                      		}
                  	}
                  	if (CurrAniData != "0")
                  	{
                      		SetiAni1Idx(CurrAniData);
                  	}
                        if (seekindex==0 && (iTemplateIdx >= 5) && (iTemplateIdx < 8)) 
                        	this.document.all.item("event2").src = "blank.htm";
                        else continuePlaying();
              	}
         } catch (e)
         {
                ShowError("DataChangeAtNowMarker exception", e);
         }
    }    
    
    function AttachTemplate(arguStr, iIndex)
    {
          try
          {
                if (iIndex!=-1)
                    setTemplateIdx(sTemplateOrderAtMarker[iIndex], arguStr);
                //else
                //    setTemplateIdx("1", arguStr);
                sPreTemplateDirName = arguStr ;
          } catch (e)
          {
              ShowError("AttachTemplate exception", e)  ;
          }
   }    

    function HighLightTOC(TOCIndex)
    {
         try {
              if (iNumTOC > 0)
              {
                    var j = 0;
                    for (j=TOCIndex;j>1;j--)
                    {
                    	if(typeof(iTOCAtMarker[j-1]) == "undefined") return;
                        if (iTOCAtMarker[j-1]!=0) break;
                    }
		    HighLight(iTOCAtMarker[j-1].toString(10));
              }
              
         } catch (e)
         {
              ShowError("HighLightTOC exception (HighLightTOC)", e)  ;
         }
    }
    function popup()
    {
	 try
         {
               	if (bIfDownload)
               	{
                     	Darea.openQ();
               	}
         } catch (e)
         {
         	ShowError("popup exception", e)  ;
         }
    }
    
    function GetPreviewMarkerNum(nowPreviewMarker)
    {
    	var i=0;
    	var result = 1;
	for (;i<iTotalMarkers;i++)
  	{
		if (iTOCAtMarker[i] == nowPreviewMarker)
            	{
            		result = iTOCIndexAtMarker[i];
			break;
            	}
   	}  
   	return result;  	
    }
        
    function GetMarkerTime(iMarker)
    {
	 try 
         {
              	var j = 0;
	      	for (j=0;j<iTotalMarkers;j++)
	      	{
	            	if (iTOCAtMarker[j]== iMarker) break;
	      	}
	      	return sTimeArray[j];
         } catch (e)
         {
              ShowError("GetMarkerTime exception", e);
         }
    }      
    
    function CheckIfTest(newposition)
    {
	for(i = 0; i<QuizNum; i++)
	{
		if(parseInt(Quiz[i]) == newposition) return true;
	}    	
	return false;
    }
    
    function RandomPositionChange(newposition)
    {
         try
         {
         	var mapposition = 0;
         	if (MediaTime.length > 0)
         		newposition = MediaTime[iClipindex]*1000 + newposition;
         	var currmapposition = 0 ;
	        for (var i=0;i<iTotalMarkers;i++)
                {
               		if (parseInt(newposition) >= parseInt(sTimeArray[i]))               		      		
               		{
                        	mapposition = parseInt(sTimeArray[i]);  
                        	if(!InQuiz && sEvent1AtMarker[i] != "")                      
                        	{
                        		if(sEvent1AtMarker[i].charAt(0) != '"') currmapposition = mapposition;
                        	}
                        }	
		  	if (parseInt(newposition) < parseInt(sTimeArray[i])) 
		  		break;
              	}
              	if((currmapposition != 0) && (mapposition < currmapposition)) mapposition = currmapposition;
              	bRandomAccess = true;
              	PositionChange(mapposition, 1);
              	bRandomAccess = false;
         } catch (e)
         {
              	ShowError("RandomPositionChange exception", e)  ;
         }
    }   
    
    function LoadEvent2(bstrparam)
    {
         try
         {
         	bNoEvent2 = true;         	
    	        var nowIdx = parseInt(bstrparam);
    	        
    	        //fix-BugCode : SAR040402-0023
                if (sEvent2AtMarker[nowIdx-1] != sPreEvent2File || parent.bPreview)
                {
                        if (sEvent2AtMarker[nowIdx-1] != "")
                                this.document.all.item("event2").src = sEvent2AtMarker[nowIdx-1] ;
                        else
                                this.document.all.item("event2").src = sEvent2AtMarker[iHintEvent2[nowIdx-1]] ;
                }
                sPreEvent2File = sEvent2AtMarker[nowIdx-1];
         } catch (e)
         {
            	ShowError("LoadEvent2 excloeption", e)  ;
         }
    }

    function setTOCBGcolor(s_TOCColor)
    {
         try
         {
                if (s_TOCColor != "")
                {
                      	if (s_TOCColor.indexOf(".") > -1) 
                      		textspace.document.body.style.backgroundImage = s_TOCColor ;
                      	else 
                      	{
                      		textspace.document.body.style.backgroundImage = "";
                      		textspace.document.body.style.backgroundColor = s_TOCColor ;
		       	}
                }
         } catch (e)
         {
                ShowError("setTOCBGcolor exception", e)  ;
         }
    }
    
    function setDareaBGcolor(s_DareaColor)
    {
         try
         {
                if (s_DareaColor != "")
                {
                      	if (s_DareaColor.indexOf(".") > -1) 
                      		Darea.document.body.style.backgroundImage = s_DareaColor;
                      else 
                      {
                      		Darea.document.body.style.backgroundImage = "";
                      		Darea.document.body.style.backgroundColor = s_DareaColor;
			}
                }
         } catch (e)
         {
                ShowError("setDareaBGcolor exception", e)  ;
         }
    }

    function LoadEvent1(bstrparam)
    {
         try
         {
         	//fornevigate control
         	InQuiz = false;
         	
         	bNoEvent1 = true;         	
    	        var nowIdx = parseInt(bstrparam);
    	        
    	        //fix-BugCode : SAR040402-0023
                if (sEvent1AtMarker[nowIdx-1] != sPreEvent1File || parent.bPreview)
                {
                    	if (sEvent1AtMarker[nowIdx-1] != "")
                        	this.document.all.item("pptmain").src = sEvent1AtMarker[nowIdx-1];
                    	else
                        	this.document.all.item("pptmain").src = sEvent1AtMarker[iHintEvent1[nowIdx-1]];
                        	
                        if(parent.bPreview)               		
                		setTimeout("UpdateFramePos()", 300);
                }
                sPreEvent1File = sEvent1AtMarker[nowIdx-1];
              	for (iTempSlide=0;iTempSlide<sEvent1Lists.length;iTempSlide++)
              	{
              		if (sEvent1Lists[iTempSlide] == sEvent1AtMarker[nowIdx-1]) 
              		{              			
              			iCurrSlide = iTempSlide;
              			break;
              		}	
              	}  
                               
                 
         } catch (e)
         {
                ShowError("LoadEvreent1 exception", e)  ;
         }
    }
    
    function LoadQuiz(bstrparam)
    {
         try
         {
         	bNoEvent1 = true;         	
    	        var nowIdx = parseInt(bstrparam);
    	        
         	//for nevigate control
                if(!skipLQuiz)
                {
                	InQuiz = true;
                	if (bMP7) MediaPlayer1.controls.pause();
			else MediaPlayer1.pause();                	
                	PauseFun();
                	nowQuiz = sTimeArray[nowIdx-1];                                
                }
                else
                {                	
                 	skipLQuiz = false;
                 	return;                 
                }
                      
                if(!parent.bPreview)                           
                	bContinueTOC = CheckTOC(nowQuiz,1);
         	         	    	        
                if (sEvent1AtMarker[nowIdx-1] != sPreEvent1File)
                {
                    	if (sEvent1AtMarker[nowIdx-1] != "")
                        	this.document.all.item("pptmain").src = sEvent1AtMarker[nowIdx-1].substring(1,sEvent1AtMarker[nowIdx-1].length);
                    	else
                        	this.document.all.item("pptmain").src = sEvent1AtMarker[iHintEvent1[nowIdx-1]];
                        	
                        if(bMP7) MediaPlayer1.fullScreen = false;
			else MediaPlayer1.DisplaySize = 4;
                }
                sPreEvent1File = sEvent1AtMarker[nowIdx-1];
                
                if(parent.bPreview)
		{                                              		
			bLoadQuiz = true;                                            
                	setTimeout("UpdateFramePos()", 300);                                                                
                }
                                                                                              
                 
         } catch (e)
         {
                ShowError("LoadEvent1 exception", e)  ;
         }
    }    
    
    function ResetPenDrawSetting(whichEvent)
    {
         try
         {
         	//set all visibility attribute to hidden
		Clear_PPT_ShowPic(whichEvent, "0");
         } catch (e)
         {
            	ShowError("ClearPenDraw exception", e)  ;
         }
    }
    function ClearPenDraw(PicStr)
    {
         try
         {
 		iPreCursor = iNowCursor;
		var whichEvent = PicStr.substring(0, PicStr.indexOf("|"));
 		var divIdx = PicStr.substring(PicStr.indexOf("|")+1, PicStr.length);
		Clear_PPT_ShowPic(whichEvent, divIdx);
         } catch (e)
         {
            	ShowError("ClearPenDraw exception", e)  ;
         }
    }

    function ClearNoteBG()
    {
         try
         {
         	pptmain.SetPicState(0);
         } catch (e)
         {
            	ShowError("ClearNoteBG exception", e)  ;
         }
    }    

    function ShowCursor(PicStr)
    {
         try
         {
         	var OdestWin;
		iPreCursor = iNowCursor;
		var whichEvent = PicStr.substring(0, PicStr.indexOf("|"));
		iNowCursor = parseInt(PicStr.substring(PicStr.indexOf(";")+1, PicStr.length));
		var CurrMarker = PicStr.substring(PicStr.indexOf("|")+1, PicStr.indexOf(";"));
		var destDIV = "imageDIV" + CurrMarker;

                if (whichEvent == "E1")
                {
                      OdestWin = pptmain.pendraw;
                      //OdestWinDIV = pptmainDIV;                      
                      i = 3;
                }else if(whichEvent == "E2")
                {
                      OdestWin = this.event2;
		      //OdestWinDIV = pptmainDIV;                      
		      i = 4;
                }

		if (document.styleSheets[0].rules[i].style.visibility == "visible")
		{                      
	                if (OdestWin.document.all.item(destDIV)(iNowCursor))
	                {
		                var sObjectExist = typeof(OdestWin.document.all.item(destDIV)(iNowCursor));
		                //var sObjectExist = OdestWin.ObjectExist(destDIV,iNowCursor.toString(10));
		                	
		                if (sObjectExist == "object")
		                {
					if (iNowCursor>1)
		                      	{
		                        	if (OdestWin.document.all.item(destDIV)(iPreCursor)) OdestWin.document.all.item(destDIV)(iPreCursor).style.visibility = 'hidden';
		                      	}
		                        if (OdestWin.document.all.item(destDIV)(iNowCursor)) OdestWin.document.all.item(destDIV)(iNowCursor).style.visibility = 'visible';
		                }
		        } 
		 }       
         } catch (e)
         {
            	ShowError("ShowCursor exception", e)  ;
         }
    }

    function ClearCursor(PicStr)
    {
         try
         {
         	var OdestWin;
		iPreCursor = iNowCursor;
		var whichEvent = PicStr.substring(0, PicStr.indexOf("|"));
		iNowCursor = parseInt(PicStr.substring(PicStr.indexOf(";")+1, PicStr.length));
		var CurrMarker = PicStr.substring(PicStr.indexOf("|")+1, PicStr.indexOf(";"));
		var destDIV = "imageDIV" + CurrMarker;
               	if (whichEvent == "E1")
               	{
                      OdestWin = pptmain.pendraw;
		      //OdestWinDIV = pptmainDIV;                                            
		      i = 3;
                }else if(whichEvent == "E2")
                {
                      OdestWin = this.event2;
                      //OdestWinDIV = event2DIV;
                      i = 4;
                }      

		if (document.styleSheets[0].rules[i].style.visibility == "visible")
		{                                      
	                if (OdestWin.document.all.item(destDIV)(iNowCursor))
	                {
				var sObjectExist = typeof(OdestWin.document.all.item(destDIV)(iNowCursor));                                	
		                if (sObjectExist == "object")
		                {
					if (iNowCursor>1)
		                      	{
		                        	if (OdestWin.document.all.item(destDIV)(iPreCursor)) OdestWin.document.all.item(destDIV)(iPreCursor).style.visibility = 'hidden';
		                      	}
		                }
		         } 
		 }        
         } catch (e)
         {
           	ShowError("ClearCursor exception", e)  ;
         }
    }
    
    function ShowPic(PicStr)
    {
         try
         {
         	
         	var OdestWin;
		var whichEvent = PicStr.substring(0, PicStr.indexOf("|"));
		var idx = parseInt(PicStr.substring(PicStr.indexOf(";")+1, PicStr.length));
		var CurrMarker = PicStr.substring(PicStr.indexOf("|")+1, PicStr.indexOf(";"));
		var destDIV = "imageDIV" + CurrMarker;
                if (whichEvent == "E1")
                { 
                      OdestWin = pptmain.pendraw;
                      //OdestWinDIV = pptmainDIV;                      
                      i = 3;
                }else if(whichEvent == "E2")
                {
                      OdestWin = this.event2;
                      //OdestWinDIV = event2DIV;                      
                      i = 4;
                }      
                      
		//if (OdestWinDIV.style.visibility == "visible")
		if (document.styleSheets[0].rules[i].style.visibility == "visible")
		{                      
			destImage = "image" +  CurrMarker + "_" + idx;                      
	                if (OdestWin.document.all.item(destImage))
	                {
	                        var sObjectExist = typeof(OdestWin.document.all.item(destImage));                
			 	if (sObjectExist == "object")
		                {		                	
		                   	//OdestWin.document.all.item(destDIV)(idx).style.visibility = "visible";
		                   	OdestWin.document.all.item(destImage).style.visibility = "visible";
		                  	if (idx > 1) 
		                    	{
		                    		if (OdestWin.document.all.item(destDIV)(idx-1))
		                    		{
							if (OdestWin.document.all.item(destDIV)(idx-1).style.visibility == "hidden")
							{
								for (var j=0;j<idx;j++)
									if (OdestWin.document.all.item(destDIV)(j)) OdestWin.document.all.item(destDIV)(j).style.visibility = 'visible';
							}
						}	
					}
				}	
	                }
	         }       
         } catch (e)
         {
            	ShowError("ShowPic exception", e)  ;
         }
    }

    function ShowHTMPic(PicStr)
    {
         try
         {
         	var OdestWin;
		var whichEvent = PicStr.substring(0, PicStr.indexOf("|"));
		var divIdx = PicStr.substring(PicStr.indexOf("|")+1, PicStr.indexOf(";"));
		var picIdx = parseInt(PicStr.substring(PicStr.indexOf(";")+1, PicStr.lastIndexOf(";")));
		var pageTop = PicStr.substring(PicStr.lastIndexOf(";")+1, PicStr.length);
                if (whichEvent == "E1")
                {
                      OdestWin = pptmain.pendraw;
                      //OdestWinDIV = pptmainDIV;                                            
                      i = 3;
                }else if(whichEvent = "E2")
                {
                      OdestWin = this.event2;
                      //OdestWinDIV = event2DIV;                                            
                      i = 4;
                }      
                
		if (document.styleSheets[0].rules[i].style.visibility == "visible")
		{                                      
			var destDIV = "imageDIV" + divIdx;
			if (OdestWin.document.all.item(destDIV)(picIdx))
			{
		                var sObjectExist = typeof(OdestWin.document.all.item(destDIV)(picIdx));                
		                if (sObjectExist == "object")
		                {
		                    	//OdestWin.scrollwindow(pageTop);
		                    	OdestWin.document.all.item(destDIV)(picIdx).style.visibility = 'visible';
		                    	if (picIdx > 1) 
		                    	{
		                    		if (OdestWin.document.all.item(destDIV)(picIdx-1))
		                    		{
							if (OdestWin.document.all.item(destDIV)(picIdx-1).style.visibility == "hidden")
							{
								for (var j=0;j<picIdx;j++)
									if (OdestWin.document.all.item(destDIV)(j)) OdestWin.document.all.item(destDIV)(j).style.visibility = 'visible';
							}
						}	
					}	                    	
		                }
		         } 
		 }        
         } catch (e)
         {
          	ShowError("ShowHTMPic exception", e)  ;
         }
    }

    function Clear_PPT_ShowPic(whichEvent, CurrDiv)
    {
         try
         {
                var OdestWin;
                var destDIV = "";
                var ArrayNum = 0;
                var DivSum = 0;
                var startIdx = 0;
                var endIdx = 0;
                var sArrayNum = "";

                if (whichEvent == "E1")
                {
                      OdestWin = pptmain.pendraw;
                      //OdestWinDIV = pptmainDIV;                      
                      i = 3;
                }else if(whichEvent == "E2")
                {
                      OdestWin = this.event2;
                      //OdestWinDIV = event2DIV;                      
                      i = 4;
                }      

		if (document.styleSheets[0].rules[i].style.visibility == "visible")
		{
	                startIdx = 1;
	                endIdx = parseInt(CurrDiv);
	                for (var m=startIdx;m<=endIdx;m++)
	                {
	                      	destDIV = "imageDIV" + m;
	                      	var destImage = "image" + m + "_";
				if (OdestWin) ArrayNum = OdestWin.getArrayNum(destDIV);
	                      	for (var j=1;j<=ArrayNum;j++)
	                      	{       
	                      		destImage = "image" + m + "_" + j;
	                      		if (OdestWin.document.all.item(destImage))                		
	                      			OdestWin.document.all.item(destImage).style.visibility = "hidden";
	                      	}
	                }
	         }
         }catch (e)
         {
               ShowError("Clear_PPT_ShowPic exception", e);
         }
    }
    
    function Load_Template(bstrparam)
    {
         try         
         {
                var nowIdx = parseInt(bstrparam);         	
                var nowTemplateIdx = parseInt(sTemplateArguAtMarker[nowIdx-1]);
                if ((nowTemplateIdx >= 5) && (nowTemplateIdx <= 8))
                    	bNoEvent2 = false;                
                else 
                    	bNoEvent2 = true;                                
                //for nevigate control         
                if(typeof(sEvent1AtMarker[nowIdx]) != "undefined")                       
                	if(!(sEvent1AtMarker[nowIdx].charAt(0) == '"' && SATime[nowIdx] == SATime[nowIdx+1]))
                		if (!bNoEvent1 && (sPreEvent1File != "")) this.document.all.item("pptmain").src = sPreEvent1File;
                if (!bNoEvent2 && (sPreEvent2File != "")) this.document.all.item("event2").src = sPreEvent2File;                
                
                //retrieve the current Template Argument
                sNowTemplateDirName = sTemplateAtMarker[nowIdx-1];
                if (sNowTemplateDirName != sPreTemplateDirName)
                {
                            //check if DownloadArea exists
                            if (sNowTemplateDirName.indexOf(":") != -1) bIfDownload = true;
                            else bIfDownload = false;
                            iTemplateIdx = parseInt(sTemplateArguAtMarker[nowIdx-1]);
                            AttachTemplate(sNowTemplateDirName, nowIdx-1);
                }
         } catch (e)
         {
            	ShowError("Load_Template exception", e) ;
         }
    }        
    

function ResetMutex()
{
	bAllow = true;
	imutexTimer = -1;	
}

function CheckTemplateReady()
{
	try
	{
		clearTimeout(iTemplateTimer);
		if (!(LINKLAYOUT.readyState=="complete"))
		{
			bFirst = true;
			if (bMP7) MediaPlayer1.controls.pause();
			else
			{
				if (MediaPlayer1.PlayState != iStateStop_M6) MediaPlayer1.pause();
			}
			iTemplateTimer = setTimeout("CheckTemplateReadyAgain()", iWaitTime/2);		
		}else
		{
			bFirst = false;
			iTemplateTimer = -1;
		}	
	}catch (e)
	{
		ShowError ("CheckTemplateReady exception", e);
	}	
}

function CheckTemplateReadyAgain()
{
	try
	{
		clearTimeout(iTemplateTimer);
		if (!((LINKLAYOUT.readyState=="complete")) && (igPlayState == iStatePlay))
		{
			bFirst = false;	
			if (bMP7) MediaPlayer1.controls.play();
			else MediaPlayer1.play();		
		}else
		{
			bFirst = true;
			iTemplateTimer = -1;
			iTemplateTimer = setTimeout("CheckTemplateReadyAgain()", iWaitTime/2);
		}
	}catch (e)
	{
		ShowError ("CheckTemplateReadyAgain exception", e);
	}		
}

function InitImg()
{
	try
	{  		
		playerpreviouspic.src= buttonImage[2][0].src;		
		playernextpic.src= buttonImage[3][0].src;			
		if (igPlayState == iStatePlay)
		{ 
			playerplaypausepic.src=buttonImage[0][2].src;
			playerstoppic.src=buttonImage[4][0].src;
		}else if (igPlayState == iStatePause)
		{ 
			playerplaypausepic.src=buttonImage[1][0].src;
			playerstoppic.src=buttonImage[4][0].src;	
		}else if (igPlayState == iStateStop)
		{
			playerplaypausepic.src= buttonImage[1][0].src;
			playerstoppic.src= buttonImage[4][2].src;	
		}
		
		
		if(typeof(buttonImage[10][0]) != "undefined")
			preSlidepic.src= buttonImage[10][0].src;				
		if(typeof(buttonImage[11][0]) != "undefined")
			nextSlidepic.src= buttonImage[11][0].src;								
		if(typeof(buttonImage[12][0]) != "undefined")
			SyncDatapic.src= buttonImage[12][0].src;		
														
		if(typeof(buttonImage[5][0]) != "undefined")
			pptMaxpic.src = buttonImage[5][0].src;
		if(typeof(buttonImage[6][0]) != "undefined")
			videoMaxpic.src = buttonImage[6][0].src;
		if(typeof(buttonImage[7][0]) != "undefined")
			Swappic.src = buttonImage[7][0].src;
		if(typeof(buttonImage[8][0]) != "undefined")
			PPTNormalpic.src = buttonImage[8][0].src;		
		if(typeof(buttonImage[9][0]) != "undefined")
			ViewScorepic.src = buttonImage[9][0].src;					
		
		SetToolTip();
	}catch (e)
	{
		ShowError ("InitImg exception", e);
	}	
}
function SetToolTip()
{
	playerpreviouspic.alt = sPreviousTOC;		
	playernextpic.alt= sNextTOC;		
	playerplaypausepic.alt= sPlay;		
	playerstoppic.alt= sStop;		
	if (igPlayState == iStatePlay)
		playerplaypausepic.alt= sPause;	
	
	if (parent.bPreview)
	{	
		preSlidepic.alt = sNorSupported;		
		SyncDatapic.alt = sNorSupported;
		nextSlidepic.alt = sNorSupported;	
		videoMaxpic.alt = sNorSupported;			
	}else
	{
		preSlidepic.alt = sPreviousSlide;		
		SyncDatapic.alt = sSyncData;
		nextSlidepic.alt = sNextSlide;				
		videoMaxpic.alt = sVideoMax;
	}	
	
	pptMaxpic.alt = sPPTMax;
	Swappic.alt = sSwapVP;
	PPTNormalpic.alt = sPPTNormal;
	ViewScorepic.alt = sViewScore;	
}
function LoadButnImg()
{
	try
	{	
		for (var i=0;i<=12;i++)
		{	
		      tempImage = new Array();
		      
		      for (var j=1;j<=3;j++)
		      {												
			    	if (i==0) 
			    	{        			    		
			    		tempImage[j-1] = new Image();			    		
			    	        if( typeof(eval("document.styleSheets[0].rules[" + eval(i+10) + "].style.pic" + eval(j+3))) != "undefined")
			    	        {
			    		 	data = eval("document.styleSheets[0].rules[" + eval(i+10) + "].style.pic" + eval(j+3));
			    		 	temp = data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
		                         	if(temp == "")
		                         		temp = Styles[TemplateOrder] + "/" + sImagestr[i] + "_" + eval(j+3) + ".gif";
		                         	else
		                          		temp = Styles[TemplateOrder] + "/" + temp;					 
					}
					else
					 	temp = Styles[TemplateOrder] + "/" + sImagestr[i] + "_" + eval(j+3) + ".gif";
					 
					tempImage[j-1].src = temp;					
				}
				else if (i<=4)
				{		
					tempImage[j-1] = new Image();
					if(typeof(eval("document.styleSheets[0].rules[" + eval(i+9) + "].style.pic" + j)) != "undefined")
					{
			    		 	data = eval("document.styleSheets[0].rules[" + eval(i+9) + "].style.pic" + j);
			    		 	temp = data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
		                         	if(temp == "")
		                         		temp = Styles[TemplateOrder] + "/" + sImagestr[i] + "_" + j + ".gif";
		                         	else
		                          		temp = Styles[TemplateOrder] + "/" + temp;
		                         }
		                         else
		                          	temp = Styles[TemplateOrder] + "/" + sImagestr[i] + "_" + j + ".gif";
					
					tempImage[j-1].src = temp					
				}	
				else if ((i<=9) && (i>=5))  //i = 5-9
				{							
					if(typeof(eval("document.styleSheets[2].rules[" + eval(i-4) + "]")) != "undefined")				
					{						
						tempImage[j-1] = new Image();
						if(typeof(eval("document.styleSheets[2].rules[" + eval(i-4) + "].style.pic" + j)) != "undefined")
						{
			    		 		data = eval("document.styleSheets[2].rules[" + eval(i-4) + "].style.pic" + j);
			    		 		temp = data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
		                         		if(temp == "")
		                         		{
								if(document.styleSheets[0].rules[8].style.TemplateType == "00")		                         			
									temp = Styles[TemplateOrder] + "/" + sImagestr[i] + "_" + j + ".gif";
								else
		                         				temp = Styles[TemplateOrder] + "/../Others/" + sImagestr[i] + "_" + j + ".gif";
		                         		}else
		                          			temp = Styles[TemplateOrder] + "/" + temp;
		                         	}
		                         	else
		                          		temp = Styles[TemplateOrder] + "/../Others/" + sImagestr[i] + "_" + j + ".gif";
						tempImage[j-1].src = temp
					}
					
				}else
				{
					if(typeof(eval("document.styleSheets[0].rules[" + eval(i+8) + "]")) != "undefined")
					{										
						tempImage[j-1] = new Image();					
						if(typeof(eval("document.styleSheets[0].rules[" + eval(i+8) + "].style.pic" + j)) != "undefined")
						{
			    		 		data = eval("document.styleSheets[0].rules[" + eval(i+8) + "].style.pic" + j);
			    		 		temp = data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
		                         		if(temp == "")
		                         		{
								if(document.styleSheets[0].rules[8].style.TemplateType == "00")		                         			
									temp = Styles[TemplateOrder] + "/" + sImagestr[i] + "_" + j + ".gif";
								else
		                         				temp = Styles[TemplateOrder] + "/../Others/" + sImagestr[i] + "_" + j + ".gif";		                         			
		                         		}else
		                          			temp = Styles[TemplateOrder] + "/" + temp;
		                         	}
		                         	else
		                          		temp = Styles[TemplateOrder] + "/../Others/" + sImagestr[i] + "_" + j + ".gif";
															
						tempImage[j-1].src = temp
					}
				}				
			}		
			buttonImage[i] = tempImage;
		}
		// add logo image
		TImage1 = new Image();
		
		IfRepeat = document.styleSheets[0].rules[16].style.backgroundRepeat;
		bRepeat = true;
		if((IfRepeat.toLowerCase() == "no-repeat") || (IfRepeat.toLowerCase() == ""))
		  bRepeat = false;		
		data = document.styleSheets[0].rules[16].style.backgroundImage;		  		  
		if(data == "") 
			if(typeof(document.styleSheets[0].rules[16].style.pic) != "undefined")
				data = document.styleSheets[0].rules[16].style.pic;
		if(!bRepeat && (data != ""))
		{
			temp = data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
			if(temp == "")
			{
				if(document.styleSheets[0].rules[11].style.visibility == "visible")
					temp = Styles[TemplateOrder] + "/logo.gif";
				else
					temp = Styles[TemplateOrder] + "/logo.jpg";				
			}
			else
		 		temp = Styles[TemplateOrder] + "/" + temp;
		}else
			temp = "";	
				
		TImage1.src = temp;				
		buttonImage[13] = TImage1;
		
		//add mpbg image
		TImage2 = new Image();
		IfRepeat = document.styleSheets[0].rules[9].style.backgroundRepeat;
		bRepeat = true;
		if((IfRepeat.toLowerCase() == "no-repeat") || (IfRepeat.toLowerCase() == ""))
		  bRepeat = false;		
		data = document.styleSheets[0].rules[9].style.backgroundImage;		  		  
		if(data == "") 
			if(typeof(document.styleSheets[0].rules[9].style.pic) != "undefined")
				data = document.styleSheets[0].rules[9].style.pic;
		if(!bRepeat && (data != ""))
		{
			temp = data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
		 	if(temp == "")
		  		temp = Styles[TemplateOrder] + "/mpbg.gif";
		 	else
		  		temp = Styles[TemplateOrder] + "/" + temp;
		}else
			temp = "";						
		 
		TImage2.src = temp;		
		buttonImage[14] = TImage2;
				
	}catch (e)
	{
		ShowError ("LoadButnImg exception", e);
	}	
}

function SetTOCNumbers(argu1)
{
	iTOCNumbers = argu1;
}

function adaptsize()
{	
	try
	{
	  	cltWidth=document.body.offsetWidth;
	  	cltHeight=document.body.offsetHeight;
	  	factor=Math.floor((1.0*cltWidth)/iorigW*100)/100;
	  	if (cltWidth != iorigW) 
	  	{
	  		if (cltWidth > cltHeight * iorigW / iorigH) 
	  			factor = Math.floor((1.0*cltHeight)/iorigH*100)/100;
			factor = 1;
		}else
		{
			factor = 1;
	  		iorigH = document.body.offsetHeight;
		}
		RefreshUI();
		textspace.Changefontsize();		
	}catch (e)
	{
		ShowError ("adaptsize exception", e);
	}	
}

function HideComponents()
{
	contents.style.visibility = "hidden";
	mppic.style.visibility = "hidden";
	mpbg.style.visibility = "hidden";
	playerpreviouspic.style.visibility = "hidden";
	playernextpic.style.visibility = "hidden";
}

function ShowComponents()
{
	try
	{
		if (bHasVideo != 0)
		{
			document.MediaPlayer1.style.top = 0;
			if (!parent.bPreview)
			{
				if ((igPlayState != iStateStop) && (igPlayState != iStateEnd) && (igPlayState != iStateReady))
				{
					if ((igPlayState == iStatePlay) || (igPlayState == iStatePause))					
						contents.style.visibility = "visible";
				}	
				else 
				{
					if (igPlayState == iStateEnd) igPlayState = iStatePause;
				}
			}else 
			{
				if (contents.style.posWidth!=0) contents.style.visibility = "visible";
			}
		}else
		{
			xx = contents.style.posWidth;	
			yy = contents.style.posHeight;			
			if (bMP7) 
			{
				if(document.styleSheets[0].rules[11].style.visibility != "visible")				
				{
					document.MediaPlayer1.style.top = yy - MP7_CONTROLPANEL_HEIGHT;
					document.MediaPlayer1.style.height = MP7_CONTROLPANEL_HEIGHT;
					yy = yy - MP7_CONTROLPANEL_HEIGHT;
				}	
			}
			else
			{
				if (!parent.bPreview) 
				{
					document.MediaPlayer1.style.top = yy - MP64_CONTROLPANEL_HEIGHT;
					document.MediaPlayer1.style.height = MP64_CONTROLPANEL_HEIGHT;
					yy = yy - MP64_CONTROLPANEL_HEIGHT;
				}else
				{
					document.MediaPlayer1.style.top = yy - SAMP_CONTROLPANEL_HEIGHT;
					document.MediaPlayer1.style.height = SAMP_CONTROLPANEL_HEIGHT;
					yy = yy - SAMP_CONTROLPANEL_HEIGHT;								
				}	
			}
			if(xx >= 0)
				document.MediaPlayer1.style.width = xx;
			
			if(xx >= 0)
				mppic.style.width = xx;			
			if(yy >= 0)
				mppic.style.height = yy;
			if(document.styleSheets[0].rules[1].style.visibility == "hidden")
                        	mppic.style.visibility = "hidden";
			else				
				mppic.style.visibility = 'visible';
		}	
		if(document.styleSheets[0].rules[9].style.visibility == "hidden")
                	mpbg.style.visibility = "hidden";		
		else mpbg.style.visibility = "visible";
		if (bMP7 || (parent.bPreview)) 
		{
			if (contents.style.posWidth!=0) timer.style.visibility = "visible";
		}
		if (document.styleSheets[0].rules[3].style.visibility == "visible")
		{
			playerpreviouspic.style.visibility = "visible";		
			playernextpic.style.visibility = "visible";
		}
		
		if(document.styleSheets[0].rules[1].style.visibility == "hidden")
                	contents.style.visibility = "hidden";
                
                 
	}catch (e)
	{
		ShowError ("ShowComponents exception", e);
	}	
}

function del_px(temp)
{
 return temp.substring(0,temp.indexOf("px"));	
}

function RefreshUI()
{
	try
	{
		//if (typeof(LINKLAYOUT) != "undefined" && typeof(document.styleSheets[0]) !="undefined")
		if (LINKLAYOUT.readyState == "complete")
		{				    		        
			SAcontainer.style.posTop = (cltHeight - del_px(document.styleSheets[0].rules[8].style.height) * factor) / 2;
			SAcontainer.style.posWidth = del_px(document.styleSheets[0].rules[8].style.width) * factor;
			SAcontainer.style.posHeight = del_px(document.styleSheets[0].rules[8].style.height) * factor;		        
		
		
				if (typeof(document.styleSheets[0].rules[17]) == "object")
				{
					data = document.styleSheets[0].rules[17].style.backgroundImage;														
					if((data == "none") || (data == "") || (data == "url()"))
						data = document.styleSheets[0].rules[8].style.backgroundImage;
					if((data != "") && (data != "none") && (data != "url()"))
					{
						SAcontainerpic.style.posWidth = SAcontainer.style.posWidth;
						SAcontainerpic.style.posHeight = SAcontainer.style.posHeight;	
						SAcontainerpic.src = Styles[TemplateOrder] + "/" + data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));		
						SAcontainerpic.style.visibility = "visible";
						SAcontainer.style.visibility = "visible";
					}else
					{	
						SAcontainer.style.visibility = "visible";
						if(document.styleSheets[0].rules[8].style.backgroundColor != "")
							SAcontainer.style.visibility = "visible";
						else
							SAcontainer.style.visibility = "hidden";										
						SAcontainerpic.style.visibility = "hidden";						
					}	
				}else SAcontainerpic.style.visibility = "hidden";
		
			if(!bSwap)
			{
				contents.style.posLeft = del_px(document.styleSheets[0].rules[1].style.left) * factor;
				contents.style.posTop = del_px(document.styleSheets[0].rules[1].style.top) * factor;
				if (document.styleSheets[0].rules[1].style.height == "100%")
				{
					contents.style.posHeight = SAcontainer.style.posHeight;	
					contents.style.posWidth = contents.style.posHeight * 4 / 3;
				}else	
				{
					contents.style.posHeight = parseInt(document.styleSheets[0].rules[1].style.height) * factor;	
					contents.style.posWidth = parseInt(document.styleSheets[0].rules[1].style.width) * factor;	
				}	
			}else
			{
				contents.style.posLeft = del_px(document.styleSheets[0].rules[3].style.left) * factor;
				contents.style.posTop = del_px(document.styleSheets[0].rules[3].style.top) * factor;						
				if (document.styleSheets[0].rules[3].style.height == "100%")
				{
					contents.style.posHeight = SAcontainer.style.posHeight;	
					contents.style.posWidth = pptmainDIV.style.posHeight * 4 / 3;
				}else	
				{
					contents.style.posHeight = parseInt(document.styleSheets[0].rules[3].style.height) * factor;	
					contents.style.posWidth = parseInt(document.styleSheets[0].rules[3].style.width) * factor;	
				}				
			}		
			contents.style.visibility = document.styleSheets[0].rules[1].style.visibility;
			if (bInitVideoStatus) 
			{
    				if ((contents.style.posWidth) > 0 && (contents.style.visibility == "visible")) 
    				{
     					bHasVideo = 1;
     					g_ignoreThis = false;
    				}else if (bHasVideo && (contents.style.posWidth == 0) && (contents.style.visibility == "hidden"))
			    	{
			     		if (bHasVideo && !bVer5 && !g_ignoreThis)
			     		{
			     			g_ignoreThis = true;
			     			if (bMP7 && (igPlayState == iStatePlay))
			     			{
			      				var nPos = MediaPlayer1.controls.currentPosition;
			      				MediaPlayer1.controls.playItem(MediaPlayer1.currentPlaylist.item(0));
			      				MediaPlayer1.controls.currentPosition = nPos;      
			      			}
			     		}
			     		bHasVideo = 2;
			     	}			     	
			}else 
			{
				bHasVideo = 0;
			}
			mppic.style.posLeft = contents.style.posLeft;
			mppic.style.posTop = contents.style.posTop;
			mppic.style.posWidth = contents.style.posWidth;
			mppic.style.posHeight = contents.style.posHeight;	
			MediaPlayer1.style.posWidth = contents.style.posWidth;
			MediaPlayer1.style.posHeight = contents.style.posHeight;
			
			if (del_px(document.styleSheets[0].rules[2].style.left)!=0)
			{
				textspaceDIV.style.posLeft = del_px(document.styleSheets[0].rules[2].style.left) * factor;
				textspaceDIV.style.posTop = del_px(document.styleSheets[0].rules[2].style.top) * factor;				
				textspaceDIV.style.posWidth = del_px(document.styleSheets[0].rules[2].style.width) * factor;
				textspaceDIV.style.posHeight = del_px(document.styleSheets[0].rules[2].style.height) * factor;
			}	
			textspaceDIV.style.visibility = document.styleSheets[0].rules[2].style.visibility;
			if(!bSwap || !bNormal)
			{			
				pptmainDIV.style.posLeft = del_px(document.styleSheets[0].rules[3].style.left) * factor;
				pptmainDIV.style.posTop = del_px(document.styleSheets[0].rules[3].style.top) * factor;						
				if (document.styleSheets[0].rules[3].style.height == "100%")
				{
					pptmainDIV.style.posHeight = SAcontainer.style.posHeight;	
					pptmainDIV.style.posWidth = pptmainDIV.style.posHeight * 4 / 3;
				}else	
				{
					pptmainDIV.style.posHeight = parseInt(document.styleSheets[0].rules[3].style.height) * factor;	
					pptmainDIV.style.posWidth = parseInt(document.styleSheets[0].rules[3].style.width) * factor;	
				}				
			}else
			{
				pptmainDIV.style.posLeft = del_px(document.styleSheets[0].rules[1].style.left) * factor;
				pptmainDIV.style.posTop = del_px(document.styleSheets[0].rules[1].style.top) * factor;
				if (document.styleSheets[0].rules[1].style.height == "100%")
				{
					pptmainDIV.style.posHeight = SAcontainer.style.posHeight;	
					pptmainDIV.style.posWidth = contents.style.posHeight * 4 / 3;
				}else	
				{
					pptmainDIV.style.posHeight = parseInt(document.styleSheets[0].rules[1].style.height) * factor;	
					pptmainDIV.style.posWidth = parseInt(document.styleSheets[0].rules[1].style.width) * factor;	
				}				
			}				
			pptmainDIV.style.visibility = document.styleSheets[0].rules[3].style.visibility;

			if (!parent.bPreview)
			{
				pendrawDIV.style.posLeft = pptmainDIV.style.posLeft;
				pendrawDIV.style.posTop = pptmainDIV.style.posTop;
				pendrawDIV.style.posWidth = pptmainDIV.style.posWidth;
				pendrawDIV.style.posHeight = pptmainDIV.style.posHeight;
				pendrawDIV.style.zIndex = 5;
			}	

			event2DIV.style.posLeft = del_px(document.styleSheets[0].rules[4].style.left) * factor;
			event2DIV.style.posTop = del_px(document.styleSheets[0].rules[4].style.top) * factor;						
			event2DIV.style.posWidth = del_px(document.styleSheets[0].rules[4].style.width) * factor;
			event2DIV.style.posHeight = del_px(document.styleSheets[0].rules[4].style.height) * factor;			
			event2DIV.style.visibility = document.styleSheets[0].rules[4].style.visibility;			
			//if (bMP7 || (parent.bPreview)) 
			{
				timer.style.posLeft = del_px(document.styleSheets[0].rules[7].style.left) * factor;
				timer.style.posTop = del_px(document.styleSheets[0].rules[7].style.top) * factor;				
				timer.style.posWidth = del_px(document.styleSheets[0].rules[7].style.width) * factor;
				timer.style.posHeight = del_px(document.styleSheets[0].rules[7].style.height) * factor;
				newSize = iTimerFontSize * factor ; 
				timer.style.fontSize=newSize+"pt";
			}
			
			logoDIV.style.posLeft = del_px(document.styleSheets[0].rules[16].style.left) * factor;
			logoDIV.style.posTop = del_px(document.styleSheets[0].rules[16].style.top) * factor;						
			logoDIV.style.posWidth = del_px(document.styleSheets[0].rules[16].style.width) * factor;
			logoDIV.style.posHeight = del_px(document.styleSheets[0].rules[16].style.height) * factor;
			logopic.style.posWidth = logoDIV.style.posWidth;
		        logopic.style.posHeight = logoDIV.style.posHeight;
			if (document.styleSheets[0].rules[16].style.visibility == "visible")
			{		
				if(buttonImage[13].src.charAt(buttonImage[13].src.length-1) != "/") logopic.src = buttonImage[13].src;
				else logopic.style.visibility = "hidden";
				logoDIV.style.visibility = "visible";
			}else
				logoDIV.style.visibility = "hidden";
			SideBG();
		}
	}catch (e)
	{
		ShowError ("RefreshUI exception", e);
	}		
}

function SideBG()
{
	try
	{
		//if (typeof(templateArray[TemplateOrder]) != "undefined")
		//{
			mpbg.style.posLeft = del_px(document.styleSheets[0].rules[9].style.left) * factor;
			mpbg.style.posTop = del_px(document.styleSheets[0].rules[9].style.top) * factor;
			mpbg.style.posWidth = del_px(document.styleSheets[0].rules[9].style.width) * factor;
			mpbg.style.posHeight = del_px(document.styleSheets[0].rules[9].style.height) * factor;
			mpbgpic.style.posWidth = mpbg.style.posWidth;
			mpbgpic.style.posHeight = mpbg.style.posHeight;
			if (document.styleSheets[0].rules[9].style.visibility == "visible")
			{		
				if(buttonImage[14].src.charAt(buttonImage[14].src.length-1) != "/") mpbgpic.src = buttonImage[14].src;
				else mpbgpic.style.visibility = "hidden";
				mpbg.style.visibility = "visible";
			}else
				mpbg.style.visibility = "hidden";			
			playerplaypause.style.posLeft = del_px(document.styleSheets[0].rules[10].style.left) * factor;	
			playerplaypause.style.posTop = del_px(document.styleSheets[0].rules[10].style.top) * factor;
			playerplaypause.style.posWidth = del_px(document.styleSheets[0].rules[10].style.width) * factor;
			playerplaypause.style.posHeight = del_px(document.styleSheets[0].rules[10].style.height) * factor;
			if(playerplaypause.style.visibility == "hidden") bPressPauseButn = true;
			playerplaypausepic.style.posWidth = playerplaypause.style.posWidth;
			playerplaypausepic.style.posHeight = playerplaypause.style.posHeight;
			playerprevious.style.posLeft = del_px(document.styleSheets[0].rules[11].style.left) * factor;	
			playerprevious.style.posTop = del_px(document.styleSheets[0].rules[11].style.top) * factor;
			playerprevious.style.posWidth = del_px(document.styleSheets[0].rules[11].style.width) * factor;
			playerprevious.style.posHeight = del_px(document.styleSheets[0].rules[11].style.height) * factor;
			playerpreviouspic.style.posWidth = playerprevious.style.posWidth;
			playerpreviouspic.style.posHeight = playerprevious.style.posHeight;	
			playernext.style.posLeft = del_px(document.styleSheets[0].rules[12].style.left) * factor;		
			playernext.style.posTop = del_px(document.styleSheets[0].rules[12].style.top) * factor;	
			playernext.style.posWidth = del_px(document.styleSheets[0].rules[12].style.width) * factor;
			playernext.style.posHeight = del_px(document.styleSheets[0].rules[12].style.height) * factor;
			playernextpic.style.posWidth = playernext.style.posWidth;
			playernextpic.style.posHeight = playernext.style.posHeight;	
			playerstop.style.posLeft = del_px(document.styleSheets[0].rules[13].style.left) * factor;
			playerstop.style.posTop = del_px(document.styleSheets[0].rules[13].style.top) * factor;
			playerstop.style.posWidth = del_px(document.styleSheets[0].rules[13].style.width) * factor;
			playerstop.style.posHeight = del_px(document.styleSheets[0].rules[13].style.height) * factor;
			playerstoppic.style.posWidth = playerstop.style.posWidth;
			playerstoppic.style.posHeight = playerstop.style.posHeight;	
			
			if((document.styleSheets[0].rules.length > 19) && (typeof(document.styleSheets[0].rules[18]) != "undefined"))
			{
				previousSlide.style.posLeft = del_px(document.styleSheets[0].rules[18].style.left) * factor;							
				previousSlide.style.posTop = del_px(document.styleSheets[0].rules[18].style.top) * factor;
				previousSlide.style.posWidth = del_px(document.styleSheets[0].rules[18].style.width) * factor;
				previousSlide.style.posHeight = del_px(document.styleSheets[0].rules[18].style.height) * factor;
				preSlidepic.style.posWidth = previousSlide.style.posWidth;
				preSlidepic.style.posHeight = previousSlide.style.posHeight;					
			}else
				previousSlide.style.visibility = "hidden";
				
			if(typeof(document.styleSheets[0].rules[19]) != "undefined")
			{
				nextSlide.style.posLeft = del_px(document.styleSheets[0].rules[19].style.left) * factor;		
				nextSlide.style.posTop = del_px(document.styleSheets[0].rules[19].style.top) * factor;	
				nextSlide.style.posWidth = del_px(document.styleSheets[0].rules[19].style.width) * factor;
				nextSlide.style.posHeight = del_px(document.styleSheets[0].rules[19].style.height) * factor;
				nextSlidepic.style.posWidth = nextSlide.style.posWidth;
				nextSlidepic.style.posHeight = nextSlide.style.posHeight;	
			}else
				nextSlide.style.visibility = "hidden";
			
			if(typeof(document.styleSheets[0].rules[20]) != "undefined")
			{			
				SyncData.style.posLeft = parseInt(document.styleSheets[0].rules[20].style.left) * factor;		
				SyncData.style.posTop = parseInt(document.styleSheets[0].rules[20].style.top) * factor;
				SyncData.style.posWidth = parseInt(document.styleSheets[0].rules[20].style.width) * factor;
				SyncData.style.posHeight = parseInt(document.styleSheets[0].rules[20].style.height) * factor;	
				SyncDatapic.style.posWidth = SyncData.style.posWidth;
				SyncDatapic.style.posHeight = SyncData.style.posHeight;			
			}else
				SyncData.style.visibility = "hidden";
			
			pptmainbg.style.posLeft = parseInt(document.styleSheets[0].rules[14].style.left) * factor;
			pptmainbg.style.posTop = parseInt(document.styleSheets[0].rules[14].style.top) * factor;						
			pptmainbg.style.posWidth = parseInt(document.styleSheets[0].rules[14].style.width) * factor;
			pptmainbg.style.posHeight = parseInt(document.styleSheets[0].rules[14].style.height) * factor;
			data = document.styleSheets[0].rules[14].style.backgroundImage;
			if(data != "")
			{
				pptmainbgpic.src = Styles[TemplateOrder] + "/" + data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
				pptmainbgpic.style.posWidth = pptmainbg.style.posWidth;
				pptmainbgpic.style.posHeight = pptmainbg.style.posHeight;		
			}else
			{
				pptmainbgpic.style.visibility = "hidden";
			}					
			if(typeof(document.styleSheets[2].rules[1]) != "undefined")	
			{
				pptMax.style.posLeft = del_px(document.styleSheets[2].rules[1].style.left) * factor;		
				pptMax.style.posTop = del_px(document.styleSheets[2].rules[1].style.top) * factor;	
				pptMax.style.posWidth = del_px(document.styleSheets[2].rules[1].style.width) * factor;
				pptMax.style.posHeight = del_px(document.styleSheets[2].rules[1].style.height) * factor;
				pptMaxpic.style.posWidth = pptMax.style.posWidth;
				pptMaxpic.style.posHeight = pptMax.style.posHeight;
			}else
				pptMax.style.visibility = "hidden";

			if(typeof(document.styleSheets[2].rules[2]) != "undefined")
			{
				videoMax.style.posLeft = del_px(document.styleSheets[2].rules[2].style.left) * factor;		
				videoMax.style.posTop = del_px(document.styleSheets[2].rules[2].style.top) * factor;	
				videoMax.style.posWidth = del_px(document.styleSheets[2].rules[2].style.width) * factor;
				videoMax.style.posHeight = del_px(document.styleSheets[2].rules[2].style.height) * factor;
				videoMaxpic.style.posWidth = videoMax.style.posWidth;
				videoMaxpic.style.posHeight = videoMax.style.posHeight;
			}else
				videoMax.style.visibility = "hidden";

			if(typeof(document.styleSheets[2].rules[3]) != "undefined")
			{
				SwapVP.style.posLeft = del_px(document.styleSheets[2].rules[3].style.left) * factor;		
				SwapVP.style.posTop = del_px(document.styleSheets[2].rules[3].style.top) * factor;	
				SwapVP.style.posWidth = del_px(document.styleSheets[2].rules[3].style.width) * factor;
				SwapVP.style.posHeight = del_px(document.styleSheets[2].rules[3].style.height) * factor;
				Swappic.style.posWidth = SwapVP.style.posWidth;
				Swappic.style.posHeight = SwapVP.style.posHeight;
			}else
				SwapVP.style.visibility = "hidden";

			if(typeof(document.styleSheets[2].rules[4]) != "undefined")
			{
				PPTNormal.style.posLeft = del_px(document.styleSheets[2].rules[4].style.left) * factor;		
				PPTNormal.style.posTop = del_px(document.styleSheets[2].rules[4].style.top) * factor;	
				PPTNormal.style.posWidth = del_px(document.styleSheets[2].rules[4].style.width) * factor;
				PPTNormal.style.posHeight = del_px(document.styleSheets[2].rules[4].style.height) * factor;
				PPTNormalpic.style.posWidth = PPTNormal.style.posWidth;
				PPTNormalpic.style.posHeight = PPTNormal.style.posHeight;					
			}else
				PPTNormal.style.visibility = "hidden";			
			
			if(typeof(document.styleSheets[2].rules[5]) != "undefined")
			{
				ViewScore.style.posLeft = del_px(document.styleSheets[2].rules[5].style.left) * factor;		
				ViewScore.style.posTop = del_px(document.styleSheets[2].rules[5].style.top) * factor;	
				ViewScore.style.posWidth = del_px(document.styleSheets[2].rules[5].style.width) * factor;
				ViewScore.style.posHeight = del_px(document.styleSheets[2].rules[5].style.height) * factor;
				ViewScorepic.style.posWidth = ViewScore.style.posWidth;
				ViewScorepic.style.posHeight = ViewScore.style.posHeight;					
				if(QuizNum > 0) ViewScore.style.visibility = "visible";
				else ViewScore.style.visibility = "hidden";
			}else
				ViewScore.style.visibility = "hidden";			
					
			if (bNormal)
			{	
				if(typeof(document.styleSheets[2].rules[1]) != "undefined")
				{
					if (document.styleSheets[2].rules[1].style.visibility == "visible") pptMax.style.visibility = "visible";
					else  pptMax.style.visibility = "hidden";
				}
				if(typeof(document.styleSheets[2].rules[2]) != "undefined")
				{
					if (document.styleSheets[2].rules[2].style.visibility == "visible") videoMax.style.visibility = "visible";	
					else videoMax.style.visibility = "hidden";
				}
				if(typeof(document.styleSheets[2].rules[3]) != "undefined")
				{
					if (document.styleSheets[2].rules[3].style.visibility == "visible") SwapVP.style.visibility = "visible";
					else SwapVP.style.visibility = "hidden";
				}
				if(typeof(document.styleSheets[2].rules[4]) != "undefined")
				{
					if (document.styleSheets[2].rules[4].style.visibility == "visible") PPTNormal.style.visibility = "visible";
					else PPTNormal.style.visibility = "hidden";
				}
			}
			
			if (document.styleSheets[0].rules[15].style.height == "100%")
			{
				SApanel.style.posWidth = parseInt(document.styleSheets[0].rules[15].style.width) * factor;
				SApanel.style.posHeight = this.document.body.offsetHeight;	
			}else
			{
				SApanel.style.posHeight = SAcontainer.style.posTop + parseInt(document.styleSheets[0].rules[15].style.height) * factor;
				SApanel.style.posWidth = this.document.body.offsetWidth;			
			}		        	
		        DareaDIV.style.posLeft = del_px(document.styleSheets[0].rules[5].style.left) * factor;
	                DareaDIV.style.posTop = del_px(document.styleSheets[0].rules[5].style.top) * factor;
	                DareaDIV.style.posWidth = del_px(document.styleSheets[0].rules[5].style.width) * factor;
	                DareaDIV.style.posHeight = del_px(document.styleSheets[0].rules[5].style.height) * factor;	                
			if(bIfDownload) DareaDIV.style.visibility = "visible"; 	                
	                contents.style.visibility = "visible";
			
			//set TOC & Darea background
			if (bVer5)
			{
				//Modify by james 2003/10/23
		                //bTOCVisible = document.styleSheets[0].rules[2].style.visibility;
		                //bDareaVisible = document.styleSheets[0].rules[5].style.visibility;		                
		                if(document.styleSheets[0].rules[2].style.visibility == 'hidden')
		                 bTOCVisible = false;
		                else
		                 bTOCVisible = true;
		                 
		                if(bDarea || bRef)
		                 bDareaVisible = true;
		                else
		                 bDareaVisible = false;
		                 
		                if (bTOCVisible)
		                {
			                if(document.styleSheets[0].rules[2].style.backgroundColor)
			                {
			                 	TOCColor = document.styleSheets[0].rules[2].style.backgroundColor; 
			                } 		      
			                else if(document.styleSheets[0].rules[2].style.backgroundImage)
			                {
			                	backtemp = document.styleSheets[0].rules[2].style.backgroundImage;	
			                 	backtemp = backtemp.substring(backtemp.indexOf("(")+1, backtemp.lastIndexOf(")"));
			                 	TOCColor = "/" + backtemp;
			                }
			        }   
			        if (bDareaVisible)
			        {     
			                if(document.styleSheets[0].rules[5].style.backgroundColor)
			                {
			                 	DareaColor = document.styleSheets[0].rules[5].style.backgroundColor; 
			                } 		      
			                else if(document.styleSheets[0].rules[5].style.backgroundImage)
			                {
			                 	backtemp = document.styleSheets[0].rules[5].style.backgroundImage;	
			                 	backtemp = backtemp.substring(backtemp.indexOf("(")+1, backtemp.lastIndexOf(")"));
			                 	DareaColor = "/" + backtemp;;
			                }	               	       
			        }        
		        }        
	                textOff = document.styleSheets[1].rules[0].style.color;
	                textOn = document.styleSheets[1].rules[1].style.color;
           ////////////////////////////////////////////////////////////////////////////////////////////////////////////	                
			
			//Fix-BugCode : SAR040407-0026
			if (parent.bPreview) 
				setTimeout("UpdateFramePos()", 300);

			ShowComponents();
		//}
	}catch (e)
	{
		ShowError ("SideBG exception", e);
	}		
}

function initTOC(iPos)
{
	printpage(iPos, 1);
	timer.innerText=TimerText();			
	bFirst = true;
}

function Create()
{	
	try
	{	
		igPlayState = iStatePlay;
		if (navigator.appVersion.indexOf("MSIE 5.0") > -1) bVer5 = true;
		else bVer5 = false;	
		CreateMediaPlayer();
		if (!parent.bPreview)
		{
			HideComponents();	
			var MoviePath=parent.IndexPath;
			var iURLStartPos=-1;
			if (MoviePath.indexOf(sFileURLheader)>-1) 
				iURLStartPos = sFileURLheader.length;
			else iURLStartPos = 0;
			absolutePath = MoviePath.substring(iURLStartPos, MoviePath.lastIndexOf("/"));
			MoviePath = absolutePath + "/index.asx";
			MoviePath = unescape(MoviePath);						
			if (bMP7) 
			{ 			
				GetFilePath(MoviePath);									
				MediaPlayer1.URL = unescape(GetClip());				
			}	
			else MediaPlayer1.FileName = MoviePath;						
			initTOC(parent.iSAStart);			
			
			//for navigate control
			if(getCookie("studytime"))
			 	document.MediaPlayer1.controls.currentPosition = getCookie("studytime");
			 	
			if (bSCORM)
				SetQuizDataToServer(); 
			 	
		}
	}catch (e)
	{
		ShowError ("Create exception", e);
	}		
}

function CreateMediaPlayer()
{
	var playerObj="";
	
	try
	{		
		if (parent.bPreview)
		{
			bMP7 = 0 ;
			playerObj="<OBJECT id=\"MediaPlayer1\" classid=\"CLSID:4F0CA480-D6BF-4CD1-A2C3-82B0D39B2EEB\" style=\"position:absolute;LEFT: 0px; TOP: 0px;\"><PARAM NAME=\"ShowCaptioning\" VALUE=\"0\"><\/OBJECT>"
			contents.innerHTML=playerObj;
		}
		else
		{			
			playerObj="<OBJECT id=\"MediaPlayer1\" classid=\"CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6\" style=\"position:absolute;LEFT: 0px; TOP: 0px;\"><param name=\"stretchToFit\" value=\"1\"><param name=\"enabled\" value=\"-1\"><param name=\"enableContextMenu\" value=\"true\"><PARAM NAME=\"uiMode\" VALUE=\"full\"><\/OBJECT>"			
			contents.innerHTML=playerObj;
			if (typeof(MediaPlayer1.URL) == "undefined") throw "No player";
			bMP7 = 1 ;
		}
	}
	catch(e)
	{
		try
		{
			bMP7 = 0 ;
			playerObj="<OBJECT id=\"MediaPlayer1\" classid=\"clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95\" style=\"LEFT: 0px; TOP: 0px;\" align=left><PARAM NAME=\"AudioStream\" VALUE=\"-1\"><PARAM NAME=\"AutoSize\" VALUE=\"1\"><PARAM NAME=\"AutoStart\" VALUE=\"0\"><PARAM NAME=\"AnimationAtStart\" VALUE=\"-1\"><PARAM NAME=\"AllowScan\" VALUE=\"-1\"><PARAM NAME=\"AutoRewind\" VALUE=\"0\"><PARAM NAME=\"Balance\" VALUE=\"0\"><PARAM NAME=\"BufferingTime\" VALUE=\"0\"><param name=\"CaptioningID\"><PARAM NAME=\"ClickToPlay\" VALUE=\"0\"><PARAM NAME=\"CursorType\" VALUE=\"0\"><PARAM NAME=\"CurrentPosition\" VALUE=\"-1\"><PARAM NAME=\"CurrentMarker\" VALUE=\"0\"><param name=\"DefaultFrame\"><PARAM NAME=\"DisplayBackColor\" VALUE=\"0\"><PARAM NAME=\"DisplayForeColor\" VALUE=\"16777215\"><PARAM NAME=\"DisplayMode\" VALUE=\"1\"><PARAM NAME=\"DisplaySize\" VALUE=\"4\"><PARAM NAME=\"Enabled\" VALUE=\"-1\"><PARAM NAME=\"EnablePositionControls\" VALUE=\"-1\"><PARAM NAME=\"EnableFullScreenControls\" VALUE=\"0\"><PARAM NAME=\"InvokeURLs\" VALUE=\"-1\"><PARAM NAME=\"Language\" VALUE=\"-1\"><PARAM NAME=\"Mute\" VALUE=\"0\"><PARAM NAME=\"PlayCount\" VALUE=\"1\"><PARAM NAME=\"PreviewMode\" VALUE=\"0\"><PARAM NAME=\"Rate\" VALUE=\"1\"><param name=\"SAMILang\"><param name=\"SAMIStyle\"><param name=\"SAMIFileName\"><PARAM NAME=\"SelectionStart\" VALUE=\"-1\"><PARAM NAME=\"SelectionEnd\" VALUE=\"-1\"><PARAM NAME=\"SendOpenStateChangeEvents\" VALUE=\"1\"><PARAM NAME=\"SendWarningEvents\" VALUE=\"-1\"><PARAM NAME=\"SendErrorEvents\" VALUE=\"-1\"><PARAM NAME=\"SendKeyboardEvents\" VALUE=\"0\"><PARAM NAME=\"SendMouseClickEvents\" VALUE=\"1\"><PARAM NAME=\"SendMouseMoveEvents\" VALUE=\"0\"><PARAM NAME=\"SendPlayStateChangeEvents\" VALUE=\"-1\"><PARAM NAME=\"ShowCaptioning\" VALUE=\"0\"><PARAM NAME=\"ShowControls\" VALUE=\"0\"><PARAM NAME=\"ShowAudioControls\" VALUE=\"-1\"><PARAM NAME=\"ShowDisplay\" VALUE=\"0\"><PARAM NAME=\"ShowGotoBar\" VALUE=\"0\"><PARAM NAME=\"ShowPositionControls\" VALUE=\"-1\"><PARAM NAME=\"ShowStatusBar\" VALUE=\"-1\"><PARAM NAME=\"ShowTracker\" VALUE=\"-1\"><PARAM NAME=\"TransparentAtStart\" VALUE=\"0\"><PARAM NAME=\"VideoBorder3D\" VALUE=\"0\"><PARAM NAME=\"Volume\" VALUE=\"-600\"><PARAM NAME=\"AllowChangeDisplaySize\" VALUE=\"1\"><PARAM NAME=\"EnableTracker\" VALUE=\"1\"><\/OBJECT>"
			contents.innerHTML=playerObj;
			if (typeof(MediaPlayer1.FileName) == "undefined") throw "No player";		
		}
		catch(e)
		{
			ShowError ("no players available", e);
		}
	}
}

function ProcessTemplateArgu(SAArgu)
{
	try
	{
		if (!bRef && !bDarea) 
		{
			TemplateStr = SAArgu.substring(0,SAArgu.indexOf("|"));
			if ((TemplateStr != "") && (TemplateStr.indexOf(":") != -1)) 
			{
				newSAArgu = TemplateStr.substring(0,TemplateStr.indexOf(":")) + TemplateStr.substring(TemplateStr.indexOf(":")+1, TemplateStr.length) + SAArgu.substring(SAArgu.indexOf("|"), SAArgu.length);
				return newSAArgu;
			}else 
				return SAArgu;
		}
		else
			return SAArgu;
	}catch (e)
	{
		ShowError ("ProcessTemplateArgu exception", e);
	}		
}

function butnRollOut(imgobj, mode)
{
	try
	{		
		if (!((sASXURL == "http") && !bMP7 && !parent.bPreview) && (typeof(MediaPlayer1)=="object") && buttonImage != "")
		{
			if (bMP7) currPlayState = MediaPlayer1.playState;
			else currPlayState = MediaPlayer1.PlayState + 1;
			switch (mode)
			{
				case PRESLIDE:
				case NEXTSLIDE:
				case SYNCDATA:
					imgobj.src = buttonImage[mode-10][0].src;
					break;
				case PLAYPAUSE:						
					if (currPlayState != iStateStop) 
					{						
						if (currPlayState == iStatePlay) // not playing
							imgobj.src = buttonImage[0][2].src;
						else if (currPlayState == iStatePause) 
							imgobj.src = buttonImage[1][0].src;
					}else 
						imgobj.src = buttonImage[1][0].src;
					break;
				case PREVIOUS:
				case NEXT:
				case STOP:
					//this code seems no use
					//if ((currPlayState != iStateStop) || (imgobj.id != "playerstoppic")) 
						imgobj.src = buttonImage[mode][0].src;
					break;
				case SLIDEMAX:
				case VIDEOMAX:
				case SWAP:
				case SLIDENORMAL:
				case VIEWSCORE:
					imgobj.src = buttonImage[mode][0].src;
					break;
			}
		}	
	}catch (e)
	{
		ShowError ("butnRollOut exception", e);
	}	
}

function butnRollOver(imgobj, mode)
{
		
	try
	{				
		if (!((sASXURL == "http") && !bMP7 && !parent.bPreview) && (typeof(MediaPlayer1)=="object") && buttonImage != "")	
		{
			if (bMP7) currPlayState = MediaPlayer1.playState;
			else currPlayState = MediaPlayer1.PlayState + 1;						
			switch (mode)
			{				
				case PRESLIDE:
				case NEXTSLIDE:	
				case SYNCDATA:				
					if (!parent.bPreview)
					{
						bChangeImg = true;
						if (mode==NEXTSLIDE) 
							if (iCurrSlide < sEvent1Time.length-1) imgobj.src = buttonImage[mode-10][1].src;
						if (mode==PRESLIDE) 
							if (iCurrSlide > 0) imgobj.src = buttonImage[mode-10][1].src;
						if (mode==SYNCDATA) 							
							if (!bSync) imgobj.src = buttonImage[mode-10][1].src;
					}	
					break;
				case PLAYPAUSE:					
					if (!bPreviewVideoEnd)
					{
						if (currPlayState != iStateStop)
						{
							if (currPlayState != iStatePlay)  // not playing
								imgobj.src = buttonImage[1][1].src;
							else if (currPlayState != iStatePause) 
								imgobj.src = buttonImage[0][1].src;
						}else 
							imgobj.src = buttonImage[1][1].src;
					}						
					break;
				case PREVIOUS:
				case NEXT:
				case STOP:					
					bChangeImg = true;
					if (mode==NEXT) 
					{
						if (igMarkerNum >= iTOCNumbers) bChangeImg = false;
					}
					if (mode==PREVIOUS) 
					{
						if (igMarkerNum <= 1) bChangeImg = false;
					}
					if (((currPlayState != iStateStop) || (imgobj.id != "playerstoppic")) && bChangeImg) 
						imgobj.src = buttonImage[mode][1].src;
					break;
				case VIDEOMAX:
					if (!parent.bPreview)
					{
						if ((currPlayState != iStateStop) && (currPlayState != iStatePause))
							imgobj.src = buttonImage[mode][1].src;
					}	
					break;
				case SLIDEMAX:
				case SWAP:
				case SLIDENORMAL:
				case VIEWSCORE:				
					imgobj.src = buttonImage[mode][1].src;
					break;
			}
		}
	}catch (e)
	{
		ShowError ("butnRollOver exception", e);
	}		
}

function PlayFun(){
	try
	{	
	   if(typeof(document.styleSheets[0].rules[1]) == "object") //Fix-Bug : SAR031007-0009
           {	
		if (contents.style.visibility == "hidden" && (bHasVideo ==1))
		{
			mppic.style.visibility = "hidden";
			if(document.styleSheets[0].rules[1].style.visibility == "visible") //Add by james 2003/05/07 				                         
				contents.style.visibility = "visible";
		}			
		igPlayState = iStatePlay;			
		if(playerplaypause.style.visibility == "hidden") bPressPauseButn = true;	
		
		if (bLoadCSSFileOK)	
		{
			playerplaypausepic.src = buttonImage[0][2].src;
			playerstoppic.src = buttonImage[4][0].src;
			playerplaypausepic.alt= sPause;
		}
		
		startTimer();
	   }
	   else
	   {
	   	setTimeout("PlayFun()",50);
	   }
	}catch (e)
	{
		ShowError ("PlayFun exception", e);
	}		
}

function PauseFun()
{
	try
	{
		//pauseTimer(0);
		
		if (bLoadCSSFileOK)
		{	
			if(bPreviewVideoEnd || bPreviewTimelinePause)	
				playerplaypausepic.src = buttonImage[1][0].src;
			else
				playerplaypausepic.src = buttonImage[1][1].src;
		 	playerstoppic.src = buttonImage[4][0].src;	
		 	playerplaypausepic.alt= sPlay;
		}
	}catch (e)
	{
		ShowError ("PauseFun exception", e);
	}	
}

function mpplay()
{
	try
	{		
		if (!bPreviewVideoEnd)
		{
			if (bReset) bReset=false;
			if (igPlayState==iStatePlay) bPressPauseButn=true;
			else bPressPauseButn=false;
			
			if (typeof(MediaPlayer1)=="object")
			{
				if (bMP7) currPlayState = MediaPlayer1.playState;
				else currPlayState = MediaPlayer1.PlayState + 1;		
				if (currPlayState != iStatePlay)	
				{
					if (bMP7) MediaPlayer1.controls.play();
					else document.MediaPlayer1.Play();	
					PlayFun();
				}else 
				{
					if (bMP7) MediaPlayer1.controls.pause();
					else MediaPlayer1.pause();
					if (!bRandom) igPlayState = iStatePause;
					PauseFun();
					bNoCount = true;
				}
				
				// for continue button after finish a Quiz in preview mode
				if(parent.bPreview)
				{	
					bPreviewTimelinePause = false;			
					InQuiz = false;
		  			if (bRandom) bRandom=false;
					if(bMP7)
 						RandomPositionChange((document.MediaPlayer1.controls.currentPosition*1000));
 					else
 						RandomPositionChange(document.MediaPlayer1.CurrentPosition*1000);	
 				}	
			}	
		}	
	}catch (e)
	{
		ShowError ("mpplay exception", e);
	}	
}

function StopFun()
{
	try
	{
	 if(typeof(document.styleSheets[0].rules[1]) == "object") //Fix-Bug : SAR031007-0009
	 {
		if (!parent.bPreview && (mppic.style.visibility == "hidden"))
		{
			//contents.style.visibility = "hidden";
			if(document.styleSheets[0].rules[1].style.visibility == "visible") 
			 ;//mppic.style.visibility = "visible";
		}
		if(parent.bPreview && document.styleSheets[0].rules[10].style.visibility == "visible")
			playerplaypausepic.src = buttonImage[1][0].src;	
		else
		{			
			playerplaypausepic.src = buttonImage[1][0].src;
			if(bVideoEnd)
				playerstoppic.src = buttonImage[4][0].src;
			else
				playerstoppic.src = buttonImage[4][1].src;			
		}	
         }
         else
         {
	   	setTimeout("StopFun()",50);
	 }		
	}catch (e)
	{
		ShowError ("StopFun exception", e);
	}		
}

function mpstop()
{
	try
	{		
		bSync = true;
		//for nevigate control
		bQuizContent = false;
		skipLQuiz = false;
		bQuizContent = false;
		bChangebyTOC = false;
		
		igPlayState = iStateStop;
		igMarkerNum = 1;
		inowFileNum = 0 ;
		bReset = true;	
		
		bPreviewVideoEnd = false;
		if (bScormInit) bScormInit = false;	
		if ((typeof(MediaPlayer1)=="object") && (bPlaySequence != STAYEND))
		{	
			if (bMP7) 
			{
				if(bPlaySequence == STAYHEAD)
				{
					MediaPlayer1.controls.stop();
					document.MediaPlayer1.controls.currentMarker = 1;
					if(typeof(sEvent1AtMarker[1]) != "undefined" && sEvent1AtMarker[1].charAt(0) == '"' && !parent.bPreview) // first TOC is Quiz
						goto(0,1);
					else
						goto(0,0);
					StopFun();
				}else	
					MediaPlayer1.controls.play();
			}else 
			{
				if (MediaPlayer1.PlayState != 0) document.MediaPlayer1.Stop();
				document.MediaPlayer1.CurrentPosition = 0;
				if(typeof(sEvent1AtMarker[1]) != "undefined" && sEvent1AtMarker[1].charAt(0) == '"' && !parent.bPreview) // first TOC is Quiz
					goto(0,1);
				else
					goto(0,0);
				StopFun();
			}
					
		}
	}catch (e)
	{
		ShowError ("mpstop exception", e);
	}		
}


//0906
function setMarkerNum(argu)
{
	try
	{
		igMarkerNum = argu;
		if (!bFirstEnter) 
		{
			bFirstEnter = false;
			iFirstMarkerNum = igMarkerNum;
		}
	}catch (e)
	{
		ShowError ("setMarkerNum exception", e);
	}		
}

function SetiAniIdx(argu)
{
	iAniIdx = parseInt(argu);
}

function SetiAni1Idx(argu)
{
	iAniIdx1 = parseInt(argu);
}

function SetDivVisible(argu)
{
	DivVisible = argu;
}

function SetDiv1Visible(argu)
{
	Div1Visible = argu;
}

function SetMPPosition(argu)
{
	try
	{
		iPos = parseInt(argu);
		if (bMP7) document.MediaPlayer1.controls.currentPosition = iPos / 1000;
		else document.MediaPlayer1.CurrentPosition = iPos / 1000;
	}catch (e)
	{
		ShowError ("SetMPPosition exception", e);
	}	
}

function postponePlaying()
{
	try
	{
		clearTimeout(ipostponeTimer);
		if (MediaPlayer1.playState != iStateBuffer)
		{
			//for nevigate control				
			if(!InQuiz)
			{
				if (bMP7) MediaPlayer1.controls.play();
				else MediaPlayer1.play();
				PlayFun();
			}
		}else 
		{
			//pauseTimer(0);
			ipostponeTimer = setTimeout("postponePlaying()", iWaitTime/2);
		}	
	}catch (e)
	{
		ShowError ("postponePlaying exception", e);
	}		
}

function continuePlaying()
{
	try
	{
		if (typeof(MediaPlayer1)=="object")
		{
			if (bFirst)
			{
				inowFileNum ++;	
				if (inowFileNum >= iFileNum) 
				{
			 		if (bFirst) bFirst=false;
			 		setTemplateIdx("1", sTinfo);
					if (bMP7) MediaPlayer1.controls.play();
					else MediaPlayer1.play();
					PlayFun();
					if (MediaPlayer1.playState != iStatePlay)
					{
						//pauseTimer(0);			
						ipostponeTimer = setTimeout("postponePlaying()", iWaitTime/2);
					}	
					bReset = false;
				}else
				{
					if (sASXURL == "file")			
					{
						if (bMP7) MediaPlayer1.controls.pause();
						else 
							if (MediaPlayer1.PlayState != 6) MediaPlayer1.pause();		
					}	
				}
			}
		}
	}catch (e)
	{
		ShowError ("continuePlaying exception", e);
	}	
}


function TimerText()
{
	try
	{		
		if (!parent.bPreview && typeof(document.styleSheets[0].rules[10]) != "undefined")
		{			
			timeValue = getPresentTime();
			if(document.styleSheets[0].rules[10].style.visibility == "visible")
			{
				second = Math.floor(timeValue % 60);
				minute = Math.floor(timeValue / 60) % 60;
				hour = Math.floor(timeValue / 3600);
				if (second < 10) s_second = "0"+second;
	        		else s_second = second.toString(10);
				if (minute < 10) s_minute = "0"+minute;
	        		else s_minute = minute.toString(10);
				if (hour == 0)
					head = "0" + ssymbol + s_minute + ssymbol + s_second;
				else
				{		
	                		s_hour = hour.toString(10);
					head = s_hour + ssymbol + s_minute + ssymbol + s_second;
				}
		
				sTemp = str_asx[16];
				sTemp = sTemp.substring(0, sTemp.indexOf("."));
                		var sTotalTimeToken = new Array();

                		sTotalTimeToken = sTemp.split(":");		
				if (parseInt(sTotalTimeToken[2]) < 10) s_second = "0" + sTotalTimeToken[0];
	        		else s_second = sTotalTimeToken[2];
				if (parseInt(sTotalTimeToken[1]) < 10) s_minute = "0" + sTotalTimeToken[1];
	        		else s_minute = sTotalTimeToken[1];
				if (parseInt(sTotalTimeToken[0]) == 0)
					sTotalTime = "0" + ssymbol + s_minute + ssymbol + s_second;					
				else
				{		
	                		s_hour = sTotalTimeToken[0];
					sTotalTime = s_hour + ssymbol + s_minute + ssymbol + s_second;
				}	        			    			
		
				head = head + " \\ " + sTotalTime;
				return head;
			}
			else
			{
				sTemp = str_asx[16];
				sTemp = sTemp.substring(0, sTemp.indexOf("."));
	                	var sTotalTimeToken = new Array();
	
	                	sTotalTimeToken = sTemp.split(":");		
				if (parseInt(sTotalTimeToken[2]) < 10) s_second = "0" + sTotalTimeToken[2];
		        	else s_second = sTotalTimeToken[2];
				if (parseInt(sTotalTimeToken[1]) < 10) s_minute = "0" + sTotalTimeToken[1];
		        	else s_minute = sTotalTimeToken[1];
				if (parseInt(sTotalTimeToken[0]) == 0)
					sTotalTime = "0" + ssymbol + s_minute + ssymbol + s_second;
				else
				{		
		                	s_hour = sTotalTimeToken[0];
					sTotalTime = s_hour + ssymbol + s_minute + ssymbol + s_second;
				}	        			        			
			}
			return sTotalTime;
		}
	}catch (e)
	{
		ShowError ("TimerText exception", e);
	}	
}


function getPresentTime()
{
	try
	{
		if(bMP7)
			return MediaPlayer1.controls.currentPosition;
		else
			return MediaPlayer1.CurrentPosition;
	}catch (e)
	{
		ShowError ("getPresentTime exception", e);
	}			
}

function goto(iPos, bQuiz)
{
	try
	{
		bSync = true;
		bChangebyTOC = true;
		var tmp = InQuiz;
		InQuiz = bQuiz;
		//for nevigate control
		//Quiz砞﹚ㄓ耞琌random access	
		if(!parent.bPreview)	
		{
			bContinueTOC = CheckTOC(iPos,1);					
			if(!bContinueTOC)
			{
				InQuiz = tmp;
				bChangebyTOC = false;
				alert(Navmessage);
				return;
			}
		}		
				
		if(ISQuiz && !InQuiz)
			skipLQuiz = true;
		
		if (bQuiz)
		{	
			nowQuiz	= iPos;		
			if (bMP7) MediaPlayer1.controls.pause();
			else MediaPlayer1.pause();
			if (!bRandom) igPlayState = iStatePause;
			PauseFun();			
		}
		
		
		if (bMP7) 
		{
			if (MediaPlayer1.playState<=3) igPlayState = MediaPlayer1.playState;		
		}else 
		{
			if (MediaPlayer1.PlayState<=2) igPlayState = MediaPlayer1.PlayState + 1;
		}
		if ((!bMP7 && (document.MediaPlayer1.PlayState != iStateStop_M6)) || bMP7) 
			bRandom = true;
	
		iAniIdx = 0;
		iAniIdx1 = 0;	
		inowFileNum = 0 ;
		if (bSync)
		{
			GetCurrentClip(iPos);				
				
			var ClipBeginTime = 0;
			if (MediaTime.length > 0)
				ClipBeginTime = MediaTime[iClipindex];
						
			if (bMP7) document.MediaPlayer1.controls.currentPosition = iPos  / 1000 - ClipBeginTime;
			else document.MediaPlayer1.CurrentPosition = iPos  / 1000 - ClipBeginTime;
			
		}			
		if (!bScormInit) parent.iSAStart = iPos;
		PositionChange(iPos, 1);
		
		RandomaccessTime = iPos / 1000;	
		setTimeout("SetRandomScrollPos()",100);	
		
		//bChangebyTOC = false;
	}catch (e)
	{
		ShowError ("goto exception", e);
	}	
}

function setTemplateIdx(argu1, argu2)
{
	try
	{
		TemplateOrder = parseInt(argu1);	
		if (!bIfDownload) 
		{	
			if (argu2.indexOf(":") != -1) Styles[TemplateOrder] = argu2.substring(0, argu2.indexOf(":"));
			else Styles[TemplateOrder] = argu2 ;
		}else Styles[TemplateOrder] = argu2.substring(0, argu2.indexOf(":"));
		SetupTemplate();
	}catch (e)
	{
		ShowError ("setTemplateIdx exception", e);
	}			
}

function SetupTemplate()
{
	try
	{
		if(iTemplateIdx ==9) bNormal = true;
		if ((ipreTemplateOrder != TemplateOrder) && bNormal)
		{
			HideComponents();
			ipreTemplateOrder = TemplateOrder;
			
			LINKFONT.href = Styles[TemplateOrder] + "/fontsize.css";
			LINKLAYOUT.href = Styles[TemplateOrder] + "/layout.css";
			TOOLBUTTON.href = Styles[TemplateOrder] + "/toolbutton.css";
						
			bLoadCSSFileOK = false;
			iLoadCSSFileCount = 0;
			iLoadCSSTimerID=setTimeout("linkCSSFile()",400);
		}	
	}catch (e)
	{
		ShowError ("SetupTemplate exception", e);
	}			
}

function setBGColor()
{
	try
	{
		if (bTOCVisible)
		{
			if (TOCColor.indexOf(".") > -1) 
			{
				TOCColor = "url(" + Styles[TemplateOrder] + TOCColor + ")" ;
				//document.applet1.setTOCBGcolor(TOCColor);
				setTOCBGcolor(TOCColor);
		      	}else 
		      	{
		      		if (TOCColor != "") //document.applet1.setTOCBGcolor(TOCColor);
		      			setTOCBGcolor(TOCColor);
		      	}	
		}      	
		
		if (bIfDownload && bDareaVisible) 
		{
			if (DareaColor.indexOf(".") > -1) 
			{
				DareaColor = "url(" + Styles[TemplateOrder] + DareaColor + ")" ;
				//document.applet1.setDareaBGcolor(DareaColor);
				setDareaBGcolor(DareaColor);
			}else 
			{
				if (DareaColor != "") //document.applet1.setDareaBGcolor(DareaColor);
					setDareaBGcolor(DareaColor);
			}	
		}
	}catch (e)
	{
		ShowError ("setBGColor exception", e);
	}			
}

function InitCSSImage()
{
	bLoadCSSFileOK = false;
	iLoadCSSFileCount = 0;
	linkCSSFile();
}

function linkCSSFile()
{	
	try
	{
		//if ((SCRIPTDATA.readyState=="loaded") && (LINKLAYOUT.readyState=="complete") && (!bLoadCSSFileOK) && (iLoadCSSFileCount==0))
		if ((LINKLAYOUT.readyState=="complete") && (!bLoadCSSFileOK) && (iLoadCSSFileCount==0))
		{
			if(LINKLAYOUT.href.indexOf("pptmax.css")== -1)
			{			
				LoadButnImg();
				InitImg();							
			}	
			iLoadCSSFileCount = 1;		
			if(iLoadCSSTimerID!=-1)
			{
				clearInterval(iLoadCSSTimerID);
				iLoadCSSTimerID=-1;
			}
			
			if (bIfDownload) LinkStr = "CSS_Style_d";
			else LinkStr = "CSS_Style";
			
			////////////add from layout_d.js///////////////////////
			if(bDarea || bRef)
				DareaDIV.style.visibility = "visible";
			else
			 	DareaDIV.style.visibility = "hidden";
		        textOff = document.styleSheets[1].rules[0].style.color;
	                textOn = document.styleSheets[1].rules[1].style.color;
		        ///////////////////////////////////////////////////////
		
			//eval("Init" + LinkStr +"();");			
			if (bVer5 && (sbgpic == " ")) setBGColor();
			else 
			{
				if (sbgpic == " ") textspace.document.body.style.backgroundColor = "transparent";
			}				
			textspace.header.style.color = document.styleSheets[1].rules[3].style.color;
			textspace.emaillink.style.color = document.styleSheets[1].rules[4].style.color;
			textspace.copyright.style.color = document.styleSheets[1].rules[5].style.color;
			textspace.description.style.color = document.styleSheets[1].rules[6].style.color;			
			if(!bApplySystem)
			{
				textspace.header.style.fontSize = document.styleSheets[1].rules[3].style.fontSize;
				textspace.emaillink.style.fontSize = document.styleSheets[1].rules[4].style.fontSize;
				textspace.copyright.style.fontSize = document.styleSheets[1].rules[5].style.fontSize;
				textspace.description.style.fontSize = document.styleSheets[1].rules[6].style.fontSize;
				textspace.TOCdata.style.fontSize = document.styleSheets[1].rules[0].style.fontSize;
				
				textspace.header.style.fontStyle = document.styleSheets[1].rules[3].style.fontStyle;
				textspace.emaillink.style.fontStyle = document.styleSheets[1].rules[4].style.fontStyle;
				textspace.copyright.style.fontStyle = document.styleSheets[1].rules[5].style.fontStyle;
				textspace.description.style.fontStyle = document.styleSheets[1].rules[6].style.fontStyle;				

				textspace.header.style.fontFamily = document.styleSheets[1].rules[3].style.fontFamily;
				textspace.emaillink.style.fontFamily = document.styleSheets[1].rules[4].style.fontFamily;
				textspace.copyright.style.fontFamily = document.styleSheets[1].rules[5].style.fontFamily;
				textspace.description.style.fontFamily = document.styleSheets[1].rules[6].style.fontFamily;								
			}			
			timer.style.color = textOff;			
			adaptsize();	
			if (iTOCNumbers>0) HighLight(ititleMarker);	

			if (bFirst) continuePlaying();
			bLoadCSSFileOK = true;
						
			//if the template is old one(before SA3.0), we will hide IE control's control panel			
			if(document.styleSheets[0].rules[11].style.visibility == "visible")
			{
				MediaPlayer1.uiMode = "none";				
				Darea.document.styleSheets[0].rules(0).style.backgroundColor = "transparent";
			}
			else
			{
				if(bRAccess) MediaPlayer1.uiMode = "full";				
				else
					MediaPlayer1.uiMode = "mini";				
				Darea.document.styleSheets[0].rules(0).style.backgroundColor = "#DDDDDD";
			}
			
		}else iLoadCSSTimerID=setTimeout("linkCSSFile()",50);
	}catch (e)
	{
		ShowError ("linkCSSFile exception", e);
	}			
}

function IncreaseFileNum()
{
	inowFileNum ++;
}

function setFileNum(argu)
{
	iFileNum = 2;
}
	
function IfNeedScroll(iMarker)
{
	var iTitleTop = textspace.document.all.item("title" + iMarker).offsetTop;
	var iTitleHeight = textspace.document.all.item("title" + iMarker).offsetHeight;
	var iScrollTop = textspace.document.body.scrollTop;
	var iClientHeight = textspace.document.body.clientHeight;
	var iScrollHeight= textspace.document.body.scrollHeight;
	var iOffsetTop = textspace.document.body.offsetTop;	
	if((iTitleTop >= iScrollTop) && (iTitleTop + iTitleHeight <= iScrollTop + iClientHeight))
		;
	else
	{
		if(iTitleTop + iTitleHeight < iClientHeight)
			textspace.scrollTo(0, 0);
		else if(iTitleTop > iScrollHeight - iClientHeight)
			textspace.scrollTo(0, iScrollHeight - iClientHeight);
		else
		{
			iScrollLength = iTitleTop - iClientHeight/2;
			if(iScrollLength < 0) iScrollLength = 0;
			textspace.scrollTo(0, iScrollLength);
		}
	}	
}

function HighLight(MarkerNo)
{	
	if (bTreeDisplay)
	{
		if (textspace.document.all.item("div"+MarkerNo)) iCurrDivHead = MarkerNo;
		if ((igPlayState != iStateStop) && (iCurrDivHead != MarkerNo)) textspace.ShowHideDIV(iCurrDivHead, 1);
	}	
	IfNeedScroll(MarkerNo);	
	ititleMarker = parseInt(MarkerNo);
	if(MarkerNo == "0") MarkerNo = "1";
	var title = "title" + MarkerNo;
	try
	{
		for ( var i=1;(i<=iNumMarkers);i++)
		{
			clear_title = "title" + i;
			if (textspace.document.all(clear_title))
			{
				if (sbgpic == " ") 
					textspace.document.all(clear_title).style.color = textOff;
				else
					textspace.document.all(clear_title).style.color = "#000000";	
			}	
		}
	}catch (e)
	{
		ShowError ("HighLight exception (clear_title)", e);
	}	
	try
	{
		if (textspace.document.all(title))
		{
			if (sbgpic == " ") textspace.document.all(title).style.color = textOn;
			else textspace.document.all(title).style.color = "#FF6347";
		}
	}catch (e)
	{
		ShowError ("HighLight exception (title)", e);
	}		
	try
	{
		if (parent.parent.bLMSresult == "true")
		{
			var iNowPos = 0;
			iNowPos = GetMarkerTime(MarkerNo);		
			sNowPos = iNowPos.toString(10);
			if (sNowPos.indexOf(".") != -1) sNowPos = sNowPos.substring(0,sNowPos.indexOf("."));
			//if (bSCORM) parent.parent.doLMSSetValue("cmi.core.lesson_location", sNowPos);	
		}
	}catch (e)
	{
		ShowError ("HighLight exception (SCORM) - MarkerNo : " + MarkerNo, e);
	}
	try
	{
		if (parent.parent.bLMSresult == "true")
		{
			var iNowPos = 0;
			iNowPos = GetMarkerTime(MarkerNo);		
			sNowPos = iNowPos.toString(10);
			if (sNowPos.indexOf(".") != -1) sNowPos = sNowPos.substring(0,sNowPos.indexOf("."));
			if (bSCORM) parent.parent.doLMSSetValue("cmi.core.lesson_location", sNowPos);	
		}
	}catch (e)
	{
		ShowError ("HighLight exception (doLMSSetValue)", e);
	}	
} 

function processStr(argu)
{
	var res;
	if(argu.indexOf("!!") != -1)				
		res = "-1";	
	else
		res = argu;
	//res = argu.replace( /\\/g, "\\\\");
	//res = res.replace( /'/g, "\\'");
	//res = res.replace( /"/g, "\"");	
	//res = res.replace( /&lt;/g, "<");
	//res = res.replace( /&gt;/g, ">");
	//res = res.replace( /&amp;/g, "&");		
	return res;
}

function UpdateFramePos()
{
	try
	{
		if (parent.bPreview)
		{
			var nWindowLeft = this.screenLeft;
			var nWindowTop = this.screenTop;
			var nVideoLeft=contents.style.posLeft + nWindowLeft;
			var nVideoTop=contents.style.posTop + nWindowTop;
			var nVideoWidth=contents.style.posWidth;
			var nVideoHeight=contents.style.posHeight;
			
			var nTocLeft=textspaceDIV.style.posLeft + nWindowLeft;
			var nTocTop=textspaceDIV.style.posHeight + nWindowTop;
			var nTocWidth=textspaceDIV.style.posWidth;
			var nTocHeight=textspaceDIV.style.posHeight;
		
			var nEvent1Left=0;
			var nEvent1Top=0;
			var nEvent1Width=0;
			var nEvent1Height=0;
			
			var nEvent2Left=0;
			var nEvent2Top=0;
			var nEvent2Width=0;
			var nEvent2Height=0;
					
			if( parent && pptmainDIV && (document.styleSheets[0].rules[3].style.visibility == "visible"))
			{
				nEvent1Left=pptmainDIV.style.posLeft + nWindowLeft + SAcontainer.style.posLeft;
				nEvent1Top=pptmainDIV.style.posTop + nWindowTop + SAcontainer.style.posTop;
				//nEvent1Width=pptmainDIV.style.posWidth;
				//nEvent1Height=pptmainDIV.style.posHeight;
				if(bLoadQuiz)
				{
					nEvent1Width=0;
					nEvent1Height=0;
					bLoadQuiz = false;
					bRaccessCallUpdate = true;					
				}
				else
				{
					nEvent1Width=pptmain.getclientWidth();
					nEvent1Height=pptmain.getclientHeight();
				}
			}
			
			if(parent && event2DIV && (document.styleSheets[0].rules[4].style.visibility == "visible"))
			{
				nEvent2Left=event2DIV.style.posLeft + nWindowLeft;
				nEvent2Top=event2DIV.style.posTop + nWindowTop;
				nEvent2Width=event2DIV.style.posWidth;
				nEvent2Height=event2DIV.style.posHeight;
			}
								
			//if the template is old one(before SA3.0), we will hide IE control's control panel
			// we use SetFramePosition function to send flag to SA determine MediaPlayer's control panel show or hide			
			var MediaPlayerUI;
			if(document.styleSheets[0].rules[10].style.visibility == "visible")
				MediaPlayerUI = 0; //none UI
			else
				MediaPlayerUI = 1; //full UI				
			document.MediaPlayer1.SetFramePosition(nVideoLeft, nVideoTop, nVideoWidth, nVideoHeight, nTocLeft, nTocTop, nTocWidth, nTocHeight, nEvent1Left, nEvent1Top, nEvent1Width, nEvent1Height, nEvent2Left, nEvent2Top, nEvent2Width, nEvent2Height,  MediaPlayerUI, 0, 0, 0);
		}
         } catch (e)
         {
            	ShowError("UpdateFramePos exception", e) ;
         }			
}

function ShowContextMenu()
{
	try
	{
		return true;
		if (event.srcElement.id != "MediaPlayer1")
			window.event.returnValue=false;
        } catch (e)
        {
            	ShowError("ShowContextMenu exception", e) ;
        }		
}

function GotoScormPos()
{
	try
	{
		clearTimeout(iSetScormPosTimer);	
		if (document.MediaPlayer1.controls.isAvailable("CurrentPosition"))
		{
			iAniIdx = 0;
			iAniIdx1 = 0;	
			if (bMP7) document.MediaPlayer1.controls.currentPosition = parent.iSAStart  / 1000;
			else document.MediaPlayer1.CurrentPosition = parent.iSAStart  / 1000;			
		}else iSetScormPosTimer = setTimeout("GotoScormPos()", iWaitTime/5);
         } catch (e)
         {
            	ShowError("GotoScormPos exception", e) ;
         }	
}

function uninit()
{
	if (!parent.bPreview)
	{		
		if (bMP7) 
		{
			MediaPlayer1.controls.stop();
		}else 
		{
			if (MediaPlayer1.PlayState != 0) document.MediaPlayer1.Stop();
		}	
	}	
}

function go(mywidth,myheight)
{
  if (mywidth=="") {mywidth='360';}
  if (myheight=="") {myheight='400';}
  window.open("http://www.goCyberlink.com", 'CyberWin','width=' + mywidth + ',height=' + myheight +',status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=no,top=40,left=200');
}

function ShowError(type, error)
{
	if(debug)
   		alert(type + ":" + error.toString());
	
}
 
function loadPendraw(bflag) 
{
	if (bflag)
	{
		pendrawDIV.style.visibility = "visible";
    		sFile1 = this.document.all.item("pptmain").src;
		sNowPendraw = sFile1.substring(0, sFile1.lastIndexOf("/")+1) + "pendraw.htm";
		this.document.all.item("pendraw").src = sNowPendraw;
	}else
		pendrawDIV.style.visibility = "hidden";
}

function SetScroll()
{
	if(typeof(pptmain.setScroll) != "undefined")
		pptmain.setScroll(ScrollXp, ScrollYp);
}

function FindQuizNum(QuizTime)
{
	for(i=0; i<QuizNum; i++)
	{
		if(Quiz[i] == QuizTime)
			break;
	}
	return i;
}

//for nevigate control
function setCookie(name, value)
{	
	try
	{
		if (bSCORM) 
		{
			if(name.indexOf("studytime") != -1) // do nothing
			{
			}
			else if(name.indexOf("Grade") != -1)
			{
				var QuizTime = name.substring(0, name.indexOf("Grade"));
				var num = FindQuizNum(QuizTime);
				var obj = "cmi.objectives." + num + ".score.raw";
				parent.parent.doLMSSetValue(obj, value);
			}
			else if(name.indexOf("Num") != -1)
			{
				var QuizTime = name.substring(0, name.indexOf("Num"));
				var num = FindQuizNum(QuizTime);
				var obj = "cmi.objectives." + num + ".score.max";
				parent.parent.doLMSSetValue(obj, value);
			}			
		}
		else
		{
	 		var exp = new Date();
	 		exp.setTime(exp.getTime() + (1000 * 60 * 60 * 24 * 31)); 
	 		document.cookie = escape(name) + "=" + escape(value) + "; expires=" + exp.toGMTString();	
	 	}
	}
	catch(e){
		ShowError("set cookie exception", e);
	}
}

//for nevigate control
function getCookie(name)
{
	try
	{
		if (bSCORM) 
		{
			if(name.indexOf("studytime") != -1) //do nothing
			{
			}
			else if(name.indexOf("Grade") != -1)
			{
				var QuizTime = name.substring(0, name.indexOf("Grade"));
				var num = FindQuizNum(QuizTime);
				var obj = "cmi.objectives." + num + ".score.raw";
				var grade = parent.parent.doLMSGetValue(obj);
				if(grade != "")
					return grade;
			}
			else if(name.indexOf("Num") != -1)
			{
				var QuizTime = name.substring(0, name.indexOf("Num"));
				var num = FindQuizNum(QuizTime);
				var obj = "cmi.objectives." + num + ".score.max";
				var QNum = parent.parent.doLMSGetValue(obj);
				if(QNum != "")
					return QNum;
			}
		}
		else
		{
			var cookiename = name + "=";	
			var dc = document.cookie;
			var begin, end;
			if(dc.length >0)
			{			
				begin = dc.indexOf(cookiename);		
				if(begin != -1)
				{
					begin += cookiename.length;
					end = dc.indexOf(";", begin);
					if(end == -1)
					{
						end = dc.length;
					}
					return unescape(dc.substring(begin, end));
				}
			}						
		}
		return null;
        }
        catch(e){
        	ShowError("get cookie exception", e);
        }
}

//for nevigate control
function CheckTOC(param,type)
{
     try
     {
     	
	// if it has no quiz, ignore this function
	if(QuizNum == 0)
		return true;
	
	
	var idx;
	ISQuiz = false;
	
	//Now TOC is Quiz and it must finish
	if(bQuizContent)
	{
		Navmessage = strCompleteTestFirst;
	 	return false;		
	}
	
	
	//get previous Quiz's index
	switch(type)
	{
		case 1:
			var i;
			for(i = 0; i<QuizNum; i++)
			{
				if(parseInt(Quiz[i]) >= parseInt(param))
				{
					if(parseInt(Quiz[i]) == parseInt(param))
					{
						ISQuiz = true;
					 	if(!InQuiz)
					  		idx = i;
					 	else
					  		idx = i-1;
					}
					else
					 	idx = i-1;
					break;
				}
				idx = i;							
			}
						
			break;
		default:
		        return true;
	}
			
	//if (idx == -1 ) return true;					
	//check if user can access the TOC according to previous Quiz's status	
	if(idx == -1 ||  parseInt(QuizInfo[idx][3]) == 1) //Let "idx == -1" status in is to set bQuizContent value
	{
		if(idx >0)
		{
			for(i=0; i<idx; i++) // check Quiz's status before this Quiz(If it has previous Quiz)
			{
				if(parseInt(QuizInfo[i][3]) == 0)
				{
					var tempnum = getCookie(Quiz[i] + "Num");
		 			var tempgrade = getCookie(Quiz[i] + "Grade"); 
		 			if((parseInt(tempnum) < parseInt(QuizInfo[i][0]) && parseInt(tempgrade) < parseInt(QuizInfo[i][1])) || !tempnum)
		 			{
		 				Navmessage =  strCompletePreviousTest;;
	 					return false; 	
		 			}
				}
			}
		}
		
		if(ISQuiz && !bQuizContent && InQuiz)  // the quiz does not has previous quiz (idx = -1)
		{
		 	var Quiznum = getCookie(Quiz[idx+1] + "Num");
		 	var Quizgrade = getCookie(Quiz[idx+1] + "Grade");
		 	if(parseInt(QuizInfo[idx+1][3]) == 0)
		 	{		 	
		 		if((parseInt(Quiznum) < parseInt(QuizInfo[idx+1][0]) && parseInt(Quizgrade) < parseInt(QuizInfo[idx+1][1])) || !Quiznum)
		 			bQuizContent = true;		  		
		 	}
		}
	 	return true;
	}
	else
	{
		var num = getCookie(Quiz[idx] + "Num");
		var grade = getCookie(Quiz[idx] + "Grade");
		if(num)
		{
			if(parseInt(num) >= parseInt(QuizInfo[idx][0]) || parseInt(grade) >= parseInt(QuizInfo[idx][1]))
			{
				if(ISQuiz && !bQuizContent && InQuiz)
				{
		 			var Quiznum = getCookie(Quiz[idx+1] + "Num");
		 			var Quizgrade = getCookie(Quiz[idx+1] + "Grade");
		 			if((parseInt(Quiznum) < parseInt(QuizInfo[idx+1][0]) && parseInt(Quizgrade) < parseInt(QuizInfo[idx+1][1]) && parseInt(QuizInfo[idx+1][3]) == 0) || !Quiznum)
		 				bQuizContent = true;		  		
				}
				return true;
			}
			else
			{
				Navmessage =  strCompletePreviousTest;;
	 			return false;
			}
		}
		else
		{
			Navmessage =  strCompletePreviousTest;;
	 		return false;
		}		
	}
	
     }
     catch(e)
     {
            	ShowError("check Toc exception", e);
     }		
} 

function CheckMarker(name, num)
{
	try {
         	             
	   	var T1,T2            	              
		if (iNumTOC <= 0)
              		return false;
                else if(typeof(iTOCAtMarker[name]) == "undefined") 
              		return false;
              	else
              	{
              		if (bMP7) T1 = document.MediaPlayer1.currentMedia.getMarkerTime(num);
			else T1 = document.MediaPlayer1.GetMarkerTime(num);
			if (bMP7) T2 = document.MediaPlayer1.currentMedia.getMarkerTime(num++);
			else T2 = document.MediaPlayer1.GetMarkerTime(num++);
              		if(T1 != T2)
              			return false;
              		else
              			return true;
              	}
              	                            
         } catch (e)
         {
              ShowError("CheckMarker exception", e)  ;
         }
}

function fnSyncData()
{
	if (!parent.bPreview && !bSync && (sEvent1Time.length != 0))
	{
		bSync = true;
		if (bMP7) MediaPlayer1.controls.play();
		else MediaPlayer1.Play();				
		if (!CheckTOC(getPresentTime()  * 1000,1))
			alert (Navmessage);
		else RandomPositionChange(getPresentTime() * 1000, 0);		
	}		
}

function fnnextSlide()
{
	if (!parent.bPreview)
	{		
		if((iCurrSlide == sEvent1Time.length - 1) || (sEvent1Time.length == 0))
			return ;
		else
		{
			bSync = false;
			playernextpic.src = buttonImage[3][2].src;
			iCurrSlide++;
			if (iCurrSlide > sEvent1Time.length) iCurrSlide = sEvent1Time.length;
			if (!CheckTOC(sEvent1Time[iCurrSlide],1))
				alert (Navmessage);
			else PositionChange(sEvent1Time[iCurrSlide], 0);
		}	
	}		
}

function fnpreviousSlide()
{
	if (!parent.bPreview)
	{	
		if (iCurrSlide == 0)
			return ;
		else
		{
			bSync = false;	
			playernextpic.src = buttonImage[2][2].src;
			iCurrSlide--;
			if (iCurrSlide < 0) iCurrSlide = 0;	
			if (!CheckTOC(sEvent1Time[iCurrSlide],1))	
				alert (Navmessage);
			else PositionChange(sEvent1Time[iCurrSlide], 0);		
		}	
	}	
}

function fnSlideMax()
{	
	bNormal = false;
	LINKLAYOUT.href = Styles[TemplateOrder] + "/pptmax.css";
	if(LINKLAYOUT.readyState != "complete")
		setTimeout("fnSlideMax()", 100);
	PPTNormal.style.visibility = "visible";
	if(QuizNum > 0) ViewScore.style.visibility = "visible";	
	else ViewScore.style.visibility = "hidden";
	SwapVP.style.visibility = "hidden";
	videoMax.style.visibility = "hidden";
	pptMax.style.visibility = "hidden";	
	if(!bRef) DareaDIV.style.visibility = "hidden";
	else DareaDIV.style.visibility = "visible";
	adaptsize();
}

function fnSwap()
{
	bSwap = !bSwap;	
	if (bSwap)
	{		
		contents.style.posLeft = del_px(document.styleSheets[0].rules[3].style.left) * factor;
		contents.style.posTop = del_px(document.styleSheets[0].rules[3].style.top) * factor;
		contents.style.posWidth = del_px(document.styleSheets[0].rules[3].style.width) * factor;
		contents.style.posHeight = del_px(document.styleSheets[0].rules[3].style.height) * factor;		
		MediaPlayer1.style.posWidth = contents.style.posWidth;
		MediaPlayer1.style.posHeight = contents.style.posHeight;
		pptmainDIV.style.posLeft = del_px(document.styleSheets[0].rules[1].style.left) * factor;
		pptmainDIV.style.posTop = del_px(document.styleSheets[0].rules[1].style.top) * factor;						
		pptmainDIV.style.posWidth = del_px(document.styleSheets[0].rules[1].style.width) * factor;
		pptmainDIV.style.posHeight = del_px(document.styleSheets[0].rules[1].style.height) * factor;
		pendrawDIV.style.posLeft = del_px(document.styleSheets[0].rules[1].style.left) * factor;
		pendrawDIV.style.posTop = del_px(document.styleSheets[0].rules[1].style.top) * factor;						
		pendrawDIV.style.posWidth = del_px(document.styleSheets[0].rules[1].style.width) * factor;
		pendrawDIV.style.posHeight = del_px(document.styleSheets[0].rules[1].style.height) * factor;	
	}else
	{
		contents.style.posLeft = del_px(document.styleSheets[0].rules[1].style.left) * factor;
		contents.style.posTop = del_px(document.styleSheets[0].rules[1].style.top) * factor;
		contents.style.posWidth = del_px(document.styleSheets[0].rules[1].style.width) * factor;
		contents.style.posHeight = del_px(document.styleSheets[0].rules[1].style.height) * factor;	
		MediaPlayer1.style.posWidth = contents.style.posWidth;
		MediaPlayer1.style.posHeight = contents.style.posHeight;		
		pptmainDIV.style.posLeft = del_px(document.styleSheets[0].rules[3].style.left) * factor;
		pptmainDIV.style.posTop = del_px(document.styleSheets[0].rules[3].style.top) * factor;						
		pptmainDIV.style.posWidth = del_px(document.styleSheets[0].rules[3].style.width) * factor;
		pptmainDIV.style.posHeight = del_px(document.styleSheets[0].rules[3].style.height) * factor;
		pendrawDIV.style.posLeft = del_px(document.styleSheets[0].rules[3].style.left) * factor;
		pendrawDIV.style.posTop = del_px(document.styleSheets[0].rules[3].style.top) * factor;						
		pendrawDIV.style.posWidth = del_px(document.styleSheets[0].rules[3].style.width) * factor;
		pendrawDIV.style.posHeight = del_px(document.styleSheets[0].rules[3].style.height) * factor;		
	}	
	
	if(bHasVideo == 0)
	{
		xx = contents.style.posWidth;	
		yy = contents.style.posHeight;	
		mppic.style.posLeft = contents.style.posLeft;	
		mppic.style.posHeight = contents.style.posHeight;
		if (bMP7) 
		{
			if(document.styleSheets[0].rules[11].style.visibility != "visible")				
			{
				document.MediaPlayer1.style.top = yy - MP7_CONTROLPANEL_HEIGHT;
				document.MediaPlayer1.style.height = MP7_CONTROLPANEL_HEIGHT;
				yy = yy - MP7_CONTROLPANEL_HEIGHT;
			}	
		}
		else
		{
			if (!parent.bPreview) 
			{
				document.MediaPlayer1.style.top = yy - MP64_CONTROLPANEL_HEIGHT;
				document.MediaPlayer1.style.height = MP64_CONTROLPANEL_HEIGHT;
				yy = yy - MP64_CONTROLPANEL_HEIGHT;
			}else
			{
				document.MediaPlayer1.style.top = yy - SAMP_CONTROLPANEL_HEIGHT;
				document.MediaPlayer1.style.height = SAMP_CONTROLPANEL_HEIGHT;
				yy = yy - SAMP_CONTROLPANEL_HEIGHT;								
			}	
		}
		if(xx >= 0)
			document.MediaPlayer1.style.width = xx;
		
		if(xx >= 0)
			mppic.style.width = xx;			
		if(yy >= 0)
			mppic.style.height = yy;
		if(document.styleSheets[0].rules[1].style.visibility == "hidden")
                	mppic.style.visibility = "hidden";
		else				
			mppic.style.visibility = 'visible';					
	}
	if(parent.bPreview)
		setTimeout("UpdateFramePos()", 300);
}

function fnSlideNormal()
{
	bNormal = true;
	LINKFONT.href = Styles[TemplateOrder] + "/fontsize.css";
	LINKLAYOUT.href = Styles[TemplateOrder] + "/layout.css";
	TOOLBUTTON.href = Styles[TemplateOrder] + "/toolbutton.css";
	PPTNormal.style.visibility = "hidden";
	if(document.styleSheets[2].rules[1].style.visibility == "visible") pptMax.style.visibility = "visible";	
	if(document.styleSheets[2].rules[2].style.visibility == "visible") videoMax.style.visibility = "visible";	
	if(document.styleSheets[2].rules[3].style.visibility == "visible") SwapVP.style.visibility = "visible";
	if(QuizNum > 0) ViewScore.style.visibility = "visible";	
	else ViewScore.style.visibility = "hidden";
	if(bDarea || bRef) DareaDIV.style.visibility = "visible";
	adaptsize();	
}

function openRemindWindow(iPPindex)
{
	var iPauseTime = 0;
	if (RemindWindowSetting())	
	{
		if (bMP7) MediaPlayer1.controls.pause();
		else MediaPlayer1.Pause();	
		PauseFun();	
		alert (PPArguments[iPPindex]);
		if (bMP7) MediaPlayer1.controls.play();
		else MediaPlayer1.Play();	
		PlayFun();	
	}	
}

function RemindWindowSetting()
{
	if (bMP7) currPlayState = MediaPlayer1.playState;
	else currPlayState = MediaPlayer1.PlayState + 1;
	return ((currPlayState == iStatePlay) || (currPlayState == 9)) ;		
}

function GetCurrentClip(iPos)
{
	iOldClipindex = iClipindex;
	var mapposition = 0;
	for (var i=1;i<MediaTime.length;i++)
	{
		if (iPos >= parseInt(MediaTime[i] * 1000))
		{			
	        	mapposition = parseInt(MediaTime[i] * 1000);
	        	iClipindex =i;
	        	
	  	}
	  	if (iPos < parseInt(MediaTime[i] * 1000)) break;
	}      	
      	
	iElapsedTime = 0; 
	if (MediaTime.length > 0)     	
		iElapsedTime = Math.abs(mapposition - MediaTime[iClipindex] * 1000);
	if (iClipindex == MediaTime.length) iClipindex = 1;
	
	if(iOldClipindex != iClipindex)	
		ChangeClip();		
	
}

function ChangeClip()
{			
	if (bMP7) 
	{
		if (igPlayState != iStatePlay) MediaPlayer1.settings.autoStart = false;
		MediaPlayer1.URL = unescape(GetClip());
	}else ;
	CheckMediaType();
}

function fnVideoMax()
{
	try {
		if (bMP7) currPlayState = MediaPlayer1.playState;
		else currPlayState = MediaPlayer1.PlayState + 1;		
		if (!parent.bPreview && (currPlayState != iStateStop) && (currPlayState != iStatePause))		
		{
			if(bMP7) MediaPlayer1.fullScreen = true;
			else MediaPlayer1.DisplaySize = 3;
		}	
	}
	catch (e)
	{
		return;
	}
}

function VideoNormal()
{
	try {
		if(bMP7) MediaPlayer1.fullScreen = false;
		else MediaPlayer1.DisplaySize = 4;						
	}
	catch (e)
	{
		return;
	}
}

function CheckMediaType()
{
	if (MediaType[iClipindex] == 0) VideoNormal();
	else if (MediaType[iClipindex] == 1) fnVideoMax();
}

function SetRandomScrollPos()
{	
	var Pos = "";	
	for(i=0; i<iScrollNUM; i++)
	{	
		ScrollTime = SAScrollINFO[i].substring(0,SAScrollINFO[i].indexOf("|"));
		if(RandomaccessTime < ScrollTime)
			break;
		Pos = SAScrollINFO[i].substring(SAScrollINFO[i].indexOf("|")+1, SAScrollINFO[i].length);
	}		
	ScrollXp = Pos.substring(0,Pos.indexOf("|"));
	ScrollYp = Pos.substring(Pos.indexOf("|")+1,Pos.length) ;
	if(Pos != "" && document.all.item("pptmain").src != "blank.htm")
		SetScroll();
}

function setSkipQuiz()
{
	skipLQuiz = false;
}

function NextClipPlay()
{
	if (bMP7) MediaPlayer1.controls.play();
	else ;
	CheckMediaType();	
}

function GetFilePath(mPath)  // set sMoviePath, MediaParam
{
 	var xmlObj ;
 	xmlObj = new ActiveXObject("Microsoft.XMLDOM"); 
 	xmlObj.async = false;
    	var res = xmlObj.load(mPath);
        if (res) 
        {         
 	 	var obj = xmlObj.documentElement.selectSingleNode("/ASX/Entry/MEDIAPATH");
  		sMoviePath = (obj == null) ? "" : obj.text;
  		obj = xmlObj.documentElement.selectSingleNode("/ASX/Entry/MEDIAPARAM"); // for CTMS with MMS server
  		MediaParam = (obj == null) ? "" : obj.text;
  		
  		if(sMoviePath.indexOf("http://") == -1 && sMoviePath.indexOf("mms://") == -1) 			
			sMoviePath = absolutePath + "/" + sMoviePath;  		
  	}
	sMoviePath = 'http://webcast.shareinvestor.com/ir/grammy/oppday3q08/Media/';
}

function mpnext()
{
	try
	{
		if (!((sASXURL == "http") && !bMP7 && !parent.bPreview) && (typeof(MediaPlayer1)=="object"))
		{
			bChangeImg = false;
			if (bMP7)
			{
				igPlayState = MediaPlayer1.playState;
				if (igMarkerNum < iTOCNumbers)
				{
					bChangeImg = true;
					igMarkerNum ++;
					nextMarker = igMarkerNum;
					//document.applet1.ChangeMarker(1, nextMarker);
					ChangeMarker(1, nextMarker);
				}	
			}else
			{
				igPlayState = MediaPlayer1.PlayState + 1;
				if (igMarkerNum < iTOCNumbers)
				{
					bChangeImg = true;
					igMarkerNum ++;
					nextMarker = igMarkerNum ;
					//document.applet1.ChangeMarker(1, nextMarker);
					ChangeMarker(1, nextMarker);
				}	
			}
			if (bChangeImg) 
			{
				playernextpic.src = buttonImage[3][2].src;
			}
		}
	}catch (e)
	{
		ShowError ("mpnext exception", e);
	}		
}

    function ChangeMarker(iType, iMarker)
    {
	 try 
         {
              	//find the map time of iMarker
              	var j = 0;
              	var TOCcount = 1;
	      	for (j=0;j<iTotalMarkers;j++)
	      	{
	            	if (iTOCIndexAtMarker[j]== iMarker) break;
	      	}
	      	
	      	bContinueTOC = CheckTOC(parseInt(sTimeArray[j]),1);					
		if(!bContinueTOC)
		{			
			alert(Navmessage);
			return;
		}
	      	
	      	SetMPPosition(sTimeArray[j]);
	      	PositionChange(parseInt(sTimeArray[j]), 1);
         } catch (e)
         {
              ShowError("ChangeMarker exception", e);
         }
    }
    
function mpprevious()
{
	try
	{
		if (!((sASXURL == "http") && !bMP7 && !parent.bPreview) && (typeof(MediaPlayer1)=="object"))
		{
			var previousMarker = 0;
			bChangeImg = false;
			if (bMP7)
			{
				igPlayState = MediaPlayer1.playState;	
				if (igMarkerNum > 1) 
				{		 
					bChangeImg = true;
					igMarkerNum = igMarkerNum - 1;
					previousMarker = igMarkerNum ;
					//document.applet1.ChangeMarker(0, previousMarker);
				}
			}else
			{
				igPlayState = MediaPlayer1.PlayState + 1;	
				if (igMarkerNum > 1) 
				{
					bChangeImg = true;
					igMarkerNum = igMarkerNum - 1;
					previousMarker = igMarkerNum;
					//document.applet1.ChangeMarker(0, previousMarker);			
				}	
			}
			if (bChangeImg) ChangeMarker(0, previousMarker);		
			if (bChangeImg) 
				playerpreviouspic.src = buttonImage[2][2].src;
		}	
	}catch (e)
	{
		ShowError ("mpprevious exception", e);
	}	
}

function startTimer()
{
	try
	{
		if (!parent.bPreview) 		
		{
			//start from 00:00			
			if(impTimerID==-1)
			{
				updateTimer();
				impTimerID=setInterval("updateTimer()",500);
			}
		}
	}catch (e)
	{
		ShowError ("startTimer exception", e);
	}	
}

function updateTimer()
{
	try
	{
		//g_nCurrentClock=getPresentTime();
		//data1 = TimerText(g_nCurrentClock);
		data1 = TimerText();
		if (!parent.bPreview) timer.innerText=data1;
	}catch (e)
	{
		ShowError ("updateTimer exception", e);
	}	
}

function fnViewScore()
{
	var nowPath=window.location.href;
	var iURLStartPos=-1;
	var CurrentDir = nowPath.substring(0, nowPath.lastIndexOf("/"));
	nowPath = CurrentDir + "/../Test/sumform.htm";
	nowPath = unescape(nowPath);
	rWin = window.open(nowPath,"win_sum","left=300,top=0,width=600,height=500, resizable=yes, scrollbars=yes");
	rWin.focus();	
}

function LoadClip() //delay load clip, foe WMP7.1 issue
{
	MediaPlayer1.URL = unescape(GetClip());
}

function GetClip() // get current clip path
{
	var sMovieFile;
	bChangebyTOC = false;
	if (sMediaFiles.length>=1)
	{
  		sMovieFile = sMoviePath + sMediaFiles[iClipindex] + MediaParam;
  		return sMovieFile;
  	}
  	else
  		return "";
} 

function SetQuizDataToServer()
{
	if(QuizNum == 0)
		return;
	
	var TotalScore = 0;
	for(i=0; i<QuizNum; i++)
    	{	
    		var QuizGrade;
    		if(getCookie(Quiz[i] + "Grade"))
    			QuizGrade = getCookie(Quiz[i] + "Grade");	
    		else
    			QuizGrade = 0;
    		TotalScore = TotalScore + parseInt(QuizGrade) * parseInt(QuizInfo[i][2]) / 100;    		    		
	}	
	
	parent.parent.doLMSSetValue("cmi.core.score.raw", TotalScore);
	if(TotalScore >= TPassScore)
		parent.parent.doLMSSetValue("cmi.core.lesson_status", "passed");
	else
		parent.parent.doLMSSetValue("cmi.core.lesson_status", "failed");
} 	