var objWorkImage;
var objWorkTitle;
var objWorkDescription;
var artistPath = "../../images/artists/acmi/";
var artistCurrent = -1;
var artistURL = (location.href.substring(location.href.lastIndexOf('/')+1, location.href.length));
var artists = new Array(
	new Array("mawuliafatsiawo.html", new Array("01.afatsiawo_ghana.jpg","02.afatsiawo_box.jpg","03.afatsiawo_journey.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"Accra Makola Market, Ghana.<br/>Collection of the artist<br/> &copy; Mawuli Afatsiawo" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>Made in Ghana</em> 2000-05<br/>single-channel projection, dvd playback, online interactive installation<br/>Collection of the artist<br />&copy; Mawuli Afatsiawo, courtesy Cornerhouse, Manchester, UK" 
			),

			new Array(
				"&nbsp;",
				"from <em>Made in Ghana</em> 2000-05<br/>single-channel projection, dvd playback, online interactive installation<br/>Collection of the artist<br />&copy; Mawuli Afatsiawo, courtesy Cornerhouse, Manchester, UK" 
		)
		)
	),
	new Array("cmielewskiandstarrs.html", new Array("01.cmielewski_seeker_detail.jpg",
			"02.cmielewski_seeker.jpg",
			"03.cmielewski_seeker_detail.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>Seeker</em> 2006<br/>interactive installation, colour, sound<br/>Collection of the artists<br />&copy; Leon Cmielewski and Josephine Starrs" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>Seeker</em> 2006<br/>interactive installation, colour, sound<br/>Collection of the artists<br />&copy; Leon Cmielewski and Josephine Starrs"
			),

			new Array(
				"&nbsp;",
				"from <em>Seeker</em> 2006<br/>interactive installation, colour, sound<br/>Collection of the artists<br />&copy; Leon Cmielewski and Josephine Starrs"
		)
		)
	),
	new Array("johngilles.html", new Array("01.gillies_divide.jpg",
			"02.gillies_divide.jpg",
			"03.gillies_divide.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>Divide</em> 2004<br/>single-channel projection, digital video, DVD playback, b/w, sound, 25:17<br />Collection of the artist<br />&copy; John Gilles" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>Divide</em> 2004<br/>single-channel projection, digital video, DVD playback, b/w, sound, 25:17<br />Collection of the artist<br />&copy; John Gilles"
			),

			new Array(
				"&nbsp;",
				"from <em>Divide</em> 2004<br/>single-channel projection, digital video, DVD playback, b/w, sound, 25:17<br />Collection of the artist<br />&copy; John Gilles"
		)
		)
	),
	new Array("shilpagupta.html", new Array("01.gupta_untitled.jpg",
			"02.gupta_untitled.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>Untitled</em> 2004<br />interactive installation, colour, sound, 8:00<br />Collection of the artist<br />&copy; Shilpa Gupta" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>Untitled</em> 2004<br />interactive installation, colour, sound, 8:00<br />Collection of the artist<br />&copy; Shilpa Gupta"
			)
		)
	),
	new Array("johnhughes.html", new Array("01.hughes_archive_Mathews-.jpg",
			"02.hughes_archive_Eisen.-5.jpg",
			"03.hughes_archive_Elizabeth.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"Screen design from <em>The Archive Project</em> (film) 2002-06<br/>single-channel projections, 16mm film, DVD playback, b/w, sound<br />Collection of the artist<br />&copy; Early works / JH 2004" // Details
			),

			new Array(
				"&nbsp;", 
				"Screen design from <em>The Archive Project</em> (film) 2002-06<br/>single-channel projections, 16mm film, DVD playback, b/w, sound<br />Collection of the artist<br />&copy; Early works / JH 2004"
			),

			new Array(
				"&nbsp;",
				"Screen design from <em>The Archive Project</em> (film) 2002-06<br/>single-channel projections, 16mm film, DVD playback, b/w, sound<br />Collection of the artist<br />&copy; Early works / JH 2004"
		)
		)
	),
	new Array("isaacjulien.html", new Array("01.julien_paradise.jpg",
			"02.julien_paradise.jpg",
			"03.julien_paradise.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>Paradise Omeros</em> 2002<br/>3-channel projection, 16mm b/w / colour film, DVD playback, sound, 20:29<br />Installation view from Documenta 11, 2002<br/>&copy; Isaac Julien, courtesy of Victoria Miro Gallery, London, UK" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>Paradise Omeros</em> 2002<br/>3-channel projection, 16mm b/w / colour film, DVD playback, sound, 20:29<br />Installation view from Documenta 11, 2002<br/>&copy; Isaac Julien, courtesy of Victoria Miro Gallery, London, UK"
			),

			new Array(
				"&nbsp;",
				"from <em>Paradise Omeros</em> 2002<br/>3-channel projection, 16mm b/w / colour film, DVD playback, sound, 20:29<br />Installation view from Documenta 11, 2002<br/>&copy; Isaac Julien, courtesy of Victoria Miro Gallery, London, UK"
		)
		)
	),
		new Array("mawangiandhutter.html", new Array("01.mwangi_headskin.jpg",
			"02.mwangi_headskin.jpg",
			"03.mwangi_headskin.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>Headskin</em> 2005<br/>2-channel projection, digital video, DVD playback, colour, sound, 5:55<br/>Collection of the artists<br />&copy; Ingrid Mwangi and Robert Hutter" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>Headskin</em> 2005<br/>2-channel projection, digital video, DVD playback, colour, sound, 5:55<br/>Collection of the artists<br />&copy; Ingrid Mwangi and Robert Hutter"
			),

			new Array(
				"&nbsp;",
				"from <em>Headskin</em> 2005<br/>2-channel projection, digital video, DVD playback, colour, sound, 5:55<br/>Collection of the artists<br />&copy; Ingrid Mwangi and Robert Hutter"
		)
		)
	),
	new Array("patriciapiccinini.html", new Array("01.piccinini_baby.jpg",
			"02.piccinini_baby_detail.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>When my baby (When my baby)</em> 2005<br/>single-channel projection, computer animation, DVD playback, colour, sound, 3:30<br/>Collection of the artist<br />&copy; Patricia Piccinini, courtesy Tolarno Galleries, Melbourne; Roslyn Oxley9 Gallery, Sydney; Robert Miller Gallery, New York" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>When my baby (When my baby)</em> (detail) 2005<br/>single-channel projection, computer animation, DVD playback, colour, sound, 3:30<br/>Collection of the artist<br />&copy; Patricia Piccinini, courtesy Tolarno Galleries, Melbourne; Roslyn Oxley9 Gallery, Sydney; Robert Miller Gallery, New York"
			)
		)
	),
	new Array("rea.html", new Array("01.rea_gins_detail.jpg",
			"02.rea_gins_detail.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>gins_leap/dubb_speak</em> (detail) 2003-05<br/>multi-channel projection, digital video, DVD playback, colour, sound 25:00<br/>Collection of the artist<br />&copy; r e a" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>gins_leap/dubb_speak</em> (detail) 2003-05<br/>multi-channel projection, digital video, DVD playback, colour, sound 25:00<br/>Collection of the artist<br />&copy; r e a"
			)
		)
	),
	new Array("bernisearle.html", new Array("01a.searle_forget.jpg",
			"01b.searle_forget.jpg",
			"02.searle_vapour.jpg", "03.searle_away.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>About to forget</em> 2005<br/>3-channel projection, 35mm cinemascope film, DVD playback, colour, sound, 3:00<br/>Collection of the artist<br />&copy; Berni Searle, courtesy Michael Stevenson Gallery, Cape Town, South Africa" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>About to forget</em> 2005<br/>3-channel projection, 35mm cinemascope film, DVD playback, colour, sound, 3:00<br/>Collection of the artist<br />&copy; Berni Searle, courtesy Michael Stevenson Gallery, Cape Town, South Africa"
			),
			new Array(
				"&nbsp;", 
				"<em>Half Light</em> 2004<br/>still from <em>Vapour</em> 2004<br/>single-channel projection, 16mm film, DVD playback, colour, sound, 6:00<br/>Collection of the artist<br />&copy; Berni Searle, courtesy Michael Stevenson Gallery, Cape Town, South Africa"
			),
			new Array(
				"&nbsp;",
				"from <em>Home and away</em> 2003<br/>2-channel projection, 16mm film, DVD playback, colour, sound, 6:00<br/>Commissioned by NMAC Montenmedio Arte Contemporaneo, Spain<br/>Collection of the artist<br />&copy; Berni Searle, courtesy Michael Stevenson Gallery, Cape Town, South Africa"
		)
		)
	),
		new Array("briangothongtan.html", new Array("01.Tan_instant_asia.jpg",
			"02.Tan_instant_asia.jpg",
			"03.Tan_instant_asia.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>Instant Asia!</em> 2004-05<br/>multi-channel installation, 16mm film, digital video, computer animation, DVD playback, colour, sound<br/>&copy; Brian Gothong Tan" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>Instant Asia!</em> 2004-05<br/>multi-channel installation, 16mm film, digital video, computer animation, DVD playback, colour, sound<br/>&copy; Brian Gothong Tan"
			),

			new Array(
				"&nbsp;",
				"from <em>Instant Asia!</em> 2004-05<br/>multi-channel installation, 16mm film, digital video, computer animation, DVD playback, colour, sound<br/>&copy; Brian Gothong Tan"
		)
		)
	),
		new Array("jemimawyman.html", new Array("01.wyman_earthquake.jpg",
			"02.wyman_daisies.jpg",
			"03.wyman_glow.jpg"
		),
		new Array(		new Array(
				"&nbsp;", // Title (italics)
				"from <em>Catastrophe theory: Earthquake Girl and other stories</em> 2005<br/>multi-channel, multimedia installation,<br/>Collection of the artist<br />&copy; Jemima Wyman, courtesy Bellas Milani Gallery, Brisbane, Australia" // Details
			),

			new Array(
				"&nbsp;", 
				"from <em>Catastrophe theory: Earthquake Girl and other stories</em> 2005<br/>multi-channel, multimedia installation,<br/>Collection of the artist<br />&copy; Jemima Wyman, courtesy Bellas Milani Gallery, Brisbane, Australia"
			),

			new Array(
				"&nbsp;",
				"from <em>Catastrophe theory: Earthquake Girl and other stories</em> 2005<br/>multi-channel, multimedia installation,<br/>Collection of the artist<br />&copy; Jemima Wyman, courtesy Bellas Milani Gallery, Brisbane, Australia"
		)
		)
	)
);

