 /* ------------------------------------------------------------
 * PROJECT        : FHSC Interface Standard
 * FILENAME       : jqscrollablediv.js
 * ------------------------------------------------------------
 * DATE CREATED   : 08 Sep 2006
 * LAST UPDATED   : 23 May 2007
 * ------------------------------------------------------------
 * AUTHOR(S)      : Kevin Scholl (http://www.ksscholl.com/)
 * ------------------------------------------------------------ */

/* ------------------------------------------------------------
 * INITIATE FUNCTION ONLOAD or ONRESIZE
 * ------------------------------------------------------------ */

$(document).ready(function(){
  $("div.contentBorderExp").scrollableDiv();																			 
  }); // end ready function

$(window).resize(function(){
  $("div.contentBorderExp").scrollableDiv();																			 
  }); // end resize function

/* ------------------------------------------------------------
 * SET DIMENSIONS OF THE SCROLLABLE DIV
 * ------------------------------------------------------------ */

$.fn.scrollableDiv = function() {
	
	// alert($(window).height());

  var adjustedHeight  = $(window).height() - 185;
	
  if(document.all) {
		var adjustedWidth = $(window).width() - 72 + 'px';
		}
		
	// reduce available height for each element present...
	$("div.main1Column h1").each(function(){                      adjustedHeight = adjustedHeight - 30;});
	$("div.main1Column h2").each(function(){                      adjustedHeight = adjustedHeight - 32;});
	$("div.main1Column ul.tabBar").each(function(){               adjustedHeight = adjustedHeight - 20;});
	$("div.main1Column p.systemMessage").each(function(){         adjustedHeight = adjustedHeight - 21;});
	$("div.main1Column div.downloadPlugin").each(function(){      adjustedHeight = adjustedHeight - 42;});
	$("div.main1Column h3").each(function(){                      adjustedHeight = adjustedHeight - 25;});
	$("div.main1Column p.tableInfoDark").each(function(){         adjustedHeight = adjustedHeight - 25;});
	$("div.main1Column p.tableInfoLight").each(function(){        adjustedHeight = adjustedHeight - 25;});
	$("div.main1Column div.tableButtonBlock").each(function(){    adjustedHeight = adjustedHeight - 29;});
		
	// alert(adjustedHeight);
	// alert($(window).height() - adjustedHeight);

  if(!document.all) {		
		adjustedHeight = adjustedHeight + "px";
		$("div.contentBorderExp")
			.css("maxHeight",adjustedHeight)
		}
	else { // handle element height detection misbehavior by Internet Exploder - blech!
		adjustedHeight = ((adjustedHeight < 145) ? 145 : adjustedHeight) + 'px'; // emulate minimum height
		$("div.contentBorderExp")
			.css("height",adjustedHeight)
			.css("width",adjustedWidth)
		}

	} // end scrollableDiv function