// ExoBUD¢â MP(II) v4.2 plus [wmp-obj v7.1/v9][Á¤½Ä¹öÀü]
// Copyright (Pe) 1999-2002 ExoBUD¢â , Design by Jinwoong, Yu. 
// Home  : http://exobud.nayana.org
// E-Mail : exobud@hanmail.net
// ICQ      : 96138429

// º» ¼Ò½ºÀÇ »ó±â ³»¿ëÀ» º¯°æÇÏ°Å³ª »èÁ¦ÇÏ½Ã¸é ¾ÈµË´Ï´Ù.
// º» ¼Ò½º´Â ¹«·á½ºÅ©¸³Æ®ÀÌ¸ç, »ç¿ëÀÚ ÀÓÀ¸·Î ¼öÁ¤.¹èÆ÷ ÇÏ½Ç ¼ö ¾ø½À´Ï´Ù.
// º» ¼Ò½º·Î ÀÎÇØ ¹ß»ýµÈ ¹®Á¦¿¡ ´ëÇØ¼­´Â ¾î¶°ÇÑ Ã¥ÀÓµµ ÁöÁö¾Ê½À´Ï´Ù.
// º» ¼Ò½º¸¦ µ¿ÀÇ¾øÀÌ ÆÄÀÏÀÇ ÀÏºÎ ¶Ç´Â ÀüÃ¼¸¦ ¹èÆ÷ÇÏ°Å³ª »ó¾÷ÀûÀÎ ¿ëµµ·Î »ç¿ëÇÒ¼ö ¾ø½À´Ï´Ù.

var objMmInfo = null;
var intMmCnt = 0;
var intSelMmCnt=0;
var intActMmCnt=0;
var cActIdx=0;
var cActTit="nAnT";
var strMmInfo ="ExoBUD Media Infomation";

var blnfpl=false;
var blnEnabled= false;
var blnEOT=false;
var arrSelMm=null;
var arrActMm=null;
var intExobudStat =0;
var tidTLab=null;
var tidErr=null;
var tidMsg=null;
var intErrCnt=0;
var blnRept=false;

// ¹ÂÁ÷ºñµð¿À Àç»ý±â·Î »ç¿ëÇÏ°Å³ª ¿¬¼ÓÀç»ýÀ» ±ÝÁöÇÒ¶§´Â blnAutoProcÀ» false·Î ¼³Á¤ÇÏ¼¼¿ä
var blnAutoProc = true;

// blnElaps´Â trueÀÏ¶§ Àç»ýÁøÇà½Ã°£(ELaps)À», falseÀÏ¶§ ³²Àº½Ã°£(Laps)À» ÃÊ±â¸ðµå·Î ÁöÁ¤ÇÕ´Ï´Ù
var blnElaps=true; 

// intDelay´Â ÀÚµ¿À¸·Î ´ÙÀ½ ¹Ìµð¾î¸¦ Àç»ýÇÒ °æ¿ìÀÇ Àç»ý Áö¿¬(À¯°Ý) ½Ã°£À» ¼³Á¤ÇÕ´Ï´Ù.(¹Ð¸®ÃÊ.msec)
// 100¹Ð¸®ÃÊ(0.1ÃÊ) ÀÌ»ó  Áö¿¬½Ã°£À» ¼³Á¤ÇÏ±â ¹Ù¶ó¸ç, ±âº» ¼³Á¤Àº 500¹Ð¸®ÃÊ(0.5ÃÊ)ÀÔ´Ï´Ù.
var intDelay =500;

//wmpInit()Àº wmp-obj v7.x¿¡ ´ëÇÑ ±âº» È¯°æÀ» ¼³Á¤ÇÕ´Ï´Ù
function wmpInit(){
 var wmps = Exobud.settings;
 var wmpc = Exobud.ClosedCaption;

 wmps.autoStart=true;
 wmps.balance=0;
 wmps.enableErrorDialogs=false;
 wmps.invokeURLs = false;
 wmps.mute=false;
 wmps.playCount=1;
 wmps.rate=1;
 wmps.volume = 100;
 if(blnUseSmi){wmpc.captioningID="capText"; capText.style.display="";}
// var wmpEnabled=Exobud.settings.enabled;
}

