window.onresize = init;

function init()
{
	//This function sets up all of the visible elements on the page based on the size of the screen.
	//It kind of has a FOBUC (flash of butt ugly content) effect, but it's usually fast enough to not last long.

	//Setup the menu visibility
	montre();

	//Hide the accessibility windows
	document.getElementById('accessPop').style.display = 'none';
	document.getElementById('accessBG').style.display = 'none';

	//Check for IE. The offsetWidth thing screws up with IE... well... everything screws up with IE...
	blnIE = ((document.all)&&(navigator.appVersion.indexOf("MSIE")!=-1)) ? true : false;

	intPadding = 15;
	intWidth   = document.getElementsByTagName('body')[0].offsetWidth;
	intHeight  = document.getElementsByTagName('body')[0].offsetHeight;

	if(blnIE)
	{
		intWidth = intWidth - 15;
	}

	//Set the menu to be in the top left corner just above the footer
	document.getElementById('menu').style.top  = intPadding + 'px';
	document.getElementById('menu').style.left = intPadding + 'px';
	document.getElementById('menu').style.height = intHeight - 60 - intPadding - intPadding - intPadding + 'px';

	//Set the footer on the bottom
	document.getElementById('foot').style.top  = document.getElementById('menu').offsetHeight + intPadding + intPadding + 'px';
	document.getElementById('foot').style.left    = intPadding + 'px';
	document.getElementById('foot').style.width = intWidth - 161 - intPadding - intPadding - intPadding + 'px';

	//Set the content in the middle of the above four
	document.getElementById('cont').style.top    = 60  + intPadding + intPadding + 'px';
	document.getElementById('cont').style.left   = document.getElementById('menu').offsetWidth + intPadding + intPadding + 'px';
	document.getElementById('cont').style.height = intHeight - 60 -60 - intPadding - intPadding - intPadding - intPadding + 'px';
	document.getElementById('cont').style.width  = intWidth - 160 - 160 - intPadding - intPadding - intPadding - intPadding + 'px';
	
	//Set the side Ad on the right of the screen
	document.getElementById('sideAd').style.top  = 60  + intPadding + intPadding + 'px';
	document.getElementById('sideAd').style.left = intPadding + intPadding + intPadding + document.getElementById('cont').offsetWidth + 160 + 'px';
	document.getElementById('sideAd').style.height = document.getElementById('menu').offsetHeight + 'px';

	//Set the top Ad along the top, toward the right
	document.getElementById('topAd').style.top   = intPadding + 'px';
	document.getElementById('topAd').style.left  = document.getElementById('menu').offsetWidth + intPadding + intPadding + 'px';
	document.getElementById('topAd').style.width = intWidth - 160 - intPadding - intPadding - intPadding + 'px';

	//Set up the transparent backgrounds for the various elements
	document.getElementById('contCopy').style.top    = document.getElementById('cont').style.top;
	document.getElementById('contCopy').style.left   = document.getElementById('cont').style.left;
	document.getElementById('contCopy').style.height = document.getElementById('cont').offsetHeight + 'px';
	document.getElementById('contCopy').style.width  = document.getElementById('cont').offsetWidth + 'px';

	document.getElementById('menuCopy').style.top    = intPadding + 'px';
	document.getElementById('menuCopy').style.left   = intPadding + 'px';
	document.getElementById('menuCopy').style.height = intHeight - 60 - intPadding - intPadding - intPadding + 'px';

	document.getElementById('footCopy').style.top   = document.getElementById('foot').style.top;
	document.getElementById('footCopy').style.left  = document.getElementById('foot').style.left;
	document.getElementById('footCopy').style.width = document.getElementById('foot').offsetWidth + 'px';

	document.getElementById('sideAdCopy').style.top    = document.getElementById('sideAd').style.top;
	document.getElementById('sideAdCopy').style.left   = document.getElementById('sideAd').style.left;
	document.getElementById('sideAdCopy').style.height = document.getElementById('menu').offsetHeight + 'px';

	document.getElementById('topAdCopy').style.top   = document.getElementById('topAd').style.top;
	document.getElementById('topAdCopy').style.left  = document.getElementById('topAd').style.left;
	document.getElementById('topAdCopy').style.width = document.getElementById('topAd').offsetWidth + 'px';

	if(document.cookie.length > 0)
	{
		strWeight = cookieSearch('fontWt');
		intSize = parseInt(cookieSearch('fontSize'));

		changeFont('fontWeight',strWeight,'p');
		changeFont('fontWeight',strWeight,'li');
		changeFont('fontWeight',strWeight,'td');
		
		changeFont('fontSize',intSize,'p');
		changeFont('fontSize',intSize,'li');
		changeFont('fontSize',intSize,'td');

		document.frmFont.pFontSize.value = intSize;
		document.frmFont.pFontWt.value = strWeight;
		document.frmFont.chkSave.checked = true;
	}
	
	document.getElementById('divLoad').style.display = 'none';
}

