/*
* °ü½É¾ÆÆ¼½ºÆ® °ü·Ã ·¹ÀÌ¾îµå  Ã¢À» Ãâ·Â ÇÏ±â À§ÇÑ ÇÔ¼ö. body Å×±× ¾ÈÂÊ¿¡¼­ È£Ãâ
*
»ç¿ë¿¹ :
    <script>writeRegInterestArtistLayer(IMAGE_HOME, WWW_HOME)</script>
    
date 2008. 07. 09
@author whitedream    
*/ 
function writeRegInterestArtistLayer(IMAGE_HOME, WWW_HOME){
    document.write (" <!-- °ü½É¾ÆÆ¼½ºÆ® µî·Ï ·¹ÀÌ¾î ½ÃÀÛ --> ");
    document.write (" <div id=\"lp_interest_artist_login\" class=\"lp_bx\" style=\"display:none;\"> ");
    document.write ("   <p class=\"txt\"> ");
    document.write ("       °ü½É¾ÆÆ¼½ºÆ® µî·ÏÀº<br /> ");
    document.write ("       ·Î±×ÀÎ ÈÄ¿¡ ÇÏ¼¼¿ä.<br /> ");
    document.write ("       <a href=\"javascript:hide_lpop('lp_interest_artist_login_layer');\"><img src=\""+IMAGE_HOME+"/svc/images/common/btn/btn_close03.gif\" height=\"20\" alt=\"\" title=\"\"/></a>                                     ");
    document.write ("   </p> ");
    document.write (" </div> ");
    document.write (" <!-- °ü½É¾ÆÆ¼½ºÆ® µî·Ï ·¹ÀÌ¾î ³¡ --> ");
    document.write (" <!-- °ü½É¾ÆÆ¼½ºÆ® µî·Ï ·¹ÀÌ¾î ½ÃÀÛ --> ");
    document.write (" <div id=\"lp_interest_artist_dupl\" class=\"lp_bx\" style=\"display:none;\"> ");
    document.write ("   <p class=\"txt\"> ");
    document.write ("       ÀÌ¹Ì °ü½É¾ÆÆ¼½ºÆ®·Î<br /> ");
    document.write ("       µî·ÏµÈ ¾ÆÆ¼½ºÆ® ÀÔ´Ï´Ù.<br /> ");
    document.write ("       <a href=\"javascript:hide_lpop('lp_interest_artist_dupl_layer');\"><img src=\""+IMAGE_HOME+"/svc/images/common/btn/btn_close03.gif\" height=\"20\" alt=\"\" title=\"\"/></a> ");
    document.write ("       <a href=\"javascript:goMyPage('myArtist');\" title=\"¸¶ÀÌÆäÀÌÁö º¸±â\"><img src=\""+IMAGE_HOME+"/svc/images/common/btn/btn_view_mypage.gif\" height=\"20\" alt=\"\" title=\"\"/></a> ");
    document.write ("   </p> ");
    document.write (" </div> ");
    document.write (" <!-- °ü½É¾ÆÆ¼½ºÆ® µî·Ï ·¹ÀÌ¾î ³¡ --> ");
    document.write (" <!-- °ü½É¾ÆÆ¼½ºÆ® µî·Ï ·¹ÀÌ¾î ½ÃÀÛ --> ");
    document.write (" <div id=\"lp_interest_artist_ok\" class=\"lp_bx\" style=\"display:none;\"> ");
    document.write ("   <p class=\"txt\"> ");
    document.write ("       °ü½É¾ÆÆ¼½ºÆ® µî·ÏÀÌ<br /> ");
    document.write ("       ¼º°øÀûÀ¸·Î ¿Ï·áµÇ¾ú½À´Ï´Ù. ");
    document.write ("       <a href=\"javascript:hide_lpop('lp_interest_artist_ok_layer');\"><img src=\""+IMAGE_HOME+"/svc/images/common/btn/btn_close03.gif\" height=\"20\" alt=\"\" title=\"\"/></a> ");
    document.write ("       <a href=\"javascript:goMyPage('myArtist');\" title=\"¸¶ÀÌÆäÀÌÁö º¸±â\"><img src=\""+IMAGE_HOME+"/svc/images/common/btn/btn_view_mypage.gif\" height=\"20\" alt=\"\" title=\"\"/></a> ");
    document.write ("   </p> ");
    document.write (" </div> ");
    document.write (" <!-- °ü½É¾ÆÆ¼½ºÆ® µî·Ï ·¹ÀÌ¾î ³¡ --> ");
    document.write (" <!-- °ü½É¾ÆÆ¼½ºÆ® µî·Ï ·¹ÀÌ¾î ½ÃÀÛ --> ");
    document.write (" <div id=\"lp_interest_artist_fail\" class=\"lp_bx\" style=\"display:none;\"> ");
    document.write ("   <p class=\"txt\"> ");
    document.write ("       °ü½É¾ÆÆ¼½ºÆ® µî·Ï Áß<br /> ");
    document.write ("       ¿À·ù°¡ ¹ß»ýÇÏ¿´½À´Ï´Ù.<br /> ");
    document.write ("       <a href=\"javascript:hide_lpop('lp_interest_artist_fail_layer');\"><img src=\""+IMAGE_HOME+"/svc/images/common/btn/btn_close03.gif\" height=\"20\" alt=\"\" title=\"\"/></a> ");
    document.write ("   </p> ");
    document.write (" </div> ");
    document.write (" <!-- °ü½É¾ÆÆ¼½ºÆ® µî·Ï ·¹ÀÌ¾î ³¡ --> ");
}

