﻿//弹出的内容
var ImgHintPop=null;
var ImgHintoffsetX = 10;
var ImgHintoffsetY = 15;
var ImgHintPopbg="#ffffee";
var ImgHintPopfg="#111111";
var ImgHintTitle="";
document.write('<iframe id="DivShim" src="" scrolling="no" frameborder="0" style="position:absolute;top:0px;left:0px;width:0px;height:0px;z-index:10000;"></iframe>');
document.write('<div id=ImgHintTipLayer style="display: none;position: absolute; z-index:10001;"></div>');
var DivShim=document.getElementById('DivShim');
function ImgHintinits()
{
    document.onmouseover = ImgHint;
    document.onmousemove = moveToMouseLoc;
}
function resize(obj)
{
    var maxWidth = 400;
    if (obj.width>maxWidth) obj.width=maxWidth;
}
function ImgHint()
{
	//img图片对象
  var o=event.srcElement;
  if(o.tagName=='IMG' && o.parentElement!=null && o.parentElement.className=='img_hint')
  {
    var _src=o.src;
    //alert(_src);
  	o.dypop='<img src="'+_src+'" border="0" onload="resize(this)" />';
  	//alert(o.alt);  //1.jpg
  	//alert(o.title); 
  	//清空o.title、o.alt以使o.dypop为""
  	o.title="";
  	o.alt="";
    if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
    if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
    ImgHintPop=o.dypop;
    //alert(ImgHintPop);  //<img src="images/1.jpg" border="0" onload="resize(this)" />;
  }
   //o.dypop为空时显示跳出图片
    if(ImgHintPop!=null&&ImgHintPop!=""&&typeof(ImgHintPop)!="undefined" && o.parentElement.className=='img_hint')
    {
			ImgHintTipLayer.style.left=-1000;
			ImgHintTipLayer.style.display='';
			DivShim.style.display='';
			var Msg=ImgHintPop.replace(/\n/g,"<br>");
			Msg=Msg.replace(/\0x13/g,"<br>");
			var re=/\{(.[^\{]*)\}/ig;
			//alert(re.test(Msg));  false
			//var ddv="{abhaha}";  //"{ab}" -true  ^非以{开头
			//alert(re.test(ddv));
			//Msg="{abcde}hahaj";
			if(!re.test(Msg)){
				ImgHintTitle="";
				//alert('a');进入
			}
			else{
			  re=/\{(.[^\{]*)\}(.*)/ig;
		  	ImgHintTitle=Msg.replace(re,"$1")+" ";
		  	//alert(ImgHintTitle);
			  re=/\{(.[^\{]*)\}/ig;
			  Msg=Msg.replace(re,"");
			  //alert(Msg);
			  Msg=Msg.replace("<br>","");
			 }
	  	var attr=(document.location.toString().toLowerCase().indexOf("list.asp")>0?"nowrap":"");
     	var content = Msg;
     	//alert(Msg);
     	ImgHintTipLayer.innerHTML=content;
     	moveToMouseLoc();
     	return true;
    }
    else
    //不为空则不显示跳出图片
    {
        ImgHintTipLayer.innerHTML='';
      	ImgHintTipLayer.style.display='none';
      	DivShim.style.display='none';
       	return true;
    }
}

function moveToMouseLoc()
{
	if(ImgHintTipLayer.innerHTML=='')return true;
	var MouseX=event.x;
	var MouseY=event.y;
	//window.status=event.y;
	var popHeight=ImgHintTipLayer.clientHeight;
	var popWidth=ImgHintTipLayer.clientWidth;
	var scrollT = document.documentElement.scrollTop;
	if(MouseY+ImgHintoffsetY+popHeight+scrollT>document.body.clientHeight)
	{
	  	popTopAdjust=-popHeight-ImgHintoffsetY*1.5;
	  	//ImgHintPoptop.style.display="none";
	  	//ImgHintPopbot.style.display="";
	}
	 else
	{
	   	popTopAdjust=0;
	  	//ImgHintPoptop.style.display="";
	  	//ImgHintPopbot.style.display="none";
	}
	if(MouseX+ImgHintoffsetX+popWidth>document.body.clientWidth)
	{
		popLeftAdjust=-popWidth-ImgHintoffsetX*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";
	}
	ImgHintTipLayer.style.left=MouseX+ImgHintoffsetX+document.documentElement.scrollLeft+popLeftAdjust;
	ImgHintTipLayer.style.top=MouseY+ImgHintoffsetY+document.documentElement.scrollTop+popTopAdjust;
	DivShim.style.left = ImgHintTipLayer.style.left;
	DivShim.style.top = ImgHintTipLayer.style.top;
	DivShim.style.height=ImgHintTipLayer.clientHeight;
	DivShim.style.width=ImgHintTipLayer.clientWidth;
  return true;
}
ImgHintinits();



//showimageinits();
