/*************************************************************************
    This code is from Dynamic Web Coding at dyn-web.com
    Copyright 2008-2010 by Sharon Paine 
    See Terms of Use at www.dyn-web.com/business/terms.php
    regarding conditions under which you may use this code.
    This notice must be retained in the code as is!
    
    for use with dw_tooltip.js
    Version date: July 2010
*************************************************************************/
var dw_Event={add:function(a,b,c,d){a.addEventListener?a.addEventListener(b,c,d||false):a.attachEvent&&a.attachEvent("on"+b,c)},remove:function(a,b,c,d){a.removeEventListener?a.removeEventListener(b,c,d||false):a.detachEvent&&a.detachEvent("on"+b,c)},DOMit:function(a){a=a?a:window.event;if(!a.target)a.target=a.srcElement;if(!a.preventDefault)a.preventDefault=function(){return a.returnValue=false};if(!a.stopPropagation)a.stopPropagation=function(){a.cancelBubble=true};return a},getTarget:function(a){a=
dw_Event.DOMit(a);a=a.target;if(a.nodeType!=1)a=a.parentNode;return a}},dw_Viewport={getWinWidth:function(){this.width=0;if(window.innerWidth)this.width=window.innerWidth-18;else if(document.documentElement&&document.documentElement.clientWidth)this.width=document.documentElement.clientWidth;else if(document.body&&document.body.clientWidth)this.width=document.body.clientWidth;return this.width},getWinHeight:function(){this.height=0;if(window.innerHeight)this.height=window.innerHeight-18;else if(document.documentElement&&
document.documentElement.clientHeight)this.height=document.documentElement.clientHeight;else if(document.body&&document.body.clientHeight)this.height=document.body.clientHeight;return this.height},getScrollX:function(){this.scrollX=0;if(typeof window.pageXOffset=="number")this.scrollX=window.pageXOffset;else if(document.documentElement&&document.documentElement.scrollLeft)this.scrollX=document.documentElement.scrollLeft;else if(document.body&&document.body.scrollLeft)this.scrollX=document.body.scrollLeft;
else if(window.scrollX)this.scrollX=window.scrollX;return this.scrollX},getScrollY:function(){this.scrollY=0;if(typeof window.pageYOffset=="number")this.scrollY=window.pageYOffset;else if(document.documentElement&&document.documentElement.scrollTop)this.scrollY=document.documentElement.scrollTop;else if(document.body&&document.body.scrollTop)this.scrollY=document.body.scrollTop;else if(window.scrollY)this.scrollY=window.scrollY;return this.scrollY},getAll:function(){this.getWinWidth();this.getWinHeight();
this.getScrollX();this.getScrollY()}},dw_Tooltip={offX:12,offY:12,showDelay:100,hideDelay:100,hoverDelay:500,tipID:"tipDiv",actuatorClass:"showTip",maxLoops:2,activateOnfocus:true,provideShim:false,on_show:function(){},on_position:function(){},on_hide:function(){},tip:null,shim:null,timer:0,hoverTimer:0,active:false,actuator:null,resetFlag:false,restored:true,init:function(){var a=dw_Tooltip,b;if(a.hasSupport()){if(!(b=document.getElementById(a.tipID)))b=document.createElement("div"),b.id=a.tipID,
document.body.appendChild(b);b.style.position="absolute";b.style.visibility="hidden";b.style.zIndex=1E4;a.tip=document.getElementById(a.tipID);a.checkOverlaySupport()&&a.prepOverlay();a.setDefaults();a.setPosition(0,0)}},hasSupport:function(){return document.createElement&&document.getElementsByTagName&&(document.addEventListener||document.attachEvent)?true:false},setDefaults:function(){if(!this.defaultProps)this.defaultProps={};for(var a=this.props_list,b=0;a[b];b++)this[a[b][0]]=typeof this.defaultProps[a[b][0]]==
a[b][1]?this.defaultProps[a[b][0]]:a[b][2];this.tip.className=this.klass;this.coordinateOptions()},activate:function(a,b,c,d){var e=dw_Tooltip;if(e.tip&&(e.clearTimer("timer"),e.clearTimer("hoverTimer"),e.restored||e.handleRestore(),e.actuator=b,dw_Viewport.getAll(),e.getContent(a,b,c,d),e.restored=false,e.tip.innerHTML))e.active=true,e.handleOptions(a),e.positionFn(a,b),e.adjust(),e.timer=setTimeout(e.show,e.showDelay)},getContent:function(a,b,c,d){if(d&&!c)if(a=dw_Tooltip.defaultProps.content_source||
"content_vars",b=this.content_vars&&this.content_vars[d]?this.content_vars[d]:false,typeof b=="string")c=b;else if(typeof b=="object")if(this.checkForProps(b),a=="ajax"&&!b["static"]&&dw_Tooltip.initAjaxRequest(d),b.content)c=b.content;else if(b.html_id){if(d=document.getElementById(b.html_id))c=d.innerHTML}else c=b;this.writeTip(c)},writeTip:function(a){a=this.wrapFn(a);this.tip.innerHTML=a},positionRelEvent:function(a,b){var c=dw_Tooltip;if(typeof a=="object")if(a.type=="mouseover"||a.type=="mousemove")c.evX=
c.getMouseEventX(a),c.evY=c.getMouseEventY(a);else{var d=dw_Util.getPageOffsets(b);c.evX=d.x;c.evY=d.y}d=c.calcPosCoords(a,b);c.setPosition(d.x,d.y)},calcPosCoords:function(a,b){var c=this.evX,d=this.evY,e=this.getMaxX(),j=this.getMaxY(),k,l,f=c+this.offX,h=c-(this.width+this.offX),m=c-dw_Viewport.scrollX>dw_Viewport.width/2;if(typeof a=="object"&&a.type&&(a.type=="focus"||a.type=="focusin")){var g=b.offsetWidth;if(f+g<e)c=this.evX=c+g,f+=g;else if(f+20<e)c=this.evX=c+20,f+=20;d=this.evY=d+10}var g=
d+this.offY,i=d-(this.height+this.offY),n=d-dw_Viewport.scrollY>dw_Viewport.height/2;if(!this.Left&&f<e)c=f;else if(this.Left&&h>=dw_Viewport.scrollX||this.jumpLeft&&f>=e&&h>=dw_Viewport.scrollX)c=h;else if(this.Left&&h<dw_Viewport.scrollX||!this.Left&&this.jumpLeft&&h<dw_Viewport.scrollX&&m)c=dw_Viewport.scrollX,k="Left";else if(!this.Left&&f>=e&&(!this.jumpLeft||this.jumpLeft&&h<dw_Viewport.scrollX&&!m))c=e,k="Right";if(!this.Above&&g<j)d=g;else if(this.Above&&i>=dw_Viewport.scrollY||this.jumpAbove&&
g>=j&&i>=dw_Viewport.scrollY)d=i;else if(this.Above&&i<dw_Viewport.scrollY||!this.Above&&this.jumpAbove&&i<dw_Viewport.scrollY&&n)d=dw_Viewport.scrollY,l="Above";else if(!this.Above&&g>=j&&(!this.jumpAbove||this.jumpAbove&&i<dw_Viewport.scrollY&&!n))d=j,l="Below";k&&l&&((k=="Left"?dw_Viewport.scrollX-h:f-e)<=(l=="Above"?dw_Viewport.scrollY-i:g-j)?c=k=="Left"?h:f:d=l=="Above"?i:g);return{x:c,y:d}},adjust:function(){function a(){b.active&&(b.positionFn(),d&&!d.complete&&setTimeout(a,50))}var b=dw_Tooltip,
c=b.tip.getElementsByTagName("img"),d=c.length?c[c.length-1]:null;a()},setPosition:function(a,b){this.tip.style.left=a+"px";this.tip.style.top=b+"px";this.setOverlay();this.on_position()},show:function(){var a=dw_Tooltip;a.tip.style.visibility="visible";if(a.shim)a.shim.style.visibility="visible";a.on_show()},deactivate:function(a){var b=dw_Tooltip;if(b.tip&&b.active&&!b.sticky&&(a=a?a:window.event,!a.type||a.type!="mouseout"||dw_Util.mouseleave(a,b.actuator)))b.clearTimer("timer"),b.clearTimer("hoverTimer"),
b.hoverable?b.hoverTimer=setTimeout(b.hide,b.hoverDelay):b.timer=b.duration?setTimeout(b.hide,b.duration):setTimeout(b.hide,b.hideDelay)},hide:function(){var a=dw_Tooltip;if(a.tip){a.tip.style.visibility="hidden";if(a.shim)a.shim.style.visibility="hidden";a.handleRestore();a.on_hide()}},handleOptions:function(a){this.coordinateOptions();if(this.klass)this.tip.className=this.klass;this.hoverable?(this.tip.onmouseout=dw_Tooltip.tipOutCheck,this.tip.onmouseover=function(){dw_Tooltip.clearTimer("hoverTimer")}):
this.followMouse&&!(a.type=="focus"||a.type=="focusin")?dw_Event.add(document,"mousemove",this.positionRelEvent):(this.sticky||this.duration)&&dw_Event.add(document,"mouseup",dw_Tooltip.checkDocClick)},coordinateOptions:function(){if(this.sticky||this.hoverable||this.duration)this.followMouse=false;if(this.sticky)this.hoverable=false,this.duration=0;if(this.hoverable)this.duration=0;if(this.positionFn!=this.positionRelEvent)this.followMouse=false},handleRestore:function(){this.followMouse?dw_Event.remove(document,
"mousemove",this.positionRelEvent):(this.sticky||this.duration)&&dw_Event.remove(document,"mouseup",dw_Tooltip.checkDocClick,false);this.tip.onmouseover=this.tip.onmouseout=function(){};this.resetFlag&&this.setDefaults();this.resetRequest();this.writeTip("");this.active=false;this.actuator=null;this.tip.style.width="";this.restored=true},getTipClass:function(a){if(!a)return"";for(var b="",a=a.split(/\s+/),c=0;a[c];c++)if(a[c]==this.actuatorClass&&a[c+1]){b=a[c+1];break}return b},checkForProps:function(a){for(var b=
this.props_list,c=0;b[c];c++)if(typeof a[b[c][0]]!="undefined")this[b[c][0]]=a[b[c][0]],this.resetFlag=true},tipOutCheck:function(a){var b=dw_Tooltip;if(dw_Util.mouseleave(a,this))b.timer=setTimeout(b.hide,b.hideDelay)},checkEscKey:function(a){a=a?a:window.event;a.keyCode==27&&dw_Tooltip.hide()},checkDocClick:function(a){if(dw_Tooltip.active){var a=dw_Event.getTarget(a),b=document.getElementById(dw_Tooltip.tipID);if(a==b||dw_Util.contained(a,b)){if(a.tagName&&a.tagName.toLowerCase()=="img")a=a.parentNode;
if(a.tagName.toLowerCase()!="a"||a.href.indexOf("dw_Tooltip.hide")!=-1)return}dw_Tooltip.timer=setTimeout(dw_Tooltip.hide,50)}},checkOverlaySupport:function(){return this.provideShim&&navigator.userAgent.indexOf("Windows")!=-1&&typeof document.body!="undefined"&&typeof document.body.insertAdjacentHTML!="undefined"&&!window.opera&&navigator.appVersion.indexOf("MSIE 5.0")==-1?true:false},prepOverlay:function(){document.body.insertAdjacentHTML("beforeEnd",'<iframe id="tipShim" src="javascript: false" style="position:absolute; left:0; top:0; z-index:500; visibility:hidden" scrolling="no" frameborder="0"></iframe>');
if((this.shim=document.getElementById("tipShim"))&&this.tip)this.shim.style.width=this.tip.offsetWidth+"px",this.shim.style.height=this.tip.offsetHeight+"px"},setOverlay:function(){if(this.shim)this.shim.style.left=this.tip.style.left,this.shim.style.top=this.tip.style.top,this.shim.style.width=this.tip.offsetWidth+"px",this.shim.style.height=this.tip.offsetHeight+"px"},clearTimer:function(a){dw_Tooltip[a]&&(clearTimeout(dw_Tooltip[a]),dw_Tooltip[a]=0)},initAjaxRequest:function(){},resetRequest:function(){},
getWidth:function(){return this.width=this.tip.offsetWidth},getHeight:function(){return this.height=this.tip.offsetHeight},getMaxX:function(){return dw_Viewport.width+dw_Viewport.scrollX-this.getWidth()-1},getMaxY:function(){return dw_Viewport.height+dw_Viewport.scrollY-this.getHeight()-1},getMouseEventX:function(a){return a.pageX?a.pageX:a.clientX+dw_Viewport.scrollX},getMouseEventY:function(a){return a.pageY?a.pageY:a.clientY+dw_Viewport.scrollY}};
dw_Tooltip.props_list=[["klass","string",""],["followMouse","boolean",true],["sticky","boolean",false],["hoverable","boolean",false],["duration","number",0],["jumpAbove","boolean",true],["jumpLeft","boolean",true],["Left","boolean",false],["Above","boolean",false],["positionFn","function",dw_Tooltip.positionRelEvent],["wrapFn","function",function(a){return a}]];
dw_Tooltip.initHandlers=function(){dw_Event.add(document,"mouseover",dw_Tooltip.checkActuatorMouseover);dw_Event.add(document,"keydown",dw_Tooltip.checkEscKey,true);dw_Event.add(window,"blur",dw_Tooltip.deactivate,true);dw_Event.add(window,"unload",dw_Tooltip.deactivate,true);dw_Tooltip.activateOnfocus&&(window.addEventListener?dw_Event.add(document,"focus",dw_Tooltip.checkActuatorFocus,true):window.attachEvent&&dw_Event.add(document,"focusin",dw_Tooltip.checkActuatorFocus))};
dw_Tooltip.checkActuatorMouseover=function(a){var b=dw_Event.getTarget(a),c=null,d=0,e=dw_Tooltip.maxLoops;do{if(c=dw_Tooltip.getActuatorInfo(b)){dw_Tooltip.activate(a,b,c.msg,c.id);window.attachEvent&&dw_Event.remove(b,"mouseout",dw_Tooltip.deactivate);dw_Event.add(b,"mouseout",dw_Tooltip.deactivate);break}d++}while(d<e&&(b=b.parentNode))};
dw_Tooltip.checkActuatorFocus=function(a){var b=dw_Event.getTarget(a),c=null;if(b&&(c=dw_Tooltip.getActuatorInfo(b))&&!(dw_Tooltip.active&&b==dw_Tooltip.actuator))dw_Tooltip.activate(a,b,c.msg,c.id),window.addEventListener?dw_Event.add(b,"blur",dw_Tooltip.deactivate,true):window.attachEvent&&dw_Event.add(b,"focusout",dw_Tooltip.deactivate)};
dw_Tooltip.getActuatorInfo=function(a){var b=dw_Tooltip.getTipClass(a.className);if(!b)return"";var c=dw_Tooltip.defaultProps.content_source||"content_vars",d=a="";dw_Tooltip.content_vars&&(d=dw_Tooltip.content_vars[b]?b:"");if(!d&&c=="class_id"&&(b=document.getElementById(b)))a=b.innerHTML;return d||a?{msg:a,id:d}:false};var dw_Util;dw_Util||(dw_Util={});
dw_Util.mouseleave=function(a,b){var a=dw_Event.DOMit(a),c=a.relatedTarget?a.relatedTarget:a.toElement?a.toElement:null;return b!=c&&!dw_Util.contained(c,b)?true:false};dw_Util.contained=function(a,b){if(!a)return null;for(;a=a.parentNode;)if(a==b)return true;return false};dw_Util.getPageOffsets=function(a){var b=0,c=0;do b+=a.offsetLeft,c+=a.offsetTop;while(a=a.offsetParent);return{x:b,y:c}};dw_Tooltip.writeStyleRule=function(){dw_Tooltip.hasSupport()&&document.write('<style type="text/css" media="screen">.tipContent { display:none; }</style>')};
dw_Event.add(window,"load",dw_Tooltip.init);dw_Event.add(window,"load",dw_Tooltip.initHandlers);dw_Tooltip.positionWindowCenter=function(){var a=Math.round((dw_Viewport.width-dw_Tooltip.tip.offsetWidth)/2)+dw_Viewport.scrollX,b=Math.round((dw_Viewport.height-dw_Tooltip.tip.offsetHeight)/2)+dw_Viewport.scrollY;dw_Tooltip.setPosition(a,b)};
dw_Tooltip.wrapSticky=function(a,b){return'<table id="stickyTable" border="0" cellpadding="0" cellspacing="0" width="100%"><tr class="stickyBar"><td><div class="stickyTitle">'+(b||"")+'</div></td><td style="text-align:right"><a href="javascript: void dw_Tooltip.hide()"><img style="float:right" src="'+dw_Tooltip.defaultProps.closeBoxImage+'" border="0" /></a></td></tr><tr><td colspan="2"><div class="stickyContent">'+a+"</div></td></tr></table>"};
dw_Tooltip.wrapToWidth=function(a){if(!a)return"";var b=a.str,c=a.caption||"";this.sticky&&this.defaultProps.showCloseBox?b=dw_Tooltip.wrapSticky(b,c):c&&(b='<div class="caption">'+a.caption+"</div>"+b);a.w&&this.setTipWidth(a.w);return b};
dw_Tooltip.wrapImageToWidth=function(a){if(!a)return"";dw_Util.getImage(a.img);var b=a.caption||"",c=a.w,d='<img src="'+a.img+'" width="'+c+'" height="'+a.h+'" alt="">';this.sticky&&this.defaultProps.showCloseBox?(d=dw_Tooltip.wrapSticky(d,b),c+=8):b&&(d='<div class="caption">'+a.caption+"</div>"+d);c&&this.setTipWidth(c);return d};
dw_Tooltip.wrapTextByImage=function(a){if(!a)return"";dw_Util.getImage(a.img);var b=a.caption||"",c='<table cellpadding="0" cellspacing="0" border="0"><tr><td><div class="txt">'+a.txt+'</div></td><td><div class="img"><img src="'+a.img+'" /></div></td></tr></table>';this.sticky&&this.defaultProps.showCloseBox?c=dw_Tooltip.wrapSticky(c,b):b&&(c='<div class="caption">'+a.caption+"</div>"+c);a.w&&this.setTipWidth(a.w);return c};
dw_Tooltip.wrapImageOverText=function(a){if(!a)return"";dw_Util.getImage(a.img);var b=a.caption||"",c='<div class="img"><img src="'+a.img+'" /></div><div class="txt">'+a.txt+"</div>";this.sticky&&this.defaultProps.showCloseBox?c=dw_Tooltip.wrapSticky(c,b):b&&(c='<div class="caption">'+a.caption+"</div>"+c);a.w&&this.setTipWidth(a.w);return c};
dw_Tooltip.wrapTextOverImage=function(a){if(!a)return"";dw_Util.getImage(a.img);var b=a.caption||"",c='<div class="txt">'+a.txt+'</div><div class="img"><img src="'+a.img+'" /></div>';this.sticky&&this.defaultProps.showCloseBox?c=dw_Tooltip.wrapSticky(c,b):b&&(c='<div class="caption">'+a.caption+"</div>"+c);a.w&&this.setTipWidth(a.w);return c};dw_Tooltip.setTipWidth=function(a){a=parseInt(a)+dw_Util.forBackCompatWidth(this.tip);this.tip.style.width=a+"px"};dw_Util||(dw_Util={});
dw_Util.getImage=function(a){(new Image).src=a};dw_Util.forBackCompatWidth=function(a){var b=0;if(a.currentStyle&&!window.opera&&(document.compatMode==null||document.compatMode=="BackCompat"))var b=parseInt(dw_Util.getCurrentStyle(a,"paddingLeft")),c=parseInt(dw_Util.getCurrentStyle(a,"paddingRight")),d=parseInt(dw_Util.getCurrentStyle(a,"borderLeftWidth")),a=parseInt(dw_Util.getCurrentStyle(a,"borderRightWidth")),b=(!isNaN(b)?b:0)+(!isNaN(c)?c:0)+(!isNaN(d)?d:0)+(!isNaN(a)?a:0);return b};
dw_Util.getCurrentStyle=function(a,b){var c="";if(document.defaultView&&document.defaultView.getComputedStyle)c=document.defaultView.getComputedStyle(a,null)[b];else if(a.currentStyle&&(c=a.currentStyle[b],!/^\d+(px)?$/i.test(c)&&/^\d/.test(c))){var d=a.style.left,e=a.runtimeStyle.left;a.runtimeStyle.left=a.currentStyle.left;a.style.left=c||0;c=a.style.pixelLeft+"px";a.style.left=d;a.runtimeStyle.left=e}return c};
