var tooltipIsVisible=false
var tooltipIsFading=false

var tipobj = top.document.getElementById("tooltip") 
var tipobjContent = top.document.getElementById("tooltipContent") 

function posTooltip2(){
	if (tooltipIsVisible && !closeTooltip){
		//top.document.getCoordinates();
		var a;
		var b;
		//left=parent.parent.parent.document.getElementById("topContainer").offsetLeft
		//var curX=event.x + left
		var curX=event.x + top.mainPosition.offsetLeft
		var curY=event.y + top.mainPosition.offsetTop
		
		tipobj.style.left=curX + "px"
		tipobj.style.top=curY + 45 + "px"
		fadeIn();
	}
}

var offsetxpoint = 0
var offsetypoint = 45

offsetypoint = (parent == top)? 25:45;

offsetypoint = 25;

function posTooltip(){
if (!e) var e = window.event;

		//var curX = event.x + top.document.body.scrollLeft;
	//	var curY = event.y + top.document.body.scrollTop;
		//var curX=event.x + top.mainPosition.offsetLeft + 155
		//var curX=event.x + top.mainPosition.clientLeft +155 //+ 155
		var curX = e.clientX + top.mainPosition.offsetLeft //+ 155
		//var curY=event.y + top.mainPosition.offsetTop
		var curY = e.clientY + top.mainPosition.offsetTop
		
		if (parent.columnA != null){
			curX += parent.columnA.offsetLeft
		}
		
		var rightedge = top.document.body.clientWidth - curX - offsetxpoint
		var bottomedge = top.document.body.clientHeight - curY - offsetypoint
		var leftedge = (offsetxpoint<0)? offsetxpoint*(-1) : -1000
		
		if (rightedge<tipobj.offsetWidth)
			tipobj.style.left = top.document.body.clientWidth - tipobj.offsetWidth +"px"
		else if (curX<leftedge)
			tipobj.style.left = "0px"
		else
			tipobj.style.left = curX + offsetxpoint + "px"
		
		if (bottomedge<tipobj.offsetHeight)
			//tipobj.style.top = top.document.body.scrollTop + event.clientY - tipobj.offsetHeight +"px"
			tipobj.style.top = curY - tipobj.offsetHeight - 30 + "px"
		else
			tipobj.style.top = curY + offsetypoint + "px"
			
		fadeIn();
}


function posTooltip2(){
		//var curX = event.x + top.document.body.scrollLeft;
	//	var curY = event.y + top.document.body.scrollTop;
		//var curX=event.x + top.mainPosition.offsetLeft + 155
		//var curX=event.x + top.mainPosition.clientLeft +155 //+ 155
		var curX = event.clientX + top.mainPosition.offsetLeft //+ 155
		//var curY=event.y + top.mainPosition.offsetTop
		var curY = event.clientY + top.mainPosition.offsetTop
		
		if (parent.columnA != null){
			curX += parent.columnA.offsetLeft
		}
		
		var rightedge = top.document.body.clientWidth - curX - offsetxpoint
		var bottomedge = top.document.body.clientHeight - curY - offsetypoint
		var leftedge = (offsetxpoint<0)? offsetxpoint*(-1) : -1000
		
		if (rightedge<tipobj.offsetWidth)
			tipobj.style.left = top.document.body.clientWidth - tipobj.offsetWidth +"px"
		else if (curX<leftedge)
			tipobj.style.left = "0px"
		else
			tipobj.style.left = curX + offsetxpoint + "px"
		
		if (bottomedge<tipobj.offsetHeight)
			//tipobj.style.top = top.document.body.scrollTop + event.clientY - tipobj.offsetHeight +"px"
			tipobj.style.top = curY - tipobj.offsetHeight - 30 + "px"
		else
			tipobj.style.top = curY + offsetypoint + "px"
			
		fadeIn();
}



function showAdPreviewTooltip(content){
	closeTooltip = false;

	tipobjContent.style.width = "0px"
	//tipobj.style.backgroundColor = "#ffffff"
	tipobjContent.style.backgroundColor = "#ffffff"
	

	t = content
	tipobjContent.innerHTML = t
	tipobj.style.visibility="visible"
	tooltipIsVisible=true
	posTooltip();
	return false
}

function showTooltip(productName, description, price, numberOfMessages, typeID, storeName){
	closeTooltip = false;

	//tipobj.style.width = "220px"
	tipobjContent.style.width = "220px"
	//tipobj.style.backgroundColor = "#ffffff"
	tipobjContent.style.backgroundColor = "#ffffff"



	//t = printHLTooltip(printProductTooltip(productName, description, price, numberOfMessages, typeID))
	//t = printProductTooltip(productName, description, price, numberOfMessages, typeID)
	t = printProductTooltip(productName, description, price, numberOfMessages, typeID, storeName)

	//tipobj.innerHTML = t
	tipobjContent.innerHTML = t
	tipobj.style.visibility = "visible"
	tooltipIsVisible=true
	posTooltip();
	return false
}

