var debug = false;
var bTOCVisible = true;
var bDareaVisible = false;
var g_ignoreThis = false;
var bInitVideoStatus = true;
var sTotalVideoLength = "";
var bPreviewVideoEnd = false;
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 = false;
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");
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 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;

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)
			{
				if (bMP7) MediaPlayer1.controls.play();
				else MediaPlayer1.play();	 		
				PlayFun();
				bReset = false;
				startTimer();			
			}	
		}
	}	
}    
    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;

            var sParamArray = new Array();
            var sNameArray = new SpecificArray(iNumMarkers);
            var sNameLink = new SpecificArray(iNumMarkers);
            var s_tempTime = "";
            var markerHeading = "";
            var BlueSection = "";           
            
            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;

	    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];
	    }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("-"));	
	    }	
	    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;
            	for (var i = 1; i <= iNumMarkers; i++)
            	{
            		var temp = '';
            		sGet = processStr(document.MediaPlayer1.GetMarkerName(i));
            		//Fix-BugCode : SAR031023-0004
            		for(var j = 0; j<= sGet.length; j++)
            		{
            			if(sGet.charAt(j) == '%')
            			{
            				temp = temp + '%';
            				j = j+2;
            			}
            			else
            			{
            				temp = temp + sGet.charAt(j);
            			}
            		}
            		sNameArray[i] = sGet;
            		sNameLink[i] = temp;            		            		
            		sTimeArray[i-1] = document.MediaPlayer1.GetMarkerTime(i).toString(10);
            	}	            		
            }
            TOCHeading(sParamArray[0], sParamArray[1], sParamArray[2], sParamArray[3], sParamArray[10], sParamArray[11]);
            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\">");	    
  	    for (var j=0;j<iNumMarkers;j++)
            {
                        sTOC = "";
                        sNameArray[j+1] = ProcessTemplateArgu(sNameArray[j+1]);
                        if (sNameArray[j+1].indexOf("?")+1 != sNameArray[j+1].length)
                        {
                           //Fix-BugCode : SAR031023-0004
                           if (!parent.bPreview)
                                sTOC = sNameArray[j+1].substring(sNameArray[j+1].indexOf("?")+1, sNameArray[j+1].length);
                           else
                              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") ;
     			sFiles = sNameArray[j+1].substring(sNameArray[j+1].indexOf("|")+1, sNameArray[j+1].indexOf("?"));
     	
                        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
                        		{
                            			sEvent1AtMarker[j] = sFiles;
                            			//iHintEvent1[j] = j;
                            			iE1index = j;
                            			sDareaAtMarker[j] = "";
                            			iHintDarea[j] = iDareaindex;
                        		}
					sEvent2AtMarker[j] = "";
                        		iHintEvent2[j] = iE2index;
		    		}else
                    		{
	                                sEvent1AtMarker[j] = sFiles.substring(0, sFiles.indexOf("|"));
	                                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];
//			buffer_event1.append("Event1 [" + j + "]: " + sTimeArray[j] + " -> " + sEvent1AtMarker[j] + " -- " + iHintEvent1[j] + " -- " + sPenDrawAtE1[j] + " -- " + sAniAtE1[j] + "\n") ;
//			buffer_event2.append("Event2 [" + j + "]: " + sTimeArray[j] + " -> " + sEvent2AtMarker[j] + " -- " + iHintEvent2[j] + " -- " + sPenDrawAtE2[j] + " -- " + sAniAtE2[j] + "\n") ;/
                	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;
				//buffer_toc.append("TOCAtMarker[" + j + "]: "  + sTimeArray[j] + " -> " + TOCAtMarker[j] + " -- " + iTOCIndexAtMarker[j] + "\n") ;
                	}else                		
                	{
                  		iNumTOC ++;
                  		iTOCindex = j + 1;
                          	iTOCAtMarker[j] = iTOCindex;
                          	iTOCIndexAtMarker[j] = iNumTOC;

                          	if (sParamArray[13] == "0") markerHeading = "";
                          	else if (sParamArray[13] == "1") markerHeading = iNumTOC.toString(10) + ".";
                          	else if (sParamArray[13] == "2") markerHeading = sHead;
                          	else if (sParamArray[13] == "3") markerHeading = sHead + iNumTOC.toString(10) + ".";
                              	//enable the link anchor of TOC
                      		if (!bMP7)
                      		{
                            		if ((sParamArray[8] == "file") || (sParamArray[0] == "mms"))
                                		textspace.document.writeln("<div id=title"+iTOCindex.toString(10)+" onclick=\"javascript:parent.goto("+sTimeArray[j]+")\" style=\"color:#0000FF; cursor: hand\">" + markerHeading + sTOC +"</div>");
                            		else
                                		textspace.document.writeln("<div id=title"+iTOCindex.toString(10)+" style=\"color:#0000FF\">" + markerHeading + sTOC +"</div>");
                      		}else
                            		textspace.document.writeln("<div id=title"+iTOCindex.toString(10)+" onclick=\"javascript:parent.goto("+sTimeArray[j]+")\" style=\"color:#0000FF; cursor: hand\">" + markerHeading + sTOC +"</div>");                            		
           		}
            	}
            	textspace.document.writeln("</div></body></html>");

            	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
          {
                textspace.document.body.innerHTML = "";
                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 text=#000000 STYLE=\"background-color:transparent\" oncontextmenu=\"window.event.returnValue=false\">");
  		else
                {
                    if (sparam.indexOf(".") == -1) // color, not image file
                        textspace.document.write("<body text=#000000 STYLE=\"background-color:" + sparam + "\" oncontextmenu=\"window.event.returnValue=false\">");
                    else
                        textspace.document.write("<body text=#000000 STYLE=\"background-image: url(" + sparam + "); background-repeat: repeat\" oncontextmenu=\"window.event.returnValue=false\">");
                }
          } catch (e)
          {
              ShowError("background exception", e)  ;
          }
    }    
    
    function PositionChange(newposition, iType)
    {
         try
         {
                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;
                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 (iType == 1)
                {
                	if (parent.bPreview) 
                	{
                		AttachTemplate(sNowTemplateDirName, TemplateSeekIndex);
                	}else
                	{                	
	                        if (sNowTemplateDirName != sPreTemplateDirName)
	                                AttachTemplate(sNowTemplateDirName, TemplateSeekIndex);
	                        else
	                                InitCSSImage();
			}	                                
                }
                //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)
                            	{
                                	compareData = iTOCAtMarker[i];
                                	FindIdx = i;
                            	}
                   	}
                  	if (compareData==0)  // no TOC at first Time region
                  	{
                      		for (i=ubound;i<=iTotalMarkers;i++)
                      		{
                            		if (iTOCAtMarker[i] > 0) 
                            		{
                                		compareData = iTOCAtMarker[i];
                                		FindIdx = i;
                                		break;
                            		}
                      		}
                  	}
                  	if (compareData>0)
                  	{
                      		setMarkerNum(iTOCIndexAtMarker[FindIdx]);
                      		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] != "")
                  	{
                    		seekindex = i;
                    		break;
                  	}
              	}
             	//load current Event1 file
              	if (seekindex == -1)
                    	seekindex = iHintEvent1[lbound];

              	sFile1 = sEvent1AtMarker[seekindex];
                sPreEvent1File = sFile1;
              	if (sFile1 != "")
              	{
                  	CurrAniData = sAniAtE1[seekindex];
                  	if (CurrAniData != "0")
                  	{
                      		SetiAniIdx(CurrAniData);
                  	}
                  	if ((iTemplateIdx<8) || (iTemplateIdx==10))
                        {
                            	bNoEvent1 = false;
                            	this.document.all.item("pptmain").src = sFile1;
                            	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 (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 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;
	      	}
	      	SetMPPosition(sTimeArray[j]);
	      	PositionChange(parseInt(sTimeArray[j]), 1);
         } catch (e)
         {
              ShowError("ChangeMarker exception", e);
         }
    }
    function RandomPositionChange(newposition)
    {
         try
         {
              //get the correct time interval when doing random access
         	var mapposition = 0;
	        for (var i=0;i<iTotalMarkers;i++)
                {
               		if (newposition >= parseInt(sTimeArray[i]))
                        	mapposition = parseInt(sTimeArray[i]);
		  	if (newposition < parseInt(sTimeArray[i])) break;
              	}
              	PositionChange(mapposition, 1);
         } catch (e)
         {
              	ShowError("RandomPositionChange exception", e)  ;
         }
    }   
    
    function LoadEvent2(bstrparam)
    {
         try
         {
         	bNoEvent2 = true;         	
    	        var nowIdx = parseInt(bstrparam);
                if (sEvent2AtMarker[nowIdx-1] != sPreEvent2File)
                {
                        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
         {
         	bNoEvent1 = true;         	
    	        var nowIdx = parseInt(bstrparam);
                if (sEvent1AtMarker[nowIdx-1] != sPreEvent1File)
                {
                    	if (sEvent1AtMarker[nowIdx-1] != "")
                        	this.document.all.item("pptmain").src = sEvent1AtMarker[nowIdx-1];
                    	else
                        	this.document.all.item("pptmain").src = sEvent1AtMarker[iHintEvent1[nowIdx-1]];
                }
                sPreEvent1File = sEvent1AtMarker[nowIdx-1];
                               
                 
         } catch (e)
         {
                ShowError("LoadEvreent1 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 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 = this.pptmain;
                      //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 = this.pptmain;
		      //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 = this.pptmain;
                      //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 = this.pptmain;
                      //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 = this.pptmain;
                      //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;                                
                //bugCode : SAR1225-0026
                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;
                            TemplateIdx = 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 (!((SCRIPTDATA.readyState=="loaded") && (LINKLAYOUT.readyState=="complete")))
		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 (!((SCRIPTDATA.readyState=="loaded") && (LINKLAYOUT.readyState=="complete")) && (igPlayState == iStatePlay))
		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;	
		}
	
		mpbgpic.src= buttonImage[6].src;
	}catch (e)
	{
		ShowError ("InitImg exception", e);
	}	
}

/*
function LoadButnImg()
{
	try
	{
		for (var i=0;i<=4;i++)
		{	
			tempImage = new Array();	
			for (var j=1;j<=3;j++)
			{
			    	if (i==0) 
			    	{
					tempImage[j-1] = new Image();
					tempImage[j-1].src =  sImagestr[i] + "_" + eval(j+3) + ".gif";
				}else
				{		
					tempImage[j-1] = new Image();
					tempImage[j-1].src =  sImagestr[i] + "_" + j + ".gif";
				}		
			}	
			buttonImage[i] = tempImage;
		}
	}catch (e)
	{
		ShowError ("LoadButnImg exception", e);
	}	
}
*/

function LoadButnImg()
{
	try
	{	
		for (var i=0;i<=4;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
				{		
					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
					
				}		
			}				
			buttonImage[i] = tempImage;
		}
		// add logo image
		TImage1 = new Image();
		
		if(typeof(document.styleSheets[0].rules[16].style.pic) != "undefined")
		{
		 data = document.styleSheets[0].rules[16].style.pic;
		 temp = data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
		 if(temp == "")
		  temp = Styles[TemplateOrder] + "/logo.gif";
		 else
		  temp = Styles[TemplateOrder] + "/" + temp;
		}
		else
		 temp = Styles[TemplateOrder] + "/logo.gif";
		 
		TImage1.src = temp;				
		buttonImage[5] = TImage1;
		
		//add mpbg image
		TImage2 = new Image();
		
		if(typeof(document.styleSheets[0].rules[9].style.pic) != "undefined")
		{
		 data = document.styleSheets[0].rules[9].style.pic;
		 temp = data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
		 if(temp == "")
		  temp = Styles[TemplateOrder] + "/mpbg.gif";
		 else
		  temp = Styles[TemplateOrder] + "/" + temp;
		}
		else
		 temp = Styles[TemplateOrder] + "/mpbg.gif";
		 
		TImage2.src = temp;		
		buttonImage[6] = 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;
		}else
		{
			factor = 1;
	  		iorigH = document.body.offsetHeight;
		}
		RefreshUI();
	}catch (e)
	{
		ShowError ("adaptsize exception", e);
	}	
}

