var msgs = {
	'missing.username'	:'Bitte gib Deinen Usernamen an!',
	'missing.name'		:'Bitte gib Deinen Nachnamen an!',
	'missing.email'		:'Bitte g\u00fcltige eMail-Adresse eingeben!',
	'missing.land'		:'Bitte gib Dein Land an!',
	'missing.plz'		:'Bitte gib Deine Stadt an!',
	'missing.ort'		:'Bitte gib Deinen Ort an!',
	'missing.agb'		:"Bitte stimme den AGB's zu!",
	'missing.location'	:'Bitte Ort aussuchen!'
	};
function getMsg(key) {{{
	if(msgs[key]) return msgs[key];
	return key;
	}}}

//  cIIN(id,name) => cE('input',{'id':id, 'name':name})
//  cIN (name   ) => cE('input',{         'name':name})
//  cINV(id,name) => cE('input',{'id':id, 'value':name})
// DOM {{{
function gE(e) {{{
	if (typeof e!='string') return e;
	return document.getElementById(e);
	}}}
function debug(t) { alert(t); }
function cE(t) {{{ // cE(t,[attr],[style],[childs])
	var v;
        var e = document.createElement(t);
        if (cE.arguments.length > 1)
		for (var k in cE.arguments[1]) {
			e[k] = cE.arguments[1][k];
			if (typeof e[k] != 'function') sA(e,k,e[k]);
			}
        if (cE.arguments.length > 2) for (var k in cE.arguments[2]) e.style[k]=cE.arguments[2][k];
        if (cE.arguments.length > 3) for (var k in cE.arguments[3]) if (typeof (v=cE.arguments[3][k])!='function') aC(e,v);
        return e;
        }}}
function cT(e) { return document.createTextNode(e); }
function aC(d,s) {{{
	var i = gE(d);
	try { i.appendChild(s); } catch (e) { debug('aC('+d+' , '+s+') => '+e); }
	return i;
	}}}
function cSIN(id,name,opt) {{{
	var s = cE('select',{'id':id});
	s.name = name;
	for(i=0;i<opt.length;i++) {
		var o = cE('option');
		o.value = opt[i][0];
		aC(s,aC(o,cT(opt[i][1])));
		}
	return s;
	}}}
function aE(i,evt,fkt) {{{
	var obj = gE(i);
	if (obj.addEventListener) {
		obj.addEventListener(evt, fkt, true);
		return true;
		}
	if (obj.attachEvent) {
		var r = obj.attachEvent('on' + evt, fkt);
		return r;
		}
	var xEventFn = obj['on' + evt];
	if (typeof obj['on'+evt] != 'function') obj['on'+evt] = fkt;
	else 					obj['on'+evt] = function(e) { xEventFn(e); fkt(e); };
	}}}
function sA(e,a,v) {{{
	var n = document.createAttribute(a);
	n.nodeValue = v;
	e.setAttributeNode(n);
	e.setAttribute(a,v);
	return e;
	}}}
function gV(i) {{{
	var e = gE(i);
	try {
		switch(e.nodeName.toLowerCase()) {
		case 'textarea'	: return e.value; break;
		case 'select'	: return e.value; break;
		case 'td'	: return e.innerHTML; break;
		case 'input'	: switch(e.type) {
					case 'hidden'	: return e.value; break;
					case 'password'	: return e.value; break;
					case 'text'	: return e.value; break;
					case 'checkbox'	: return (e.checked?1:0); break;
					default: alert('<input type="'+e.type+'">');
						 return e.value;
					}
				 break;
		default: alert('gV('+i+') Error: '+e.nodeName.toLowerCase()+'\nCaller'+gV.caller);
			 return '';
			}
		} catch(err) { alert('gV('+i+') e='+e+'=> '+err+'\nCaller:'+gV.caller); }
	}}}
function sV(i,v) {{{
	var e = gE(i);
	try {
		if(typeof(v)=="undefined" || v==null || v=='undefined') v='';
		switch(e.nodeName.toLowerCase()) {
		case 'textarea'	: e.value=v; break;
		case 'select'	: e.value=v; break;
		case 'div'	:
		case 'span'	:
		case 'td'	: e.innerHTML=v; break;
		case 'input'	: switch(e.type) {
					case 'hidden'	:
					case 'text'	: e.value=v; break;
					case 'checkbox'	: e.checked=(v==1); break;
					default: alert('<input type="'+e.type+'">');
						 return i;
					}
				break;
		default: alert('sV('+i+') Error: '+e.nodeName.toLowerCase());
			 return i;
			}
		if (e.onchange) e.onchange(e);
		return i;
		} catch(err) { alert('sV('+i+'('+e+') , '+v+') => '+err); }
	return i;
	}}}
function gH(e) {{{
	e = gE(e);
	if (typeof e.offsetHeight == 'number') return e.offsetHeight;
	return e.style.pixelHeight;
	}}}
function gW(e) {{{
	e = gE(e);
	if (e.tagName=='FORM') {
		e = e.firstChild;
	}
	var w = parseInt(e.style.width);
	if(w>0) return w;
	if (typeof e.offsetWidth == 'number') return e.offsetWidth;
	return e.style.pixelWidth;
	}}}
function gL(e) {{{
	e = gE(e);
	var x = e.offsetLeft;
	e = e.offsetParent;
	for(e = e.offsetParent; e != null; e = e.offsetParent) x += e.offsetLeft;
	return x;
	}}}
function gT(e) {{{
	e = gE(e);
	var y = e.offsetTop;
	for(e = e.offsetParent; e != null; e = e.offsetParent) x += e.offsetTop;
	return y;
	}}}
// getElementsBySelector {{{
/* The following code is Copyright (C) Simon Willison 2004. */
function getAllChildren(e) {{{
	if (e==null) return null;
	return e.all ? e.all : e.getElementsByTagName('*');
	}}}
document.getElementsBySelector = function(selector) {{{
	if (!document.getElementsByTagName) return new Array();			// Attempt to fail gracefully in lesser browsers
	var tokens = selector.split(' ');					// Split selector in to tokens
	var currentContext = new Array(document);
	for (var i = 0; i < tokens.length; i++) {
		token = tokens[i].replace(/^\s+/,'').replace(/\s+$/,'');	// token = trim(tokens[i]);
		if (token.indexOf('#') > -1) {{{	// Token is an ID selector
/* Warning !!! does not check the currentContext */
			var bits = token.split('#');
			var tagName	= bits[0];
			var id		= bits[1];
			var element	= gE(id);
			if (tagName && element.nodeName.toLowerCase() != tagName) return new Array(); // tag with that ID not found, return false
			// Set currentContext to contain just this element
			currentContext = new Array(element);			// Set currentContext to contain just this element
			continue; // Skip to next token
			}}}
		if (token.indexOf('.') > -1) {{{	// Token contains a class selector
			var bits = token.split('.');
			var tagName = bits[0];
			var className = bits[1];
			if (!tagName) tagName = '*';
			// Get elements matching tag, filter them for class selector
			var found = new Array;
			var foundCount = 0;
			for (var h = 0; h < currentContext.length; h++) {
				var elements = null;
				if (tagName == '*') elements = getAllChildren(currentContext[h]);
				else elements = currentContext[h].getElementsByTagName(tagName);
				if (elements) for (var j = 0; j < elements.length; j++) { found[foundCount++] = elements[j]; }
			}
			currentContext = new Array;
			var currentContextIndex = 0;
			for (var k = 0; k < found.length; k++)
				if (found[k].className && found[k].className.match(new RegExp('\\b'+className+'\\b'))) currentContext[currentContextIndex++] = found[k];
			continue; // Skip to next token
			}}}
		if (token.match(/^(\w*)\[(\w+)([=~\|\^\$\*]?)=?"?([^\]"]*)"?\]$/)) {{{ // deal with attribute selectors
			var tagName = RegExp.$1;
			var attrName = RegExp.$2;
			var attrOperator = RegExp.$3;
			var attrValue = RegExp.$4;
			if (!tagName) tagName = '*';
			// Grab all of the tagName elements within current context
			var found = new Array;
			var foundCount = 0;
			for (var h = 0; h < currentContext.length; h++) {
				var elements;
				if (tagName == '*') 	elements = getAllChildren(currentContext[h]);
				else 			elements = currentContext[h].getElementsByTagName(tagName);
				for (var j = 0; j < elements.length; j++) found[foundCount++] = elements[j];
				}
			currentContext = new Array;
			var currentContextIndex = 0;
			var checkFunction; // This function will be used to filter the elements
			switch (attrOperator) {
			case '=': checkFunction = function(e) { return (e.getAttribute(attrName) == attrValue); }; break;	// Equality
			case '~': checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('\\b'+attrValue+'\\b'))); }; break;	// Match one of space seperated words
			case '|': checkFunction = function(e) { return (e.getAttribute(attrName).match(new RegExp('^'+attrValue+'-?'))); }; break;	// Match start with value followed by optional hyphen
			case '^': checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) == 0); }; break; // Match starts with value
			case '$': checkFunction = function(e) { return (e.getAttribute(attrName).lastIndexOf(attrValue) == e.getAttribute(attrName).length - attrValue.length); }; break; // Match ends with value
			// $ - fails with "Warning" in Opera 7
			case '*': checkFunction = function(e) { return (e.getAttribute(attrName).indexOf(attrValue) > -1); }; break; // Match ends with value
			default : checkFunction = function(e) { return e.getAttribute(attrName); }; break; // Just test for existence of attribute
				}
			currentContext = new Array;
			var currentContextIndex = 0;
			for (var k = 0; k < found.length; k++) if (checkFunction(found[k])) currentContext[currentContextIndex++] = found[k];
			continue; // Skip to next token
		}}}
		if (!currentContext[0]) return;
		// If we get here, token is JUST an element (not a class or ID selector)
		tagName = token;
		var found = new Array;
		var foundCount = 0;
		for (var h = 0; h < currentContext.length; h++) {
			var elements = currentContext[h].getElementsByTagName(tagName);
			for (var j = 0; j < elements.length; j++) found[foundCount++] = elements[j];
			}
		currentContext = found;
	}
	return currentContext;
}}}
// }}}
// }}}

/* Function printf(format_string,arguments...) {{{
 * Javascript emulation of the C printf function (modifiers and argument types * "p" and "n" are not supported due to language restrictions)
 *
 * Copyright 2003 K&L Productions. All rights reserved http://www.klproductions.com
 * Terms of use: This function can be used free of charge IF this header is not modified and remains with the function code.
 * Legal: Use this code at your own risk. K&L Productions assumes NO resposibility for anything.
 */
function printf(fstring) {
	var pad = function(str,ch,len) {{{
		var ps='';
		for(var i=0; i<Math.abs(len); i++) ps+=ch;
		return len>0?str+ps:ps+str;
		}}}
	var processFlags = function(flags,width,rs,arg) {{{
		var pn = function(flags,arg,rs) {{{
			if(arg>=0) {
				if(flags.indexOf(' ')>=0) rs = ' ' + rs;
				else if(flags.indexOf('+')>=0) rs = '+' + rs;
				}
			else rs = '-' + rs;
			return rs;
			}}}
		var iWidth = parseInt(width,10);
		if(width.charAt(0) == '0') {{{
			var ec=0;
			if(flags.indexOf(' ')>=0 || flags.indexOf('+')>=0) ec++;
			if(rs.length<(iWidth-ec)) rs = pad(rs,'0',rs.length-(iWidth-ec));
			return pn(flags,arg,rs);
			}}}
		rs = pn(flags,arg,rs);
		if(rs.length<iWidth) {
			if(flags.indexOf('-')<0) rs = pad(rs,' ',rs.length-iWidth);
			else rs = pad(rs,' ',iWidth - rs.length);
			}
		return rs;
		}}}
	var c = new Array();
	var iPrecision = 2;
	c['c'] = function(flags,width,precision,arg) {{{
		if(typeof(arg) == 'number') return String.fromCharCode(arg);
		if(typeof(arg) == 'string') return arg.charAt(0);
		return '';
	}}}
	c['e'] = function(flags,width,precision,arg) {{{
		Precision = parseInt(precision);
		if(isNaN(iPrecision)) iPrecision = 6;
		rs = (Math.abs(arg)).toExponential(iPrecision);
		if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) rs = rs.replace(/^(.*)(e.*)$/,'$1.$2');
		return processFlags(flags,width,rs,arg);
	}}}
	c['f'] = function(flags,width,precision,arg) {{{
		Precision = parseInt(precision);
		if(isNaN(iPrecision)) iPrecision = 2;
		rs = (Math.abs(arg)).toFixed(iPrecision);
		if(rs.indexOf('.')<0 && flags.indexOf('#')>=0) rs = rs + '.';
		return processFlags(flags,width,rs,arg);
		}}}
	c['g'] = function(flags,width,precision,arg) {{{
		Precision = parseInt(precision);
		absArg = Math.abs(arg);
		rse = absArg.toExponential();
		rsf = absArg.toFixed(6);
		if(!isNaN(iPrecision)) {
			rsep = absArg.toExponential(iPrecision);
			rse = rsep.length < rse.length ? rsep : rse;
			rsfp = absArg.toFixed(iPrecision);
			rsf = rsfp.length < rsf.length ? rsfp : rsf;
		}
		if(rse.indexOf('.')<0 && flags.indexOf('#')>=0) rse = rse.replace(/^(.*)(e.*)$/,'$1.$2');
		if(rsf.indexOf('.')<0 && flags.indexOf('#')>=0) rsf = rsf + '.';
		rs = rse.length<rsf.length ? rse : rsf;
		return processFlags(flags,width,rs,arg);
	}}}
	c['i'] = function(flags,width,precision,arg) {{{
		var iPrecision=parseInt(precision);
		var rs = ((Math.abs(arg)).toString().split('.'))[0];
		if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
		return processFlags(flags,width,rs,arg);
	 }}}
	c['o'] = function(flags,width,precision,arg) {{{
		var iPrecision=parseInt(precision);
		var rs = Math.round(Math.abs(arg)).toString(8);
		if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
		if(flags.indexOf('#')>=0) rs='0'+rs;
		return processFlags(flags,width,rs,arg);
	}}}
	c['x'] = function(flags,width,precision,arg) {{{
		var iPrecision=parseInt(precision);
		arg = Math.abs(arg);
		var rs = Math.round(arg).toString(16);
		if(rs.length<iPrecision) rs=pad(rs,' ',iPrecision - rs.length);
		if(flags.indexOf('#')>=0) rs='0x'+rs;
		return processFlags(flags,width,rs,arg);
	}}}
	c['s'] = function(flags,width,precision,arg) {{{
		var iPrecision=parseInt(precision);
		var rs = arg;
		if(rs.length > iPrecision) rs = rs.substring(0,iPrecision);
		return processFlags(flags,width,rs,0);
	}}}
	c['d'] = function(flags,width,precision,arg) { return c['i'](flags,width,precision,arg); }
	c['u'] = function(flags,width,precision,arg) { return c['i'](flags,width,precision,Math.abs(arg)); }
	c['G'] = function(flags,width,precision,arg) { return(c['g'](flags,width,precision,arg)).toUpperCase(); }
	c['X'] = function(flags,width,precision,arg) { return(c['x'](flags,width,precision,arg)).toUpperCase(); }
	c['E'] = function(flags,width,precision,arg) { return(c['e'](flags,width,precision,arg)).toUpperCase(); }
	farr = fstring.split('%');
	retstr = farr[0];
	fpRE = /^([-+ #]*)(\d*)\.?(\d*)([cdieEfFgGosuxX])(.*)$/;
	for(var i=1; i<farr.length; i++) {{{
		fps=fpRE.exec(farr[i]);
		if(!fps) continue;
		if(arguments[i]!=null) retstr+=c[fps[4]](fps[1],fps[2],fps[3],arguments[i]);
		retstr += fps[5];
	}}}
	return retstr;
	} // }}}

// Ajax {{{
function loading() {{{
	var e = gE('ajaxLoading');
	if (!e) {
		e = cE('div');
		e.id = 'ajaxLoading';
		aC(gE('body') ,e);
		}
	try { e.style.height=gE('root').scrollHeight+'px'; } catch(e) { }
	e.style.display='block';
	}}}
function loaded() {{{
	var e = gE('ajaxLoading');
	if(!e) return;
	gE('ajaxLoading').style.display='none';
	}}}
function createXMLHttpRequest() {{{
	try { return new ActiveXObject('Msxml2.XMLHTTP'); } catch (e) {}
	try { return new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) {}
	try { return new XMLHttpRequest(); } catch(e) {}
	return null;
}}}
function post(url, data, callback,displayLoading) {{{
	var h = createXMLHttpRequest();
	if (h == null) return;
	h.open('post', 'http://'+window.location.hostname+url, true);
	h.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
	if(displayLoading) loading();
	h.onreadystatechange = function () {
		if (h.readyState == 4) {
			try { loaded(); } catch (e) {}
			if (h.status == 200) callback(h.responseText); else alert('Ajax Satus: '+h.status+'\n'+url);
			}
		}
	h.send(data);
}}}
// }}}

(function () {{{
	 var m = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\' },
		json_s = {
		 array: function (x) {{{
			var a = ['['], b, f, i, l = x.length, v;
			for (i = 0; i < l; i += 1) {
			 v = x[i];
			 f = json_s[typeof v];
			 if (f) {
				v = f(v);
				if (typeof v == 'string') {
				 if (b) a[a.length] = ',';
				 a[a.length] = v;
				 b = true;
				}
			 }
			}
			a[a.length] = ']';
			return a.join('');
		 }}},
		 'boolean': function (x) { return String(x); },
		 'null': function (x) { return "null"; },
		 number: function (x) { return isFinite(x) ? String(x) : 'null'; },
		 object: function (x) {{{
		if (x == window) return;
			if (x) {
			 if (x instanceof Array) return json_s.array(x);
			 var a = ['{'], b, f, i, v;
			 for (i in x) {
				v = x[i];
				f = json_s[typeof v];
				if (f) {
				 v = f(v);
				 if (typeof v == 'string') {
					if (b) a[a.length] = ',';
					a.push(json_s.string(i), ':', v);
					b = true;
				 }
				}
			 }
			 a[a.length] = '}';
			 return a.join('');
			}
			return 'null';
		 }}},
		 string: function (x) {{{
			if (/["\\\x00-\x1f]/.test(x)) {
			 x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
				var c = m[b];
				if (c) return c;
				c = b.charCodeAt();
				return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16);
			 });
			}
			return '"' + x + '"';
		 }}}
		};
	 Object.prototype.toJSONString = function () { return json_s.object(this); };
	 Array.prototype.toJSONString = function () { return json_s.array(this); };
}}})();

