<!--
/* Chayne Walsh : 2007 08 01 */

var siteTopRowHeight = 10;
var siteHeaderRowHeight = 80;
var sitePictureRowHeight = 210;
var siteNewsRowHeight = 30;
var siteTopTableHeight = (siteTopRowHeight + siteHeaderRowHeight + sitePictureRowHeight + siteNewsRowHeight);

function getImageFiles()
{
	if ( Core.getEnv('PAGE_NAME_FULL') == 'index.asp' || Core.getEnv('PAGE_NAME_FULL').length == 0 )
	{
		document.getElementById('siteTopRow1').style.height = siteTopRowHeight + 'px';
		document.getElementById('siteHeaderRow2').style.height = siteHeaderRowHeight + 'px';
		document.getElementById('sitePictureRow3').style.display = 'block';
		document.getElementById('sitePictureRow3').style.height = sitePictureRowHeight + 'px';
		document.getElementById('siteNewsRow4').style.display = 'block';
		document.getElementById('siteNewsRow4').style.height = siteNewsRowHeight + 'px';
		document.getElementById('siteTable').style.height = siteTopTableHeight + 'px';
	}
	var httpRequest = Core.createXHR();
	httpRequest.onreadystatechange = function()
	{  
		if (httpRequest.readyState == 4)
		{
			if (httpRequest.status == 200)
			{
				try
				{
					createArray(httpRequest.responseText);
					homeBanner();
					document.getElementById('homeBannerLoadImage').style.display='none';
				}
				catch (e){/* */}
			}
			else
			{
				/* */
			}
		}
	}
	httpRequest.open('GET', Core.getEnv('RELATIVE_ROOT') + "assets/scripts/asp/class.HomeBanner.asp", true);
	httpRequest.send(null);
}
var fadeimages = new Array();

function createArray(a)
{
	var arrImages = a.split("][");
	var fadeimagesIndex = 0;
	for ( i in arrImages )
	{
		fadeimagesIndex = fadeimages.length;
		fadeimages[fadeimagesIndex] = new Image(780,380);
		fadeimages[fadeimagesIndex].src = Core.getEnv('RELATIVE_ROOT') + 'assets/images/banner_780/' + arrImages[i];
	}
	
}

var lastImage = new Image(780,380); var thisImage = new Image(780,380);
function homeBanner()
{
	if ( Core.getEnv('PAGE_NAME_FULL') == 'index.asp' || Core.getEnv('PAGE_NAME_FULL').length == 0 )
	{
		document.getElementById('siteTopRow1').style.height = siteTopRowHeight + 'px';
		document.getElementById('siteHeaderRow2').style.height = siteHeaderRowHeight + 'px';
		document.getElementById('sitePictureRow3').style.display = 'block';
		document.getElementById('sitePictureRow3').style.height = sitePictureRowHeight + 'px';
		document.getElementById('siteNewsRow4').style.display = 'block';
		document.getElementById('siteNewsRow4').style.height = siteNewsRowHeight + 'px';
		document.getElementById('siteTable').style.height = siteTopTableHeight + 'px';
	}
	var speedFadeOut = 50;
	thisImage = fadeimages[get_random(fadeimages.length)];
	if ( lastImage.src != thisImage.src )
	{
		lastImage = thisImage;
		var obj = document.getElementById('homeBanner');
		Core.opacityFlash('homeBanner', 100, 0, speedFadeOut);
		setTimeout ( "swapImage('homeBanner','" + thisImage.src + "');", speedFadeOut );
		
	}	
	setTimeout ( "homeBanner()", 20000 );
	
}
function swapImage(id,src)
{
		
	try
	{
		document.getElementById(id).src = src;
		
		Core.opacityFlash(id, 0, 100, 50);
		document.getElementById(id).style.display = 'block';
	}
	catch (e) { /*do nothing*/}
}
function get_random(n)
{
    var ranNum= Math.floor(Math.random()*n);
    return ranNum;
}

function setHomeBannerDisplay()
{
	if ( Core.getEnv('PAGE_NAME_FULL') != 'index.asp' && Core.getEnv('PAGE_NAME_FULL').length > 0 )
	{
		document.getElementById('sitePictureRow3').style.display = 'none';
		document.getElementById('sitePictureRow3').style.height = '0px';
		document.getElementById('siteTable').style.height = (siteTopRowHeight + siteHeaderRowHeight) + 'px';
	}
}
/*///////////////////////////////////////////////////////////////////////////////////////////////////*/

function initializeZones()
{
	setHomeBannerDisplay();
	//getNewsHeadlines();
	getImageFiles();
}


if (window.addEventListener)
{ 
	window.addEventListener("load", initializeZones, false); 
}
else if (window.attachEvent)
{ 
	var r = window.attachEvent("onload", initializeZones); 
}
else
{ 
	window.onload = function ()
	{ 
		initializeZones();
	}
}
//-->