/******************************************************************************
  Crossday Discuz! Board - Common Modules for Discuz!
  Copyright 2001-2006 Comsenz Inc. (http://www.comsenz.com)
*******************************************************************************/
var sPop = null;
var pltsoffsetX = 10;   // 弹出窗口位于鼠标左侧或者右侧的距离；3-12 合适
var pltsoffsetY = 15;  // 弹出窗口位于鼠标下方的距离；3-12 合适

document.write('\
	<style type="text/css"> \
	#popLayer { \
	position:absolute; \
	Z-INDEX: 1000; \
	text-align : left; \
	white-space: nowrap; \
	font-family: Tahoma, Verdana; \
	visibility: hidden; \
	} \
	</style> \
	<div id="popLayer" class="popupmenu_popup" nowrap></div> \
');

function showPopupText(event) {
	try{
		if(event.srcElement) o = event.srcElement; else o = event.target;
		if(o.alt!=null && o.alt!="") { o.pop=o.alt;o.alt="" }
		if(o.title!=null && o.title!=""){ o.pop=o.title;o.title="" }
		if(o.pop!=sPop) {
			sPop=o.pop;
			if(sPop==null || sPop=="") {
				$("popLayer").style.visibility="hidden";
				$("popLayer").innerHTML = '';
			} else {
				$("popLayer").style.visibility="visible";
				$("popLayer").innerHTML = sPop.replace(/<(.*)>/g,"&lt;$1&gt;").replace(/\n/g,"<br />");
				moveToMouseLoc(event);
			}
		}
	}catch (e){return true}
}

function moveToMouseLoc(event){
	try{
		if($("popLayer").innerHTML=='') return true;
		var MouseX = event.clientX;
		var MouseY = event.clientY;
		var popHeight = $("popLayer").offsetHeight;
		var popWidth = $("popLayer").offsetWidth;
		if(MouseY+pltsoffsetY+popHeight>document.documentElement.clientHeight-10) {
			popTopAdjust =- popHeight-pltsoffsetY*1.5; 
		}else{
			popTopAdjust=0;
		}
		if(MouseX+pltsoffsetX+popWidth>document.documentElement.clientWidth-10) {
			popLeftAdjust = -popWidth-pltsoffsetX*2; 
		}else{
			popLeftAdjust = 0;
		}
		var pleft = MouseX+pltsoffsetX+document.documentElement.scrollLeft+popLeftAdjust;
		var ptop = MouseY+pltsoffsetY+document.documentElement.scrollTop+popTopAdjust
		$("popLayer").style.left = (pleft>5 ? pleft : 5) + 'px';
		$("popLayer").style.top = (ptop>5 ? ptop : 5) + 'px';
	  	return true;
	}catch (e){return true}
}

if(!document.onmouseover) {
	document.onmouseover = function(e) {
		if (!e) showPopupText(window.event); else showPopupText(e);
	};
	//document.onmousemove = moveToMouseLoc;
}