var overAktive = null;
function smartOver(e) {{{
	if(!e.id) e.id='gen-id-'+(gen_idx++);
	var timer = e.getAttribute('out');
	if (timer) window.clearTimeout(timer);
	if (overAktive != null && overAktive != e) {
		timer = overAktive.getAttribute('out');
		if (timer) window.clearTimeout(timer);
		overAktive.className='';
		}
	e.className="over";
	overAktive = e;
	}}}
function smartOut(e) {{{
	var timer = window.setTimeout(function() { e.className=''; },1000);
	e.setAttribute('out',timer);
	}}}

function imodeSim() {{{
	window.open("http://wapsim.mybm.de/simulator/wap/wap.htm",'universal','menubar=0 ,toolbar=0,scrollbars=no,status=0,resizable=no,height=700,width=300');
	return false;
	}}}
function help(e) { window.location.href='/Artikel/'+e.id.replace('cnt-','') }
function saveArtikel(e) {{{
	while(e && e.id!='content') e = e.parentNode;
	if (!e) return;
	var i,t = e.className.split(' ');
	var bnt='';
	var cnt='';
	var param = new Object();
	param.text = new Object();
	param.clob = new Object();
	for(i=0;i<t.length;i++) {
		if(t[i].substr(0,4)=='bnt-') param.bnt=t[i].substr(4);
		if(t[i].substr(0,4)=='cnt-') param.cnt=t[i].substr(4);
		}

	var s = e;
	e = e.firstChild;
	while(true) {
		if (e.nodeName.toLowerCase()=='input'	) param.text[e.parentNode.id]=e.value;
		if (e.nodeName.toLowerCase()=='textarea') param.clob[e.parentNode.id]=e.value;
		if (e.firstChild ) { e = e.firstChild; continue; }
		if (e.nextSibling) { e = e.nextSibling; continue; }
		while(true) {
			t = e;
			e = e.parentNode;
			if (e == s) break;
			while(e.lastChild != t) e = e.nextSibling;
			if (!e.nextSibling) continue;
			e = e.nextSibling;
			break;
			}
		if (e == s) break;
		}
	post('/fkt.php', 'fkt=saveContent&daten='+param.toJSONString(), callback, true);
	return false;
	}}}

function makeInputEdit(e) {{{
	var val = e.innerHTML;
	while(e.firstChild) e.removeChild(e.firstChild);
	var i = cE('input');
	i.value=val;
	i.style.width='620px';
	aC(e,i);
	}}}
function makeCceEdit(e) {{{
	var val = e.innerHTML;
	while(e.firstChild) e.removeChild(e.firstChild);
	var i = cE('textarea');
	i.style.width='620px';
	i.style.height='140px';
	i.value=val;
	aC(e,i);
	i = cE('a',{'href':'#'});
	i.onclick=function() { saveArtikel(this); }
	i.className='fkt';
	aC(e,aC(i,cT('Speichern')));
	}}}

/* Behaviour {{{
 Behaviour v1.1 by Ben Nolan, June 2005. Based largely on the work of Simon Willison (see comments by Simon below).
 More information: http://ripcord.co.nz/behaviour/
*/
var Behaviour = {
	list : new Array,
	register : function(sheet){ Behaviour.list.push(sheet); },
	apply	: function() {
			var dyn = [];
			dyn['.bnt-'+user.id+' .content-kurz' ] = function(e) { makeInputEdit(e); }
			dyn['.bnt-'+user.id+' .content-titel'] = function(e) { makeInputEdit(e); }
			dyn['.bnt-'+user.id+' .cce'	     ] = function(e) { makeCceEdit(e); }
			this.register(dyn);
			for (h=0;sheet=Behaviour.list[h];h++){
				for (selector in sheet){
					list = document.getElementsBySelector(selector);
					if (!list) continue;
					for (i=0;element=list[i];i++) sheet[selector](element);
					}
				}
			}
	}	// }}}

function stopBubble(event) {{{
	if (!event) var event = window.event;
	event.cancelBubble = true;
	event.returnValue = false;
	if (event.preventDefault ) event.preventDefault();
	if (event.stopPropagation) event.stopPropagation();
	return false;
	}}}

function cbRss(e,txt) {{{
	while(e.firstChild) e.removeChild(e.firstChild);
	var t = cE('h1');
	t = cE('div');
	if (typeof txt=='string') eval('res = ('+txt+')');
	else			 res = txt;
	for(i=0;i<res.length;i++) {
		var x = cE('h2');
		aC(t, aC(x, cT(res[i].kopf.txt)));
		for(j=0;j<res[i].news.length;j++) {
			var a = cE('a');
			a.href = res[i].news[j].url;
			if (res[i].news[j].url.indexOf('http://')==0) sA(a,'target','_blank');
			aC(t, aC(a, cT(res[i].news[j].txt)));
			}
		}
	aC(e,t);
	}}}
function doRss(e) {{{
	if(rssRec) cbRss(gE('rss'),rssRec);
	}}}

var gen_idx=0;
var myRules = { // {{{
	'.fadeout': function(e) { if(!e.id) e.id='gen-id-'+(gen_idx++); fadeout(e.id, 100, 50); }
	,'#location-result div' : function(e) { e.onmouseover	=function() { eventPopup(e,true ,'/location.php'); }; }
	,'#event-result div' : function(e) { e.onmouseover	=function() { eventPopup(e,true ,'/event.php'); }; }
	,'.event-short' : function(e) { e.onmouseover	=function() { eventPopup(e,true ,'/event.php'); }; }
	,'#toolbar li': function(e) {
		e.onclick = function() {
			var e = this;
			if (overAktive != null) { overAktive.className=''; if (e == overAktive) { overAktive=null; return; } }
			e.className="over";
			overAktive = e;
			}
		}
	,'#eventSuchePos'		: function(e) { createEventSuche(e.id); }
	,'#locationSuchePos'		: function(e) { createLocationSuche(e.id); }
	,'#userSuchePos'		: function(e) { createUserSuche(e.id); }
	,'#googleSuchePos'		: function(e) { createGoogleBox(e.id); }
	,'#kleinanzeigenSuchePos'	: function(e) { createKleinanzeigenSuche(e.id); }
	,'.navi span' 			: function(e) { e.onclick = function () { locJump(this); } }
	,'#kaAntworten' 		: function(e) { e.onclick = doKaAntworten; }
	,'.del'				: function(e) { e.onclick = function () { delContent(this); } }
	,'.help'			: function(e) { e.onclick = function () { help(this); } }
	,'a.imode'			: function(e) { e.onclick = imodeSim; }
	,'.cal'				: function(e) { e.onclick = function () { calTrigger(this); } }
	,'.cal input'			: function(e) { e.onclick = stopBubble; }
	,'.cnt-typ-2'			: function(e) { e.onclick = function(evt) { crossContentClick(evt,this); } }
	,'.cnt-typ-3'			: function(e) { e.onclick = function(evt) { crossContentClick(evt,this); } }
	,'.voteChk'			: function(e) { e.onclick = function(evt) { voteClicked(evt,this); } }
	}; // }}}


function mySend(url,data){{{
        window.setTimeout(function() {
                var script=window.document.createElement('script');
                var src=url+'?'+data;
                script.setAttribute('type','text/javascript');
                script.setAttribute('charset','UTF-8');
                script.setAttribute('src',src);
                window.document.documentElement.firstChild.appendChild(script);
                },0);
        }}}

function shoutboxPoll(){{{
       	if(shoutboxTimeout!=null) clearTimeout(shoutboxTimeout);
	shoutboxTimeout=window.setTimeout(function() { shoutboxPoll(); }, 120000);
	window.setTimeout(function() {
		var e = gE('shoutboxPoll');
		if(e) e.parentNode.removeChild(e);
                var script=window.document.createElement('script');
		shoutboxLast=parseInt(shoutboxLast)+1;
                var src='http://194.50.33.35:8080/mybm/shoutbox?poll='+shoutboxLast;
		script.id='shoutboxPoll';
                script.setAttribute('type','text/javascript');
                script.setAttribute('charset','UTF-8');
                script.setAttribute('src',src);
                window.document.documentElement.firstChild.appendChild(script);
                },0);
        }}}
function shoutboxSend(e) {{{
	if(!e) e=window.event;
	if(e.keyCode!=13) return;
	 shoutboxSendI();
	}}}
function shoutboxSendI() {{{
	if(user.id<0) return goLogin();
	var text = gE('shoutboxSend').value;
	if(text.length==0) return;
	gE('shoutboxSend').value='';
	mySend('http://194.50.33.35:8080/mybm/shoutbox', 'sess='+sess+'&mesg='+encodeURIComponent(text));
	}}}
function initShoutbox() {{{
	var shoutbox = gE('shoutbox');
	if(!shoutbox) return;
	aC(shoutbox,aC(cE('h2'),cT('Shoutbox')));
	aC(shoutbox,t=cE('div')); t.id='shoutboxMesg';
	aC(shoutbox,t=cE('input')); t.id='shoutboxSend'; t.onkeyup=shoutboxSend; t.maxLength=80;
	aC(shoutbox,aC(t=cE('div'),cT('Senden'))); t.onclick=shoutboxSendI; t.id='shoutboxBtn';
	window.setTimeout(function() { shoutboxPoll(); },3000);
	}}}
function shoutboxAddLine(out,user,text) {{{
	var smiley = [
		{'txt':[':-)',':)'				],'img':'http://i0.mybm.de/img/smiley/stock_smiley-1.gif'},
		{'txt':['=-)','=)'				],'img':'http://i1.mybm.de/img/smiley/stock_smiley-2.gif'},
		{'txt':[';-)',';)'				],'img':'http://i2.mybm.de/img/smiley/stock_smiley-3.gif'},
		{'txt':[':-(',':('				],'img':'http://i3.mybm.de/img/smiley/stock_smiley-4.gif'},
		{'txt':[':-O',':O',':-o',':o'			],'img':'http://i0.mybm.de/img/smiley/stock_smiley-5.gif'},
		{'txt':[':-D',':D',':-d',':d'			],'img':'http://i1.mybm.de/img/smiley/stock_smiley-6.gif'},
		{'txt':[':o)',':O)'				],'img':'http://i2.mybm.de/img/smiley/stock_smiley-7.gif'},
		{'txt':[':-|',':|'				],'img':'http://i3.mybm.de/img/smiley/stock_smiley-8.gif'},
		{'txt':[':-/',':/'				],'img':'http://i0.mybm.de/img/smiley/stock_smiley-9.gif'},
		{'txt':[':-P',':P',':-p',':p'			],'img':'http://i1.mybm.de/img/smiley/stock_smiley-10.gif'},
		{'txt':[':-(',':('				],'img':'http://i2.mybm.de/img/smiley/stock_smiley-11.gif'},
		{'txt':[':-<',':<'				],'img':'http://i3.mybm.de/img/smiley/stock_smiley-12.gif'},
		{'txt':[':-*',':*'				],'img':'http://i0.mybm.de/img/smiley/stock_smiley-13.gif'},
		{'txt':[':-X',':-x',':X',':x'			],'img':'http://i1.mybm.de/img/smiley/stock_smiley-14.gif'},
		{'txt':['8-)','8)','B-)','B)'			],'img':'http://i2.mybm.de/img/smiley/stock_smiley-15.gif'},
		{'txt':['>:-O','>:O','>:-o','>:o','>:-)','>:)'	],'img':'http://i3.mybm.de/img/smiley/stock_smiley-16.gif'},
		{'txt':[':-$',':$'				],'img':'http://i0.mybm.de/img/smiley/stock_smiley-17.gif'},
		{'txt':['O:-)','O:)'				],'img':'http://i1.mybm.de/img/smiley/stock_smiley-18.gif'},
		{'txt':[':-!',':!'				],'img':'http://i2.mybm.de/img/smiley/stock_smiley-19.gif'},
		{'txt':['=-|','=|'				],'img':'http://i3.mybm.de/img/smiley/stock_smiley-20.gif'},
		{'txt':['C:-)','C:)'				],'img':'http://i0.mybm.de/img/smiley/stock_smiley-21.gif'},
		{'txt':['C:-]','C:]'				],'img':'http://i1.mybm.de/img/smiley/stock_smiley-22.gif'},
		{'txt':[':-]',':]'				],'img':'http://i2.mybm.de/img/smiley/stock_smiley-23.gif'},
		{'txt':['O-)','O)','o-)','o)'			],'img':'http://i3.mybm.de/img/smiley/stock_smiley-24.gif'},
		{'txt':['8-D','8D','B-D','BD'			],'img':'http://i0.mybm.de/img/smiley/stock_smiley-25.gif'},
		{'txt':['8-p','8p'				],'img':'http://i1.mybm.de/img/smiley/stock_smiley-26.gif'}
		]
	var d = cE('div');
	var a = cE('a'); a.href='/ShowProfil/'+user;
	aC(d,aC(a,cT(user+':' )));
	while(text.length>0) {
		var s,i,p;
		var first = text.length;
		var aS = -1;
		var aI = -1;
		for(s=0;s<smiley.length;s++) {
			for(i=0;i<smiley[s]['txt'].length;i++) {
				p = text.indexOf(smiley[s]['txt'][i]);
				if(p >= 0 && p < first) {
					first = p;
					aS = s;
					aI = i;
					}
				}
			}
		if(aS==-1) break;
		aC(d,cT(text.substring(0, first)));
		aC(d,cE('img',{'src':smiley[aS]['img']}));
		text = text.substring(first+(smiley[aS]['txt'][aI].length));
		}
	aC(d,cT(text));
	aC(out,d);
	}}}
function shoutboxCb(obj) {{{
	try {
		var out = gE('shoutboxMesg');
		if(!out) return;
		if(typeof(obj)=='object') {
			for(var k in obj) {
				if(typeof(k)!='string') continue;
				if(typeof(obj[k])!='object') continue;
				if(shoutboxLast<obj[k].zeit) shoutboxLast=obj[k].zeit;
				shoutboxAddLine(out,obj[k]['bnt']['name'],obj[k]['mesg']);
				try { out.scrollTop = out.scrollHeight - out.clientHeight; } catch(e) { }
				}
			while(out.childNodes && out.childNodes.length>50) out.removeChild(out.firstChild);
			shoutboxPoll();
			}
		}
	catch(e) { 
		alert(e); 
		}
	}}}

var shoutboxLast = 0;
var shoutboxTimeout = null;


Behaviour.register(myRules);
aE(window,'load', function(){
	Behaviour.apply();
	var data = 'ajax=mesg&message='+encodeURIComponent('<wpt lat="'+ipLat+'" lon="'+ipLon+'" type="load"><name>Usr-'+user.id+'</name></wpt>');
	mySend('http://194.50.33.35:8080/gmap/',data);
	});
aE(window,'load', displayMeldung);
aE(window,'unload', function() {
	var data = 'ajax=mesg&message='+encodeURIComponent('<wpt lat="'+ipLat+'" lon="'+ipLon+'" type="unload"><name>Usr-'+user.id+'</name></wpt>');
	mySend('http://194.50.33.35:8080/gmap/',data);
	loading();
	}
	);

function delContent(e) {{{
	var x = window.confirm('Wollen sie wirklich l\u00f6schen?');
	if (x) post('/fkt.php', 'fkt=delContent&cnt='+e.id.substr(4), callback, true);
	}}}

// DHTML Calendar Helper {{{
function calOnSelect(cal) {{{
	var p = cal.params;
	var update = (cal.dateClicked || p.electric);
	if (update && p.inputField) {
		p.inputField.value = cal.date.print(p.ifFormat);
		if (typeof p.inputField.onchange == "function") p.inputField.onchange();
		}
	if (update && p.displayArea) p.displayArea.innerHTML = cal.date.print(p.daFormat);
	if (update && typeof p.onUpdate == "function") p.onUpdate(cal);
	if (update && p.flat) if (typeof p.flatCallback == "function") p.flatCallback(cal);
	if (update && p.singleClick && cal.dateClicked) cal.callCloseHandler();
	}}};