function HideComponents()
{
	contents.style.visibility = "hidden";
	mppic.style.visibility = "hidden";
	//timer.style.visibility = "hidden";
	mpbgpic.style.visibility = "hidden";
	playerplaypausepic.style.visibility = "hidden";
	playerpreviouspic.style.visibility = "hidden";
	playerstoppic.style.visibility = "hidden";
	playernextpic.style.visibility = "hidden";
}

function ShowComponents()
{
	try
	{
		if (bHasVideo != 0)
		{
			if (!parent.bPreview)
			{
				if ((igPlayState != iStateStop) && (igPlayState != iStateEnd) && (igPlayState != iStateReady))
				{
					if ((igPlayState == iStatePlay) || (igPlayState == iStatePause))
					{
						contents.style.visibility = "visible";
						mppic.style.visibility = "hidden";
					}else
					{
						contents.style.visibility = "hidden";
						if (bHasVideo == 1) mppic.style.visibility = "visible";
					}	
				}	
				else 
				{
					if (igPlayState == iStateEnd) igPlayState = iStatePause;
					contents.style.visibility = "hidden";
					if (bHasVideo == 1) mppic.style.visibility = "visible";
				}
			}else 
			{
				if (contents.style.posWidth!=0) contents.style.visibility = "visible";
			}
		}else
		{
			//contents.style.visibility = "hidden";
			//if (contents.style.posWidth!=0) mppic.style.visibility = "visible";	
			//else mppic.style.visibility = "hidden";	
			if(document.styleSheets[0].rules[1].style.visibility == "hidden")
                         mppic.style.visibility = "hidden";
                        else{		 
                         contents.style.visibility = "hidden";
                         mppic.style.visibility = "visible";	
                        }

		}	
		mpbgpic.style.visibility = "visible";
		if (bMP7 || (parent.bPreview)) 
		{
			if (contents.style.posWidth!=0) timer.style.visibility = "visible";
		}
		playerplaypausepic.style.visibility = "visible";
		playerpreviouspic.style.visibility = "visible";
		playerstoppic.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 != "")
					{
						SAbgpic = data.substring(data.indexOf("(")+1, data.lastIndexOf(")"));
						SAcontainerpic.src = Styles[TemplateOrder] + "/" + SAbgpic;
						SAcontainerpic.style.posWidth = SAcontainer.style.posWidth;
						SAcontainerpic.style.posHeight = SAcontainer.style.posHeight;
						SAcontainer.style.visibility = "visible";
					}else SAcontainerpic.style.visibility = "hidden";
				}else SAcontainerpic.style.visibility = "hidden";
		
			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;						
			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;
			}	
			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;

			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;			
			//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 (typeof(iSAVer) == "undefined") 
			//	logoDIV.style.visibility = "hidden";
			//else 
			//{
				if (document.styleSheets[0].rules[16].style.visibility == "visible")
				{					
					//logopic.src = Styles[TemplateOrder] + "/logo.gif";					
					logopic.src = buttonImage[5].src
					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;
			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;
			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;
			
			//resizeBG();
			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;	                
	                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;
           ////////////////////////////////////////////////////////////////////////////////////////////////////////////	                
			
			
			if (parent.bPreview) 
				UpdateFramePos();

			ShowComponents();
		//}
	}catch (e)
	{
		ShowError ("SideBG exception", e);
	}		
}

