/* Echo Field Paintball - Cranbrook BC                 */
/* Javascript Sheet                                          */
/* by NetStyle Media - www.NetStyleMedia.com  */
/* Michael Ridler - mridler@netstylemedia.com     */
/*                                                                    */


// globals
// directory path
var path = './images/gallery/';

// current image to display
var current = 0; 

//var photos = new Array();
var photos;

var photos_field = new Array(
	new Array("0",  "field/field_01.jpg", "field/field_01_th.jpg", ""),
	new Array("1",  "field/field_02.jpg", "field/field_02_th.jpg", ""),
	new Array("2",  "field/field_03.jpg", "field/field_03_th.jpg", ""),
	new Array("3",  "field/field_04.jpg", "field/field_04_th.jpg", ""),
	new Array("4",  "field/field_05.jpg", "field/field_05_th.jpg", ""),
	new Array("5",  "field/field_06.jpg", "field/field_06_th.jpg", ""),
	new Array("6",  "field/field_07.jpg", "field/field_07_th.jpg", "")
);

var photos_players = new Array(
	new Array("0",  "players/players_01.jpg", "players/players_01_th.jpg", ""),
	new Array("1",  "players/players_02.jpg", "players/players_02_th.jpg", ""),
	new Array("2",  "players/players_03.jpg", "players/players_03_th.jpg", ""),
	new Array("3",  "players/players_04.jpg", "players/players_04_th.jpg", ""),
	new Array("4",  "players/players_05.jpg", "players/players_05_th.jpg", ""),
	new Array("5",  "players/players_06.jpg", "players/players_06_th.jpg", ""),
	new Array("6",  "players/players_07.jpg", "players/players_07_th.jpg", ""),
	new Array("7",  "players/players_08.jpg", "players/players_08_th.jpg", ""),
	new Array("8",  "players/players_09.jpg", "players/players_09_th.jpg", ""),
	new Array("9",  "players/players_10.jpg", "players/players_10_th.jpg", ""),
	new Array("10", "players/players_11.jpg", "players/players_11_th.jpg", ""),
	new Array("11", "players/players_12.jpg", "players/players_12_th.jpg", ""),
	new Array("12", "players/players_13.jpg", "players/players_13_th.jpg", ""),
	new Array("13", "players/players_14.jpg", "players/players_14_th.jpg", ""),
	new Array("14", "players/players_15.jpg", "players/players_15_th.jpg", ""),
	new Array("15", "players/players_16.jpg", "players/players_16_th.jpg", ""),
	new Array("16", "players/players_17.jpg", "players/players_17_th.jpg", ""),
	new Array("17", "players/players_18.jpg", "players/players_18_th.jpg", ""),
	new Array("18", "players/players_19.jpg", "players/players_19_th.jpg", ""),
	new Array("19", "players/players_20.jpg", "players/players_20_th.jpg", ""),
	new Array("20", "players/players_21.jpg", "players/players_21_th.jpg", ""),
	new Array("21", "players/players_22.jpg", "players/players_22_th.jpg", ""),
	new Array("22", "players/players_23.jpg", "players/players_23_th.jpg", ""),
	new Array("23", "players/players_24.jpg", "players/players_24_th.jpg", ""),
	new Array("24", "players/players_25.jpg", "players/players_25_th.jpg", ""),
	new Array("25", "players/players_26.jpg", "players/players_26_th.jpg", ""),
	new Array("26", "players/players_27.jpg", "players/players_27_th.jpg", ""),
	new Array("27", "players/players_28.jpg", "players/players_28_th.jpg", ""),
	new Array("28", "players/players_29.jpg", "players/players_29_th.jpg", ""),
	new Array("29", "players/players_30.jpg", "players/players_30_th.jpg", ""),
	new Array("30", "players/players_31.jpg", "players/players_31_th.jpg", "")
);

var photos_staff = new Array(
	new Array("0",  "staff/staff_01.jpg", "staff/staff_01_th.jpg", ""),
	new Array("1",  "staff/staff_02.jpg", "staff/staff_02_th.jpg", ""),
	new Array("2",  "staff/staff_03.jpg", "staff/staff_03_th.jpg", ""),
	new Array("3",  "staff/staff_04.jpg", "staff/staff_04_th.jpg", ""),
	new Array("4",  "staff/staff_05.jpg", "staff/staff_05_th.jpg", ""),
	new Array("5",  "staff/staff_06.jpg", "staff/staff_06_th.jpg", "")
);

var photos_tournaments = new Array(
	new Array("0",  "tournaments/tournaments_01.jpg", "tournaments/tournaments_01_th.jpg", ""),
	new Array("1",  "tournaments/tournaments_02.jpg", "tournaments/tournaments_02_th.jpg", ""),
	new Array("2",  "tournaments/tournaments_03.jpg", "tournaments/tournaments_03_th.jpg", ""),
	new Array("3",  "tournaments/tournaments_04.jpg", "tournaments/tournaments_04_th.jpg", ""),
	new Array("4",  "tournaments/tournaments_05.jpg", "tournaments/tournaments_05_th.jpg", ""),
	new Array("5",  "tournaments/tournaments_06.jpg", "tournaments/tournaments_06_th.jpg", "")
);


function roll_over(img_id, img_src) {
   document.getElementById(img_id).src = img_src;
}


function gallerySetup(gallery) {
	gallery = gallery.replace(/\?/g, '');
	
	//pulls 1 large pic and thumbs from the photos array
	var x = 0;
	var thumb;
	var id;
	var thumbnails = '';
	var y = 0;
	var title = '';
	
	if      (gallery == 'field')       { photos = photos_field;       title = 'Field Photos'; }
	else if (gallery == 'players')     { photos = photos_players;     title = 'Player Photos'; }
	//else if (gallery == 'staff')       { photos = photos_staff;       title = 'Staff Photos'; }
	//else if (gallery == 'tournaments') { photos = photos_tournaments; title = "Tournament Photos"; }
	else                               { photos = photos_field;       title = 'Field Photos'; }
	
	while(x < photos.length) {
		thumb       = path + photos[x][2];
		thumbnails += '<a href="#" onClick="return(newImage(' + photos[x][0] + '))"><img class="gallery_thumb" src="' + thumb + '"></a>';
		x++;
	}
	
	document.getElementById("gallery_title").innerHTML      = title;
	document.getElementById("gallery_thumbnails").innerHTML = thumbnails;
	document.getElementById("gallery_photo").src            = path + photos[y][1];
	document.getElementById("gallery_notes").innerHTML      = photos[y][3];
}


function newImage(show) {
	// Determines if the user has reached either end of the 
	// thumbnail list and jumps to first or last image.
	if (show < 0) {
		show = photos.length - 1;
	} else if (show >= photos.length) {
		show = 0;
	}
	
	// Updates which image is currently displayed.
	current = show;
	
	// If javascript is supported the new image will update.
	// If javascript is not supported the new image will display on its own page.
	if (document.images) {
		var picture = path + photos[show][1];
		document.getElementById("gallery_photo").src = picture;
		document.getElementById("gallery_notes").innerHTML  = photos[show][3];
		return false;
	} else {
		return true;
	}
}