// mkMmPath()´Â Array¿¡ ÀÔ·ÂµÉ Multi-object¸¦ »ý¼ºÇÕ´Ï´Ù.
function mkMmPath(u, t, f,s){
 this.mmUrl = u;
 this.mmTit =t;
 this.mmDur =0;
 this.selMm=f;
 this.actMm=f;
 if(blnUseSmi){this.mmSmi=s;}
}

//mkList()´Â Multi-object array¸¦ »ý¼ºÇÕ´Ï´Ù.
function mkList(u,t,s,f){
 var cu=u;
 var ct=t;
 var cs=s;
 var cf=f;
 var idx=0;

 if(objMmInfo == null){ objMmInfo=new Array(); idx=0;}
 else{ idx=objMmInfo.length;}
 if(u=="" || u==null){cu="mms://";}
 if(t=="" || t==null){ct="nAnT";}
 if(f=="f" || f=="F"){cf="f";}
 else{cf="t"; intSelMmCnt=intSelMmCnt+1;}

 if(blnUseSmi){ objMmInfo[idx]=new mkMmPath(cu,ct,cf,cs);}
 else{objMmInfo[idx]=new mkMmPath(cu,ct,cf);}

 intActMmCnt=intSelMmCnt;
 intMmCnt=objMmInfo.length;
}

// mkSel()´Â Selected media array¹× Activated media array¸¦ »ý¼ºÇÕ´Ï´Ù.
function mkSel(){
 arrSelMm=null;
 intSelMmCnt=0;
 var selidx = 0;

 if(intMmCnt<=0){intExobudStat=1; blnEnabled=false; return;} //¹Ìµð¾î¸®½ºÆ®°ø¹é¿¡·¯

 arrSelMm=new Array();
 for(var i=0; i<intMmCnt;i++){
	if(objMmInfo[i].selMm =="t"){arrSelMm[selidx]=i;selidx=selidx+1;}
 }
 intSelMmCnt=arrSelMm.length;

 if(intSelMmCnt<=0){blnEnabled=false;intExobudStat=2; arrSelMm=null; return;}
 else{blnEnabled=true; mkAct();}
}

// mkAct()´Â Activated media array¸¦ »ý¼ºÇÕ´Ï´Ù.
function mkAct(){
 arrActMm=null;
 intActMmCnt=0;
 var selidx=0;
 var actidx=0;

 if(blnEnabled){
	arrActMm=new Array();
	for(var i=0; i<intSelMmCnt;i++){
		selidx=arrSelMm[i];
		if(objMmInfo[selidx].actMm=="t"){arrActMm[actidx]=selidx; actidx=actidx+1;}
	}
	intActMmCnt=arrActMm.length;
 }
 else{return;}
 if(intActMmCnt<=0){blnEOT=true;arrActMm=null;}
 else{blnEOT=false;}
}


//chkAllSel()Àº ¸ðµç ItemÀ» Selected ItemÀ¸·Î ÀüÈ¯ÇÕ´Ï´Ù.
function chkAllSel(){
 for(var i=0; i<intMmCnt; i++){
   objMmInfo[i].selMm="t";
   objMmInfo[i].actMm="t";
 }
 mkSel();
}

//chkAllDesel()Àº ¸ðµç ItemÀ» Deselected ItemÀ¸·Î ÀüÈ¯ÇÕ´Ï´Ù.
function chkAllDesel(){
 for(var i=0; i<intMmCnt; i++){
   objMmInfo[i].selMm="f";
   objMmInfo[i].actMm="f";
 }
 mkSel();
}

// chkItemSel()Àº Selected media ¸¦ ¼³Á¤ ¶Ç´Â ÇØÁ¦ÇÕ´Ï´Ù.
function chkItemSel(idx){
 if(objMmInfo[idx].selMm =="t"){objMmInfo[idx].selMm="f";objMmInfo[idx].actMm="f";}
 else{objMmInfo[idx].selMm="t";objMmInfo[idx].actMm="t";}
 mkSel();
}

