/*	SCRIBE_UTILITIES.JS
 *
 *	General InqScribe javascript utilities.
 *	These will be loaded on every InqScribe page that uses the InqScribe_Template.
 *
 */


//	Preload images
function preloadImages() {
	var imageFileNames = [
			'download_on.png',
			'buy_on.png'
		];
	var imageObjects = [];
	
	var u = imageFileNames.length;
	for (var i=0; i<u; i++ ) {
		imageObjects[i] = new Image();
		imageObjects[i].src = 'images/' + imageFileNames[i];
	}
}


//	Safe window onload event listener
//	Use this function to add window onload events without clobbering existing onload events.
function addLoadListener(fn) {
	if (typeof window.addEventListener != 'undefined') {
		window.addEventListener('load', fn, false);
	}
	else if (typeof document.addEventListener != 'undefined') {
		document.addEventListener('load', fn, false);
	}
	else if (typeof window.attachEvent != 'undefined') {
		window.attachEvent('onload', fn);
	}
	else {
		var oldfn = window.onload;
		if (typeof window.onload != 'function') {
			window.onload = fn;
		} else {
			window.onload = function() {
				oldfn();
				fn();
			};
		}
	}
}



addLoadListener( preloadImages );
