var lastTM=null;
var TMDelay=document.all?120:10;
function setTM(){
	var a=document.getElementsByTagName("A");
	for(var i=0;i<a.length;i++){
		if(a[i].getAttribute("img")){
			a[i].onmouseover=function(){
				showThumb(this)
			};
			a[i].onmouseout=function(){
				hideThumb()
			}
		}
	}
}
function getTMdiv(){
	var a=document.getElementById('TMdiv');
	if(!a){
		a=document.createElement("DIV");
		a.id='TMdiv';
		a.style.display='none';
		document.body.appendChild(a);
		TMimg=document.createElement("IMG");
		TMimg.id='TMimg';
		a.appendChild(TMimg);
		TMtext=document.createElement("DIV");
		TMtext.id="TMtext";
		a.appendChild(TMtext)
	}
	return a
}
function getTMshadow(){
	var a=document.getElementById('TMshadow');
	if(!a){
		a=document.createElement("DIV");
		a.id='TMshadow';
		a.style.display='none';
		document.body.appendChild(a)
	}
	return a
}
function moveThumb(a){
	var p=getMouse(a);
	if(document.documentElement){
		var b=document.documentElement;
		if(p.x>b.clientWidth+b.scrollLeft-163)p.x-=170;
		if(p.y>b.clientHeight+b.scrollTop-140)p.y-=150
	}
	var c=getTMdiv();
	c.style.left=(p.x+27)+"px";
	c.style.top=(p.y+27)+"px";
	var d=getTMshadow();
	d.style.left=(p.x+30)+"px";
	d.style.top=(p.y+30)+"px"
}
function showThumb(a){
	lastTM=a;
	window.setTimeout(function(){
		if(lastTM==a){
			TMdiv=getTMdiv();
			TMshadow=getTMshadow();
			document.getElementById('TMimg').src=(a.getAttribute('img').indexOf('http://')!=-1?"":"http://img.yxcity.com")+a.getAttribute('img');
			document.getElementById('TMtext').innerHTML=a.textContent||a.innerText;
			document.getElementById('TMimg').onload=function(){
				document.getElementById('TMdiv').style.display='';
				document.getElementById('TMshadow').style.width=document.getElementById('TMdiv').offsetWidth+"px";
				document.getElementById('TMshadow').style.height=document.getElementById('TMdiv').offsetHeight+"px";
				document.getElementById('TMshadow').style.display='';
				//setalpha(document.getElementById('TMimg'),20,8);
				moveThumb()
			};
			a.onmousemove=moveThumb
		}else{
			a.onmousemove=''
		}
	},TMDelay)
}
function hideThumb(){
	lastTM=null;
	$("#TMimg").attr("src",""); 
	$("#TMdiv").hide();
	$("#TMshadow").hide();
}
function getMouse(a){
	a=a||window.event;
	if(a.pageX||a.pageY)return{x:a.pageX,y:a.pageY};
	return{x:a.clientX+document.documentElement.scrollLeft,y:a.clientY+document.documentElement.scrollTop}
}
window.onload=setTM;
