$(function ()
{
	calibrateScroll ();
}
);

function calibrateScroll ()
{
	var s		= false;
	var text	= $('#text_text');
	var wrapper	= $('#text_wrapper');

	var theight	= text.height ();
	var wheight	= wrapper.height ()  - 42;

	if (theight > wheight)
	{
	
		wrapper.css ('border-right', '1px solid #CFCDC9');
		$('<div id="slider-vertical" style="margin-top: 22px; height: ' + wheight + 'px;"></div>').appendTo ('#text_scroll');
		$("#slider-vertical").slider({
			orientation: "vertical",
			range: "min",
			min: 0,
			max: 100,
			value: 100,
			slide: function(event, ui)
			{
				var temp	= theight - wheight;
				var top		= (temp / 100) * ui.value;
				top			= Math.ceil (temp - top);
				
				text.css ('top', '-' + top + 'px');
				
			}
		});

		$('.ui-corner-all').removeClass ('ui-corner-all');	
	}
	else
	{
		$('#slider-vertical').remove ();
		wrapper.css ('border-right', 'none');
	}

}

