﻿
var blnLogin = false;

var strMemberDir;
var strContentDir;
var strCurUrl;
var intBaseUserSeq;
var strBaseUserNick;
var intClickUserSeq;
var strClickUserNick;
var intCurDepth;

function ClickNickName(slogin, sMemberDir, sContentDir, sCurURL, sBaseSeq, sBaseNick, sClickSeq, sClickNick, sCurDepth)
{
	blnLogin = slogin;	
	strMemberDir = sMemberDir;
	strCurUrl = sCurURL;
	strContentDir = sContentDir;
	intBaseUserSeq = sBaseSeq;
	strBaseUserNick = sBaseNick;
	intClickUserSeq = sClickSeq;
	strClickUserNick = sClickNick;
	intCurDepth = sCurDepth;
/*
	if (document.all.DivRightMenu.style.display == "none")
	{
		document.all.DivRightMenu.style.top = event.y;
		document.all.DivRightMenu.style.left = event.x;
		document.all.DivRightMenu.style.display = "";
	}
	else
	{
		document.all.DivRightMenu.style.display = "none";	
	}
	*/
}

function ViewRightMenu(intSel)
{
	if (intSel == 1)
	{
		var intTempLeft = window.document.body.offsetWidth - event.x;
		var intLeft = event.x;
		var intTempTop = window.document.body.offsetHeight - event.y;
		var intTop = event.y;
		
		if(intTempTop < 142)
		{
			intTop = window.document.body.offsetHeight - 142;
		}
		
		if(intTempLeft < 150)
		{
			intLeft = window.document.body.offsetWidth - 150;
		}
		
		if(window.document.body.scrollTop != 0)
		{
			intTop += window.document.body.scrollTop;	
		}
		
		//alert(window.document.body.scrollTop);
		
		document.all.DivRightMenu.style.top = intTop;
		document.all.DivRightMenu.style.left = intLeft;
		document.all.DivRightMenu.style.display = "";
	}
	else
	{
		document.all.DivRightMenu.style.display = "none";
	}
}

function OverReightMenu(sthis)
{
	//alert(sthis);
	sthis.className = 'board_bar_02';
	sthis.style.cursor = 'hand';
}

function OutReightMenu(sthis)
{
	//alert(sthis);
	sthis.className = 'menu_text';
	sthis.style.cursor = 'hand';
}

function ProcessRightMenu(smsg)
{
	if(!blnLogin)
	{
		ConfirmLogin(intCurDepth, strMemberDir, strCurUrl);
	}
	else
	{
		switch(smsg) 
		{
			case "VIEW_USERINFO" :
				ViewUserInfo();
				break;
			case "SEND_MESSAGE" :
				SendMessage();
				break;
			case "REJECT_MESSAGE" :
				RejectMessage();
				break;
			case "REPORT_USER" :
				ReportUser();
				break;
			case "INVITE_CLUB" :
				InviteClub();
				break;
		}
	}
}

function InviteClub()
{
	if(strClickUserNick == "")
	{
		ConfirmMakeNickName(intCurDepth, strMemberDir, strCurUrl, false);
	}
	else
	{
		var winW = 350;
		var winH = 255;
		
		var winL = (screen.width - winW) / 2;
		var winT = (screen.height - winH) / 2;
	
		top.location.href=strContentDir + "Main/prClubReg.asp?intCode="+intBaseUserSeq+"&strNick="+escape(strBaseUserNick);
	}	
}

function ReportUser() 
{
	if(intCurDepth == 1)
	{
		location.href='http://www.wpark.com.tw/ServiceCenter/ASK/default.asp';
	}
	else if(intCurDepth == 2)
	{
		parent.location.href = 'http://www.wpark.com.tw/ServiceCenter/ASK/default.asp';
	}
	else
	{
		top.location.href='http://www.wpark.com.tw/ServiceCenter/ASK/default.asp';
	}
	
}

function SendMessage()
{
	if(strClickUserNick == "")
	{
		ConfirmMakeNickName(intCurDepth, strMemberDir, strCurUrl, false);
	}
	else
	{
		var winW = 350;
		var winH = 255;
		
		var winL = (screen.width - winW) / 2;
		var winT = (screen.height - winH) / 2;
	
		window.open(strContentDir + "Common/sendMessageFrm.asp?intCode="+intBaseUserSeq+"&strNick="+escape(strBaseUserNick),"popWin","width=" + winW + ",height=" + winH + ",scrollbars=no,resizable=no,top=" + winT + ", left=" + winL);
	}
}