function calTrigger(e) {{{
	var params = new Object();
	params.ifFormat='%d.%m.%Y';
	params.inputField = e.firstChild;
	params.singleClick = true;
	params.date = Date.parseDate(params.inputField.value || params.inputField.innerHTML, params.ifFormat);
	var cal = window.calendar;
	if (!cal) {
		window.calendar = cal = new Calendar(1, params.date, calOnSelect, function(cal) { cal.hide(); });
		cal.showsTime	= false;
		cal.time24	= true;
		cal.weekNumbers = true;
		cal.showsOtherMonths = false;
		cal.yearStep	= 2;
		cal.setRange(1930, 2015);
		cal.setDateStatusHandler(null);
		cal.getDateText = null;
		cal.setDateFormat(params.ifFormat);
		cal.create();
	} else {
		if (params.date) cal.setDate(params.date);
		cal.hide();
	}
	cal.params = params;
	cal.refresh();
	cal.showAtElement(e, 'Tl');
	return false;
	}}}
// }}}

function uploadForm(e) {{{
	if (e.value=="") return;
	while(e) {
		if(e.nodeName.toLowerCase()=='form') {
			e.submit();
			loading();
			}
		e = e.parentNode;
		}
	}}}

function fadeout(id,opacity,speed) {{{
	var e = gE(id).style;
	var fp = opacity/100.0;
	e.opacity	= fp;
	e.MozOpacity	= fp;
	e.KhtmlOpacity	= fp;
	var go = 0;
	try {
		e.filter="Alpha(opacity="+opacity+")";
		go = 1;
		} catch(e) { alert('541: '+e); }
	if (opacity == 100) speed = 5000;
	else speed = 50;
	if (opacity > 0 && go>0) window.setTimeout("fadeout('"+id+"',"+(opacity-1)+","+speed+")", speed);
	}}}

function getPosition(element) {{{
	var elem=element,tagname="",x=0,y=0;
	while ((typeof(elem)=="object")&&(typeof(elem.tagName)!="undefined")) {
		try { y+=elem.offsetTop; } catch(e) { alert('y+=elem.offsetTop;\n'+e); }
		x+=elem.offsetLeft;
		tagname=elem.tagName.toUpperCase();
		if (tagname=="BODY") break;
		if (tagname=="HTML") break;
		elem=elem.offsetParent;
		}
	position=new Object();
	position.x=x;
	position.y=y;
	return position;
	}}}

var events = new function () { this.init = true; }
var eventsCurrent = null;
var eventsDisplay = false;
function eventPersist(e) {{{
	eventPersist_run = true;
	var p = gE('popup-'+e.id);
	var pos = getPosition(e);
	p.style.left	= pos.x+'px';
	p.style.top	= pos.y+'px';
	e.onmouseout = function () { }
	p.onclick=function () {
		p.style.display='none';
		e.onmouseout = function () { eventPopup(e, false); }
		var pos = getPosition(e);
		p.style.left	= (15+pos.x)+'px';
		p.style.top	= (15+pos.y)+'px';
		}
	eventPersist_run = false;
	}}}

function buildLink(url,cnt) {{{
	var a = cE('a');
	a.target='_blank';
	if(url=='KARTENHAUS') {
		a.className='kartenhaus';
		a.href='/kartenhaus.php?id='+cnt;
		return aC(a,cT('tickets jetzt kaufen bei kartenhaus.de'));
		}
	a.href=url;
	return aC(a,cT(url));
	}}}

/* captureMousePosition {{{ */
/*
document.onmousemove = captureMousePosition;
var xMousePos = 0; // Horizontal position of the mouse on the screen
var yMousePos = 0; // Vertical position of the mouse on the screen
var xMousePosMax = 0; // Width of the page
var yMousePosMax = 0; // Height of the page

var one = 1;
function captureMousePosition(e) {{{
	if (document.layers) {
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
		}
	else if (document.all) {
		xMousePos = window.event.x+document.body.scrollLeft;
		yMousePos = window.event.y+document.body.scrollTop;
		xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
		yMousePosMax = document.body.clientHeight+document.body.scrollTop;
		}
	else if (gE) {
		xMousePos = e.pageX;
		yMousePos = e.pageY;
		xMousePosMax = window.innerWidth+window.pageXOffset;
		yMousePosMax = window.innerHeight+window.pageYOffset;
		}
	}}}
*/
/* }}} */

var old_p = null;
function eventPopup(e, display, url) {{{
	eventsDisplay = display;
	eventsCurrent = e;
	if (old_p) old_p.style.display='none';
	if (events[e.id]) {
		if (events[e.id] == 'go') return;
		var p = gE('popup-'+e.id);
		var i = gE('info-'+e.id);
		if (i && i.style.display=='block') return;
		if (!p) {
			var pos = getPosition(e);
			var dat = events[e.id];
			p = cE('div',{'id':'popup-'+e.id});
			p.style.left	= (15+pos.x)+'px';
			p.style.top	= (15+pos.y)+'px';
			old_p = p;
			p.className='popup';
			t = cE('div');
			t.style.fontWeight='bold';
			aC(p,aC(t,cT(dat.TITEL)));
			aC(p,cE('br'));
			if (dat.ADR) {
				if (dat.TYP==2) aC(p,cT(dat.ADR.NAME));
				aC(p,cE('br'));
				var str = '';
				if (dat.ADR.STRASSE) str = str+dat.ADR.STRASSE;
				if (dat.ADR.HAUSNR ) str = str+' '+dat.ADR.HAUSNR;
				if (str != '') aC(p,cT(str));
				aC(p,cE('br'));
				aC(p,cT(dat.ADR.PLZ+' '+dat.ADR.ORT));
				aC(p,cE('br'));
				if (dat.ADR.TELEFON	) { aC(p,cT('Telefon: '	+dat.ADR.TELEFON)); aC(p,cE('br')); }
				if (dat.ADR.FAX		) { aC(p,cT('Fax: '	+dat.ADR.FAX	)); aC(p,cE('br')); }
				}
			if (dat.ANFANG_UHRZEIT != null) aC(p,cT('Start: '+dat.ANFANG_UHRZEIT)); aC(p,cE('br'));
			if (dat.URL) {
				aC(p,cT('Internet: '));
				aC(p,buildLink(dat.URL,dat.ID));
				aC(p,cE('br'));
				}
			aC(gE('body'), p);
			}
		else	old_p = p;
/*
		p.style.left	= (xMousePos)+'px';
		p.style.top	= (yMousePos)+'px';
*/
		p.style.display = (display)?'block':'none';
		if (display) window.setTimeout(function() { p.style.display='none'; }, 4000);
		if(gE('info-'+e.id)) p.style.display='none';
		return;
		}
	events[e.id]='go';
	if (url != null) post(url, 'cnt='+e.id.replace(/...-/,''), cbEventPopup, false);
	}}}
function cbEventPopup(e) {{{
	var x;
	try { eval('x = ('+e+')'); } catch(e) { alert(e); }
	events['cnt-'+x.ID] = x;
	eventPopup(eventsCurrent, eventsDisplay,null);
	}}}

var drop = true;
function dropDown(e) {{{
	e = e.firstChild;
	while(e) {
		if(e.nodeName.toLowerCase()=='div') {
			e.style.display=(!drop)?'none':'block';
			drop = !drop;
			}
		e=e.nextSibling;
		}
	}}}

// Calendar Popup {{{
/* Copyright Mihai Bazon, 2002-2005 | www.bazon.net/mishoo
 * -----------------------------------------------------------
 * The DHTML Calendar, version 1.0 "It is happening again"
 *
 * Details and latest version at:
 * www.dynarch.com/projects/calendar
 *
 * This script is developed by Dynarch.com. Visit us at www.dynarch.com.
 *
 * This script is distributed under the GNU Lesser General Public License.
 * Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
 */
/** The Calendar object constructor. */
Calendar = function (firstDayOfWeek, dateStr, onSelected, onClose) {{{
	this.activeDiv = null;
	this.currentDateEl = null;
	this.getDateStatus = null;
	this.getDateToolTip = null;
	this.getDateText = null;
	this.timeout = null;
	this.onSelected = onSelected || null;
	this.onClose = onClose || null;
	this.dragging = false;
	this.hidden = false;
	this.minYear = 1970;
	this.maxYear = 2050;
	this.dateFormat = Calendar._TT["DEF_DATE_FORMAT"];
	this.ttDateFormat = Calendar._TT["TT_DATE_FORMAT"];
	this.isPopup = true;
	this.weekNumbers = true;
	this.firstDayOfWeek = typeof firstDayOfWeek == "number" ? firstDayOfWeek : Calendar._FD;
	this.showsOtherMonths = false;
	this.dateStr = dateStr;
	this.ar_days = null;
	this.showsTime = false;
	this.time24 = true;
	this.yearStep = 2;
	this.hiliteToday = true;
	this.multiple = null;
	this.table = null;
	this.element = null;
	this.tbody = null;
	this.firstdayname = null;
	this.monthsCombo = null;
	this.yearsCombo = null;
	this.hilitedMonth = null;
	this.activeMonth = null;
	this.hilitedYear = null;
	this.activeYear = null;
	this.dateClicked = false;
	if (typeof Calendar._SDN == "undefined") {
		if (typeof Calendar._SDN_len == "undefined") Calendar._SDN_len = 3;
		var ar = new Array();
		for (var i = 8; i > 0;) ar[--i] = Calendar._DN[i].substr(0, Calendar._SDN_len);
		Calendar._SDN = ar;
		if (typeof Calendar._SMN_len == "undefined") Calendar._SMN_len = 3;
		ar = new Array();
		for (var i = 12; i > 0;) ar[--i] = Calendar._MN[i].substr(0, Calendar._SMN_len);
		Calendar._SMN = ar;
	}
}}};
// ** constants
Calendar._C = null;
Calendar.is_ie = ( /msie/i.test(navigator.userAgent) && !/opera/i.test(navigator.userAgent) );
Calendar.is_ie5 = ( Calendar.is_ie && /msie 5\.0/i.test(navigator.userAgent) );
Calendar.is_opera = /opera/i.test(navigator.userAgent);
Calendar.is_khtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);
// BEGIN: UTILITY FUNCTIONS; beware that these might be moved into a separate library, at some point. {{{
Calendar.getAbsolutePos = function(el) {{{
	var SL = 0, ST = 0;
	var is_div = /^div$/i.test(el.tagName);
	if (is_div && el.scrollLeft) SL = el.scrollLeft;
	if (is_div && el.scrollTop) ST = el.scrollTop;
	var r = { x: el.offsetLeft - SL, y: el.offsetTop - ST };
	if (el.offsetParent) {
		var tmp = this.getAbsolutePos(el.offsetParent);
		r.x += tmp.x;
		r.y += tmp.y;
	}
	return r;
}}};
Calendar.isRelated = function (el, evt) {{{
	var related = evt.relatedTarget;
	if (!related) {
		var type = evt.type;
		if (type == "mouseover") related = evt.fromElement;
		else if (type == "mouseout") related = evt.toElement;
	}
	while (related) {
		if (related == el) return true;
		related = related.parentNode;
	}
	return false;
}}};
Calendar.removeClass = function(el, className) {{{
	if (!(el && el.className)) return;
	var cls = el.className.split(" ");
	var ar = new Array();
	for (var i = cls.length; i > 0;) if (cls[--i] != className) ar[ar.length] = cls[i];
	el.className = ar.join(" ");
}}};
Calendar.addClass = function(el, className) {{{
	Calendar.removeClass(el, className);
	el.className += " " + className;
}}};
// FIXME: the following 2 functions totally suck, are useless and should be replaced immediately.
Calendar.getElement = function(ev) {{{
	var f = Calendar.is_ie ? window.event.srcElement : ev.currentTarget;
	while (f.nodeType != 1 || /^div$/i.test(f.tagName)) f = f.parentNode;
	return f;
	}}};
Calendar.getTargetElement = function(ev) {{{
	var f = Calendar.is_ie ? window.event.srcElement : ev.target;
	while (f.nodeType != 1)
		f = f.parentNode;
	return f;
}}};
Calendar.stopEvent = function(ev) {{{
	ev || (ev = window.event);
	if (Calendar.is_ie) {
		ev.cancelBubble = true;
		ev.returnValue = false;
	} else {
		ev.preventDefault();
		ev.stopPropagation();
	}
	return false;
}}};
Calendar.addEvent = function(el, evname, func) {{{
	if (el.attachEvent) { // IE
		el.attachEvent("on" + evname, func);
	} else if (el.addEventListener) { // Gecko / W3C
		el.addEventListener(evname, func, true);
	} else {
		el["on" + evname] = func;
	}
}}};
Calendar.removeEvent = function(el, evname, func) {{{
	if (el.detachEvent) { // IE
		el.detachEvent("on" + evname, func);
	} else if (el.removeEventListener) { // Gecko / W3C
		el.removeEventListener(evname, func, true);
	} else {
		el["on" + evname] = null;
	}
}}};
Calendar.createElement = function(type, parent) {{{
	var el = null;
	if (document.createElementNS) {
		// use the XHTML namespace; IE won't normally get here unless
		// _they_ "fix" the DOM2 implementation.
		el = document.createElementNS("http://www.w3.org/1999/xhtml", type);
	} else {
		el = cE(type);
	}
	if (typeof parent != "undefined") aC(parent,el);
	return el;
}}};

