// Add below functions to onload queue
if (document.getElementById('right-box-content') != null) {
	if (window.attachEvent)
		window.attachEvent('onload', auto_size);
	else if (window.addEventListener)
		window.addEventListener('load', auto_size, false);
	else
		document.addEventListener('load', auto_size, false);
}
else if (document.location.href.match('ResourceCenter') != null) {
	if (window.attachEvent)
		window.attachEvent('onload', resources);
	else if (window.addEventListener)
		window.addEventListener('load', resources, false);
	else
		document.addEventListener('load', resources, false);
}


function auto_size() {
	// Adjust width of right box to fit the image(s) contained inside

	var imgs = document.getElementById('right-box-content').getElementsByTagName('img');
	var max_width = 150;
	
	for (var i = 0; i < imgs.length; i++) {
		if (max_width < imgs[i].width)
			max_width = imgs[i].width;
	}

	document.getElementById('main-content').style.marginRight = document.getElementById('right-box').style.width = (max_width + 30) + 'px';
}

function resources() {
	// Add "current" class to navigation and customize h1
	
	if (document.location.href.match('Glossary') != null) {
		document.getElementById('glossary').className = 'current';
		document.getElementById('resources').innerHTML = 'Glossary';
		document.getElementById('page-content').className = 'glossary';
	}
	else if (document.location.href.match('Calculators') != null) {
		document.getElementById('calculators').className = 'current';
		document.getElementById('resources').innerHTML = 'Calculators';
		document.getElementById('page-content').className = 'calculators';
	}
	else if (document.location.href.match('ResCtrInfo') != null) {
		document.getElementById('resctrinfo').className = 'current';
		document.getElementById('resources').innerHTML = 'FAQs';
	}
}