/**
 * jQuery mbTooltip Plugin
 *
 * @author: Matthias Benkwitz
 * @version: 0.1
 * @copyright (c) 2008 Matthias Benkwitz, BuI-Hinsche.de *
 **/

if (! this.LexTooltip) {
this.LexTooltip = function(){
 /* CONFIG */
 xOffset = 10;
 yOffset = 20;
 jQuery(".hide").hide();
 jQuery(".lex_tooltip").hover(function(e){
	 //var t = jQuery(this).attr('title');
	 //var t = jQuery(this).next('div.lex_tooltip_hidden').html();
	 
	 var parent = jQuery(this).parent()
	 var find_id = parent.attr('class');
	 
	 //var t = jQuery(this).next('div.lex_tooltip_hidden').html();
	 var t = jQuery(find_id).html();
	 
	 var h = getPageHeight();
	 var yScroll = getPageScroll();
	 //var check_h = h-(parseInt(h * (5 / 100)));
	 var check_h = h;
	 var curPosY = e.pageY; // top-bottom
	 var curPosX = e.pageX; // left-right
	 
	 this.idcontainer = t;
	 this.title = "";
	 jQuery("#lex_tooltip").remove();
	 jQuery("body").append("<div id='lex_tooltip'>"+ t +"<\/div>");
	 
	 if(curPosY >= check_h) {
		 var tooltip_height = jQuery("#lex_tooltip").height();
		 jQuery("#lex_tooltip").css("position", "absolute").css("top",(e.pageY - tooltip_height) + "px").css("left",(e.pageX + yOffset) + "px").show();
	 } else {
		 jQuery("#lex_tooltip").css("position", "absolute").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").show();
	 }
 },
 function(){
    this.title = this.idcontainer;
    //jQuery("#lex_tooltip").html("");
    //jQuery("#lex_tooltip").remove();
 });
 
 function getPageScroll() {
	    var xScroll, yScroll;
	    if (self.pageYOffset) {
	      yScroll = self.pageYOffset;
	      xScroll = self.pageXOffset;
	    } else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
	      yScroll = document.documentElement.scrollTop;
	      xScroll = document.documentElement.scrollLeft;
	    } else if (document.body) {// all other Explorers
	      yScroll = document.body.scrollTop;
	      xScroll = document.body.scrollLeft;	
	    }
	   // return new Array(xScroll,yScroll)
	   return yScroll
	  }
  
 function getPageHeight() {
	    var windowHeight
	    if (self.innerHeight) {	// all except Explorer
	      windowHeight = self.innerHeight;
	    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
	      windowHeight = document.documentElement.clientHeight;
	    } else if (document.body) { // other Explorers
	      windowHeight = document.body.clientHeight;
	    }	
	    return windowHeight
	  }
 
 jQuery(".lex_tooltip").hover(function(e){
	 if(curPosY >= check_h) {
		 var tooltip_height = jQuery("#lex_tooltip").height();
		 jQuery("#lex_tooltip").css("position", "absolute").css("top",(e.pageY - tooltip_height) + "px").css("left",(e.pageX + yOffset) + "px").show();
	 } else {
		 jQuery("#lex_tooltip").css("position", "absolute").css("top",(e.pageY - xOffset) + "px").css("left",(e.pageX + yOffset) + "px").show();
	 }
 }, function(e){
	 jQuery("#lex_tooltip").remove();
	 jQuery("div.lex_tooltip_hidden").css("display","none");
 });
};

jQuery(document).ready(function() {
	LexTooltip();
});
}