// END: UTILITY FUNCTIONS }}}
// BEGIN: CALENDAR STATIC FUNCTIONS {{{
/** Internal -- adds a set of events to make some element behave like a button. */
Calendar._add_evs = function(el) {{{
	with (Calendar) {
		addEvent(el, "mouseover", dayMouseOver);
		addEvent(el, "mousedown", dayMouseDown);
		addEvent(el, "mouseout", dayMouseOut);
		if (is_ie) {
			addEvent(el, "dblclick", dayMouseDblClick);
			el.setAttribute("unselectable", true);
		}
	}
}}};
Calendar.findMonth = function(el) {{{
	if (typeof el.month != "undefined") {
		return el;
	} else if (typeof el.parentNode.month != "undefined") {
		return el.parentNode;
	}
	return null;
}}};
Calendar.findYear = function(el) {{{
	if (typeof el.year != "undefined") {
		return el;
	} else if (typeof el.parentNode.year != "undefined") {
		return el.parentNode;
	}
	return null;
}}};
Calendar.showMonthsCombo = function () {{{
	var cal = Calendar._C;
	if (!cal) {
		return false;
	}
	var cal = cal;
	var cd = cal.activeDiv;
	var mc = cal.monthsCombo;
	if (cal.hilitedMonth) {
		Calendar.removeClass(cal.hilitedMonth, "hilite");
	}
	if (cal.activeMonth) {
		Calendar.removeClass(cal.activeMonth, "active");
	}
	var mon = cal.monthsCombo.getElementsByTagName("div")[cal.date.getMonth()];
	Calendar.addClass(mon, "active");
	cal.activeMonth = mon;
	var s = mc.style;
	s.display = "block";
	if (cd.navtype < 0)
		s.left = cd.offsetLeft + "px";
	else {
		var mcw = mc.offsetWidth;
		if (typeof mcw == "undefined")
			// Konqueror brain-dead techniques
			mcw = 50;
		s.left = (cd.offsetLeft + cd.offsetWidth - mcw) + "px";
	}
	s.top = (cd.offsetTop + cd.offsetHeight) + "px";
}}};
Calendar.showYearsCombo = function (fwd) {{{
	var cal = Calendar._C;
	if (!cal) return false;
	var cal = cal;
	var cd = cal.activeDiv;
	var yc = cal.yearsCombo;
	if (cal.hilitedYear) {
		Calendar.removeClass(cal.hilitedYear, "hilite");
	}
	if (cal.activeYear) {
		Calendar.removeClass(cal.activeYear, "active");
	}
	cal.activeYear = null;
	var Y = cal.date.getFullYear() + (fwd ? 1 : -1);
	var yr = yc.firstChild;
	var show = false;
	for (var i = 12; i > 0; --i) {
		if (Y >= cal.minYear && Y <= cal.maxYear) {
			yr.innerHTML = Y;
			yr.year = Y;
			yr.style.display = "block";
			show = true;
		} else {
			yr.style.display = "none";
		}
		yr = yr.nextSibling;
		Y += fwd ? cal.yearStep : -cal.yearStep;
	}
	if (show) {
		var s = yc.style;
		s.display = "block";
		if (cd.navtype < 0)
			s.left = cd.offsetLeft + "px";
		else {
			var ycw = yc.offsetWidth;
			if (typeof ycw == "undefined")
				// Konqueror brain-dead techniques
				ycw = 50;
			s.left = (cd.offsetLeft + cd.offsetWidth - ycw) + "px";
		}
		s.top = (cd.offsetTop + cd.offsetHeight) + "px";
	}
}}};
// event handlers
Calendar.tableMouseUp = function(ev) {{{
	var cal = Calendar._C;
	if (!cal) return false;
	if (cal.timeout) clearTimeout(cal.timeout);
	var el = cal.activeDiv;
	if (!el) return false;
	var target = Calendar.getTargetElement(ev);
	ev || (ev = window.event);
	Calendar.removeClass(el, "active");
	if (target == el || target.parentNode == el) Calendar.cellClick(el, ev);
	var mon = Calendar.findMonth(target);
	var date = null;
	if (mon) {
		date = new Date(cal.date);
		if (mon.month != date.getMonth()) {
			date.setMonth(mon.month);
			cal.setDate(date);
			cal.dateClicked = false;
			cal.callHandler();
		}
	} else {
		var year = Calendar.findYear(target);
		if (year) {
			date = new Date(cal.date);
			if (year.year != date.getFullYear()) {
				date.setFullYear(year.year);
				cal.setDate(date);
				cal.dateClicked = false;
				cal.callHandler();
			}
		}
	}
	with (Calendar) {
		removeEvent(document, "mouseup", tableMouseUp);
		removeEvent(document, "mouseover", tableMouseOver);
		removeEvent(document, "mousemove", tableMouseOver);
		cal._hideCombos();
		_C = null;
		return stopEvent(ev);
	}
}}};
Calendar.tableMouseOver = function (ev) {{{
	var cal = Calendar._C;
	if (!cal) return;
	var el = cal.activeDiv;
	var target = Calendar.getTargetElement(ev);
	if (target == el || target.parentNode == el) {
		Calendar.addClass(el, "hilite active");
		Calendar.addClass(el.parentNode, "rowhilite");
	} else {
		if (typeof el.navtype == "undefined" || (el.navtype != 50 && (el.navtype == 0 || Math.abs(el.navtype) > 2))) Calendar.removeClass(el, "active");
		Calendar.removeClass(el, "hilite");
		Calendar.removeClass(el.parentNode, "rowhilite");
	}
	ev || (ev = window.event);
	if (el.navtype == 50 && target != el) {
		var pos = Calendar.getAbsolutePos(el);
		var w = el.offsetWidth;
		var x = ev.clientX;
		var dx;
		var decrease = true;
		if (x > pos.x + w) {
			dx = x - pos.x - w;
			decrease = false;
		} else
			dx = pos.x - x;

		if (dx < 0) dx = 0;
		var range = el._range;
		var current = el._current;
		var count = Math.floor(dx / 10) % range.length;
		for (var i = range.length; --i >= 0;)
			if (range[i] == current) break;
		while (count-- > 0)
			if (decrease) {
				if (--i < 0)
					i = range.length - 1;
			} else if ( ++i >= range.length )
				i = 0;
		var newval = range[i];
		el.innerHTML = newval;
		cal.onUpdateTime();
	}
	var mon = Calendar.findMonth(target);
	if (mon) {
		if (mon.month != cal.date.getMonth()) {
			if (cal.hilitedMonth) Calendar.removeClass(cal.hilitedMonth, "hilite");
			Calendar.addClass(mon, "hilite");
			cal.hilitedMonth = mon;
		} else if (cal.hilitedMonth) {
			Calendar.removeClass(cal.hilitedMonth, "hilite");
		}
	} else {
		if (cal.hilitedMonth) Calendar.removeClass(cal.hilitedMonth, "hilite");
		var year = Calendar.findYear(target);
		if (year) {
			if (year.year != cal.date.getFullYear()) {
				if (cal.hilitedYear) Calendar.removeClass(cal.hilitedYear, "hilite");
				Calendar.addClass(year, "hilite");
				cal.hilitedYear = year;
			} else if (cal.hilitedYear) {
				Calendar.removeClass(cal.hilitedYear, "hilite");
			}
		} else if (cal.hilitedYear) {
			Calendar.removeClass(cal.hilitedYear, "hilite");
		}
	}
	return Calendar.stopEvent(ev);
}}};
Calendar.tableMouseDown = function (ev) { if (Calendar.getTargetElement(ev) == Calendar.getElement(ev)) return Calendar.stopEvent(ev); }
Calendar.calDragIt = function (ev) {{{
	var cal = Calendar._C;
	if (!(cal && cal.dragging)) return false;
	var posX;
	var posY;
	if (Calendar.is_ie) {
		posY = window.event.clientY + document.body.scrollTop;
		posX = window.event.clientX + document.body.scrollLeft;
	} else {
		posX = ev.pageX;
		posY = ev.pageY;
	}
	cal.hideShowCovered();
	var st = cal.element.style;
	st.left = (posX - cal.xOffs) + "px";
	st.top = (posY - cal.yOffs) + "px";
	return Calendar.stopEvent(ev);
}}};
Calendar.calDragEnd = function (ev) {{{
	var cal = Calendar._C;
	if (!cal) return false;
	cal.dragging = false;
	with (Calendar) {
		removeEvent(document, "mousemove", calDragIt);
		removeEvent(document, "mouseup", calDragEnd);
		tableMouseUp(ev);
	}
	cal.hideShowCovered();
}}};
Calendar.dayMouseDown = function(ev) {{{
	var el = Calendar.getElement(ev);
	if (el.disabled) return false;
	var cal = el.calendar;
	cal.activeDiv = el;
	Calendar._C = cal;
	if (el.navtype != 300) with (Calendar) {
		if (el.navtype == 50) {
			el._current = el.innerHTML;
			addEvent(document, "mousemove", tableMouseOver);
		} else
			addEvent(document, Calendar.is_ie5 ? "mousemove" : "mouseover", tableMouseOver);
		addClass(el, "hilite active");
		addEvent(document, "mouseup", tableMouseUp);
	} else if (cal.isPopup) {
		cal._dragStart(ev);
	}
	if (el.navtype == -1 || el.navtype == 1) {
		if (cal.timeout) clearTimeout(cal.timeout);
		cal.timeout = setTimeout("Calendar.showMonthsCombo()", 250);
	} else if (el.navtype == -2 || el.navtype == 2) {
		if (cal.timeout) clearTimeout(cal.timeout);
		cal.timeout = setTimeout((el.navtype > 0) ? "Calendar.showYearsCombo(true)" : "Calendar.showYearsCombo(false)", 250);
	} else {
		cal.timeout = null;
	}
	return Calendar.stopEvent(ev);
}}};
Calendar.dayMouseDblClick = function(ev) {{{
	Calendar.cellClick(Calendar.getElement(ev), ev || window.event);
	if (Calendar.is_ie) {
		document.selection.empty();
	}
}}};
Calendar.dayMouseOver = function(ev) {{{
	var el = Calendar.getElement(ev);
	if (Calendar.isRelated(el, ev) || Calendar._C || el.disabled) {
		return false;
	}
	if (el.ttip) {
		if (el.ttip.substr(0, 1) == "_") {
			el.ttip = el.caldate.print(el.calendar.ttDateFormat) + el.ttip.substr(1);
		}
		el.calendar.tooltips.innerHTML = el.ttip;
	}
	if (el.navtype != 300) {
		Calendar.addClass(el, "hilite");
		if (el.caldate) {
			Calendar.addClass(el.parentNode, "rowhilite");
		}
	}
	return Calendar.stopEvent(ev);
}}};
Calendar.dayMouseOut = function(ev) {{{
	with (Calendar) {
		var el = getElement(ev);
		if (isRelated(el, ev) || _C || el.disabled)
			return false;
		removeClass(el, "hilite");
		if (el.caldate)
			removeClass(el.parentNode, "rowhilite");
		if (el.calendar)
			el.calendar.tooltips.innerHTML = _TT["SEL_DATE"];
		return stopEvent(ev);
	}
}}};
/* A generic "click" handler :) handles all types of buttons defined in this calendar. */
Calendar.cellClick = function(el, ev) {{{
	var cal = el.calendar;
	var closing = false;
	var newdate = false;
	var date = null;
	if (typeof el.navtype == "undefined") {
		if (cal.currentDateEl) {
			Calendar.removeClass(cal.currentDateEl, "selected");
			Calendar.addClass(el, "selected");
			closing = (cal.currentDateEl == el);
			if (!closing) {
				cal.currentDateEl = el;
			}
		}
		cal.date.setDateOnly(el.caldate);
		date = cal.date;
		var other_month = !(cal.dateClicked = !el.otherMonth);
		if (!other_month && !cal.currentDateEl)
			cal._toggleMultipleDate(new Date(date));
		else
			newdate = !el.disabled;
		// a date was clicked
		if (other_month)
			cal._init(cal.firstDayOfWeek, date);
	} else {
		if (el.navtype == 200) {
			Calendar.removeClass(el, "hilite");
			cal.callCloseHandler();
			return;
		}
		date = new Date(cal.date);
		if (el.navtype == 0)
			date.setDateOnly(new Date()); // TODAY
		// unless "today" was clicked, we assume no date was clicked so
		// the selected handler will know not to close the calenar when
		// in single-click mode.
		// cal.dateClicked = (el.navtype == 0);
		cal.dateClicked = false;
		var year = date.getFullYear();
		var mon = date.getMonth();
		function setMonth(m) {
			var day = date.getDate();
			var max = date.getMonthDays(m);
			if (day > max) {
				date.setDate(max);
			}
			date.setMonth(m);
		};
		switch (el.navtype) {
		case 400:
			Calendar.removeClass(el, "hilite");
			var text = Calendar._TT["ABOUT"];
			if (typeof text != "undefined") {
				text += cal.showsTime ? Calendar._TT["ABOUT_TIME"] : "";
			} else {
				// FIXME: this should be removed as soon as lang files get updated!
				text = "Help and about box text is not translated into this language.\n" +
					"If you know this language and you feel generous please update\n" +
					"the corresponding file in \"lang\" subdir to match calendar-en.js\n" +
					"and send it back to <mihai_bazon@yahoo.com> to get it into the distribution ;-)\n\n" +
					"Thank you!\n" +
					"http://dynarch.com/mishoo/calendar.epl\n";
			}
			alert(text);
			return;
		case -2:
			if (year > cal.minYear) {
				date.setFullYear(year - 1);
			}
			break;
		case -1:
			if (mon > 0) {
				setMonth(mon - 1);
			} else if (year-- > cal.minYear) {
				date.setFullYear(year);
				setMonth(11);
			}
			break;
		case 1:
			if (mon < 11) {
				setMonth(mon + 1);
			} else if (year < cal.maxYear) {
				date.setFullYear(year + 1);
				setMonth(0);
			}
			break;
		case 2:
			if (year < cal.maxYear) {
				date.setFullYear(year + 1);
			}
			break;
		case 100:
			cal.setFirstDayOfWeek(el.fdow);
			return;
		case 50:
			var range = el._range;
			var current = el.innerHTML;
			for (var i = range.length; --i >= 0;)
				if (range[i] == current)
					break;
			if (ev && ev.shiftKey) {
				if (--i < 0)
					i = range.length - 1;
			} else if ( ++i >= range.length )
				i = 0;
			var newval = range[i];
			el.innerHTML = newval;
			cal.onUpdateTime();
			return;
		case 0:
			// TODAY will bring us here
			if ((typeof cal.getDateStatus == "function") && cal.getDateStatus(date, date.getFullYear(), date.getMonth(), date.getDate())) return false;
			break;
		}
		if (!date.equalsTo(cal.date)) {
			cal.setDate(date);
			newdate = true;
		} else if (el.navtype == 0)
			newdate = closing = true;
	}
	if (newdate) {
		ev && cal.callHandler();
	}
	if (closing) {
		Calendar.removeClass(el, "hilite");
		ev && cal.callCloseHandler();
	}
}}};
// END: CALENDAR STATIC FUNCTIONS }}}
Calendar.prototype.create = function (_par) {{{
	var parent = null;
	if (! _par) {
		// default parent is the document body, in which case we create
		// a popup calendar.
		parent = document.getElementsByTagName("body")[0];
		this.isPopup = true;
	} else {
		parent = _par;
		this.isPopup = false;
	}
	this.date = this.dateStr ? new Date(this.dateStr) : new Date();

	var table = Calendar.createElement("table");
	this.table = table;
	table.cellSpacing = 0;
	table.cellPadding = 0;
	table.calendar = this;
	Calendar.addEvent(table, "mousedown", Calendar.tableMouseDown);

	var div = Calendar.createElement("div");
	this.element = div;
	div.className = "calendar";
	if (this.isPopup) {
		div.style.position = "absolute";
		div.style.display = "none";
	}
	aC(div,table);

	var thead = Calendar.createElement("thead", table);
	var cell = null;
	var row = null;

	var cal = this;
	var hh = function (text, cs, navtype) {
		cell = Calendar.createElement("td", row);
		cell.colSpan = cs;
		cell.className = "button";
		if (navtype != 0 && Math.abs(navtype) <= 2)
			cell.className += " nav";
		Calendar._add_evs(cell);
		cell.calendar = cal;
		cell.navtype = navtype;
		cell.innerHTML = "<div unselectable='on'>" + text + "</div>";
		return cell;
	};

	row = Calendar.createElement("tr", thead);
	var title_length = 6;
	(this.isPopup) && --title_length;
	(this.weekNumbers) && ++title_length;

	hh("?", 1, 400).ttip = Calendar._TT["INFO"];
	this.title = hh("", title_length, 300);
	this.title.className = "title";
	if (this.isPopup) {
		this.title.ttip = Calendar._TT["DRAG_TO_MOVE"];
		this.title.style.cursor = "move";
		hh("&#x00d7;", 1, 200).ttip = Calendar._TT["CLOSE"];
	}

	row = Calendar.createElement("tr", thead);
	row.className = "headrow";

	this._nav_py = hh("&#x00ab;", 1, -2);
	this._nav_py.ttip = Calendar._TT["PREV_YEAR"];

	this._nav_pm = hh("&#x2039;", 1, -1);
	this._nav_pm.ttip = Calendar._TT["PREV_MONTH"];

	this._nav_now = hh(Calendar._TT["TODAY"], this.weekNumbers ? 4 : 3, 0);
	this._nav_now.ttip = Calendar._TT["GO_TODAY"];

	this._nav_nm = hh("&#x203a;", 1, 1);
	this._nav_nm.ttip = Calendar._TT["NEXT_MONTH"];

	this._nav_ny = hh("&#x00bb;", 1, 2);
	this._nav_ny.ttip = Calendar._TT["NEXT_YEAR"];

	// day names
	row = Calendar.createElement("tr", thead);
	row.className = "daynames";
	if (this.weekNumbers) {
		cell = Calendar.createElement("td", row);
		cell.className = "name wn";
		cell.innerHTML = Calendar._TT["WK"];
	}
	for (var i = 7; i > 0; --i) {
		cell = Calendar.createElement("td", row);
		if (!i) {
			cell.navtype = 100;
			cell.calendar = this;
			Calendar._add_evs(cell);
		}
	}
	this.firstdayname = (this.weekNumbers) ? row.firstChild.nextSibling : row.firstChild;
	this._displayWeekdays();

	var tbody = Calendar.createElement("tbody", table);
	this.tbody = tbody;

	for (i = 6; i > 0; --i) {
		row = Calendar.createElement("tr", tbody);
		if (this.weekNumbers) {
			cell = Calendar.createElement("td", row);
		}
		for (var j = 7; j > 0; --j) {
			cell = Calendar.createElement("td", row);
			cell.calendar = this;
			Calendar._add_evs(cell);
		}
	}

	if (this.showsTime) {
		row = Calendar.createElement("tr", tbody);
		row.className = "time";

		cell = Calendar.createElement("td", row);
		cell.className = "time";
		cell.colSpan = 2;
		cell.innerHTML = Calendar._TT["TIME"] || "&nbsp;";

		cell = Calendar.createElement("td", row);
		cell.className = "time";
		cell.colSpan = this.weekNumbers ? 4 : 3;

		(function(){
			function makeTimePart(className, init, range_start, range_end) {
				var part = Calendar.createElement("span", cell);
				part.className = className;
				part.innerHTML = init;
				part.calendar = cal;
				part.ttip = Calendar._TT["TIME_PART"];
				part.navtype = 50;
				part._range = [];
				if (typeof range_start != "number")
					part._range = range_start;
				else {
					for (var i = range_start; i <= range_end; ++i) {
						var txt;
						if (i < 10 && range_end >= 10) txt = '0' + i;
						else txt = '' + i;
						part._range[part._range.length] = txt;
					}
				}
				Calendar._add_evs(part);
				return part;
			};
			var hrs = cal.date.getHours();
			var mins = cal.date.getMinutes();
			var t12 = !cal.time24;
			var pm = (hrs > 12);
			if (t12 && pm) hrs -= 12;
			var H = makeTimePart("hour", hrs, t12 ? 1 : 0, t12 ? 12 : 23);
			var span = Calendar.createElement("span", cell);
			span.innerHTML = ":";
			span.className = "colon";
			var M = makeTimePart("minute", mins, 0, 59);
			var AP = null;
			cell = Calendar.createElement("td", row);
			cell.className = "time";
			cell.colSpan = 2;
			if (t12)
				AP = makeTimePart("ampm", pm ? "pm" : "am", ["am", "pm"]);
			else
				cell.innerHTML = "&nbsp;";

			cal.onSetTime = function() {
				var pm, hrs = this.date.getHours(),
					mins = this.date.getMinutes();
				if (t12) {
					pm = (hrs >= 12);
					if (pm) hrs -= 12;
					if (hrs == 0) hrs = 12;
					AP.innerHTML = pm ? "pm" : "am";
				}
				H.innerHTML = (hrs < 10) ? ("0" + hrs) : hrs;
				M.innerHTML = (mins < 10) ? ("0" + mins) : mins;
			};

			cal.onUpdateTime = function() {
				var date = this.date;
				var h = parseInt(H.innerHTML, 10);
				if (t12) {
					if (/pm/i.test(AP.innerHTML) && h < 12)
						h += 12;
					else if (/am/i.test(AP.innerHTML) && h == 12)
						h = 0;
				}
				var d = date.getDate();
				var m = date.getMonth();
				var y = date.getFullYear();
				date.setHours(h);
				date.setMinutes(parseInt(M.innerHTML, 10));
				date.setFullYear(y);
				date.setMonth(m);
				date.setDate(d);
				this.dateClicked = false;
				this.callHandler();
			};
		})();
	} else {
		this.onSetTime = this.onUpdateTime = function() {};
	}

	var tfoot = Calendar.createElement("tfoot", table);

	row = Calendar.createElement("tr", tfoot);
	row.className = "footrow";

	cell = hh(Calendar._TT["SEL_DATE"], this.weekNumbers ? 8 : 7, 300);
	cell.className = "ttip";
	if (this.isPopup) {
		cell.ttip = Calendar._TT["DRAG_TO_MOVE"];
		cell.style.cursor = "move";
	}
	this.tooltips = cell;

	div = Calendar.createElement("div", this.element);
	this.monthsCombo = div;
	div.className = "combo";
	for (i = 0; i < Calendar._MN.length; ++i) {
		var mn = Calendar.createElement("div");
		mn.className = Calendar.is_ie ? "label-IEfix" : "label";
		mn.month = i;
		mn.innerHTML = Calendar._SMN[i];
		aC(div,mn);
	}

	div = Calendar.createElement("div", this.element);
	this.yearsCombo = div;
	div.className = "combo";
	for (i = 12; i > 0; --i) {
		var yr = Calendar.createElement("div");
		yr.className = Calendar.is_ie ? "label-IEfix" : "label";
		aC(div,yr);
	}

	this._init(this.firstDayOfWeek, this.date);
	aC(parent,this.element);
}}};
Calendar._keyEvent = function(ev) {{{
	var cal = window._dynarch_popupCalendar;
	if (!cal || cal.multiple)
		return false;
	(Calendar.is_ie) && (ev = window.event);
	var act = (Calendar.is_ie || ev.type == "keypress"),
		K = ev.keyCode;
	if (ev.ctrlKey) {
		switch (K) {
		case 37: act && Calendar.cellClick(cal._nav_pm); break;	// KEY left
		case 38: act && Calendar.cellClick(cal._nav_py); break; // KEY up
		case 39: act && Calendar.cellClick(cal._nav_nm); break; // KEY right
		case 40: act && Calendar.cellClick(cal._nav_ny); break; // KEY down
		default: return false;
		}
	} else switch (K) {
		case 32: Calendar.cellClick(cal._nav_now); break; // KEY space (now)
		case 27: act && cal.callCloseHandler(); break; // KEY esc
		case 37: // KEY left
		case 38: // KEY up
		case 39: // KEY right
		case 40: // KEY down
		if (act) {
			var prev, x, y, ne, el, step;
			prev = K == 37 || K == 38;
			step = (K == 37 || K == 39) ? 1 : 7;
			function setVars() {
				el = cal.currentDateEl;
				var p = el.pos;
				x = p & 15;
				y = p >> 4;
				ne = cal.ar_days[y][x];
			};setVars();
			function prevMonth() {
				var date = new Date(cal.date);
				date.setDate(date.getDate() - step);
				cal.setDate(date);
			};
			function nextMonth() {
				var date = new Date(cal.date);
				date.setDate(date.getDate() + step);
				cal.setDate(date);
			};
			while (1) {
				switch (K) {
				case 37: if (--x >= 0) ne = cal.ar_days[y][x]; else { x = 6; K = 38; continue; } break; // KEY left
				case 38: if (--y >= 0) ne = cal.ar_days[y][x]; else { prevMonth(); setVars(); } break; // KEY up
				case 39: if (++x < 7) ne = cal.ar_days[y][x]; else { x = 0; K = 40; continue; } break; // KEY right
				case 40: if (++y < cal.ar_days.length) ne = cal.ar_days[y][x]; else { nextMonth(); setVars(); } break; // KEY down
				}
				break;
			}
			if (ne) {
				if (!ne.disabled) Calendar.cellClick(ne);
				else if (prev) prevMonth();
				else nextMonth();
			}
		}
		break;
	case 13: if (act) Calendar.cellClick(cal.currentDateEl, ev); break; // KEY enter
	default: return false;
	}
	return Calendar.stopEvent(ev);
}}};
Calendar.prototype._init = function (firstDayOfWeek, date) {{{
	var today = new Date(),
		TY = today.getFullYear(),
		TM = today.getMonth(),
		TD = today.getDate();
	this.table.style.visibility = "hidden";
	var year = date.getFullYear();
	if (year < this.minYear) {
		year = this.minYear;
		date.setFullYear(year);
	} else if (year > this.maxYear) {
		year = this.maxYear;
		date.setFullYear(year);
	}
	this.firstDayOfWeek = firstDayOfWeek;
	this.date = new Date(date);
	var month = date.getMonth();
	var mday = date.getDate();
	var no_days = date.getMonthDays();

	// calendar voodoo for computing the first day that would actually be
	// displayed in the calendar, even if it's from the previous month.
	// WARNING: this is magic. ;-)
	date.setDate(1);
	var day1 = (date.getDay() - this.firstDayOfWeek) % 7;
	if (day1 < 0)
		day1 += 7;
	date.setDate(-day1);
	date.setDate(date.getDate() + 1);

	var row = this.tbody.firstChild;
	var MN = Calendar._SMN[month];
	var ar_days = this.ar_days = new Array();
	var weekend = Calendar._TT["WEEKEND"];
	var dates = this.multiple ? (this.datesCells = {}) : null;
	for (var i = 0; i < 6; ++i, row = row.nextSibling) {
		var cell = row.firstChild;
		if (this.weekNumbers) {
			cell.className = "day wn";
			cell.innerHTML = date.getWeekNumber();
			cell = cell.nextSibling;
		}
		row.className = "daysrow";
		var hasdays = false, iday, dpos = ar_days[i] = [];
		for (var j = 0; j < 7; ++j, cell = cell.nextSibling, date.setDate(iday + 1)) {
			iday = date.getDate();
			var wday = date.getDay();
			cell.className = "day";
			cell.pos = i << 4 | j;
			dpos[j] = cell;
			var current_month = (date.getMonth() == month);
			if (!current_month) {
				if (this.showsOtherMonths) {
					cell.className += " othermonth";
					cell.otherMonth = true;
				} else {
					cell.className = "emptycell";
					cell.innerHTML = "&nbsp;";
					cell.disabled = true;
					continue;
				}
			} else {
				cell.otherMonth = false;
				hasdays = true;
			}
			cell.disabled = false;
			cell.innerHTML = this.getDateText ? this.getDateText(date, iday) : iday;
			if (dates)
				dates[date.print("%Y%m%d")] = cell;
			if (this.getDateStatus) {
				var status = this.getDateStatus(date, year, month, iday);
				if (this.getDateToolTip) {
					var toolTip = this.getDateToolTip(date, year, month, iday);
					if (toolTip)
						cell.title = toolTip;
				}
				if (status === true) {
					cell.className += " disabled";
					cell.disabled = true;
				} else {
					if (/disabled/i.test(status))
						cell.disabled = true;
					cell.className += " " + status;
				}
			}
			if (!cell.disabled) {
				cell.caldate = new Date(date);
				cell.ttip = "_";
				if (!this.multiple && current_month && iday == mday && this.hiliteToday) {
					cell.className += " selected";
					this.currentDateEl = cell;
				}
				if (date.getFullYear() == TY && date.getMonth() == TM && iday == TD) {
					cell.className += " today";
					cell.ttip += Calendar._TT["PART_TODAY"];
				}
				if (weekend.indexOf(wday.toString()) != -1)
					cell.className += cell.otherMonth ? " oweekend" : " weekend";
			}
		}
		if (!(hasdays || this.showsOtherMonths))
			row.className = "emptyrow";
	}
	this.title.innerHTML = Calendar._MN[month] + ", " + year;
	this.onSetTime();
	this.table.style.visibility = "visible";
	this._initMultipleDates();
	// PROFILE
	// this.tooltips.innerHTML = "Generated in " + ((new Date()) - today) + " ms";
}}};
Calendar.prototype._initMultipleDates = function() {{{
	if (this.multiple) {
		for (var i in this.multiple) {
			var cell = this.datesCells[i];
			var d = this.multiple[i];
			if (!d)
				continue;
			if (cell)
				cell.className += " selected";
		}
	}
}}};
Calendar.prototype._toggleMultipleDate = function(date) {{{
	if (this.multiple) {
		var ds = date.print("%Y%m%d");
		var cell = this.datesCells[ds];
		if (cell) {
			var d = this.multiple[ds];
			if (!d) {
				Calendar.addClass(cell, "selected");
				this.multiple[ds] = date;
			} else {
				Calendar.removeClass(cell, "selected");
				delete this.multiple[ds];
			}
		}
	}
}}};
Calendar.prototype.setDateToolTipHandler = function (unaryFunction) { this.getDateToolTip = unaryFunction; }
Calendar.prototype.setDate = function (d) { if (!d.equalsTo(this.date)) this._init(this.firstDayOfWeek, d); }
Calendar.prototype.refresh = function () { this._init(this.firstDayOfWeek, this.date); }
Calendar.prototype.setFirstDayOfWeek = function (firstDayOfWeek) {{{
	this._init(firstDayOfWeek, this.date);
	this._displayWeekdays();
}}};
Calendar.prototype.setDateStatusHandler = Calendar.prototype.setDisabledHandler = function (unaryFunction) {{{
	this.getDateStatus = unaryFunction;
}}};
Calendar.prototype.setRange = function (a, z) {{{
	this.minYear = a;
	this.maxYear = z;
}}};
Calendar.prototype.callHandler = function () { if (this.onSelected) this.onSelected(this, this.date.print(this.dateFormat)); }
Calendar.prototype.callCloseHandler = function () {{{
	if (this.onClose) this.onClose(this);
	this.hideShowCovered();
}}};
Calendar.prototype.destroy = function () {{{
	var el = this.element.parentNode;
	el.removeChild(this.element);
	Calendar._C = null;
	window._dynarch_popupCalendar = null;
}}};
Calendar.prototype.reparent = function (new_parent) {{{
	var el = this.element;
	el.parentNode.removeChild(el);
	aC(new_parent,el);
}}};
Calendar._checkCalendar = function(ev) {{{
	var calendar = window._dynarch_popupCalendar;
	if (!calendar) {
		return false;
	}
	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
	for (; el != null && el != calendar.element; el = el.parentNode);
	if (el == null) {
		// calls closeHandler which should hide the calendar.
		window._dynarch_popupCalendar.callCloseHandler();
		return Calendar.stopEvent(ev);
	}
}}};
Calendar.prototype.show = function () {{{
	var rows = this.table.getElementsByTagName("tr");
	for (var i = rows.length; i > 0;) {
		var row = rows[--i];
		Calendar.removeClass(row, "rowhilite");
		var cells = row.getElementsByTagName("td");
		for (var j = cells.length; j > 0;) {
			var cell = cells[--j];
			Calendar.removeClass(cell, "hilite");
			Calendar.removeClass(cell, "active");
		}
	}
	this.element.style.display = "block";
	this.hidden = false;
	if (this.isPopup) {
		window._dynarch_popupCalendar = this;
		Calendar.addEvent(document, "keydown", Calendar._keyEvent);
		Calendar.addEvent(document, "keypress", Calendar._keyEvent);
		Calendar.addEvent(document, "mousedown", Calendar._checkCalendar);
	}
	this.hideShowCovered();
}}};
Calendar.prototype.hide = function () {{{
	if (this.isPopup) {
		Calendar.removeEvent(document, "keydown", Calendar._keyEvent);
		Calendar.removeEvent(document, "keypress", Calendar._keyEvent);
		Calendar.removeEvent(document, "mousedown", Calendar._checkCalendar);
	}
	this.element.style.display = "none";
	this.hidden = true;
	this.hideShowCovered();
}}};
Calendar.prototype.showAt = function (x, y) {{{
	var s = this.element.style;
	s.left = x + "px";
	s.top = y + "px";
	this.show();
}}};
Calendar.prototype.showAtElement = function (el, opts) {{{
	var self = this;
	var p = Calendar.getAbsolutePos(el);
	if (!opts || typeof opts != "string") {
		this.showAt(p.x, p.y + el.offsetHeight);
		return true;
	}
	function fixPosition(box) {
		if (box.x < 0)
			box.x = 0;
		if (box.y < 0)
			box.y = 0;
		var cp = cE("div");
		var s = cp.style;
		s.position = "absolute";
		s.right = s.bottom = s.width = s.height = "0px";
		aC(document.body,cp);
		var br = Calendar.getAbsolutePos(cp);
		document.body.removeChild(cp);
		if (Calendar.is_ie) {
			br.y += document.body.scrollTop;
			br.x += document.body.scrollLeft;
		} else {
			br.y += window.scrollY;
			br.x += window.scrollX;
		}
		var tmp = box.x + box.width - br.x;
		if (tmp > 0) box.x -= tmp;
		tmp = box.y + box.height - br.y;
		if (tmp > 0) box.y -= tmp;
	};
	this.element.style.display = "block";
	Calendar.continuation_for_the_fucking_khtml_browser = function() {
		var w = self.element.offsetWidth;
		var h = self.element.offsetHeight;
		self.element.style.display = "none";
		var valign = opts.substr(0, 1);
		var halign = "l";
		if (opts.length > 1) {
			halign = opts.substr(1, 1);
		}
		// vertical alignment
		switch (valign) {
		case "T": p.y -= h; break;
		case "B": p.y += el.offsetHeight; break;
		case "C": p.y += (el.offsetHeight - h) / 2; break;
		case "t": p.y += el.offsetHeight - h; break;
		case "b": break; // already there
		}
		// horizontal alignment
		switch (halign) {
		case "L": p.x -= w; break;
		case "R": p.x += el.offsetWidth; break;
		case "C": p.x += (el.offsetWidth - w) / 2; break;
		case "l": p.x += el.offsetWidth - w; break;
		case "r": break; // already there
		}
		p.width = w;
		p.height = h + 40;
		self.monthsCombo.style.display = "none";
		fixPosition(p);
		self.showAt(p.x, p.y);
	};
	if (Calendar.is_khtml)
		setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()", 10);
	else
		Calendar.continuation_for_the_fucking_khtml_browser();
}}};
Calendar.prototype.setDateFormat = function (str) { this.dateFormat = str; }
Calendar.prototype.setTtDateFormat = function (str) { this.ttDateFormat = str; }
Calendar.prototype.parseDate = function(str, fmt) {{{
	if (!fmt) fmt = this.dateFormat;
	this.setDate(Date.parseDate(str, fmt));
}}};
Calendar.prototype.hideShowCovered = function () {{{
	if (!Calendar.is_ie && !Calendar.is_opera)
		return;
	function getVisib(obj){
		var value = obj.style.visibility;
		if (!value) {
			if (document.defaultView && typeof (document.defaultView.getComputedStyle) == "function") { // Gecko, W3C
				if (!Calendar.is_khtml)
					value = document.defaultView.
						getComputedStyle(obj, "").getPropertyValue("visibility");
				else
					value = '';
			} else if (obj.currentStyle) { // IE
				value = obj.currentStyle.visibility;
			} else
				value = '';
		}
		return value;
	};
	var tags = new Array("applet", "iframe", "select");
	var el = this.element;
	var p = Calendar.getAbsolutePos(el);
	var EX1 = p.x;
	var EX2 = el.offsetWidth + EX1;
	var EY1 = p.y;
	var EY2 = el.offsetHeight + EY1;
	for (var k = tags.length; k > 0; ) {
		var ar = document.getElementsByTagName(tags[--k]);
		var cc = null;
		for (var i = ar.length; i > 0;) {
			cc = ar[--i];
			p = Calendar.getAbsolutePos(cc);
			var CX1 = p.x;
			var CX2 = cc.offsetWidth + CX1;
			var CY1 = p.y;
			var CY2 = cc.offsetHeight + CY1;
			if (this.hidden || (CX1 > EX2) || (CX2 < EX1) || (CY1 > EY2) || (CY2 < EY1)) {
				if (!cc.__msh_save_visibility) cc.__msh_save_visibility = getVisib(cc);
				cc.style.visibility = cc.__msh_save_visibility;
			} else {
				if (!cc.__msh_save_visibility) cc.__msh_save_visibility = getVisib(cc);
				cc.style.visibility = "hidden";
			}
		}
	}
}}};
Calendar.prototype._displayWeekdays = function () {{{
	var fdow = this.firstDayOfWeek;
	var cell = this.firstdayname;
	var weekend = Calendar._TT["WEEKEND"];
	for (var i = 0; i < 7; ++i) {
		cell.className = "day name";
		var realday = (i + fdow) % 7;
		if (i) {
			cell.ttip = Calendar._TT["DAY_FIRST"].replace("%s", Calendar._DN[realday]);
			cell.navtype = 100;
			cell.calendar = this;
			cell.fdow = realday;
			Calendar._add_evs(cell);
		}
		if (weekend.indexOf(realday.toString()) != -1) {
			Calendar.addClass(cell, "weekend");
		}
		cell.innerHTML = Calendar._SDN[(i + fdow) % 7];
		cell = cell.nextSibling;
	}
}}};
Calendar.prototype._hideCombos = function () {{{
	this.monthsCombo.style.display = "none";
	this.yearsCombo.style.display = "none";
}}};
Calendar.prototype._dragStart = function (ev) {{{
	if (this.dragging) {
		return;
	}
	this.dragging = true;
	var posX;
	var posY;
	if (Calendar.is_ie) {
		posY = window.event.clientY + document.body.scrollTop;
		posX = window.event.clientX + document.body.scrollLeft;
	} else {
		posY = ev.clientY + window.scrollY;
		posX = ev.clientX + window.scrollX;
	}
	var st = this.element.style;
	this.xOffs = posX - parseInt(st.left);
	this.yOffs = posY - parseInt(st.top);
	with (Calendar) {
		addEvent(document, "mousemove", calDragIt);
		addEvent(document, "mouseup", calDragEnd);
	}
}}};
// {{{ Localisation
Calendar._DN = new Array ("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag");
Calendar._SDN = new Array ("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa", "So");
Calendar._MN = new Array ("Januar", "Februar", "M\u00e4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember");
Calendar._SMN = new Array ("Jan", "Feb", "M\u00e4r", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez");
// tooltips
Calendar._TT = {};
Calendar._TT["INFO"] = "\u00DCber dieses Kalendarmodul";
Calendar._TT["ABOUT"] =
"DHTML Date/Time Selector\n" +
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" +
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
"Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." +
"\n\n" +
"Datum ausw\u00e4hlen:\n" +
"- Benutzen Sie die \xab, \xbb Buttons um das Jahr zu w\u00e4hlen\n" +
"- Benutzen Sie die " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " Buttons um den Monat zu w\u00e4hlen\n" +
"- F\u00fcr eine Schnellauswahl halten Sie die Maustaste \u00fcber diesen Buttons fest.";
Calendar._TT["ABOUT_TIME"] = "\n\n" +
"Zeit ausw\u00e4hlen:\n" +
"- Klicken Sie auf die Teile der Uhrzeit, um diese zu erh\u00F6hen\n" +
"- oder klicken Sie mit festgehaltener Shift-Taste um diese zu verringern\n" +
"- oder klicken und festhalten f\u00fcr Schnellauswahl.";
Calendar._TT["TOGGLE"] = "Ersten Tag der Woche w\u00e4hlen";
Calendar._TT["PREV_YEAR"] = "Voriges Jahr (Festhalten f\u00fcr Schnellauswahl)";
Calendar._TT["PREV_MONTH"] = "Voriger Monat (Festhalten f\u00fcr Schnellauswahl)";
Calendar._TT["GO_TODAY"] = "Heute ausw\u00e4hlen";
Calendar._TT["NEXT_MONTH"] = "N\u00e4chst. Monat (Festhalten f\u00fcr Schnellauswahl)";
Calendar._TT["NEXT_YEAR"] = "N\u00e4chst. Jahr (Festhalten f\u00fcr Schnellauswahl)";
Calendar._TT["SEL_DATE"] = "Datum ausw\u00e4hlen";
Calendar._TT["DRAG_TO_MOVE"] = "Zum Bewegen festhalten";
Calendar._TT["PART_TODAY"] = " (Heute)";
Calendar._TT["DAY_FIRST"] = "Woche beginnt mit %s ";
Calendar._TT["WEEKEND"] = "0,6";
Calendar._TT["CLOSE"] = "Schlie\u00dfen";
Calendar._TT["TODAY"] = "Heute";
Calendar._TT["TIME_PART"] = "(Shift-)Klick oder Festhalten und Ziehen um den Wert zu \u00e4ndern";
Calendar._TT["DEF_DATE_FORMAT"] = "%d.%m.%Y";
Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
Calendar._TT["WK"] = "wk";
Calendar._TT["TIME"] = "Zeit:";
// }}}
window._dynarch_popupCalendar = null;	// global object that remembers the calendar
// }}}

// BEGIN: DATE OBJECT PATCHES {{{
Date._MD = new Array(31,28,31,30,31,30,31,31,30,31,30,31);	/** Adds the number of days array to the Date object. */
/** Constants used for time computations */
Date.SECOND	= 1000 /* milliseconds */;
Date.MINUTE	= 60 * Date.SECOND;
Date.HOUR	= 60 * Date.MINUTE;
Date.DAY	= 24 * Date.HOUR;
Date.WEEK	= 7 * Date.DAY;
Date.parseDate = function(str, fmt) {{{
	var today = new Date();
	var y = 0;
	var m = -1;
	var d = 0;
	var a = str.split(/\W+/);
	var b = fmt.match(/%./g);
	var i = 0, j = 0;
	var hr = 0;
	var min = 0;
	for (i = 0; i < a.length; ++i) {
		if (!a[i]) continue;
		switch (b[i]) {
		case "%d":
		case "%e": d = parseInt(a[i], 10); break;
		case "%m": m = parseInt(a[i], 10) - 1; break;
		case "%Y":
		case "%y": y = parseInt(a[i], 10); (y < 100) && (y += (y > 29) ? 1900 : 2000); break;
		case "%b":
		case "%B": for (j = 0; j < 12; ++j) if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { m = j; break; } break;
		case "%H":
		case "%I":
		case "%k":
		case "%l": hr = parseInt(a[i], 10); break;
		case "%P":
		case "%p": if (/pm/i.test(a[i]) && hr < 12) hr += 12; else if (/am/i.test(a[i]) && hr >= 12) hr -= 12; break;
		case "%M": min = parseInt(a[i], 10); break;
		}
	}
	if (isNaN(y)) y = today.getFullYear();
	if (isNaN(m)) m = today.getMonth();
	if (isNaN(d)) d = today.getDate();
	if (isNaN(hr)) hr = today.getHours();
	if (isNaN(min)) min = today.getMinutes();
	if (y != 0 && m != -1 && d != 0) return new Date(y, m, d, hr, min, 0);
	y = 0; m = -1; d = 0;
	for (i = 0; i < a.length; ++i) {
		if (a[i].search(/[a-zA-Z]+/) != -1) {
			var t = -1;
			for (j = 0; j < 12; ++j) if (Calendar._MN[j].substr(0, a[i].length).toLowerCase() == a[i].toLowerCase()) { t = j; break; }
			if (t != -1) {
				if (m != -1) d = m+1;
				m = t;
			}
		} else if (parseInt(a[i], 10) <= 12 && m == -1) {
			m = a[i]-1;
		} else if (parseInt(a[i], 10) > 31 && y == 0) {
			y = parseInt(a[i], 10);
			(y < 100) && (y += (y > 29) ? 1900 : 2000);
		} else if (d == 0) {
			d = a[i];
		}
	}
	if (y == 0) y = today.getFullYear();
	if (m != -1 && d != 0) return new Date(y, m, d, hr, min, 0);
	return today;
}}};
Date.prototype.getMonthDays = function(month) {{{
	var year = this.getFullYear();
	if (typeof month == "undefined") {
		month = this.getMonth();
	}
	if (((0 == (year%4)) && ( (0 != (year%100)) || (0 == (year%400)))) && month == 1) {
		return 29;
	} else {
		return Date._MD[month];
	}
}}};
Date.prototype.getDayOfYear = function() {{{
	var now = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
	var then = new Date(this.getFullYear(), 0, 0, 0, 0, 0);
	var time = now - then;
	return Math.floor(time / Date.DAY);
}}};
Date.prototype.getWeekNumber = function() {{{
	var d = new Date(this.getFullYear(), this.getMonth(), this.getDate(), 0, 0, 0);
	var DoW = d.getDay();
	d.setDate(d.getDate() - (DoW + 6) % 7 + 3); // Nearest Thu
	var ms = d.valueOf(); // GMT
	d.setMonth(0);
	d.setDate(4); // Thu in Week 1
	return Math.round((ms - d.valueOf()) / (7 * 864e5)) + 1;
}}};
Date.prototype.equalsTo = function(date) {{{
	return ((this.getFullYear() == date.getFullYear()) &&
		(this.getMonth() == date.getMonth()) &&
		(this.getDate() == date.getDate()) &&
		(this.getHours() == date.getHours()) &&
		(this.getMinutes() == date.getMinutes()));
}}};
Date.prototype.setDateOnly = function(date) {{{
	var tmp = new Date(date);
	this.setDate(1);
	this.setFullYear(tmp.getFullYear());
	this.setMonth(tmp.getMonth());
	this.setDate(tmp.getDate());
}}};
Date.prototype.print = function (str) {{{
	var m = this.getMonth();
	var d = this.getDate();
	var y = this.getFullYear();
	var wn = this.getWeekNumber();
	var w = this.getDay();
	var s = {};
	var hr = this.getHours();
	var pm = (hr >= 12);
	var ir = (pm) ? (hr - 12) : hr;
	var dy = this.getDayOfYear();
	if (ir == 0) ir = 12;
	var min = this.getMinutes();
	var sec = this.getSeconds();
	s["%a"] = Calendar._SDN[w]; 		// abbreviated weekday name [FIXME: I18N]
	s["%A"] = Calendar._DN[w]; 		// full weekday name
	s["%b"] = Calendar._SMN[m]; 		// abbreviated month name [FIXME: I18N]
	s["%B"] = Calendar._MN[m]; 		// full month name
	s["%C"] = 1 + Math.floor(y / 100); 	// the century number
	s["%d"] = (d < 10) ? ("0" + d) : d; 	// the day of the month (range 01 to 31)
	s["%e"] = d; 				// the day of the month (range 1 to 31)
	s["%H"] = (hr < 10) ? ("0" + hr) : hr; 	// hour, range 00 to 23 (24h format)
	s["%I"] = (ir < 10) ? ("0" + ir) : ir; 	// hour, range 01 to 12 (12h format)
	s["%j"] = (dy < 100) ? ((dy < 10) ? ("00" + dy) : ("0" + dy)) : dy; // day of the year (range 001 to 366)
	s["%k"] = hr;				// hour, range 0 to 23 (24h format)
	s["%l"] = ir;				// hour, range 1 to 12 (12h format)
	s["%m"] = (m < 9) ? ("0" + (1+m)) : (1+m); // month, range 01 to 12
	s["%M"] = (min < 10) ? ("0" + min) : min; // minute, range 00 to 59
	s["%n"] = "\n";				// a newline character
	s["%p"] = pm ? "PM" : "AM";
	s["%P"] = pm ? "pm" : "am";
	s["%s"] = Math.floor(this.getTime() / 1000);
	s["%S"] = (sec < 10) ? ("0" + sec) : sec; // seconds, range 00 to 59
	s["%t"] = "\t";				// a tab character
	s["%U"] = s["%W"] = s["%V"] = (wn < 10) ? ("0" + wn) : wn;
	s["%u"] = w + 1;			// the day of the week (range 1 to 7, 1 = MON)
	s["%w"] = w;				// the day of the week (range 0 to 6, 0 = SUN)
	s["%y"] = ('' + y).substr(2, 2); 	// year without the century (range 00 to 99)
	s["%Y"] = y;				// year with the century
	s["%%"] = "%";				// a literal '%' character
	var re = /%./g;
	if (!Calendar.is_ie5 && !Calendar.is_khtml) return str.replace(re, function (par) { return s[par] || par; });
	var a = str.match(re);
	for (var i = 0; i < a.length; i++) {
		var tmp = s[a[i]];
		if (tmp) str = str.replace(new RegExp(a[i], 'g'), tmp);
	}
	return str;
}}};
/*
IE 6.* baut hier mist recursion
Date.prototype.__msh_oldSetFullYear = Date.prototype.setFullYear;
Date.prototype.setFullYear = function(y) {{{
	var d = new Date(this);
	d.__msh_oldSetFullYear(y);
	if (d.getMonth() != this.getMonth()) this.setDate(28);
	this.__msh_oldSetFullYear(y);
	}}};
*/

// END: DATE OBJECT PATCHES }}}

function setDates(i) {{{
	var fd = function(d) { return d.print('%d.%m.%Y'); }
	var jetzt	= new Date();
	var morgen	= new Date(jetzt.getFullYear(), jetzt.getMonth(), jetzt.getDate()+1);
	var uebermorgen = new Date(jetzt.getFullYear(), jetzt.getMonth(), jetzt.getDate()+2);
	var wd = (jetzt.getDay()+6)%7;
	var sonntag	= new Date(jetzt.getFullYear(), jetzt.getMonth(), jetzt.getDate()+6-wd);
	var nextWeek_v	= new Date(jetzt.getFullYear(), jetzt.getMonth(), jetzt.getDate()+6-wd+1);
	var nextWeek_b	= new Date(jetzt.getFullYear(), jetzt.getMonth(), jetzt.getDate()+6-wd+7);
	var d31		= new Date(jetzt.getFullYear(), jetzt.getMonth()+1, 0);
	var nextMonth_v	= new Date(jetzt.getFullYear(), jetzt.getMonth()+1, 1);
	var nextMonth_b	= new Date(jetzt.getFullYear(), jetzt.getMonth()+2, 0);
	var heute	= fd(jetzt);
	morgen		= fd(morgen);
	uebermorgen	= fd(uebermorgen);
	sonntag		= fd(sonntag);
	nextWeek_v	= fd(nextWeek_v);
	nextWeek_b	= fd(nextWeek_b);
	d31		= fd(d31);
	nextMonth_v	= fd(nextMonth_v);
	nextMonth_b	= fd(nextMonth_b);
	var von = gE('event-von');
	var bis = gE('event-bis');
	switch(i) {
		case 0: von.value = heute;	bis.value = heute;	break;
		case 1: von.value = morgen;	bis.value = morgen;	break;
		case 2: von.value = uebermorgen;bis.value = uebermorgen; break;
		case 3: von.value = heute;	bis.value = sonntag;	break;
		case 4: von.value = nextWeek_v;	bis.value = nextWeek_b;	break;
		case 5: von.value = heute;	bis.value = d31;	break;
		case 6: von.value = nextMonth_v;bis.value = nextMonth_b; break;
		case 7: break;
		}
	}}}

function suchBox(id,action) {{{
	var r,f,t;
	aC(id,r=cE('div',{'class':'box','onclick':stopBubble}));
	aC(r,aC(cE('div',{'className':'closeMenu','onclick':function(){ this.parentNode.parentNode.onclick(); }  }),cT('\u00d7')));
	aC(r,f=cE('form',{'method':'post','action':action}));
	aC(f,t = cE('table',{'className':'suchen'}));
	return t;
	}}}

function createGoogleBox(id) {{{
	var e;
	var d;
	var b,u,i,c;
	var custom = "GALT:#0000FF;GL:1;DIV:#000000;VLC:663399;AH:center;BGC:FFFFFF;LBGC:FFFF00;ALC:000000;LC:000000;T:666666;GFNT:0000FF;GIMP:0000FF;LH:50;LW:193;L:http://bewegungsmelder.de/images/Bemel_Logoanimation_h63.gif;S:http://bewegungsmelder.de/;FORID:1;";
	d = suchBox(id, 'http://www.google.com/custom');
	d.parentNode.id='googleSuche';
	d.parentNode.target='_blank';
	c = cE('td');
	sA(c,'colspan',4);
	aC(d,aC(cE('tfoot'),aC(cE('tr'),aC(c,aC(cE('a',{'href':'#', 'className':'fkt', 'onclick':function() { gE('googleSuche').submit(); } }),cT('SUCHEN'))))));
	c = cE('tbody');
	d = aC(d,c);
	d = c;
	r = cE('tr');
	i = cE('input'); i.type='radio'; i.name='sitesearch', i.value=''; i.checked='checked'; i.className="radio";
	aC(r,aC(cE('td'),i));
	aC(r,aC(cE('td'),cT('Web')));
	i = cE('input'); i.type='radio'; i.name='sitesearch', i.value='bewegungsmelder.de'; i.checked='checked'; i.className="radio";
	aC(r,aC(cE('td'),i));aC(r,aC(cE('td'),cT('bewegungsmelder.de')));
	aC(d,r);
	c = cE('td');
	sA(c,'colspan',4);
	i = cE('input'); i.type='text'; i.name='q'; i.style.width='140px'; i.border='1px solid black';	aC(c,i);
	i = cE('input'); i.type='hidden'; i.name='domains';	i.value='bewegungsmelder.de'; aC(c,i);
	i = cE('input'); i.type='hidden'; i.name='client';	i.value='pub-1426488938351665';			aC(c,i);
	i = cE('input'); i.type='hidden'; i.name='forid';	i.value="1";					aC(c,i);
	i = cE('input'); i.type='hidden'; i.name='ie';		i.value="UTF-8";				aC(c,i);
	i = cE('input'); i.type='hidden'; i.name='oe';		i.value="UTF-8";				aC(c,i);
	i = cE('input'); i.type='hidden'; i.name='cof';		i.value=custom;					aC(c,i);
	i = cE('input'); i.type='hidden'; i.name='hl';		i.value="de";					aC(c,i);
	i = cE('input'); i.type='hidden'; i.name='sa';		i.value='Google-Suche';				aC(c,i);
	aC(d,aC(cE('tr'),c));
	}}}

/* Events / Locations / Kleinanzeigen , Suche / Navi / Popup {{{ */
function putStadtCookie(field){{{
	gE(field).value=getStadtCookie();
}}}

function getCookieValue(name){{{
 	var c=""+document.cookie;
	var a,b;
	if(!name || name=='' || !c || c=='') return '';
	name = name+'=';
 	if ((a=c.indexOf(name))==-1) return "";
 	if ((b=c.indexOf(';',a))==-1) b=c.length;
 	return unescape(c.substring(a+name.length,b));
}}}
function clearCookieValue(name){{{
	document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT" + "; path=/";
}}}
function getStadtCookie() {{{
	return getCookieValue('bm-stadt');
	}}}
function setStadtCookie(wo) {{{
	var expire = new Date();
	expire.setTime((new Date()).getTime() + 3600000*24*30);
	document.cookie = 'bm-stadt='+escape(wo)+ ';expires='+expire.toGMTString()+'; path=/';
	}}}
function setUserPassCookie(user,pass){
	var expire = new Date();
	expire.setTime((new Date()).getTime() + 3600000*24*30);
	document.cookie = 'bm-user='+escape(user)+ ';expires='+expire.toGMTString()+'; path=/';
	document.cookie = 'bm-pass='+escape(pass)+ ';expires='+expire.toGMTString()+'; path=/';
	document.cookie = 'bm-autologin=true;expires='+expire.toGMTString()+'; path=/';
}
function clearUserPassCookie(){
	clearCookieValue('bm-user');
	clearCookieValue('bm-pass');
	clearCookieValue('bm-autologin');
}
function loginFromCookie(){
	user=getCookieValue('bm-user');
	pass=getCookieValue('bm-pass');
	auto=getCookieValue('bm-autologin');
	if (!user || user == '' || !pass || pass == '' || !auto || auto != 'true') return'';
	post('/fkt.php','fkt=doLogin&user='+user+'&pass='+pass, callback, true);
}
function getValidDatum(id) {{{
	var e = gE(id);
	var d = e.value;
	if(d == '' || d==null) {{{
		e.focus();
		e.style.background='red';
		alert('Bitte Datum im Format dd.mm.yyyy eingeben!');
		return false;
		}}}
	var dateSyntax = /^([0-9]{1,2})\.([0-9]{1,2})\.([0-9]{4})$/;
	var r = dateSyntax.exec(d);
	if (r == null) {{{
		e.focus();
		e.style.background='red';
		alert('Bitte Datum im Format dd.mm.yyyy eingeben!');
		return false;
		}}}
	var o = new Date(r[3], r[2]-1, r[1]);
	if (r[1] != o.getDate() || r[2]-1 != o.getMonth() || r[3] != o.getFullYear()) {
		e.focus();
		e.style.background='red';
		alert('Bitte ein g\u00fcltiges Datum eingeben');
		return false;
		}
	e.style.background='#E5E5F7';
	return e.value;
	}}}

function seekEvents() {{{
	if (gE('event-wo').value.length == 0) {
		alert(getMsg('missing.location'));
		return false;
		}
	var was = gE('event-was');
	var wo = gE('event-wo').value
	var von = getValidDatum('event-von');
	if(!von) return false;
	var bis = getValidDatum('event-bis');
	if(!bis) return false;
	setStadtCookie(wo);
	url = '/Events/'+encodeURIComponent(wo);
	url = url + '/'+ encodeURIComponent(was.options[was.selectedIndex].text);
	url = url + '/'+ encodeURIComponent(von);
	url = url + '/'+ encodeURIComponent(bis);
	url = url + '/0';
	url = url + '/1';
	url = url + '/'+ encodeURIComponent(gE('event-txt').value);
	window.location.href = url;
	return false;
	}}}
function seekUser() {{{
	var login = gV('user-login');
	var wo = gV('user-wo');
	var online = gE('user-online');
	var onlineValue=online.checked==true?'1':'0';
	if (login == '' || login == 'Username / Realname') login = '#';
	if (wo == '') wo = '#';	
	setStadtCookie(wo);
	url = '/User/'+encodeURIComponent(login);
	url = url + '/'+ encodeURIComponent(wo);
	url = url + '/'+ onlineValue;
	url = url + '/0';
	url = url + '/1';
	window.location.href = url;
	return false; 
	}}}
function seekLocations() {{{
	if (gE('location-wo').value.length == 0) {
		alert(getMsg('missing.location'));
		return false;
		}
	var was = gE('location-was');
	var wo = gV('location-wo');
	setStadtCookie(wo);
	url = '/Locations/'+encodeURIComponent(wo);
	url = url + '/'+ encodeURIComponent(was.options[was.selectedIndex].text);
	url = url + '/0';
	url = url + '/1';
	url = url + '/'+ encodeURIComponent(gE('location-txt').value);
	window.location.href = url;
	return false;
	}}}
function seekKleinanzeigen() {{{
	if (gE('kleinanzeigen-wo').value.length == 0) {
		alert('Bitte Ort aussuchen!');
		return false;
		}
	var was = gE('kleinanzeigen-was');
	url = '/Kleinanzeigen/'+encodeURIComponent(gE('kleinanzeigen-wo' ).value);
	url = url + '/'+ encodeURIComponent(was.options[was.selectedIndex].text); // Todo
	url = url + '/0';
	url = url + '/1';
	window.location.href = url;
	return false;
	}}}
var was_evt_arr = [[-1,'alle'],[1,'Ausstellung'],[2,'B\u00fchne'],[3,'Fest'],[4,'Gay'],[8,'Kids'],[9,'Kino'],[5,'Klassik'],[6,'Musik'],[7,'Nightlife'],[13,'Sonstige'],[10,'Sport'],[11,'Treff']];
var was_loc_arr = [[-1,'alle'],[85,'Bildung'],[88,'Kartenvorverkauf'],[46,'Essen & Trinken'],[35,'Kino'],[76,'Kunst'],[29,'Live'],[40,'Nachtleben'],[80,'Sport']];
var was_ka_arr = [[-1,'alle'],[14,'Sie sucht Ihn'],[15,'Er sucht Sie'], [16,'Sie sucht Sie'], [17,'Er sucht Ihn'], [18,'Wohnen'], [19,'Jobs'], [20,'Kaufen'], [21,'Verkaufen'],
		[22,'Gr\u00fc\u00dfe'], [23,'Reisen'], [24,'Musik'], [25,'Kleingewerbe'], [26,'Kurse/Projekte'], [27,'KFZ'], [28,'Treff'], [1086,'Sonstige'],
		[1856,'Tickets (Suchen und Anbieten)'], [3001961,'PICKUP Kleinanzeigen']];
function getText4Val(arr,val) {{{
	for(i=0;i<arr.length;i++) {
		if(arr[i][0]==val) return arr[i][0];
		}
	return 'alle';
	}}}

function createEventSuche(id) {{{
	var wann = [[1,'Heute'],[2,'Morgen'],[3,'\u00dcbermorgen'],[4,'Diese Woche'],[5,'N\u00e4chste Woche'],[6,'Dieser Monat'],[7,'N\u00e4chster Monat'],[8,'Datum von - bis']];
	var d,c;
	var t = this;
	var fktCal = function () { calTrigger(t); };
	var s = cSIN('event-wann','wann', wann);
	s.name=null;
	s.onchange	= function() { setDates(this.selectedIndex); };
	s.onblur	= function() { setDates(this.selectedIndex); };
	d = suchBox(id,'/event-liste.php');
	aC(d,aC(cE('tfoot'),aC(cE('tr'),aC(cE('td',{'colspan':2}),aC(cE('a',{'href':'#','className':'fkt','onclick':seekEvents}),cT('SUCHEN'))))));
	aC(d,c = cE('tbody'));
	d = c;
	c = cE('td');
	aC(c,cE('input',{'id':'event-wo', 'name':'wo', 'value':getStadtCookie(),'onkeyup':function () { seekType='event'; woSugestBox(this); }}));
	aC(c,cE('div',{'id':'event-sugest','className':'sugest'}));
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('Wo:'))),c));
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('Was:'))),aC(cE('td'),cSIN('event-was','was', was_evt_arr))));
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('Wann:'	))),aC(cE('td'),s)));
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('von:'	))),aC(cE('td',{'className':'cal','onclick':fktCal}	),cE('input',{'id':'event-von', 'name':'von'	  }))));
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('bis:'	))),aC(cE('td',{'className':'cal','onclick':fktCal}	),cE('input',{'id':'event-bis', 'name':'bis'	  }))));
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('Stichwort:'	))),aC(cE('td'						),cE('input',{'id':'event-txt', 'name':'stichwort'}))));
	setDates(0);
	}}}
