
var dxhaction = new Array();
var popside_x = 10;   // 弹出窗口位于鼠标左侧或者右侧的距离；3-12 合适
var dxhtimeout = 500;
var e_m;

function ducepopupinit(event){
	try{
		if(event.srcElement) o = event.srcElement; else o = event.target;
		if(o.id != dxhaction['id']){
			dxhaction['id'] = o.id;
			if(dxhaction['id'].indexOf('thread_') != -1 || dxhaction['id'].indexOf('rank_') != -1){
				var showid = 'duce' + dxhaction['id'];

				dxhaction['showid'] = showid;
				dxhaction['offset'] = dxhaction['id'].indexOf('rank_') != -1 ? 1 : 0;
				dxhaction['ex'] = event.clientX;
				
				dxhimer['poptitle'] = setTimeout("ducetomouseloc()", dxhtimeout);

				if(!o.onmouseover) {
					o.onmouseout = function() {
						$(showid).style.display = 'none';
						clearTimeout(dxhimer['poptitle']);
					}
				}
				if(!$(showid).onmouseover) {
					$(showid).onmouseover = function() {
						this.style.display = 'block';
					}
					$(showid).onmouseout = function() { 
						this.style.display = 'none';
						clearTimeout(dxhimer['poptitle']);
					}
				}
			}
		}
	}catch(e){return true}
}

function ducetomouseloc(){
	try{
		var showobj = $(dxhaction['showid']);
		if(!showobj || showobj.innerHTML == '') return;
		var menuobj = $(dxhaction['id']);
		showobj.style.display = 'block';
		menuobj.pos = fetchOffset(menuobj);
		showobj.X = dxhaction['ex'] + popside_x;
		showobj.Y = menuobj.pos['top'];		

		showobj.w = showobj.offsetWidth;
		showobj.h = showobj.offsetHeight;
		menuobj.w = menuobj.offsetWidth;
		menuobj.h = menuobj.offsetHeight;

		var bdtop = document.documentElement.scrollTop + document.documentElement.clientHeight;
		var bdleft = document.body.clientWidth;

		if(!dxhaction['offset']){
			if(showobj.X > menuobj.w + menuobj.pos['left'] - popside_x*2){
				showobj.X = menuobj.w + menuobj.pos['left'] - popside_x*2;
			}
			showobj.style.left = (showobj.X + showobj.w > document.body.clientWidth) && (showobj.X - showobj.w - popside_x >= 0) ? showobj.X - showobj.w - popside_x + 'px' : showobj.X + 'px';
			showobj.style.top = showobj.Y + showobj.h > document.documentElement.scrollTop + document.documentElement.clientHeight ? showobj.Y - showobj.h + 1 + 'px' : showobj.Y + (BROWSER['moz'] ? 15 : 14) + 'px';
		}else if(dxhaction['offset'] == 1){
			showobj.style.left = menuobj.pos['left'] + showobj.w + menuobj.w + 5 > document.body.clientWidth ? menuobj.pos['left'] - showobj.w - 3 + 'px' : menuobj.pos['left'] + menuobj.w + 5 + 'px';
			showobj.style.top = showobj.Y + showobj.h - menuobj.h > document.documentElement.scrollTop + document.documentElement.clientHeight ? showobj.Y - showobj.h + menuobj.h + 'px' : showobj.Y + 'px';
		}
	}catch(e){}
}

if(!document.onmouseover) {
	document.onmouseover = function(e) {
		if (!e) ducepopupinit(window.event); else ducepopupinit(e);
	};
}

function ducerandstr(num) { 
	var seedArray = new Array('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','0','1','2','3','4','5','6','7','8','9');
	var seedStr = '';
	for (i=0;i<num;i++) {
		seedStr += seedArray[Math.round(Math.random()*(seedArray.length-1))];
	}
	return(seedStr);
}
