

//·Î±×ÀÎ ÆäÀÌÁö·Î
function goLogin(){
	var return_page_name = document.location.href;
	if(document.location.pathname.indexOf("/member/login.jsp")>=0){
		return_page_name = "";
	}

	location.href="http://www.thenadree.com/member/login.jsp?rurl="+encodeURIComponent(return_page_name);
	//location.href="https://www.thenadree.com/member/login.jsp?rurl="+encodeURIComponent(return_page_name);

}

//·Î±×¾Æ¿ô
function goLogout(){
	location.href="/member/logout.jsp";
}

//È¸¿ø°¡ÀÔ
function goMemberJoin(){
	//location.href="http://www.thenadree.com/member/join_ref.jsp?site_name=happyteria";
	location.href="https://www.thenadree.com/member/join_ref.jsp?site_name=happyteria";
}

function goSmenu( gb ){
	if( gb=="home" ){ //home
		location.href="/";
	}else if( gb=="login" ){ //·Î±×ÀÎ
		goLogin();
	}else if( gb=="logout" ){ //·Î±×¾Æ¿ô
		goLogout();
	}else if( gb=="member_edit" ){ //È¸¿øÁ¤º¸¼öÁ¤
		//location.href="http://www.thenadree.com/mypage/member_edit.jsp?rurl="+encodeURIComponent(document.location.href);
		location.href="https://www.thenadree.com/mypage/member_edit.jsp?rurl="+encodeURIComponent(document.location.href);
	}else if( gb=="member_join" ){ //È¸¿ø°¡ÀÔ
		goMemberJoin();
	}else if( gb=="mypage" ){ //¸¶ÀÌÆäÀÌÁö
		//window.open("http://www.thenadree.com/mypage/my_point.jsp");
		window.open("https://www.thenadree.com/mypage/my_point.jsp");
	}else if( gb=="schedule" ){ //ÀÏÁ¤
		windowOpen(
			'/event/auction_cal.jsp'
			,'calendar'
			,356
			,270
			,'no'
			,'no'
		);
	}else if( gb=="auction_join" ){ //¿Á¼ÇÂü¿©
		location.href="/event/ing_auction.jsp";
	}else if( gb=="happyqna" ){ //ÇØÇÇqna
		location.href="/advice/qna_list.jsp";
	}else if( gb=="poll" ){ //¼³¹® Âü¿©
		windowOpen(
			'/event/ingpoll_pop.jsp'
			,'ingpoll_pop'
			,346
			,500
			,'yes'
			,'no'
		);
	}else if( gb=="happypoint" ){ //ÇØÇÇ Æ÷ÀÎÆ®
		window.open("http://www.thenadree.com/help/faq.jsp");
	}else if( gb=="prosumer" ){ //ÇÁ·Î½´¸ÓÂü¿©
		location.href="/prosumer/prosumer.jsp";
	}else if( gb=="sense" ){ //¼¾½ºµû¶óÀâ±â




		//location.href="/event/2007/1112/event.jsp";
		//location.href="/event/2008/0625/event.jsp";
		//location.href="/event/2008/1028/event.jsp";
		location.href="/event/review_list.jsp";



	}else if( gb=="agreement" ){ //ÀÌ¿ë¾à°ü
		windowOpen('http://www.thenadree.com/member/agreement.jsp','pop_agreement',490,480,'no','no');
	}else if( gb=="policy" ){ //°³ÀÎÁ¤º¸º¸È£Á¤Ã¥
		windowOpen('http://www.thenadree.com/member/policy.jsp','pop_agreement',490,480,'no','no');
	}else if( gb=="contact" ){ //Contact
		window.open("http://www.thenadree.com/intro/contact.jsp");
	}else if( gb=="happyteria" ){ //happyteria
		location.href="/prosumer/h_list.jsp?cate=0";
	}else if( gb=="nadree" ){ //nadree
		window.open("http://www.thenadree.com");
	}
}



//ÇÃ·¡½Ã¿¡¼­ Å¬¸¯ ¸Þ´º
function goFlashMenu(fcode){

	if( fcode=="" || fcode=="000000" ){
		location.href="/";
		return;
	}

	if(fcode.length<6){
		alert(fcode);
		alert("¾ø´Â ¸Þ´º ÀÔ´Ï´Ù.");
		return;
	}
	var code = fcode.substring(0, 2);
	var no = fcode.substring(2, 4);
	var step = fcode.substring(4, 6);



	goMenu(code, no, step);
}

//¸Þ´º ¹Ù·Î °¡±â
function goMenu(code, no, step){
	if(no=="00") no="01";
	//if(step=="00") step="01";
	var sUrl = "/common/menu.xml";
	var xPath = "//item[@code='"+ code + "' and @no='"+no+"' and @step='"+step+"']";

	var link = getXmlValue(sUrl, xPath, "link");

	if(link==""){
		alert(code+"_"+no+"_"+step);
		alert("¾ø´Â ¸Þ´º ÀÔ´Ï´Ù.");
		return;
	}

	//½ºÅ©¸³Æ® È£ÃâÀÏ °æ¿ì Ã¼Å©
	var blScript = false;
	if( link.length>10 ){
		if( link.substring(0, 10)=="javascript" ){
			blScript = true;
		}
	}

	if(blScript){
		eval(link.substring(11));
	}else{
		var _url = "";
		location.href=_url+link;
	}
}

