function RegenerateToolTip() {
    //in IE, sometimes it is necessary to force the browser to render the HTML again, 
    //to fix positioning problems when the height of a window is resized with javascript.
    $('.toolTip').each(function (i) {
        this.innerHTML = this.innerHTML;
    });
}


function initTooltip() {
    
    //clear existing HTML
    $('.toolTip').each(function (i) {
        if (this.isInitialized == true) {
            return;
        }
        this.tip = this.innerHTML;
        this.innerHTML = '';
        this.style.visibility = 'visible';
        this.style.overflow = 'visible';
        
        //check if an inline width is set
        if (this.style.width != '') {
            InlineCss = ' style="width:' + this.style.width + '"';
            this.style.width = 'auto'; //reset width and use the width in the toolTipWrapper
        } else {
            InlineCss = '';
        }
        
        $(this).append(
         '<div class="toolTipWrapper"'+InlineCss+'>'
            +'<div class="toolTipContent">'
              +this.tip
            +'</div>'
          +'</div>'
        );
        
        this.isInitialized = true;
    
  });
  
  $('.toolTip').hover(
    function() {
        $(this).css({zIndex:99999});
        $(this).find('.toolTipWrapper').fadeIn(300);
        
        
        
  },
    function() {
        $(this).css({zIndex:1});
        $(this).find('.toolTipWrapper').fadeOut(100);
      }
  );
}


function initErrorTooltip() {
    
    $('.errorToolTip').each(function (i) {
        if (this.isInitialized == true) {
            return;
        }
        
        var errorMessage = $(this).html();
        
        $(this).html('');
        $(this).css("overflow",'visible');
        
        //var errorMessage = eval(parent.attr('id') + '.errormessage');
        $(this).append(
         '<div class="errorToolTipWrapper">'
            +'<div class="errorToolTipContent">'
              +errorMessage
            +'</div>'
          +'</div>'
        );
        
        this.isInitialized = true;
        
    });
    
    $('.errorToolTip').hover(
    function() {
        $(this).css({zIndex:99999});
        $(this).find('.errorToolTipWrapper').fadeIn(300);
        
        
        
  },
    function() {
        $(this).css({zIndex:1});
        $(this).find('.errorToolTipWrapper').fadeOut(100);
      }
  );
}