function showTooltip2(productName, description, price, numberOfMessages, typeID){
	closeTooltip = false;

	tipobj.style.width = "220px"
	tipobj.style.backgroundColor = "#ffffff"


	t = "<table width=100% class=menulines cellpadding=0 cellspacing=0>"
	t += "	<tr>"
	t += "	<td width=3>"
	t += "	<td><nobr style=\"width: 180; text-overflow: ellipsis; overflow: hidden\"><font class=plName>" + escHTML(productName) + "</nobr>"
	t += "	<br><font class=plDescription><nobr style=\"width: 100; text-overflow: ellipsis; overflow: hidden\">" + escHTML(description) + "</nobr>&nbsp;&nbsp;&nbsp;&nbsp;<nobr style=\"width: 50; text-overflow: ellipsis; overflow: hidden; text-align:center\">" + escHTML(price) + "</nobr>"
	if (numberOfMessages > 0){
		t += "<td width=22 background=/images/style/" + typeID + "/discussionCloud.gif align=center>"
		if (numberOfMessages >= 1000){
			t += "<p class=plName style=\"margin-top:-2pt; letter-spacing:-1pt;\">" + numberOfMessages
		}else{
			t += "<p class=plName style=\"margin-top:-2pt\">" + numberOfMessages
		}
	}else{
		t += "<td width=22>"
	}
	t += "<td width=4>"
	t += "</tr>"
	t += "</table>"

	tipobj.innerHTML = t
	tipobj.style.visibility="visible"
	tooltipIsVisible=true
	posTooltip();
	return false
}



function showAdPreviewTooltip2(content){
	closeTooltip = false;

	tipobj.style.width = "0px"
	tipobj.style.backgroundColor = "#ffffff"
	

	t = content
	tipobj.innerHTML = t
	tipobj.style.visibility="visible"
	tooltipIsVisible=true
	posTooltip();
	return false
}



function escHTML(text){
	return text.replace("<", "&lt;")
}

var closeTooltip = false;

function hideTooltip(){
	closeTooltip = true;
	setTimeout('fadeOut()', 200);
}
function hideTooltipInstant(){
	closeTooltip = true;
	fadeOut();
}

function mouseOverFunctions(){
	//executeGlobalMouseMove();
	posTooltip();
}

//document.onmousemove = posTooltip
document.onmousemove = mouseOverFunctions


var ieop=0;

function fadeIn(){
	if (!closeTooltip){
		ieop = 100;
		tooltipIsFading = true;
		//tipobj.style.filter="progid:DXImageTransform.Microsoft.Shadow(color=#79797d,direction=120,STRENGTH=2)progid:DXImageTransform.Microsoft.alpha(opacity="+ieop+");"
		tooltipIsFading = false;
	}
}

function fadeOut(){
	if (closeTooltip){
			ieop=0;
			tooltipIsVisible = false
			tooltipIsFading = false;
			tipobj.style.visibility = "hidden"
			tipobj.style.left = "-1000px"
			tipobj.style.backgroundColor = ''
			tipobj.style.width = ''
			activeProductID = 0
	}
}


function fadeIn2(){
	if (!closeTooltip){
		ieop = 100;
		if(ieop<=100){
		//alert(ieop)
			tooltipIsFading = true;
			ieop+=25;
			tipobj.style.filter="progid:DXImageTransform.Microsoft.Shadow(color=#79797d,direction=120,STRENGTH=2)progid:DXImageTransform.Microsoft.alpha(opacity="+ieop+");"
			//tipobj.style.filter="progid:DXImageTransform.Microsoft.Shadow(color=#79797d,direction=120,STRENGTH=2);"
			setTimeout('fadeIn()', 50);
		}else{
			tooltipIsFading = false;
		}
	}
	//}
}

function fadeOut2(){
	//alert(closeTooltip);
	if (closeTooltip){
		ieop = 0;
		if(ieop > 0){
			tooltipIsFading = true;
			ieop-=15;
			tipobj.style.filter="progid:DXImageTransform.Microsoft.Shadow(color=#79797d,direction=120,STRENGTH=2)progid:DXImageTransform.Microsoft.alpha(opacity="+ieop+");"
			//tipobj.style.filter="progid:DXImageTransform.Microsoft.Shadow(color=#79797d,direction=120,STRENGTH=2);"
			setTimeout('fadeOut()', 50);
		} else {
			ieop=0;
			tooltipIsVisible=false
			tooltipIsFading = false;
			tipobj.style.visibility="hidden"
			tipobj.style.left="-1000px"
			tipobj.style.backgroundColor=''
			tipobj.style.width=''
			activeProductID = 0
		}
	}
}
