﻿var pltsPop=null;
var pltsoffsetX = 10;
var pltsoffsetY = 15;
var pltsPopbg=" ";
var pltsPopfg=" ";
var pltsTitle="";
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=pltsTipLayer style="display: none;position: absolute; z-index:10001;"></div>');
var DivShim=document.getElementById('DivShim');
function pltsinits()
{
    document.onmouseover = plts;
    document.onmousemove = moveToMouseLoc;
}
function resize(obj)
{
    var maxWidth = 300;
   if (obj.width>maxWidth) obj.width=maxWidth;
}
function plts()
{
  var o=event.srcElement;
  if(o.tagName=='IMG' && o.parentElement!=null && o.parentElement.className=='img_hint')
  {
    var _src=o.src;
    if(_src.indexOf('thumbs')>=0){
    _src=_src.substr(0,_src.length-4);
    _src=_src.replace('thumbs','pics');}
  	o.dypop='<img src="'+_src+'" border="0"  onload="resize(this)" />';
  	o.title="";
  	o.alt="";
  }
  else {pltsTipLayer.style.display='none';DivShim.style.display='none';return;}

    if(o.alt!=null && o.alt!=""){o.dypop=o.alt;o.alt=""};
    if(o.title!=null && o.title!=""){o.dypop=o.title;o.title=""};
    pltsPop=o.dypop;
    if(pltsPop!=null&&pltsPop!=""&&typeof(pltsPop)!="undefined")
    {
	pltsTipLayer.style.left=-1000;
	pltsTipLayer.style.display='';
	DivShim.style.display='';
	var Msg=pltsPop.replace(/\n/g,"<br>");
	Msg=Msg.replace(/\0x13/g,"<br>");
	var re=/\{(.[^\{]*)\}/ig;
	if(!re.test(Msg))pltsTitle="";
	else{
	  re=/\{(.[^\{]*)\}(.*)/ig;
  	  pltsTitle=Msg.replace(re,"$1")+" ";
	  re=/\{(.[^\{]*)\}/ig;
	  Msg=Msg.replace(re,"");
	  Msg=Msg.replace("<br>","");}
	  var attr=(document.location.toString().toLowerCase().indexOf("list.asp")>0?"nowrap":"");
       	var content = Msg;
//      	'<table style="" id=toolTipTalbe border=0><tr><td width="100%"><table class=selet_bg cellspacing="0" cellpadding="0" style="width:100%" style="font size:9pt;">'+
//      	'<tr id=pltsPoptop><th height=0 valign=bottom class=header><p id=topleft align=left>'+pltsTitle+'</p><p id=topright align=right style="display:none">'+pltsTitle+'</font></th></tr>'+
//      	'<tr><td "+attr+" class=f_one style="padding-left:10px;padding-right:10px;padding-top: 4px;padding:0px;line-height:135%">'+Msg+'</td></tr>'+
//      	'<tr id=pltsPopbot style="display:none"><th height=0 valign=bottom class=header><p id=botleft align=left>'+pltsTitle+'</p><p id=botright align=right style="display:none">'+pltsTitle+'</font></th></tr>'+
//      	'</table></td></tr></table>';
       	pltsTipLayer.innerHTML=content;
       	//toolTipTalbe.style.width=Math.min(pltsTipLayer.clientWidth,document.body.clientWidth/2.2);
       	moveToMouseLoc();
       	return true;
       }
    else
    {
        pltsTipLayer.innerHTML='';
      	pltsTipLayer.style.display='none';
      	DivShim.style.display='none';
       	return true;
    }
}

function moveToMouseLoc()
{
	if(pltsTipLayer.innerHTML=='')return true;
	var MouseX=event.x;
	var MouseY=event.y;
	//window.status=event.y;
	var popHeight=pltsTipLayer.clientHeight;
	var popWidth=pltsTipLayer.clientWidth;
	var scrollT = document.documentElement.scrollTop;
	if(MouseY+pltsoffsetY+popHeight+scrollT>document.body.clientHeight)
	{
	  	popTopAdjust=-popHeight-pltsoffsetY*1.5;
	  	//pltsPoptop.style.display="none";
	  	//pltsPopbot.style.display="";
	}
	 else
	{
	   	popTopAdjust=0;
	  	//pltsPoptop.style.display="";
	  	//pltsPopbot.style.display="none";
	}
	if(MouseX+pltsoffsetX+popWidth>document.body.clientWidth)
	{
		popLeftAdjust=-popWidth-pltsoffsetX*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";
	}
	pltsTipLayer.style.left=MouseX+pltsoffsetX+document.documentElement.scrollLeft+popLeftAdjust;
	pltsTipLayer.style.top=MouseY+pltsoffsetY+document.documentElement.scrollTop+popTopAdjust;
	DivShim.style.left = pltsTipLayer.style.left;
	DivShim.style.top = pltsTipLayer.style.top;
	DivShim.style.height=pltsTipLayer.clientHeight;
	DivShim.style.width=pltsTipLayer.clientWidth;
  return true;
}
pltsinits();

/**
 * 显示弹出图片。
 * @param tag 目标元素。弹出的框将显示在其旁边
 * @param url 需要弹出的图片的URL
 * @param pos 弹出位置。0=右，1=上，2=左，3=下，缺省为自动选择最佳方位。
 *
if(document.all["_showImage"]==null)
{
 document.write('<img id="_showImage" style="z-index:10001; display:none; position:absolute; border:1 solid black" onmouseout="style.display="none"">');
}*/
function showImage(tag,url,pos) {
    var o=event.srcElement;
    if(o.tagName=='IMG')
    {
        if (o.parentElement!=null && o.parentElement.className=='img_hint')
        {
          tag = o;
          url = o.src;
        }
        else return;
    }
    else return;
    tag.attachEvent("onmouseout",mouseout);
    var helper = document.all["_showImage"];
    helper.removeAttribute("src");
    helper.removeAttribute("width");
    helper.removeAttribute("height");
    helper.onload=showImage_show;
    helper.src = url;

    function mouseout() {
        //注释本行将使鼠标移出原图时弹出图立即关闭
        helper.onmouseout();
        DivShim.style.display='none';
        helper.onload = null;
        helper.removeAttribute("src");
        tag.detachEvent("onmouoseout",arguments.callee);
    }
    function showImage_show() {
        var rc = tag.getBoundingClientRect();
        helper.style.display = '';
        DivShim.style.display = '';
        var rc2 = helper.getBoundingClientRect();   
        var body = document.documentElement;
        var l = rc.left;
        var t = rc.top;
        var r = body.clientWidth-rc.right;
        var b = body.clientHeight-rc.bottom;
        var ratio = (rc2.bottom-rc2.top) / (rc2.right-rc2.left);

        var pos = typeof(pos)!='undefined'?pos:-1;
        if(pos >= 0) { //指定了显示方位
            var w = pos==1||pos==3?body.clientWidth : pos==0?r:l;
            var h = pos==0||pos==2?body.clientHeight : pos==1?t:b;
            if(h < w*ratio) w = h/ratio;
            else if(w < h/ratio) h = w*ratio;

        } else { //未指定显示方位，自动选择
            var pos0_2 = l < r ? 0 : 2;
            var pos1_3 = t < b ? 3 : 1;
            var w = l < r ? r : l;
            var h = t < b ? b : t;
            var h1 = w*ratio; if(h1 > body.clientHeight) h1 = body.clientHeight;
            var h2 = body.clientWidth*ratio; if(h2 > h) h2 = h;
            if(h1 > h2) {
                var pos = pos0_2;
                h = h1;
                w = h1 / ratio;
            } else {
                var pos = pos1_3;
                h = h2;
                w = h2 / ratio;
            }
        }

        if(rc2.bottom-rc2.top > h || rc2.right-rc2.left > w) {
            helper.width = w;
            helper.height = h;
        }

        var rc2 = helper.getBoundingClientRect();
        l = (pos==1||pos==3?rc.left:pos==0?rc.right:rc.left-(rc2.right-rc2.left));
        t = (pos==0||pos==2?rc.top:pos==3?rc.bottom:rc.top-(rc2.bottom-rc2.top));
        var k = body.clientWidth-(l+rc2.right-rc2.left);
        if(k < 0) l += k;
        var k = body.clientHeight-(t+rc2.bottom-rc2.top);
        if(k < 0) t += k;

        helper.style.left = -2+body.scrollLeft+l;
        helper.style.top = -2+body.scrollTop+t;
        DivShim.style.left = helper.style.left;
        DivShim.style.top = helper.style.top;
        DivShim.style.height=helper.style.height;
        DivShim.style.width=helper.style.width;
    }
}
function showimageinits()
{
    document.onmousemove = showImage;
}
//showimageinits();