function initTOC(iPos)
{
	pauseTimer(1);
	printpage(iPos, 1);
	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;
			var CurrentDir = MoviePath.substring(iURLStartPos, MoviePath.lastIndexOf("/"));
			MoviePath = CurrentDir + "/index.asx";
			MoviePath = unescape(MoviePath);			
			if (bMP7) MediaPlayer1.URL = MoviePath;			
			else MediaPlayer1.FileName = MoviePath;
			initTOC(parent.iSAStart);
		}
	}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=\"none\"><\/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 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:
					if ((currPlayState != iStateStop) || (imgobj.id != "playerstoppic")) 
						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 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;
			}
		}
	}catch (e)
	{
		ShowError ("butnRollOver exception", e);
	}		
}

function PlayFun(){
	try
	{	
	   if(typeof(document.styleSheets[0].rules[1]) == "object") //Fix-Bug : SAR031007-0009
           {	
		startTimer();				
		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";
		}/*else if (bHasVideo == 0)
		{
			mppic.style.visibility = "hidden";
			contents.style.visibility = "visible";
			mppic.src = "Def_A_only.jpg";
		}*/			
		igPlayState = iStatePlay;	
		
		
		if (bLoadCSSFileOK)	{
		 playerplaypausepic.src = buttonImage[0][2].src;
		 playerstoppic.src = buttonImage[4][0].src;
		}
	   }
	   else
	   {
	   	setTimeout("PlayFun()",50);
	   }
	}catch (e)
	{
		ShowError ("PlayFun exception", e);
	}		
}