function createLocationSuche(id) {{{
	var d = suchBox(id,'/location-liste.php');
	i = cE('a',{'href':'#','class':'fkt'});
	aC(i,cT('SUCHEN'));
	i.onclick=seekLocations;
	aC(d,aC(cE('tfoot'),aC(cE('tr'),aC(sA(cE('td'),'colspan',2),i))));
	c = cE('tbody');
	d = aC(d,c);
	d = c;
	i = cE('input',{'id':'location-wo', 'name':'wo', 'value':getStadtCookie()});
	i.onkeyup = function () { seekType='location'; woSugestBox(this); }
	c = aC(cE('td'),i);
	i = cE('div',{'id':'location-sugest'});
	i.className='sugest';
	aC(c,i);
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('Wo:'))),c));
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('Was:'      ))),aC(cE('td'),cSIN('location-was','was', was_loc_arr))));
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('Stichwort:'))),aC(cE('td'),cE('input',{'id':'location-txt', 'name':'stichwort'       }))));
	}}}
function createUserSuche    (id) {{{
	var d = suchBox(id,'/user-liste.php');
	var i=aC(cE('a',{'href':'#','className':'fkt','onclick':seekUser}),cT('SUCHEN'));
	aC(d,aC(cE('tfoot'),aC(cE('tr'),aC(sA(cE('td'),'colspan',2),i))));
	c = cE('tbody');
	d = aC(d,c);
	d = c;
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('User:'))),aC(cE('td'),cE('input',{'id':'user-login', 'name':'stichwort'}))));
	c = aC(cE('td'),cE('input',{'id':'user-wo', 'name':'wo', 'value':getStadtCookie(), 'onkeyup':function () { seekType='user'; woSugestBox(this); }}));
	aC(c,cE('div',{'id':'user-sugest', 'className':'sugest'}));
	aC(d,aC(aC(cE('tr'),aC(cE('td'),cT('Wo:'))),c));
	}}}