// chkItemAct()´Â ActivatedµÈ media¸¦ µ¿°áÇÕ´Ï´Ù.
function chkItemAct(idx){
 objMmInfo[idx].actMm="f";
 mkAct();
}

// mkSelAct()´Â Selected Media¸¦ activated media·Î ¼³Á¤ÇÕ´Ï´Ù.
function mkSelAct(){
 var idx=0;
 for(var i=0; i<intSelMmCnt; i++){
	idx=arrSelMm[i];
	objMmInfo[idx].actMm="t";
 }
 mkAct();
}

// initExobud()´Â ExoBUD MP(II) ½ºÅ©¸³Æ®¸¦ ÃÊ±âÈ­ ÇÕ´Ï´Ù.
function initExobud(){
 wmpInit();
 mkSel();
 blnfpl=false;

 if(!blnShowTitle){document.exobudform.disp1.style.display="none";}
 if(!blnShowTime){document.exobudform.disp2.style.display="none";}

 if(!blnShowVolCtrl) {
	document.exobudform.vmute.style.display = "none";
	document.exobudform.vdn.style.display = "none";
	document.exobudform.vup.style.display = "none";
 }
 if(!blnShowPlist){document.exobudform.plist.style.display = "none";}

 if(blnRept){document.exobudform.rept.style.background=btnOnColor;}
 else{document.exobudform.rept.style.background=btnOffColor;}

 if(blnRndPlay){document.exobudform.pmode.value="R";document.exobudform.pmode.style.background=btnOnColor;}
 else{document.exobudform.pmode.value="S";document.exobudform.pmode.style.background=btnOffColor;}
 showTLab();
 document.exobudform.disp1.value="Stopped..";
 if(blnStatusBar){window.status=('Stopped..');}
 if(blnAutoStart){startExobud();}

}

// startExobud()´Â ±âº»ÀûÀÎ ¹Ìµð¾î Àç»ýÀ» ½ÃÀÛÇÕ´Ï´Ù.
function startExobud(){
 var wmps= Exobud.playState;
 if(wmps==2){Exobud.controls.play(); return;} //ÀÏ½ÃÁ¤ÁöÀÏ¶§
 if(wmps==3){return;} // Àç»ýÁßÀÏ¶§ 

 blnfpl=false;
 if(!blnEnabled){waitMsg();return;}
 if(blnEOT){mkSelAct();}
 if(intErrCnt>0){intErrCnt=0;tidErr=setTimeout('retryPlay(),1000');return;}
 if(blnRndPlay){rndPlay();}
 else{cActIdx=arrActMm[0]; selMmPlay(cActIdx);}
}


// selMmPlay()´Â Selected - Activated MediumÀ» Àç»ýÇÕ´Ï´Ù.
function selMmPlay(idx){
 clearTimeout(tidErr);
 cActIdx=idx;
 var trknum=idx+1;
 var ctit =objMmInfo[idx].mmTit;
 if(ctit=="nAnT"){ctit="Title ¹× Author ÃßÃ´Áß..."}
 if(blnUseSmi){Exobud.ClosedCaption.SAMIFileName = objMmInfo[idx].mmSmi;}
 Exobud.URL = objMmInfo[idx].mmUrl;
 cActTit="T"+ trknum + ". " + ctit;
 document.exobudform.disp1.value = cActTit;
 if(blnStatusBar){window.status=(cActTit);}
 chkItemAct(cActIdx); 
}

// wmpPlay()´Â wmp-obj v7.x Àç»ýÇÔ¼öÀÔ´Ï´Ù.
function wmpPlay(){Exobud.controls.play();}

// wmpStop()Àº Àç»ýÀ» ÁßÁöÇÏ°í ´ë±â»óÅÂ·Î ÀüÈ¯ÇÕ´Ï´Ù.
function wmpStop(){
 intErrCnt=0;
 clearTimeout(tidErr);
 clearInterval(tidTLab);
 document.exobudform.stopt.style.background=btnOnColor; 
 document.exobudform.pauzt.style.background=btnOffColor;
 imgChange("scope",0);
 showTLab();
 mkSelAct();
 Exobud.controls.stop();
 Exobud.close();
 document.exobudform.disp1.value="´ë±âÁßÀÔ´Ï´Ù";
 if(blnStatusBar){window.status=(' ');return true;}
}

