addEvent(window,'load',popupSelection);
addEvent(window,'load',insertStylesMenu);
addEvent(window,'load',nameAndTripcode);

function nameAndTripcode()
{
	if(document.forms[0]) {
		var name = getCookie('name');
		if(name) {
			document.forms[0].name.value = name;
		}
		var tripcode = getCookie('tripcode');
		if(tripcode) {
			document.forms[0].tripcode.value = tripcode.replace("+"," ");
		}
	}
}

function popupSelection()
{
	if(document.forms[0]) {
		me = document.forms[0].useFrame;
		if(getCookie('useFrame') == "t") {
			me[1].checked = true;
		} else {
			me[0].checked = true;
		}
	}
}

function insertStylesMenu()
{

	// The select menu
	s = document.getElementById("stylesmenu");
	if(!s) {
		return;
	}
	current = getCookie('style');
	// Find all <link> and extract the stylesheets
	links = document.getElementsByTagName("link");
	for(i=0 ; l = links[i] ; i++) {
		if(l.getAttribute("rel").indexOf("style") != -1 && l.getAttribute("title")) {
			title = l.getAttribute('title');
			o = document.createElement("option");
			t = document.createTextNode(title);
			o.appendChild(t);
			o.setAttribute("value",title);
			if(title==current) {
				o.setAttribute("selected",true);
			}
			s.appendChild(o);
		}
	}
}

