// JavaScript Document
var querystring = window.location.search;
var querystringValue = querystring.substring(querystring.indexOf("=") +1, querystring.length); 

var currentGallery = 1;
var currentImage = 1;
var totalImage = 8;

var caption = new Array(
	new Array("WAM trainee Ejnar Aerok of Arno Atoll is giving a presentation to the students from the Delap Village HeadStart in Majuro Atoll.",
			  "Sailors representing the atolls of Ujae and Lae are getting their canoes ready during the Legendary Jõbro Tipñõl (mid-size sailing canoe) race. The race was hosted by the Iroij (high chiefs) from Rãlik (Sunset) Chain.",
			  "Kids playing as the sailors are getting their canoes ready for Majuro Atoll Latao Canoe Race, which is hosted annually by the Majuro Atoll Local Government.",
			  "Crystal Wase, a WAM trainee, is working on her canoe model project.",
			  "Upward Bound students are busy rebuilding a canoe during a WAM-Upward Bound Summer Elective Course.",
			  "John Kawakami, WAM Carpentry and Fiberglass Boat Trainer, is showing a trainee how to measure and cut a piece of wood.",
			  "Trainees in the WAM Carpentry Training Program are busy building the WAM Bungalow as a real-life carpentry project.",
			  "A group of students from Majuro SDA school is getting ready to go out sailing."),
	new Array("Caleb, Traditional Skill Trainer-trainee, is lashing the outrigger complex of one of the canoes.",
			  "Tobonion Samual, a master weaver from Ujae Atoll, is showing trainees Ejnar Aerok, Kejwa Langrik, Jelton Jorlang and James Jelai the traditional technique used to weave the canoe sail.",
			  "Traditional Skill trainees Andy Caleb and Jelton Jorlang demonstrating the traditional canoe building dress and tools.",
			  "WAM’s Class of 2003 graduates with supporters. Left to right: Alson J. Kelen, WAM Program Manager; Jaminlok Kabua; Dennis Alessio, WAM Director; Marton Philip, WAM 2003 Graduate; Hon. Mike Senko, US Ambassador to RMI; Grant James, Outrigger Marshall Islands Resort General Manager; Mark Canny, ADB Consultant to the RMI Ministry of Education; and Goldon Libokmeto, WAM 2003 Graduate.",
			  "WAM graduates 2004. Left to right James Jelai, Ben Jacob, Jelton Jorlang, and Hemty Clement. During 2004, WAM graduated 11 trainees.",
			  "Maui International Festival of Canoes 2005: Marshall Islands was once again represented by a team of the youngest skilled canoe carvers from the WAM program. The team is chopping away on their 18 foot traditional sailing canoe from the Marshall Islands.",
			  "Maui International Festival of Canoes 2005: a large group from the Marshallese community in Maui came to support Marshallese carvers. In the middle in the blue shirt and nut lei is Iroij (high chief) Mike Kabua. This is a traditional Marshallese activity called “Jemjem”. The literal translation is “sharpening tools.” In this case, the people are sharpening the manly spirit in the carvers.",
			  "Festival of Pacific Arts 2004: Marshall Islands was represented by a team of the youngest skilled canoe carvers from the WAM program. Standing proudly next to the completed 14 canoe is: left to right, Ben Jacob, Traditional Skill Trainer- trainee; Alson J. Kelen, WAM Program Manager; Tiem Clement, Master Carver; Hemty Clement, Traditional Skill Trainer-trainee;  James Jelai, Traditional Skill Trainer-trainee; and Ejnar Aerok, Traditional Skill Trainer- trainee."),
	new Array("Trainers-in-training painting the hulls of the 24’ fiberglass catamaran WAM was contracted to build for Ailuk atoll.",
			   "Sea trials in the lagoon with the completed Ailuk fiberglass catamaran.",
			   "Sailing WAM’s voyaging canoe Jitdam in the Majuro lagoon. Our Advanced Trainees recently rebuilt this canoe, with a 35’ fiberglass hull and wooden outrigger complex. It was renamed Jitdam Kapeel.",
			   "Advanced trainees work on their canoe models. Trainees learn to make to-scale museum quality model canoes as an income-generating opportunity.",
			   "Carpentry & Woodworking trainees are building the Youth to Youth in Health/Jodikdik Ñan Jodikdik ilo Ejmour Community Youth Center.",
			   "Young women in WAM’s Administrative Training program learn computer skills as part of their overall office administration curriculum.",
			   "Trainer-in-training Ijikar Anwel works on the fiberglass canoes WAM built for local Majuro elementary schools."),
	new Array("Maui International Festival of Canoes 2004: Marshall Islands is represented by a team of youngest skilled canoe carvers from WAM, left to right: Maston Hicom, Ejnar Aerok along with Master Carver Tiem Clement and WAM Program Manager, Alson J. Kelen.",
			  "Calysta Watson, a volunteer from the US Embassy in the Marshall Islands, is teaching Vocational English to the WAM trainees.",
			  "WAM trainees are taking WAM’s past Program Administrator Jill Luciano and volunteer Helen Lin out sailing on their new 35 foot sailing canoe.",
			  "Marshall Islands paddling team with coach Jason Kisa and Molly and Mary from Lanikai Paddling Club in Hawaii.",
			  "Raewyn Fraser, Australian Volunteer International to WAM, is teaching English to the WAM trainees.",
			  "Maui International Festival of Canoes 2004: a group of women from the Marshallese Protestant Church in Maui came to show their support for the Marshallese Team, which was represented by young carvers from WAM."),
	new Array("Sailors are getting their canoes ready to sail from Jeh Island to Bouj Island in Aelõñlaplap Atoll during the legendary Jõbro Tipñõl (mid-size sailing canoe) race.",
			  "Sailors representing the atolls of Ujae and Lae are getting their canoes during the Jõbro Tipñõl (mid-size sailing canoe) race. The race was hosted by the Iroij (high chiefs) from Rãlik (Sunset) Chain.",
			  "Fire dance from Aelõñlaplap Atoll, part of the festivities at the 2003 Jõbro Tipñõl (mid-size traditional canoe) race.",
			  "The famous “Jõbwa” (stick dance) from Ujae Atoll being performed at the 2003 Jõbro Tipñõl (mid-size sailing canoe) race in Aelõñlaplap Atoll. The sacred Jõbwa can only be performed with the permission and the presence of the Iroij (high chief).",
			  "The famous “Jõbwa Du” or chanters perform at the Jõbro Tipñõl (mid-size sailing canoe) race."),
	new Array("Full-Sized Canoes",
			  "Full-Sized Canoes",
			  "Full-Sized Canoes",
			  "Full-Sized Canoes",
			  "Full-Sized Canoes",
			  "Full-Sized Canoes",
			  "Full-Sized Canoes",
			  "Full-Sized Canoes",
			  "Full-Sized Canoes",
			  "Full-Sized Canoes")
	);

