var picindex = 1;
var ind = -1;
  // Array that tells you how many pictures this piece of art has
  	var pictureCount = new Array();
	pictureCount[1] = 2;
	pictureCount[2] = 3;
	pictureCount[3] = 7;
	pictureCount[4] = 2;
	pictureCount[5] = 4;
	pictureCount[6] = 4;
	pictureCount[7] = 2;
	pictureCount[8] = 2;
	pictureCount[9] = 2;
	pictureCount[10] = 4;
	pictureCount[11] = 4;
	pictureCount[12] = 5;
	pictureCount[13] = 2;
	pictureCount[14] = 3;
	pictureCount[15] = 3;
	pictureCount[16] = 3;
	pictureCount[17] = 3;
	pictureCount[18] = 1;
	pictureCount[19] = 1;
	
	var pictures = new Array();
		
	
function getobj(id) {
      return document.getElementById ? document.getElementById(id) : document.all[id];
}

function urlParse() {
	var urlquery = location.href.split("?");
	var url_param = new Array();
	if (urlquery.length > 1) {
		url_param = urlquery[1].split("&");
	}
	
	return url_param;
}



// Figure out which VR tour to use
function getEmbed() {
	var url_param = urlParse();

  // adding the or "amp" thing in the javascript was quicker and easier than fixing the panos
	if (url_param.length > 0) {
		if (url_param[0] == "end" || url_param[0] == "amp;end") {
			document.write("<embed id=\"tour\" src=\"end.mov\">");
		}
		else if (url_param[0] == "middle" || url_param[0] == "amp;middle") {
			document.write("<embed id=\"tour\" src=\"middle.mov\">");
		}
		else {
		  document.write("<embed id=\"tour\" src=\"entrance.mov\">");
		}
	}
	else {
		document.write("<embed id=\"tour\" src=\"entrance.mov\">");
	}
}


// Writes out the code for the map at the left of the screen
function navmap() {
	document.write("<img src=\"map.gif\" usemap=\"#mapmap\" style=\"border:0\" />");
	document.write("<map name=\"mapmap\">");
	document.write("<area coords=\"44,239,13\" shape=\"circle\" href=\"index.html\" alt=\"01\">");
	document.write("<area coords=\"34,185,14\" shape=\"circle\" href=\"index.html?middle\" alt=\"02\">");
	document.write("<area coords=\"43,133,13\" shape=\"circle\" href=\"index.html?end\" alt=\"03\">");
	document.write("</map><br />");
}

