var child_window = null;
function search(s, t, k, st) {
	window.GNBsearchForm.start.value = s;
	window.GNBsearchForm.type.value = t;
	window.GNBsearchForm.kwd.value = k;
	//window.SEARCH_QUERY_FORM.subtype.value = st;
	window.GNBsearchForm.submit();
}

function OpenPlayer_Playlist(pid) {
	window_width = 300;
	window_height = 427;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	window.open("/joos_music/player/player.php?type=playlist&id=" + pid, "JOOS_MUSIC_PLAYER", position);
}

function OpenListPlayer(tids) {
	window_width = 350;
	window_height = 500;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,menubar=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	window.open("/joos_music/player/player.php?type=list&id=" + tids,  "JOOS_MUSIC_PLAYER", position);
}

function OpenSinglePlayer(tid) {
	window_width = 350;
	window_height = 500;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,menubar=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	window.open("/joos_music/player/player.php?type=single&id=" + tid,  "JOOS_MUSIC_PLAYER", position);
}

function OpenRadio() {
	window_width = 300;
	window_height = 110;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	window.open("/joos_music/player/player.php?type=radio", "JOOS_MUSIC_PLAYER", position);
}

// Ã¼Å©¹Ú½º ´©¸£´Â°Å °ü·Ã...
function toggle(obj) {
	for(i=0;i<window.TRACK_CHECK.length;i++) {
		if(window.TRACK_CHECK(i).tagName == "INPUT" && window.TRACK_CHECK(i).TID != null) {
			window.TRACK_CHECK(i).checked = obj.checked;
		}
	}
}

//TRACK_CHECK ÀÌ°Í¸¸ °Ë»çÇØµµ µÇ´Âµð..

// ÇöÀç ¼±ÅÃµÈ°Í(b=false) È¤Àº ÀüÃ¼(b=true)¸¦ °¡Á®¿Â´Ù.
function getChecked(b) {
	rtn = "";
	for(i=0;i<window.TRACK_CHECK.length;i++) {
		if(window.TRACK_CHECK(i).TID != null && window.TRACK_CHECK(i).TID != "") {
			if(window.TRACK_CHECK(i).checked || b) rtn += (window.TRACK_CHECK(i).TID + ";");
		}
	}
//alert(rtn);
	return rtn;
}

function Listen_Checked() {
	c = getChecked(false);
	if(c == "") {alert("À½¾ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");return;}
	OpenListPlayer(c);
}

function Listen_All() {
	c = getChecked(true);
	if(c == "") {alert("À½¾ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");return;}
	OpenListPlayer(c);
}

function GoMp3Down() {
	c = getChecked(false);
	if(c == "") {alert("À½¾ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");return;}
	Basket_InsertMP3(c);
}

// CD-Burn ´Ù¿î·Îµå ÇÔ¼ö
function MP3CDBurnDownload() {
	cnt = 0;
	data = "";
	for(i=0;i<window.TRACK_CHECK.length;i++) {
		if(window.TRACK_CHECK(i).checked && window.TRACK_CHECK(i).DOWN_ID != null) {
			data += window.TRACK_CHECK(i).TID+";";
			cnt++;
		}
	}
	if(data == "") {alert("À½¾ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");return false;}
	
	return data;
}

//MarkAny Download ÇÔ¼ö
function MP3Download_MA_old(t) {
	cnt = 0;
	data = "";
	for(i=0;i<window.TRACK_CHECK.length;i++) {
		if(window.TRACK_CHECK(i).checked && window.TRACK_CHECK(i).DOWN_ID != null) {
			data += window.TRACK_CHECK(i).DOWN_ID;
			cnt++;
		}
	}
	if(data == "") {alert("À½¾ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");return;}

//alert(data);

	obj = document.multiForm;
	//Á¦¸ñ/ÆÄÀÏURL/ °¡¼ö/ ÀúÀåÆÄÀÏ¸í/½Äº°ÀÚ
	obj.multiFname.value = data;
	obj.action = "/joos_music/download/MADownload.php";
	window.open('', 'DownloadWin', 'width=540,height=380,menubar=no, directories=no,resizable=no,status=no,scrollbars=no');
	obj.target = "DownloadWin";
	obj.submit();	
	
}

