/*==================================================================================*/
var
 jquery_followlink_count=0;

/*==================================================================================*/
function followLinkPosition(aelement){
    var left=0;
    var top=0;
    var e=document.getElementById(aelement);
    while(e.id!="page" && e.offsetParent!=undefined && e.offsetParent!=null){
        left+=e.offsetLeft+(e.clientLeft!=null?e.clientLeft:0);
        top+=e.offsetTop+(e.clientTop!=null?e.clientTop:0);
        e=e.offsetParent;
	}
    return new Array(left,top);
}
/*==================================================================================*/



/*==================================================================================*/
function followLinkEnter(aid,aposition){
	p=followLinkPosition(aid);

	switch(aposition){
		case "bottom":
			a={left :p[0],
			   width:document.getElementById(aid).offsetWidth,
			   top  :p[1]+document.getElementById(aid).offsetHeight+2};
			b={height:3,opacity:0.75};
			break;
		case "left":
			a={left  :p[0]-5,
			   height:document.getElementById(aid).offsetHeight,
			   top   :p[1]};
			b={width:3,opacity:0.75};
			break;
	}
	
	if($("#jquery-followlink").css("opacity")==0){
		$("#jquery-followlink").css(a);
		$("#jquery-followlink").stop().animate(b,350);
	}
	else{
		a.opacity=0.75;
		switch(aposition){
			case "bottom":
				a.height=3;
				break;
			case "left":
				a.width=3;
				break;
		}
		$("#jquery-followlink").stop().animate(a,350);
	}
}
/*==================================================================================*/



/*==================================================================================*/
function followLinkLeave(){
	$("#jquery-followlink").stop().animate({width:1,height:1,opacity:0},500);
}
/*==================================================================================*/


/*==================================================================================*/
(function($) {
	$.fn.followLink = function(options) {
		var opts=$.extend({},$.fn.followLink.defaults,options);
		if(jquery_followlink_count==0){
			$("#page").append("<div id=\"jquery-followlink\" style=\"opacity:0;position:absolute;background-color:"+opts.color+"\"></div>");
			jquery_followlink_count=1;}
		if(opts.active==1){
			return this.each(function(){
				$("#"+this.id).bind("mouseenter",function(e){followLinkEnter(this.id,opts.position);});
				$("#"+this.id).bind("mouseleave",function(e){followLinkLeave();});
	          });
		}
		else{
			return this.each(function(){
				$("#"+this.id).unbind("mouseenter").unbind("mouseleave");});
		};
      }
	  $.fn.followLink.defaults={active:1,position:'bottom',color:'yellow'};
	  })(jQuery);
/*==================================================================================*/

