//¹®ÀÚ¿­ Ä¡È¯
function url_replaceAll(orgStrVal, strValue1, strValue2) {
	var strTemp = orgStrVal;
	while(1)
	{
		if(strTemp.indexOf(strValue1) != -1) strTemp = strTemp.replace(strValue1, strValue2);
		else break;
	}
	return strTemp;
}

//·Î±×ÀÎ ÀÌµ¿
function goLoginPage() {
	//var ampChar = escape("&");
	//var perChar = escape("%");
	
	var returnURL = document.location.href;
	if (returnURL == "") returnURL = "/";
	else returnURL = escape(returnURL);
	location.href = "http://www.melon.com/PIMS/myMelon/newMyInfo/login.jsp?return_page="+returnURL+"&popGubun=notPop&SUB=GNB";
}

//·Î±×¾Æ¿ô ÀÌµ¿
function goLogoutPage() {
	document.location.href="http://www.melon.com/PIMS/myMelon/newMyInfo/logout.jsp?SUB=GNB";
}

//È¸¿ø°¡ÀÔ ÀÌµ¿
function goJoinPage() {
	document.location.href = "http://www.melon.com/PIMS/myMelon/newMyInfo/agree.jsp?SUB=GNB";
}

//³ªÀÇÆäÀÌÁö ÀÌµ¿
function goMyPage() {
	document.location.href = "http://www.melon.com/svc/mybox/mypage/mypage_main_index.jsp?p_memberKey="+ getMemberKey() +"&SUB=GNB";
}