// wmpPause()´Â wmp-obj v7.x ÀÏ½ÃÁ¤Áö ÇÔ¼öÀÔ´Ï´Ù.
function wmpPause(){Exobud.controls.pause();}

// wmpPP()´Â ÀÏ½ÃÁ¤Áö.Àç»ýÀ» À§ÇÑ Åä±ÛÇÔ¼öÀÔ´Ï´Ù.
function wmpPP(){
	var wmps = Exobud.playState;
	var wmpc=Exobud.controls;
	clearInterval(tidTLab);
	clearTimeout(tidMsg);
	if (wmps == 2) {wmpc.play();}
	if (wmps == 3) {wmpc.pause();document.exobudform.disp2.value="Pause"; tidMsg=setTimeout('rtnTLab()',1500);}
	return;
}


//rndPlay()´Â ¹«ÀÛÀ§Àç»ý(Random play)¸¦ ½ÃÀÛÇÕ´Ï´Ù.
function rndPlay(){
 if(!blnEnabled){waitMsg();return;}
 intErrCnt=0;
 var idx=Math.floor(Math.random() * intActMmCnt);
 cActIdx= arrActMm[idx];
 selMmPlay(cActIdx);
}

//playAuto()´Â Activated Media¸¦ ÀÚµ¿À¸·Î ±³Ã¼ÇÕ´Ï´Ù.
//½ºÅ©¸³Æ® »ó´ÜÀÇ blnAutoProc ¼³Á¤¿¡µû¶ó ÀÚµ¿¿¬¼ÓÀç»ý ¼³Á¤À» º¯°æÇÒ ¼ö ÀÖ½À´Ï´Ù.
function playAuto(){
 var wmps=Exobud.playState;
 if(wmps>1 && wmps<10){return;}

 if(blnRept){ selMmPlay(cActIdx); return;}
 if(!blnAutoProc){wmpStop();return;}
 if(blnfpl){wmpStop(); return;} //wmpStop()´ë½Å playNext()·Î ¼³Á¤ÇÏ¸é ´Ù¸¥ Àç»ý ·ÎÁ÷ °¡´É
 if(!blnEnabled){wmpStop();return;}
 if(blnEOT){ if(blnLoopTrk){startExobud();}
	   else{wmpStop();}
 }
 else{  if(blnRndPlay){rndPlay();}
	else{cActIdx= arrActMm[0]; selMmPlay(cActIdx);}
 }
}

// Play a user selected element from the playlist
function selPlPlay(idx){
 blnfpl=true;
 intErrCnt=0;
 selMmPlay(idx);
}


// playPrev()´Â activated medium ÀÌÀüÀÇ Selected MediumÀ» ¹ÝÈ¯ÇÕ´Ï´Ù.
function playPrev(){
 var wmps= Exobud.playState;
 if(wmps==2 || wmps==3){Exobud.controls.stop();}
 blnfpl=false;
 if(!blnEnabled){waitMsg();return;}
 if(blnEOT){mkSelAct();}

 intErrCnt=0;
 if(blnRndPlay){rndPlay();}
 else{	var idx=cActIdx;
 	var blnFind=false;
	for(var i=0;i<intSelMmCnt;i++){if(cActIdx==arrSelMm[i]){idx=i-1; blnFind=true;}}
	if(!blnFind){startExobud();return;}
	if(idx<0){idx=intSelMmCnt-1;cActIdx=arrSelMm[idx];}
	else{cActIdx=arrSelMm[idx];}
	selMmPlay(cActIdx);
 }
}

