﻿var $u=YAHOO.util,$e=$u.Event,$D=$u.Dom;$d=document,$gE=function(id){return $d.getElementById(id)};
function onPressEnterClick(targetId,elementToClickId){
    $e.onContentReady(targetId,function(){ $e.onContentReady(elementToClickId,function(){ 
$e.addListener($gE(targetId),"keydown", function(e){
    var k=e.keyCode||e.charCode;
    if(k==13){
        $e.stopEvent(e);
        $gE(elementToClickId).click();                   
} }) }) }) }
function doFocus(targetId){ $e.onContentReady(targetId,function(){var r=$gE(targetId);r.focus();r.select()}) }
function $TC(o){var t;o=$e.getTarget(o);while(o&&o.tagName!='TD')o=o.parentNode;if(o){t=o;o=o.getElementsByTagName('A');if(o.length){o.t=t;return o}}}
function $PTC(a){$PTMVC();a=$e.getEvent(a);var o=$e.getTarget(a);if(o.tagName=="IMG")o=o.parentNode;if(o&&o.getAttribute("rel")!="nofollow"){o=$TC(a);if(o){$PTMV=function(){};setTimeout(function(){location.href=o[0].href},10)}}}
var $OF=16;
function $calcXY(div,xy){
    var maxY = $D.getDocumentScrollTop()+$D.getClientHeight(),maxX=$D.getDocumentScrollLeft()+$D.getClientWidth(),
        r=$D.getRegion(div.children[0]), w=r.right-r.left+30, h=r.bottom-r.top+30;
    if ((xy=xy.o)[0]+w>maxX)xy[0]-=w;
    if (xy[1]+h>maxY)xy[1]=maxY-h;
}
function $PTMVE(e){$PTMV({target:$e.getTarget(e)},e.type=="mouseout")};
function $PTMVC(){clearTimeout($PTMV.to);clearTimeout($PTMV.to2);clearTimeout($PTMV.to3),clearInterval($PTMV.ito)}
function $PTMV(ev,out){
    $PTMVC();
    var o=$TC((ev=$e.getEvent(ev)));
    if(o&&o.length==3){       
        if(!o[0].getAttribute("T")){
            var no=[];
            for(var i=0;i<o.length;i++){
                if (o[i].getAttribute("rel")=="nofollow") continue;                                
                o[i].setAttribute("T",o[i].getAttribute("title"));o[i].removeAttribute("title")
                var x=o[i].getElementsByTagName('IMG');
                if(x.length)x[0].setAttribute('title','');
                no.push(o[i]);
            }            
            $e.on(no,"mousemove",$PTMVE); 
            $e.on(o.t,"mouseout",$PTMVE);
        }
        var xy=$e.getXY(ev);        
        o=o[0];             
        var f = function(){                    
            var div=$PTMV.div;
            if(out){ if(div){ $D.setStyle(div,"display","none"); div.innerHTML = $PTMV.imgUrl = "" } return }        
            var imgUrl=o.getAttribute("xdata"), div=$PTMV.div,
                f2=function(){$PTMV.to3=setTimeout(function(){$D.setStyle(div,"display","none");$PTMV.imgUrl=""},3500)};
            if (!$PTMV.div){ div=$PTMV.div=document.createElement("DIV"); document.body.appendChild(div) }                                   
            if ($PTMV.imgUrl!=imgUrl)
            {
                $D.setStyle(div,"display","none");                
                $PTMV.to = setTimeout(
                    function(){                                                
                        div.innerHTML="<table style=\"background-color:#fff;border:1px solid #ddd;width:205px\" cellpadding=5><tr><td align=\"center\"><img id=\"tt__pu\" src='"+imgUrl+"' width=\"200\" height=\"200\"/><p><b>"+o.getAttribute("T")+"</b></p></td></tr></table>";
                        $PTMV.imgUrl=imgUrl;                        
                        $e.onAvailable("tt__pu",function(o){                            
                            $D.setStyle(div,"opacity",0.0);
                            $D.setStyle(div,"display","inline-block");                                                                                    
                            $calcXY(div,{o:xy});
                            $D.setXY(div,[xy[0]+$OF,xy[1]+$OF])                            
                            var op=0.0;
                            $PTMV.ito=setInterval(function(){$D.setStyle(div,"opacity",op+=0.25);if(op>1)clearInterval($PTMV.ito)},30);
                            f2();
                        });                        
                    },100);                
            }
            if ($D.getStyle(div,"display")!="none"){
                $D.setStyle(div,"opacity",1);
                $calcXY(div,{o:xy});       
                $D.setXY(div,[xy[0]+$OF,xy[1]+$OF])      
                f2();
            }
        }
        if(out)f(); 
        else $PTMV.to2=setTimeout(f,300); 
    }       
}