function createKleinanzeigenSuche(id) {{{
	var d = suchBox(id,'/kleinanzeigen-liste.php');
	c = cE('td'); sA(c,'colspan',2);
	aC(d,aC(cE('tfoot'),aC(cE('tr'),c)));
	i = cE('a');
	i.href='#';
	i.className='fkt';
	aC(i,cT('SUCHEN'));
	i.onclick=seekKleinanzeigen;
	aC(c,i);
	i = cE('a');
	i.href='#';
	i.className='fkt';
	aC(i,cT('AUFGEBEN'));
	i.onclick=function () {
		if(!(user.id>0)) {
			var j = cE('div');
			j.style.padding='5px';
			j.style.width="180px";
			displayPopup(aC(j,cT('Bitte vorher Anmelden!')));
			}
		else 	window.location.href='/KleinanzeigeAufgabe.php';
		return false;
		}
	aC(c,i);
	c = cE('tbody');
	d = aC(d,c);
	d = c;
	r = cE('tr');
	aC(r,aC(cE('td'),cT('Wo:')));
	c = cE('td');
	i = cE('input',{'id':'kleinanzeigen-wo', 'name':'wo'});
	i.onkeyup = function () { seekType='kleinanzeigen'; woSugestBox(this); }
	aC(c,i);
	i = cE('div');
	i.id='kleinanzeigen-sugest';
	i.className='sugest';
	aC(c,i);
	aC(d,aC(r,c));
	r = cE('tr');
	aC(r,aC(cE('td'),cT('Was:')));
	aC(d,aC(r,aC(cE('td'),cSIN('kleinanzeigen-was','was', was_ka_arr))));
	}}}