// playNext()´Â activated medium ÀÌÈÄÀÇ Selected MediumÀ» ¹ÝÈ¯ÇÕ´Ï´Ù.
function playNext(){
 var wmps= Exobud.playState;
 if(wmps==2 || wmps==3){Exobud.controls.stop();}
 blnfpl=false;
 if(!blnEnabled){waitMsg();return;}
 if(blnEOT){mkSelAct();}

 intErrCnt=0;
 if(blnRndPlay){rndPlay();}
 else{	var idx=cActIdx;
 	var blnFind=false;
	for(var i=0;i<intSelMmCnt;i++){	if(cActIdx==arrSelMm[i]){idx=i+1; blnFind=true;}}
	if(!blnFind){startExobud();return;}
	if(idx>=intSelMmCnt){idx=0;cActIdx=arrSelMm[idx];}
	else{cActIdx=arrSelMm[idx];}
	selMmPlay(cActIdx);
 }
}


//retryPlay()´Â Activated medium¿¡ ´ëÇÑ Àç»ýÀ» ½ÃµµÇÕ´Ï´Ù.
function retryPlay(){
  selMmPlay(cActIdx);
}


//chkRept()´Â Activated mediumÀÇ ¹Ýº¹ Àç»ý ¿©ºÎ¸¦ º¯°æÇÕ´Ï´Ù.
function chkRept(){
 var wmps=Exobud.playState;
 if(wmps == 3){clearInterval(tidTLab);}
 if(blnRept){blnRept=false;document.exobudform.rept.style.background=btnOffColor;document.exobudform.disp2.value="Norm. Play";}
 else{blnRept=true;document.exobudform.rept.style.background=btnOnColor;document.exobudform.disp2.value="Repeat";}
 tidMsg= setTimeout('rtnTLab()',1000);
}


// chgPMode()´Â Àç»ý¸ðµå(Sequential / Random)¸¦ º¯°æÇÕ´Ï´Ù.
function chgPMode(){
 var wmps=Exobud.playState;
 if(wmps == 3){clearInterval(tidTLab);}
 if(blnRndPlay){blnRndPlay=false;document.exobudform.pmode.value="S";document.exobudform.pmode.style.background=btnOffColor;document.exobudform.disp2.value="SEQ. Play";}
 else{blnRndPlay=true;document.exobudform.pmode.value="R";document.exobudform.pmode.style.background=btnOnColor;document.exobudform.disp2.value="RND. Play";}
 tidMsg=setTimeout('rtnTLab()',1000); 
}


function evtOSChg(f){
// 0(Undefined) 8(MediaChanging) 9(MediaLocating) 10(MediaConnecting) 11(MediaLoading) 
// 12(MediaOpening) 13(MediaOpen) 20(MediaWaiting) 21(OpeningUnknownURL)

 if(f==8){capText.innerHTML="ExoBUD¢â MP(II) Captioning(SMI)";}
 if(f==13){
	var strTitle = Exobud.currentMedia.getItemInfo("title");
	if(strTitle.length <=0){strTitle = "(Á¦¸ñ) ¾Ë¼ö¾øÀ½"}
	var strAuthor = Exobud.currentMedia.getItemInfo("Author");
	if(strAuthor.length <=0){strAuthor = "(°¡¼ö) ¾Ë¼ö¾øÀ½"}
	var strCopy = Exobud.currentMedia.getItemInfo("Copyright");
	if(strCopy.length <=0){strCopy = "(ÀúÀÛ±ÇÀÚ) ¾Ë¼ö¾øÀ½"}
	var strType = Exobud.currentMedia.getItemInfo("MediaType");
	var strBitrate = Exobud.currentMedia.getItemInfo("Bitrate");
	var strDur=Exobud.currentMedia.durationString;
	var strUrl =Exobud.currentMedia.sourceURL;
	var trknum=cActIdx+1;
	var ctit = objMmInfo[cActIdx].mmTit;
	if(ctit=="nAnT"){ objMmInfo[cActIdx].mmTit = strAuthor + " - " + strTitle;
		ctit=strAuthor + " - " + strTitle;
		cActTit="T"+ trknum + ". " +ctit;
		document.exobudform.disp1.value = cActTit;
	}

	strMmInfo= "Media (Title) : " + strTitle + "\n\n"
	strMmInfo= strMmInfo + "Media (Author) : " + strAuthor + "\n\n"
	strMmInfo= strMmInfo + "Media (URL) : " +strUrl + "\n\n"
	strMmInfo= strMmInfo + "Media (Copyright) : " + strCopy +"\n\n" 
	strMmInfo= strMmInfo + "Media (Type) : " +strType +"\n\n"
	strMmInfo= strMmInfo + "Media (Duration) : " +strDur +"\n\n"
	strMmInfo= strMmInfo + "Media (Bitrate) : " + parseInt(strBitrate/1000) + " KBit/sec \n\n"
	strMmInfo= strMmInfo + " (C)Copyright ExoBUD¢â MPlayer(II) 1999-2003  \n";
	if(blnShowMmInfo){alert(strMmInfo);}
 }
}


