// JavaScript Document

var imgThumbArray = new Array();
var slideArray = new Array();
var slideIndex = 0;
var imgFolder = "../images/events/art_in_ch07/";
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_animal","brezina_lubo_animal_thumb","bench","laminated solid wood","lubo brezina",null,"studio junction","http://www.lubodesign.com","lubodesign",null,null,false);
slideArray[1] = new slideItem("eliuk_joy_cups","eliuk_joy_cups_thumb","cups","ceramic","joy eliuk",null,"studio junction","http://www.joypottery.com","joypottery.com",null,null,false);
slideArray[2] = new slideItem("eunson_scott_peanut","eunson_scott_peanut_thumb","peanut table","plywood","scott eunson",null,"studio junction","http://www.scotteunson.com","scott eunson",null,null,false);
slideArray[3] = new slideItem("krug_steve_chairs","krug_steve_chairs_thumb","chairs","digital prints","steve krug",null,"steve krug","http://www.krugfoto.com","krugfoto.com",null,null,false);
slideArray[4] = new slideItem("lamont_madeleine","lamont_madeleine_thumb","flowers",null,"madeleine lamont",null,"studio junction","http://www.madeleinelamont.com","madeleinelamont.com",null,null,false);
slideArray[5] = new slideItem("lee_fung_poles","lee_fung_poles_thumb","installation","metal poles","fung lee",null,"studio junction","http://www.pmalarch.ca","PMA Landscape Architects",null,null,false);
slideArray[6] = new slideItem("petrocco_lisa","petrocco_lisa_thumb","triptych","pigmented acrylic paint","petrocco_lisa",null,"studio junction","http://www.lisapetrocco.com","lisapetrocco.com",null,null,false);
slideArray[7] = new slideItem("wilcox_john","wilcox_john_thumb","installation","coloured & stained 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[8] = new slideItem("brezina_lubo_table","brezina_lubo_table_thumb",null,"reclaimed fir","lubo brezina",null,"studio junction","http://www.lubodesign.com","lubodesign",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;
}
