path1 = '/include/img/rollover/over/';

function preloadStandard() {
	preloadImages(
					path1 + 'nav_home.gif',
					path1 + 'nav_events.gif',
					path1 + 'nav_bio.gif',
					path1 + 'nav_pub.gif',
					path1 + 'nav_reviews.gif',
					path1 + 'nav_onpub.gif',
					path1 + 'nav_contact.gif',
					path1 + 'nav_info.gif'
	);
}

preloaded_images = new Array();
num_preloaded_images = 0;	// a running count of all preloaded images
num_images_to_preload = 0;	// a running count of the number of requested images to preload

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	// make sure the document allows images,
	// that there are more than zero preloaded images
	// and that all the images successfully preloaded
	if (document.images && num_preloaded_images && (num_preloaded_images == num_images_to_preload)) {
		for (var i=0; i < changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function count_preloaded_images() {
	++num_preloaded_images;
}


// this version uses the preloaded_images array
// its args are just the image path/sources
function preloadImages() {
	// check if the document allows images
	if (document.images) {
		// add the new requests to the total number
		num_images_to_preload += preloadImages.arguments.length;
		// preload images into array
		for (var i=0; i < preloadImages.arguments.length; i++) {
			// add them to the end of the array
			preloaded_images[num_preloaded_images] = newImage(preloadImages.arguments[i]);
			// count how many images successfully load
			preloaded_images[num_preloaded_images].onload = count_preloaded_images();
		}
	}
}


// use this to see what is in the preloaded_images array
// OPTIONS
//	A) no arg: alerts how many images in array and displays source of last one
//	B) arg is 'all': alerts how many images in array and displays source of all
//	C) arg is an integer i between 0 and the number of images in array:
//		alerts how many images in array and displays source of ith image
//	D) arg is 'off': just turns it off (as an alternative to deleting the call from the page
function debug_preload() {
	firstarg = debug_preload.arguments[0];
	
	if (firstarg != 'off') {
		var img_index = num_preloaded_images-1;
		var list_all = false;
		var s= num_preloaded_images +" images preloaded:\n\n";
	
		if (typeof firstarg == "number") {
			if(firstarg >= 0 && firstarg < num_preloaded_images)
				img_index = firstarg;
		}
		else if (firstarg == "all")
			list_all = true;
			
		if (list_all)
			for (var i=0; i < num_preloaded_images; i++)
				s += "  "+ i +": "+preloaded_images[i].src +"\n";
		else
			s += img_index +": "+preloaded_images[img_index].src;
	
		alert(s);
	}
}