function MP3Download_MA(t) {
	cnt = 0;
	data = "";
	for(i=0;i<window.TRACK_CHECK.length;i++) {
		if(window.TRACK_CHECK(i).checked && window.TRACK_CHECK(i).DOWN_ID != null) {
			data += window.TRACK_CHECK(i).DOWN_ID;
			cnt++;
		}
	}
	if(data == "") {alert("À½¾ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");return;}

//alert(data);
//alert(t);
	obj = document.multiForm;
	//Á¦¸ñ/ÆÄÀÏURL/ °¡¼ö/ ÀúÀåÆÄÀÏ¸í/½Äº°ÀÚ
	obj.multiFname.value = data;
	obj.type.value = t;
	obj.action = "/joos_music/download/MADownload.php";
	window.open('', 'DownloadWin', 'width=540,height=380,menubar=no, directories=no,resizable=no,status=no,scrollbars=no');
	obj.target = "DownloadWin";
	obj.submit();
}

//MarkAny Download Sync ÇÔ¼ö(2007.05.29 Ãß°¡)
function MP3Download_Sync() {
	cnt = 0;
	data = "";
	for(i=0;i<window.TRACK_CHECK.length;i++) {
		if(window.TRACK_CHECK(i).checked && window.TRACK_CHECK(i).DOWN_ID != null) {
			data += window.TRACK_CHECK(i).DOWN_ID;
			cnt++;
		}
	}
	if(data == "") {alert("À½¾ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");return;}

	obj = document.multiForm;
	//Á¦¸ñ/ÆÄÀÏURL/ °¡¼ö/ ÀúÀåÆÄÀÏ¸í/½Äº°ÀÚ
	obj.multiFname.value = data;
	obj.action = "/joos_music/myalbum/_sync.php";
	window.open('', 'DownloadWin', 'width=640,height=400,menubar=no, directories=no,resizable=no,status=no,scrollbars=no');
	obj.target = "DownloadWin";
	obj.submit();	
}


//´Ù¿î·Îµå ÇÔ¼öµé
function MP3Download() {
	cnt = 0;
	data = "";
	for(i=0;i<window.TRACK_CHECK.length;i++) {
		if(window.TRACK_CHECK(i).checked && window.TRACK_CHECK(i).DOWN_ID != null) {
			data += window.TRACK_CHECK(i).DOWN_ID;
			cnt++;
		}
	}
	if(data == "") {alert("À½¾ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");return;}

//alert(data);

	obj = document.multiForm;
	//Á¦¸ñ/ÆÄÀÏURL/ °¡¼ö/ ÀúÀåÆÄÀÏ¸í/½Äº°ÀÚ
	obj.multiFname.value = data;
	obj.action = "/joos_music/download/EncodedParam.php";
	window.open('', 'DownloadWin', 'width=450,height=' + (284 + (cnt*20)) + ',menubar=no, directories=no,resizable=no,status=no,scrollbars=no');
	obj.target = "DownloadWin";
	obj.submit();
}


function MP3TestDownload() {
	obj = document.multiForm;
	//Á¦¸ñ/ÆÄÀÏURL/ °¡¼ö/ ÀúÀåÆÄÀÏ¸í/½Äº°ÀÚ
	obj.multiFname.value = "Always&col;192k/069/80088069.mp3.MS&col;½ÅÁö&col;Always.mp3.MS&col;80088069&row;";
	obj.action = "/joos_music/download/EncodedParam.php";
	window.open('', 'DownloadWin', 'width=450,height=304,menubar=no, directories=no,resizable=no,status=no,scrollbars=no');
	obj.target = "DownloadWin";
	obj.submit();
}

// Àå¹Ù±¸´Ï °ü·Ã ÇÔ¼öµé
function Basket_InsertMP3(tid) {
	window.FORM_BASKET.TYPE.value = "+";
	window.FORM_BASKET.TRACK_ID.value = tid;
	window.FORM_BASKET.submit();
}

