function addTip(divid,txt)
{
	if(document.getElementById(divid) || divid.substring(0,1)==".")
	{
		if(!document.getElementById("appends"))
		{
			var newdiv = document.createElement('div');
			newdiv.setAttribute('id','appends');
			document.body.appendChild(newdiv);
		}
		if(divid.substring(0,1)==".")
		{
			// class not id
			$(divid).bind("mouseenter",function(e){showTip(txt,e,this.id);});
			$(divid).bind("mouseleave",function(e){killTip();});
		}
		else
		{
			$("#"+divid).bind("mouseenter",function(e){showTip(txt,e,this.id);});
			$("#"+divid).bind("mouseleave",function(e){killTip();});
		}
	}
}
function removeTip(divid)
{
	if(el(divid)  || divid.substring(0,1)==".")
	{
		if(divid.substring(0,1)==".")
		{
			// class not id
			$(divid).unbind("mouseenter");
			$(divid).unbind("mouseleave");
		}
		else
		{
			$("#"+divid).unbind("mouseenter");
			$("#"+divid).unbind("mouseleave");
		}
	}
}
function showTip(tooltext, event,divid)
{
	if(!document.getElementById("appends"))
	{
		var newdiv = document.createElement('div');
		newdiv.setAttribute('id','appends');
		document.body.appendChild(newdiv);
	}
	if(tooltext)
	{
		killTip();
		if(!el("tooltip"))
		{
			// create new div element
			addEl("div","tooltip","appends");
			addEl("div","tooltip_shadow","appends");
			
			// set the text
			el("tooltip").innerHTML=tooltext;

			// grab mouse x and y
			
			var xpos=event.clientX;
			var ypos=event.clientY;
			
			// offset y by scroll
			ypos+=getScrollY();
			
			// check if going left or right
			var tmp1=screen.width-10;
			var tmp2=xpos+el("tooltip").offsetWidth;
			if(tmp1>tmp2)
			{
				xpos+=10;
				ypos+=10;
			}
			else
			{
				xpos-=10;
				//offset by tool width, due to flicker issue
				xpos-=el("tooltip").offsetWidth;
				ypos-=10;
			}
						
			// set pos to the new coords
			if(el(divid))
			{
				if($("#"+divid).hasClass("mini_img"))
					xpos=150;
			}
			el("tooltip").style.left=xpos+"px";
			el("tooltip").style.top=ypos+"px";
			//el("tooltip").style.width=(tooltext.length*8)+"px";
			
			el("tooltip_shadow").style.left=(xpos+3)+"px"
			el("tooltip_shadow").style.top=(ypos+3)+"px";
			
			el("tooltip_shadow").style.width=el("tooltip").offsetWidth+"px";
			el("tooltip_shadow").style.height=el("tooltip").offsetHeight+"px";
		}
	}
	
}
function killTip()
{
	
	if(el("tooltip"))
	{
		rmEl("tooltip","appends");
		rmEl("tooltip_shadow","appends");
	}
}
function getScrollY()
{
	var scrOfY = 0;
	try{
	if( typeof( window.pageYOffset ) == 'number' )
	{
		//Netscape compliant
		scrOfY = window.pageYOffset;

	}
	else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) )
	{
		//DOM compliant
		scrOfY = document.body.scrollTop;

	}
	else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) )
	{
		//IE6 standards compliant mode
		scrOfY = document.documentElement.scrollTop;
	
	}
	return scrOfY;
	}catch(ee){}
}
function getWidth()
{
	var widChk = document.createElement('div');
	widChk.setAttribute('style', 'height:100%;width:100%;position:fixed;');
	widChk.setAttribute('id','wid');
	document.body.appendChild(widChk);

	var tmpw=document.getElementById("wid").offsetWidth;
	tmpw=tmpw-5;
	document.body.removeChild(document.getElementById("wid"));
	return tmpw;
}
