	function node_getLeft(td) {
		var left = td.offsetLeft;
		var el = td;
		while (el = el.offsetParent) left += el.offsetLeft;
		return left;
	}
	function node_getTop(td) {
		var top = td.offsetTop;
		var el = td;
		while (el = el.offsetParent) top += el.offsetTop;
		return top;
	}
	// This will get the position of the specified element.  For text, this will return the
	// position of the first character, and not the top left bounds if the text wraps.
	function getNodePos(el) {
		if (!el) return { x:0, y:0 };
		var pos = { x:el.offsetLeft, y:el.offsetTop }
		for (var parent = el.offsetParent; parent != null; parent = parent.offsetParent) {
			pos.x += parent.offsetLeft;
			pos.y += parent.offsetTop;
		}
		return pos;
	}

	function set_cookie(name, value, expires) {
		if (!expires) expires = new Date();
		document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() +  "; path=/";
	}
	function ShowHide(img,branch,store) {
		var objbranch = document.getElementById(branch).style;
		if (objbranch.display=="none") {
			objbranch.display = "";
			document.images[img].src = img_collapse_url;
			if (store) {
				expires = new Date();
				expires.setTime(expires.getTime() + (1000 * 86400 * 365));
				set_cookie(branch, '', expires);
			}
		} else {
			objbranch.display = "none";
			document.images[img].src = img_expand_url;
			if (store) {
				expires = new Date();
				expires.setTime(expires.getTime() + (1000 * 86400 * 365));
				set_cookie(branch, 'hidden', expires);
			}
		}
	}

	function OpenMapRating(mapidx) {
		window.open("?mod=mapinfo&action=maprating&idx="+mapidx+"", "moo", "toolbar=no,scrollbars=no,resizable=yes,width=220,height=135");
	}
	function OnlineHelp(section) {
		window.open("?mod=onlinehelp&section="+section, "sl.help", "toolbar=no,scrollbars=yes,resizable=yes,width=320,height=385");
	}
	function whoarethefans(plidx) {
		window.open("?mod=playerinfo&idx="+plidx+"&action=whoarethefans", "moo", "toolbar=no,scrollbars=yes,resizable=yes,width=310,height=365");
	}
	function EditLangKey(key,sec) {
		sec = sec==null ? "" : "&sec="+sec;
		window.open("?mod=admin-langkeys-popup&key="+encodeURIComponent(key)+sec, "edit language key", "toolbar=no,scrollbars=yes,resizable=yes,width=500,height=555");
	}
	function BuildTeamspeakLink(ip,name,channel) {
		if (!name) {
			name= prompt('Enter your teamspeak name', 'sl.Guest');
		}
		if (!name) return;
		var password;		
		var i = ip.indexOf('@');
		if (i>0) {
			password = ip.slice(0,i);
			ip = ip.slice(i+1);
		}
		link = 'teamspeak://'+ip+'/?nickname='+name;
		if (channel) link = link+'?channel='+channel;
		if (password) link = link+'?password='+password;
		window.location.href = link;
	}
	
	function SetFormValue(form,name,value) {
		document.forms[form].elements[name].value = value;
	}

	function ConfirmUrl(msg,urlparams) {
		if (confirm(msg)) return location.href  = location.protocol+'//'+location.host+location.pathname+urlparams;
		return;
	}

	function itemchosen(content) {
		top.opener.ifield.value = content;
		top.close();
	}


	// Notebook-Scripts (c) sl.Proddi
	function tm_click_tab(prefix,page) {
		for (i=1;i<=100;i++) {
			var pageobj = document.getElementById(prefix+"_page_"+i);
			var tabobj = document.getElementById(prefix+"_tab_"+i);
			if (!pageobj || !tabobj) continue;
			tabobj.className = (i==page ? "selected" : "");
			pageobj.style.display = (i==page ? "" : "none");
		}
	}
	// 3Choice-Script (c) sl.Proddi
	function sl_click_3choice(obj,labid,y,n,w) {
		if (!obj) return;
		hiddenobj = document.getElementById(obj.id+"_3c");
		if (!hiddenobj) return;
		if (hiddenobj.value>0) {
			hiddenobj.value = -1;
			obj.className = "no_3c";
			sl_set_label(labid,n);
		} else if (hiddenobj.value<0) {
			hiddenobj.value = 0;
			obj.className = "none_3c";
			sl_set_label(labid,w);
		} else {
			hiddenobj.value = 1;
			obj.className = "yes_3c";
			sl_set_label(labid,y);
		}
	}
	function sl_set_label(id,content) {
		labobj = document.getElementById(id);
		if (!labobj) return;
		labobj.innerHTML = content;
	}
	// Checkbox-Script (c) sl.Proddi
	function sl_click_checkbox(obj,showhide) {
		if (!obj) return false;
		inputobj = document.getElementById(obj.id+"_cb");
		if (!inputobj) return false;
		inputobj.value = (inputobj.value != "") ? "" : "checked";
		obj.className = (inputobj.value != "") ? "checked" : "unchecked";
		if (showhide) showhide.style.display = (inputobj.value != "") ? "" : "none";
		return false;
	}
	// Image resize function (c) sl.Proddi
	function sl_image_maxsize(id, limX,limY) {
		var obj = document.getElementById(id);
		if (!obj) return;
		obj.onload = function() {
			var imX = obj.width;
			var imY = obj.height;
			var imScal = Math.max(1,imX/limX,imY/limY);
			obj.width = Math.round(imX/imScal);
			obj.height = Math.round(imY/imScal);
		}
	}
	// Vote-Functions (c) sl.Proddi
	function sl_mr(id,imgurl,comment) {
		var img = document.getElementById(id);
		if (!img) return;
		img.src = imgurl;
		var lab = document.getElementById(id+"_lab");
		if (!lab) return;
		lab.innerHTML = comment;
	}

	function why_gads(URL) {
		day = new Date();
		id = day.getTime();
		eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=160,left = 590,top = 112');");
	}
	function sl_countdown(Secs,Id) {
	    var Sec = Secs;
	    var Min = 0;
	    if (Sec>=60) {
		var Min = Math.max(0,Math.floor(Sec/60));
		Sec = Math.max(0,Sec-Min*60);
	    }
	    if (Min<10) Min = '0'+Min;
	    if (Sec<10) Sec = '0'+Sec;
	    Secs--;
	    document.getElementById(Id).innerHTML = Min+':'+Sec;
	    if (Secs>=0) window.setTimeout("sl_countdown("+Secs+",'"+Id+"')", 1000);
	}

	// xml-functions (c) sl.Proddi
	function XMLLoad(url,destobj) {
		if (!destobj) return;
		var xmlHttp = null;
		var sandhour = document.getElementById('sandhour');
		var sandhourbg = document.getElementById('sandhourbg');
		var dim = getNodePos(destobj);
		var reqok = true;
		sandhour.style.top = sandhourbg.style.top = dim.y+"px";
		sandhour.style.left = sandhourbg.style.left = dim.x+"px";
		sandhour.style.width = sandhourbg.style.width = destobj.offsetWidth+"px";
		sandhourbg.style.height = destobj.offsetHeight+"px";
		sandhour.style.height = (destobj.offsetHeight >> 1) +"px";
		if (window.XMLHttpRequest) { // fx
			xmlHttp = new XMLHttpRequest(); // if (xmlhtml.overrideMimeType) { xmlhtml.overrideMimeType('text/html'); } // make sure we are receiving xml
		} else if (window.ActiveXObject) { // ie
			try { xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try { xmlHttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {}
			}
		}
		if (xmlHttp) {
			try {
				xmlHttp.open("GET",url, true);
				sandhour.style.display = sandhourbg.style.display = "";
				xmlHttp.onreadystatechange = function () {
					if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
						reqok = xmlHttp.responseText != "";
						if (reqok) destobj.innerHTML = xmlHttp.responseText;
						
						makeNiceObjTitles(destobj);
						sandhour.style.display = sandhourbg.style.display = "none";
					}
				};
				try {
					xmlHttp.send(null);
				} catch (e) {
					sandhour.style.display = sandhourbg.style.display = "none";
				}
			} catch (e) {}
		} else reqok = false;
		return reqok;
	}
	function XMLRefresh(url,destid,intval) {
		if (!(obj=document.getElementById(destid))) return;
		var Div = document.createElement("div");
		Div.className = 'progress';
		var Img = document.createElement("img");
		Img.src = "http://themes.splatterladder.com/red.jpg";
		Img.style.width = "100" + "%";
//		Img.style.height = "4px";
//		Img.style.textAlign = "right";
		Img.id = destid+"_progress";
		Div.appendChild(Img);
		obj.parentNode.insertBefore(Div, obj.nextSibling);
//		obj.style.background = "url(http://wiki.splatterladder.com/skins/monobook/bullet.gif) no-repeat right bottom;";
//		obj.style.background-position = "20px 20px;";
		window.setTimeout("XMLRefreshTick('"+url+"','"+destid+"',"+intval+",20,'"+Img.id+"');", intval*50);
	}
	function XMLRefreshTick(url,destid,intval,countdown,Imgid) {
		countdown--;
		document.getElementById(Imgid).style.width = (countdown*5) + "%";
		refresh = true;
		if (!countdown) {
			refresh = XMLLoad(url,document.getElementById(destid));
			if (refresh) document.getElementById(Imgid).style.width = "100%";
//			if (refresh) {
//				if (!(obj=document.getElementById(destid))) return;
//				var Img = document.createElement("img");
//				Img.src = "http://wiki.splatterladder.com/skins/monobook/bullet.gif";
//				Img.style.width = "100" + "%";
//				Img.style.height = "4px";
//				Img.style.textAlign = "right";
//				Img.id = destid+"_progress";
//				obj.appendChild(Img);
//			}
			countdown = 20;
		}
//		XMLLoad(url,destobj);
		if (refresh) {
			window.setTimeout("XMLRefreshTick('"+url+"','"+destid+"',"+intval+","+countdown+",'"+Imgid+"')", intval*50);
		} else document.getElementById(Imgid).style.display = "none";
//		alert(intval);
	}

