// JavaScript Document
//This is where the floating div code starts
document.write("<div id = 'floatingDiv' onmouseout = 'hide()' onmouseover = 'dontHide()' class = 'hiddenDiv'></div>");

var currentImgID;
var imgY;
var imgX;
var t;
var mouseY;
var div = document.getElementById("floatingDiv");
var offsetLeft;
var offsetTop;

document.onmousemove = mouseMove;

function mouseMove(ev){
	ev           = ev || window.event;
	mouseY = document.body.clientHeight - ev.clientY;
	return;
}

function showFloatingDiv(img){
	var newImg = currentImgID != img.id ? true : false;
	imgY = (currentImgID != img.id) ? img.offsetParent.offsetParent.offsetTop + img.offsetParent.offsetTop : imgY;
	imgX = img.offsetParent.offsetParent.offsetLeft + img.offsetParent.offsetLeft;
	currentImgID = img.id;	
	dontHide();
	
	var rollOverImg = currentImgID + "rollover.gif";
	var partInfo = "<div><img src = 'http://focus.ti.com/en/graphics/mcu/mcugen/" + rollOverImg + "' /></div><br /><div class = 'rightAlign'>" + img.alt + "</div>";
	var imgHeightOffset = img.height;
	
	if(offsetLeft == null)
		offsetLeft = 0;
	
	if(offsetTop == null)
		offsetTop = 0;
	
	var divHeight;

	div.innerHTML = partInfo;	
	div.className = "floatingDiv";
	divHeight = div.clientHeight;
	div.style.left = imgX + offsetLeft;
	
	if(newImg)
		div.style.top = imgY + offsetTop + imgHeightOffset - (mouseY > divHeight + 25 ? 0 : divHeight + 30);
	else
		dontHide();
	
	return;
}

function dontHide(){
	clearTimeout(t);
	return;
}

function hide(){
	t = setTimeout(div.id + ".className = 'hiddenDiv'; currentImgID = ''", 1000);
	return;
}

function setOffset(x, y){
	offsetLeft = x;
	offsetTop = y;
	
	return;
}
//This is where the floating div code ends