var $j = jQuery.noConflict();



this.tooltip = function(){  

    var $xOffset = -210;
    var $yOffset = -20;
    var $footnoteWidth = 200;
    var $headerHeight = $j('#header').height();
    var $leftColWidth = $j('#leftContent').width();
    
	var $setY;
	var $setX;
	var bordercolor;
    var $windowHeight;
    var $windowWidth;
    if (self.innerHeight) { // all except Explorer
        $windowHeight = self.innerHeight;
        $windowWidth = self.innerWidth;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
        $windowHeight = document.documentElement.clientHeight;
        $windowWidth = document.documentElement.clientWidth;
    } else if (document.body) { // other Explorers
        $windowHeight = document.body.clientHeight;
        $windowWidth = document.body.clientWidth;
    };

    //$windowWidth = $j('body').width();

    

    $j('#streamsRow .pad .horizontalNav li a').hover(function(e){
        this.t = this.title;
        this.title = "";
		bordercolor = $j(this).css('border-bottom-color');
        $j('body').prepend('<div class="footnoteHover"><p>'+$j(this).attr('tooltip')+'</p></div>');
        $j('body').find('div.footnoteHover')
            .css('top',(e.pageY - ($yOffset+$headerHeight))+'px')
            .css('left',( (e.pageX + $xOffset) +'px'))
//          .html('left: '+e.pageX)
            .css('width',$footnoteWidth+'px')
//          .fadeIn('slow');
			.css('border-top', '6px solid '+bordercolor);
		$j('div.footnoteHover').fadeTo('slow', 0.87);
    }, function(){
        this.title = this.t;
        $j('body').find('div.footnoteHover').remove();
    });

    

    $j().mousemove(function(m){
        $setY = m.pageY;
        $setX = m.pageX;                    
    });  

    

    $j('#streamsRow .pad .horizontalNav li a').mousemove(function(e){
        //alert($windowWidth+$footnoteWidth);
        if($windowWidth<($setX+$footnoteWidth+($leftColWidth/4))) {
            $newPos = ($windowWidth-$footnoteWidth);
            $j('body').find('div.footnoteHover')
            .css('top',(e.pageY - ($yOffset+$headerHeight))+'px')
            .css('left',($newPos-($leftColWidth*1.5))+'px');
        } else {                               
            $j('body').find('div.footnoteHover')
                .css('top',(e.pageY - ($yOffset+$headerHeight))+'px')
                .css('left',( (e.pageX + $xOffset) +'px'));
        };
    });
};

