//document.domain = "miclub.com";

var n_id = "";
var n_tid = "";
var open_type = "";
var n_nick = "";
/******************************************
 *miclub blog ui
 *@param userId È¸¿øº»ÀÎ
 *@param blogId ºí·ÏÀ¯Àú
 *@
 *@
 *****************************************/


 function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}



function m_blog_ui(userId,blogId, lv_open_type, nick) {	
	document.all.UserBlogIdInfo.innerHTML = blogId;
	n_id = userId; //È¸¿øº»ÀÎ
	n_tid = blogId; //ºí·Ï
	open_type = lv_open_type;
	n_nick = nick;

}

/**
 * ·Î±×ÀÎ check
 */
 
function viewLoginForm() {	
	var loginURL = "http://www.miclub.com/profile/login/index.jsp?returnUrl=";
	loginURL += escape(top.location.href);
	top.location.href = loginURL;
}


function exec_menuitem(key) {
		switch(key) {
		case "EVENT1" :			//ºí·Ïº¸±â
			blog_view(n_tid);
			break;
		case "EVENT2" :			//ÀÎ¿¬¸Î±â
			
			
			
			if (n_id == n_tid)
			{
			    alert("ÀÚ½Å°ú´Â ÀÎ¿¬À» ¸ÎÀ» ¼ö ¾ø½À´Ï´Ù.");
				return;
			}
			buddyApplyPopup(n_id, n_tid);			
			break;
		case "EVENT3" :			//ÂÊÁöº¸³»±â
			
			
			if(n_id == ""){
				if (confirm('·Î±×ÀÎÀÌ ÇÊ¿äÇÕ´Ï´Ù. ·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?')){					
					viewLoginForm();
					return;				
				}else{
					return;
				}
			}	
			
			if (n_id == n_tid)
			{
			    alert("ÀÚ½Å¿¡°Ô´Â ÂÊÁö¸¦ º¸³¾ ¼ö ¾ø½À´Ï´Ù.");
				return;
			}
			sendmemo(n_tid);
			break;
		
		case "EVENT5" :				//¾ÆÁöÆ®ÃÊ´ë
			
			if(n_id == ""){
				if (confirm('·Î±×ÀÎÀÌ ÇÊ¿äÇÕ´Ï´Ù. ·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?')){					
					viewLoginForm();
					return;				
				}else{
					return;
				}
			}	
			if (n_id == n_tid)
			{
			    alert("ÀÚ½ÅÀ» ¾ÆÁöÆ®¿¡ ÃÊ´ëÇÒ ¼ö ¾ø½À´Ï´Ù.");
				return;
			}
			inviteAgit(n_tid);
			break;
		case "EVENT6" :
			if (n_id == n_tid)
			{
			    alert("ÀÚ½ÅÀ» ÀÌ¿ôÃß°¡ ÇÒ ¼ö ¾ø½À´Ï´Ù.");
				return;
			}
			buddyAdd(n_tid);
			break;
	}

}

function blog_view(tid) {

	lv_linkUrl = "http://blog.miclub.com/" + tid ;

	switch(open_type) {
		case "0" : 	
			document.location.href = lv_linkUrl;
			break;
		case "1" : 	
			parent.location.href = lv_linkUrl;
			break;
		case "2" : 	
			top.location.href = lv_linkUrl;
			break;
		case "3" : 			
			//window.open(lv_linkUrl,'PopBlog','width=800,height=700');			
			window.open(lv_linkUrl , "_blank");
			//window.open(lv_linkUrl , "_blank", "width=800, height=600, resizable=yes,menubar=yes,location=yes, toolbar=yes, scrollbars=yes,status=yes");
			//window.open(lv_linkUrl,"_blank", "height=200,width=400,status=yes,toolbar=yes,menubar=yes,location=yes");

			break;
		case "4" : 	
			break;
		case "5" : 
			break;
		default :		
			document.location.href = lv_linkUrl;
			break;
	}
}

function sendmemo(target_id){		
	window.open("http://mypage.miclub.com/MainServlet?cmd=view_shortmemo_sendding_form_pop&target_userId=" + target_id , "", "width=350, height=470, resizable=no, toolbars=no, scrollbars=no,status=yes");
//	window.open("http://mypage0.miclub.com/MainServlet?cmd=view_shortmemo_sendding_form_pop&target_userId=" + target_id , "send_shortmemo", "width=350, height=310, resizable=no, toolbars=no, scrollbars=no,status=yes");
}
function inviteAgit(target_id){
	window.open("http://mypage.miclub.com/MainServlet?cmd=view_agit_shortmemo_sendding_form_pop&smtyp=02&target_userId=" + target_id , "", "width=350, height=370, resizable=no, toolbars=no, scrollbars=no,status=yes");
	//window.open("http://mypage0.miclub.com/MainServlet?cmd=view_agit_shortmemo_sendding_form_pop&smtyp=02&target_userId=" + target_id , "send_shortmemo", "width=350, height=370, resizable=no, toolbars=no, scrollbars=no,status=yes");
	
}

