if (parent.frames.length > 0) {
	parent.location.href = self.document.location;
}

count = 0;
enabled = 0;

function shout() {
	window.open("shoutbox.php","shoutbox","resizable=yes,status=yes,scrollbars=yes,width=300,height=500");
}

function archive() {
	window.open("shoutarchive.php","shoutbox","resizable=yes,status=yes,scrollbars=yes,width=500,height=500");
}

function snake() {
	window.open("snake.php","snake","resizable=yes,status=yes,scrollbars=yes,width=580,height=500");
}

function mouse() {
	window.open("mouse.php","mouse","resizable=yes,status=yes,scrollbars=yes,width=660,height=500");
}

function img(url) {
	window.open("image.php?view="+url,"image","resizable=yes,status=yes,scrollbars=yes,width=760,height=500");
}

function launch(id) {
	window.open(id);
}

function docount() {
	if (count < 1) { count++; }
	else { enabled++; }

	if (enabled > 1) {
		window.open("shoutedit.php","shoutbox","resizable=yes,status=yes,scrollbars=yes,width=300,height=460");
		enabled = 0;
		count = 0;
	}
}

function dest(obj) {
	id = obj.options[obj.selectedIndex].value;
	if (id != "") { location.href = id; }
}

function setstyle(title) {
	var i, a;
	for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
		if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
			a.disabled = true;
			if (a.getAttribute("title") == title) {
				a.disabled = false;
			}
		}
	}
}

function getactive() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return null;
}

function getpreferred() {
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title")) return a.getAttribute("title");
	}
	return null;
}

function createcookie(name, value, days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime() + (days*24*60*60*1000));
		var expires = "; expires=" + date.toGMTString();
	}
	else expires = "";
	document.cookie = name + "=" + value + expires + "; path=/";
}

function readcookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0; i < ca.length; i++) {
		var c = ca[i];
		while (c.charAt(0) == ' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
	}
	return null;
}

window.onload = function(e) {
	var cookie = readcookie("style");
	var title = cookie ? cookie : getpreferred();
	setstyle(title);
}

window.onunload = function(e) {
	var title = getactive();
	createcookie("style", title, 30);
}

var cookie = readcookie("style");
var title = cookie ? cookie : getpreferred();
setstyle(title);
