var countChk;
countChk = "N";

// ============================================
//  ÃÊ±âÈ­ ÇÔ¼ö 
// ============================================
function Init() {
		
}
///// [¡Ú¡Ú¡Ú AD ¡Ú¡Ú¡Ú] À¯·á»ç¿ëÀÚ´Â ±¤°í ¾Èº¸¿©ÁÖ°í ·Î±×ÀÎ ¾ÈÇÑ »ç¿ëÀÚ³ª ¹«·á»ç¿ëÀÚ¸¸ ±¤°í º¸¿©ÁÖ±â
// ============================================
//  ÇÃ·¹ÀÌ¾î ½Ã°£À» Ç¥½ÃÇÏ´Â ÇÔ¼ö  
// ============================================
function playTimeDuration() {

	var durTime = document.Player.currentMedia.durationString;
	var curTime = document.Player.controls.currentPositionString;

	if (durTime == "00:01")
	{
		State_Time.innerHTML = "BUFFERING";
	}
	else {
		State_Time.innerHTML = curTime;
	}

///// [¡Ú¡Ú¡Ú AD ¡Ú¡Ú¡Ú] ºñ·Î±×ÀÎ½Ã ¹Ì¸®º¸±â¸¦ ¾ø¿¥

	if (document.Player.controls.currentPosition>10 && countChk == "N"){
			countChk = 'Y';
			PlayCounting.location.href = "playCounting.asp?currentMediaInfo=" + document.Player.currentMedia.getItemInfo("copyright");
	}
}

///// [¡Ú¡Ú¡Ú AD ¡Ú¡Ú¡Ú] ºñ·Î±×ÀÎ½Ã 1ºÐ º¸±â ¾ø¿¥
/////½Ç½Ã°£ ¹æ¼ÛÀÇ °æ¿ì´Â À¯·á ÄÁÅÙÃ÷ ÀÔ´Ï´Ù.
function playTimeDurationOnAir() {
	if (document.OnAirPlayer.currentPosition>10 && countChk == "N"){
			countChk = 'Y';
			if(nowOnAir == "MNET") {
				PlayCounting.location.href = "playCounting.asp?currentMediaInfo=16422|PRG";
			} else {
				PlayCounting.location.href = "playCounting.asp?currentMediaInfo=16424|PRG";
			}
	}
/*	if (document.OnAirPlayer.currentPosition>60){
		if(loginFrm.loginChk.value=="N"){
			location.href="http://www.mnet.com/MaxMP3/Html/MPlayer/goLoginPage2.php?Target=" + TargetFrm.Target.value;
		}else if (loginFrm.ExR.value=="ADSEfseGeSAfEAGN"){
			location.href="http://www.mnet.com/MaxMP3/Html/MPlayer/goLoginPage.php?Target=" + TargetFrm.Target.value;
		}
	}
*/
}
// ============================================
//  ÀÌÀü/´ÙÀ½°î¿¡ ´ëÇÑ Á¤º¸¸¦ Ç¥½ÃÇÏ´Â ÇÔ¼ö 
// ============================================
function setStateInfoStr(infoStr,timeRef) {
var bitrate;
		if (document.Player.currentMedia.getItemInfo("abstract")=="300")	{ //bitrate == "300";
				curVodInfoStr.innerHTML = "<nobr  style='width:170;overflow:hidden'>" + infoStr + "</nobr>"; 
		}else{
				curVodInfoStr.innerHTML = "<nobr  style='width:350;overflow:hidden'>" + infoStr + "</nobr>"; 
		}
		
	//}
}

// ============================================
// À½¼Ò°Å °ü·Ã ÇÔ¼ö 
// ============================================
function isMute() {
	if (document.Player.Settings.mute) {
		document.mute.src="img/speaker_on.gif";
	} else {
		document.mute.src="img/speaker_off.gif";
	}
	document.Player.Settings.mute = !document.Player.Settings.mute;
}

// ============================================
//  º¼·ý ½½¶óÀÌµå ¹Ù °ü·Ã ÇÔ¼öµé
// ============================================
var VolumeThumbStartPosition = 32;
var VolumeThumbPositionLength = 42;
var oldOnMouseMove = null;
var oldOnMouseUp = null;

function moveVolumePosition() {

	if(document.Player.playstate==3) {
		volumeThumbCurPos = VolumeThumb.style.posLeft;
		CurMousePos = event.clientX;

		oldOnMouseMove = document.onmousemove;
		document.onmousemove = dragVolumePosition;
	
		oldOnMouseUp = document.onmouseup;
		document.onmouseup = setVolumePosition;
	}
	return false;
}

function dragVolumePosition() {

	var tmpValue = volumeThumbCurPos + event.clientX - CurMousePos;

	if (tmpValue < VolumeThumbStartPosition) { tmpValue = VolumeThumbStartPosition; }
	if (tmpValue > (VolumeThumbStartPosition + VolumeThumbPositionLength - 1)) { tmpValue = VolumeThumbStartPosition + VolumeThumbPositionLength - 1; }

	VolumeThumb.style.posLeft = tmpValue;
	slideGage.style.width =  tmpValue - VolumeThumbStartPosition;

	document.Player.Settings.Volume = Math.round(((VolumeThumb.style.posLeft - VolumeThumbStartPosition ) / VolumeThumbPositionLength) * 100);

	return false;
}

function setVolumePosition() {

	document.onmouseup = oldOnMouseUp;
	document.onmousemove = oldOnMouseMove;
	VolumeThumb.style.posLeft = Math.round(VolumeThumbPositionLength * (document.Player.Settings.volume / 100) + VolumeThumbStartPosition);
	slideGage.style.width = Math.round(VolumeThumbPositionLength * (document.Player.Settings.volume / 100) );
}

// ============================================
//  ÇÃ·¹ÀÌ ½½¶óÀÌµå ¹Ù °ü·Ã ÇÔ¼öµé
// ============================================
function movePlayPosition() {
	if (nowStatus =="ONAIR" ){
		playThumbCurPos = trackPosition.style.posLeft;
		CurMousePos = event.clientX;

		oldOnMouseMove = document.onmousemove;
		document.onmousemove = dragPlayPosition;

		oldOnMouseUp = document.onmouseup;
		document.onmouseup = setPlayPosition;

		return false;
	}
}

function dragPlayPosition() {

	var tmpValue = playThumbCurPos + event.clientX - CurMousePos;

	isSetPlayPosition = true;
	isPlayThumeDrag = true;

	if (tmpValue < var_startpoint) { tmpValue = var_startpoint; }
	if (tmpValue > (var_startpoint + var_length - 1)) { tmpValue = var_startpoint + var_length - 1; }

	trackPosition.style.posLeft = tmpValue;

	return false;
}


function setPlayPosition() {

	document.onmouseup = oldOnMouseUp;
	document.onmousemove = oldOnMouseMove;

	if (isSetPlayPosition) {
		isSetPlayPosition = false;
		isPlayThumeDrag = false;
		var curPosValue = document.Player.currentMedia.duration * ((trackPosition.style.posLeft - var_startpoint + 1) / var_length);
		
		document.Player.controls.currentPosition = curPosValue;
	}

	return false;
}

function CurPlayPosition(var_length) {

	if(document.Player.controls != null){
		if (!isSetPlayPosition) {
			var tmpValue = var_startpoint + (var_length * (document.Player.controls.currentPosition / document.Player.currentMedia.duration));
			if (tmpValue) {
				if (isPlayThumeDrag == false) {
					trackPosition.style.posLeft = tmpValue;
				}
			}
		}
	}
}