var scrollOkToDo = true;

function showScrollContainer() {
  var mainText        = $$('#content .mainText')[0];
  var textToScroll    = $$('#content .mainText .textToScroll')[0];
  var scrollContainer = $$('#content .scrollContainer')[0];

  if (scrollContainer && mainText && textToScroll) {
    if (Element.getHeight(mainText) < Element.getHeight(textToScroll)) {
	  scrollContainer.style.display = 'block';
    }
  }
}

function scrollPageTextDown() {
  var mainText        = $$('#content .mainText')[0];
  var textToScroll    = $$('#content .mainText .textToScroll')[0];

  if (scrollOkToDo) {
	scrollOkToDo = false;
	setTimeout(function() {scrollOkToDo = true}, 1000);

	if (textToScroll.offsetTop > (Element.getHeight(mainText) - Element.getHeight(textToScroll)) ) {
	  new Effect.Move(textToScroll, {x: 0, y: -(Element.getHeight(mainText) - 15), mode: 'relative'});
	}
  }
}

function scrollPageTextUp() {
  var mainText        = $$('#content .mainText')[0];
  var textToScroll    = $$('#content .mainText .textToScroll')[0];

  if (scrollOkToDo) {
	scrollOkToDo = false;
	setTimeout(function() {scrollOkToDo = true}, 1000);

	if (textToScroll.offsetTop < 0) {
	  new Effect.Move(textToScroll, {x: 0, y: Element.getHeight(mainText) - 15, mode: 'relative'});
	}
  }
}

Event.observe(window, 'load', showScrollContainer, false);


/*
function setHeightOfTextbox() {
  var textbox      = $$('#content .text')[0];
  var admintextbox = $$('#content .text .text')[0];
  var mainImage    = $$('#content #mainImage')[0];

  if (mainImage) {
    var height = Element.getHeight(mainImage);
    if (height > 200) {
	  textbox.style.height        = height + 'px';
	  if (admintextbox) {
	    admintextbox.style.height = (height - 20) + 'px';
	  }
    }
  }
}

Event.observe(window, 'load', setHeightOfTextbox, false);
*/