function loadData() {
  var url_param = urlParse();
  

  
  // Put statements for pictures here! Make sure to escape quote marks like this: \"hello\"
	var statements = new Array();
	statements[1] = "<div style=\"width: 260px; padding: 5px;\">JON PETRO<br>1501<br>2006<br>acrylic on canvas<br></div>";
	statements[2] = "<div style=\"width: 260px; padding: 5px;\">JON PETRO<br>Human is the Hardest Thing<br>2006<br>acrylic on canvas</div>";
	statements[3] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Canoe<br>2003<br>Yellow Pipes - Polyethelyne tubing<br>105 x 8\"</div>";
	statements[4] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Lifelines<br>2003<br>Yellow Pipes - Polyethelyne tubing<br>114 x 6\"</div>";
	statements[5] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Hairpipe<br>2004<br>Yellow Pipes - Polyethelyne tubing<br>111 x 6\"</div>";
	statements[6] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Inside Out<br>2006<br>Yellow Pipes - Polyethelyne tubing<br>24 x 6\"</div>";
	statements[7] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Split End<br>2006<br>Yellow Pipes - Polyethelyne tubing<br>10 x 6\"</div>";
	statements[8] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Bend<br>2006<br>Yellow Pipes - Polyethelyne tubing<br>32 x 6\"</div>";
	statements[9] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Well ?<br>2005-2006<br>Hemlock, pigmented glue, mylar<br>92 x 24\"</div>";
	statements[10] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Fish Eye<br>2006<br>Domed mirror, flexible duct, wire and wood<br>22 x 34\"</div>";
	statements[11] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Untitled<br>2006<br>\#2 Pine, zip ties</div>";
	statements[12] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Untitled<br>2006<br>\#2 Pine, tripod</div>";
	statements[13] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Untitled<br>2006<br>\#2 Pine, zip ties</div>";
	statements[14] = "<div style=\"width: 260px; padding: 5px;\">TIM MURDOCH<br>Aperture 2<br>2006<br>\#2 Pine, lenses, mirror</div>";
	statements[15] = "<div style=\"width: 260px; padding: 5px;\">JON PETRO<br>Portland<br>2006<br>acrylic on canvas</div>";
	statements[16] = "<div style=\"width: 260px; padding: 5px;\">JON PETRO<br>The Theory of Everythign<br>2006<br>acrylic on canvas</div>";
	statements[17] = "<div style=\"width: 260px; padding: 5px;\">JON PETRO<br>You've Got Yours<br>2006<br>acrylic on canvas</div>";

  
  // artist pages.. might as well use the same array
  statements[18]= "<h1>Jon Petro</h1>";
  statements[18]+= "<p>www.jonpetro.com</p>";

  statements[18]+= "<p><b>Disassociation: </b></p>";
  statements[18]+= "<p>Over the years that I have invested in the act of painting, I've come to understand some things about my own artistic process. The first is that my mind's visual archive is ruthlessly storing images every moment I am conscious. The second is that I need to have a dialog with all of this information, both artistically and emotionally. Humans innately develop associations with images all the time. As a painter one begins to develop a personal dialog for one's own visual syntax, and soon it becomes the foundation of one's artistic expression. I have painted many ideas and in many different styles; all of which reflect my need to grow and transcend through the artistic experience itself. </p>";
  statements[18]+= "<p>I am now, in a very real sense, working backwards; trying to remove all association with those images that I've maintained a dialog with for years. This concept isn't new or original; it's a reversal of the method that I've used to create art since I started to paint. Disassociation is often confused with the idea of deconstruction. I am not destroying the image per se; I am merely trying to disassociate myself from the ideas of what I originally believed these images to be.</p>";
  statements[18]+= "<p>Abstract imagery has no direct association with anything other than itself. It has a greater connection to the gesture or movement that the painter used to create it. The only logic association a viewer could make would be to another painting from the same painter or a period in Art history.  In effect, painting in this manner has enabled me to remove any visual association I might have had to the painting I've completed previously. I have no real association with this new visual dialog; it becomes something that did not exist prior to its being painted. </p>";

  statements[19] = "<h1>Tim Murdoch</h1>";
  statements[19]+= "<p>Questions. I ask a lot of questions. There was a time when I thought that my art should answer questions, but whatever inferences were gained inevitably led to more questions. This conundrum is the basis of my approach to creating forms that cause the viewer to think about relationships between objects and the space they occupy.</p>";
  statements[19]+= "<p>What makes something art? Why does the front of the painting have to be the side you show the viewer? Why not the back? A professor of mine once said to me, \"You know, the real part of a painting is the edge\" to which I responded with a series of paintings that hung with their edge facing out, I thought that it would make my paintings more tangible.</p>";
  statements[19]+= "<p>My work is constructed using various methods of fabrication coming from my experience as a cabinet maker and carpenter. I wasn't being flippant when I posed the question of back and front. When I am constructing something there is no difference between 'Tim' the carpenter and 'Tim' the artist. However, sometimes the necessity used to create a structure is more honest that the trickery used to make what appears to be art.</p>";
  statements[19]+= "<p>My art is the meeting point between my mind and my hands. I work using a broad range of materials; plywood, framing guide lumber, polyethylene tubing, gypsum panels and oil paint. The physical presence of the material is an important aspect of my work. I often use materials that originated from nature and restore them to an organic form, such as dimensional lumber and the tree from which they were cut. I like to juxtapose the physicality against an illusionary background. A structure against a picture plane, for instance, or a sharp edge against a colored reflection. I am constantly questioning what is there and what is not, what is substance and what is space.</p>";
  statements[19]+= "<p>What exists in the space between things, between the art object and the walls, between the viewer and the art? What separates us from the world? From other people? Is this space real or imagined? Ask most people and the space is a real distance, ask a physicist or a philosopher and the space becomes less space and more substance and perception, my work negotiates the boundaries between the art object and the environment, as well as the boundary between what is intentional and what is incidental.</p>";
  statements[19]+= "<p>Tim Murdoch</p>";

	var str = url_param[0];
	str = str.substring(0, str.length - 1);
	url_param[0] = str;

	getobj("description").innerHTML = statements[url_param[0]] + "<p><a style=\"float: left\" id=\"back_link\" href=\"index.html\"></a></p>";

	ind = parseInt(url_param[0]);
		
	// Change 9 to 09 so the right files are grabbed
	if (url_param[0] < 10) {
		url_param[0] = "0" + url_param[0];
	}
	
	
	// It just uses url_param as is, without checking it, but I don't think
	// we have to worry about injection attacks here...

	for (var i = 1; i < pictureCount[ind] + 1; i++) {
		pictures[i] = new Image();
		
		pictures[i].src = 'pics/' + url_param[0] + '_' + i + '.jpg';
	}	

	
	pictures[1].setAttribute("onLoad", "centerPicture();");	
	
	getobj('main_image').src = pictures[1].src;
	
	switch (ind) {
		case 18: getobj("main_link").href = "pics.html?2#"; break;
		case 19: getobj("main_link").href = "pics.html?6#"; break;
		default: getobj("main_link").href = pictures[picindex].src;
		
	}
	
	if (pictureCount[ind] > 1) {
		getobj("controls").innerHTML = "<a href=\"#\" onClick=\"prevPicture()\">&lt;&lt;</a> " + picindex + 
			 " out of " + pictureCount[ind] + " <a href=\"#\" onClick=\"nextPicture()\">&gt; &gt;</a>";
	}

}

function nextPicture() {
	picindex++;
	if (picindex > pictureCount[ind]) 
	{
		picindex = 1;

	}

	centerPicture();
	getobj('main_image').src = pictures[picindex].src;
	getobj('main_link').href = pictures[picindex].src;
	if (pictureCount[ind] > 1) {	
		getobj("controls").innerHTML = "<a href=\"#\" onClick=\"prevPicture()\">&lt;&lt;</a> " + picindex + 
			 " out of " + pictureCount[ind] + " <a href=\"#\" onClick=\"nextPicture()\">&gt; &gt;</a>";
	}
}

function prevPicture() {
	picindex--;
	if (picindex < 1) 
	{
		picindex = pictureCount[ind];

	}

	centerPicture();
	getobj('main_image').src = pictures[picindex].src;
	getobj('main_link').href = pictures[picindex].src;
	if (pictureCount[ind] > 1) {
		getobj("controls").innerHTML = "<a href=\"#\" onClick=\"prevPicture()\">&lt;&lt;</a> " + picindex + 
			 " out of " + pictureCount[ind] + " <a href=\"#\" onClick=\"nextPicture()\">&gt; &gt;</a>";
	}
}

function centerPicture() {
	getobj('image_holder').style.width = pictures[picindex].width;
	var margin = (360 - pictures[picindex].width*360/640)/2;
	getobj('image_holder').style.marginLeft= '' + margin + 'px';
}


