// Find out if we're viewing the album list, or an album image.
// This means that when they click on an album, it will open in a new window,
//   and display the first image, with all the info. They can then click the
//   "next" or "back" buttons, if possible, or click the "close" button.
// If we are in an album, variable "In_Album" will be the number of the album
//   and "In-Photo" will be the number of the photo. If either one is missing,
//   they both will be set to "0". This is for FLAG ONLY. **NOT TO DETERMINE ANY
//   HTML CODING**.

// Our function...
function getVar(name)
{
	get_string = document.location.search;
	return_value = '';
	do
	{
		//This loop is made to catch all instances of any get variable.
		name_index = get_string.indexOf(name + '=');

		if (name_index != -1)
		{
			get_string = get_string.substr(name_index + name.length + 1, get_string.length - name_index);
			end_of_value = get_string.indexOf('&');
			if (end_of_value != -1)
				value = get_string.substr(0, end_of_value);
			else
				value = get_string;
			if (return_value == '' || value == '')
				return_value += value;
			else
				return_value += ', ' + value;
		}
	} while (name_index != -1)

	space = return_value.indexOf('+');
	while (space != -1)
	{
		return_value = return_value.substr(0, space) + ' ' +
			return_value.substr(space + 1, return_value.length);
		space = return_value.indexOf('+');
	}
	return(return_value);
}

// Format of our array...
// 0 - Number of Albums
// 1 - Description
// 2 - Date
// 3 - Base path (prepended to pictures)
// 4 - Thumbnaill Image (to be prepended with #3 above)
// 5 - Number of Photos in this Album.
// (Above HAS to be defined here. MAY also be defined in 'album_x.js'.
var Albums = new Array;
Albums[0] = 2;

Albums[1] = new Array;
Albums[1][1] = "Grand Opening at United Drywall";
Albums[1][2] = "Mar 21st, 2005";
Albums[1][3] = "/images/albums/go_ud/";
Albums[1][4] = "thumb.jpg";
Albums[1][5] = 8;

Albums[2] = new Array;
Albums[2][1] = "Blue Ridge Scenic Railroad 2004";
Albums[2][2] = "";
Albums[2][3] = "/images/albums/brsr_2004/";
Albums[2][4] = "thumb.jpg";
Albums[2][5] = 7;


// Get our information..
InPhoto = getVar("photo");
InAlbum = getVar("album");
if (InPhoto == '' || InAlbum == '')
{
	InPhoto = 0;
	InAlbum = 0;
}
else
{
	if (InAlbum > Albums[0] || InAlbum < 1)
	{
		InAlbum = 0;
		InPhoto = 0;
	}
	else
	{
		if (InPhoto > Albums[InAlbum][5] || InPhoto < 1)
		{
			InAlbum = 0;
			InPhoto = 0;
		}
	}
}