﻿var KSTip=null;
var KSX = 12; //ALT位于鼠标左侧或者右侧的距离；3-12 合适
var KSY = 15; //ALT位于鼠标下方的距离；3-12 合适
var KSTitle="";
var KScolor="#ffffff"//ALT标题颜色
var KScolor1="#f60"//ALT说明颜色
var KSbg="#000000"//ALT标题背景色
var KSbg1="#EDF5FA"//ALT说明背景色
var KS_border=1//ALT边框大小px
var KS_b_color="#B6CAE3"//ALT边框颜色
var KSalpha = "80"//ALT透明度
document.write('<div id=KSTipdiv style="display: none;position: absolute; z-index:10001;font-weight:bold"></div>');
function KSloadinits(){
	document.onmouseover = KSload;
	document.onmousemove = KSmove;
}
function KSload(){
	var o=event.srcElement;
	if(o.alt!=null  &&  o.alt!=""){o.KStemp=o.alt;o.alt=""};
	if(o.title!=null  &&  o.title!=""){o.KStemp=o.title;o.title=""};
	KSTip=o.KStemp;
	if(KSTip!=null && KSTip!="" && typeof(KSTip)!="undefined"){
		KSTipdiv.style.left=-1000;
		KSTipdiv.style.display='';
		var KStext=KSTip.replace(/\n/g,"<br>");
		KStext=KStext.replace(/\0x13/g,"<br>");
		var re=/\{(.[^\{]*)\}/ig;
		if(!re.test(KStext)){
			KSTitle="『Design BY KanSea.com』";
		}else{
			re=/\{(.[^\{]*)\}(.*)/ig;
			KSTitle=KStext.replace(re,"$1")+" ";
			re=/\{(.[^\{]*)\}/ig;
			KStext=KStext.replace(re,"");
			KStext=KStext.replace("<br>","");
		}
		var content =
			'<div style="FILTER:alpha(opacity='+KSalpha+');opacity:0.'+KSalpha+';-moz-opacity:0.'+KSalpha+';border: '+KS_border+'px solid '+KS_b_color+';text-align:left;" id="toolTipTalbe">'+
			'	<div id="KSTiptop" style="color:'+KScolor+';background-color:'+KSbg+';list-style:none;">'+
			'	<b><div id="topleft">↖'+KSTitle+'</div>'+
			'	<div id="topright" style="text-align:right;display:none">'+KSTitle+'↗</div></b>'+
			'	</div>'+
			'	<div style="padding:10px 8 10 6px;line-height:140%;color:'+KScolor1+';background-color:'+KSbg1+';list-style:none;">'+KStext+'</div>'+
			'	<div id="KSTipbot" style="color:'+KScolor+';background-color:'+KSbg+';display:none;list-style:none;">'+
			'	<div id="botleft">↙'+KSTitle+'</div>'+
			'	<div id="botright" style="text-align:right;display:none">'+KSTitle+'↘</div></div>'+
			'</div>';
		KSTipdiv.innerHTML=content;
		toolTipTalbe.style.width=Math.min(KSTipdiv.clientWidth,document.body.clientWidth/2.2);
		KSmove();
		return true;
	}else{
		KSTipdiv.innerHTML='';
		KSTipdiv.style.display='none';
		return true;
	}
}
function KSmove(){
	if(KSTipdiv.innerHTML=='')return true;
	var MouseX=event.x;
	var MouseY=event.y;
	var popHeight=KSTipdiv.clientHeight;
	var popWidth=KSTipdiv.clientWidth;
	if(MouseY+KSY+popHeight>document.body.clientHeight){
		popTopAdjust=-popHeight-KSY*1.5;
		KSTiptop.style.display="none";
		KSTipbot.style.display="";
	}else{
		popTopAdjust=0;
		KSTiptop.style.display="";
		KSTipbot.style.display="none";
	}
	if(MouseX+KSX+popWidth>document.body.clientWidth){
		popLeftAdjust=-popWidth-KSX*2;
		topleft.style.display="none";
		botleft.style.display="none";
		topright.style.display="";
		botright.style.display="";
	}else{
		popLeftAdjust=0;
		topleft.style.display="";
		botleft.style.display="";
		topright.style.display="none";
		botright.style.display="none";
	}
	KSTipdiv.style.left=MouseX+KSX+document.body.scrollLeft+popLeftAdjust;
	KSTipdiv.style.top=MouseY+KSY+document.body.scrollTop+popTopAdjust;
	return true;
}
KSloadinits();