
var sweetTitles = { 
	xCord : 0,								// @Number: x pixel value of current cursor position
	yCord : 0,								// @Number: y pixel value of current cursor position
	tipElements : ['a'],					// @Array: Allowable elements that can have the toolTip
	obj : Object,							// @Element: That of which you're hovering over
	tip : Object,							// @Element: The actual toolTip itself
	active : 0,								// @Number: 0: Not Active || 1: Active
	init : function() {
		if ( !document.getElementById ||
			!document.createElement ||
			!document.getElementsByTagName ) {
			return;
		}
		var i,j;
		this.tip = document.createElement('div');
		this.tip.id = 'toolTip';
		document.getElementsByTagName('body')[0].appendChild(this.tip);
		this.tip.style.top = '0';
		this.tip.style.visibility = 'hidden';
		addEvent(this.tip,'mouseover',this.tipOver);
		addEvent(this.tip,'mouseout',this.tipOut);
		var tipLen = this.tipElements.length;
		for ( i=0; i<tipLen; i++ ) {
			var current = document.getElementsByTagName(this.tipElements[i]);
			var curLen = current.length;
			for ( j=0; j<curLen; j++ ) {
				addEvent(current[j],'mouseover',this.menuOver);
				addEvent(current[j],'mouseout',this.menuOut);
				current[j].setAttribute('tip',current[j].title);
				current[j].removeAttribute('title');
			}
		}
	},
	updateXY : function(e) {
		if ( document.captureEvents ) {
			sweetTitles.xCord = e.pageX;//firefox
			sweetTitles.yCord = e.pageY;
		} else if ( window.event.clientX ) {
			sweetTitles.xCord = window.event.clientX+document.body.scrollLeft;
			sweetTitles.yCord = window.event.clientY+document.body.scrollTop;
		}
	},
	tipOver: function() {
		sweetTitles.tip.style.visibility = 'visible';
	},
	tipOut: function() {
		sweetTitles.tip.style.visibility = 'hidden';
	},
	menuOut: function() {
		if ( window.tID ) {
			clearTimeout(tID);
		}
		if ( window.opacityID ) {
			clearTimeout(opacityID);
		}
	},
	menuOver : function(e) {
		sweetTitles.obj = this;
		if(this.getAttribute("tip") != ""){
			tID = window.setTimeout("sweetTitles.tipShow('')",500);
			sweetTitles.updateXY(e);
		}
		else
			sweetTitles.tip.style.visibility = 'hidden';
	},
	checkNode : function() {
		var trueObj = this.obj;
		if ( this.tipElements.inArray(trueObj.nodeName.toLowerCase()) ) {
			return trueObj;
		} else {
			return trueObj.parentNode;
		}
	},
	tipShow : function(type) {
		var scrX = Number(this.xCord);
		var scrY = Number(this.yCord);
		var tp = parseInt(scrY+5);
		var lt = parseInt(scrX+8);
		var anch = this.checkNode();
		
		var allNames = document.getElementsByTagName('input')[0].value;
		
		if(anch.getAttribute("tip") != "")
		{
			var name = anch.getAttribute("tip");
			var methodName = "";
			if(name == "投标项目信息")
				methodName = "projectBidder";
			else if(name == "我的质疑")
				methodName = "oppugn";
			else if(name == "评标公示")
				methodName = "announce";
			else if(name == "标书下载及购买记录")
				methodName = "filePurchase";
			else if(name == "开标一览表")
				methodName = "openBidRecord";
			else if(name == "公示结果公告")
				methodName = "result";
			else if(name == "参标项目信息")
				methodName = "stat";
			if(methodName != "")
			{	
				var regExp = new RegExp("balloon","g");
				allNames = allNames.replace(regExp,methodName);
			}	
		}
		var names = allNames.split("|");
		if(type == "all")//全部显示
		{
			allNames = allNames.replace(/[|]/g,"");
			allNames = allNames.substring(0,allNames.lastIndexOf("<div"));
			//lastOne = allNames.substring(allNames.lastIndexOf("<div"));
		}
		else//前十个
		{
			allNames = "";
			for(i=0;i<names.length;i++)
			{
				if(i == 10)
				{
					allNames += names[names.length-1];
					break;
				}
				allNames += names[i];
			}
			//alert("topTen = " + allNames);
		}
		this.tip.innerHTML = "<p>"+allNames+"</p>";
		
		this.tip.style.left = lt+'px';
		this.tip.style.top = tp+'px';
		
		this.tip.style.visibility = 'visible';
		this.tip.style.opacity = '1.0';
	}
};
function pageLoader() {
	sweetTitles.init();
}
function showMore()
{
	sweetTitles.tipShow('all');
}
addEvent(window,'load',pageLoader);
