// JavaScript Document

// J.Skemp, 08/23/2007 - Added to make all block content hidden, save one. I don't know if this will cause conflicts, so ...
function addOnloadEvent_Conv(fnc) {
	if ( typeof window.addEventListener != "undefined" )
		window.addEventListener( "load", fnc, false );
	else if ( typeof window.attachEvent != "undefined" ) {
		window.attachEvent( "onload", fnc );
	}
	else {
		if ( window.onload != null ) {
			var oldOnload = window.onload;
			window.onload = function ( e ) {
				oldOnload( e );
				window[fnc]();		
			};
		}
		else 
			window.onload = fnc;
	}
}


// J.Skemp, 08/23/2007 - Validates that a value is numeric. JS doesn't have something like this built in? Can't be a real programming language then ...
function isNumeric(value) {
	if (value == null || !value.toString().match(/^[-]?\d*\.?\d*$/)) return false;
	return true;
}

// J.Skemp, 08/23/2007 - For this function, pass the id of the block you want to display, as well as the total number of blocks. Also pass the beginning of the id for the tab, followed by the id of the content block. The one you want to display will be shown (currentItem), while the rest will be hidden.
function activateContentBlockID(currentItem,totalItems,baseNameNav,baseNameContent) {
	if (isNumeric(currentItem) && isNumeric(totalItems)) { // Make sure we have numeric values for those that should be numeric.
		for (var x = 1; x <= totalItems; x++) {
			if (document.getElementById(baseNameNav + x)) {
				tempObject = document.getElementById(baseNameNav + x);
				tempObject.setAttribute('class', '');
				tempObject.className = '';
			}
			if (document.getElementById(baseNameContent + x)) {
				tempObject = document.getElementById(baseNameContent + x);
				tempObject.setAttribute('style','display:none;');
				tempObject.style.display = 'none';
			}
		}
		if (currentItem <= totalItems) {
			if (document.getElementById(baseNameNav + currentItem)) {
				tempObject = document.getElementById(baseNameNav + currentItem);
				tempObject.setAttribute('class','intTabSelect');
				tempObject.className = 'intTabSelect';
			}
			if (document.getElementById(baseNameContent + currentItem)) {
				tempObject = document.getElementById(baseNameContent + currentItem);
				tempObject.setAttribute('style','display:block;');
				tempObject.style.display = 'block';
			}
		}
	}
}

// J.Skemp, 08/23/2007 - For this function, pass the id of the block you want to display, as well as the total number of blocks. Also pass the beginning of the id for the tab, followed by the id of the content block. The one you want to display will be shown (currentItem), while the rest will be hidden. 10/03/2007, Added bgImage controls.
function activateContentBlockID_bgImg(currentItem,totalItems,baseNameNav,baseNameContent,bgImageNorm,bgImageSel) {
	if (isNumeric(currentItem) && isNumeric(totalItems)) { // Make sure we have numeric values for those that should be numeric.
		for (var x = 1; x <= totalItems; x++) {
			tempObject = document.getElementById(baseNameNav + x);
			tempObject.setAttribute('style','background-image:url(' + bgImageNorm + ');');
			tempObject.style.backgroundImage = 'url(' + bgImageNorm + ')';
			tempObject = document.getElementById(baseNameContent + x);
			tempObject.setAttribute('style','display:none;');
			tempObject.style.display = 'none';
		}
		if (currentItem <= totalItems) {
			tempObject = document.getElementById(baseNameNav + currentItem);
			tempObject.setAttribute('style','background-image:url(' + bgImageSel + ');');
			tempObject.style.backgroundImage = 'url(' + bgImageSel + ')';
			tempObject = document.getElementById(baseNameContent + currentItem);
			tempObject.setAttribute('style','display:block;');
			tempObject.style.display = 'block';
		}
	}
}

function activateContentBlockListID(currentItem,totalItems,baseBlockName) {
	if (isNumeric(currentItem) && isNumeric(totalItems)) { // Make sure we have numeric values for those that should be numeric.
		for (var x = 1; x <= totalItems; x++) {
			tempObject = document.getElementById(baseBlockName + x);
			tempObject.setAttribute('style','display:none;');
			tempObject.style.display = 'none';
		}
		if (currentItem <= totalItems) {
			tempObject = document.getElementById(baseBlockName + currentItem);
			tempObject.setAttribute('style','display:block;');
			tempObject.style.display = 'block';
		}
	}
}