function  buddyApplyPopup(userId, target_id){			
	
	if(userId == ""){
		if (confirm('·Î±×ÀÎÀÌ ÇÊ¿äÇÕ´Ï´Ù. ·Î±×ÀÎ ÇÏ½Ã°Ú½À´Ï±î?')){					
			viewLoginForm();
			return;				
		}else{
			return;
		}
	}	
	
	window.open("/MainServlet?cmd=view_buddy_application_form&blogId="+target_id+"&userId="+ userId,"buddyapply","scrollbars=no, status=yes,left=0, top=0, width=350,height=362");
	//window.open("/buddyapply/buddyapply.jsp?blogId="+target_id,"","scrollbars=no, left=0, top=0, width=350,height=362");
	//window.open("/buddyapply/buddyapply.jsp?blogId="+target_id,"buddyapply","scrollbars=no, left=0, top=0, width=350,height=362");
}
function PchatInvite(id){
	window.open("/chat/PrivateChatOn.jsp?blogId=" + id,"popChatinvite","width=10,height=10,scrollbars=no,resizable=no,top=" + ((screen.height - 500) / 2) + ", left=" + ((screen.width - 330) / 2));
}

function buddyAdd(tid)
{
	window.open("/buddy/addBuddy.jsp?blogId="+tid,"buddyAdd","width=346,height=250,scrollbars=yes");
}
//	IE Script

	var NS4;
	var IE4;
	var mouse_top;
	var mouse_left;
	var scroll_top;
	var scroll_left;
	var event_id = "none";
	var status_over = false;	
	var parent_menu_name = "menu_parent";
	var child_menu_array = ["menu_child1"];
//	var child_menu_array = ["menu_child1", "menu_child2", "menu_child3"];
	var submenu_left_indent = 70;
	var column_height = 18;
	var submenu_top_indent = 0;
	var mainmenu_top_indent = 0;	
	var menuover_bgcolor = "#e4ff75";
	var menuover_fgcolor = "#ffffff";
	var default_menuover_bgcolor = "#ffffff";
	var default_menuover_fgcolor = "#000000";
	
	NS4 = (document.layers);
	IE4 = (document.all);
	isWin = (navigator.appVersion.indexOf("Win") != -1)
	
	if (NS4) {
		document.captureEvents(Event.CLICK)
		document.onclick = MouseDown;
	} else if (IE4) {
		document.onclick = MouseDown;
	}
	
	function startIt() {
	}
	
	function menuOver(ar_obj, ar_id) {
		status_over = true;
		changeColor(ar_obj);
		hideChild(event_id);
		viewSubMenu(event, ar_obj, ar_id);
				
	}
	
	function SubmenuOver(ar_obj) {
		status_over = true;
		changeColor(ar_obj);
	}
	
	function MouseDown(e) 
	{

		event_target = event.srcElement;
		event_target = event_target.toString();
		event_check = event_target.indexOf("javascript:m_blog_ui(");		

		if (!status_over) hideAll();
		if (!event_check)
		{
			viewMenu(event,  parent_menu_name);
			return;
		}
		else 
		{
			if (!status_over) hideAll();
			return;
		}
	}	
	
	function hideChild(ar_id) {
		if (event_id == "none") return;
		var menu_len = child_menu_array.length;
		for (i=0; i<menu_len; i++) eval(child_menu_array[i] + ".style.display = \"none\"");
	}
	
	function hideAll() {
		eval(parent_menu_name + ".style.display = \"none\"");
		if (event_id == "none") return;
		var menu_len = child_menu_array.length;
		for (i=0; i<menu_len; i++) eval(child_menu_array[i] + ".style.display = \"none\"");
	}

	function viewMenu(e, ar_id) {
		if (ar_id == "none") return;
		menuLocBod = window.document.body;
		xPos = menuLocBod.scrollLeft + event.clientX;
		yPos = event.clientY + menuLocBod.scrollTop;
		screen_height = window.document.body.offsetHeight;
		screen_width = window.document.body.offsetWidth;
		mouse_top = e.y;
		mouse_left = e.x;
		eval("mainmenu_top_indent = " + parent_menu_name + ".children[0].children[0].children.length");
		mainmenu_top_indent = mainmenu_top_indent * column_height;
		if (screen_height > mouse_top + mainmenu_top_indent) 
			yPos = event.clientY + menuLocBod.scrollTop;
		else
			yPos = (event.clientY + menuLocBod.scrollTop) - mainmenu_top_indent;

		if (mouse_top - mainmenu_top_indent < 0) 
			yPos = event.clientY + menuLocBod.scrollTop;
			
		eval(ar_id + ".style.pixelTop =" + yPos);
		eval(ar_id + ".style.pixelLeft =" + xPos);		
		eval(ar_id + ".style.display = \"\"");
	}
	
	function viewSubMenu(e, ar_obj, ar_id) {
		if (ar_id == "none") return;
		event_id = ar_id;
		parent_top = menu_parent.style.pixelTop;
		parent_left = menu_parent.style.pixelLeft;
		child_top = ar_obj.style.pixelTop;
		child_left = ar_obj.style.pixelLeft;
		screen_height = window.document.body.offsetHeight;
		screen_width = window.document.body.offsetWidth;
		mouse_top = e.y;
		mouse_left = e.x;
		menuLocBod = window.document.body;
		xPos = menuLocBod.scrollLeft + parent_left + submenu_left_indent;
		eval("submenu_top_indent = " + ar_id + ".children[0].children[0].children.length");
		submenu_top_indent = submenu_top_indent * column_height;
		if (screen_height > mouse_top + submenu_top_indent) 
			yPos = event.clientY + menuLocBod.scrollTop;
		else
			yPos = (event.clientY + menuLocBod.scrollTop) - submenu_top_indent;
		
		if (mouse_top - submenu_top_indent < 0) 
			yPos = event.clientY + menuLocBod.scrollTop;
			
		eval(ar_id + ".style.pixelTop =" + yPos);
		eval(ar_id + ".style.pixelLeft =" + xPos);		
		eval(ar_id + ".style.display = \"\"");
	}
		
	function menuOut(ar_obj) {
		status_over = false;
		changeColor(ar_obj);
	}
	
	function changeColor(ar_obj) {
        

		if (ar_obj.style.background == menuover_bgcolor) {
			//ar_obj.style.color = default_menuover_fgcolor;
			ar_obj.style.background = default_menuover_bgcolor;
		} else {
			ar_obj.style.background = menuover_bgcolor;
			//ar_obj.children[0].style.color = menuover_fgcolor;
		}
		
	}


