requestVars = location.search.replace("?","")
category = medium = ""
if (requestVars != "") { parseVar = requestVars.split(","); medium = parseVar[1]; category = parseVar[0] }

//CATEGORY
//	0	Still Life
//	1	Landscape
//	2	Habitat
//	3	Floral
//	4	Figure
//	5	Italy: Light & Color

//MEDIUM
//	0	Oil
//	1	Watercolor
//	2	Drawings
//	3	Monoprint

mediumArray = new Array("Oils","Watercolor","Drawings","Monoprint")
categoryArray = new Array("Still Life","Landscape","Habitat","Floral","Figure","Italy: Light &amp; Color")
catOrder = new Array(5,1,0,2,3,4)

itemSort = new Array()
artFile = ""


function sortItems() {
	for(x=0;x<dataArray.length;x++) {
			// itemArray[0] = [0,1,2]
			// itemArray[0][0] = [22,34,100]
		
		if (!itemSort[dataArray[x][2]]) itemSort[dataArray[x][2]] = [dataArray[x][1]]

		if (!itemSort[dataArray[x][2]][dataArray[x][1]]) {
			itemSort[dataArray[x][2]][dataArray[x][1]] = [x]
		} else {
			v = itemSort[dataArray[x][2]][dataArray[x][1]].length
			itemSort[dataArray[x][2]][dataArray[x][1]][v] = [x]
		}
	}
		//alert(itemSort[1])
}



function drawNav() {
	sortItems()
	navCode = ""
	
	for (x=0; x<categoryArray.length; x++) {
	//alert(itemSort[0].length)
		if (itemSort[catOrder[x]] && itemSort[catOrder[x]].length > 0) navCode += "<span class=navHeader>" + categoryArray[catOrder[x]].toUpperCase() + "</span><br>\n"

		for (y=0; y<mediumArray.length; y++) {
		
			if (itemSort[catOrder[x]] && itemSort[catOrder[x]][y] && itemSort[catOrder[x]][y].length > 0) {
				dummy = (medium != "" && y == medium && category != "" && catOrder[x] == category)? navCode += "<span class=navSel>" : navCode += "<a href='gallery.html?" + catOrder[x] + "," + y + "' class=navDef>"
				navCode += "<img src='images/bullet1.gif' width=9 height=11 border=0 alt=''>" + mediumArray[y].toUpperCase()
				dummy = (medium != "" && y == medium && category != "" && catOrder[x] == category)? navCode += "</span><br>\n" : navCode += "</a><br>\n"
			}
		}

		navCode += "<br>"

	}
	document.getElementById('navLayer').innerHTML = navCode

}



function drawTable() {
	if (category!="" && medium!="") {
		counter=0
		htmlCode = 'Click on a thumbnail to view the complete image.<br>'
		//if (navigator.userAgent.indexOf('AOL') >= 0) document.write('<span class=footnote1>Warning: Your AOL browser may prevent you from viewing the larger versions of these images.  Please open Internet Explorer or another browser to fully enjoy this site.</span><br><br>')
		htmlCode += "<table class='galleryTable'>\n"
		for (row in dataArray) {
			if (dataArray[row][2] == category && dataArray[row][1] == medium) {
				counter++
				if (counter == 1 || (counter-1)%3 == 0) htmlCode += "\t<tr>\n"
				htmlCode += "\t\t<td valign=top class='artCell' onclick='viewArt(" + row + ")' onmouseover='highLight(this)' onmouseout='unhighLight(this)'>"
				htmlCode += "<img src='art/" + dataArray[row][8] + "' width=120 height=90 border=0 alt='" + dataArray[row][0] + "'><br>\t"
				htmlCode += "<b>" + dataArray[row][0] + "</b><br>" //NAME
				if (dataArray[row][4]) htmlCode += dataArray[row][4] + "in. " //CANVAS SIZE
				if (dataArray[row][5]) htmlCode += "(" + dataArray[row][5] + ")" //FRAME SIZE
				if (dataArray[row][4] || dataArray[row][5]) htmlCode += "<br>"
				if (dataArray[row][6] && dataArray[row][6] == "Sold") htmlCode += dataArray[row][6] + " " //PRICE
				if (dataArray[row][3] && dataArray[row][6] != "Sold") htmlCode += dataArray[row][3] //FRAMED
				htmlCode += "</td>\n"
				if (counter%3 == 0 || x+1 == dataArray.length) htmlCode += "\t</tr>\n"
			}
		}
		htmlCode += "<table>\n"
		htmlCode += '<br><span class=footnote1>Note: Frame or mat sizes are in parentheses.  Sizes are accurate to within .5in.</span>'

	} else {
		htmlCode = 'Select a category from the left menu to view Cindi\'s work.<br><br>'
	}
	htmlCode += '<hr noshade color="#e3e7e8" size=1>'
	htmlCode += '<span class=footnote2>Copyright &#169;2010 Cynthia Lewis.  <a href="javascript:disclaimer()">Disclaimers</a><br>'
	htmlCode += 'Site designed by <a href="http://www.shermanvision.com/" target=_blank>ShermanVision</a>.</span><br><br>'

	document.getElementById('contentLayer').innerHTML = htmlCode
}


function highLight(i,n) {
	i.style.backgroundColor = "#e4f2f8"
	i.style.cursor = "pointer"
	i.style.cursor = "hand"
}
		
function unhighLight(i,n) {
	i.style.backgroundColor = "transparent"
}

function viewArt(i) {
	artFile = "art/" + dataArray[i][7]
	artWindow = window.open("galleryPH.html",'gallerywindow','width=700,height=570,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes')
	artWindow.resizeTo(700,570)
	artWindow.focus()
}
function drawPainting() {
	artWindow.document.artImage.src = artFile
}
		
function drawHeader() {
	document.write('<img src="images/header-page_gallery' + category + '.gif" width=600 height=53 alt="Gallery">')
}

