// JavaScript Document

var imgThumbArray = new Array();
var slideArray = new Array();
var slideIndex = 0;
var imgFolder = "../images/events/art_in_ch08/";
var ext = ".jpg";

//                  slideItem(fileName,thumbName,title,artist 1,artist 2,photo credits,website 1, webname 1, website 2, webname 2, no caption boolean)
slideArray[0] = new slideItem("brezina_lubo_bench","brezina_lubo_bench_thumb","bench","reclaimed wood","LUBO",null,"studio junction","http://www.lubodesign.com","lubo design",null,null,false);
slideArray[1] = new slideItem("coe&waito_wejsmann_andree_ladders","coe&waito_wejsmann_andree_ladders_thumb","ladders","porcelain","coe&waito","andrée wejsmann","studio junction","http://www.coe&waito.com","coe&waito","http://www.softdogstudios.ca","soft dog studios",false);
slideArray[2] = new slideItem("coe&waito_wejsmann_andree_towers","coe&waito_wejsmann_andree_towers_thumb","radio towers","porcelain","coe&waito","andrée wejsmann","studio junction","http://www.coe&waito.com","coe&waito","http://www.softdogstudios.ca","soft dog studios",false);
slideArray[3] = new slideItem("dunkley_joel","dunkley_joel_thumb","bench","cast concrete & fir","joel dunkley",null,"studio junction","mailto: joel_dunkley@hotmail.com","e: joel dunkley",null,null,false);
slideArray[4] = new slideItem("eunson_scott","eunson_scott_thumb","installation","formica sheets","scott eunson",null,"studio junction","http://www.scotteunson.com","scotteunson.com",null,null,false);
slideArray[5] = new slideItem("harasym_anna_mobile","harasym_anna_mobile_thumb","mobile","transparencies","anna harasym",null,"anna harasym, studio junction","http://www.annaharasym.com","annaharasym.com",null,null,false);
slideArray[6] = new slideItem("kendall_steve","kendall_steve_thumb","southeast asia","prints","steve kendall",null,"steve kendall","mailto: steve.kendall@gmail.com","e: steve kendall",null,null,false);
slideArray[7] = new slideItem("mastrandrea_andrea_bread","mastrandrea_andrea_bread_thumb","installation","bread","andrea mastrandrea",null,"studio junction","http://www.paperspacestudio.com","PAPERspace studio",null,null,false);
slideArray[8] = new slideItem("mcmaster_clayton","mcmaster_clayton_thumb","installation","bent wood","clayton mcmaster",null,"studio junction","http://www.claytonmcmaster.com","claytonmcmaster.com",null,null,false);
slideArray[9] = new slideItem("pineda-willis_pablo_chair","pineda-willis_pablo_chair_thumb","chair","solid wood","pablo pineda-willis",null,"studio junction","http://www.pablopinedawillis.com","pablopinedawillis.com",null,null,false);
slideArray[10] = new slideItem("rao_liming","rao_liming_thumb","bowls","paper","liming rao",null,"studio junction","http://www.studiolimingrao.com","studio liming rao",null,null,false);
slideArray[11] = new slideItem("stead_lindsay","stead_lindsay_thumb","table","bent plywood","lindsay stead",null,"studio junction","mailto: lindsay.stead@gmail.com","e: lindsay stead",null,null,false);
slideArray[12] = new slideItem("stewart_penelope_fallentree","stewart_penelope_fallentree_thumb","fallen tree",null,"penelope stewart",null,"penelope stewart","http://www.penelopestewart.com","penelopestewart.com",null,null,false);
slideArray[13] = new slideItem("tippin_steve","tippin_steve_thumb","glass installation","glass","steve tippin",null,"studio junction","http://www.stevetippin.com","stevetippin.com",null,null,false);
slideArray[14] = new slideItem("waller_andrew_nfld","waller_andrew_nfld_thumb","nfld","digital print","andrew waller",null,"andrew waller","http://www.andrewwaller.com","andrewwaller.com",null,null,false);
slideArray[15] = new slideItem("weich_kate_triptych","weich_kate_triptych_thumb","triptych","mixed media","kathleen weich",null,"studio junction","http://www.kathleenweich.com","kathleenweich.com",null,null,false);
slideArray[16] = new slideItem("wilcox_john","wilcox_john_thumb","lightwell installation","fused glass","john wilcox",null,"studio junction","http://www.vitreous.ca","vitreous glassworks",null,null,false);
//aux. slides---leave title as null to insert photo into rotation without writing thumbnail
slideArray[17] = new slideItem("pineda-willis_pablo_bench",null,null,"reclaimed furniture","pablo pineda-willis",null,"studio junction","http://www.pablopinedawillis.com","pablopinedawillis.com",null,null,false);
slideArray[18] = new slideItem("brezina_lubo_stools","brezina_lubo_stools_thumb",null,"reclaimed wood","LUBO",null,"studio junction","http://www.lubodesign.com","lubo design",null,null,false);