function PauseFun()
{
	try
	{
		pauseTimer(0);
		
		if (bLoadCSSFileOK){	
		 playerplaypausepic.src = buttonImage[1][1].src;
		 playerstoppic.src = buttonImage[4][0].src;	
		}
	}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;
				}	
			}	
		}	
	}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 (bLoadCSSFileOK){
		 playerstoppic.src = buttonImage[4][2].src;
		 playerplaypausepic.src = buttonImage[1][0].src;
		}
         }
         else
         {
	   	setTimeout("StopFun()",50);
	 }		
	}catch (e)
	{
		ShowError ("StopFun exception", e);
	}		
}

function mpstop()
{
	try
	{
		igPlayState = iStateStop;
		igMarkerNum = 1;
		inowFileNum = 0 ;
		bReset = true;	
		
		bPreviewVideoEnd = false;
		if (bScormInit) bScormInit = false;	
		if (typeof(MediaPlayer1)=="object")
		{	
			if (bMP7) 
			{
				MediaPlayer1.controls.stop();
				document.MediaPlayer1.controls.currentMarker = 1;
				goto(0);
			}else 
			{
				if (MediaPlayer1.PlayState != 0) document.MediaPlayer1.Stop();
				document.MediaPlayer1.CurrentPosition = 0;
				goto(0);
			}
		
			pauseTimer(1);	
			StopFun();	
		}
	}catch (e)
	{
		ShowError ("mpstop exception", e);
	}		
}

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);
	}		
}

