var pltsPop=null;
var pltsoffsetX = 6;   // 弹出窗口位于鼠标左侧或者右侧的距离；3-12 合适
var pltsoffsetY = 10;  // 弹出窗口位于鼠标下方的距离；3-12 合适
var pltsPopbg="#FFFFFF"; //背景色
var pltsPopfg="#111111"; //前景色
var pltsTitle="";
document.write('<div id=pltsTipLayer style="display: none;position: absolute; z-index:10001"></div>');
function pltsinits()
{
    document.onmouseover   = plts;
    document.onmousemove = moveToMouseLoc;
}
function plts()
{  var o=event.srcElement;
    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")
    {
document.getElementById("pltsTipLayer").style.left=-1000;
document.getElementById("pltsTipLayer").style.display='';
var Msg=pltsPop.replace(/\n/g,"<br>");
Msg=Msg.replace(/\0x13/g,"<br>");
var re=/\{(.[^\{]*)\}/ig;
if(!re.test(Msg))pltsTitle="买好货-到货好! huohao.com";
else{
   re=/\{(.[^\{]*)\}(.*)/ig;
     pltsTitle=Msg.replace(re,"$1")+"&nbsp;";
   re=/\{(.[^\{]*)\}/ig;
   Msg=Msg.replace(re,"");
   Msg=Msg.replace("<br>","");}
   var attr=(document.location.toString().toLowerCase().indexOf("/shop")>0?"nowrap":"");
        var content =
       '<table style="FILTER:alpha(opacity=80) shadow(color=#bbbbbb,direction=135);" id=toolTipTalbe border=0><tr><td style="width: 260px; word-wrap: break-word "><table bgcolor=#7CADE1 cellspacing=1 cellpadding=0 border=0 width=260px style="font-size:12px">'+
       '<tr id=pltsPoptop><th height=18 valign=bottom><b><p id=topleft align=left style="color:#FFC0A0;">↖'+pltsTitle+'</p><p id=topright align=right style="color:#FFC0A0;display:none">'+pltsTitle+'↗</font></b></th></tr>'+
       '<tr><td "+attr+"  bgcolor=#EAF2FB style="padding-left:14px;padding-right:14px;padding-top: 6px;padding-bottom:6px; line-height: 18px; word-break:break-all;">'+Msg+'</td></tr>'+
       '<tr id=pltsPopbot style="display:none"><th height=12 valign=bottom><b><p id=botleft align=left style="color:#FFC0A0;">↙'+pltsTitle+'</p><p id=botright align=right style="color:#FFC0A0;display:none">'+pltsTitle+'↘</b></th></tr>'+
       '</table></td></tr></table>';
        document.getElementById("pltsTipLayer").innerHTML=content;
        toolTipTalbe.style.width=Math.min(document.getElementById("pltsTipLayer").clientWidth,document.body.clientWidth/2.2);
        moveToMouseLoc();
        return true;
       }
    else
    {
     document.getElementById("pltsTipLayer").innerHTML='';
     document.getElementById("pltsTipLayer").style.display='none';
        return true;
    }
}

function moveToMouseLoc()
{
if(document.getElementById("pltsTipLayer").innerHTML=='')return true;
var MouseX=event.clientX;
var MouseY=event.clientY;
//window.status=event.y + '-'+ event.clientY;
var popHeight=document.getElementById("pltsTipLayer").clientHeight;
var popWidth=document.getElementById("pltsTipLayer").clientWidth;
if(MouseY+pltsoffsetY+popHeight>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";
}
//scrolltop = Math.max(document.body.scrollTop,document.documentElement.scrollTop);
//scrollleft = Math.max(document.body.scrollLeft,document.documentElement.scrollLeft);

if (document.documentElement && !document.documentElement.scrollTop)
// IE6 +4.01 but no scrolling going on
scrolltop = document.documentElement.scrollTop;
else if (document.documentElement && document.documentElement.scrollTop)
// IE6 +4.01 and user has scrolled
scrolltop = document.documentElement.scrollTop;
else if (document.body && document.body.scrollTop)
scrolltop = document.body.scrollTop;
else
scrolltop=0;

if (document.documentElement && !document.documentElement.scrollLeft)
// IE6 +4.01 but no scrolling going on
scrollleft = document.documentElement.scrollLeft;
else if (document.documentElement && document.documentElement.scrollLeft)
// IE6 +4.01 and user has scrolled
scrollleft = document.documentElement.scrollLeft;
else if (document.body && document.body.scrollLeft)
scrollleft = document.body.scrollLeft;
else
scrollleft=0;

document.getElementById("pltsTipLayer").style.left=MouseX+pltsoffsetX+scrollleft+popLeftAdjust;
document.getElementById("pltsTipLayer").style.top=MouseY+pltsoffsetY+scrolltop+popTopAdjust;
   return true;
}
pltsinits();
