﻿// JScript File

/*
 * BeginResizeWindow
 * Run's resize when the user let's go of the mouse click.
 */
function BeginResizeWindow()
{
	setTimeout("ResizeWindowCallBack()",10);
}
/*
 * ResizeWindow
 * This is a workaround for IE 6 not supporting min-width and max-width
 * The page maxwidth is 1024 and min width is 785. 
 * This one function should resize
 */
function ResizeWindowCallBack()
{
    var widths = GetWidths();
	var pageContainer = document.getElementById('pageContainer');
	var loginAndFind = document.getElementById('loginAndFind');
	var loginHeader = document.getElementById('loginHeader');
	var findHeader = document.getElementById('findHeader');
	var navigationRight = document.getElementById('navigation_right');
	var navigation = document.getElementById('navigation');	
	//get rid of the flicker by turning the right nav off while resizing
	if (navigationRight != null) navigationRight.style.display = 'none';
	if (navigation != null) navigation.style.display = 'none';
	if (loginAndFind != null) loginAndFind.style.display = 'none';
	if (loginHeader != null) loginHeader.style.display = 'none';
	if (findHeader != null) findHeader.style.display = 'none';
	if (pageContainer.style.width != widths.PageContainerWidth)
		pageContainer.style.width = widths.PageContainerWidth;
	if (document.body.style.width != widths.BodyWidth)
		document.body.style.width = widths.BodyWidth;
	//get rid of the flicker by turning the right nav back on now that we are done resizing
	if (navigation != null) navigation.style.display = 'block';
	if (navigationRight != null) navigationRight.style.display = 'block';
	if (loginAndFind != null) loginAndFind.style.display = 'block';
		if (loginHeader != null) loginHeader.style.display = 'block';
	if (findHeader != null) findHeader.style.display = 'block';
}

/** Get the widths of the dynamic elements and shove them into a collection box **/
function GetWidths()
{
    var widths = new Object()
    widths.Width = document.documentElement.clientWidth;
	widths.BodyWidth = widths.Width - 50;
	widths.PageContainerWidth = widths.BodyWidth;
	widths.LoginAndFindWidth = "auto";
	if (widths.BodyWidth <= 730)
	{
		widths.PageContainerWidth = "730px";
		widths.BodyWidth = "730px";
	}
	else if (widths.Width >= 1024)
	{
		widths.PageContainerWidth = "1024px";
	}
	return widths;
}


//register the re-size workaround for ie
if (navigator.appVersion.indexOf('MSIE 6') != -1)
{
	window.onresize = BeginResizeWindow;
	window.onload = BeginResizeWindow;
	
	
	//export the styles manually so the screen doesn't flicker
	var widths = GetWidths();
	var style = '<style>';
	style+= '#pageContainer{width:' + widths.PageContainerWidth + ';}';
	style+= 'body{width:' + widths.BodyWidth + ';}';
	style +='</style>';
	document.writeln(style);
}


