var SITE = window.location.hostname;
/*var BASEURL = 'https://www.biologicalservices.com/';

function returnDocument() {
	var file_name = document.location.href;
	if(file_name == BASEURL) {
		file_name = BASEURL + 'index.php';
	}
	var end = (file_name.indexOf("?") == -1) ? file_name.length : file_name.indexOf("?");
	return file_name.substring(file_name.lastIndexOf("/")+1, end);
}

var page = returnDocument();*/

function resize() {
	//alert("resize2 called");
	var height = 0;
	var lowestElement = 0;
	
	/*if(SITE == 'www.biologicalservices.com' && page != 'index.php') {
		var contentDiv = '#topContent';
	} else {*/
		var contentDiv = '#main_content';
	/*}*/

	$(contentDiv).find('*:visible').not('option').each(function(){
		//alert($(this).attr('id') + ' ' + $(this).attr('class'));
 		var pos = $(this).position();
		var bottomOfCurrent = pos.top + $(this).height();
 		if (bottomOfCurrent >= lowestElement) {
			lowestElement = bottomOfCurrent;
			$('.lowest').removeClass('lowest');
			$(this).addClass('lowest');
		}
	});

	var lowestOnPageTop = $('.lowest').position();
	lowestOnPageTop = lowestOnPageTop.top;
	var lowestOnPageHeight = $('.lowest').height();
	var bottomOfLowest = lowestOnPageTop + lowestOnPageHeight;
	if($('#main_content').is(':visible')) {
		var contentOffsetTop = $('#main_content')[0].offsetTop;
	} /*else if($('#content2').is(':visible')) {
		var contentOffsetTop = $('#content2')[0].offsetTop;
	} else if($('#topContent').is(':visible')) {
		var contentOffsetTop = $('#topContent')[0].offsetTop;
	}*/
	var newHeight = contentOffsetTop + bottomOfLowest + 50;
	if(newHeight < 600) {
		newHeight = 600;
	}
	
	if(bottomOfLowest < 555) {
		bottomOfLowest = 555 - contentOffsetTop;
	}

	//$('.lowest').hide();

	$(contentDiv).height(bottomOfLowest + 100);
	$('#main_container').height(newHeight + 100);
}

$(window).bind('load', function () {
	resize();
});

$(function() {
	window.setTimeout('resize()', 50);
});