#####################################################
#  LEO SuperCool BBS / LeoBBS X / 雷傲極酷超級論壇  #
#####################################################
# 基於山鷹(糊)、花無缺製作的 LB5000 XP 2.30 免費版  #
#   新版程式製作 & 版權所有: 雷傲科技 (C)(R)2004    #
#####################################################
#      主頁地址： http://www.LeoBBS.com/            #
#      論壇地址： http://bbs.LeoBBS.com/            #
#####################################################

open (MSGIN, "${lbdir}$msgdir/in/${memberfilename}_msg.cgi");
sysread(MSGIN, $totalmessages,(stat(MSGIN))[7]);
close (MSGIN);
$totalmessages =~ s/\r//isg;
my @allmessages = split (/\n/, $totalmessages);
$totalmessages = @allmessages;
my @newmessages=grep(/^(.+)\tno\t/,@allmessages);
$unread = @newmessages;
if ($unread) {
    my $intanchumsg = $query->cookie("tanchumsg");
    my $popnew = qq~<script>if (confirm("你有新的短訊，是否打開收件箱查看？")) openScript("messanger.cgi?action=inbox",600,400);</script>~ if ((($newmsgpop eq "on")||($newmsgpop eq "popup"))&&($intanchumsg eq ""));
    my $lightnew = qq~<script language="JavaScript">pmBox.bgColor='Lightblue';setInterval("Timer()", 500);x=1;function Timer(){set=1;if(x==0 && set==1){pmBox.bgColor='Lightblue';x=1;set=0;}if(x==1 && set==1){pmBox.bgColor='';x=0;set=0;}}</script>~ if ((($newmsgpop eq "on")||($newmsgpop eq "light")));
    $newmail = qq(<table width=$tablewidth cellpadding=2 cellspacing=0 align=center><tr><td width="*"></td><td align=right id="pmBox" width=215><bgsound src=$imagesurl/images/mail.wav border=0>$lightnew$popnew<span style="cursor:hand" onClick="javascript:openScript('messanger.cgi?action=inbox',600,400)"><img src=$imagesurl/images/newmail.gif border=0><font color=$fonthighlight>你有 <B>$unread</B> 條新的短訊，請注意查收</font></span></td></tr></table>);
$newmail=qq~
<script language="JavaScript">
window.onload = getMsg;
window.onresize = resizeDiv;
window.onerror = function(){}
var divTop,divLeft,divWidth,divHeight,docHeight,docWidth,objTimer,i = 0;
function getMsg()
{
	try{
	divTop = parseInt(document.getElementById("eMeng").style.top,10)
	divLeft = parseInt(document.getElementById("eMeng").style.left,10)
	divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10)
	divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10)
	docWidth = document.body.clientWidth;
	docHeight = document.body.clientHeight;
	document.getElementById("eMeng").style.top = parseInt(document.body.scrollTop,10) + docHeight + 10;
	document.getElementById("eMeng").style.left = parseInt(document.body.scrollLeft,10) + docWidth - divWidth
	document.getElementById("eMeng").style.visibility="visible"
	objTimer = window.setInterval("moveDiv()",10)
	}
	catch(e){}
}

function resizeDiv()
{
	i+=1
	if(i>1000) closeDiv()
	try{
	divHeight = parseInt(document.getElementById("eMeng").offsetHeight,10)
	divWidth = parseInt(document.getElementById("eMeng").offsetWidth,10)
	docWidth = document.body.clientWidth;
	docHeight = document.body.clientHeight;
	document.getElementById("eMeng").style.top = docHeight - divHeight + parseInt(document.body.scrollTop,10)
	document.getElementById("eMeng").style.left = docWidth - divWidth + parseInt(document.body.scrollLeft,10)
	}
	catch(e){}
}

function moveDiv()
{
	try
	{
	if(parseInt(document.getElementById("eMeng").style.top,10) <= (docHeight - divHeight + parseInt(document.body.scrollTop,10)))
	{
	window.clearInterval(objTimer)
	objTimer = window.setInterval("resizeDiv()",1)
	}
	divTop = parseInt(document.getElementById("eMeng").style.top,10)
	document.getElementById("eMeng").style.top = divTop - 1
	}
	catch(e){}
}
function closeDiv()
{
	document.getElementById('eMeng').style.visibility='hidden';
	if(objTimer) window.clearInterval(objTimer)
}
</script>
<DIV id=eMeng style="BORDER-RIGHT: #455690 0px solid; BORDER-TOP: #a6b4cf 0px solid; Z-INDEX:99999; LEFT: 1px; VISIBILITY: hidden; BORDER-LEFT: #a6b4cf 0px solid; WIDTH: 180px; BORDER-BOTTOM: #455690 1px solid; POSITION: absolute; TOP: 0px; HEIGHT: 114px">
	<TABLE style="BORDER-TOP: #ffffff 0px solid; BORDER-LEFT: #ffffff 0px solid" cellSpacing=0 cellPadding=0 width="100%" border=0 background="$imagesurl/pm/msn6.gif">
	<TBODY>
		<TR>
		<TD style="FONT-SIZE: 12px; COLOR: #000000" width=30 height=23></TD>
		<TD style="FONT-WEIGHT: normal; FONT-SIZE: 12px; COLOR: #000000; PADDING-TOP: 4px;PADDING-left: 25px" vAlign=center width="100%" class="nav"><b>Leobbs X! Messenger</b></TD>
		<TD style="PADDING-TOP: 2px;PADDING-right:2px" vAlign=center align=right width=16><span title=關閉 style="CURSOR: hand;color:red;font-size:12px;font-weight:bold;margin-right:4px;" onclick=closeDiv() >&nbsp;&nbsp;&nbsp;</span></TD>
		</TR>
		<TR>
		<TD style="PADDING-RIGHT: 0px; PADDING-BOTTOM: 0px" colSpan=3 height=91>
		<DIV style="BORDER-RIGHT: #b9c9ef 0px solid; PADDING-RIGHT: 13px; BORDER-TOP: #728eb8 0px solid; PADDING-LEFT: 13px; FONT-SIZE: 12px; PADDING-BOTTOM: 13px; BORDER-LEFT: #728eb8 0px solid; WIDTH: 100%; COLOR: #000000; PADDING-TOP: 18px; BORDER-BOTTOM: #b9c9ef 0px solid; HEIGHT: 100%">
          <p align="center">你有新的短訊<BR>
		  </p>
		<DIV align=center style="word-break:break-all"><span style="cursor:hand" onClick="javascript:openScript('messanger.cgi?action=inbox',420,320)"><font color=#000000>&nbsp;&nbsp;&nbsp;立即查看短消息。</font></span></DIV>
		</DIV>
		</TD>
		</TR>
	</TBODY>
	</TABLE>
</DIV>
<bgsound src="$imagesurl/pm/mail.wav" border="0">
~ if ($newmsgpop eq "msn");

}
#寫入 cache
open (FILE, ">${lbdir}cache/mymsg/$memberfilename.pl");
print FILE qq~\$totalmessages = $totalmessages;\n~;
print FILE qq~\$unread = $unread;\n~;
print FILE qq~\$newmail = qq($newmail);\n~;
print FILE "1;\n";
close (FILE);
1;