function Basket_DeleteMP3(tid) {
	window.FORM_BASKET.TYPE.value = "-";
	window.FORM_BASKET.TRACK_ID.value = tid;
	window.FORM_BASKET.submit();
}

function Basket_ClearMP3() {
	if(confirm('Àå¹Ù±¸´Ï¸¦ ºñ¿ì½Ã°Ú½À´Ï±î??')) {
		window.FORM_BASKET.TYPE.value = "";
		window.FORM_BASKET.submit();
	}
}

function Delete_Checked() {
	c = getChecked(false);
	if(c == "") {alert("À½¾ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä.");return;}
	Basket_DeleteMP3(c);
}

function SongWord(id) {
	window_width = 350;
	window_height = 470;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	window.open("/joos_music/popup/music_pop_songword.php?id="+id, "SONGWORD", position);
}

function CheckMP3Ness() {
	window_width = 450;
	window_height = 600;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	window.open("/joos_music/popup/music_pop_check.htm", "CHECKMP3", position);
}

function MakeAlbum() {
	window_width = 350;
	window_height = 200;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	child_window = window.open("/joos_music/popup/music_pop_album.php?type=0", "ALBUM", position);
}

function RenameAlbum(list_id, subj) {
	if(list_id == "") return;
	window_width = 350;
	window_height = 200;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	child_window = window.open("/joos_music/popup/music_pop_album.php?type=1&id=" + list_id + "&subj=" + subj, "ALBUM", position);
}

function DeleteAlbum(list_id) {
	if(list_id == "") return;
	if(confirm("»èÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) {
		window_width = 350;
		window_height = 200;
		screen_top = parseInt((screen.availHeight - window_height)/2);
		screen_left = parseInt((screen.availWidth - window_width)/2);
		position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
		child_window = window.open("/joos_music/popup/music_pop_album.php?type=4&id=" + list_id, "ALBUM", position);
	}
}

function buy_ticket(type) {
	window_width = 450;
	window_height = 550;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	child_window = window.open('/joos_music/popup/music_pop_buym.php?type='+type, 'BUY_TICKET', position);
}

function present_ticket(type) {
	alert("ÁØºñÁßÀÔ´Ï´Ù.");
	return;
	window_width = 450;
	window_height = 563;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	child_window = window.open('/joos_music/popup/music_pop_presentm.php?type='+type, 'BUY_TICKET', position);
}

function close_child() {
	try {
		child_window.close();
	} catch(E) {
	}
}

function BuyMP3Confirm(rest) {
	if(rest < 0) {
		if(confirm("ÀÜ¾×ÀÌ ºÎÁ·ÇÕ´Ï´Ù. ÃæÀüÇÏ½Ã°Ú½À´Ï±î?")) {
			location.href = "/myjoos/myjoos.php?type=31";
		}
	} else {
		if(confirm("°áÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) {
			window.open('/joos_music/cgi/music_buymp3.php', 'QUERY_TARGET');
		}
	}
}

function BuyMP3ConfirmForCoupon(rest, cpn) {
	if(rest < 0) {
		if(confirm("ÀÜ¾×ÀÌ ºÎÁ·ÇÕ´Ï´Ù. ÃæÀüÇÏ½Ã°Ú½À´Ï±î?")) {
			location.href = "/myjoos/myjoos.php?type=31";
		}
	} else {
		if(confirm("°áÁ¦ÇÏ½Ã°Ú½À´Ï±î?")) {
			window.open('/joos_music/cgi/music_buymp3.php?cpn='+cpn, 'QUERY_TARGET');
		}
	}
}

function couponinfo(item_no, div)
{
	window_width = 450;
	window_height = 550;
	screen_top = parseInt((screen.availHeight - window_height)/2);
	screen_left = parseInt((screen.availWidth - window_width)/2);
	position = 'resizable=no,scrollbars=no,left='+screen_left+',top='+screen_top+',width='+window_width+',height=' + window_height;
	child_window = window.open('/joos_music/popup/music_pop_guidetiket.php?item_no='+item_no+'&div='+div, 'COUPON_TICKET', position);
}
