/*******************************************************************************
 * 2004.10.13 - POC
 * Modify
 * 2011.03.30 as-is script´Â melon_vod_player_back.js·Î backup
 * 			  À¥¹ÂÁ÷ºñµð¿ÀÇÃ·¹ÀÌ¾î °ü·Ã ½ºÅ©¸³Æ®¸¸À¸·Î ±¸¼º 					: YunHyeJeong
 ******************************************************************************/
// WIDTH: 322px; TOP: 0px; HEIGHT: 242px

var WWW_HOME = "http://www.melon.com";
if (typeof httpWww != 'undefined' && httpWww != null && httpWww != ''){
	WWW_HOME = httpWww;
}

// Wide È­¸é ºñÀ²·Î Á¶Á¤
//var SIZE_X1_WIDTH  = 322;

var progressBarBgWidth = 430;

//alert('chyeo2');

var SIZE_X1_WIDTH  = 430;
var SIZE_X1_HEIGHT = 242;

var SIZE_X2_WIDTH  = SIZE_X1_WIDTH * 2;
var SIZE_X2_HEIGHT = SIZE_X1_HEIGHT * 2;

var currentWidth = SIZE_X2_WIDTH;
var currentHeight = SIZE_X2_HEIGHT;

//Àü¹Î¼ö Ãß°¡ »ó¿ë¿¡´Â Àý¶§ ¿Ã¸®Áö ¸»°Í
var hostSetting = "http://www.melon.com";
//////////////////////////////

/* ¿À¸¥ÂÊ Å¬¸¯ °æ°í ¹Ú½º ¾øÀÌ ¸øÇÏ°Ô ÇÏ±â(ÀÍ½ºÇÃ·Î·¯/³Ý½ºÄÉÀÌÇÁ ¸ðµÎ) */
// ¿À¸¥ÂÊ ¹öÆ° Å¬¸¯À» ¸øÇÏ°Ô ÇÏ´Â ºÎºÐ
// ³Ý½ºÄÉÀÌÇÁ¿¡¼­¸¸ ´ë¹®ÀÚ E.
if (window.Event)
{
	//document.captureEvents(Event.MOUSEUP); // mouse up ÀÌº¥Æ®¸¦ ÀâÀ½
}

// IE4¿¡¼­¸¸ Àû¿ë, ´Ù¸¥ ºê¶ó¿ìÀú´Â ¹«½Ã
function nocontextmenu()
{
	event.cancelBubble = true;
	event.returnValue = false;
	return false;
}

// ´Ù¸¥ ¸ðµç ºê¶ó¿ìÀú¿¡¼­ ÀÛµ¿
function norightclick(e)
{
	// ´Ù½Ã, IE ¶Ç´Â NAV ?
	if (window.Event)
	{
		//if (e.which == 2 || e.which == 3)
		//{
			return false;
		//}
	}
	else if (event.button == 2 || event.button == 3)
	{
		event.cancelBubble = true;
		event.returnValue = false;
		return false;
	}
}

function ctrl_click()
{
//	ctrl key Á¦ÇÑ Ç®±â : ¿©Ã¢Çö 2005-01-18
//	if((event.ctrlKey) && (event.keyCode == 67)) // ctrl + C key
//	{
//		alert('³»¿ëÀ» º¹»çÇÒ ¼ö ¾ø½À´Ï´Ù.');
//	}
	if((event.ctrlKey) && (event.keyCode == 68))// ctrl + V key
	{
		alert('³»¿ëÀ» ºÏ¸¶Å©ÇÒ ¼ö ¾ø½À´Ï´Ù.');
	}
	// Bug·Î ÁÖ¼® Ã³¸®
	//if((event.keyCode >= 112 && event.keyCode <= 123))// Esc, f1~f12  key
	//{
	//	event.keyCode = 0;
	//	event.cancelBubble = true;
	//	event.returnValue = false;
	//}
	if((event.ctrlKey) && (event.keyCode == 78)) // ctrl + N key
	{
		return false;
	}
}

/* À¥ÆäÀÌÁö¿¡¼­ ¿À¸¥ÂÊ Å¬¸¯ Á¦ÇÑ
	½Ç¼­¹ö ¹Ý¿µ½Ã´Â ÁÖ¼®¸¶Å©//¸¦ ¹Ýµå½Ã »¬°Í!
*/
//document.oncontextmenu = nocontextmenu;	// IE5+ ¿ë
//document.onmousedown = norightclick;	// ´Ù¸¥ ºê¶ó¿ìÀú ¿ë
//document.onkeydown = ctrl_click;		// ÄÁÆ®·ÑÅ°¸¦ ÀÌ¿ëÇÑ Á¦¾î¸¦ ¸·´Â ºÎºÐ


