
StartTime=50;
EndTime=200;
ClipDuration=EndTime-StartTime;//µ¿¿µ»óÀÌ Å¬¸³ÀÏ°æ¿ìÀÇ µ¿¿µ»ó ±æÀÌ
ClipDurationString=GetTimeStr(ClipDuration);//µ¿¿µ»óÀÌ Å¬¸³ÀÏ°æ¿ìÀÇ µ¿¿µ»ó ±æÀÌ(display¿ë)



///////////////////////////////////////////////////////////////////////////////////////
//------------------------ ¹Ìµð¾î ÇÃ·¹ÀÌ¾î Á¦¾îºÎ -----------------------------------//
///////////////////////////////////////////////////////////////////////////////////////

function btstop(){
	document.MPlayer.controls.stop();
			
}                    
function btplay(){   
	if (StartTime!=0&&document.MPlayer.playState != 2){
		document.MPlayer.controls.currentPosition=StartTime;
	}
	document.MPlayer.controls.play();
	

}
function btpause(){
	document.MPlayer.controls.pause();

}
function btForward(){
   	document.MPlayer.controls.FastForward();
	

}
function btReverse(){
	document.MPlayer.controls.FastReverse();	
}
function btFullScreen(){
	if (document.MPlayer.playState == 3) {
		document.MPlayer.fullScreen = 'true';
		FullScreenMode='yes';
	}
}
///////////////////////////////////////////////////////////////////////////////////////



///////////////////////////////////////////////////////////////////////////////////////
//--------------------- ¹Ìµð¾î ÇÃ·¹ÀÌ¾î »ç¿îµå Á¶Á¤¹Ù Á¦¾îºÎ ------------------------//
///////////////////////////////////////////////////////////////////////////////////////


//------------------------------ ¸¶¿ì½º ÀÌº¥Æ® ÇÚµé -----------------------------------


//¸¶¿ì½º°¡ Á¶Á¤¹Ù À§¿¡¼­ ¿òÁ÷ÀÏ¶§
function Smousemove( event ){ 
	if (Ex_Soundvalue==0){
		if (event.x<SoundSize+SProgressPos + SMousePos && event.x>SProgressPos + SMousePos){
			setsoundBar (event.x-SMousePos);
		}
	}
}
//»ç¿îµå Á¶Á¤¹Ù À§¿¡¼­ ¸¶¿ì½º¹öÆ°À» ´Ù¿î ÇßÀ»¶§
function Smousedown( event ){
	setsoundBar (event.x-SMousePos);
	Ex_Soundvalue=0;
}
//ÁøÇà¹Ù À§¿¡¼­ ¸¶¿ì½º ¹öÆ°À» UPÇßÀ»¶§ 
function Smouseup(event)
{
	if (Ex_Soundvalue==0){
		if(ViewerMode==1){
			document.MPlayer.settings.volume=(event.x -SProgressPos - SMousePos)/SoundSize*100;
		}else{
			document.MPlayer.settings.volume=(event.x -(SProgressPos+(document.body.offsetWidth-(simpleWidth-borderWidth))/2) - SMousePos)/SoundSize*100;
		}
		Ex_Soundvalue=1;
	}
}

//-------------------------------------------------------------------------------------

//------------------------------------  ±âÅ¸ ÇÔ¼ö  ------------------------------------
//»ç¿îµå Á¶Á¤¹Ù¸¦ ÇØ´ç À§Ä¡¿¡ ³õÀÌ°Ô ÇÑ´Ù.
function setsoundBar(pos){
	soundBar.style.left=pos;
}
///////////////////////////////////////////////////////////////////////////////////////
 

///////////////////////////////////////////////////////////////////////////////////////
//------------------------ ¹Ìµð¾î ÇÃ·¹ÀÌ¾î ÁøÇà¹Ù Á¦¾îºÎ ----------------------------//
///////////////////////////////////////////////////////////////////////////////////////



//------------------------------ ¸¶¿ì½º ÀÌº¥Æ® ÇÚµé -----------------------------------
//¸¶¿ì½º°¡ ÁøÇà¹Ù À§¿¡¼­ ¿òÁ÷ÀÏ¶§
function mousemove( event ){ 
	if (Ex_value==0){
		if (document.MPlayer.playState == 2 || document.MPlayer.playState == 3 || document.MPlayer.playState == 4 || document.MPlayer.playState == 5 || document.MPlayer.playState == 6){
			if (event.x<ProgressSize + ProgressPos + MousePos  && event.x > ProgressPos+ MousePos){
				setProgressBar ( event.x - MousePos);
			}
		}
	}
}