function next() {
	for ( var x = 0 ; x < artists.length ; x++ ) {
		if (artists[x][0] == artistURL) {
			if (artistCurrent == -1) {
				artistCurrent = 1;
			}
			else {
				if (artistCurrent == (artists[x][1].length-1)) {
					artistCurrent = 0;
				}
				else {
					artistCurrent++;
				}
			}
			
			objWorkImage.src = artistPath + artists[x][1][artistCurrent];
			//write(objWorkTitle, artists[x][2][artistCurrent][0]);
			write(objWorkDescription, artists[x][2][artistCurrent][1]);
			return;
		}
	}
}

function back() {
	for ( var x = 0 ; x < artists.length ; x++ ) {
		if (artists[x][0] == artistURL) {
			if (artistCurrent == -1) {
				artistCurrent = artists[x][1].length-1;
			}
			else {
				if (artistCurrent == 0) {
					artistCurrent = artists[x][1].length-1;
				}
				else {
					artistCurrent--;
				}
			}
			
			objWorkImage.src = artistPath + artists[x][1][artistCurrent];
			//write(objWorkTitle, artists[x][2][artistCurrent][0]);
			write(objWorkDescription, artists[x][2][artistCurrent][1]);
			return;
		}
	}
}

function preload() {
	for ( var x = 0 ; x < artists.length ; x++ ) {
		if (artists[x][0] == artistURL) {
			for ( var y = 0 ; y < artists[x][1].length ; y++ )
			{
				var objImage = new Image();
				objImage.src = artistPath + artists[x][1][y];
			}
		}
	}
}

function write(obj, text) {
	//if (document.all) {
		//alert('true');
		obj.innerHTML = text;
	//}
//	else {
	//	obj.textContent = text;
	//}
}

function init() {
	objWorkImage = document.getElementById('objWorkImage');
	//objWorkTitle = document.getElementById('objWorkTitle');
	objWorkDescription = document.getElementById('objWorkDescription');

	preload();
}

window.onload = init;

