var G_tooltips=new Array();gTooltip=GClass.create();gTooltip.prototype={initialize:function(a){this.options={className:'',fade:true,delayin:200,delayout:500,autohidedelay:5000};Object.extend(this.options,a||{});var i=0;var b='gtooltip_iframe_'+i;while(document.getElementById(b)){i++;b='gtooltip_iframe_'+i};var c=null;if(window.ActiveXObject){c=document.createElement('<iframe id="'+b+'" name="'+b+'" scrolling="no" />')}else{c=document.createElement('iframe');c.setAttribute('id',b);c.setAttribute('name',b)};this.iframe=$G(c);this.iframe.set('frameBorder',0);this.iframe.set('scrollbar',0);this.iframe.setStyle('opacity',0);this.iframe.setStyle('position','absolute');this.iframe.setStyle('display','none');this.iframe.setStyle('zIndex',2000);document.body.appendChild(c);lyrtooltip=document.createElement("div");lyrtooltip.style.position='absolute';lyrtooltip.style.left='-1000px';lyrtooltip.style.top='-1000px';lyrtooltip.style.zIndex=2001;document.body.appendChild(lyrtooltip);this.arrowheadimg=['arrow-left.gif','arrow-right.gif'];for(var i=0;i<this.arrowheadimg.length;i++){var d=new Image();d.src=this.arrowheadimg[i]};imgobj=document.createElement("img");imgobj.style.position='absolute';imgobj.style.top='0px';imgobj.style.zIndex=2002;this.imgobj=imgobj;lyrtooltip.appendChild(imgobj);lyrtext=document.createElement("div");lyrtext.onmouseout=this.delayHide.bind(this);lyrtext.className=this.options.className;lyrtext.style.position='absolute';lyrtooltip.appendChild(lyrtext);this.lyrtext=$G(lyrtext);this.fade=new GFade(lyrtooltip);this.id=G_tooltips.length;G_tooltips[this.id]=this;$G(document.body).addEvent('click',function(){for(var i=0;i<G_tooltips.length;i++){G_tooltips[i].hide()}});this.req=new GAjax()},setArrow:function(a,b){this.arrowheadimg[0]=a;var c=new Image();c.src=a;this.arrowheadimg[1]=b;var c=new Image();c.src=b},showAjax:function(b,c,d){this.req.abort();temp=this;this.req.send(c,d,function(a){data=a.responseText;if(temp.iframe.style.display!='none')temp.show(b,data);else this.delayin=window.setTimeout(function(){temp.show(b,data)},temp.options.delayin)});el=$E(b);var e=el.onmouseout;req=this.req;el.onmouseout=function(){req.abort();window.clearTimeout(temp.delayin);window.clearTimeout(temp.delayout);window.clearTimeout(temp.timeautohidedelay);el.onmouseout=e;temp.delayout=window.setTimeout(function(){temp.hide.call(temp)},temp.options.delayout)}},show:function(b,c){var d=$G(b);elemPos=d.viewportOffset();elemHeight=d.getHeight();elemWidth=d.getWidth();this.imgobj.src=this.arrowheadimg[0];arrowWidth=this.imgobj.width||13;borderWidth=this.lyrtext.getStyle('borderLeftWidth');borderWidth=borderWidth=='medium'?0:parseFloat(borderWidth);var e=document.getElementsByTagName('body')[0];var f=document.createElement('div');e.appendChild(f);f.className=this.options.className;f.style.position='absolute';f.style.left=(elemPos.left+elemWidth+arrowWidth+borderWidth+5)+'px';f.style.visibility='hidden';f.innerHTML=c;var g=f.offsetHeight;var h=f.offsetWidth;e.removeChild(f);clientHeight=document.viewport.getHeight();clientWidth=document.viewport.getWidth();scrollTop=document.viewport.getscrollTop();scrollLeft=document.viewport.getscrollLeft();arrowTop=((g+elemHeight)/2);t=elemPos.top-(g/2)+(elemHeight/2);arrowTop=(g/2)-(elemHeight/2);if(t<scrollTop){arrowTop=scrollTop<elemPos.top?arrowTop-(scrollTop-t):0;t=scrollTop<elemPos.top?scrollTop:elemPos.top}else if((t+g)>(scrollTop+clientHeight)){ot=t;t=(scrollTop+clientHeight)-g;if((t+g)<(elemPos.top+elemHeight)){t=(elemPos.top+elemHeight)-g};arrowTop=arrowTop+(ot-t)};f=null;this.cancleHideDelay();this.fade.Element.style.display='block';this.lyrtext.elem.innerHTML=c;var j=this.lyrtext.elem.getElementsByTagName('*');for(var i=0;i<j.length;i++)j[i].onmouseover=this.cancleHideDelay.bind(this);l=elemPos.left+elemWidth+5;if(l+h<clientWidth){this.imgobj.src=this.arrowheadimg[0];this.lyrtext.elem.style.left=(arrowWidth-borderWidth)+'px';this.imgobj.style.marginLeft='0px'}else{this.imgobj.src=this.arrowheadimg[1];l=elemPos.left-h-arrowWidth;this.lyrtext.elem.style.left='0px';this.imgobj.style.marginLeft=(h-borderWidth)+'px'};this.fade.Element.style.left=l+'px';this.iframe.style.left=l+'px';this.imgobj.style.top=arrowTop+'px';this.fade.Element.style.top=t+'px';this.fade.Element.style.height=g+'px';this.fade.Element.style.width=(h+arrowWidth)+'px';this.iframe.style.top=t+'px';this.iframe.style.height=g+'px';this.iframe.style.width=(h+arrowWidth-borderWidth)+'px';var f=this;for(var i=0;i<G_tooltips.length;i++){if(i!=f.id)G_tooltips[i].hide()};if(this.options.fade&&(this.iframe.style.display=='none'||this.fade.playing)){this.fade.play({'from':0,'to':100,'iframe':this.iframe,'onComplete':function(a){if(a.name=='fadeOut'){a.Element.style.display='none';a.options.iframe.style.display='none'}else f.timeautohidedelay=window.setTimeout(f.hide.bind(f),f.options.autohidedelay)}})}else this.timeautohidedelay=window.setTimeout(this.hide.bind(this),this.options.autohidedelay);this.fade.Element.style.display='';this.iframe.style.display=''},delayHide:function(){this.timedelayhide=window.setTimeout(this.hide.bind(this),this.options.autohidedelay)},hide:function(){if(this.options.fade){this.fade.play({'from':100,'to':0})}else{this.fade.Element.style.display='none';this.iframe.style.display='none'}},cancleHideDelay:function(){this.req.abort();window.clearTimeout(this.timeautohidedelay);window.clearTimeout(this.timedelayhide);window.clearTimeout(this.delayout)}};