function evtPSChg(f){
// 0(Undefined) 1(Stopped) 2 (Paused) 3(Playing) 4(ScanFowrd) 5(ScanReverse)
// 6(Buffering) 7(Waitng) 8(MediaEnded) 9(Transitioning) 10(Redy)

 switch(f){
	case 1:
		evtStop();
		break;
	case 2:
		evtPause();
		break;
	case 3:
		evtPlay();
		break;
	case 8:
		setTimeout('playAuto()', intDelay);
		break;
 }
}


//evtWmpBuff()´Â ¹öÆÛ¸µÀÇ ½ÃÀÛ°ú ³¡À» Ã¼Å©ÇÕ´Ï´Ù..
function evtWmpBuff(f){
	 if(f){ document.exobudform.disp2.value = "Buffering";
		var msg="(¹öÆÛ¸µÁß) " + cActTit;
		document.exobudform.disp1.value = msg;
		if(blnStatusBar){window.status=(msg);}
	}
	else{ document.exobudform.disp1.value = cActTit; showTLab();}
}


//evtWmpError()´Â ¿À·ù¹ß»ý½Ã Ã³¸®ÇÒ ÇÁ·Î½ÃÀú¸¦ Á¤ÀÇÇÕ´Ï´Ù.
function evtWmpError(){
 intErrCnt=intErrCnt+1;
 Exobud.Error.clearErrorQueue();
 document.exobudform.pauzt.style.background=btnOffColor;
 document.exobudform.playt.style.background=btnOffColor;
 imgChange("scope",0);
 if(intErrCnt<=3){
	document.exobudform.disp2.value="Àç½Ãµµ("+intErrCnt+")";
	var msg="(Àç»ý½Ãµµ:" + intErrCnt +") " +cActTit;
	document.exobudform.disp1.value="<Àç»ý¿À·ù> " +cActTit;
	if(blnStatusBar){window.status=(msg);}
	tidErr=setTimeout('retryPlay()',1000);
 }
 else{	clearTimeout(tidErr);
	intErrCnt=0;showTLab();
	var msg="»õ·Î¿î ¹Ìµð¾î Àç»ýÀ» ÁØºñÇÕ´Ï´Ù";
	if(blnStatusBar){window.status=(msg);}	
	setTimeout('playAuto()',1000);}
}

function evtStop(){
 clearTimeout(tidErr);
 clearInterval(tidTLab);
 showTLab();
 intErrCnt=0;
 document.exobudform.pauzt.style.background=btnOffColor;
 document.exobudform.playt.style.background=btnOffColor;
 document.exobudform.stopt.style.background=btnOnColor;
 imgChange("scope",0);
 document.exobudform.disp1.value="´ë±âÁßÀÔ´Ï´Ù";
 if(blnStatusBar){window.status=(' ');return true;}
}

function evtPause(){
 document.exobudform.pauzt.style.background=btnOnColor;
 document.exobudform.playt.style.background=btnOffColor;
 document.exobudform.stopt.style.background=btnOffColor;
 imgChange("scope",0);
 clearInterval(tidTLab);
 showTLab();
}

function evtPlay(){
 document.exobudform.pauzt.style.background=btnOffColor;
 document.exobudform.playt.style.background=btnOnColor;
 document.exobudform.stopt.style.background=btnOffColor;
 imgChange("scope",1);
 tidTLab=setInterval('showTLab()',1000);
}

