<?php
/************************************************************/
/*	                     RUNCMS                             */
/* Relaible - Unique - Nocost &  Simplicity & ease off use  */
/*              < http://www.runcms.org >                   */
/************************************************************/
// Original Author: Half-Dead
// Author Website : http://www.e-xoops.com
// License Type   : LGPL: See /manual/LICENSES/LGPL.txt
// ------------------------------------------------------------------------- //


//---------------------------------------------------------------------------------------//
/**
* Description
*
* @param type $var description
* @return type description
*/
function b_pmessages_show() {
global $db, $xoopsUser;

if (!$xoopsUser) {
	return FALSE;
}

$block            = array();
$block['title']   = _PM_PRIVMSGS;

list($total_messages) = $db->fetch_row($db->query("SELECT COUNT(*) FROM ".$db->prefix("private_msgs")." WHERE to_userid = ".$xoopsUser->getVar("uid").""));
list($new_messages)   = $db->fetch_row($db->query("SELECT COUNT(*) FROM ".$db->prefix("private_msgs")." WHERE to_userid = ".$xoopsUser->getVar("uid")." AND read_msg=0"));

if ($total_messages > 0) {
	if ($new_messages > 0) {

		$block['content'] .= "<img src='".XOOPS_URL."/modules/messages/images/more.gif'>".$new_messages." <a id='msgtxt' href='".XOOPS_URL."/modules/messages/' onmouseover='setBlink(0);' onmouseout='setBlink(1);'><b>"._PM_NEW."</b></a><br />";
		if ( !defined('EXOOPS_PM_INCLUDED') ) {
			$block['content'] .= "<bgsound src='".XOOPS_URL."/modules/messages/images/msg.wav' loop='false'>";
		}
		$block['content'] .= '
					<script type="text/javascript">
					<!--
					var blink    = 1;
					var blinkdom = xoopsGetElementById("msgtxt");

					function blink1() {
					blinkdom.style.visibility = "hidden";
					if (blink == 1) {
						setTimeout("blink2()", 500);
						} else {
							blinkdom.style.visibility = "visible";
						}
					}

					function blink2() {
					blinkdom.style.visibility = "visible";
					if (blink == 1) {
						setTimeout("blink1()", 1000);
					}
					}

					function setBlink(val) {
					blink = val;
					blink1();
					}

					setBlink(1);
					
					 

					//-->
					</script>';

		} else {
			$block['content'] .= _PM_NONEW." <br /> ";
		}
	$block['content'] .= "<img src='".XOOPS_URL."/modules/messages/images/new.gif'>".$total_messages." <a href='".XOOPS_URL."/modules/messages/'>"._PM_TOT."</a>";
	} else {
		$block['content'] .= "<a href='".XOOPS_URL."/modules/messages/'>"._PM_NONEW."</a>";
	}
$block['content'] .= "<br /><br /><img src='".XOOPS_URL."/modules/messages/images/em.gif'>&nbsp;<a href='".XOOPS_URL."/modules/messages/index.php'>"._PM_SEND."</a>";

return $block;
}
?>