function montre(id)
{
	var d = document.getElementById(id);
	for (var i = 1; i<=10; i++)
	{
		if (document.getElementById('smenu'+i))
		{
			document.getElementById('smenu'+i).style.display='none';
		}
	}
	if (d)
	{
		d.style.display='block';
	}
}

function accessPop()
{
	intWidth   = document.getElementsByTagName('body')[0].offsetWidth;
	intHeight  = document.getElementsByTagName('body')[0].offsetHeight;

	document.getElementById('accessBG').style.display = 'block';
	document.getElementById('accessBG').style.top  = 0;
	document.getElementById('accessBG').style.left = 0;
	document.getElementById('accessBG').style.width = intWidth + 'px';
	document.getElementById('accessBG').style.height = intHeight + 'px';
	document.getElementById('accessBG').style.zIndex = 1000;

	intTop  = (intHeight - 325) / 2 -50;
	intLeft = (intWidth  - 600) / 2;

	document.getElementById('accessPop').style.display = 'block';
	document.getElementById('accessPop').style.top = intTop + 'px';
	document.getElementById('accessPop').style.left = intLeft + 'px';
	document.getElementById('accessPop').style.zIndex = 1001;
}

function closePop()
{
	if(document.frmFont.chkSave.checked == true)
	{
		document.cookie = 'fontSize=' + document.frmFont.pFontSize.value + '; expires=Fri, 1 Jan 2016 20:47:11 UTC; path=/';
		document.cookie = 'fontWt=' + document.frmFont.pFontWt.value + '; expires=Fri, 1 Jan 2016 20:47:11 UTC; path=/';
	}
	else
	{
		document.cookie = 'fontSize=' + document.frmFont.pFontSize.value + '; expires=Mon, 1 Jan 2007 20:47:11 UTC; path=/';
		document.cookie = 'fontWt=' + document.frmFont.pFontWt.value + '; expires=Mon, 1 Jan 2007 20:47:11 UTC; path=/';
	}

	document.getElementById('accessPop').style.display = 'none';
	document.getElementById('accessBG').style.display = 'none';
	init();
}

function fontSize(act)
{
	if(act == '+')
	{
		intOldSize = parseInt(document.frmFont.pFontSize.value);
		intNewSize = intOldSize + 1;

		changeFont('fontSize',intNewSize,'p');
		changeFont('fontSize',intNewSize,'li');
		changeFont('fontSize',intNewSize,'td');

		document.frmFont.pFontSize.value = intNewSize;
	}
	else
	{
		intOldSize = parseInt(document.frmFont.pFontSize.value);
		intNewSize = intOldSize - 1;

		changeFont('fontSize',intNewSize,'p');
		changeFont('fontSize',intNewSize,'li');
		changeFont('fontSize',intNewSize,'td');

		document.frmFont.pFontSize.value = intNewSize;
	}
}

function fontWt(act)
{
	if(act == '+')
	{
		changeFont('fontWeight','bold','p');
		changeFont('fontWeight','bold','li');
		changeFont('fontWeight','bold','td');

		document.frmFont.pFontWt.value = 'bold';
	}
	else
	{
		changeFont('fontWeight','normal','p');
		changeFont('fontWeight','normal','li');
		changeFont('fontWeight','normal','td');

		document.frmFont.pFontWt.value = 'normal';
	}
}

function cookieSearch(varName)
{
	values_arr = document.cookie.split(';');

	for(i=0;i<values_arr.length;i++)
	{
		if(values_arr[i].indexOf(varName) > -1)
		{
			return_arr = values_arr[i].split('=');
			return return_arr[1];
		}
	}
	
	return -1;
}

function changeFont(strStyle,strValue,strTag)
{
	tag_arr = document.getElementsByTagName(strTag);
	
	for(i=0;i<tag_arr.length;i++)
	{
		eval("tag_arr[i].style."+ strStyle +" = '" + strValue + "';");
	}	
}