//showTLab()Àº Å¸ÀÌ¸Ó Å×ÀÌºíÀ» Ç¥½ÃÇÕ´Ï´Ù.
function showTLab(){
 var ps=Exobud.playState;
 if(ps==2 || ps==3){
	var cp=Exobud.controls.currentPosition
	var cps=Exobud.controls.currentPositionString
	var dur=Exobud.currentMedia.duration;
	var durs=Exobud.currentMedia.durationString;
	if(blnElaps){document.exobudform.disp2.value= cps+" | "+durs;
		var msg=cActTit + " ("+cps+" | "+durs+ ")";
		if(ps==2){msg="(ÀÏ½ÃÁ¤Áö) "+ msg;}
		if(blnStatusBar){window.status=(msg);return true;}
	}
	else{var laps= dur-cp; 
		var strLaps=wmpTime(laps);
		document.exobudform.disp2.value= strLaps + " | "+durs;
		var msg= cActTit + " (" + strLaps + " | "+durs + ")";
		if(ps==2){msg="(ÀÏ½ÃÁ¤Áö) "+ msg;}
		if(blnStatusBar){window.status=(msg);return true;}
	}

 }
 else{document.exobudform.disp2.value="00:00 | 00:00";}
}

// chgTimeFmt()´Â Å¸ÀÌ¸Ó Å×ÀÌºíÀÇ Ç¥½ÃÇü½ÄÀ» º¯°æÇÕ´Ï´Ù.
function chgTimeFmt(){
 var wmps=Exobud.playState;
 if(wmps == 3){clearInterval(tidTLab);}
 if(blnElaps){blnElaps=false; document.exobudform.disp2.value="Laps";}
 else{blnElaps=true;document.exobudform.disp2.value="ELaps";}
 tidMsg=setTimeout('rtnTLab()',1000); 
}

// rtnTLab()Àº Å¸ÀÌ¸Ó Å×ÀÌºíÀ» º¹¿øÇÕ´Ï´Ù.
function rtnTLab(){
clearTimeout(tidMsg);
var wmps=Exobud.playState;
if(wmps == 3){tidTLab=setInterval('showTLab()',1000);}
else{showTLab();}
}

function wmpTime(dur){
	var hh, min, sec, timeLabel
	hh = Math.floor(dur/3600);
	min = Math.floor(dur / 60)%60;
	sec = Math.floor(dur % 60);
	if (isNaN(min)){ return "00:00"; }
	if (isNaN(hh) || hh==0){timeLabel="";}
	else{
		if(hh >9){timeLabel = hh.toString()+":";}
		else{timeLabel="0"+hh.toString() +":";}
	}
  	if ( min > 9 ){  timeLabel = timeLabel + min.toString() + ":"; }
	else {timeLabel = timeLabel + "0" +min.toString() + ":";}
	if ( sec > 9 ){timeLabel = timeLabel + sec.toString();}
	else{timeLabel = timeLabel + "0" + sec.toString();}
	return timeLabel;
}


// wmpVolUp(),wmpVolDn(), wmpMute() ´Â º¼·ý°ú °ü·ÃµÈ ÇÔ¼öÀÔ´Ï´Ù.
// vmax´Â ÃÖ´ëº¼·ý(100), vminÀº ÃÖ¼Òº¼·ý(0), vdep´Â º¼·ýÁ¶Àý °£°ÝÀ¸·Î 5~10 Á¤µµ°¡ Àû´çÇÕ´Ï´Ù.
// wmp 6.4 °³Ã¼¿Í´Â ´Þ¸® v7.x °³Ã¼ÀÇ º¼·ý ¹üÀ§´Â (ÃÖ¼Ò 0 ~ ÃÖ´ë 100)À¸·Î %´ÜÀ§·Î ÀÎ½ÄÇØµµ µË´Ï´Ù.

var vmax = 100;
var vmin=0;
var vdep = 10;

function wmpVolUp(){ // ExoBUD¢â MP(II) Volume Up 
	var wmps=Exobud.playState;
	if(wmps == 3){clearInterval(tidTLab);}
	var ps = Exobud.settings;
	if(ps.mute){ps.mute = false; document.exobudform.disp2.value="Speach";document.exobudform.vmute.style.background=btnOffColor;}
	else{
		if (ps.volume >= (vmax-vdep)) {ps.volume = vmax;}
		else {  ps.volume = ps.volume + vdep;}
		document.exobudform.disp2.value="Vol. " + ps.volume +"%";
	}
	tidMsg=setTimeout('rtnTLab()',1000);
}

