var dropdowntimeout;
var ajaxDropdown = function(name, file) {
	clearTimeout(dropdowntimeout);
	start = function() {
		new Ajax.Updater(name + "[list]", file, {
			method: 'get',
			evalScripts: true,
			parameters: { q: $(name + "[input]").value },
			onCreate: function() { wait(name + "[list]"); $(name + "[list]").style.display = 'block'; }
		});
	}
	dropdowntimeout = setTimeout("start()", 500);
}
var ajaxDropdownSelect = function(name, value, label) {
	if($(name + "[hidden]")) { $(name + "[hidden]").value = value; }
	$(name + "[input]").value = label;
	$(name + "[list]").style.display = "none";
}
var calendar = function(target, y, m, d, doafter) {
	new Ajax.Updater("overlaybox", "snippets/tools/calendar.php", {
			method: 'post',
			evalScripts: true,
			parameters: { target: target, doafter: doafter, y: y, m: m, d: d },
			onSuccess: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "436px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
var clearOverlay = function() { $("overlay").style.display = "none"; }
var composeMessage = function(to) {
	new Ajax.Updater("overlaybox", "snippets/community/messages/compose.php", {
			method: 'get',
			evalScripts: true,
			parameters: { to: to },
			onSuccess: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "600px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
var datePicker = function(prefix, id, y, m, d, doafter) {
	new Ajax.Updater(id + "datepicker", "snippets/tools/datepicker.php", {
			method: 'post',
			evalScripts: true,
			parameters: { prefix: prefix, id: id, doafter: doafter, y: y, m: m, d: d },
			onSuccess: function() { if(!$(id + "datepicker").visible()) { Effect.BlindDown(id + "datepicker", { "direction": "top-left", "duration": .3}); }; },
			onCreate: function() { }
		});
}
var editImageText = function(id) {
	new Ajax.Updater("overlaybox", "snippets/tools/imageadder/edittext.php", {
			method: 'post',
			evalScripts: true,
			parameters: { id: id },
			onSuccess: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "600px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
var editText = function(id) {
	new Ajax.Updater("overlaybox", "snippets/tools/texts/edit.php", {
			method: 'post',
			evalScripts: true,
			parameters: { id: id },
			onSuccess: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "600px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
var favArtistUi = function(artistid) {
	new Ajax.Updater("favartist_" + artistid, "snippets/tools/artists/fav/ui.php", {
			method: 'post',
			evalScripts: true,
			parameters: { artistid: artistid },
			onCreate: function() { wait("favartist_" + artistid); }
		});
}
var friendrq = function(to) {
	new Ajax.Updater("overlaybox", "snippets/community/friends/request.php", {
			method: 'get',
			evalScripts: true,
			parameters: { to: to },
			onSuccess: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "400px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
var geoSetPos = function(q, target) {
	new Ajax.Updater("overlaybox", "snippets/tools/geo/setpos.php", {
			method: 'get',
			evalScripts: true,
			parameters: { q: q, target: target },
			onSuccess: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "600px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
var geoShowPos = function(q, header) {
	new Ajax.Updater("overlaybox", "snippets/tools/geo/showpos.php", {
			method: 'get',
			evalScripts: true,
			parameters: { q: q, header: header },
			onComplete: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "600px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
var myPresenceUi = function(eventid) {
	new Ajax.Updater("mypresence[" + eventid + "]", "snippets/tools/presence/ui.php", {
			method: 'post',
			evalScripts: true,
			parameters: { eventid: eventid },
			onCreate: function() { wait("mypresence[" + eventid + "]"); }
		});
}
var newsletter = function() {
	new Ajax.Updater("overlaybox", "snippets/newsletter/overlay/form.php", {
			method: 'post',
			evalScripts: true,
			parameters: { q: "" },
			onComplete: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "400px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
var keepOnline = function() {
	new Ajax.Request("snippets/community/keep_online.php", {
			method: 'post',
			evalScripts: true
		});
}
var previewText = function(text) {
	new Ajax.Updater("overlaybox", "snippets/tools/previewtext.php", {
			method: 'post',
			evalScripts: true,
			parameters: { text: text },
			onSuccess: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "400px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
var rate = function(table, id, rating) {
	new Ajax.Updater("test", "snippets/tools/rating/rate.php", {
			method: 'post',
			evalScripts: true,
			parameters: { table: table, id: id, rating: rating },
			onSuccess: function() { ratingBox(table, id); },
			onCreate: function() { wait("test"); }
		});
}
var ratingHover = function(table, id, rating, icon) {
	for(i = 1; i <= 5; i++) {
		$("rate_" + table + "_" + id + "_" + i).src = "imgs/icons/" + icon + ".dimmed";
	}
	for(i = 1; i <= rating; i++) {
		$("rate_" + table + "_" + id + "_" + i).src = "imgs/icons/" + icon;
	}
}
var ratingBox = function(table, id) {
	new Ajax.Updater("rbox_" + table + "_" + id, "snippets/tools/rating/ratingbox.php", {
			method: 'post',
			evalScripts: true,
			parameters: { table: table, id: id },
			onCreate: function() { wait("rbox_" + table + "_" + id); }
		});
}
var refreshComments = function(tablename, itemid, offset) {
	new Ajax.Updater("comments_" + tablename + "_" + itemid, "snippets/tools/commentarea/comments.php", {
		method: 'post',
		evalScripts: true,
		parameters: { tablename: tablename, itemid: itemid, offset: offset },
		onCreate: function() { wait("comments_" + tablename + "_" + itemid); }
	});
}
var replaceHeaders = function() {
	/* var headers = $$('h1');
	for(i = 0; i < headers.length; i++) {
		var label = headers[i].innerHTML;
		headers[i].replace("<img src=\"php/imgs/h1.php?t=" + escape(label) + "\" class=\"h1\" alt=\"" + label + "\" />");
	} */
}
var save = function(form, href) {
	new Ajax.Updater("test", href, {
		method: 'post',
		evalScripts: true,
		parameters: $(form).serialize(),
		encoding: "utf-8",
		onSuccess: function() { alert("Einstellungen gespeichert."); },
		onFailure: function() { alert("Es ist ein Fehler aufgetreten."); }
	});
}
function saveCities(vars) {
	new Ajax.Updater("test", "snippets/tools/savecities.php", { method: "post", parameters: vars })
}
var savePresence = function(eventid) {
	new Ajax.Request("snippets/tools/presence/save.php", {
			method: 'post',
			evalScripts: true,
			parameters: $("presenceform[" + eventid + "]").serialize(),
			onCreate: function() { $("presencecheckbox[" + eventid + "]").replace("<img src=\"imgs/icons/wait16trans.gif\" class=\"ajaxWait\" />"); },
			onComplete: function() { myPresenceUi(eventid); }
		});
}
function selectTab(group, tab) {
	var tabs = $$("#" + group + " a");
	for(i = 0; i < tabs.length; i++) { tabs[i].removeClassName("current"); }
	tab.addClassName("current");
}
var showImage = function(file) {
	var h = document.viewport.getHeight();
	var w = document.viewport.getWidth();
	var o = document.viewport.getScrollOffsets();
	if(h < w) { m = h; } else { m = w; }
	if($("bigImage")) { $("bigImage").remove(); }
	if($("loading")) { $("loading").remove(); }
	$$("body")[0].insert("<div id=\"loading\">Einen Moment bitte...</div>");
	$$("body")[0].insert("<img src='php/imgs/scale.php?f=" + file + "&amp;m=" + Math.round(m*.95) + "' id='bigImage' style='display:none;' onload=\"\" onclick=\"$('bigImage').fade({ duration : .3 })\" />");
	$("loading").style.top = Math.round((document.viewport.getHeight()-$("loading").getHeight())/2) + o["top"] +  "px";
	$("loading").style.left = Math.round((document.viewport.getWidth()-$("loading").getWidth())/2) + o["left"] + "px";
	$("bigImage").observe("load", function() {
		if($("loading")) { $("loading").remove(); }
		$("bigImage").style.top = Math.round((document.viewport.getHeight()-$("bigImage").getHeight())/2) + o["top"] +  "px";
		$("bigImage").style.left = Math.round((document.viewport.getWidth()-$("bigImage").getWidth())/2) + o["left"] + "px";
		$("bigImage").appear({ duration : .3 });
	});
}
var switchview = function(elementid) {
	if($(elementid).className == "vTiles") { $(elementid).className = "vBiglist"; }
	if($(elementid).className == "vBiglist") { $(elementid).className = "vList"; }
	if($(elementid).className == "vList") { $(elementid).className = "vTiles"; }
}
var wait = function(elementid) {
	$(elementid).innerHTML = "<span class=\"wait\"><img src=\"imgs/icons/wait16trans.gif\" /></span>";
}
var writeNews = function() {
	new Ajax.Updater("overlaybox", "snippets/news/compose.php", {
			method: 'get',
			evalScripts: true,
			onSuccess: function() { $("overlay").style.display = "block"; $("overlaybox").style.width = "400px"; },
			onCreate: function() { wait("overlaybox"); }
		});
}
<!-- setInterval("keepOnline()", 60000); -->