var block = false;
function cbWoSugestBox(v) {{{
	if (block) {
		return;
	}
	var e = gE(seekType+'-sugest');
	e.style.display='none';
	while(e.firstChild) e.removeChild(e.firstChild);
	if (v.length<10) return;
	eval('var x = ('+v+')');
	if (x.cnt>10) return;
	var i;
	block = true;
	try {
		if (x.daten != null){
			for(i=0;i<x.daten.PLZ.length;i++) {
				var t = cE('div');
				t.title = x.daten.ORT[i];
				t.onclick=function () { gE(seekType+'-wo').value=this.title; gE(seekType+'-sugest').style.display='none'; }
				var txt = x.daten.PLZ[i]+'***\u00A0'+x.daten.ORT[i];
				aC(e,aC(t,cT(txt)));
				}
			e.style.display='block';
		}
	} catch (e) { alert (e);}
	block=false;
	}}}
function woSugestBox(v) {{{
	if (block) return;
	var data = {};
	data['query']=v.value;
	data['time']=new Date().getTime();
	post('/js/ort-sugest.php', 'q='+data.toJSONString(), cbWoSugestBox, false);
	}}}
function seeksuche() {{{
	var url;
	switch(typ) {
	case 'event':
		url = '/Events/'+encodeURIComponent(wo);
		url = url + '/'+ getText4Val(was_evt_arr, was);
		url = url + '/'+von;
		url = url + '/'+bis;
		url = url + '/'+start;
		url = url + '/'+dist;
		url = url + '/'+ encodeURIComponent(stichwort);
		window.location.href = url;
		break;
	case 'location':
		url = '/Locations/'+encodeURIComponent(wo);
		url = url + '/'+ getText4Val(was_loc_arr, was);
		url = url + '/'+start;
		url = url + '/'+dist;
		url = url + '/'+ encodeURIComponent(stichwort);
		window.location.href = url;
		break;
	case 'kleinanzeige':
		url = '/Kleinanzeigen/'+encodeURIComponent(wo);
		url = url + '/'+ getText4Val(was_ka_arr, was);
		url = url + '/'+start;
		url = url + '/'+dist;
		window.location.href = url;
		break;
		}
	}}}
function locJump(i){{{
	o = i.firstChild.data;
	if (o>0 && o<100) {
		start = (o-1)*10;
		seeksuche();
		return;
		}
	if (o=='<<' && start > 0) {
		if (start>30) 	start = start-30;
		else		start = 0;
		seeksuche();
		return;
		}
	if (seiten && o=='>>' && start+10/10 < seiten) {
		if (start>30) 	start= start+30;
		else		start= 0;
		seeksuche();
		return;
		}
	alert(o);
	}}}

/* }}} */

function getPageSize() {{{
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;
	arrayPageSize = new Array(w,h)
	return arrayPageSize;
	}}}

function windowClose() {{{
	var e = gE('TB_window');
	e.parentNode.removeChild(e);
	e = gE('TB_overlay');
	e.parentNode.removeChild(e);
	}}}
function displayPopup(content) {{{
	var body = gE('body');
	var e = cE('div',{'id':'TB_overlay'});
	var a,i,j,k;
	try { e.style.height=gE('root').scrollHeight+'px'; } catch(e) { }
	aC(body,e);
	e = cE('div',{'id':'TB_window'});
	e.style.display='none';
	aC(body,e);
	i = cE('div');
	i.id = 'TB_title';
	aC(e,i);
	j = cE('div',{'id':'TB_ajaxWindowTitle'});
	aC(i,aC(j,cT(' ')));
	j = cE('div',{'id':'TB_closeAjaxWindow'});
	aC(i,j);
	a = cE('a',{'id':'TB_closeWindowButton'});
	a.style.cursor='pointer';
	a.onclick = windowClose;
	aC(j,aC(a,cT('close')));
	i = cE('div',{'id':'TB_ajaxContent'});
	aC(e,aC(i,content));
	var ps = getPageSize();
	e.style.top ='-10000px';
	e.style.display='block';
	e.style.width=(gW(content) + 30)+'px';
	e.style.left= (ps[0]-e.clientWidth )/2+'px';
	e.style.top ='255px';
	}}}

function displayMeldung() {{{
	if (typeof(meldung)!='string') return;
	if (meldung.length==0) return;
	var j = cE('div');
	j.style.padding='5px';
	j.style.width='500px';
	displayPopup(aC(j,cT(meldung)));
	}}}

function callback(t) {{{
	eval('var x=('+t+')');
	var i;
	for(i=0;i<x.length;i++) {
		switch(x[i].fkt) {
			case 'createMessage':
			case 'kaAufgeben':
			case 'error': 	alert(x[i].text);
					break;
			case 'createUser':
					alert(x[i].text);
					window.location.href="/";
					return;
			case 'saveProfil':
					alert(x[i].text);
					return;
			case 'doForgetPassword':
					alert(x[i].text);
					goLogin();
					break;
			case 'doCreateBlog':
			case 'doCreateUserBlog':
			case 'doCreateGuest':
			case 'reload':
			case 'doLogin': window.location.reload();
					return;
			default		: alert(t);
			}
		}
	loaded();
	}}}

function extraParam(opts) {{{
	var ret = '';
	for(var i=0;i<opts.length;i++) {
		ret=ret+'&'+opts[i]+'='+encodeURIComponent(gV(opts[i]));
		}
	return ret;
	}}}
function doLogin	 (){ if (gV('autoLogin')){setUserPassCookie(gV('user'), gV('pass'));}else{clearUserPassCookie();} post('/fkt.php','fkt=doLogin'+extraParam(['user','pass'])		, callback, true); return false;}
function doForgetPasswort(){ post('/fkt.php','fkt=doForgetPassword'+extraParam(['user','email']), callback, true); }
function doLogout	 (){ clearCookieValue('bm-autologin');post('/fkt.php','fkt=doLogout', function(){clearCookieValue('bm-autologin');window.location.reload(); }, true); }

