function CalloutInterface(){this.calloutId=null;this.elemId=null;this.anchorId=null;this.calloutPadding=0;this.erase=CalloutInterface_Erase;this.draw=CalloutInterface_Draw;this.alignElement=CalloutInterface_AlignElement;this.disableScroll=false;this.getAnchorX=AnchoredInterface_GetAnchorX;this.getAnchorY=AnchoredInterface_GetAnchorY;this.getAnchorZ=AnchoredInterface_GetAnchorZ;this.getAnchorWidth=AnchoredInterface_GetAnchorWidth;this.getAnchorHeight=AnchoredInterface_GetAnchorHeight;this.getElemWidth=AnchoredInterface_GetElemWidth;this.getElemHeight=AnchoredInterface_GetElemHeight;this.getAnchorPosition=AnchoredInterface_GetAnchorPosition;this.setAnchor=AnchoredInterface_SetAnchor;this.implement(AnchoredInterface);return this;}
CalloutInterface.prototype=new Interface;CalloutInterface.prototype.constructor=CalloutInterface;CalloutInterface.superclass=Interface.prototype;CalloutInterface.settings={images:{left:{src:util.resourceManager.get('http://i.pgcdn.com/images/balloon/left_arrow.gif'),height:23,width:11},top:{src:util.resourceManager.get('http://i.pgcdn.com/images/balloon/top_arrow.gif'),height:11,width:23},right:{src:util.resourceManager.get('http://i.pgcdn.com/images/balloon/right_arrow.gif'),height:21,width:11},bottom:{src:util.resourceManager.get('http://i.pgcdn.com/images/balloon/bottom_arrow.gif'),height:11,width:23}}};function CalloutInterface_Erase(){var callout=document.getElementById(this.calloutId);if(callout){DomUtils.removeElement(callout);}
callout=null;}
function CalloutInterface_Draw(){if(!this.calloutId)this.calloutId=this.id+'_Callout';var elem=document.getElementById(this.elemId);if(!elem)throw new Error('Unable to find element: '+this.elemId);var anchor=document.getElementById(this.anchorId);if(!anchor)throw new Error('Unable to find anchor element: '+this.anchorId);if(elem&&anchor){elem.style.padding='1px';elem.style.border='1px solid #dadada';var callout=document.getElementById(this.calloutId);if(callout&&callout.parentNode)DomUtils.removeElement(callout);var pos=this.getAnchorPosition();callout=document.createElement('img');callout.id=this.calloutId;callout.style.position='absolute';callout.style.visibility='hidden';var body=document.getElementsByTagName('body')[0];body.appendChild(callout);var imgDetails;switch(pos){case AnchoredInterface.ALIGN.RIGHT_TOP:imgDetails=CalloutInterface.settings.images.top;callout.src=util.resourceManager.get(imgDetails.src);callout.height=imgDetails.height;callout.width=imgDetails.width;callout.style.left=this.calloutPadding+'px';break;case AnchoredInterface.ALIGN.RIGHT_BOTTOM:imgDetails=CalloutInterface.settings.images.top;callout.src=util.resourceManager.get(imgDetails.src);callout.height=imgDetails.height;callout.width=imgDetails.width;break;case AnchoredInterface.ALIGN.LEFT_TOP:imgDetails=CalloutInterface.settings.images.top;callout.src=util.resourceManager.get(imgDetails.src);callout.height=imgDetails.height;callout.width=imgDetails.width;break;case AnchoredInterface.ALIGN.LEFT_BOTTOM:default:imgDetails=CalloutInterface.settings.images.bottom;callout.src=util.resourceManager.get(imgDetails.src);callout.height=imgDetails.height;callout.width=imgDetails.width;break;}
}
}
function CalloutInterface_AlignElement(pos){pos=pos||this.getAnchorPosition();var elem=document.getElementById(this.elemId);if(!elem)throw new Error('Unable to find element: '+this.elemId);var callout=document.getElementById(this.calloutId);if(!callout)throw new Error('Unable to find callout element: '+this.calloutId);var anchor=document.getElementById(this.anchorId);if(!anchor)throw new Error('Unable to find anchor element: '+this.anchorId);var aTop=parseInt(DomUtils.getElementTop(anchor));var aLeft=parseInt(DomUtils.getElementLeft(anchor));var aHeight=parseInt(DomUtils.getElementHeight(anchor));var aWidth=parseInt(DomUtils.getElementWidth(anchor));var eTop=parseInt(DomUtils.getElementTop(elem));var eLeft=parseInt(DomUtils.getElementLeft(elem));var eHeight=parseInt(DomUtils.getElementHeight(elem));var eWidth=parseInt(DomUtils.getElementWidth(elem));var cHeight=parseInt(DomUtils.getElementHeight(callout));var cWidth=parseInt(DomUtils.getElementWidth(callout));switch(pos){case AnchoredInterface.ALIGN.RIGHT_TOP:elem.style.top=parseInt(eTop+cHeight)+'px';elem.style.left=parseInt(eLeft+this.calloutPadding)+'px';callout.style.left=parseInt(aLeft+parseInt(aWidth/2)-parseInt(cWidth/2))+'px';callout.style.top=parseInt(aTop+aHeight+1)+'px';callout.style.zIndex=parseInt(DomUtils.getZIndex(elem))+1;break;case AnchoredInterface.ALIGN.RIGHT_BOTTOM:elem.style.top=parseInt(eTop+cHeight-1)+'px';elem.style.left=parseInt(eLeft+this.calloutPadding)+'px';callout.style.left=parseInt(aLeft+parseInt(aWidth/2)-parseInt(cWidth/2))+'px';callout.style.top=parseInt(aTop+aHeight)+'px';callout.style.zIndex=parseInt(DomUtils.getZIndex(elem))+1;break;case AnchoredInterface.ALIGN.LEFT_TOP:elem.style.top=parseInt(eTop+cHeight-1)+'px';elem.style.left=parseInt(eLeft-this.calloutPadding)+'px';callout.style.left=parseInt(aLeft+parseInt(aWidth/2)-parseInt(cWidth/2)-1)+'px';callout.style.top=parseInt(aTop+aHeight)+'px';callout.style.zIndex=parseInt(DomUtils.getZIndex(elem))+1;break;case AnchoredInterface.ALIGN.LEFT_BOTTOM:default:elem.style.top=parseInt(eTop-cHeight-2)+'px';elem.style.left=parseInt(eLeft-this.calloutPadding)+'px';callout.style.left=parseInt(aLeft-parseInt(cWidth/2)+parseInt(aWidth/2)-1)+'px';callout.style.top=parseInt(aTop-cHeight)+'px';callout.style.zIndex=parseInt(DomUtils.getZIndex(elem))+1;break;}
}