/******************************************************************************/
/**
 * °³º° ¹ÂÁ÷ºñµð¿À & °³º°°î¿¡¼­ Á÷Á¢ È£Ãâ
 * ¾îÇÐÀÎ °æ¿ì studyId = songId À±ÇýÁ¤ Ãß°¡
 * as-is play_melon_vod(songId) play_melon_vod2(songId, mvId) ÅëÇÕ
 * @param songId
 * @param mvId
 */


function play_melon_vod(songId, mvId) {
//	alert("play_melon_vod(songId, mvId) "+" & songId : ["+songId+"] & "+" & mvId : ["+mvId+"]");
	var vodPlayerURL = WWW_HOME+"/cds/main/web/playermusicvideo_list.htm";
	var targetWindow = "melonVOD";
	var vod_width = 346;
 	var vod_height = 338;
 	var paramType = "";

	if (songId == "" && mvId == "") {
		alert("Àß¸øµÈ ¹ÂÁ÷ºñµð¿À ¿äÃ»ÀÔ´Ï´Ù");
		return;
	}
	if(mvId == undefined) {
		mvId = "";
	}
	if(songId == "") {
		paramType = "Mv";
	} else if(mvId == "") {
		paramType = "Song";
	} else {
		paramType = "Mv";
	}

	// ·Î±×ÀÎÃ¼Å©
	if (isMelonLogin()) {
		// ·Î±×ÀÎÇÑ »ç¿ëÀÚ - ¾ÖÇÃ¸®ÄÉÀÌ¼Ç º¸±â
		melonPlayerPlayForVod(songId, mvId);
	} else {
		// ·Î±×ÀÎ ¾È ÇÑ »ç¿ëÀÚ - À¥¹ÂÁ÷ÇÃ·¹ÀÌ¾î ¹Ì¸® º¸±â  - 2.0¿¡¼­´Â ÇÃ·¹ÀÌ¾î¿¡ OCX»ç¿ëÇÏÁö ¾ÊÀ½->ÇÃ·¡½Ã·Î º¯°æ
		window.open(vodPlayerURL+"?paramType="+paramType+"&p_songid="+songId+"&p_mvid="+mvId,targetWindow,
				"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+vod_width+",height="+vod_height+"");
//		window.open(vodPlayerURL+"?paramType="+paramType+"&p_songid="+songId+"&p_mvid="+mvId
//				,targetWindow
//				,"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+vod_width+",height="+vod_height+"");
		//window.open(vodPlayerURL+"?paramType="+paramType+"&p_songid="+songId+"&p_mvid="+mvId, targetWindow, "toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width="+currentWidth+", height="+currentHeight+", left=40, top=40");
//		window.open(vodPlayerURL+"?p_songid="+songId+"&p_mvid=50018746,50000010", targetWindow, "toolbar=no,location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, width="+currentWidth+", height="+currentHeight+", left=40, top=40");
	}
}
/**
 * °³º° ¹ÂÁ÷ºñµð¿À & °³º°°î¿¡¼­ Á÷Á¢ È£Ãâ
 * 110808 - kjt
 * as-is play_melon_vod(songId) play_melon_vod_main(songId, mvId) ÅëÇÕ¹öÀüÀÌ³ª ¿ÍÀÌÁî·Î±× ÀûÃâÀ» À§ÇØ ´Ù½Ã ºÐ¸®.
 * @param songId
 * @param mvId
 */
function play_melon_vod_main(songId, mvId) {
	var vodPlayerURL = WWW_HOME+"/cds/main/web/playermusicvideo_list.htm";
	var targetWindow = "melonVOD";
	var vod_width = 346;
 	var vod_height = 338;
 	var paramType = "";

	if (songId == "" && mvId == "") {
		alert("Àß¸øµÈ ¹ÂÁ÷ºñµð¿À ¿äÃ»ÀÔ´Ï´Ù");
		return;
	}
	if(mvId == undefined) {
		mvId = "";
	}
	if(songId == "") {
		paramType = "Mv";
	} else if(mvId == "") {
		paramType = "Song";
	} else {
		paramType = "Mv";
	}

	// ·Î±×ÀÎÃ¼Å©
	if (isMelonLogin()) {
		// ·Î±×ÀÎÇÑ »ç¿ëÀÚ - ¾ÖÇÃ¸®ÄÉÀÌ¼Ç º¸±â
		melonPlayerPlayForVod(songId, mvId);
	} else {
		// ·Î±×ÀÎ ¾È ÇÑ »ç¿ëÀÚ - À¥¹ÂÁ÷ÇÃ·¹ÀÌ¾î ¹Ì¸® º¸±â  - 2.0¿¡¼­´Â ÇÃ·¹ÀÌ¾î¿¡ OCX»ç¿ëÇÏÁö ¾ÊÀ½->ÇÃ·¡½Ã·Î º¯°æ
		window.open(vodPlayerURL+"?MAIN=MAIN_NM&paramType="+paramType+"&p_songid="+songId+"&p_mvid="+mvId,targetWindow,
				"toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width="+vod_width+",height="+vod_height+"");
	}
}


/**
 ******************************************************************************/
/**
*
	OCX / PLUG-INÀ¸·Î µ¿¿µ»ó Á¤º¸ÀÇ Àü´Þ °ü·Ã ³»¿ëÀ» Ãß°¡ ÇØ¾ß ÇÒ°Í °°½À´Ï´Ù.
	OCX / PLUG-INÀ¸·Î Àü¼ÛÇÏ´Â SongInfoÀÇ °æ¿ì Æ÷¸ËÀÌ ¾Æ·¡¿Í °°½À´Ï´Ù.

	SongInfo
	pItem_Flag | pItem_ID | pStatistic_ID¡¦
	pItem_Flag : 1=Song ID, 2=Album ID, 3=Product ID, 4=Study ID, 5=LectureID, 6=°ø°³¾Ù¹ü_ID, 7=¿Àµð¿ÀºÏ ID (21=¹ÂÁ÷ºñµð¿À_ID´Â Download ¿¡¼­¸¸ »ç¿ëÇÏ±â·Î ÇÔ)
	pItem_ID : pItem_Flag¿¡ ÇØ´çÇÏ´Â ID
	pStatistic_ID : Åë°è¿ë ID
	Delimiter´Â 0x0B
*
* */
function melonPlayerPlayForVod(songId, mvId){
	var PARAM_DELIMITER = "";
	var PARAM_DELIMITER_END = ":";
	var playFlag = mvId != "" ? "21" : "22";
	var playIds = mvId != "" ? mvId : songId;
	var playArr = (String(playIds)).split(",");

	var playList = "";
	var playLenth = 0;

	if(playArr != null){
		for(var p=0; p<playArr.length; p++){
			if(playArr[p] != ""){
				playList += playFlag + PARAM_DELIMITER + playArr[p] + PARAM_DELIMITER + "0" +PARAM_DELIMITER+PARAM_DELIMITER_END;
				playLenth++;
			}
		}
		playList = playLenth + PARAM_DELIMITER + playList;
	}

	var params = "/c play /b "+melonPlayerFunc.browser()+" /i "+getMemberId()+" /n "+getMemberKey()+" /s "+playList;
	//alert('chyeodocÈ£ÃâÆÄ¶÷:'+params);
	melonplayerActualPlay(params);
}


/**
 * ¹ÂÁ÷ºñµð¿À ¼±ÅÃº¸±â
 * @param formId
 */
function selectView(formId){
	var returnValue = false;
	var mvId = "";
	var songId = "";
	var i = 0;
	$('input[type=checkbox]:checkbox:checked',$("#"+formId)).each(function(){
		//mvId +=  this.value + ",";
		// mvId, songId µÑ´Ù ³Ñ¾î¿Ã °æ¿ì ·ÎÁ÷Ãß°¡ - ±èÀç¸¸
		if(this.value.indexOf(",") > -1){
			tmpArr = this.value.split(",");
			mvId += tmpArr[0] + ",";
			songId += tmpArr[1] + ",";
		}else{
			mvId += this.value + ",";
		}

		returnValue = true;
		i++;
	});
	if(!returnValue){
		alert("¹ÂÁ÷ºñµð¿À¸¦ ¼±ÅÃÇØ ÁÖ½Ê½Ã¿À");
	} else {
	play_melon_vod(songId, mvId);
	}
}

/**
 * Á¡¼öÁÖ±â
 * @param score
 * @param mvId
 * @param memberKey
 */
function setMvScore(score, mvId, memberKey){
	hide_add_point_layer();
	if(memberKey == null || memberKey == "") {
	   displayPopupLayer("Á¡¼öÁÖ±â´Â ·Î±×ÀÎ ÈÄ¿¡ ÇÒ ¼ö  ÀÖ½À´Ï´Ù.");
	} else {
		insertScore(score, mvId, memberKey);
	}
}
/**
 * Æù´Ù¿î ·¹ÀÌ¾î
 */
//Æù´Ù¿î ·¹ÀÌ¾î º¸ÀÌ±â
function show_mv_layer() {
	$("#show_mv_layer").show();
}
//Æù´Ù¿î ·¹ÀÌ¾î ¼û±â±â
function hide_mv_layer() {
	$("#show_mv_layer").hide();
}

