/* Create Flash Tags */
/*
		<div id="headerFlash">
			<object type="application/x-shockwave-flash" data="../flash/header/header.swf" width="474" height="75">
				<param name="movie" value="../flash/header/header.swf" />
				<param name="wmode" value="transparent" />
			</object>
		</div>
		<div id="slideShowFlash">
			<object type="application/x-shockwave-flash" data="../flash/slideshow/slideshow.swf" width="151" height="151">
				<param name="movie" value="../flash/slideshow/slideshow.swf" />
				<param name="wmode" value="transparent" />
			</object>
		</div>
		<div id="testimonialFlash">
			<object type="application/x-shockwave-flash" data="../flash/testimonial/testimonial.swf" width="130" height="200">
				<param name="movie" value="../flash/testimonial/testimonial.swf" />
				<param name="wmode" value="transparent" />
			</object>
		</div>

*/
function CreateFlashTags(sFlashFile, iHeight, iWidth)
{
    var sFlashTag;
	sFlashTag =  "<object type='application/x-shockwave-flash' data='../flash/" + sFlashFile + "' width='" + iWidth + "' height='" + iHeight + "'>\n";
	sFlashTag += "<param name='movie' value='../flash/" + sFlashFile + "' />\n";
	sFlashTag += "<param name='wmode' value='transparent' />\n";
	sFlashTag += "</object>\n";
	document.write(sFlashTag);
}

var bShowFlash;
function adjustLayout()
{
/*
    if (arguments.length == 1)
    {
        bShowFlash = arguments[0];
    }
*/

	var headerHeight = 140;
	var leftNavHeight = 550;
	var minClientHeight = 600;
	var slideShowHeight = 151;
	var testimonialHeight = 200;
	var footerHeight = 45;
	var flashGap = 5;
	var leftNavTargetHeight = xClientHeight() - headerHeight;
	var targetHeight = xHeight("content") + headerHeight + footerHeight;
	
	//alert("content: " + xHeight("content"));
	
	if (xClientHeight() > targetHeight)
	{
	    xHeight("leftNav", xClientHeight() - headerHeight);
	    xHeight("rightNav", xClientHeight());
	    
	    var slideShowTop = xClientHeight() - slideShowHeight - flashGap;
	    var testimonialTop = xClientHeight() - testimonialHeight - flashGap;
	    var footerTop = xClientHeight() - footerHeight;
	    
	    placeElements(slideShowTop, testimonialTop, footerTop);
	}
	else if (xClientHeight() < targetHeight)
	{
	    xHeight("leftNav", targetHeight - headerHeight);
	    xHeight("rightNav", targetHeight);
	    
	    var slideShowTop = targetHeight - slideShowHeight - flashGap;
	    var testimonialTop = targetHeight - testimonialHeight - flashGap;
	    var footerTop = targetHeight - footerHeight;
	    
	    placeElements(slideShowTop, testimonialTop, footerTop);
	}
	
	if (xClientHeight() < (leftNavHeight + headerHeight))
	{
	    if (targetHeight < xClientHeight())
	    {
            xHeight("rightNav", leftNavHeight + headerHeight);
            	    
	        var slideShowTop = leftNavHeight + headerHeight - slideShowHeight - flashGap;
	        var testimonialTop = leftNavHeight + headerHeight - testimonialHeight - flashGap;
	        var footerTop = leftNavHeight + headerHeight - footerHeight;
	        
	        placeElements(slideShowTop, testimonialTop, footerTop);
	    }
	}
	
    xShow("footer");
	if (bShowFlash)
	{
	    xShow("headerFlash");
	    xShow("slideShowFlash");
	    xShow("testimonialFlash");
	}
}

function placeElements(sTop, tTop, fTop)
{
    xTop("slideShowFlash", sTop);
    xTop("testimonialFlash", tTop);
    xTop("footer", fTop);
}

function hideFlash(sName)
{
    xHide(sName + "Flash");
}

function showFlash(sName)
{
    xShow(sName + "Flash");
}

/* This is now created in code. */
//window.onload = function()
function WindowOnLoad(bShowFlashObjects)
{
    bShowFlash = bShowFlashObjects;
	adjustLayout();
	try { RunAfterAdjust(); } catch(e) {}
	xAddEventListener(window, "resize", adjustLayout, false);
}