function setSubCookie(cookieKey,subKey,subValue) {
	subValue = escape(subValue)
	if (document.cookie.indexOf(cookieKey) >= 0) {
		
		//get cookie
		var keyValuePairs = document.cookie.split("; ")
		for (var i=0; i < keyValuePairs.length; ++i) {
			var tempArray = keyValuePairs[i].split("=")
			if (tempArray[0] == cookieKey) {
				var theCookie = tempArray[1]
				break
			}
		}
		
		
		//get sub cookies
		var subKeyValuePairs = theCookie.split("&&")
		
		//update sub cookie
		for (var i=0; i < subKeyValuePairs.length; ++i) {
			var tempArray = subKeyValuePairs[i].split("::")
			if (tempArray[0] == subKey) {
				subKeyValuePairs[i] = tempArray[0] + "::" + subValue
				var newCookie = subKeyValuePairs.join("&&")
				document.cookie = cookieKey + "=" + newCookie
				return true
			}
		}
		
		//or, add sub cookie
		var newCookie = subKeyValuePairs.join("&&")
		document.cookie = cookieKey + "=" + newCookie + "&&" + subKey + "::" + subValue
		
	}
	else {
		document.cookie = cookieKey + "=" + subKey + "::" + subValue
		return true
	}
}





function retrieveSubCookie(cookieKey,cookieSubKey) {
	//Check for existence of cookie
	if (!document.cookie) {
		return false
	}


	//get cookie
	var keyValuePairs = document.cookie.split("; ")
	for (var i=0; i < keyValuePairs.length; ++i) {
		var tempArray = keyValuePairs[i].split("=")
		if (tempArray[0] == cookieKey) {
			var theCookie = tempArray[1]
			break
		}
	}
	
	//get sub cookie
	var subKeyValuePairs = theCookie.split("&&")
	for (var i=0; i < subKeyValuePairs.length; ++i) {
		var tempArray = subKeyValuePairs[i].split("::")
		if (tempArray[0] == cookieSubKey) {
			return unescape(tempArray[1])
		}
	}
	return false
}










function closeSW() {

	if (subW && !subW.closed) {
		subW.close()
	}
		
}


function resizeImgWin(i,w,h) {

	origWidth = eval("image" + i + ".sm_width")
	origHeight = eval("image" + i + ".sm_height")
	newWidth = origWidth
	newHeight = origHeight
	percent = 99
	
	while (newWidth > w || newHeight > h) {
		newWidth = parseInt(origWidth * percent * .01)
		newHeight = parseInt(origHeight * percent * .01)
		--percent
	}
	
	return "<A HREF='javascript: openSW(" + i + ")'><IMG SRC='" + eval("image" + i + ".small") + "' BORDER=0 WIDTH=" + newWidth + " HEIGHT=" + newHeight + " VSPACE=3></A>"
	
}








var subWin = ""

function showHint(URL,x,y) {
	var xLoc = (screen.availWidth - x) / 2
	var yLoc = (screen.availHeight - y) / 2
	subWin = open(URL,"sub","left=" + xLoc + ",top="  + yLoc + ",resizable=0,status=0,location=0,toolbars=0,scrollbars=1,menubar=0,width=" + x + ",height=" + y)
	subWin.focus()
	subWin.focus()
}



function closeIt() {
	if (subWin && !subWin.closed) {
		subWin.close()
	}
}



var subW = ""

function openSW(x) {
		
		subW = window.open("","view_window","left=0,top=0,scrollbars=yes,location=no,status=no,resizable=yes,toolbar=no,height=" + eval("image" + x + ".lg_height  + 40") + ",width=" + eval("image" + x + ".lg_width + 10"))
		
		subW.document.writeln("<HTML>")
		subW.document.writeln("<HEAD>")
		subW.document.writeln("<TITLE>Enlarged Image</TITLE>")
		subW.document.writeln("</HEAD>")
		subW.document.writeln("<BODY BGCOLOR=ffffff LEFTMARGIN=0 TOPMARGIN=0>")
		subW.document.writeln("<SPAN STYLE='position: absolute; left: 0px; top: 0px; z-index: 1'>")
		subW.document.writeln("<FORM>")
		subW.document.writeln("<INPUT TYPE=button VALUE='Close Window' onClick='window.close()'><BR><BR>")
		subW.document.writeln("<IMG SRC=" + eval("image" + x + ".large") + "><BR><BR>")
		subW.document.writeln("<INPUT TYPE=button VALUE='Close Window' onClick='window.close()'>")
		subW.document.writeln("</FORM>")
		subW.document.writeln("</SPAN>")
		subW.document.writeln("</BODY>")
		subW.document.writeln("</HTML>")
		subW.document.close()
		subW.focus()
		
}




function HTMLnewLine(theString) {
	
	var re1 = /\r\n/g
	var re2 = /\r/g
	var re3 = /\n/g
	
	theString = theString.replace(re1, "<BR>")
	theString = theString.replace(re2, "<BR>")
	theString = theString.replace(re3, "")

	return theString
	
}




function deHTMLnewLine(theString) {
	
	var re = /<BR>/g
	theString = theString.replace(re, "\r")
	return theString
	
}
