	var PrevScroll=0;
	var CurScroll;
	var DerHeight;
	var DerPosition
	var BottomScrolled;
	var Subiendo=false;
	var CSSstr;
	var NuevoderTop;
	
	var Top0=40; /* height de los minibuttons */
	var Bottom0=80; /* EMPIRICO -- height del footer */
	
	var AltoTotal;
	
	$(document).ready(function () {

		AltoTotal=$(window).height();
		DerHeight=$("#DERECHA").height()+Bottom0;
		DerTop=parseInt( $("#DERECHA").css('marginTop') );
		DerBottom=DerTop+DerHeight;
		if (BottomScrolled>DerBottom)	$("#DERECHA").css("marginTop",BottomScrolled-DerHeight);
		
		
	});
	
	$(window).resize(function () {

		AltoTotal=$(window).height();
		DerHeight=$("#DERECHA").height()+Bottom0;
		DerTop=parseInt( $("#DERECHA").css('marginTop') );
		DerBottom=DerTop+DerHeight;
		if (BottomScrolled>DerBottom)	$("#DERECHA").css("marginTop",BottomScrolled-DerHeight);
		//if (DerBottom>AltoTotal) 		$("#DERECHA").css("marginTop",DerTop-(DerBottom-AltoTotal));
	});
	
	
	$(window).scroll(function () {
	
		if (!$.browser.opera) {
		
			CurScroll=( $(window).scrollTop()>Top0 ) ? $(window).scrollTop()-Top0 : 0;
			BottomScrolled=$(window).scrollTop()+AltoTotal;
			Subiendo=(CurScroll<PrevScroll);
			
			// DerPosition=$("#DERECHA").position();
			
			DerTop=parseInt( $("#DERECHA").css('marginTop') );
			DerBottom=DerTop+DerHeight;
			
			//if (!Subiendo && BottomScrolled>DerBottom)	$("#DERECHA").css("marginTop",BottomScrolled-DerHeight+"px");
			//if (Subiendo && DerTop>CurScroll) { $("#DERECHA").css("marginTop",CurScroll); }
			
			if (!Subiendo && BottomScrolled>DerBottom)	$("#DERECHA").css("marginTop",BottomScrolled-DerHeight);
			if (Subiendo && DerTop>CurScroll) $("#DERECHA").css("marginTop",CurScroll);
			
			PrevScroll=CurScroll;
		}
	
	
	});
