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", "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 = "#888888";
var menuover_fgcolor = "#f5f5f5";
var default_menuover_bgcolor = "#f5f5f5";
var default_menuover_fgcolor = "#000000"; 

var isView = 0;

var userid = "";
var ggurl = "";
var serverIP = "";
var gid = "";


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 ProfilePreloadImages() { //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=ProfilePreloadImages.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 menuOver(ar_obj, ar_id)
{
	status_over = true;
	hideChild(event_id);
	viewSubMenu(event, ar_obj, ar_id);
}

function LyrMenu()
{
	isView = 1;
}

function SetParam(id, urlnm, server, sessionid) 
{
	userid = id;
	ggurl = urlnm;
	serverIP  = server;
	gid = sessionid;
	
	// ¾ÆÀÌÄÜ ÀÌ¹ÌÁö ·Îµå
	ProfilePreloadImages("/main/img/icon_view_gallog.gif", "/main/img/icon_view_profile.gif", "/main/img/icon_friend_add.gif");
}


function MouseDown(e) 
{
	event_target = event.srcElement;
	event_target = event_target.toString();
	
	if (!status_over)
		hideAll();
	if(!event_target.indexOf("javascript:LyrMenu("))
	//if (isView == 1)
	{
		
		if(document.layers)
		{
			document.layers["menu_parent"].innerHTML = 
				"<TABLE borderColor=#000000 cellSpacing=0 cellPadding=0 border=1 bgcolor='#FFFFFF' width='100'>" +
				"<TR><TD height='3'></TD></TR>" +
				"<TR><TD onmouseover=\"menuOver(this, 'none');\" style=\"FONT-SIZE: 9pt; LEFT: 0px; CURSOR: hand; TOP: 0px\" onmouseout=\"menuOut(this);\" borderColor=#F5F5F5>" +
				"	<TABLE cellSpacing=0 cellPadding=2 width=\"100%\" align=left border=0>" +
				"	<TR OnMouseOver=\"this.style.backgroundColor='#EEEEEE'\" OnMouseOut=\"this.style.backgroundColor='#FFFFFF'\">" +
				"		<TD height='20'><img src='/main/img/icon_view_gallog.gif' width='13' height='13'></TD>" +
				"		<TD valign='bottom'><a href='#' onclick=\"OpenWin('" + serverIP + "/GallogHome.html?ggUrlNm=" + ggurl + "&gid=" + gid + "', 800, 600)\"><span class='dotum_11'>°¶·Î±×º¸±â</a></TD>" +
				"	</TR></TABLE>" +
				"</TD></TR>" +
				"<TR><TD onmouseover=\"menuOver(this, 'none');\" style=\"FONT-SIZE: 9pt; LEFT: 0px; CURSOR: hand; TOP: 0px\" onmouseout=\"menuOut(this);\" borderColor=#F5F5F5>" +
				"	<TABLE cellSpacing=0 cellPadding=2 width=\"100%\" align=left border=0>" +
				"	<TR OnMouseOver=\"this.style.backgroundColor='#EEEEEE'\" OnMouseOut=\"this.style.backgroundColor='#FFFFFF'\">" +
				"		<TD height='20'><img src='/main/img/icon_view_profile.gif' width='13' height='13'></TD>" +
				"		<TD valign='bottom'><a href='#' onclick=\"OpenWin('" + serverIP + "/GallogHome.html?ggUrlNm=" + ggurl + "&gid=" + gid + "&url=/main/profile/ProfileHome.html', 800, 600)\"><span class='dotum_11'>ÇÁ·ÎÇÊº¸±â</a></TD>" +
				"	</TR></TABLE>" +
				"</TD></TR>" +
				"<TR><TD onmouseover=\"menuOver(this, 'none');\" style=\"FONT-SIZE: 9pt; LEFT: 0px; CURSOR: hand; TOP: 0px\" onmouseout=\"menuOut(this);\" borderColor=#F5F5F5>" +
				"	<TABLE cellSpacing=0 cellPadding=2 width=\"100%\" align=left border=0>" +
				"	<TR OnMouseOver=\"this.style.backgroundColor='#EEEEEE'\" OnMouseOut=\"this.style.backgroundColor='#FFFFFF'\">" +
				"		<TD height='20'><img src='/main/img/icon_friend_add.gif' width='13' height='13'></TD>" +
				"		<TD valign='bottom'>&nbsp;<a href='#' onclick=\"OpenWin('" + serverIP + "/actions/Friend/AddGallogFriendInfo.php?ggUrlNm=" + ggurl + "', 100, 100, 'AddFriend')\"><span class='dotum_11'>°ü½ÉÄ£±¸µî·Ï</a></TD>" +
				"	</TR></TABLE>" +
				"</TD></TR>" +
				"<TR><TD height='3'></TD></TR>" +
				"</TABLE></TD></TR></TABLE>";
				
		} else if (document.all)
		{
			document.all["menu_parent"].innerHTML = 
				"<TABLE borderColor=#000000 cellSpacing=0 cellPadding=0 border=1 bgcolor='#FFFFFF' width='100'>" +
				"<TR><TD height='3'></TD></TR>" +
				"<TR><TD onmouseover=\"menuOver(this, 'none');\" style=\"FONT-SIZE: 9pt; LEFT: 0px; CURSOR: hand; TOP: 0px\" onmouseout=\"menuOut(this);\" borderColor=#F5F5F5>" +
				"	<TABLE cellSpacing=0 cellPadding=2 width=\"100%\" align=left border=0>" +
				"	<TR OnMouseOver=\"this.style.backgroundColor='#EEEEEE'\" OnMouseOut=\"this.style.backgroundColor='#FFFFFF'\">" +
				"		<TD height='20'><img src='/main/img/icon_view_gallog.gif' width='13' height='13'></TD>" +
				"		<TD valign='bottom'><a href='#' onclick=\"OpenWin('" + serverIP + "/GallogHome.html?ggUrlNm=" + ggurl + "&gid=" + gid + "', 800, 600)\"><span class='dotum_11'>°¶·Î±×º¸±â</a></TD>" +
				"	</TR></TABLE>" +
				"</TD></TR>" +
				"<TR><TD onmouseover=\"menuOver(this, 'none');\" style=\"FONT-SIZE: 9pt; LEFT: 0px; CURSOR: hand; TOP: 0px\" onmouseout=\"menuOut(this);\" borderColor=#F5F5F5>" +
				"	<TABLE cellSpacing=0 cellPadding=2 width=\"100%\" align=left border=0>" +
				"	<TR OnMouseOver=\"this.style.backgroundColor='#EEEEEE'\" OnMouseOut=\"this.style.backgroundColor='#FFFFFF'\">" +
				"		<TD height='20'><img src='/main/img/icon_view_profile.gif' width='13' height='13'></TD>" +
				"		<TD valign='bottom'><a href='#' onclick=\"OpenWin('" + serverIP + "/GallogHome.html?ggUrlNm=" + ggurl + "&gid=" + gid + "&url=/main/profile/ProfileHome.html', 800, 600)\"><span class='dotum_11'>ÇÁ·ÎÇÊº¸±â</a></TD>" +
				"	</TR></TABLE>" +
				"</TD></TR>" +
				"<TR><TD onmouseover=\"menuOver(this, 'none');\" style=\"FONT-SIZE: 9pt; LEFT: 0px; CURSOR: hand; TOP: 0px\" onmouseout=\"menuOut(this);\" borderColor=#F5F5F5>" +
				"	<TABLE cellSpacing=0 cellPadding=2 width=\"100%\" align=left border=0>" +
				"	<TR OnMouseOver=\"this.style.backgroundColor='#EEEEEE'\" OnMouseOut=\"this.style.backgroundColor='#FFFFFF'\">" +
				"		<TD height='20'><img src='/main/img/icon_friend_add.gif' width='13' height='13'></TD>" +
				"		<TD valign='bottom'>&nbsp;<a href='#' onclick=\"OpenWin('" + serverIP + "/actions/Friend/AddGallogFriendInfo.php?ggUrlNm=" + ggurl + "', 100, 100, 'AddFriend')\"><span class='dotum_11'>°ü½ÉÄ£±¸µî·Ï</a></TD>" +
				"	</TR></TABLE>" +
				"</TD></TR>" +
				"<TR><TD height='3'></TD></TR>" +
				"</TABLE></TD></TR></TABLE>";
		}
		
		viewMenu(event, "menu_parent");
		
		isView = 0;
		
	} 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("menu_parent.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;
} 

document.writeln("<DIV id='menu_parent' style='DISPLAY: none; LEFT: 0px; POSITION: absolute; TOP: 0px'></DIV>");