﻿VocusBalloon = Class.create();
VocusBalloon.prototype = 
{
	initialize: function()
	{
        this._balloonAjaxOptions = 
			        {
				        method:		'get',
				        asynchronous: true,
				        parameters: 	null,
				        onComplete: 	null
			        };
        			
        this._balloonAjaxRequest = null;
        this._showTimerId = null;
        this._balloonCurrentElement = null;
        this._balloonPageName = null;
        this._balloonId = null;
        this._startX = -1;
        this._startY = -1;
        this._lastX = -1;
        this._lastY = -1;
        this._visible = false;
        this.balloon = null;
        this.lastElement = null;
				this.win = null;
				this.startShow = false;
				this.track = false;
	 		if (document.all)
	 		{
	 			Event.observe(window, 'unload', this.cleanup.bindAsEventListener(this), false);
	 		}
	 		else
	 			window.addEventListener("unload", this.cleanup.bindAsEventListener(this),  false);
		},
		cleanup: function()
		{
			cleanupBalloon(this);
		},
    showBalloon: function(element, pageName, id, win)
    {	
			if (this._balloonCurrentElement)
			this.startShow = true;
        if (element != this._balloonCurrentElement)
        {             
            if (this._showTimerId != null)
            {
                clearTimeout(this._showTimerId);
                this._showTimerId = null;
            }
           // console.debug("showballoon");
         
            if (this.balloon == null)
            {
	            var div = document.createElement("div");
	            div.id = "balloon";
	            div.style.display = "none";
    	        Event.observe(div, 'mouseout', this.hideBalloonEvent.bindAsEventListener(this));
	            var url = location.protocol + "//" + location.host + _baseUrl + "LocalTemp/" + _releaseNumber + "/Skin"
	            var colorSuffix = "_" + skinColorDark.replace("#", "") + "_" + skinColorLight.replace("#", "");
        		
        		var html = "";
        		
    			if (document.all)
    			{		                
	                html = html + "<div id=\"balloonArrowLeft\" style=\"z-index:2; position:absolute; left:0px; width:55px; top:0px; \">";
	                html = html + "	<div id=\"balloonArrowUL\" style=\"width:55px; height:101px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "/Balloon_ArrowUL" + colorSuffix + ".png', sizingMethod='scale');\">&nbsp;</div>";
	                html = html + "	<div id=\"balloonArrowLL\" style=\"display:none; width:55px; height:101px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "/Balloon_ArrowLL" + colorSuffix + ".png', sizingMethod='scale');\">&nbsp;</div>";
	                html = html + "</div>";
	                html = html + "<div id=\"balloonMain\" style=\"position:absolute; left:45px; top:0px\">";
	                html = html + "	<div id=\"balloonTop\" style=\"margin:0; padding:0; width:435px; height:23px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "/Balloon_Top" + colorSuffix + ".png', sizingMethod='scale');\">";
	                html = html + "		&nbsp;";
	                html = html + "	</div>";
	                html = html + "	<div id=\"balloonTitleBox\" style=\"width:435px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "/Balloon_TitleMiddle" + colorSuffix + ".png', sizingMethod='scale');\">";
	                html = html + "		<div style=\"position:relative; padding-left:30px; margin-right:50px; padding-bottom:5px; font-face:arial;font-size:14pt;color:white; text-align:left;\">";
	                html = html + "			<span id=\"balloonTitle\" >&nbsp;</span>";
	                html = html + "			<span id=\"balloonTitleSubTitle\">&nbsp;</span>";
	                html = html + "		</div>";
	                html = html + "	</div>";
	                html = html + "	<div id=\"balloonInner\" style=\"text-align:left; width:435px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "/Balloon_BodyMiddle" + colorSuffix + ".png', sizingMethod='scale');\">";
	                html = html + "		<div id=\"balloonBody\" style='position:relative; margin-bottom:0px; padding-bottom:10px; padding-left:30px; padding-right:0px; margin-right:0px; padding-top:10px; width:404px'>";
	                html = html + "		   <div id=\"balloonBodyTextArea\" style='margin-right:10px;'></div>";
	                html = html + "		</div>";
	                html = html + "		<br clear=all style='line-height:3px; font-size:3px; height:3px'>";
	                html = html + "	</div>";
	                html = html + "	<div id=\"balloonTitleBottom\" style=\"width:435px; height:31px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "/Balloon_Bottom" + colorSuffix + ".png', sizingMethod='scale');\">";
	                html = html + "		&nbsp;";
	                html = html + "	</div>";
	                html = html + "</div>";
	                html = html + "<div id=\"balloonArrowRight\" style=\"z-index:2; position:absolute; left:490px; width:55px; top:0px; \">";
	                html = html + "	<div id=\"balloonArrowUR\" style=\"width:55px; height:101px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "/Balloon_ArrowUR" + colorSuffix + ".png', sizingMethod='scale');\">&nbsp;</div>";
	                html = html + "	<div id=\"balloonArrowLR\" style=\"display:none; width:55px; height:101px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + url + "/Balloon_ArrowLR" + colorSuffix + ".png', sizingMethod='scale');\">&nbsp;</div>";	            
	                html = html + "</div>";	            
			    }
				else
				{
	                html = html + "<div id=\"balloonArrowLeft\" style=\"z-index:2; position:absolute; left:0px; width:55px; top:0px; \">";
	                html = html + "	<div id=\"balloonArrowUL\" style=\"width:55px; height:101px; background-image:url('" + url + "/Balloon_ArrowUL" + colorSuffix + ".png');\">&nbsp;</div>";
	                html = html + "	<div id=\"balloonArrowLL\" style=\"display:none; width:55px; height:101px; background-image:url('" + url + "/Balloon_ArrowLL" + colorSuffix + ".png'); \">&nbsp;</div>";
	                html = html + "</div>";
	                html = html + "<div id=\"balloonMain\" style=\"text-align:left; position:absolute; left:45px; top:0px\">";
	                html = html + "	<div id=\"balloonTop\" style=\"width:435px; height:23px; background-image:url('" + url + "/Balloon_Top" + colorSuffix + ".png'); \">";
	                html = html + "		&nbsp;";
	                html = html + "	</div>";
	                html = html + "	<div id=\"balloonTitleBox\" style=\"width:435px; background-image:url('" + url + "/Balloon_TitleMiddle" + colorSuffix + ".png'); \">";
	                html = html + "		<div style=\"position:relative; padding-left:30px; margin-right:50px; padding-bottom:5px; font-face:arial;font-size:14pt;color:white;\">";
	                html = html + "			<span id=\"balloonTitle\" >&nbsp;</span>";
	                html = html + "			<span id=\"balloonTitleSubTitle\">&nbsp;</span>";
	                html = html + "		</div>";
	                html = html + "	</div>";
	                html = html + "	<div id=\"balloonInner\" style=\"width:435px; background-image:url(" + url + "/Balloon_BodyMiddle" + colorSuffix + ".png); \">";
	                html = html + "		<div id=\"balloonBody\" style='position:relative; margin-bottom:10px; padding-bottom:10px; padding-left:30px; padding-right:0px; margin-right:0px; padding-top:10px; width:374px'>";
	                html = html + "		   <div id=\"balloonBodyTextArea\" style='margin-right:10px;'></div>";
	                html = html + "		</div>";
	                html = html + "		<br clear=all style='line-height:3px; font-size:3px; height:3px'>";
	                html = html + "	</div>";
	                html = html + "	<div id=\"balloonTitleBottom\" style=\"width:435px; height:31px; background-image:url('" + url + "/Balloon_Bottom" + colorSuffix + ".png'); \">";
	                html = html + "		&nbsp;";
	                html = html + "	</div>";
	                html = html + "</div>";
	                html = html + "<div id=\"balloonArrowRight\" style=\"z-index:2; position:absolute; left:490px; width:55px; top:0px; \">";
	                html = html + "	<div id=\"balloonArrowUR\" style=\"width:55px; height:101px; background-image:url('" + url + "/Balloon_ArrowUR" + colorSuffix + ".png'); \">&nbsp;</div>";
	                html = html + "	<div id=\"balloonArrowLR\" style=\"display:none; width:55px; height:101px; background-image:url('" + url + "/Balloon_ArrowLR" + colorSuffix + ".png'); \">&nbsp;</div>";	            
	                html = html + "</div>";	            
				}	

	            div.innerHTML = html;
	            document.body.appendChild(div);				
                this.balloon = div;
            }
            
            this._startX = -1;
            this._startY = -1;
            this._lastX = -1;
            this._lastY = -1;		
            
	        if (this.balloon)	
		        this.balloon.style.display='none';  	
            this._balloonCurrentElement = element;    
            this._balloonPageName = pageName;
            this._balloonId = id;			        				           				        				       
        	this.lastElement = element;
	 	  		var eventName = document.all ? "mousewheel" : "DOMMouseScroll";
	           
	        if (win != null)
	        {
	        	if (this.win != null)
	        	{
        			Event.stopObserving(this.win.document.body, 'mousemove',  this.trackMouseMovement.bindAsEventListener(this));
        			Event.stopObserving(this.win.document.body, 'scroll',  this.checkScroll.bindAsEventListener(this));
        		}
	        	this.win = win;
	        	Event.observe(this.win.document.body, 'mousemove', this.trackMouseMovement.bindAsEventListener(this));		    
	        	Event.observe(this.win.document.body, 'keydown', this.checkScroll.bindAsEventListener(this));		 
	        	Event.observe(this.win.document.body, 'scroll', this.checkScroll.bindAsEventListener(this));		 
     			  Event.observe(this.win.document.body, eventName, this.checkScroll.bindAsEventListener(this));	
   
					}
					else
					{
						this.win = null;
		        Event.observe(document.body, 'mousemove', this.trackMouseMovement.bindAsEventListener(this));		
					}
					Event.observe(document.body, 'keydown', this.checkScroll.bindAsEventListener(this));		
					Event.observe(document.body, 'scroll', this.checkScroll.bindAsEventListener(this));		
   			  Event.observe(document.body, eventName, this.checkScroll.bindAsEventListener(this));	
 	        this._showTimerId = setTimeout(this.checkForMouseMovement.bind(this), 500);
	    }
	    this.startShow = false;
    },
    checkScroll: function(ev)
    {
    	var el = Event.element(ev);
    	while (el != document.body || (this.win != null && el != this.win.document.body))
    	{
    		if (el == this.balloon)
    		{
    			return;
    		}
    		if (el.parentNode)
 		    	el = el.parentNode;
 		    else
 		    	break;
	   	}
    	this.hideBalloonCallBack();
    },
    trackMouseMovement: function(ev)
    {       	
      if (this._startX == -1 && this._startY == -1)
      {
          this._startX = ev.pageX||ev.clientX;
          this._startY = ev.pageY||ev.clientY;
      }
      else
      {
          this._lastX = ev.pageX||ev.clientX;
          this._lastY = ev.pageY||ev.clientY;    
      }
      this.track = true;
      this.hideBalloonEvent(ev);
      this.track = false;
    },
    hideBalloonEvent: function(ev)
    {
      if (this.balloon && this.balloon.style.display == 'block')
      {
      	if (this.track)
	        var el = Event.element(ev);
	      else if (ev.toElement)
	      	var el = ev.toElement;
	      else if (ev.relatedTarget)
	      	var el = ev.relatedTarget;
	      if (!el)
	      {
	        this.hideBalloonCallBack();
	        return;		            
				}
        while (el && el != this._balloonCurrentElement && el != this.balloon)
		    {
	        if (el == document.body || (this.win != null && el == this.win.document.body))
	        {
	            this.hideBalloonCallBack();
	            return;		            
	        }
	        if (el.contentWindow && el.contentWindow == this.win)
  		       return;
			    el = el.parentNode;
		    }    		
      }      
      else if (this._balloonCurrentElement != null)
      {
      	if (this.track)
	        var el = Event.element(ev);
	      else
	      	var el = ev.toElement;
        
        while (el != this._balloonCurrentElement)
    		{
	        if (el == document.body || (this.win != null && el == this.win.document.body))
	        {
	            this.hideBalloonCallBack();
	            return;		            
	        }
  		        				
			    el = el.parentNode;
		    }    	        
    	}
    },
    checkForMouseMovement: function()
    {
        if (this._showTimerId != null)
            clearTimeout(this._showTimerId);
            
        if  (this._startX == this._lastX && this._startY == this._lastY && this._startX != -1)
        {
            this.showBalloonRequestData();

            if (window.ActiveXObject) // IsIE
            {
	            hideSelects(document.forms[0]);
            }
        }
        else
        {
            this._startX = this._lastX;
            this._startY = this._lastY;    
            this._showTimerId = setTimeout(this.checkForMouseMovement.bind(this), 1000);	
        }       
    },
    showBalloonRequestData: function()
    {
        if (this._balloonAjaxRequest)
            return;
            
        if (this._showTimerId != null)
            clearTimeout(this._showTimerId);
            
	    this._showTimerId = null;
    	
    	if (!hasAttribute(this._balloonCurrentElement, "BalloonHeaderText"))
    	{
	        this._balloonAjaxOptions.onComplete = this.showBalloonCallback.bind(this, this._balloonCurrentElement);	
	        this._balloonAjaxOptions.parameters = "id=" + escape(this._balloonId);
    	
	        try
	        {         
	            this._balloonAjaxRequest = new Ajax.Request(_baseUrl + this._balloonPageName, this._balloonAjaxOptions);
	        }
	        catch (e) { }    
        }
        else
        {
            this.drawBalloon();
        }	    
    },
    showBalloonCallback: function(element, ajaxResponse)
    {           
        var xmlDoc = ajaxResponse.responseXML;  			  			
       
        var headerText = "";
        var bodyText = "";
        
        if (xmlDoc.getElementsByTagName("Header").length > 0 && xmlDoc.getElementsByTagName("Header")[0].firstChild != null)
            headerText = xmlDoc.getElementsByTagName("Header")[0].firstChild.data;
           
        if (xmlDoc.getElementsByTagName("Body").length > 0 && xmlDoc.getElementsByTagName("Body")[0].firstChild != null)            
        {
            if (document.all)
                bodyText = xmlDoc.getElementsByTagName("Body")[0].firstChild.data;
            else
                bodyText = xmlDoc.getElementsByTagName("Body")[0].textContent;
        }
        
        element.setAttribute("BalloonHeaderText", headerText);
        element.setAttribute("BalloonBodyText", bodyText);
        
        if (this._balloonCurrentElement == element && this._balloonAjaxRequest != null)
            this.drawBalloon();
        
        this._balloonAjaxRequest = null;
    },
    drawBalloon: function()
    {                  
            
			restrictPopupShow = true; 
			if (this.win)
				this.win.restrictPopupShow = true;
            var headerText =  this._balloonCurrentElement.getAttribute("BalloonHeaderText");
            var bodyText =  this._balloonCurrentElement.getAttribute("BalloonBodyText");
            
		    this.balloon.style.display='none';  	

            var windowHeight = GetWindowHeight();
            
            //console.debug(windowHeight);
            
            var tt = $("balloonMain");			
            var arrowLeft = $('balloonArrowLeft');	
            var arrowRight = $('balloonArrowRight');	

            tt.style.height = "";
            $("balloonBody").style.height = "auto";            
            $("balloonBodyTextArea").style.height = "auto";            

            $("balloonTitle").innerHTML = headerText;
            $("balloonBodyTextArea").innerHTML = bodyText;
            
            this.balloon.style.visibility = 'hidden';			                
            this.balloon.style.left = "-500px";             
            this.balloon.style.top = "-1500px";  
            this.balloon.style.display='block'; 
            

            while (tt.offsetHeight < 191)
            {
	            $("balloonBodyTextArea").innerHTML = $("balloonBodyTextArea").innerHTML + "<br/>";
            }
        				
            if (tt.offsetHeight > windowHeight - 120)
            {
                $("balloonBody").style.height = (windowHeight - 120) + "px";                    
                $("balloonBody").style.overflowY = "auto";
                $("balloonBody").style.overflowX = "hidden";
            }   
            else
            {
                // console.debug("in here");
                $("balloonBody").style.height = "auto";
                $("balloonBody").style.overflowY = "auto";
                $("balloonBody").style.overflowX = "hidden";
            }     				
        				
            var divHeight = tt.offsetHeight;
        	
            this.balloon.style.display='none'; 
        	
         		if ((typeof(balloonOffsetX) != 'undefined') && balloonOffsetX != -1)
         			this._lastX += balloonOffsetX;
         		if ((typeof(balloonOffsetY) != 'undefined') && balloonOffsetY != -1)
         			this._lastY += balloonOffsetY;
         		if ((typeof(balloonScrollX) != 'undefined') && balloonScrollX != -1)
         			this._lastX -= balloonScrollX;
         		if ((typeof(balloonScrollY) != 'undefined') && balloonScrollY != -1)
         			this._lastY -= balloonScrollY;
            var y = this._lastY;
            var x = this._lastX;
         		if ((typeof(balloonScrollY) != 'undefined') && balloonScrollY != -1)
         			y += balloonScrollY;

            var showLeftArrows = true;
            
            if (x > GetWindowWidth() /2)
                showLeftArrows = false;
            //if (document.all)
            //	x += 5;
            if (showLeftArrows)
            {            
                arrowLeft.style.left = x + "px";
                tt.style.left = x + 35 + "px";	                
                arrowRight.style.display = "none";
                arrowLeft.style.display = "";                
            }
            else
            {
                arrowRight.style.left = (x - 55) + "px";
                tt.style.left = (x - (435 + 23)) + "px";	
                arrowRight.style.display = "";
                arrowLeft.style.display = "none";                                              
            }
                               	  			            
            var offset = 0;  			
        	
            // console.debug("Div Height =  " + divHeight);
            // console.debug("Window Height =  " + windowHeight);
                	
            if (window.ActiveXObject) // IsIE
            {
	            $('balloonArrowUR').style.backgroundImage = "";
	            $('balloonArrowLR').style.backgroundImage = "";        		
	            $('balloonArrowUL').style.backgroundImage = "";
	            $('balloonArrowLL').style.backgroundImage = "";
	            $('balloonTop').style.backgroundImage = "";
	            $('balloonTitleBox').style.backgroundImage = "";
	            $('balloonInner').style.backgroundImage = "";
	            $('balloonTitleBottom').style.backgroundImage = "";
        		
            }
        	
        	if ($("mainDiv"))
        	{
                //y = y - $("mainDiv").scrollTop;                
                //x = x - $("mainDiv").scrollLeft;                
            }
            else
            {
                y = y - document.body.scrollTop;                
                x = x - document.body.scrollLeft;                
            }
            
            // 

            if (y < (windowHeight/3) * 2)  // Top 2/3 of screen
            {  				
                // console.debug("in here" + y + "," + windowHeight);
                
                if (showLeftArrows)
                {            
  	                $('balloonArrowUL').style.display = "";
	                $('balloonArrowLL').style.display = "none";    			
	            }
	            else
	            {
  	                $('balloonArrowUR').style.display = "";
	                $('balloonArrowLR').style.display = "none";    				            
	            }
        		
        		if (y + divHeight  > windowHeight)
        		    y = y + (windowHeight - (y + divHeight ));
        		
        		if (y < 0)
        		    y = 0;
        		    
	            if (y > 40)
		            tt.style.top = y - 40 + "px";
	            else
		            tt.style.top =  "0px";
        		
	            // arrowLeft.style.top = (y + 20) + "px";  				  				
	            // arrowRight.style.top = (y + 20) + "px";  				  				
	            
                arrowLeft.style.top = (this._lastY - 10) + "px";  				  				
	            arrowRight.style.top = (this._lastY - 10) + "px";  				  				

            }
            else
            {                
                if (showLeftArrows)
                {
	                $('balloonArrowUL').style.display = "none";
	                $('balloonArrowLL').style.display = "";  			
	            }
	            else
	            {
	                $('balloonArrowUR').style.display = "none";
	                $('balloonArrowLR').style.display = "";  				            
	            }
	            
	            if (y + divHeight  > windowHeight)
        		    y = y + (windowHeight - (y + divHeight ));
        		
        		if (y < 0)
        		    y = 0;
	            	            
	            if (this._lastY - 80 < y)
	                y = this._lastY - 80;
	            
	            if (y > 40)
	            {
	                if ((this._lastY - 80 + arrowLeft.offsetHeight) - (y + tt.offsetHeight) >= 40)
	                {
                        tt.style.top = y + "px";	                    	                    
	                }
	                else	           
	                {
	                    tt.style.top = y - 40 + "px";
		            }
		        }
	            else
	            {
		            tt.style.top =  "0px";
	            }
	            
	            arrowLeft.style.top = (this._lastY - 80) + "px";
	            arrowRight.style.top = (this._lastY - 80) + "px";
            }  											
        	
        	this.balloon.style.visibility = 'visible';			                
            this.balloon.style.display='block';             
    },
    hideBalloonCallBack: function()
    {
        this._balloonAjaxRequest = null;
        if (!this._balloonCurrentElement)
        {
            return;
          }

      	if (this.win != null)
    			Event.stopObserving(this.win.document.body, 'mousemove',  this.trackMouseMovement.bindAsEventListener(this));
    		else
        	Event.stopObserving(document.body, 'mousemove',  this.trackMouseMovement.bindAsEventListener(this));
        
      	if (this.win != null)
    			Event.stopObserving(this.win.document.body, 'keydown',  this.checkScroll.bindAsEventListener(this));
        Event.stopObserving(document.body, 'keydown', this.checkScroll.bindAsEventListener(this));
        
      	if (this.win != null)
    			Event.stopObserving(this.win.document.body, 'scroll',  this.checkScroll.bindAsEventListener(this));
        Event.stopObserving(document.body, 'scroll', this.checkScroll.bindAsEventListener(this));

 	  		var eventName = document.all ? "mousewheel" : "DOMMouseScroll";
      	if (this.win != null)
    			Event.stopObserving(this.win.document.body, eventName,  this.checkScroll.bindAsEventListener(this));
        Event.stopObserving(document.body, eventName, this.checkScroll.bindAsEventListener(this));

        this._balloonCurrentElement = null;

        this.hideTimer = null;
    		
	    if ( this._showTimerId != null)
	    {
		    clearTimeout( this._showTimerId);
		     this._showTimerId = null;		
	    }
    	
        //if (_balloonAjaxRequest != null)
	    //    _balloonAjaxRequest.cancel();
    	
	    if (this.balloon)
	    {
    		restrictPopupShow = false;
    				if (this.win)
    					this.win.restrictPopupShow = false;
		    this.balloon.style.display='none';  	

            if (window.ActiveXObject) // IsIE
            {
    	        showSelects();
            }
	    }
    		
        this._startX = -1;
        this._startY = -1;
        this._lastX = -1;
        this._lastY = -1;
    }
}
    
   

