function getIEVersion()
{
	var rv = -1; // Return value assumes failure.
	
	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		var ua = navigator.userAgent;
		var re  = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
		if (re.exec(ua) != null)
		rv = parseFloat( RegExp.$1 );
	}
	
	return rv;
}

// Set the columns to equal heights
addLoadEvent(function() 
{
	function $(e) { return document.getElementById(e); }

	var mainCopy = $('mainCopy');
	var secLinks = $('secondaryLinks');
	

	
	if (document.body.className == 'home' && 
		(getIEVersion() < 7 && getIEVersion() != -1))
	{
		mainCopy.style.height = mainCopy.offsetHeight - 310 + 'px';
	}	
});

// Fixup the top of the resource block
addLoadEvent(function()
{
	var resourceBlock = document.getElementById('resources');
	var magicNumber   = (getIEVersion() == 6) ? 154 : 5;

	if (!resourceBlock)
	{
		return;
	}
	
	var o = resourceBlock.offsetTop;
	var t = resourceBlock.style.marginTop.split('px')[0];
	
	var adjuster = magicNumber - o - t;
	resourceBlock.style.marginTop = adjuster + 'px';
});

// Randomize the squigee image
addLoadEvent(function() 
{
	var squigee = document.getElementById('squigee');
	var randNum = Math.round(Math.random() * (12 - 1));
	
	if (squigee)
	{
		squigee.src = '/siteflow/images/squigee_images/squigee_' + randNum + '.jpg';
	}
});

function addLoadEvent(func) 
{
	var oldonload = window.onload;

	if (typeof window.onload != 'function')
	{
		window.onload = func;
	}
	else
	{
		window.onload = function() { oldonload(); func(); };
	}
}


function printPage()
{
	window.print();  
	return false;
}

function swapEm2(imagename, stat)
{
	var opStat  = (stat == 'on') ? 'off' : 'on';
	var myImage = document.getElementById(imagename);
	var myRegEx = new RegExp(opStat + '(\.[a-z]{3})$');
	
	myImage.src = myImage.src.replace(myRegEx, stat + '$1');
	return true;
}

/*
 * Main Banner Images
 */
var imgBase = 'https://www.akronchildrens.org/dcm/elements/headers/';
var urlBase = 'https://www.akronchildrens.org/cms/site/';

var theBanners = 
[
	'heart_abby.jpg',
	'heart_qt.jpg',
	'autism_payton.jpg',
	'neuro_kyle.jpg',
	'depression_lakeina.jpg',
	'hannah_hull_cancer.jpg',
	'sickle_darayah.jpg'
];

var theURL = 
[
	'b5b83873c878fa4c',
	'3c4b446aea183c1e',
	'99ba4bbd5bc477d6',
	'2a745d338781c733',
	'cc939282a76e06e0',
	'0e6bc8cfccee5035',
	'0415cc3dc7f50304'
];

function showBanner()
{
	var imgIndex = Math.round(Math.random() * (theBanners.length - 1));
	
	var buffer   = new Image();
	buffer.src   = imgBase + theBanners[imgIndex];
	
	document.write(
		'<a id="topAd" href="' + urlBase + theURL[imgIndex] + '">' +
		'<img border="0" src="' + buffer.src + '" width="556"' +
		' height="97" title="Akron Childrens" /></a>'
	);
}

function pop_image(image, width, height) 
{
	window.open(escape(image),"","width="+width+",height="+height+",menubar=0,scrollbars=1,toolbar=0");
	return false;
}

function pop_image2(image, width, height) 
{
	window.open(image,"","width="+width+",height="+height+",menubar=0,scrollbars=1,toolbar=0");
	return false;
}

function pop(url) 
{	
	var loc = window.location;
	window.open(url,'pop_resource','toolbar=0,menubar=0,location=0,scrollbars=1,height=500,width=600,resizable=1');
	return false;
}

function pop_window(url,width,height) 
{
	window.open(url,"info",'toolbar=no,menubar=no,resizable=yes,location=no,scrollbars=yes,height='+height+',width='+width);
	return false;
}