function RejectMessage()
{
	if(strClickUserNick == "")
	{
		ConfirmMakeNickName(intCurDepth, strMemberDir, strCurUrl, false);
	}
	else
	{
		if (window.confirm(strBaseUserNick+"會員訊息 \n\n封鎖嗎?")) 
		{	
			window.open(strContentDir + "MyPage/Message/rejectMessage.asp?intCode="+intBaseUserSeq+"&strNick="+escape(strBaseUserNick), "popWin", "width=10,height=10,scrollbars=no,resizable=no,left=10000");
		}
	}
}

function ViewUserInfo()
{
	var winW = 350;
	var winH = 217;
	
	var winL = (screen.width - winW) / 2;
	var winT = (screen.height - winH) / 2;
	
	window.open(strContentDir+"Common/viewIntroduction.asp?intCode="+intBaseUserSeq+"&strNick="+escape(strBaseUserNick),"popWin","width=" + winW + ",height=" + winH + ",scrollbars=no,resizable=no,top=" + winT + ", left=" + winL);
}

function MouseDown(e) 
{
	if (!e) e = window.event;
	
	event_target = e.srcElement;
	event_target = event_target.toString();
	event_check = event_target.indexOf("javascript:ClickNickName");        
    	
	if (!event_check) 
	{
		ViewRightMenu(1);
	}
	else 
	{
        ViewRightMenu(2);
	}
	
	ClearAllRightMenu();
}

document.onclick = MouseDown;
   
document.writeln ("<div id='DivRightMenu' style='position:absolute;display:none;top:0;left:0;z-index:10;'>");
document.writeln ("<table width='150' border='0' cellpadding='5' cellspacing='0' class='menu_frame'>");
document.writeln ("<tr>");
document.writeln ("<td width='140' align='center'>");
document.writeln ("	<table width='140' border='0' cellpadding='0' cellspacing='0' class='menu_back'>");
document.writeln ("	<tr class='menu_text'>");
document.writeln ("	<td height='5'></td>");
document.writeln ("	</tr>");
document.writeln ("	<tr>");
document.writeln ("	<td align='center'>");
document.writeln ("		<table width='140' border='0' cellpadding='0' cellspacing='0' class='menu_text'>");
document.writeln ("		<tr>");
document.writeln ("		<td height='20' class='menu_text' style='padding:0 0 0 10;cursor:hand' OnClick=\"ProcessRightMenu('VIEW_USERINFO')\" onmouseover='OverReightMenu(this)' onmouseout='OutReightMenu(this)'>查看會員介紹</td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("		<td height='5'></td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("		<td height='1' class='dot_line'></td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("		<td height='5'></td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("		<td height='20' class='menu_text' style='padding:0 0 0 10;cursor:hand' OnClick=\"ProcessRightMenu('SEND_MESSAGE')\" onmouseover='OverReightMenu(this)' onmouseout='OutReightMenu(this)'>傳遞訊息</td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("		<td height='20' class='menu_text' style='padding:0 0 0 10;cursor:hand' OnClick=\"ProcessRightMenu('REJECT_MESSAGE')\" onmouseover='OverReightMenu(this)' onmouseout='OutReightMenu(this)'>阻斷訊息</td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("          <td height='20' class='menu_text' style='padding:0 0 0 10;cursor:hand' OnClick=\"ProcessRightMenu('INVITE_CLUB')\" onmouseover='OverReightMenu(this)' onmouseout='OutReightMenu(this)'>宣傳Club</td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("		<td height='5'></td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("		<td height='1' class='dot_line'></td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("		<td height='5'></td>");
document.writeln ("		</tr>");
document.writeln ("		<tr>");
document.writeln ("		<td height='20' class='menu_text' style='padding:0 0 0 10;cursor:hand' OnClick=\"ProcessRightMenu('REPORT_USER')\" onmouseover='OverReightMenu(this)' onmouseout='OutReightMenu(this)'>申告</td>");
document.writeln ("		</tr>");
document.writeln ("		</table>");
document.writeln ("	</td>");
document.writeln ("	</tr>");
document.writeln ("	<tr class='menu_text'>");
document.writeln ("	<td height='5'></td>");
document.writeln ("	</tr>");
document.writeln ("	</table>");
document.writeln ("</td>");
document.writeln ("</tr>");
document.writeln ("</table>");
document.writeln ("</div>");