var art= new Array();
var currWork=0;
 

///////////////////////////////////////////////////////////////////////////
// 	FUNCTION: DISPLAYARTWORK - makes the div layout for the javascript app
// 	NOTES - Executed only once, when starting up the script. The links that goto different 
//			work are bolded.  Links that don't go anywhere are not bold.
//			
function displayArtwork(keyword, name) {
	artList(keyword);  
	//DISPLAY work
	document.write("<table width=100% cellpadding=0 cellspacing=0>");
	document.write("<tr><td width=50%>&nbsp;</td><td>&nbsp;</td>");
	if(name){
	document.write("<tr><td>&nbsp;</td><td><div id='artist'>"+art[currWork][0]+"</div></td>");
	} document.write("<tr><td>&nbsp;</td><td><div id='title'>"+art[currWork][1]+"</div></td>");
    document.write("<tr><td>&nbsp;</td><td><div id='year'>"+art[currWork][2]+"</div></td>");  
	document.write("<tr><td>&nbsp;</td><td><div id='medium'>"+art[currWork][3]+"</div></td>");
	document.write("<tr><td>&nbsp;</td><td><div id='dimensions'>"+art[currWork][4]+"</div></td>");
	document.write("<tr><td>&nbsp;</td><td><div id='price'>"+art[currWork][5]+"</div></td>");
  	var imgsrc="url("+art[currWork][6]+")";
	MM_changeProp('portfolio','','style.backgroundImage',imgsrc,'DIV');

	document.write("<tr><td>&nbsp;</td><td>&nbsp;</td>");
	//GOTO work by PREV & NEXT
	document.write("<tr><td>&nbsp;</td><td><div id='prev' style='float:left;'>< PREV&nbsp;</div>");
	document.write("<div id='close' style='float:left;'><strong><a href='javascript:return false;' onclick='window.close();'>| CLOSE |</a></strong></div>")
	if (art.length==1){document.write("<div id='next' style='float:left;'>&nbsp;NEXT ></div></td>")	
	} else {document.write("<div id='next' style='float:left;'><strong><a href='javascript:return false;' onclick='swap("+(currWork+1)+")'>&nbsp;NEXT ></a></strong></div></td>");																													
	}
	document.write("<tr><td>&nbsp;</td><td>&nbsp;</td>");

//GOTO work by number
	document.write("<tr><td>&nbsp;</td><td><div id='imglink0' style='float:left;'>&nbsp;1&nbsp;</div>");
	for (var x=1; x<art.length; x++) { 
      document.write("<div id='imglink"+x+"' style='float:left;'><strong><a href='javascript:return false;' onclick='swap("+x+")'>&nbsp;"+(x+1)+"&nbsp;</a></strong></div>");
	}
	document.write("</td></tr></table>");
}

///////////////////////////////////////////////////////////////////////////
// 	FUNCTION: SWAP - changes artwork information and images and updates the navigation
// 	NOTES - Executed onclicking the goto links. Updated links that goto different 
//			work are bolded.  Links that don't go anywhere are not bold.
//		
function swap(nextWork){
	currWork = nextWork;
	//UPDATE display work
	if(document.getElementById('artist')){
	document.getElementById('artist').innerHTML=art[currWork][0];
	}
	document.getElementById('title').innerHTML=art[currWork][1];
	document.getElementById('year').innerHTML=art[currWork][2];
	document.getElementById('medium').innerHTML=art[currWork][3];
	document.getElementById('dimensions').innerHTML=art[currWork][4];
	document.getElementById('price').innerHTML=art[currWork][5];
	var imgsrc="url("+art[currWork][6]+")";
	MM_changeProp('portfolio','','style.backgroundImage',imgsrc,'DIV');
	//UPDATE goto work by next & prev
	if(nextWork==0){document.getElementById('prev').innerHTML="< PREV&nbsp;";
	}else{document.getElementById('prev').innerHTML="<strong><a href='javascript:return false;' onclick='swap("+(currWork-1)+")'>< PREV&nbsp;</a></strong>";																														
	}
	if((nextWork+1)==art.length){document.getElementById('next').innerHTML="&nbsp;NEXT >";
	}else{document.getElementById('next').innerHTML="<strong><a href='javascript:return false;' onclick='swap("+(currWork+1)+")'>&nbsp;NEXT ></a></strong>";																														
	}	
	//UPDATE goto work by number
	for (var x=0; x<art.length; x++) { 
	 	if(x==currWork){
		document.getElementById('imglink'+x).innerHTML="&nbsp;"+(x+1)+"&nbsp;";
		}
		else{
      	document.getElementById('imglink'+x).innerHTML="<strong><a href='javascript:return false;' onclick='swap("+x+")'>&nbsp;"+(x+1)+"&nbsp;</a></strong>";
		}
	}

}

///////////////////////////////////////////////////////////////////////////
// 	FUNCTION: NOTEARTWORK - fills the art array with information
// 	TITLE, YEAR, MEDIUM, DIMENSIONS, IMGSRC - puts this information in the array
//	NOTES - Executed when the page opens. 
//	
function noteArtwork(artist, title, year, medium, dimensions, price, imgsrc) {
  var work = new Array();
  work[0] = artist;
  work[1] = title;
  work[2] = year;
  work[3] = medium;
  work[4] = dimensions;
  work[5] = price;
  work[6] = imgsrc;
  art[art.length] = work;
}


