var playerWnd;
var chkMode = 1;

function PlayChk() { 

	var songno = ""; 
	var aElement = document.all("song_id[]"); 
	
	if(aElement == null) { 

		alert('곡을 선택해주세요'); 
		
		} else { 
		
		for(var i=0; i<aElement.length; i++) { 
			
			var ele = aElement[i]; 
			
			if(ele.checked == true && ele.value != '') { 
				
				//songno = ele.value + "," + songno; 
				songno += ele.value + ","; 
				
				} else { 
					
					ele.checked = false; 
					
					} 
					
				} 
				
			} 
			
		 rushPlayer(songno);
		
} 



function GetPlayList() 
{
	var songList = '';

	for(xx = 0; xx < document.frmSongList.elements.length; xx++){

		var musicCode = document.frmSongList.elements[xx];
		
		if(musicCode.name == 'musicCode'){

			if(musicCode.checked == true){ 
				songList += musicCode.value + ',';
			}
				
		}
	}
	
	return songList;
}


function CheckAll(chkVal)
{
	for(xx = 0; xx < document.frmSongList.elements.length; xx++)
		if(document.frmSongList.elements[xx].name == 'musicCode' && document.frmSongList.elements[xx].disabled == false) 
			document.frmSongList.elements[xx].checked = chkVal;
}


function ChgAllChkBox()
{
	for(xx = 0; xx < document.frmSongList.elements.length; xx++)
		if(document.frmSongList.elements[xx].name == 'musicCode') 
			if(document.frmSongList.elements[xx].checked == true)
				document.frmSongList.elements[xx].checked = false;
			else	document.frmSongList.elements[xx].checked = true;
}


function OnOffChkBox()
{
	chkMode *= (-1);

	if(chkMode < 0)
		CheckAll(true);
	else if(chkMode > 0)
		CheckAll(false);
}


function rushPlayer(musicCode)
{
	
	var wndLeft;
	var wndTop;
	var oldList;
	
	if(musicCode != "")
	{
		if(musicCode.substring(musicCode.length - 1, musicCode.length) != ",")
			musicCode += ",";
			
		var myExpVer = navigator.appVersion.split(";");
		myExpVer = myExpVer[1].replace(" ","");

		
		
		if(myExpVer == "MSIE 4.0" || myExpVer == "MSIE 5.0")
		{
			//메시지는 하루만 나온다.
			if(getCookie("showMsg") != "true")
			{
				setCookie("showMsg", "true", 1);
			
				if(confirm("Internet Explorer 6.0 이전버젼은 정상적으로 작동되지 않을 수 있습니다. \r\n6.0으로 업그레이드하시겠습니까?"));
					//document.location = "http://music.inlive.co.kr/help/ie6setup.exe";
			}
		}
		
		if(myExpVer != "MSIE 4.0")
		{
			setCookie("letMeFirst", 0, 1);
	//		if(!playerWnd)setCookie("mpBoxMode", "", 1);
			
			if(getCookie("mpBoxMode") == "playing")

					//top.MpBoxList.listView.ReSetSongList(); //전체리스트 삭제
					setCookie("mCode", musicCode, 1);



			else
			{

				wndLeft = getCookie("ck_wndLeft");
				wndTop = getCookie("ck_wndTop");
				oldList = getCookie("listLog");
				
				//ccap 수정
				var CntoldList = oldList.split(","); 
				var NowPlayNo = CntoldList.length;
				//ccap 수정	
						
				musicCode = oldList + musicCode;
				
				if(!wndLeft || wndLeft == "")
				{
					wndLeft = 100;
					setCookie("ck_wndLeft", wndLeft, 10);
				}
				
				if(!wndTop || wndTop == "") 
				{
					wndTop = 100;
					setCookie("ck_wndTop", wndTop, 10);
				}
					
				setCookie("mCode", "", 1);
				playerWnd = window.open("/_player/player.html?&npn=" + NowPlayNo + "&musicCode=" + musicCode,"rushPlayer","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,left=" + wndLeft + ",top=" + wndTop + ",width=400,height=432");
				playerWnd.focus();			
			}
		}
	}
	else
		alert('선택한 곡이 없습니다. 듣고싶은 음악을 선택하세요.');
}

