var divContentDimensionsOriginal;

Position.GetWindowSize = function(w) {
        w = w ? w : window;
        var width = w.innerWidth || (w.document.documentElement.clientWidth || w.document.body.clientWidth);
        var height = w.innerHeight || (w.document.documentElement.clientHeight || w.document.body.clientHeight);
        return [width, height]
}

Event.observe(window, 'load', function() {
    divContentTextHeightOriginal = $('divContentText').getHeight();
    setScrollDivHeight();
});

Event.observe(window, 'resize', function() {
    setScrollDivHeight();
});

function setScrollDivHeight()
{
    var maxSize = Position.GetWindowSize();
    var maxHeight = maxSize[1];
    var headerHeight = $('divHeader').getHeight();
    var footerHeight = $('divLogoText').getHeight();

    if ((divContentTextHeightOriginal + headerHeight + footerHeight + 40) > maxHeight) {
        newHeight = maxHeight - headerHeight - footerHeight - 40;
        $('divContentText').style.height = newHeight;
    } else if ($('divContentText').getHeight() < divContentTextHeightOriginal) {
        $('divContentText').style.height = divContentTextHeightOriginal + 30;
    }
}


function setScroll(){
	
  ScrollHeight = 0;
	
	if (document.getElementById("ContentScroll").scrollHeight > 245) {
		document.getElementById("main_table").style.height = "100%";
	}
	
	if (document.getElementById("ContentScroll").scrollHeight < 280) {
		document.getElementById("ContentScroll").style.overflow = "hidden";
	}

  if(document.getElementById("ContentScroll"))
    document.getElementById("ContentScroll").style.display = "none";  

  if(document.getElementById("TDScroll"))

    ScrollHeight = document.getElementById("TDScroll").offsetHeight;

  if(document.getElementById("ContentScroll"))
    document.getElementById("ContentScroll").style.height=ScrollHeight+"px";

  if(document.getElementById("ContentScroll"))
    document.getElementById("ContentScroll").style.display = "";

}

function toggleDisplay(name, disp, current) {
  if(current != name){
    if (disp) {
      if (document.getElementById) {
        document.getElementById(name).style.display = '';
      }
      else if (document.all){
        document.all[name].style.display = '';
      }
    }
    else {
      if (document.getElementById) {
        document.getElementById(name).style.display = 'none';
      }
      else if (document.all) {
        document.all[name].style.display = 'none';
      }
    }
  }
}

function toggleMenu(item, image, current) {
  if(current != item){
    if(document.getElementById(item))
      document.getElementById(item).src = '/images/menu_'+image+'.gif';
  }
}

function toggleColor(item, tdclass, current) {
  if(current != item){
    if(document.getElementById(item+'_td'))
      document.getElementById(item+'_td').className = tdclass;
    if(document.getElementById(item+'_link'))
      document.getElementById(item+'_link').className = tdclass;
  }
}