if (querystringValue != null)
{
	var sel = document.getElementById("category");
	if (sel != null)
	{
		for (var i = 0; i < sel.options.length; i++)
		{
			if (sel.options[i].value == querystringValue)
			{
				sel.options[i].selected = "selected";
				currentGallery = i + 1;
				currentImage = 1;
				break;
			}
		}
	}
	
	var title = document.getElementById("title");
	if (title != null) title.innerText = sel.options[currentGallery - 1].text;
	
	switch (querystringValue)
	{
		case "general":
		currentGallery = 1;
		totalImage = 8;
		break;
			
		case "history":
		currentGallery = 2;
		totalImage = 8;
		break;
			
		case "projects":
		currentGallery = 3;
		totalImage = 7;
		break;

		case "volunteers":
		currentGallery = 4;
		totalImage = 6;
		break;
		
		case "jebro":
		currentGallery = 5;
		totalImage = 5;
		break;

		case "canoe":
		currentGallery = 6;
		totalImage = 10;
		break;
}
	
	if (currentGallery > 0)
	{
		var varNumbers = "";
		for (var j = 1; j <= totalImage; j++)
		{
			varNumbers += '&nbsp; <a id="img' + j + '" style="font-weight:bold" href="#" onclick="javascript:showImage(' + j + '); return false;" style="text-decoration:none">' + j + "</a> ";
		}
		if (document.getElementById("numbers") != null)
		{
			document.getElementById("numbers").innerHTML = varNumbers;
			showImage();
		}
	}
}

function changeCategory(cat)
{
	var i = cat.selectedIndex;
	window.location = "gallery.html?category="+cat.options[i].value;
}

function previousImage()
{
	if (document.getElementById("img" + currentImage) != null)
		document.getElementById("img" + currentImage).style.textDecoration = "none";
	currentImage--;
	if (currentImage < 1) currentImage = totalImage;
	showImage();
}

function nextImage()
{
	if (document.getElementById("img" + currentImage) != null)
		document.getElementById("img" + currentImage).style.textDecoration = "none";
	currentImage++;
	if (currentImage > totalImage) currentImage = 1;
	showImage();
}

function showImage(image)
{
	if (!image)
		image = currentImage;
	else
	{
		if (document.getElementById("img" + currentImage) != null)
			document.getElementById("img" + currentImage).style.textDecoration = "none";
		currentImage = image;
	}
	
	var showing = document.getElementById("showing");
	if (showing != null)
	{
		showing.src = "image/gallery_" + currentGallery + "_" + image + ".jpg";
	}
	
	if (document.getElementById("img" + image) != null)
		document.getElementById("img" + image).style.textDecoration = "underline";

	showCaption();
}

function showCaption()
{
	var cap = document.getElementById("caption");
	if (cap != null) cap.innerHTML = caption[currentGallery-1][currentImage-1];
}
