if (location.pathname.indexOf("gallery.html") >= 0) {
	categoryId = -1
	if (window.location.search) {
		requestVars = window.location.search.replace("?","")
		if (requestVars != "") { categoryId = requestVars }
	}
	//categoryId = (categoryId < categoryTitle.length)? categoryId : 0
}
imageFile = ""
imageIndex = ""
awardImageTitle = ""


function drawTable() {
	drawMenu()
	if (categoryId >= 0 && categoryId < categoryTitle.length) {
		counter=0
		htmlCode = ""
		htmlCode += "<div class=galleryHeader>" + categoryTitle[categoryId] + "</div>"
		htmlCode += "<table class='galleryTable' cellspacing=10 cellpadding=8 border=0>"
		for (x=0;x<dataArray.length;x++) {
			if (dataArray[x] && dataArray[x][0] == categoryId) {
				counter++
				if (counter == 1 || (counter-1)%3 == 0) htmlCode += "<tr>"
				htmlCode += "<td valign=top onclick='viewImage(" + x + ")' onmouseover='highLight(this)' onmouseout='unhighLight(this)'><div style='width:122'>"
				htmlCode += "<img src='gallery/" + dataArray[x][1] + "_th.jpg' width=120 height=90 border=0 alt='Click to enlarge' class=imageBorder><br>"
				htmlCode += "<b>" + dataArray[x][2] + "</b><br>" //TITLE
				if (dataArray[x][3]) htmlCode += dataArray[x][3] + "<br>" //LOCATION
				if (dataArray[x][4]) htmlCode += dataArray[x][4] + " " //YEAR
				htmlCode += "</div></td>"
				if (counter%3 == 0 || x+1 == dataArray.length) htmlCode += "</tr>"
			}
		}
		htmlCode += "</table><div id=contentLayer>"
		imageCount(counter)
	} else {
		htmlCode = '<div id=contentLayer>Select a category from the left menu to view Karen\'s work.<br><br>'
	}
	if (categoryId >= 0 && counter > 6) htmlCode += '<a href="#top">Back to top</a><br><br>'
	htmlCode += '<hr noshade color="#acacac" size=1>'
	htmlCode += '<span class=footnote1>Copyright &#169;2009 Karen Kaiser</span></div>'

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


function highLight(i,n) {
	i.style.backgroundColor = "#1f1f1f"
	i.style.cursor = "pointer"
	i.style.cursor = "hand"
}

function unhighLight(i,n) {
	i.style.backgroundColor = "transparent"
}

function viewImage(i, title) {
	if (!title) {
		imageIndex = i
		imageFile = "gallery/" + dataArray[i][1] + ".jpg"
	} else {
		imageFile = "images/" + i
		awardImageTitle = title
	}
	imageWindow = window.open("galleryWindow.html",'gallerywindow','width=710,height=730,toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes')
	imageWindow.focus()
}

function drawImage() {
	if (imageIndex) imageWindow.document.getElementById('galleryTitle').innerHTML = dataArray[imageIndex][2]
	if (awardImageTitle) imageWindow.document.getElementById('galleryTitle').innerHTML = awardImageTitle
	imageWindow.document.galleryImage.src = imageFile
}

function drawHeader(imageName) {
	nameArray = imageName.split(" ")
	nameArray[0] = nameArray[0].substring(0,1).toUpperCase() + nameArray[0].substring(1,nameArray[0].length)
	newName = nameArray.join(" ")
	document.getElementById('subHeaderLayer').innerHTML = '<img src="images/subheader_' + imageName + '.gif" width=200 height=50 alt="' + newName + '">'
}

function drawMenu() {
	menuHtml = ""
	for (x=0;x<categoryTitle.length;x++) {
		styleClass = (x == categoryId)? "subnavActive":"subnav"
		menuHtml += '<div style="margin-bottom:10px;"><img src="images/bullet-nav.gif" width=8 height=11 alt=""><a href="gallery.html?' + x + '" class=' + styleClass + '>' + categoryTitle[x] + '</a></div>'
	}
	document.getElementById('menuLayer').innerHTML = menuHtml
}

function drawMainNav() {
	navHtml = ""
	navHtml += '<a href="index.html">Home</a>|<a href="bio.html">Bio</a>|<a href="gallery.html">Gallery</a>|<a href="image-shop.html">Image Shop</a>|<a href="contact.html">Contact</a>'
	document.getElementById('mainNav').innerHTML = navHtml
	if (location.pathname == "/" || location.pathname.indexOf("index.html") >= 0) {
		document.getElementById('mainNavLayer').style.top = 359
		document.getElementById('mainNavLayer').style.left = 49
	}
	document.getElementById('mainNavLayer').style.display = "block"
}

function imageCount(z) {
	document.getElementById('imageCountLayer').innerHTML = "<span class=imageCaption>There are " + z + " images in this set</span>"
}


