var media_dir = "/ronkatz/media";

var pictures = new Array();
var selected_pics = new Array();
var preloaded_pics = new Array();

function init()
{
	// preload pics
	// these are always present
	
	var count = preloaded_pics.length;
	
	// this loads all the preloaded_pics into memory
	count = 0;
	for (var i = 0; i < preloaded_pics.length; i++)
	{
		pictures[count] = new Image();
		pictures[count].src = media_dir + "/" + preloaded_pics[i] + "_off.gif";

		count++;
		
		pictures[count] = new Image();
		pictures[count].src = media_dir + "/" + preloaded_pics[i] + "_on.gif";
		
		count++;
	}

	rollOver('');
}

function rollOver(pic)
{
	var pics = new Array();

	// this creates an array of all of the images that should be turned on
	if (pic == "")
	{
		for (var i = 0; i < selected_pics.length; i++)
		{
			pics[i] = selected_pics[i];
		}
	}
	else
	{
		pics[0] = pic;
	}

	for (var i = 0; i < pics.length; i++)
	{
		for (var j = 0; j < pictures.length; j++)
		{		
			if (pictures[j].src.indexOf(media_dir + "/" + pics[i] + "_on.gif") != -1)
			{
				document.images[pics[i]].src = pictures[j].src;
			}
		}
	}
}

function rollOut(pic)
{
	var count = 0;
	
	// this verifies that the image to turn off is not supposed to be always on
	for (var i = 0; i < selected_pics.length; i++)
	{
		if (pic != selected_pics[i])
		{
			count++;
		}
	}
	
	// turn off the image
	if (count == selected_pics.length)
	{
		for (var j = 0; j < pictures.length; j++)
		{
			if (pictures[j].src.indexOf(media_dir + "/" + pic + "_off.gif") != -1)
			{
				document.images[pic].src = pictures[j].src;
			}
		}
	}
}
