﻿function adjustPage()
{
	//** Calculate object heights - all heights will be based off of height of main content area
	//** Default maximum height is height of header plus height of main content area, plus a 100px buffer for aesthetics
	//** Width of logs on right needs to be set based on screen width
	//** Bottom of left and right borders must meet top of bottom border
	//** Right border has some quirks, so add 100px to make bottom of right border meet top of bottom border
	//** Align the bottom of the footer with the max height
	var headerHeight = document.getElementById("header").offsetHeight;
	var logo1Height = document.getElementById("logo1").offsetHeight;
	var logo2Height = document.getElementById("logo2").offsetHeight;
	var navTotHeight;
	if (document.getElementById("register"))
	{ navTotHeight = document.getElementById("logo1").offsetHeight + document.getElementById("logo2").offsetHeight + document.getElementById("nav").offsetHeight + document.getElementById("register").offsetHeight;}
	else { navTotHeight = document.getElementById("logo1").offsetHeight + document.getElementById("logo2").offsetHeight + document.getElementById("nav").offsetHeight;}
	var mainContentHeight = document.getElementById("content").offsetHeight;
	var bkgLeftHeight;
	var bkgRtHeight;
	var leftBorderHeight;
	var rightBorderHeight;
	var bkgRtWidth;
	var footerTop;
	var footerHeight = document.getElementById("footer").offsetHeight;
	var finalHeight;

	var finalHeight = headerHeight + mainContentHeight + 100;
	
	if ((finalHeight - footerHeight) < mainContentHeight)
	{
		if ((finalHeight - footerHeight) < navTotHeight)
		{
			finalHeight = navTotHeight + footerHeight + 100;
			leftBorderHeight = navTotHeight + logo1Height + 50; //WTF????
			rightBorderHeight = navTotHeight + footerHeight;
			footerTop = navTotHeight + 100;
			bkgLeftHeight = finalHeight;
			bkgRtHeight = finalHeight;
		}
		else
		{
			finalHeight = mainContentHeight + footerHeight + 100;
			leftBorderHeight = (mainContentHeight + footerHeight) - headerHeight;
			rightBorderHeight = mainContentHeight + footerHeight;
			footerTop = mainContentHeight + 100;
			bkgLeftHeight = finalHeight;
			bkgRtHeight = finalHeight;
		}
	}
	else
	{
		//** finalHeight stays as-is
		leftBorderHeight = (mainContentHeight - document.getElementById("bottomBorder").offsetHeight);
		rightBorderHeight = mainContentHeight + 100;
		footerTop = finalHeight - footerHeight;
		bkgLeftHeight = finalHeight;
		bkgRtHeight = finalHeight;
	}

	bkgRtWidth = screen.width - document.getElementById("backgroundRight").offsetLeft + "px";

//	alert("footerTop = " + footerTop);

	//** Finished with calculations, add the "px" to the values for cross-browser compatibility
	finalHeight += "px";
	bkgLeftHeight += "px";
	bkgRtHeight += "px";
	leftBorderHeight += "px";
	rightBorderHeight += "px";
	footerTop += "px";

	//** Assign values to appropriate controls
	document.getElementById("backgroundLeft").style.height = bkgLeftHeight;
	document.getElementById("backgroundRight").style.height = bkgRtHeight;
	document.getElementById("backgroundRight").style.width = bkgRtWidth;
	document.getElementById("left").style.height = leftBorderHeight;
	document.getElementById("right").style.height = rightBorderHeight;
	document.getElementById("footer").style.top = footerTop;
}

function printDirections()
{
	var prtContent = document.getElementById("content");
	var WinPrint =
	window.open('','','left=0,top=0,width=500,height=700,toolbar=0,scrollbars=0,status=0');
	WinPrint.document.write(prtContent.innerHTML);
	WinPrint.document.write("<script language='javascript' type='text/javascript'>locationDirections_load();</script>");
	WinPrint.document.close();
	WinPrint.focus();
//	WinPrint.print();
//	WinPrint.close();
}

function OpenCertDetails()
{
	thewindow = window.open('https://www.thawte.com/cgi/server/certdetails.exe?code=USSCLY1-3', 'anew', config='height=400,width=450,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,directories=no,status=yes');
}

function show_prodpic(pic_name) {
	url_to_view = "images/" + pic_name;

	var window_width = 350;
	var window_height = 350;
	var window_type = "status,scrollbars,resizable,width=" + window_width + ",height=" + window_height;
	window.open(url_to_view, '', window_type);
	return;
}
