﻿// Tooltips!
//
// Init tooltips on document ready by calling either:
//	
//  setTips($(selector)); - for normal '?' icons on 'a' tags with tooltips
//	setTips($(selector),"inline-content"); - for images etc.

function setTips(helperEl,type){       
                  
   $(helperEl).each(function(index) {            
           // create tooltip div and insert contents from helperEl (or if .tooltip-content if 'inline-content' type)               
           if (type == "inline-content"){
                var tipContents = '<div class="toolTip"><div class="ttInner">' + $(this).find('.tooltip-content').html() + '</div></div>';  
           }
           else{  
                var tipContents = '<div class="toolTip"><div class="ttInner">' + $(this).html() + '</div></div>'; 
           }                   
           $(this).after(function() {
               return tipContents;
           });
           // when mouse is over helperEl find the tooltip div and turn it on
           var tip = $(this).next();
           $(this).bind({
              mousemove: function(e) {
                tip.css({top: (e.pageY + 13) + "px",left: (e.pageX + 13) + "px"})
                tip.show()
              },
              mouseleave: function() {
                tip.hide()
              }
           });       
   });         
   
}