//·Î±×ÀÎ ÇÊ¿ä
var REQ_INTEREST_ARTIST_LOGIN = "login";
//±âÅ¸¿¡·¯
var REQ_INTEREST_ARTIST_FAIL = "fail";
//µî·Ï¼º°ø
var REQ_INTEREST_ARTIST_OK = "ok";
//Áßº¹µî·Ï
var REQ_INTEREST_ARTIST_DUPL = "dupl";
    
//°ü½É¾ÆÆ¼½ºÆ® Ãß°¡µÇ¾ú´ÂÁö  ¿©ºÎ¸¦ ÀúÀå
var isRegInterest = "";
var triedInterestArtistId = "";

/*
* °ü½É¾ÆÆ¼½ºÆ® µî·Ï È£Ãâ ÇÔ¼ö
@param p_artistId
*/ 
function regInterestArtist(p_artistId){
    /*
    isMelonLogin() : /js/common/auth_cookie.js
    */
    var isLogin = isMelonLogin();
    if(arguments[1]!=undefined){
        isLogin = true;
    }
    if(isLogin){
	    if(triedInterestArtistId!=p_artistId){
		     isRegInterest="";
		     triedInterestArtistId = p_artistId;
		}

	    if(isRegInterest==REQ_INTEREST_ARTIST_LOGIN){
	        show_lpop('lp_interest_artist_login','','225',getCenterX()-112,getCenterY()-112);
	    }else if(isRegInterest==REQ_INTEREST_ARTIST_OK && triedInterestArtistId==p_artistId){
	        show_lpop('lp_interest_artist_dupl','','225',getCenterX()-112,getCenterY()-112);
	    }else if(isRegInterest==""){
	        if(arguments[1]==undefined){
	           ajax_addInterest(p_artistId,getMemberKey());
	        }else{
	           ajax_addInterest(p_artistId,getMemberKey(),arguments[1]);
	        }
	    }
    }else{
        loginPopupLayerd();
    }        
}

/*
* °ü½É¾ÆÆ¼½ºÆ® µî·Ï ajax Á÷Á¢ È£Ãâ ÇÔ¼ö
*
@param p_artistId
*/
function ajax_addInterest(p_artistId) {
    if(arguments[2]==undefined){
        ajax_request("/AjaxService", { command : "AxAddInterestArtist" , artistId : p_artistId }, ajax_cb_addInterest);
    }else{
        ajax_request("/AjaxService", { command : "AxAddInterestArtist" , artistId : p_artistId , dbg : arguments[2] }, ajax_cb_addInterest);
    }
}

/*
* ajax_addInterest Callback ÇÔ¼ö
*/    
function ajax_cb_addInterest(data) {
    if(data.AJAX_ERROR != "SUCCESS") {
        ajax_error();
        show_lpop('lp_interest_artist_fail','','225',getCenterX()-112,getCenterY()-112);
        return false;
    }
    
    var itemList = data.AJAX_LIST;
    var entity = itemList[0];
    var rstl = entity.String;
    
    if (rstl == REQ_INTEREST_ARTIST_OK) {
        isRegInterest=REQ_INTEREST_ARTIST_OK;
        show_lpop('lp_interest_artist_ok','','225',getCenterX()-112,getCenterY()-112);            
    }else if(rstl == REQ_INTEREST_ARTIST_DUPL){
        isRegInterest=REQ_INTEREST_ARTIST_OK;
        show_lpop('lp_interest_artist_dupl','','225',getCenterX()-112,getCenterY()-112); 
    }else{
        show_lpop('lp_interest_artist_fail','','225',getCenterX()-112,getCenterY()-112);
    }
}

if(window.getCenterY==undefined){
    //ÇöÀç ºê¶ó¿ìÁ® ³ôÀÌÀÇ Áß°£ À§Ä¡°ªÀ» ±¸ÇÑ´Ù.           
    var getCenterY = function(){
        var height = 0; 
        if( navigator.appName.indexOf("Microsoft") > -1 ){
            height = document.body.clientHeight;
        }else{
            height = innerHeight;
        }
        //alert("height="+height);
        return Math.floor(height/2);
    }
}

if(window.getCenterX==undefined){
    //ÇöÀç ºê¶ó¿ìÁ® ³ÐÀÌÀÇ Áß°£ À§Ä¡°ªÀ» ±¸ÇÑ´Ù.
    var getCenterX = function(){
        var width = 0; 
        if( navigator.appName.indexOf("Microsoft") > -1 ){
            width = document.body.clientWidth;
        }else{
            width = innerWidth;
        }
        //alert("width="+width);
        return Math.floor(width/2);
    }                
}
