if (top.location != location) top.location = location;

if (location.host != "localhost" && location.host != "chris.localdomain")
	window.onerror = function(){return true; }

d = document;

if (!d.getElementById){
	if (d.all) d.getElementById = function(id){if (d.all[id]) return d.all[id];	return false;};
	if (d.layers) d.getElementById = function(id,parentObj){
		if(d.layers[id]){
			d.layers[id].style = d.layers[id];
			d.layers[id].d = d.layers[id].document;
			return d.layers[id];
		}
		return false;
	};
}

function newsComments(id){
	open("comments.phtml?news=1&id="+id,"","width=500,height=400,scrollbars,status,resizable")
	}
	
function toggleIt(elm,name1,name2){
	if (elm.name == name1){
		if (elm.checked) elm.form[name2].checked = false;
		else elm.form[name2].checked = true;
	}
	else if (elm.name == name2){
		if (elm.checked) elm.form[name1].checked = false;
		else elm.form[name2].checked = true;
	}
}

function alterNate(elm){
	if (!elm.base) elm.base = elm.value
	if (elm.value == elm.base) elm.value = "";
	else if (elm.value == "") elm.value = elm.base;
}

function checkAll(elm,name){
  for (var i = 0; i < elm.form.elements.length; i++)
  	if (elm.form.elements[i].name.indexOf(name) == 0)
	    elm.form.elements[i].checked = elm.checked;
}

function init(){
	if (!d.getElementById) return;
	if (navigator.userAgent.indexOf("Mac") != -1)
		d.getElementById("cmenu").style.top = "0px";
	iface = new anarChaotic();
	var rand = Math.floor(Math.random() * 2);
	if (rand == 0) iface.css.top = "-800px";
	else iface.css.top = "800px";
	iface.slideIt();
}

function doMenu(){
	if (typeof(iface) == "undefined") iface = new anarChaotic();
	var rand = Math.floor(Math.random() * 2);
	if (rand == 0) iface.css.top = "-800px";
	else iface.css.top = "800px";
	iface.slideIt();
}

function anarChaotic(id){
	this.id = id || "cmenu";
	this.obj = "anarObj";
	eval(this.obj + " = this");

	this.css = d.getElementById(this.id).style;
	this.slideIt = function(){
		if (!this.timer) this.timer = setInterval(this.obj+".slideDown()",40);
	}
	
	this.slideDown = function(){
		if (parseInt(this.css.top) != 0){
			this.accel = parseInt(this.css.top)/7*-1;
			this.css.top = (parseInt(this.css.top) + this.accel) + "px";
			}
		else this.stop();
	}
	
	this.stop = function(){
		clearInterval(this.timer);
		delete this.timer;
	}
		
	return this;
}

function writeIt(id,text){
	if (d.getElementById && d.getElementById(id)){
		var l = d.getElementById(id);
		if (l.innerHTML) l.innerHTML = text;
		else {
			l.document.open();
			l.document.write(text);
			l.document.close();
		}
	}
}