//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;
		data1 = TimerText(iPos / 1000);
		if (!parent.bPreview) timer.innerText=data1;	
	}catch (e)
	{
		ShowError ("SetMPPosition 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 postponePlaying()
{
	try
	{
		clearTimeout(ipostponeTimer);
		if (MediaPlayer1.playState != iStateBuffer)
		{
			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();		
					}	
				}
			}else	
			{
				if (igPlayState == iStatePlay)
				{
					if (bMP7) MediaPlayer1.controls.play();
					else MediaPlayer1.play();	 		
					PlayFun();
					bReset = false;
					startTimer();			
				}	
			}
		}
	}catch (e)
	{
		ShowError ("continuePlaying exception", e);
	}	
}

function startTimer()
{
	try
	{
		if (!parent.bPreview) 		
		{
			//start from 00:00			
			if(impTimerID==-1)
			{
				updateTimer();
				impTimerID=setInterval("updateTimer()",1000);
			}
		}
	}catch (e)
	{
		ShowError ("startTimer exception", e);
	}	
}

function updateTimer()
{
	try
	{
		g_nCurrentClock=getPresentTime();
		data1 = TimerText(g_nCurrentClock);
		if (!parent.bPreview) timer.innerText=data1;
	}catch (e)
	{
		ShowError ("updateTimer exception", e);
	}	
}

