function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
var offsetxpoint = -20; // 
var offsetypoint = -90;   // 
var ie = document.all;
var ns6 = document.getElementById && !document.all;
var safari = isSafari();
var enabletip = false;
var xmlHttp = createXmlhttpRequestobject();
function createXmlhttpRequestobject()
{
	var xmlHttp;	
	try
	{  
		xmlHttp = new XMLHttpRequest();
	}
	catch(e)
	{
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
										"MSXML2.XMLHTTP.5.0",
										"MSXML2.XMLHTTP.4.0",
										"MSXML2.XMLHTTP.3.0",
										"MSXML2.XMLHTTP",
										"Microsoft.XMLHTTP");
		for(var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
		{
			try
			{
				xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch(e){}
		}
	}
	if(!xmlHttp)
	{
		alert("创建XMLHttpRequest对象出错");
	}
	else
	{		
		return xmlHttp;
	}
}

function getmapsrc(messageContent)
{
var desc = messageContent;
var tipObject = MM_findObj('toolTipWindow');
tipObject.innerHTML ='<img src="http://www.4h1j.com/images/loading.gif" border=0 />';
	if(xmlHttp)
		{		
			try
			{			
				xmlHttp.open("GET","http://www.4h1j.com/get_pic/getmapsrc.php?url="+ desc + "&" +Math.random(),true);				
				xmlHttp.onreadystatechange = handleRequestStateChange;
				xmlHttp.send(null);
			}
			catch(e)
			{
				alert("不能连接服务器:\n" + e.toString());	
			}		
		}	
enabletip = true;
return false;
}
function handleRequestStateChange()
{	
	if(xmlHttp.readyState ==4)
	{
		//http状态为OK时继续
		if(xmlHttp.status == 200)
		{
			try
			{				
				var xmlResponse = xmlHttp.responseXML;
				if (!xmlResponse || !xmlResponse.documentElement)
					throw("Invalid XML structure:\n" + xmlHttp.responseText);
				var rootNodeName = xmlResponse.documentElement.nodeName;
				if (rootNodeName == "parsererror") 
					throw("Invalid XML structure");
				// obtain the XML's document element
				xmlRoot = xmlResponse.documentElement;
				
				
				var arry = xmlRoot.getElementsByTagName("mapsrc");
				//alert(arry.length);
				var mapsrc = arry.item(0).firstChild.data;
		var tipObject = MM_findObj('toolTipWindow');
tipObject.innerHTML = '<div><span class="arrow"></span><a class="frame"><img src="'+mapsrc+'" border="0"/></a></div>';
			
			}
			catch(e)
			{
				//alert(e.toString());
				if(tipObject.innerHTML.indexOf("arrow1")==-1)
					tipObject.innerHTML = '<div><span class="arrow"></span><a class="frame"><br><br>'+mapsrc+'</a></div>';		
				else
					tipObject.innerHTML = '<div><span class="arrow1"></span><a class="frame"><br><br>'+mapsrc+'</a></div>';					
			}
		}
	}	
}

function hideTip()
{
var tipObject = MM_findObj('toolTipWindow'); 
enabletip = false;
tipObject.style.visibility = "hidden";
}
function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function isSafari(){
return navigator.userAgent.toLowerCase().indexOf("safari") + 1;
}
function positionTip(e)
{
if (enabletip)
{
   var tipobj = MM_findObj('toolTipWindow');
   var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
   var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
   var rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20;
   var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20;
   var leftedge=(offsetxpoint<0)? offsetxpoint*(-1) : -1000
   if (rightedge<tipobj.offsetWidth)
   {
    tipobj.style.left=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
   }
   else if (curX<leftedge)
   {
    tipobj.style.left="5px"
   }
   else
   {
    tipobj.style.left=curX+offsetxpoint+"px";
   }

   if(safari)
   {
    tipobj.style.top=curY+offsetypoint+"px";
   }
   else
   {
    if (bottomedge<tipobj.offsetHeight)
    {
     tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px";
    }
    else
    {
     tipobj.style.top=curY+offsetypoint+"px";
    }
   }
   tipobj.style.visibility="visible";
}
}

document.onmousemove = positionTip;