
if(!window.Richfaces){window.Richfaces={};}
Richfaces.ToolTip={};Richfaces.ToolTip.cumulativeOffset=function(element)
{var valueT=0,valueL=0;do{if(window.opera&&Richfaces.getComputedStyle(element,'position')=='fixed')
{valueT+=Richfaces.getComputedStyleSize(element,"top");valueL+=Richfaces.getComputedStyleSize(element,"left");}
else
{valueT+=element.offsetTop||0;valueL+=element.offsetLeft||0;}
element=element.offsetParent;}while(element);return Element._returnOffset(valueL,valueT);};ToolTip=Class.create();ToolTip.prototype={initialize:function(events,functions,id,parentId,mode,disabled,direction,followMouse,horizontalOffset,verticalOffset,ajaxFunction,ajaxOptions){this["rich:destructor"]="destroy";this.showEvent=events.showEvent;this.hideEvent=events.hideEvent!=""?events.hideEvent:null;this.onshow=functions.onshow;this.oncomplete=functions.oncomplete;this.onhide=functions.onhide;this.delay=events.delay;this.hideDelay=events.hideDelay;this.id=id;this.parentId=parentId;this.parent=$(this.parentId);this.mode=mode;this.direction=direction;this.disabled=disabled;this.followMouse=followMouse;this.horizontalOffset=horizontalOffset;this.verticalOffset=verticalOffset;this.ajaxExecuteString=ajaxFunction;this.ajaxOptions=ajaxOptions;this.clientAjaxParams={};this.toolTip=$(id);this.toolTip.component=this;this.toolTipContent=$(id+'content');this.toolTipDefaultContent=$(id+'defaultContent');this.toolTip.style.visibility='hidden';this.toolTip.style.display='block';this.toolTipOffsetW=this.toolTip.offsetWidth;this.toolTipOffsetH=this.toolTip.offsetHeight;this.toolTipW=this.toolTip.getWidth();this.toolTipH=this.toolTip.getHeight();this.toolTipBorderHeight=(this.toolTipOffsetH-this.toolTipH)/2;this.toolTipBorderWidth=(this.toolTipOffsetW-this.toolTipW)/2;this.toolTip.style.visibility='visible';this.toolTip.style.display="none";this.parentAttached=false;this.hintParentElement=null;this.isMouseOvered=false;if(Richfaces.browser.isIE6){var toolTipZindex=parseInt(this.toolTip.style.zIndex);new Insertion.Before(this.toolTip,"<iframe src=\"javascript:''\" frameborder=\"0\" scrolling=\"no\" id=\""+this.id+"iframe\""+"style=\"position: absolute; width: "+this.toolTipOffsetW+"px; height: "+this.toolTipOffsetH+"px; display: none;background-color:black; z-index: "+
+(toolTipZindex-1)+";\">"+"</iframe>");this.iframe=$(this.id+'iframe');}
this.attachOnLoadEventsListner=this.attachOnLoadEvents.bindAsEventListener(this);this.setToolTipPositionListner=this.setToolTipPosition.bindAsEventListener(this);this.leaveToolTipListner=this.leaveToolTip.bindAsEventListener(this);if(!this.disabled)Event.observe(document,"mousemove",this.attachOnLoadEventsListner,true);},destroy:function()
{if(this.toolTip){this.toolTip.component=null;}
this.doDisable();this.hintParentElement=null;this.parent=null;this.toolTip=null;this.toolTipContent=null;this.toolTipDefaultContent=null;this.iframe=null;this.eventCopy=null;this.showEvent=null;this.hideEvent=null;},attachOnLoadEvents:function(){if(!this.parentAttached){if(this.parent!=null&&!this.disabled){this.attachParentEvents();this.parentAttached=true;}
Event.stopObserving(document,"mousemove",this.attachOnLoadEventsListner,true);}},attachParentEvents:function(){if(this.followMouse){Event.observe(this.parent,'mousemove',this.setToolTipPositionListner,false);}
this.doShowListner=this.doShow.bindAsEventListener(this);this.doHideListner=this.doHide.bindAsEventListener(this);Event.observe(this.parent,this.showEvent,this.doShowListner,false);if(this.showEvent!="focus"){if(this.hideEvent!=null){Event.observe(this.parent,this.hideEvent,this.doHideListner,false);Event.observe(this.toolTip,this.hideEvent,this.leaveToolTipListner,false);}else{Event.observe(this.parent,"mouseout",this.doHideListner,false);Event.observe(this.toolTip,"mouseout",this.leaveToolTipListner,false);}}else{if(this.hideEvent!=null){Event.observe(this.parent,this.hideEvent,this.doHideListner,false);}else{Event.observe(this.parent,"blur",this.doHideListner,false);}}},detectAncestorNode:function(leaf,element){var node=leaf;while(node!=null&&node!=element)
{node=node.parentNode;}
return(node!=null);},ffcheck:function(relTarg)
{if(this.parent.tagName.toLowerCase()=="input"&&relTarg){var className;try{className=relTarg.className;if(className=="anonymous-div")return true;}catch(e)
{return true;}
if(relTarg==this.parent)return true;}else{while(relTarg){if(relTarg==this.parent){return true;}
relTarg=relTarg.parentNode;}}
return false;},leaveToolTip:function(e){var hintNotLeft=false;var relTarg=e.relatedTarget||e.toElement;var className;if(relTarg)
{try{className=relTarg.className;if(className!="anonymous-div");hintNotLeft=this.detectAncestorNode(relTarg,this.hintParentElement);}catch(e){;}}
if(!hintNotLeft){this.doHide(e);this.isMouseOvered=false;}},doShow:function(e){if(this.disabled){return;}
if(this.activationTimerHandle)return;this.setScrollDelta();var obj;if(!e)var e=window.event;var relTarg=e.relatedTarget||e.fromElement;if(this.ffcheck(relTarg))return;var className;if(relTarg)
{try{className=relTarg.className;if(className!="anonymous-div");if(this.detectAncestorNode(relTarg,this.toolTip))return;}catch(e){;}}
this.isMouseOvered=true;if(e.target)
this.hintParentElement=e.target;if(e.srcElement)
this.hintParentElement=e.srcElement;if(this.mode=='ajax'){if(this.toolTipDefaultContent){this.toolTipContent.innerHTML=this.toolTipDefaultContent.innerHTML;this.toolTip.style.visibility="hidden";this.toolTip.style.display='block';this.setToolTipPosition(e);this.setToolTipVisible(false);}
var event=e;var ajaxOptions=this.ajaxOptions;if(this.clientAjaxParams){if(e.clientX){this.clientAjaxParams['clientX']=e.clientX;this.clientAjaxParams['clientY']=e.clientY;}else{this.clientAjaxParams['event.pageX']=e.pageX;this.clientAjaxParams['event.pageY']=e.pageY;}
Object.extend(ajaxOptions['parameters'],this.clientAjaxParams);}
eval(this.ajaxExecuteString);}else{this.setToolTipPosition(e);if(this.hidingTimerHandle)
{window.clearTimeout(this.hidingTimerHandle);this.hidingTimerHandle=undefined;}
if(this.delay>0)
{this.activationTimerHandle=window.setTimeout(function()
{this.displayDiv();}.bindAsEventListener(this),this.delay);}
else this.displayDiv();}},hideDiv:function(e)
{this.isMouseOvered=false;this.toolTip.style.visibility="hidden";this.toolTip.style.display="none";if(this.iframe){this.iframe.style.display="none";}
this.hintParentElement=null;this.isMouseOvered=false;if(this.onhide!=null)
{this.onhide(e);}
this.scrollDelta=undefined;},doHide:function(e){if(this.hidingTimerHandle)return;this.eventCopy=null;if(!e)var e=window.event;var relTarg=e.relatedTarget||e.toElement;if(this.ffcheck(relTarg))return;if(this.activationTimerHandle){window.clearTimeout(this.activationTimerHandle);this.activationTimerHandle=undefined;}
var className;if(relTarg)
{try{className=relTarg.className;if(className!="anonymous-div");if(this.detectAncestorNode(relTarg,this.toolTip))return;}catch(e){;}}
if(this.activationTimerHandle)
{window.clearTimeout(this.activationTimerHandle);this.activationTimerHandle=undefined;}
if(this.hideDelay>0)
{var event=A4J.AJAX.CloneObject(e,false);this.hidingTimerHandle=window.setTimeout(function()
{this.hideDiv(event);}.bindAsEventListener(this),this.hideDelay);}
else this.hideDiv();},doEnable:function(){if(!this.parentAttached){Event.observe(document,"mousemove",this.attachOnLoadEventsListner,true);}
this.disabled=false;},doDisable:function(){if(!this.parentAttached){if(!this.disabled){Event.stopObserving(document,"mousemove",this.attachOnLoadEventsListner,true);}}else{if(this.followMouse){Event.stopObserving(this.parent,'mousemove',this.setToolTipPositionListner,false);}
Event.stopObserving(this.parent,this.event,this.doShowListner,false);if(this.showEvent!="focus"){if(this.hideEvent!=null){Event.stopObserving(this.parent,this.hideEvent,this.doHideListner,false);Event.stopObserving(this.toolTip,this.hideEvent,this.leaveToolTipListner,false);}else{Event.stopObserving(this.parent,"mouseout",this.doHideListner,false);Event.stopObserving(this.toolTip,"mouseout",this.leaveToolTipListner,false);}}else{if(this.hideEvent!=null){Event.stopObserving(this.parent,this.hideEvent,this.doHideListner,false);}else{Event.stopObserving(this.parent,"blur",this.doHideListner,false);}}
this.parentAttached=false;}
this.disabled=true;},show:function(e){this.doShow(e);},hide:function(e){this.doHide(e);},enable:function(e){this.doEnable(e);},disable:function(e){this.doDisable(e);},setScrollDelta:function(){if(!this.scrollDelta){this.scrollDelta=[0,0];}
var parentNode=this.parent;while(parentNode&&!/^body$/i.test(parentNode.tagName)){if(/^absolute$/i.test(Richfaces.getComputedStyle(parentNode,"position"))){if(parentNode.scrollLeft){this.scrollDelta[0]=parentNode.scrollLeft;}
if(parentNode.scrollTop){this.scrollDelta[1]=parentNode.scrollTop;}}
parentNode=parentNode.parentNode;}},setToolTipPosition:function(e){var toolTipX=0;var toolTipY=0;var x=Event.pointerX(e);var y=Event.pointerY(e);var elementDim=Richfaces.Position.getOffsetDimensions(this.toolTip);var _display=this.toolTip.style.display;var _visibility=this.toolTip.style.visibility;this.toolTip.style.visibility="hidden";this.toolTip.style.display="block";this.toolTip.style.top="0px";this.toolTip.style.left="0px";var offsets=Richfaces.ToolTip.cumulativeOffset(this.toolTip);this.toolTip.style.visibility=_visibility;this.toolTip.style.display=_display;offsets[0]-=this.toolTip.offsetLeft||0;offsets[1]-=this.toolTip.offsetTop||0;toolTipX=x-offsets[0];toolTipY=y-offsets[1];var regExpression=/^(top|bottom)-(left|right)$/;var match=this.direction.match(regExpression);var horizontalDirection=match[2];var verticalDirection=match[1];this.prePosition({'x':toolTipX,'y':toolTipY},elementDim,horizontalDirection,verticalDirection,{'x':this.horizontalOffset,'y':this.verticalOffset});var coords=this.fitToolTip(e.clientX,e.clientY,{'x':toolTipX,'y':toolTipY},elementDim,horizontalDirection,verticalDirection,{'x':this.horizontalOffset,'y':this.verticalOffset});if(this.scrollDelta){coords.x+=this.scrollDelta[0];coords.y+=this.scrollDelta[1];}
Element.setStyle(this.toolTip,{"left":coords.x+"px","top":coords.y+"px"});if(this.iframe)
{this.iframe.style.top=(coords.y-this.toolTipBorderHeight)+'px';this.iframe.style.left=(coords.x-this.toolTipBorderWidth)+'px';}
this.eventCopy=A4J.AJAX.CloneObject(e,false);},prePosition:function(basePoint,elementDim,horizontalDirection,verticalDirection,offset){var returnX,returnY;returnX=horizontalDirection=='left'?basePoint.x-elementDim.width-offset.x:basePoint.x+=offset.x;returnY=verticalDirection=='top'?basePoint.y-elementDim.height-offset.y:basePoint.y+offset.y;return{'x':returnX,'y':returnY};},fitToolTip:function(clientX,clientY,basePoint,elementDim,horizontalDirection,verticalDirection,offset){var winDim=Richfaces.Position.getWindowDimensions();var deltaLeft=clientX-offset.x-elementDim.width;var deltaRight=winDim.width-(clientX+offset.x+elementDim.width);var deltaTop=clientY-offset.y-elementDim.height;var deltaBottom=winDim.height-(clientY+offset.y+elementDim.height);if(deltaLeft<0){this.prePosition({'x':basePoint.x,'y':basePoint.y},elementDim,'right',verticalDirection,offset);var newDeltaRight=winDim.width-(clientX+offset.x+elementDim.width);if(newDeltaRight>0){horizontalDirection='right';}else{if(newDeltaRight>deltaLeft){horizontalDirection='right';}}}else if(deltaRight<0){this.prePosition({'x':basePoint.x,'y':basePoint.y},elementDim,'left',verticalDirection,offset);var newDeltaLeft=clientX-offset.x-elementDim.width;if(newDeltaLeft>0){horizontalDirection='left';}else{if(newDeltaLeft>deltaRight){horizontalDirection='left';}}}
if(deltaTop<0){this.prePosition({'x':basePoint.x,'y':basePoint.y},elementDim,horizontalDirection,'bottom',offset);var newDeltaBottom=winDim.height-(clientY+offset.y+elementDim.height);if(newDeltaBottom>0){verticalDirection='bottom';}else{if(newDeltaBottom>deltaTop){verticalDirection='bottom';}}}else if(deltaBottom<0){this.prePosition({'x':basePoint.x,'y':basePoint.y},elementDim,horizontalDirection,'top',offset);var newDeltaTop=clientY-offset.y-elementDim.height;if(newDeltaTop>0){verticalDirection='top';}else{if(newDeltaTop>deltaBottom){verticalDirection='top';}}}
var coords=this.prePosition({'x':basePoint.x,'y':basePoint.y},elementDim,horizontalDirection,verticalDirection,offset);return coords;},displayDiv:function(){if(this.isMouseOvered){if(this.mode=='ajax'){this.toolTip.style.display='none';if(this.clientAjaxParams){var xVarName;if(this.clientAjaxParams.clientX){xVarName='clientX';}else{xVarName='pageX';}
var yVarName;if(this.clientAjaxParams.clientY){yVarName='clientY';}else{yVarName='pageY';}
var obj={};obj[xVarName]=this.clientAjaxParams[xVarName];obj[yVarName]=this.clientAjaxParams[yVarName];this.toolTip.style.visibility="hidden";this.toolTip.style.display='block';this.setToolTipPosition((this.eventCopy?this.eventCopy:obj));}}
if(this.onshow!=null)
{this.onshow(this.eventCopy);}
this.setToolTipVisible(true);}},setToolTipVisible:function(runOnComplete){this.activationTimerHandle=undefined;this.toolTip.style.display="block";this.toolTip.style.visibility="visible";if(this.iframe)
{this.iframe.style.display="block";}
if(runOnComplete){if(this.oncomplete!=null)
{this.oncomplete(window.event);}}}}