function setActiveStylesheet(title) {
	linksFound = document.getElementsByTagName("link")
	for(i = 0; i < linksFound.length; i++) {
		thisLink = linksFound[i]
		if(thisLink.getAttribute("rel").indexOf("style") > -1 && thisLink.getAttribute("title")) {
			thisLink.disabled = true
			if(thisLink.getAttribute("title") == title) {
				thisLink.disabled = false
			}
		}
	}
}

function getActiveStylesheet() {
	linksFound = document.getElementByTagName("link")
	for(i = 0; i < linksFound.length; i++) {
		thisLink = linksFound[i]
		if(thislink.getAttribute("rel").indexOf("style") > -1 && thisLink.getAttribute("title") && !thisLink.disabled) {
			return thisLink.getAttribute("title")
		}
	}
}

function cookieVal(cookieName) {
	thisCookie = document.cookie.split("; ")
	for(i = 0; i < thisCookie.length; i++) {
		if(cookieName == thisCookie[i].split("=")[0]) {
			return thisCookie[i].split("=")[1]
		}
	}
}

function changeData() {
	fontArray = new Array("a","bmt","tnr")
	font = fontArray[document.styleForm.fontBox.selectedIndex]
	expireDate = new Date
	expireDate.setYear(expireDate.getYear() + 5)
	document.cookie = "style=" + font + "; expires=" + expireDate.toGMTString() + "; path=/;"
	setActiveStylesheet(font)
}

window.onload = function() {
	thisCookie = cookieVal("style")
	if(thisCookie) {
		title = thisCookie
	}
	else {
		title = "tnr"
	}
	setActiveStylesheet(title)	
}

window.onunload = function() {
	expireDate = new Date
	expireDate.setYear(expireDate.getYear() + 5)
	document.cookie = "expires=" + expireDate.toGMTString() + ";"
}
