﻿
var blnLogin = false;

var strMemberDir;
var strContentDir;
var strCurUrl;
var intBaseUserSeq;
var strBaseUserNick;
var intClickUserSeq;
var strClickUserNick;
var intCurDepth;
var strScrapTitle;
var strScrapFullUrl;

function ClickNickNameByContent(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;
}

function ClickMyPlus(slogin, sMemberDir, sContentDir, sCurURL, sClickSeq, sTitle, sFullContentUrl, sCurDepth)
{
	blnLogin = slogin;	
	strMemberDir = sMemberDir;
	strCurUrl = sCurURL;
	strContentDir = sContentDir;
	intClickUserSeq = sClickSeq;
	strScrapTitle = sTitle;
	strScrapFullUrl = sFullContentUrl;
	intCurDepth = sCurDepth;
}

function ViewRightMenu(intSel)
{
	if (intSel == 1)
	{
		document.all.DivRightMenuContent.style.top = event.y;
		document.all.DivRightMenuContent.style.left = event.x;
		document.all.DivRightMenuContent.style.display = "";
	}
	else
	{
		document.all.DivRightMenuContent.style.display = "none";
	}
}

function ViewMyPlus(intSel)
{
	if (intSel == 1)
	{
		document.all.DivRightMenuMyPlus.style.top = event.y;
		document.all.DivRightMenuMyPlus.style.left = 605;
		document.all.DivRightMenuMyPlus.style.display = "";
	}
	else
	{
		document.all.DivRightMenuMyPlus.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="+strBaseUserNick;
		//window.open(strContentDir + "Common/publicClubFrm.asp?intCode="+intBaseUserSeq+"&strNick="+strBaseUserNick,"popWin","width=" + winW + ",height=" + winH + ",scrollbars=no,resizable=no,top=" + winT + ", left=" + winL);
	}	
}

function ReportUser() 
{
	if(intCurDepth == 1)
	{
		top.location.href='http://www.wpark.com.tw/ServiceCenter/ASK/Default.asp';
		//location.href = strContentDir + "Support/UnifyReport/ReportInfo.asp?strReportKind=04";
	}
	else if(intCurDepth == 2)
	{
		top.location.href='http://www.wpark.com.tw/ServiceCenter/ASK/Default.asp';
		//parent.location.href = strContentDir + "Support/UnifyReport/ReportInfo.asp?strReportKind=04";
	}
	
}

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 ProcessMyPlusMenu(smsg)
{
	if(!blnLogin)
	{
		ConfirmLogin(intCurDepth, strMemberDir, strCurUrl);
	}
	else
	{
		switch(smsg) 
		{
			case "SCRAP_MYPLUS" :
				ScrapMyPlus();
				break;
			case "SCRAP_CLUB" :
				ScrapClub();
				break;
			case "SCRAP_PRINT" :
				ScrapPrint();
				break;
			case "SCRAP_EMAIL" :
				ScrapEmail();
				break;
		}
	}
}

function ScrapEmail()
{
	var winW = 400;
	var winH = 330;
		
	var winL = (screen.width - winW) / 2;
	var winT = (screen.height - winH) / 2;
		
	window.open("/Common/ClubScrapSendEmail.asp", "Scrap", "width=" + winW + ",height=" + winH + ",scrollbars=no,resizable=no,top=" + winT + ", left=" + winL);
}

function ScrapMyPlus()
{
	if(confirm("要將此文章複製到『我的收藏』嗎?"))
	{
		window.open(strContentDir + "MyPage/MyPlus/saveScrap.asp?strType=1&strTitle=" + strScrapTitle + "&strUrl=" + escape(strScrapFullUrl), "myplus", "scrollbars=no, menubars=no, status=no, width=10, height=10, left=10000");
	}
}

function ScrapClub()
{
	
	var winW = 300;
	var winH = 135;
		
	var winL = (screen.width - winW) / 2;
	var winT = (screen.height - winH) / 2;
		
	window.open("/Common/ClubScrap.asp?cluburl=" + strCurUrl, "Scrap", "width=" + winW + ",height=" + winH + ",scrollbars=no,resizable=no,top=" + winT + ", left=" + winL);
	
}

function ScrapPrint()
{
	if(confirm("要列印這篇文章嗎?"))
	{
		window.print();
	}
}

function MouseDown(e) 
{
	if (!e) e = window.event;
	
	event_target = e.srcElement;
	event_target = event_target.toString();
	
    	var intSel
    	
    	event_check = event_target.indexOf("javascript:ClickNickNameByContent");
    	
    	if(event_check != -1)
    	{
    		intSel = 1;	
    	}
    	else
    	{
    		event_check = event_target.indexOf("javascript:ClickMyPlus");
    		
    		if(event_check != -1)
    		{
    			intSel = 2;	
    		}
    	}
    	
	if (!event_check) 
	{
		if(intSel == 1)
		{
			ViewRightMenu(1);
		}
		else
		{
			ViewMyPlus(1);
		}
	}
	else 
	{
		ViewMyPlus(2);
		ViewRightMenu(2);
	}
	
	ClearAllRightMenu();
}

document.onclick = MouseDown;
   
document.writeln ("<div id='DivRightMenuContent' 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('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)'>宣傳俱樂部</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>");

document.writeln ("<div id='DivRightMenuMyPlus' 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=\"ProcessMyPlusMenu('SCRAP_MYPLUS')\" 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 ("		<tr>");
document.writeln ("		<td height='20' class='menu_text' style='padding:0 0 0 10;cursor:hand' OnClick=\"ProcessMyPlusMenu('SCRAP_PRINT')\" 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>");