//ÁøÇà¹Ù À§¿¡¼­ ¸¶¿ì½º¹öÆ°À» ´Ù¿î ÇßÀ»¶§
function mousedown( event ){
	if (document.MPlayer.playState == 2 || document.MPlayer.playState == 3 || document.MPlayer.playState == 4 || document.MPlayer.playState == 5 || document.MPlayer.playState == 6){
		setProgressBar ( event.x - MousePos);
		Ex_value=0;
	}
}
//ÁøÇà¹Ù À§¿¡¼­ ¸¶¿ì½º ¹öÆ°À» UPÇßÀ»¶§ 
function mouseup( event )
{
	if (Ex_value==0){
		
		if(checkPosition(barToPosition(event.x-ProgressPos-MousePos))){
			if (document.MPlayer.playState == 2 || document.MPlayer.playState == 3 || document.MPlayer.playState == 4 || document.MPlayer.playState == 5 || document.MPlayer.playState == 6){
				Movemedia(event.x- ProgressPos - MousePos);
			}
		}
		Ex_value=1;
	}
}
//-------------------------------------------------------------------------------------

 
//------------------------------------  ±âÅ¸ ÇÔ¼ö  ------------------------------------
//Å¸ÀÌ¸Ó¿¡ ÀÇÇØ ÀÏÁ¤ÇÑ °£°ÝÀ¸·Î È£Ãâ µÈ´Ù.
function StartTimer(){
	var pos,TotPos;
	if (document.MPlayer.playState == 2 || document.MPlayer.playState == 3 || document.MPlayer.playState == 4 || document.MPlayer.playState == 5 || document.MPlayer.playState == 6){
			TotPos = document.MPlayer.currentMedia.duration;

		pos = document.MPlayer.controls.currentPosition;
		if(checkPosition(document.MPlayer.controls.currentPosition)){
			if (Ex_value==1){
				MoveProgress(pos,TotPos);
			}
			if (document.MPlayer.playState != 1){

				document.form1.PPlayTime.value = GetTimeStr(document.MPlayer.controls.currentPosition);

			}else{
				document.form1.PPlayTime.value = "00:00:00";
			}
		}
	}	
}
//µ¿¿µ»ó ÇÃ·¹ÀÌ À§Ä¡¿¡ ¸Â°Ô ÁøÇà¹Ù¸¦ À§Ä¡ ½ÃÅ²´Ù.
function MoveProgress(pos,TotPos){
	var ProPosition;
	
	ProPosition=parseInt(ProgressSize*(pos/TotPos))+ProgressPos;
	setProgressBar(ProPosition);
}
//ÁøÇà¹Ù À§Ä¡¸¦ ¹Þ¾Æ¼­ ±× À§Ä¡¿¡ ÇØ´çÇÏ´Â µ¿¿µ»óÀÌ ³ª¿Àµµ·Ï ÇÑ´Ù.
function Movemedia(x){
	
	document.MPlayer.controls.currentPosition=barToPosition(x);
}
//ÁøÇà¹ÙÀÇ À§Ä¡¸¦ ¹Þ¾Æ¼­ µ¿¿µ»óÀÇ À§Ä¡¸¦ ¸®ÅÏÇÑ´Ù.
function barToPosition(x){
	
	return parseInt(document.MPlayer.currentMedia.duration*(x/ProgressSize));
}
//ÁøÇà¹Ù¸¦ ÇØ´ç À§Ä¡¿¡ ³õÀÌ°Ô ÇÑ´Ù.
function setProgressBar(pos){
	progressbar.style.left=pos;
}
//ÁøÇà¹ÙÀÇ À§Ä¡°¡ À¯È¿ÇÑ ¹üÀ§ ÀÎÁö¸¦ Ã¼Å© ÇÑ´Ù.
function checkPosition(pos){
	var T_F=true;
	if(pos<StartTime){
		document.MPlayer.controls.currentPosition=StartTime;
		MoveProgress(StartTime,document.MPlayer.currentMedia.duration);
		T_F=false;
		btstop();
	}
	if(pos>EndTime+0.5){
		btpause();
		document.MPlayer.controls.currentPosition=EndTime;
		MoveProgress(EndTime,document.MPlayer.currentMedia.duration);
		T_F=false;
		
	} 
	return T_F		
}
//ÃÊ¸¦ ½Ã°£À¸·Î Ç¥½Ã
function GetTimeStr(Isec){
	var SSecond=0,Smin=0,Shour=0,TimeString="";
	SSecond=Isec%60;
	Isec=(Isec-SSecond)/60;
	Smin=Isec%60;
	Shour=(Isec-Smin)/60;
	
	if (Shour < 10){
		TimeString = "0" + Shour + ":";
	}else{
		TimeString = Shour + ":";
	}
	if (Smin < 10){
		TimeString = TimeString+"0" + Smin + ":";
	}else{
		TimeString = TimeString+Smin + ":";
	}
	if (SSecond < 10){
		TimeString = TimeString+"0" + SSecond ;
	}else{
		TimeString = TimeString+SSecond;
	}	
	return TimeString.substring(0,8);
}
///////////////////////////////////////////////////////////////////////////////////////