//Çì´õ
function header(IMAGE_HOME, WWW_HOME) {

	var fromMPS = getCookie("MPS");  // ¸á·Ð ÇÃ·¹ÀÌ¾î¿¡¼­ ¿Ô´ÂÁö È®ÀÎ.
	
	document.write("<!-- GNB LAYER -->");
	document.write("<!-- Àå¸£ ¼±ÅÃ -->");
	document.write("<div id=\"gnbLayerGenre\" style=\"display: none;\">");
	document.write("<div class=\"gnbLayerT\">");
	document.write("<h2><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/layer/tit_gnb_layer_genre.gif\" alt=\"Àå¸£ ¼±ÅÃ\"></h2>");
	document.write("<a href=\"javascript: closeLayer('gnbLayerGenre');\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/layer/btn_gnb_layer_close.gif\" alt=\"´Ý±â\"></a>");
	document.write("</div>");
	document.write("<div class=\"gnbLayer\">");
	document.write("<ul>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/kpop_main.jsp?SUB=GNB\">°¡¿ä</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/classic_main.jsp?SUB=GNB\">Å¬·¡½Ä</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/korean_traditional_main.jsp?SUB=GNB\">±¹¾Ç</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/pop_main.jsp?SUB=GNB\">POP</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/ccm_main.jsp?SUB=GNB\">CCM</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/religious_music_main.jsp?SUB=GNB\">Á¾±³</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/ost_main.jsp?SUB=GNB\">OST</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/jazz_main.jsp?SUB=GNB\">JAZZ</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/child_main.jsp?SUB=GNB\">¾î¸°ÀÌ</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/jpop_main.jsp?SUB=GNB\">J-POP</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/world_main.jsp?SUB=GNB\">¿ùµå</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/cpop_main.jsp?SUB=GNB\">Áß±¹À½¾Ç</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/genre/newage_main.jsp?SUB=GNB\">´º¿¡ÀÌÁö</a></li>");
	document.write("</ul>");
	document.write("</div>");
	document.write("<div class=\"gnbLayerBt\"></div>");
	document.write("</div>");
	document.write("<!-- //Àå¸£ ¼±ÅÃ -->");
	document.write("<!-- ºÎ°¡¼­ºñ½º ¼±ÅÃ -->");
	document.write("<div id=\"gnbLayerAddService\" style=\"display: none;\">");
	document.write("<div class=\"gnbLayerT\">");
	document.write("<h2><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/layer/tit_gnb_layer_add_s.gif\" alt=\"ºÎ°¡¼­ºñ½º ¼±ÅÃ\"></h2>");
	document.write("<a href=\"javascript:closeLayer('gnbLayerAddService');\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/layer/btn_gnb_layer_close.gif\" alt=\"´Ý±â\"></a>");
	document.write("</div>");
	document.write("<div class=\"gnbLayer\">");
	document.write("<ul>");
	document.write("<li><a href=\"http://www.melon.com/decophone/index.jsp?SUB=GNB\">Æù²Ù¹Ì±â</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/edu2/edu_main.jsp?SUB=GNB\">¾îÇÐ</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/entnews/newsMain.jsp?SUB=GNB\">¿¬¿¹´º½º</a></li>");
	document.write("<li><a href=\"http://sing.melon.com/melon/index.php?SUB=GNB\">³ë·¡¹æ</a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/melonshop/shop_main.jsp?SUB=GNB\">¸á·Ð¼¥</a></li>");
	document.write("</ul>");
	document.write("</div> ");
	document.write("<div class=\"gnbLayerBt\"></div>");
	document.write("</div>");
	document.write("<!-- //ºÎ°¡¼­ºñ½º ¼±ÅÃ -->");
	document.write("<!-- //GNB LAYER -->");
	document.write("<!-- GNB WRAP -->");
	document.write("<div id=\"gnbWrap\">");
	document.write("<!-- BI -->");
	document.write("<div id=\"bi\">");
	document.write("<h1><a href=\"http://www.melon.com/index.jsp?SUB=GNB\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/bi_melon.gif\" alt=\"Melon\"></a></h1>");
	//ÆäÀÌÁöº° BI Ãâ·Â
	try {
		document.write("<h2><img src=\""+IMAGE_HOME+_arrBiImage[0]+"\" alt=\""+_arrBiImage[1]+"\"></h2>");
	}
	catch(e) {}
	document.write("</div>");
	document.write("<!-- //BI -->");
	document.write("<!-- GNB and LOGIN -->");
	document.write("<div id=\"gnbAndLogin\">");
	
	//ºñ·Î±×ÀÎ ½Ã
	if (isMelonLogin() == false) {
		document.write("<!-- LOGOUT -->");
		document.write("<ul id=\"login\">");
		document.write("<li><a href=\"javascript:goLoginPage();\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/btn_login.gif\" alt=\"·Î±×ÀÎ\"></a></li>");
		document.write("<li class=\"noBar\"><a href=\"javascript:goJoinPage();\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/btn_join.gif\" alt=\"È¸¿ø°¡ÀÔ\"></a></li>");
		document.write("</ul>");
		document.write("<!-- //LOGOUT -->");
	}
	//·Î±×ÀÎ ½Ã
	else {
		document.write("<!-- LOGIN -->");
		document.write("<ul id=\"login\">");
		//ÇÃ·¹ÀÌ¾î¿¡¼­ ¿Â °æ¿ì ³ëÃâ ¾ÈÇÔ
		if (fromMPS == null || fromMPS.indexOf("MELONPLAYER") < 0) {
			document.write("<li><a href=\"javascript:goLogoutPage();\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/btn_logout.gif\" alt=\"·Î±×¾Æ¿ô\"></a></li>");
		}
		document.write("<li class=\"noBar\"><a href=\"javascript:goMyPage();\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/btn_mypage.gif\" alt=\"¸¶ÀÌÆäÀÌÁö\"></a></li>");
		document.write("</ul>");
		document.write("<!-- //LOGIN -->");
	}
	
	document.write("<!-- GNB -->");
	document.write("<ul id=\"gnb\">");
	document.write("<li><a href=\"javascript:gnbLayer('gnbLayerGenre');\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/gnb_genre.gif\" alt=\"À½¾ÇÀå¸£\"></a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/studio/new/new_main.jsp?SUB=GNB\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/gnb_new_song.gif\" alt=\"ÃÖ½ÅÀ½¾Ç\"></a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/melonchart/chart_main.html?SUB=GNB\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/gnb_chart.gif\" alt=\"¸á·ÐÂ÷Æ®\"></a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/studio/mv/index.jsp?SUB=GNB\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/gnb_mv.gif\" alt=\"¹ÂÁ÷ºñµð¿À\"></a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/smartradio/main_artist.jsp?SUB=GNB\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/gnb_smart.gif\" alt=\"½º¸¶Æ®¶óµð¿À\"></a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/html/mybox/open/oalbum_index.jsp?SUB=GNB\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/gnb_album.gif\" alt=\"°ø°³¾Ù¹ü\"></a></li>");
	document.write("<li><a href=\""+WWW_HOME+"/event/event_main_1.jsp?SUB=GNB\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/gnb_event.gif\" alt=\"ÀÌº¥Æ®\"></a></li>");
	document.write("<li class=\"noBar\"><a href=\"javascript:gnbLayer('gnbLayerAddService');\"><img src=\""+IMAGE_HOME+"/svc/09/images/gnb/gnb_service.gif\" alt=\"ºÎ°¡¼­ºñ½º\"></a></li>");
	document.write("</ul>");
	document.write("<!-- //GNB -->");
	document.write("</div>");
	document.write("<!-- //GNB and Login -->");
	document.write("</div>");
	document.write("<!-- //GNB WRAP -->");
}
