
dojo.require("dijit.Tooltip");
dojo.declare("gtk.Tooltip", dijit.Tooltip,	{});
dojo.declare("gtk._MasterTooltip", dijit._MasterTooltip,	{
	 show: function( /*DomNode*/ aroundNode, fromNode){
                if(this.fadeOut.status() == "playing"){
                    // previous tooltip is being hidden; 
                    // wait until the hide completes then show new one
                    this._onDeck=arguments;
                    return;
                }
             //   this.containerNode.innerHTML= aroundNode;
				 this.containerNode.innerHTML ="";
				var cp = new dijit.layout.ContentPane({
	        	    content:"",
	            	style: "height:150px"
		        }).placeAt(this.containerNode);
				cp.attr("href", aroundNode.href+"?type=3");
                this.domNode.style.top = (this.domNode.offsetTop + 1) + "px";
    			var align = {'TL' : 'BL'};
			 	var imageCords = dojo.coords(fromNode, true);
				var coords = aroundNode.coords.split(",");

				var _x = parseInt(imageCords.x)+parseInt(coords[0]);
				var _y = parseInt(imageCords.y)	+parseInt(coords[1]); 

                var pos = dijit.placeOnScreen(this.domNode, {x: _x, y: _y}, ["BL"]);
				this.domNode.className="dijitTooltip dijitTooltipBelow";
    
                dojo.style(this.domNode, "opacity", 0);
                this.fadeIn.play();
                this.isShowingNow = true;
          		this.aroundNode=aroundNode;
			
     },
      close: function(){
                        // summary:
                        //              Hide the tooltip or cancel timer for show of tooltip
                        // tags:
                        //              private
					
                       if(this._connectNode){
                                // if tooltip is currently shown
                                dijit.hideTooltip(this._connectNode);
                            	delete this._connectNode;
                        }
                       if(this._showTimer){
                               // if tooltip is scheduled to be shown (after a brief delay)
                                clearTimeout(this._showTimer);
                               delete this._showTimer;
                        }
                }
	
});

gtk.showTooltip = function(/*DomNode*/ aroundNode, fromNode){
     	if(!gtk._masterTT){ 
			gtk._masterTT = new gtk._MasterTooltip();
			
			dojo.connect(gtk._masterTT.domNode,"onmouseleave",function (evt){
						gtk._masterTT.hide(gtk._masterTT.aroundNode);
					
				} );  
				
			dojo.connect(gtk._masterTT.domNode,"onclick",function (evt){
						window.location.href = gtk._masterTT.aroundNode.href;
					
				} );  
		}
		gtk._masterTT.aroundNode = aroundNode;
		gtk._masterTT.show(aroundNode, fromNode)
		return gtk._masterTT;
};