function TimerText(timeValue)
{
	try
	{
	        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[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;
		}	        			    			
		
		head = head + " \\ " + sTotalTime;
		return head;
	}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 pauseTimer(mode)
{
	try
	{
		if(impTimerID!=-1)
		{
			clearInterval(impTimerID);
			impTimerID=-1;		
		}
		if (mode==1) data1 = TimerText(0);
		else data1 = TimerText(getPresentTime());
		if (!parent.bPreview) timer.innerText=data1;
	}catch (e)
	{
		ShowError ("goto exception(pauseTimer)", e);
	}	
}

function goto(iPos)
{
	try
	{
		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 (bMP7) document.MediaPlayer1.controls.currentPosition = iPos  / 1000;
		else document.MediaPlayer1.CurrentPosition = iPos  / 1000;
		//document.applet1.PositionChange(iPos, 1);
		if (!bScormInit) parent.iSAStart = iPos;
		PositionChange(iPos, 1);
		data1 = TimerText(iPos / 1000);
		if (!parent.bPreview) timer.innerText=data1;	
	}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 (ipreTemplateOrder != TemplateOrder)
		{
			HideComponents();
			ipreTemplateOrder = TemplateOrder;
			
			LINKFONT.href = Styles[TemplateOrder] + "/fontsize.css";
			/*
			if (bIfDownload) 
			{
				//SCRIPTDATA.src = Styles[TemplateOrder] + "/layout_d.js";
			
				LINKLAYOUT.href = Styles[TemplateOrder] + "/layout_d.css";
			
			}else
			{	
				//SCRIPTDATA.src = Styles[TemplateOrder] + "/layout.js";
			*/
				LINKLAYOUT.href = Styles[TemplateOrder] + "/layout.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))
		{
			LoadButnImg();
			InitImg();		
			adaptsize();
			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";
			}				
			if (sbgpic == " ") 
			{
				textspace.header.style.color = textOff;
				textspace.emaillink.style.color = textOff;
				textspace.copyright.style.color = textOff;
				textspace.description.style.color = textOff;
				timer.style.color = textOn;
			}				
			if (iTOCNumbers>0) HighLight(ititleMarker);	

			if (bFirst) continuePlaying();
			bLoadCSSFileOK = true;
		}else iLoadCSSTimerID=setTimeout("linkCSSFile()",50);
	}catch (e)
	{
		ShowError ("linkCSSFile exception", e);
	}			
}

function IncreaseFileNum()
{
	inowFileNum ++;
}

function setFileNum(argu)
{
	iFileNum = 2;
}
	
function HighLight(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 = 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;
				nEvent1Top=pptmainDIV.style.posTop + nWindowTop;
				nEvent1Width=pptmainDIV.style.posWidth;
				nEvent1Height=pptmainDIV.style.posHeight;
			}
			
			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;
			}
					
			document.MediaPlayer1.SetFramePosition(nVideoLeft, nVideoTop, nVideoWidth, nVideoHeight, nTocLeft, nTocTop, nTocWidth, nTocHeight, nEvent1Left, nEvent1Top, nEvent1Width, nEvent1Height, nEvent2Left, nEvent2Top, nEvent2Width, nEvent2Height,  0, 0, 0, 0);
		}
         } catch (e)
         {
            	ShowError("UpdateFramePos exception", e) ;
         }			
}

function ShowContextMenu()
{
	try
	{
		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;			
			data1 = TimerText(parent.iSAStart / 1000);
			if (!parent.bPreview) timer.innerText=data1;	
		}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());
	
}
 