function makeNiceObjTitles(obj) {
	for (var i = 0; i<obj.childNodes.length; i++) {
		var lnk = obj.childNodes[i];
		if (lnk.nodeName == "A") {
			if (lnk.title) {
				var toolTipHack = navigator.userAgent.indexOf("Opera") >= 0;
				lnk.setAttribute("nicetitle", lnk.title);
				if (toolTipHack)
					lnk.setAttribute("title", " ");
				else
					lnk.removeAttribute("title");
				addEvent(lnk, "mouseover", showNiceTitle);
				addEvent(lnk, "mouseout", hideNiceTitle);
				addEvent(lnk, "focus", showNiceTitle);
				addEvent(lnk, "blur", hideNiceTitle);
			}
			continue;
		}
		if (lnk.nodeName == "#text") continue;
		if (lnk.nodeName == "IMG") continue;
		if (lnk.nodeName == "SPAN") continue;
		if (lnk.nodeName == "FONT") continue;
		makeNiceObjTitles(lnk);
	}
}
//document.write('<div id="sandhour" class="sandhour"></div><div id="sandhourbg" class="sandhourbg"></div>');
document.write('<div id="sandhour" style="display:none;position:absolute;z-index:255;background: transparent url(http://themes.splatterladder.com/sl.Default/gfx/s_wait.gif) center center no-repeat;"></div>');
document.write('<div id="sandhourbg" style="display:none;position:absolute;z-index:254;opacity:.5;filter: alpha(opacity=50); -moz-opacity: 0.5;background: black;"></div>');

	// GADGET OPTIONS
	var gadget = false;
	var gadgetbar = false;

	
	function gadgetbar_enter() {
		gadgetbar = true;
	}
	function gadgetbar_leave() {
		gadgetbar = false;
		window.setTimeout("gadget_options_hide()", 2000);
	}

	function gadget_enter(node,idx,options) {
		var options = document.getElementById("gadget_options");
		if (!options) return;
		left = node_getLeft(node);
		top = node_getTop(node);
		options.style.left = left-21;
		options.style.top = top-25;
		options.style.display = "";
		gadget = true;
	}
	function gadget_leave(node,idx) {
		gadget = false;
		window.setTimeout("gadget_options_hide()", 1000);
	}
	function gadget_options_hide() {
		if (gadget || gadgetbar) return;
		var options = document.getElementById("gadget_options");
		if (!options) return;
		options.style.display = "none";
	}
