
//-------------
// instanciate the XmlHttp object
//------------------------

var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}

// --------------------------
// get lens description 
// --------------------------

//------------------------
// show/hide tooltip div
//-------------------------

logging = false;
xsltdebug = false;
xpathdebug = false;

function showTip(image_obj, pid)
{
	xmlhttp.open("GET", "get_lens_desc.asp?pid=" + pid, true);
	xmlhttp.onreadystatechange = function() {
	 if (xmlhttp.readyState==4) {
		var thediv = document.getElementById('tip');
		var thespan = document.getElementById('lens_desc');
		
		thediv.style.top = findPosY(image_obj) - 65;
		thediv.style.left = findPosX(image_obj) + 65; 
		thediv.style.display = thediv.style.display == 'block' ? 'none' : 'block';	 
		
		var xml = xmlParse(xmlhttp.responseText);
		var xslt = xmlParse(document.getElementById('xslt').value);
		var html = xsltProcess(xml, xslt);
		thespan.innerHTML = html;					
	 }
	}
	xmlhttp.send(null)
}

function hideTip()
{
	var thediv = document.getElementById('tip');
	thediv.style.display = 'none';		
}
	
function findPosX(obj)
{
	var curleft = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft;
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	if (obj.offsetParent)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop;
			obj = obj.offsetParent;
		}
	}
	else if (obj.y)
		curtop += obj.y;
	return curtop;
}