function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}




	document.writeln("							"+
			"<div id=\"menu_parent\" style=\"position:absolute;display:none;top:0;left:0\">	"+
			"<table border=0 width=105 ><tr><td style='padding:2 2 2 2'>"+

			"<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"93\">	"+
			"	<tr>"+
			"		<td colspan=\"3\"><img src=\"/image/common/hidden_menu_top.gif\" alt=\"\" border=\"0\" align=\"absmiddle\"></td>"+
			"	</tr>"+
			"	<tr>"+
			"		<td width=\"1\" bgcolor=\"#C6C6C6\"></td>"+
			"		<td width=\"91\" valign=\"top\" bgcolor=\"#ffffff\" align=\"center\">"+
			"			<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"89\">"+
			"	<tr>"+
			"		<td height='20' align='center' bgcolor='#E4E4E4' style='padding-top:3'><span id='UserBlogIdInfo' name='UserBlogIdInfo'></span></td>"+
			"	</tr>"+
			"	<tr>"+
			"		<td height='1' background='/image/common/dot_03.gif'></td>"+
			"	</tr>"+
			"				<tr>"+
			"					<td height=\"2\"></td>"+
			"				</tr> "+
			"				<tr>"+
			"					<td><a href=\"#\"  onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('ShowblogInfo_aa','','/image/common/hidden_m_01_over.gif',1)\"><img name=\"ShowblogInfo_aa\" src=\"/image/common/hidden_m_01.gif\" onclick=\"exec_menuitem('EVENT1');\" alt=\"\" border=\"0\"></a></td>"+
			"				</tr>"+
			"				<tr>"+
			"					<td height=\"2\"></td>"+
			"				</tr>"+
			"				<tr>"+
			"					<td><a href=\"#\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('ShowblogInfo_bb','','/image/common/hidden_m_02_over.gif',1)\"><img name=\"ShowblogInfo_bb\" src=\"/image/common/hidden_m_02.gif\" onclick=\"exec_menuitem('EVENT2');\" alt=\"\" border=\"0\" ></a></td>"+
			"				</tr>"+
			"				<tr>"+
			"					<td height=\"2\"></td>"+
			"				</tr>"+
			"				<tr>"+
			"					<td><a href=\"#\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('ShowblogInfo_cc','','/image/common/hidden_m_03_over.gif',1)\"><img name=\"ShowblogInfo_cc\" src=\"/image/common/hidden_m_03.gif\" alt=\"\" onclick=\"exec_menuitem('EVENT3');\" border=\"0\"></a></td>"+
			"				</tr>"+
			"				<tr>"+
			"					<td height=\"2\"></td>"+
			"				</tr>"+
			"				<tr>"+
			"					<td><a href=\"#\" onMouseOut=\"MM_swapImgRestore()\" onMouseOver=\"MM_swapImage('ShowblogInfo_ee','','/image/common/hidden_m_05_over.gif',1)\"><img name=\"ShowblogInfo_ee\" src=\"/image/common/hidden_m_05.gif\" alt=\"\" onclick=\"exec_menuitem('EVENT5');\" border=\"0\"></a></td>"+
			"				</tr>"+
			"			</table>"+
			"		</td>"+
			"		<td width=\"1\" bgcolor=\"#C6C6C6\"></td>"+
			"	</tr>"+
			"	<tr>"+
			"		<td colspan=\"3\"><img src=\"/image/common/hidden_menu_bottom.gif\" alt=\"\" border=\"0\" align=\"absmiddle\"></td>"+
			"	</tr>"+
			"</table></td></tr></table>"+
		"</div>");