function goForgetPasswort() {{{
	windowClose();
	var t = cE('table');
	var f = cE('tfoot');
	var r = cE('tr');
	var c = cE('td');
	aC(t,aC(f,aC(r,c)));
	c.setAttribute('colspan','2');
	c.style.textAlign='right';
	var e;
	e = cE('input');
	e.type = 'submit';
	e.value = 'Zusenden';
	e.onclick = doForgetPasswort;
	aC(c,e);
	aC(t, f = cE('tbody'));
	aC(f, r = cE('tr'));
	aC(r, c = cE('td'));
	aC(c, e = cE('label'));
	aC(e, cT('Username'));
	aC(r, c = cE('td'));
	aC(c, e = cE('input'));
	e.id = 'user';
	e.size = 20;
	aC(f, r = cE('tr'));
	aC(r, c = cE('td'));
	aC(c, e = cE('label'));
	aC(e, cT('eMail'));
	aC(r, c = cE('td'));
	e = cE('input');
	e.id = 'email';
	e.size = 20;
	aC(c, e);
	displayPopup(t);
	return false;
	}}}
function goLogin() {{{

//	var forget = aC(cE('button',{'onclick':goForgetPasswort,'tabindex':100},{'marginRight':'15px'}),cT('Passwort?'));
//	var regist = aC(cE('button',{'onclick':function() { window.location.href='/Register.php'; } ,'tabindex':101},{'marginRight':'15px'}),cT('Anmelden'));
	var forget = aC(cE('button',{'onclick':goForgetPasswort,'tabindex':100},{'width':'80px','textAlign':'center'}),cT('Passwort?'));
	var regist = aC(cE('button',{'onclick':function() { window.location.href='/Register.php'; } ,'tabindex':101},{'width':'80px','textAlign':'center'}),cT('Anmelden'));
//	var login  = aC(cE('button',{'onclick':doLogin         ,'tabindex':  3}                       ),cT('Login'));
	var login  = aC(cE('button',{'onclick':doLogin         ,'tabindex':  3},{'width':'80px','textAlign':'center'}),cT('Login'));
	var cookieUser=getCookieValue('bm-user');
	var cookiePass=getCookieValue('bm-pass');
	var cookieAuto=getCookieValue('bm-autologin');
	// var keycheck = function(e) { if(!e) e=window.event; if(e.keyCode==13) doLogin(); return false; }
//	var pass = cE('input',{'id':'pass','tabindex':2,'type':'password','size':20, 'onkeyup':keycheck, 'name':'pass' } );
	var user = cE('input',{'id':'user','tabindex':1, 'size':20,'name':'user', 'autocomplete':'on', 'value':cookieUser});
	var pass = cE('input',{'id':'pass','tabindex':2,'type':'password','size':20, 'name':'pass', 'autocomplete':'on', 'value':cookiePass} );
	var autoLogin = cE('input',{'id':'autoLogin','tabindex':3,'type':'checkbox', 'name':'autoLogin'} );
	if (cookieAuto == 'true') {
		autoLogin.checked='checked';
	}
	var form = cE('form',{'name':'bemelLoginForm', 'onSubmit':'doLogin();return false;', 'action':'fkt.php', 'method':'get', 'action':'/fkt.php', 'autocomplete':'on'});
	var t = cE('table');
	var f = cE('tfoot');
	var r = cE('tr');
	var c = cE('td');
	aC(form,aC(t,aC(f,aC(r,c))));
	c.setAttribute('colspan','2');
	c.style.textAlign='right';
	var e;
	aC(c,login);

	c = cE('td');
	aC(f,aC(cE('tr'),c));
	c.setAttribute('colspan','2');
	c.style.textAlign='right';
	aC(c,forget);

	c = cE('td');
	aC(f,aC(cE('tr'),c));
	c.setAttribute('colspan','2');
	c.style.textAlign='right';
	aC(c,regist);



	aC(t,f = cE('tbody'));
	aC(f,r = cE('tr'));
	aC(r,c = cE('td'));
	aC(c,e = cE('label'));
	aC(e,cT('Username'));
	aC(r,c = cE('td'));
	aC(c,e = user);
	aC(f,r = cE('tr'));
	aC(r,c = cE('td'));
	aC(c,e = cE('label'));
	aC(e,cT('Password'));
	aC(r,c = cE('td'));
	aC(c,pass);
	aC(f,r = cE('tr'));
	aC(r,c = cE('td'));
	aC(c,e = cE('label'));
	aC(e,cT('Autologin'));
	aC(r,c = cE('td'));
	aC(c,autoLogin);
//	displayPopup(t);
	displayPopup(form);
	user.focus();
	return false;
	}}}

function makeRubrik(onclick,text) {{{
	var d = cE('a');
	d.className='menulink';
	d.href='#';
	d.onclick = onclick;
	d.style.cursor='pointer';
	return aC(d,cT(text));
	}}}

function initRubriken() {{{
	var re = gE('rubrikenEnde');
	var p = re.parentNode;
	
	}}}

function play(player, media, w, h, objType) {{{
	var s = media.split(".");
	var objType = s[s.length-1];
	var pluginspace = '';
	var codebase = '';
	var o,p;
	while(player.firstChild) player.removeChild(player.firstChild);
	if (media=="") return false;
	switch(objType) {
		case 'mpg':
		case 'mpeg': objType= 'video/mpeg'; break;
		case 'avi':
		case 'wmv':	objType		= 'video/x-msvideo';
				pluginspace	= 'http://www.microsoft.com/windows/windowsmedia/default.aspx';
				codebase	= 'http://www.microsoft.com/windows/windowsmedia/default.aspx';
				break;
		default:	objType= 'video/quicktime';
				pluginspace	= 'http://www.apple.com/quicktime/download/';
				codebase	= 'http://www.apple.com/qtactivex/qtplugin.cab';
				break;
		}
	o = cE('embed');
	o.pluginspace=pluginspace;
	o.src='http://'+window.location.hostname+media;
	o.showcontrols='false';
	o.type = objType;
	o.style.width=w+'px';
	o.style.height=w+'px';
	aC(player,o);
	return false;
	}}}

function openForum() { }

// Marquee scroller {{{
function Marquee(id) {{{
	this.id = id;
	this.step=-1;
	this.intervall = false;
	}}}
Marquee.prototype.scroll = function () {{{
	var m = gE(this.id);
	if(this.step<0) {
		var e = m.firstChild;
		var off = parseInt(e.style.marginTop)+this.step;
		var height = gH(e) + parseInt(e.style.marginBottom);
		if (-off < height) e.style.marginTop = off+'px';
		else {
			m.removeChild(e);
			e.style.marginTop = '0px';
			aC(m,e);
			}
		}
	}}}
Marquee.prototype.init = function () {{{
	var m = gE(this.id);
	while(e = m.firstChild) {
		var idx = 0;
		do {
			if (e.nodeType == 3) { m.removeChild(e); break; }
			if (e.nodeType == 8) { m.removeChild(e); break; }
			e.style.display='block';
			e.style.marginBottom='5px';
			e.style.marginTop='0px';
			idx++;
			} while((e = e.nextSibling));
		if (!e) break;
		}
	var thisObj = this;
	this.intervall = window.setInterval(function () { thisObj.scroll(); }, 50);
	}}}
Marquee.prototype.stop = function () {{{
	window.clearInterval(this.intervall);
	}}}
var marquee = new Marquee('marquee');
aE(window,'load', function () { marquee.init(); } );
// }}}

function extLink(u,t) {{{
	return cE('div',{'cursur':'pointer','onclick':function(){window.open(u, '_blank').focus()}},{},[cT()]);
	}}}
function mapLink(r) {{{
	var url = '';
	if(r['strasse']!=null) url=url+r['strasse'];
	if(url!=''           ) url=url+' ';
	if(r['hausnr' ]!=null) url=url+r['hausnr' ];
	if(url!=''           ) url=url+', ';
	if(r['plz'    ]!=null) url=url+r['plz'    ];
	if(url!=''           ) url=url+' ';
	if(r['ort'    ]!=null) url=url+r['ort'    ];
	url = 'http://maps.google.com/maps?q='+encodeURIComponent(url);
	return cE('div',{'class':'fkt m1','onclick':function(){window.open(url, '_blank').focus()}},{},[cT('Location finden')]);
	}}}

function crossContentClick(e,i) {{{
	function addAddress(d,r) {{{
		var t;
		t = '';
		if (r['strasse'	]!=null	) t+=r['strasse']+' ';
		if (r['hausnr' 	]!=null	) t+=r['hausnr'];
		if (t!=''           	) aC(d,cE('div',{},{},[cT(t)]));
		t = '';
		if (r['plz'    	]!=null	) t+=r['plz']+' ';
		if (r['ort'	]!=null	) t+=r['ort'];
		if (t!=''           	) aC(d,cE('div',{},{},[cT(t)]));
		}}}
	function url(t) {
		var d
		return ((t.substr(0,7)!='http://')?'http://':'')+t;
		}
	e=(e)?e:((window.event)?window.event:false);
	if(!e) return;
	var r = crossContent[i.id];
	var d = false;
	if (r.typ==3) { // Location
		d = cE('div',{'class':'c7'});
		aC(d,mapLink(r));
		aC(d,cE('div',{'class':'b7'},{},[cT(r['location'])]));
		addAddress(d,r);
		if(r['telefon'	]!=null&&r['telefon']!='') aC(d,cE('div',{},{},[cT('Tel: '	+r['telefon'	])]));
		if(r['fax'	]!=null&&r['fax'    ]!='') aC(d,cE('div',{},{},[cT('Fax: '	+r['fax'	])]));
		if(r['e_mail'	]!=null&&r['e_mail' ]!='') aC(d,cE('div',{},{},[cT('eMail: '	+r['e_mail'	])]));
		if(r['loc_url'	]!=null&&r['loc_url']!='') aC(d,cE('div',{},{},[cT('Web: '	+r['loc_url'	])]));
		}
	if (r.typ==2) { // Event
		d = cE('div',{'class':'c7'});
		aC(d,mapLink(r));
		aC(d,cE('div',{'class':'b7'},{},[cT(r['titel']),cE('br')]));
		aC(d,cE('div',{},{},[cT(r['location'])]));
		addAddress(d,r);
		if(r['telefon'	]!=null&&r['telefon']!='') aC(d,cE('div',{},{},[cT('Tel: '	+r['telefon'	])]));
		if(r['fax'	]!=null&&r['fax'    ]!='') aC(d,cE('div',{},{},[cT('Fax: '	+r['fax'	])]));
		if(r['e_mail'	]!=null&&r['e_mail' ]!='') aC(d,cE('div',{},{},[cT('eMail: '	+r['e_mail'	])]));
		if(r['loc_url'	]!=null&&r['loc_url']!='') aC(d,cE('div',{},{},[cT('Web: '	+r['loc_url'	])]));
		var z;
		aC(d,z=cE('div',{},{},[cT(r['datum']+' '+r['uhrzeit']+' Uhr')]));
		if(r['url']!=null) {
			aC(z,cT(' - '));
			aC(z,cE('a',{'href':url(r.url),'target':'_blank'},{},[cT('mehr Infos')]));
			}
		}
	if (d) i.parentNode.replaceChild(d,i);
	}}}

function OpenKinoPreview() {{{
var MyWindow;
 MyWindow = open( "http://www.preview-diekinoshow.de/preview/popup/index.asp?lngService=4361", "MyWindowOpen",
   "width=800, height=620, resizable=no, directories=no, menubar=no, location=no");
 MyWindow.moveTo(400,150);
 MyWindow.focus();
}}}

function voteClicked(evt,obj) {{{
	var p = obj.value.split('-');
	if(obj.checked==false) return;
	p = 'fkt=doVote&cnt='+p[1]+'&sort='+p[3];
	post('/fkt.php', p, callback, true);
	}}}

function wap() {{{
	var e = cE('div');
	e.id = 'wapBack';
	e.style.zIndex=20001;
	e.style.position="absolute";
	e.style.opacity='0.6';
	e.style.filter='alpha(opacity=60)';
	e.style.width='100%';
	e.style.height='100%';
	try { e.style.height=gE('root').scrollHeight+'px'; } catch(e) { }
	e.style.background='#000';
	aC(gE('body') ,e);
	aC(e, cE('div'));
	var i = cE('iframe');
	sA(i,'allowtransparency','true');
	i.src="http://wap.mybm.de/simulator/wap/bm.html";
	i.scrolling="no";
	i.height="660";
	i.width="290";
	sA(i,'frameborder','no');
	i.frameborder="no";
	i.style.border=0;
	i.style.zIndex=20002;
	i.style.position="absolute";
	i.style.top='220px';
	i.style.left='165px';
	i.id='wapFrame';
	i.name='wapFrame';
	aC(gE('body') ,i);
	var e = cE('div');
	aC(e,cT('X'));
	e.id = 'wapClose';
	e.style.zIndex=20003;
	e.style.position="absolute";
	e.style.top='220px';
	e.style.left='423px';
	e.style.background='#fff';
	e.onclick=wapClose;
	aC(gE('body') ,e);
	}}}
function wapClose() {
	var x;
	(x=gE('wapClose')).parentNode.removeChild(x);
	(x=gE('wapBack' )).parentNode.removeChild(x);
	(x=gE('wapFrame')).parentNode.removeChild(x);
	}
	
function sP(id){
	if (user.id > 0) {
		hP('userSuche');
	}
	hP('eventSuche');
	hP('locationSuche');
	hP('kleinanzeigenSuche');
	gE(id).style.display='block';
}
function hP(id){
	gE(id).style.display='none';
}

function regWarn(e) {{{
	e.focus();
	alert(getMsg('missing.'+e.id));
	e.className='warn';
	return false;
	}}}

function echeck(str) {{{
	if ((str==null)||(str=="")) return false;						// Empty eMail
	var lstr=str.length;
	var lat=str.indexOf('@');
	var pat=str.indexOf('.');
	if (lat==-1 || lat==0 || lat==lstr) return false;					// @ on invalid position
	if (pat==-1 || pat==0 || pat==lstr) return false;					// . on invalid position
	if (str.indexOf('@',(lat+1))!=-1)   return false;					// Second @
	if (str.substring(lat-1,lat)=='.' || str.substring(lat+1,lat+2)=='.') return false;	// @. or .@ invalid
	if (str.indexOf('.',(lat+2))  == 1) return false;					// no . after @
	if (str.indexOf(" ")	      !=-1) return false;					// ' ' not allowed
	if (str.indexOf(",")	      !=-1) return false;					// ' ' not allowed
	if (str.indexOf(";")	      !=-1) return false;					// ' ' not allowed
 	return true					
	}}}

function doRegister() {
	var felder = ['username','name','vorname','str','hnr','email','land','plz','ort','agb'];
	var i,e;
        var request = "fkt=createUser";
	var e = gE('username');
	var u = e.value;
	for(i=0;i<u.length;i++) {
		var c = u.charAt(i);
		if(c>='0' && c<='9') continue;
		if(c>='A' && c<='Z') continue;
		if(c>='a' && c<='z') continue;
		if(c=='-' || c=='_' || c=='.') continue;
		e.focus();
		alert('Es sind nur die Zeichen "A-Z", "a-z", "0-9", "-", "_" und "." erlaubt.');
		e.className='warn';
		return false;
		}
	if (!echeck((e=gE('email')).value)) return regWarn(e);
	for(i=0;i<felder.length;i++) {
		e = gE(felder[i]);
		var val = e.value;
		if (val == null || val == 'null') val = ''; 
		if (e.parentNode.parentNode.className=='b' && e.value=='') return regWarn(e); else e.className='';
		request = request + '&'+e.id + '=' + encodeURIComponent(e.value);
		}
	
	if(!gE('agb').checked) { 
		alert(getMsg('missing.agb'));
		return false;
		}
        post('/fkt.php', request, callback, true);
	return false;
	}

function ErrorFunction(msg, url, line) {
	if(url.indexOf('JsError')!=-1) return true;

	var safeGet = function(v) { 
		try { return encodeURIComponent(v); } 
		catch(e) { return encodeURIComponent('EXCEPTION: '+e); } 
		}

	if(line==2 && msg=='Syntaxfehler' 		&& safeGet(navigator.appName)=='Microsoft Internet Explorer') return true;
	if(line==1 && msg=='Error loading script'	&& safeGet(navigator.appName)=='Netscape'		    ) return true;

	var wl=  "JsErrorUrl="     +safeGet(url)
		+"&JsErrorLine="   +safeGet(line)
		+"&JsErrorMsg="    +safeGet(msg)
		+"&JsErrorAppcode="+safeGet(navigator.appCodeName)
		+"&JsErrorApp="    +safeGet(navigator.appName)
		+"&JsErrorVer="    +safeGet(navigator.appVersion)
		+"&JsErrorUsr="    +safeGet(navigator.userAgent)
		+"&JsErrorHref="   +safeGet(window.location.href)
		+"&JsErrorQuery="  +safeGet(window.location.search)
		;
        window.setTimeout(function() {
                var script=window.document.createElement('script');
                var src='http://mybm.de/error.php?'+wl;
                script.setAttribute('type','text/javascript');
                script.setAttribute('charset','UTF-8');
                script.setAttribute('src',src);
                window.document.documentElement.firstChild.appendChild(script);
                },0);
  	return true;
	}

window.onerror=ErrorFunction;
window.onError=ErrorFunction;

