/********************************************************************
Vricks Republic Publishing S&A
Beginning : 2009-07-23
Final : 2009-07-23
*********************************************************************/

//·¹ÀÌ¾î ¿Â¿ÀÇÁ
function layerHelpOver(layerId, xPos, yPos) {
	document.getElementById(layerId).style.display = "block";
	document.getElementById(layerId).style.left = xPos;
	document.getElementById(layerId).style.top = yPos;
	document.getElementById(layerId).style.zIndex = "10";
}
function layerHelpOut(layerId) {
	document.getElementById(layerId).style.display = "none";
}

//Á¤º¸ ´õº¸±â
function infoMore(openLayer, closeLayer) {
	document.getElementById(openLayer).style.display = "block";
	document.getElementById(closeLayer).style.display = "none";
}


//¸¶¿ì½º ¾×¼Ç
function mouseOver(elem) {
	elem.src = elem.src.replace(/_off.gif/, "_on.gif");
}
function mouseOut(elem) {
	elem.src = elem.src.replace(/_on.gif/, "_off.gif");
}


/**
* ¾ÆÆ¼½ºÆ® »ó¼¼ ¸ÞÀÎÀÇ ¹ÂÁ÷ºñµð¿À 
*/
var detailArtistMvlistUtil = new PlaylistUtil();
detailArtistMvlistUtil.setCommand("AxGetPageListArtistMv");
detailArtistMvlistUtil.setCallback(ajaxGetPageListDetailMv);
detailArtistMvlistUtil.setRowCount(4);    
detailArtistMvlistUtil.setListDivName("divDetailArtistMvList"); 
            
function ajax_goPage_artist_mv(currPage, se101_genre, se102_rowCount, se103_orderBy){
	//alert("ajax_goPage_artist_mv");
	detailArtistMvlistUtil.ajax_goPage_addJsonParam("artistId : \""+artistId+"\"", currPage, se101_genre, se102_rowCount, se103_orderBy);
}  
//DB¿¡¼­ ³Ñ°ÜÁØ data°ªÀ» °¡Áö°í ÀÖ´Â ºÎºÐÀÌ´Ù.
//Client´Â °¢°¢ ÀÌ ºÎºÐÀ» ±¸ÇöÇØ¾ß ÇÑ´Ù.
function ajaxGetPageListDetailMv(data) {
    
	if(data.AJAX_ERROR != "SUCCESS") {
        ajax_error();
        return false;
    }        
    
    var ajaxList = data.AJAX_LIST;
    var ajaxListCount = ajaxList[0].list.length;
    var ajaxListTotalCount = ajaxList[0].totalCount;
           
    var itemList = data.AJAX_LIST;        
    var playList = detail_mv_playlist(data, "divTmp", menuId);
    detailArtistMvlistUtil.renamePlaylistFormInfo("divTmp","divDetailArtistMvList",itemList,"aux3_","detailMv");
    document.getElementById("divDetailMvPagingList").innerHTML = ajax_paging_gopage(detailArtistMvlistUtil.getCurrentPage(), detailArtistMvlistUtil.getRowCount(), 10, ajaxListTotalCount, "ajax_goPage_artist_mv");
    //document.getElementById("txtTmp").value =   document.getElementById("divArtistMvList").innerHTML;
    //ÀÓ½Ã div Å×±× Å¬¸®¾î
    document.getElementById("divTmp").innerHTML="";         
}


/**
* ¾Ù¹ü »ó¼¼ ¸ÞÀÎÀÇ ¹ÂÁ÷ºñµð¿À 
*/
var detailAlbumMvlistUtil = new PlaylistUtil();
detailAlbumMvlistUtil.setCommand("AxGetPageListAlbumMv");
detailAlbumMvlistUtil.setCallback(ajaxGetPageListDetailAlbumMv);
detailAlbumMvlistUtil.setRowCount(2);    
detailAlbumMvlistUtil.setListDivName("divDetailAlbumMvList"); 
            