function rushPlayer2(musicCode)
{
	var wndLeft;
	var wndTop;
	var oldList;
	
	if(musicCode != "")
	{
		if(musicCode.substring(musicCode.length - 1, musicCode.length) != ",")
			musicCode += ",";
			
		var myExpVer = navigator.appVersion.split(";");
		myExpVer = myExpVer[1].replace(" ","");
		
		
		if(myExpVer == "MSIE 4.0" || myExpVer == "MSIE 5.0")
		{
			//메시지는 하루만 나온다.
			if(getCookie("showMsg") != "true")
			{
				setCookie("showMsg", "true", 1);
			
				if(confirm("Internet Explorer 6.0 이전버젼은 정상적으로 작동되지 않을 수 있습니다. \r\n6.0으로 업그레이드하시겠습니까?"))
					document.location = "http://music.inlive.co.kr/help/ie6setup.exe";
			}
		}
		
		if(myExpVer != "MSIE 4.0")
		{
			if(getCookie("mpBoxMode") == "playing")
			{
				setCookie("mCode", musicCode, 1);
				setCookie("letMeFirst", parseInt(getCookie("letMeFirst")) + 1, 1);
			}
			else
			{
				var mcList;
				
				wndLeft = getCookie("ck_wndLeft");
				wndTop = getCookie("ck_wndTop");
				oldList = getCookie("listLog");
				musicCode = oldList + musicCode;
				
				//ccap 수정
				var CntoldList = oldList.split(","); 
				var NowPlayNo = CntoldList.length;
				//ccap 수정	
				
				mcList = musicCode.split(",");
				setCookie("letMeFirst", mcList.length - 1, 1);
				
				if(!wndLeft || wndLeft == "")
				{
					wndLeft = 100;
					setCookie("ck_wndLeft", wndLeft, 10);
				}
				
				if(!wndTop || wndTop == "") 
				{
					wndTop = 100;
					setCookie("ck_wndTop", wndTop, 10);
				}
					
				setCookie("mCode", "", 1);
				playerWnd = window.open("/_player/player.html?npn=" + NowPlayNo + "&musicCode=" + musicCode,"rushPlayer","toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=no,left=" + wndLeft + ",top=" + wndTop + ",width=300,height=134");
				playerWnd.focus();			
			}
		}
	}
	else
		alert('선택한 곡이 없습니다. 듣고싶은 음악을 선택하세요.');
}

function rushPlayer3(musicCode)
{
	var wndLeft;
	var wndTop;
	var oldList;
	
	if(musicCode != "")
	{
		if(musicCode.substring(musicCode.length - 1, musicCode.length) != ",")
			musicCode += ",";
			
		var myExpVer = navigator.appVersion.split(";");
		myExpVer = myExpVer[1].replace(" ","");
		
		
		if(myExpVer == "MSIE 4.0" || myExpVer == "MSIE 5.0")
		{
			//메시지는 하루만 나온다.
			if(getCookie("showMsg") != "true")
			{
				setCookie("showMsg", "true", 1);
			
				if(confirm("Internet Explorer 6.0 이전버젼은 정상적으로 작동되지 않을 수 있습니다. \r\n6.0으로 업그레이드하시겠습니까?"))
					document.location = "http://music.inlive.co.kr/help/ie6setup.exe";
			}
		}
		
		if(myExpVer != "MSIE 4.0")
		{
			//if(getCookie("mpBoxMode") == "playing")
			//{
			//	setCookie("mCode", musicCode, 1);
			//	setCookie("letMeFirst", parseInt(getCookie("letMeFirst")) + 1, 1);
			//}
			//else
			//{
				var mcList;
				
				wndLeft = getCookie("ck_wndLeft");
				wndTop = getCookie("ck_wndTop");
				
				mcList = musicCode.split(",");
				setCookie("letMeFirst", mcList.length - 1, 1);
				
				if(!wndLeft || wndLeft == "")
				{
					wndLeft = 100;
					setCookie("ck_wndLeft", wndLeft, 10);
				}
				
				if(!wndTop || wndTop == "") 
				{
					wndTop = 100;
					setCookie("ck_wndTop", wndTop, 10);
				}
					
				setCookie("mCode", "", 1);
				playerWnd = window.open("/_player/player.html?&musicCode=" + musicCode,"rushPlayer","toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,left=" + wndLeft + ",top=" + wndTop + ",width=300,height=134");
				playerWnd.focus();			
			//}
		}
	}
	else
		alert('선택한 곡이 없습니다. 듣고싶은 음악을 선택하세요.');
}

function BaginChk2()	
{
	var songno = "";
	
	for(var i=0; i<document.frmSongList.elements.length; i++)
	{
		var ele = document.frmSongList.elements[i];
		
		if(ele.name == 'musicCode')
		{
			if(ele.checked == true)
				songno =  ele.value + "," + songno;
			else
				ele.checked = false;
		}
	}
	
	if(songno == "")
		alert('선택한 곡이 없습니다.');
	else
		OpenWnd('/myfolder/ms2folder.html?code='+songno, 'msfolder', 342, 410, 200, 200);
}


function Listen1()
{
	chkMode = -1;
	CheckAll(true);
	rushPlayer3(GetPlayList());
}


function Listen2()
{
	CheckAll(true);
	rushPlayer(GetPlayList());
}


function Listen3()
{
	CheckAll(true);
}


function Listen4()
{
	CheckAll(false);
}


function Listen5()
{
	rushPlayer(GetPlayList());
}





document.write("<script language=javascript src='/_player/cookie.js'></script>");
document.write("<span id=hiddenProc style='display:none'>");
document.write("<iframe id=DeepDeep width=0 height=0 frameborder=0 framespacing=0 noresize scrolling=no></iframe>");
document.write("</span> ");