var front_menu_code;
var front_menu_no;
var front_menu_step;
var front_menu_name;
var front_top_menu_name;

function load_front_menu(){

	var ph_name = location.pathname.replace("","");

	var sUrl = "/common/menu.xml";
	var xPath = "//item[@link='"+ ph_name + "']";

	//ÀÚ±â ÀÚ½ÅÀÇ ÄÚµå Á¤ÀÇ
	if(
		typeof(self_front_menu_code)!="undefined"
		&&
		typeof(self_front_menu_no)!="undefined"
		&&
		typeof(self_front_menu_step)!="undefined"
		){

		xPath = "//item[@code='"
					+self_front_menu_code
					+"' and @no='"
					+self_front_menu_no
					+"' and @step='"
					+self_front_menu_step
					+"']";
	}

	//¹è¿­·Î °¡Á®¿È
	var arrResult = getXmlSelectNodes(sUrl, xPath);

	if(arrResult.length>0){
		front_menu_code 	= arrResult[0].getAttribute("code");
		front_menu_no 		= arrResult[0].getAttribute("no");
		front_menu_step		= arrResult[0].getAttribute("step");
		front_menu_name 	= arrResult[0].getAttribute("name");

		front_top_menu_name = getXmlValue(sUrl, "/root/item[@code='"+front_menu_code+ "']", "name");
	}
}

//Å¾ ¸Þ´º ºÒ·¯¿À±â
function load_front_top_menu(){

	var sUrl = "/common/menu.xml";
	var xPath = "/root/item";

	//¹è¿­·Î °¡Á®¿È
	var arrResult = getXmlSelectNodes(sUrl, xPath);

	if(arrResult.length>0){

		var str = "";

		var sel_menu = false;

		for(var i=0;i<arrResult.length;i++){

			sel_menu = false;
			if(front_menu_code){
				if(front_menu_code==arrResult[i].getAttribute("code")){
					sel_menu = true;
				}
			}
			str+= "<td>";
			str+= "<a href=\"javascript:goFlashMenu('"
						+arrResult[i].getAttribute("code")+"0100"
						+"')\">";
			if(sel_menu) str+="<b>";
			str+= arrResult[i].getAttribute("name");
			if(sel_menu) str+="</b>";
			str+= "<"+"/a>";
			str+= " | ";
		}

		str += "";

		document.getElementById("front_top_menu").innerHTML = str;

	}else{
		//alert("¸Þ´º ¾øÀ½");
		//return;
	}
}


//ÁÂÃø ¸Þ´º ºÒ·¯¿À±â
function load_front_left_menu(){

	var sUrl = "/common/menu.xml";
	var xPath = "/root/item[@code='"+front_menu_code+ "']/item";

	//¹è¿­·Î °¡Á®¿È
	var arrResult = getXmlSelectNodes(sUrl, xPath);

	if(arrResult.length>0){

		var str = "";

		var sel_menu = false;

		for(var i=0;i<arrResult.length;i++){

			sel_menu = false;

			if(front_menu_no){
				if(front_menu_no==arrResult[i].getAttribute("no")){
					sel_menu = true;
				}
			}

			str+= "";
			str+= "<a href=\"javascript:goFlashMenu('"
						+arrResult[i].getAttribute("code")
						+arrResult[i].getAttribute("no")
						+arrResult[i].getAttribute("step")
						+"')\">";
			if(sel_menu) str+="<b>";
			str+= arrResult[i].getAttribute("name");
			if(sel_menu) str+="</b>";
			str+= "<"+"/a>";
			str+= " | ";

		}

		str += "";

		document.getElementById("front_left_menu").innerHTML = str;

	}else{
		//alert("¸Þ´º ¾øÀ½");
		//return;
	}
}

function load_front_page_title(){

	if( front_menu_name ){
		var str = "";
		str += "";
		str += "<a href=\"/\">Home</a> &gt; ";
		str += ""
				+"<a href=\"javascript:goFlashMenu('"
						+front_menu_code
						+"0100"
						+"')\">"
				+front_top_menu_name+"</a> &gt; ";

		str += "<b>"+front_menu_name+"</b> ";

		var div_front_page_title = document.getElementById("front_page_title");

		if( div_front_page_title ){
			div_front_page_title.innerHTML = str;
		}
	}
}

//¹Ù·Î ½ÇÇà
load_front_menu();

//·ÎµåÈÄ ½ÇÇà
//Utils.addEvent(window,"onload", new Function( "load_front_top_menu()" ));
//Utils.addEvent(window,"onload", new Function( "load_front_left_menu()" ));

Utils.addEvent(window,"onload", new Function( "load_front_page_title()" ));

if( !front_menu_code ) front_menu_code = "00";
if( !front_menu_no ) front_menu_no = "00";
if( !front_menu_step ) front_menu_step = "00";