function ajax_goPage_album_mv(currPage, se101_genre, se102_rowCount, se103_orderBy){
	//alert("ajax_goPage_album_mv");
    detailAlbumMvlistUtil.ajax_goPage_addJsonParam("albumId : \""+g_albumEntity.albumId+"\"", currPage, se101_genre, se102_rowCount, se103_orderBy);
	//ajax_request("/AjaxService", { command : "AxGetPageListAlbumMv" , albumId : g_albumEntity.albumId, pageNum : currPage, rowCount : 2, orderBy : 1 }, ajaxGetPageListDetailAlbumMv);
}  

//DB¿¡¼­ ³Ñ°ÜÁØ data°ªÀ» °¡Áö°í ÀÖ´Â ºÎºÐÀÌ´Ù.
//Client´Â °¢°¢ ÀÌ ºÎºÐÀ» ±¸ÇöÇØ¾ß ÇÑ´Ù.
function ajaxGetPageListDetailAlbumMv(data) {
    
	//alert(data.AJAX_ERROR);
    if(data.AJAX_ERROR != "SUCCESS") {
        ajax_error();
        return false;
    }        
    
    var ajaxList = data.AJAX_LIST;
    var ajaxListCount = ajaxList[0].list.length;
    var ajaxListTotalCount = ajaxList[0].totalCount;
           
    var itemList = data.AJAX_LIST;        
    var playList = detail_mv_playlist(data, "divTmp", menuId);
    detailAlbumMvlistUtil.renamePlaylistFormInfo("divTmp","divDetailAlbumMvList",itemList,"aux3_","detailMv");
	document.getElementById("divDetailMvPagingList").innerHTML = ajax_paging_gopage(detailAlbumMvlistUtil.getCurrentPage(), detailAlbumMvlistUtil.getRowCount(), 10, ajaxListTotalCount, "ajax_goPage_album_mv");
     //document.getElementById("txtTmp").value =   document.getElementById("divArtistMvList").innerHTML;
    //ÀÓ½Ã div Å×±× Å¬¸®¾î
    document.getElementById("divTmp").innerHTML="";         
}


