// get browser info
var browser = ""
var browsername = navigator.appName
var browserversion = parseInt(navigator.appVersion)
var ua = navigator.userAgent
if (browsername == "Netscape") {
    browser = "ns" + browserversion
} 
strURL = "http://" + document.location.hostname + document.location.pathname
// browser = "ns3"

// redirect ns3 users away to avoid errors
if (browser != "ns3") 
{
	// get querystring info
	strQS = location.search
	if (strQS != "") 
	{
		// delete first question mark
		if (strQS.charAt(0) == "?") strQS = strQS.substring(1,strQS.length)
		// divide into keys
		arrQS = strQS.split("&")
		// declare object to store keys/values
		objQS = new Object()
		// assign to key/value relationship
		for (z=0; z<arrQS.length; z++)
		{
			arrTemp = arrQS[z].split("=")
			objQS[arrTemp[0]] = arrTemp[1]
		}
	}
	
	// assign variables with lots of error-checking
	if (typeof objQS != "undefined") {
		// decide which set of images to show
		if (typeof objQS.array != "undefined") {
			arr = eval(objQS.array)
		} else {
			// default is me!
			arr = arrRussImages
			objQS.array = "arrRussImages"
		}
		// decide on photo number
		if (typeof objQS.photo != "undefined") {
			if ((objQS.photo >= 0) && (objQS.photo < arr.length)) {
				i = objQS.photo
			} else {
				i = 0
			}
		} else {
			i = 0
		}
	} else {
		i = 0
	}
}

function init()
{
}

function loadNewImage(dir)
{
	if(dir == "next") {
		if (arr.length -1 == i) {
			i = 0
		} else {
			i++
		}
	} else {
		if (i == 0) {
			i = arr.length - 1
		} else {
			i--
		}
	}
	// assemble the URL
	strURL += "?photo=" + i
	strURL += "&array=" + objQS.array
	// reload page with new info
	document.location.href = strURL
}

function changeImage(dir, arr, img)
{
	// can't use this function reliably since Netscape doesn't auto-change widths and heights.
	// also, since the page doesn't reload, hit counters would be inaccurate.
	if(dir == "next") {
		if (arr.length -1 == r) {
			r = 0
		} else {
			r++
		}
	} else {
		if (r == 0) {
			r = arr.length - 1
		} else {
			r--
		}
	}	
	img.src = strURL + arr[r][0]
	img.width = arr[r][1]
	img.height = arr[r][2]
}
