document.write('<script src="/__/scripts/cleanhtml.js"></script>');
runOnLoad( function() {
	Ext.QuickTips.interceptTitles = false;
	Ext.QuickTips.init();
	Ext.select('.regdesc .reglongdesc').each( function(el) {
		if (el.dom.innerHTML && el.dom.innerHTML !== '') {
			var master = Ext.get(el.dom.parentNode);
			master.removeAllListeners();
		}
	});
	var evserie  = Ext.get('editorext');
	var endevents0 = Ext.get('endevents0tablerow'); 
	evserie.insertAfter(endevents0);
	
	
	
});


function checkChars(editor, html) {
	
	var maxChars = 160; 
	html = html.split('\n').join('');
	
	if (editor.el.id.substring(0,6) == "teaser"){
	
		if (Ext.util.Format.stripTags(html).length > maxChars){
		//alert("Ihr Text bei dem Feld \""+editor.fieldLabel+"\" ist größer als "+ maxChars +" Zeichen");
		//editor.focus();
		}
		
		
	}
	
	/*if (h != html) {
	/*	editor.setValue(h);
	/*}*/
	
	
};



Ext.onReady( function() {
	
//

	
	if (document.documentElement.clientWidth) {
		var el = Ext.get('hauptcontainerrightwidth');
		if (document.documentElement.clientWidth % 2 != 0) {
			if (Ext.isIE) {
				el.dom.style.marginLeft = "0px";
			} else {
				el.dom.style.marginLeft = "-1px";
			}
		}
	}
});
var webCamTimeOut;
function showWebcam(lnk) {
	var jetzt = new Date();
	var Zeit = jetzt.getTime()
	var lnk = Ext.get(lnk);
	var url = "http://www.badkissingen.de/flash/webcam/kglive.jpg?" + Zeit;
	var box = Ext.MessageBox.show( {
		title : 'Webcam - Aktualisierung alle 30 Sec / refresh all 30 sec',
		msg : 'Loading',
		modal : false,
		width : 1024,
		height : 384,
		animEl : lnk,
		fn : function() {
			window.clearTimeout(webCamTimeOut);
			Ext.MessageBox.hide();
		}
	});
	var txt = '<div style="width:1024px; height: 384px;  overflow-x:hidden;overflow-y:auto;"><img id="webcamPic" src="' + url + '" width="1024"></div>';
	Ext.MessageBox.updateText(txt);
	Ext.MessageBox.getDialog().center();
	Ext.MessageBox.getDialog().resizeTo(1024, 384);
	webCamTimeOut = window.setTimeout("refreshWebCamPic()", 30000);
};
function refreshWebCamPic() {
	var jetzt = new Date();
	var Zeit = jetzt.getTime()
	var url = "http://www.badkissingen.de/flash/webcam/kglive.jpg?" + Zeit;
	var pic = Ext.get('webcamPic').dom.src = url;
	webCamTimeOut = window.setTimeout("refreshWebCamPic()", 30000);
}
function showMediacenter(lnk) {
	var lnk = Ext.get(lnk);
	var url = "/r_1862";
	var box = Ext.MessageBox.show( {
		title : 'Mediacenter',
		msg : '<img src="' + basepath + '__/images/indicator_tree.gif" style="vertical-align:middle;"> Loading',
		modal : false,
		width : 1024,
		height : 384,
		animEl : lnk,
		fn : function() {
			Ext.MessageBox.hide();
		}
	});
	Ext.Ajax.request( {
		url : url,
		success : function(req) {
			var treg = /<!--\sCONTENT\s-->(.+)<!--\sCONTENT\s-->/gi;
			var bd = treg.exec(req.responseText.split(/\n/).join(''));
			if (bd && bd[1]) {
				var txt = bd[1];
				var dlg = box.getDialog();
				var swfs = {};
				txt.extractScripts().each( function(script) {
					var swfreg = /\('([^']+)',\s'([^']+)',\s'([^']+)'\)/;
					var movie = script.match(swfreg);
					if (movie) {
						var w = movie[2];
						var h = movie[3];
						var src = movie[1];
						var id = getUniqueID();
						txt += '<div style="text-align:center;" id="flash' + id + '"></div>';
						var swf = new SWFObject(basepath + '_/flash/moviePlayer.swf', "flash" + id + "obj", w, h, "8");
						swf.addParam('wmode', 'transparent');
						swf.addVariable("skinSource", basepath + '_/flash/SteelExternalAll.swf');
						swf.addVariable("streamSource", src);
						swf.useExpressInstall(basepath + '_/flash/expressinstall.swf');
						swfs[id] = swf;
					}
				});
				box.updateText('<div style=\"width:576px; height:560px; overflow:auto;\">' + txt + '</div>');
				dlg.resizeTo(616, 610);
				for ( var id in swfs) {
					swfs[id].write("flash" + id);
				}
			}
		}
	});
};
gMapsLoaded.createInterceptor( function() {
	debugger;
}, gMapsLoaded);
Ext.onReady( function() {
	var box;
	var swfs = {};
	var initlink = Ext.select('.extwndowlink');
	initlink.each( function(el) {
		var lnk = el.dom;
		var conf_title = 'Weitere Informationen';
		var conf_modal = true;
		var conf_width = 740;
		var conf_height = 460;
		var conf_display_header = true;
		Ext.MessageBox.maxWidth = 800;
		lnk.onclick = function() {
			box = Ext.MessageBox.show( {
				title : conf_title,
				msg : 'Lade Daten...',
				animEl : lnk,
				modal : conf_modal,
				fn : function() {
					for ( var id in swfs) {
						Ext.get(swfs[id].attributes.id).remove(); // raus mit
																	// den SWFs
					}
					Ext.MessageBox.hide();
				}
			});
			if (conf_display_header == false) {
				box.getDialog().header.dom.style.display = 'none';
			}
			var url = lnk.href;
			Ext.Ajax.request( {
				url : url,
				success : function(req) {
					var treg = /<!--\sINHALT\s-->(.+)<!--\sINHALT\s-->/gi;
					var bd = treg.exec(req.responseText.split(/\n/).join(''));
					var swfHeight = 0;
					if (bd && bd[1]) {
						var txt = bd[1];
						var scripttoeval;
						swfs = {};
						txt.extractScripts().each( function(script) {
							var swfreg = /\('([^']+)',\s'([^']+)',\s'([^']+)'\)/;
							var movie = script.match(swfreg);
							if (script.substring(0, 8) == "loadGMap") {
								scripttoeval = script;
							};
							if (movie) {
								var w = parseInt(movie[2]);
								var h = parseInt(movie[3]);
								swfHeight = swfHeight + h;
								var src = movie[1];
								var id = getUniqueID();
								txt += '<div id="flash' + id + '" style="text-align:center;"></div>';
								var swf = new SWFObject(basepath + '_/flash/moviePlayer.swf', "flash" + id + "obj", w, h, "8");
								swf.addParam('wmode', 'transparent');
								swf.addVariable("skinSource", basepath + '_/flash/SteelExternalAll.swf');
								swf.addVariable("streamSource", src);
								swf.useExpressInstall(basepath + '_/flash/expressinstall.swf');
								swfs[id] = swf;
							}
						});
						txt = '<div id="mediacnt" style="width:' + (conf_width - 40) + 'px; overflow-x:hidden;overflow-y:auto;">' + txt + '</div>';
						Ext.MessageBox.updateText(txt);
						// txt.evalScripts();
						var dlg = Ext.MessageBox.getDialog();
						dlg.center();
						var mediacnt = Ext.get('mediacnt');
						if (mediacnt) {
							mediacnt.select('.c_teaser').each( function(el) {
								el.dom.style.display = "none";
							});
						};
						if (dlg.size.height > 500) {
							mediacnt.dom.style.height = "440px";
							dlg.resizeTo(conf_width, 500);
						} else {
							dlg.resizeTo(conf_width, dlg.size.height + swfHeight);
						};
						for ( var id in swfs) {
							swfs[id].write("flash" + id);
						};
						if (typeof scripttoeval != 'undefined') {
							eval(scripttoeval);
						}
					}
				}
			});
			return (false);
		}
	});
});
var showHighscores = function(gnr) {
	var url = 'index.html?_func=shc&_gnr=' + gnr;
	Ext.Ajax.request( {
		url : url,
		success : function(req) {
			var msg = Ext.MessageBox;
			var buttons = {
				ok : 'OK'
			};
			msg.show( {
				title : 'Highscores',
				msg : req.responseText,
				buttons : buttons,
				modal : true,
				progress : false,
				closable : true,
				width : 500
			});
		}
	});
};
/** ** ALTZEUGS *** */
function embedkatalog(config) {
	//var conf = config.split(".");
	// config = conf[0];
	var fid = (new Date()).getTime() + "" + Math.floor((Math.random() * 8999) + 1000);
	if (config) {
		fid += '&configXML=' + config;
	}
	var domainurl = "http://www2009.badkissingen.de/flash/katalog.swf?t=" + fid;
	var oeTags = '<div style="margin-left:-10px;" id="klgflash"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + 'width="620" height="600"' + 'data="' + domainurl + '"' + 'codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">' + '<param name="movie" value="' + domainurl + '" />' + '<param name="loop" value="false"/>' + '<param name="menu" value="false" />' + '<param name="quality" value="high" />' + '<param name="wmode" value="transparent" />' + '<param name="bgcolor" value="#FFFFFF" />' + '<embed src="' + domainurl + '" quality="high" bgcolor="#FFFFFF" wmode="transparent" width="620" height="600" name="katalog" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed>' + '<\/object></div>';
	document.write(oeTags);
}
function showPic(picurl) {
	var box = Ext.Msg.show( {
		title : 'Details',
		msg : '<img src="' + picurl + '" id="ktlgpic">',
		animEl : Ext.get('klgflash')
	});
	Ext.get('ktlgpic').on('load', function(ev, el) {
		var box = Ext.get(el).getBox();
		var h = box.height + 50;
		var w = box.width;
		// Maximale Höhe limitieren: unten auskommentieren...
		/*
		 * var maxheight = 750; if (h > maxheight){ var txt = '<img
		 * src="'+picurl+'" id="ktlgpic" height="'+maxheight+'">';
		 * Ext.MessageBox.updateText(txt); var box =
		 * Ext.get('ktlgpic').getBox(); h = box.height+50; w = box.width; }
		 */
		Ext.MessageBox.getDialog().resizeTo(w, h);
	});
};