//½ÇÁ¦ data°ªÀ» Ãâ·ÂÇÑ´Ù.
function detail_mv_playlist(data, divId, menuId) {
    
    //var playListMedium; 
    var arrHtml = new Array();
    var itemList = data.AJAX_LIST;
    var i = 0;
    var cnt = 1;
    var checkboxVal = 1;

    arrHtml.push("");
    
	//	¹ÂÁ÷ ºñµð¿À ¸®½ºÆ® ¿µ¿ª ½ÃÀÛ
	arrHtml.push("<form name=\"detailMvFrm\">");
	arrHtml.push("<div id=\"detailMv\">");
	
	
/*		
	var idx = 1;
	var sizeVal = 0;

	if(itemList[0].list.length >= 20) sizeVal = 20;
	else sizeVal = itemList[0].list.length;
*/
	var idx = 1;  // ´Ù¿î·Îµå¿¡¼­ »ç¿ë
	
    for(var index=0; index<itemList[0].list.length; index++) {
		var mediumList = itemList[0].list[index];

		var dlallow = mediumList.innerMvType.substr(15,1);  // 0, 2 ¸é ´Ù¿î·Îµå ¹öÆ° È°¼ºÈ­

		if(index%2==0){
			arrHtml.push("<div class=\"mvList\">");
			arrHtml.push("<dl class=\"first\">");
		}else {
			arrHtml.push("<dl>");
		}
		arrHtml.push("	<dd class=\"mv\"><a href=\"#\" onClick=\"javascript:play_melon_vod2('"+mediumList.songId+"', '"+mediumList.mvId+"');return false;\" title=\""+mediumList.mvTitle+"\"><img src=\""+mediumList.mvImgPath+"\" ONERROR=\"defaultImg(this);\" alt=\"\" width=\"120\" height=\"90\"></a></dd>");
		arrHtml.push("	<dt><a href=\"#\" onClick=\"javascript:play_melon_vod2('"+mediumList.songId+"', '"+mediumList.mvId+"');return false;\" title=\""+mediumList.mvTitle+"\">");
		arrHtml.push(mediumList.mvTitle);
		arrHtml.push("	</a></dt>");
		arrHtml.push("		<dd class=\"point\">");
		
		var cntVal = Math.floor(mediumList.avgScr);
		var modVal = (mediumList.avgScr *10) % 10;
		var remainCnt = 5 - cntVal;
			
		for(var index1=0; index1<cntVal; index1++) {
			arrHtml.push("<img src=\""+IMAGE_HOME+"/svc/09/images/bu/star_s01.gif\" alt=\"\">");
		}	
		if(cntVal > 0 && cntVal < 5 ){
			if(modVal >= 1 && modVal <= 5) {
				addArray(arrHtml,"<img src=\""+IMAGE_HOME+"/svc/09/images/bu/star_s03.gif\"  alt=\"\" />");
				remainCnt = 5 - cntVal - 1;
			}else if(modVal > 5){	
				addArray(arrHtml,"<img src=\""+IMAGE_HOME+"/svc/09/images/bu/star_s01.gif\" border=\"0\"  alt=\"\" />");
				remainCnt = 5 - cntVal - 1;
			}	
		}	
		for(var index1=0; index1<remainCnt; index1++) {
			arrHtml.push("<img src=\""+IMAGE_HOME+"/svc/09/images/bu/star_s02.gif\" border=\"0\" alt=\"\" />");
		}

		arrHtml.push("<br><span>(Âü¿© <strong>"+mediumList.totCnt+"</strong>¸í)</span>"); 
		arrHtml.push("</dd>");
		arrHtml.push("<dd class=\"btn\">");
		
		if (dlallow==0 || dlallow==2) {

			arrHtml.push("<div class=\"phoneDownBtn\" style=\"z-index: "+index+";\" onmouseover=\"rollOverPhoneDown('phoneDownArtist"+index+"','"+index+"');\" onmouseout=\"rollOutPhoneDown('phoneDownArtist"+index+"','"+index+"');\"><a href=\"javascript:;\"><img src=\""+IMAGE_HOME+"/svc/09/images/btn/btn_mv_down.gif\" name=\"pdImg"+index+"\" border=\"0\"></a>");
			arrHtml.push("	<ul class=\"phoneDown\" style=\"display: none; z-index: "+index+";\" id=\"phoneDownArtist"+index+"\" onmouseover=\"rollOverPhoneDown('phoneDownArtist"+index+"','"+index+"');\" onmouseout=\"rollOutPhoneDown('phoneDownArtist"+index+"','"+index+"');\">");
			arrHtml.push("		<li><a href=\"javascript:goBuyProduct('detailMvFrm','"+mediumList.mvId+"','FG1104','','0','"+menuId+"');\">P C</a></li> ");
			arrHtml.push("		<li><a href=\"javascript:goBuyProduct('detailMvFrm','"+mediumList.mvId+"','FG1104','','0','"+menuId+"');\">½º¸¶Æ®Æù</a></li> ");
			arrHtml.push("		<li><a href=\"javascript:phoneDownMv('"+mediumList.mvId+"','"+menuId+"');\">ÀÏ¹ÝÆù</a></li> ");
			arrHtml.push("	</ul>");
			arrHtml.push("</div>");
		} // dlallow


		arrHtml.push("</dd>");
		arrHtml.push("</dl>");

		if(index%2==1){
			arrHtml.push("</div>");
		}

	}//end for	
	arrHtml.push("</form>");
	arrHtml.push("</div>");

	ajax_obj_clear(divId);
	//document.getElementById(divId).innerHTML = playListMedium;
	document.getElementById(divId).innerHTML = arrHtml.join("");

}
			
		
 function ajax_init_detail_mv(){        
    ajax_goPage_artist_mv(1);    
}


//100205 Æù´Ù¿î ·¹ÀÌ¾î Ãß°¡
var tmpDivsV = "";
function rollOutPhoneDown(divV,num) {
	tmpDivsV = divV;

	try {
		clearInterval(timer);
	} catch(e) {}
	timer = setInterval("disappearDivs()", 100);
}

function rollOverPhoneDown(divV,num) {
	if(tmpDivsV != "" && tmpDivsV != divV) {
		if (document.getElementById(tmpDivsV)!=null) {
			document.getElementById(tmpDivsV).style.display = "none";
			}
	}
	document.getElementById(divV).style.display = "block";

	try {
		clearInterval(timer);
	} catch(e) {}
}

function disappearDivs() {
	document.getElementById(tmpDivsV).style.display = "none";
	clearInterval(timer);
}	