function speed1(a){
	document.MPlayer.settings.rate=a;
}
function checkSize( source ) 
{
	var name = source.name;
	
	if ( source.value.length == 2 ) 
	{	    
		if ( name == "hour" ) {	
			 document.form1.min.focus();
		} else document.form1.sec.focus();
	}
}
function GoToPlay(){	
	if (document.MPlayer.PlayState == 3){
				
		var strMin,strSec,strSecond;
	
			strHour = document.form1.hour.value;
			strMin = document.form1.min.value;
			strSec = document.form1.sec.value;

	
		if (strHour == ""){
			alert("½Ã°£°ªÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			document.form1.hour.focus;

		}
		if (strMin == ""){
			alert("ºÐ°ªÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			document.form1.min.focus;

		}
		if (strSec == ""){
			alert("ÃÊ°ªÀ» ÀÔ·ÂÇØÁÖ¼¼¿ä.");
			document.form1.sec.focus;

		}				
	
		if (strMin != "" && strSec != ""){			
			strHour = parseInt( strHour ) * 60 * 60
			strSecond = parseInt(parseInt(strMin)*60 + parseInt(strSec));
			strSecond = strSecond + strHour;
			
			
			document.MPlayer.controls.currentPosition = strSecond;
		}
	} 			
}
///////////////////////////////////////////////////////////////////////////////////////


//ÆäÀÌÁö°¡ ¿ÏÀüÈ÷ ·Îµù µÈ´ÙÀ½ºÎÅÍ ½ÃÀÛ
function loadend(){
	btplay();
	window.focus();
	window.onresize=reSize_Check;
	window.resizeTo(defaultWidth,defaultHeight);
	media_width=document.all("MPlayer").style.width;//¹Ìµð¾î Ã¢ÀÇ ÃÊ±â Å©±â
	media_height=document.all("MPlayer").style.height;	//¹Ìµð¾î Ã¢ÀÇ ÃÊ±â Å©±â
	divWidth=document.all("DIVPlayer").style.width;//·¹ÀÌ¾î ±âº» ³ÐÀÌ
	divHight=document.all("DIVPlayer").style.height;//·¹ÀÌ¾î ±âº» ³ôÀÌ 
	MousePos=MousePos+diffLeft;
	SMousePos=SMousePos+diffLeft;
}
///////////////////////////////////////////////////////////////////////////////////////
//------------------------------- È­¸é»çÀÌÁî Á¦¾îºÎ----------------------------------//
///////////////////////////////////////////////////////////////////////////////////////

//±âº»È­¸é º¸±â
function SimpleDefault(){
	window.resizeTo(simpleWidth,simpleHeight);
}
//È­¸é ÀÛ°Ô º¸±â
function SimpleViewer(){
	if(ViewerMode==1){
		window.resizeTo(simpleWidth,simpleHeight);
		
		ViewerMode=0;	
		document.all("simpleView").style.display = "none";
		document.all("defaultView").style.display = "";
		//document.all("simpledefault").style.display = "";
		media_size();
		document.all("DIVPlayer").style.width=divWidth
		document.all("DIVPlayer").style.height=divHight	
		MousePos=MousePos-diffLeft;
		SMousePos=SMousePos-diffLeft;
	}
}
function DefaultViewer(){
	if(ViewerMode==0){
		window.resizeTo(defaultWidth,defaultHeight);//±âº»Ã¢ Å©±â·Î º¯°æ
		ViewerMode=1;	
		document.all("simpleView").style.display = "";
		document.all("defaultView").style.display = "none";	
		//document.all("simpledefault").style.display = "none";
		media_size();//¹Ìµð¾î ÇÃ·¹ÀÌ¾îÃ¢ ±âº» Å©±â·Î ¼³Á¤
		document.all("DIVPlayer").style.width=divWidth;//·¹ÀÌ¾î »çÀÌÁî ±âº» Å©¸®·Î ¼³Á¤
		document.all("DIVPlayer").style.height=divHight;//·¹ÀÌ¾î »çÀÌÁî ±âº» Å©¸®·Î ¼³Á¤		
		MousePos=MousePos+diffLeft;//¸¶¿ì½º Æ÷ÀÎÅÍ¿Í ÁøÇà¹Ù Æ÷ÀÎÅÍÀÇ ¿ÀÂ÷°ª Àç ¼³Á¤
		SMousePos=SMousePos+diffLeft;//¸¶¿ì½º Æ÷ÀÎÅÍ¿Í »ç¿îµå¹Ù Æ÷ÀÎÅÍÀÇ ¿ÀÂ÷°ª Àç ¼³Á¤
		// ÁøÇà¹Ù,»ç¿îµå¹Ù,ÁøÇà¹Ù ÄÁÆ®·Ñ, »ç¿îµå¹Ù ÄÁÆ®·Ñ µéÀÇ À§Ä¡ Àç¼³Á¤
		document.all("progressbar").style.top=progressbarTop;
		document.all("box").style.top=boxTop;
		document.all("soundBar").style.top=soundBarTop;
		document.all("soundBox").style.top=soundBoxTop;	
		document.all("soundBar").style.left=SProgressPos+(document.MPlayer.settings.volume*(SoundSize/100));
		document.all("soundBox").style.left=SProgressPos;			
		/////////////////////////////////////////////////
	}
}
function media_size(){
		document.all("MPlayer").style.width=media_width;
		document.all("MPlayer").style.height=media_height;
}
function reSize_Check(){
	if (ViewerMode==1){
		window.resizeTo(defaultWidth,defaultHeight);
		ProgressSize=initProgressSize;
		
	}else{

		if(document.body.offsetWidth>=simpleWidth-borderWidth&&document.body.offsetHeight>=simpleHeight-borderHeight){
			document.all("MPlayer").style.width=document.body.offsetWidth-spWidth;//ÇÃ·¹ÀÌ¾îÀÇ Å©±â ¼³Á¤ - ¿©¹é Á¦°ÅÇÑ Å©±â
			document.all("MPlayer").style.height=document.body.offsetHeight-spHeight;//ÇÃ·¹ÀÌ¾îÀÇ Å©±â ¼³Á¤ - ¿©¹é Á¦°ÅÇÑ Å©±â
			document.all("progressbar").style.top=document.body.offsetHeight-ProgressButtonBottom;//ÁøÇà¹Ù À§Ä¡ÀÇ Àç¼³Á¤
			document.all("box").style.top=document.body.offsetHeight-ProgressButtonBottom;//ÁøÇà¹Ù ÄÁÆ®·Ñ À§Ä¡ Àç¼³Á¤
			document.all("box").style.width=document.body.offsetWidth;//ÁøÇà¹Ù ÄÁÆ®·ÑÀÇ ³ÐÀÌ Àç¼³Á¤
			document.all("soundBar").style.top=document.body.offsetHeight-SProgressButtonBottom;//»ç¿îµå¹Ù À§Ä¡ Àç¼³Á¤
			//»ç¿îµå¹Ù À§Ä¡ Àç¼³Á¤ : ÃÖÃÊÀ§Ä¡+(Ã¢»çÀÌÁîÀÇ º¯È­·®)/2 + ÇöÀç º¼·ýÅ©±â¿¡ ´ëÇÑ À§Ä¡°ª      
			document.all("soundBar").style.left=(SProgressPos+(document.body.offsetWidth-(simpleWidth-borderWidth))/2)+(document.MPlayer.settings.volume*(SoundSize/100));
			document.all("soundBox").style.top=document.body.offsetHeight-SProgressButtonBottom;//»ç¿îµå¹Ù ÄÁÆ®·Ñ À§Ä¡ Àç¼³Á¤
			document.all("soundBox").style.left=(SProgressPos+(document.body.offsetWidth-(simpleWidth-borderWidth))/2);//»ç¿îµå¹Ù ÄÁÆ®·Ñ À§Ä¡ Àç¼³Á¤

		}else{
			window.resizeTo(simpleWidth,simpleHeight);
		}	
			document.all("DIVPlayer").style.width=document.body.offsetWidth-divoffset;//·¹ÀÌ¾î Å©±âÀÇ Àç¼³Á¤
			document.all("DIVPlayer").style.height=document.body.offsetHeight-divoffset;//·¹ÀÌ¾î Å©±âÀÇ Àç¼³Á¤
			ProgressSize=document.body.offsetWidth-10;//¿Ö 10À» »©Áà¾ß ¸Â´ÂÁö ³ªµÎ ¸ð¸§......(¾çÂÊ ÀÌ¹ÌÁö6 + divoffset ???)
			
		window.scrollTo(diffLeft,diffTop);
	}
}

///////////////////////////////////////////////////////////////////////////////////////oncontextmenu="return false" onselectstart="return false" ondragstart="return false" 