var _vocusBalloon = null;

function showBalloon(element, pageName, id, win)
{	
    if (!_vocusBalloon)
    {
        _vocusBalloon = new VocusBalloon();
    }
    _vocusBalloon.showBalloon(element, pageName, id, win);
}
function removeBalloonEvents(balloon)
{
	var eventName = document.all ? "mousewheel" : "DOMMouseScroll";
  if (balloon.win != null)
  {
		Event.stopObserving(balloon.win.document.body, 'mousemove', balloon.trackMouseMovement.bindAsEventListener(this));
		Event.stopObserving(balloon.win.document.body, 'keydown', balloon.checkScroll.bindAsEventListener(this));
		Event.stopObserving(balloon.win.document.body, 'scroll', balloon.checkScroll.bindAsEventListener(this));
		Event.stopObserving(balloon.win.document.body, eventName, balloon.checkScroll.bindAsEventListener(this));
	}
	else
	{
		Event.stopObserving(document.body, 'mousemove', balloon.trackMouseMovement.bindAsEventListener(this));
	}
	Event.stopObserving(document.body, 'keydown', balloon.checkScroll.bindAsEventListener(this));
	Event.stopObserving(document.body, 'scroll', balloon.checkScroll.bindAsEventListener(this));
	Event.stopObserving(document.body, eventName, balloon.checkScroll.bindAsEventListener(this));
  Event.stopObserving(balloon.balloon, 'mouseout', balloon.hideBalloonEvent.bindAsEventListener(this));
}
function cleanupBalloon(balloon)
{
	removeBalloonEvents(balloon);	
	
	balloon.balloon.innerHTML = '';
	
	for (var el in balloon)
	{
		balloon[el] = null;
	}
	
	balloon = null;
	_vocusBalloon = null;
};
function hideBalloon()
{
    // hideBalloonCallBack();
    // hideTimerId = setTimeout("hideBalloonCallBack()", 200)
}

function hasAttribute(el, attr)
{
	var attributeNode = el.getAttributeNode(attr);
	if (attributeNode)
		if (attributeNode.specified)
			return true;
	return false;
}
function getPosition(oNode,pNode)
{
  if(!pNode)
  	var pNode = document.body
  var oCurrentNode=oNode;
  var iLeft=0;
  var iTop=0;
  while ((oCurrentNode)&&(oCurrentNode!=pNode))
	{
		iLeft+=oCurrentNode.offsetLeft;
		iTop+=oCurrentNode.offsetTop;
	  oCurrentNode=oCurrentNode.offsetParent;
  }
  return new Array(iLeft,iTop);
}
