//cookie
function comm_read_cookie(name){var cookieValue = "", search = name + "=";if(document.cookie.length > 0){offset = document.cookie.indexOf(search);if (offset != -1){offset += search.length;end = document.cookie.indexOf(";", offset);if (end == -1) end = document.cookie.length;cookieValue = unescape(document.cookie.substring(offset, end));}}return cookieValue;};
//swap
function swap(v){
	$("a.swapselected").removeClass("swapselected");
	$("#swap"+v).addClass("swapselected");
	$.getJSON("/data/json_index_swap_"+ v +".html",{"ran": new Date().getDate()},function(jsonData){
		if(!jsonData.game){return;}
		var s = new Array(),link = "";
		for(var i=0; i<jsonData.game.length; i++){
			if((i+1)%9==1){s.push('<ul>');}
			link = jsonData.game[i].link;
			if(!link){link = "flash/"+ jsonData.game[i].id+".htm";}
			s.push('<li><div class="i"><div><a href="'+ link +'" target="_blank"><img src="'+ jsonData.game[i].pic +'" /></a></div></div><h4><a href="'+ link +'" target="_blank">'+ jsonData.game[i].name +'</a></h4></li>');
			if((i+1)%9==0){s.push('</ul>');}
		}
		s.push('<div class="clear"></div>');
		$("#jsonlist").html(s.join(""));
	});
};
//step
//
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+17)+"px";
	c.style.top=(p.y+17)+"px";
	var d=getTMshadow();
	d.style.left=(p.x+20)+"px";
	d.style.top=(p.y+20)+"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://i5.17173.itc.cn/2010/flash/")+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;