function wmpVolDn(){ // ExoBUD¢â MP(II) Volume Down 
	var wmps=Exobud.playState;
	if(wmps == 3){clearInterval(tidTLab);}
	var ps = Exobud.settings;
	if(ps.mute){ps.mute = false;document.exobudform.disp2.value="Speach";document.exobudform.vmute.style.background=btnOffColor;}
	else{
		if (ps.volume <= vdep){ ps.volume = vmin;}
		else{ps.volume = ps.volume - vdep;}
		document.exobudform.disp2.value="Vol. " + ps.volume +"%";
	}
	tidMsg=setTimeout('rtnTLab()',1000);
}


function wmpMute(){ // ExoBUD¢â MP(II) Mute 
	var wmps=Exobud.playState;
	if(wmps == 3){clearInterval(tidTLab);}
	var ps = Exobud.settings;
	if(!ps.mute){ps.mute = true;document.exobudform.disp2.value="Mute On"; document.exobudform.vmute.style.background=btnOnColor;}
	else {ps.mute = false;document.exobudform.disp2.value="Mute Off";document.exobudform.vmute.style.background=btnOffColor;}
	tidMsg=setTimeout('rtnTLab()',1000);
}

function waitMsg(){
 capText.innerHTML="ExoBUD¢â MP(II) Captioning(SMI)";
 if(intExobudStat ==1){document.exobudform.disp1.value="ÇÃ·¹ÀÌ¸®½ºÆ®¿¡ µî·ÏµÈ ¹Ìµð¾î°¡ ¾ø½À´Ï´Ù";}
 if(intExobudStat ==2){document.exobudform.disp1.value="ÇÃ·¹ÀÌ¸®½ºÆ®¿¡¼­ ¹Ìµð¾î¸¦ ¼±ÅÃÇÏ¼¼¿ä";}
 if(blnStatusBar){
	if(intExobudStat ==1){window.status=('ÇÃ·¹ÀÌ¸®½ºÆ®¿¡ µî·ÏµÈ ¹Ìµð¾î°¡ ¾ø½À´Ï´Ù');return true;}
	if(intExobudStat ==2){window.status=('ÇÃ·¹ÀÌ¸®½ºÆ®¿¡¼­ ¹Ìµð¾î¸¦ ¼±ÅÃÇÏ¼¼¿ä'); return true;}
 }
}


function openPlist() { // ExoBUD¢â MP(II) List Popping Up
	window.open("playlist.html" , "mplist", " width=280 , height=400 ,scrollbars=auto , resizable=no , copyhistory=no");
}


// chkWmpState()´Â wmp°³Ã¼ÀÇ Àç»ý »óÅÂ Áï, playState °ªÀ» ¹ÝÈ¯ÇÕ´Ï´Ù.
// chkWmpOState() ´Â wmp °³Ã¼ÀÇ ¹Ìµð¾îÀÇ °³¹æ(open)»óÅÂ Áï, openState °ªÀ» ¹ÝÈ¯ÇÕ´Ï´Ù.

function chkWmpState(){
// 0(Undefined) 1(Stopped) 2 (Paused) 3(Playing) 4(ScanFowrd) 5(ScanReverse)
// 6(Buffering) 7(Waitng) 8(MediaEnded) 9(Transitioning) 10(Redy)
 return Exobud.playState;
}

function chkWmpOState(){
// 0(Undefined) 8(MediaChanging) 9(MediaLocating) 10(MediaConnecting) 11(MediaLoading) 
// 12(MediaOpening) 13(MediaOpen) 20(MediaWaiting) 21(OpeningUnknownURL)
 return Exobud.openState;
}

function chkOnline(){
// true(Network Connected) false(Network Lost)
return Exobud.isOnline;
}

function vizExobud(){
//Exobud.launchURL("http://exobud.nayana.org");
  window.open("http://exobud.nayana.org","vizExobud");
}