function slideItem(fileName,thumbName,title,material,artist1,artist2,photo,web1,wName1,web2,wName2,noCap)
{
	this.fileName = fileName + ext;
	this.thumbName = thumbName + ext;
	this.title = title;
	this.material = material
	this.artist1 = artist1;
	this.artist2 = artist2;
	this.photo = photo;
	this.web1 = web1;
	this.wName1 = wName1;
	this.web2 = web2;
	this.wName2= wName2;
	this.noCap = noCap;
}

function writeSlideShow(container)
{
	var mHTML = "";
	var oddCount = 0;
	
	for (i=0;i<slideArray.length;i++)
	{
		if (slideArray[i].title != null && !(slideArray[i].noCap))
		{
			if (slideArray[i].artist2 != null)
			{
				mHTML += '<li><a href="#" onclick="this.blur(); showSlideImg(' + i + ')"><img src="'
				+ imgFolder + slideArray[i].thumbName +
				'" class="thumbnailArt" /></a><p>'
				+ slideArray[i].artist1 + ' + ' + slideArray[i].artist2 +
				'</p><a href="'
				+ slideArray[i].web1 + '" target="_blank">' + slideArray[i].wName1 + '</a>';
				
				if (slideArray[i].web2 != null)
				{
					mHTML += ' :: <a href="'
					+ slideArray[i].web2 + '" target="_blank">' + slideArray[i].wName2 + '</a>';
				}
				mHTML += '</li>';
			}
			else
			{
				mHTML += '<li><a href="#" onclick="this.blur(); showSlideImg(' + i + ')"><img src="'
				+ imgFolder + slideArray[i].thumbName +
				'" class="thumbnailArt" /></a><p>'
				+ slideArray[i].artist1 +
				'</p><a href="'
				+ slideArray[i].web1 + '" target="_blank">' + slideArray[i].wName1 + '</a></li>';
			}

		}
/*		else
		{
		mHTML += '<li><a href="#" onclick="this.blur(); showSlideImg(' + i + ')"><img src="'
		+ imgFolder + slideArray[i].thumbName +
		'" class="thumbnailArt" /></a><p>&nbsp;</p></li>';
		}
*/	}
	
	if (Math.round(oddCount/2) != oddCount/2)
	{
		mHTML += '<li class="lastRowSpacer"><a href="#" onclick="this.blur(); "><img src="'
		+ imgFolder + slideArray[0].thumbName +
		'" class="thumbnailArt" /></a>&nbsp;<br /><br /><br /></li>';
	}
	
	document.getElementById(container).innerHTML = mHTML;
}

function showSlideImg(index)
{
	var mHTML = genCaption(index,mHTML);
		
	document.getElementById("slideImg").src = imgFolder+slideArray[index].fileName;
	document.getElementById("imgCap").innerHTML = mHTML;

return true;
}

function shuffleImg()
{
	var i=Math.round(Math.random( ) * (slideArray.length-1));
	var mHTML = genCaption(i,mHTML);
	document.getElementById("slideImg").src = imgFolder+slideArray[i].fileName;
	document.getElementById("imgCap").innerHTML = mHTML;
	
	return true;
}

function genCaption(index,mHTML)
{
	mHTML = "<table>";
	if (slideArray[index].artist1 != null)
	{
		mHTML +=
		"<tr><td>artist : &nbsp;</td><td>" 
		+ slideArray[index].artist1;
		if (slideArray[index].artist2 != null)
		{
			mHTML +=
			" + " + slideArray[index].artist2 ;
		}
	}
		
	if (slideArray[index].photo != null)
	{
		mHTML += 
		"</td></tr><tr><td>photo : &nbsp;</td><td>" 
		+ slideArray[index].photo;
	}

	mHTML += "</td></tr></table>";
	
	
	return mHTML;
}