
/*****************************************************
*/ function __P___Language() {}
/******************************************************/
 
lang = 'de';
lang_show_failed_keys = '';

if(typeof INT != 'object') INT = new Object();
/*INT['firstname'] = new Object();
INT['firstname']['de'] = 'Vorname';
INT['firstname']['en'] = 'First Name';*/

function $L(key) {
	
	this.lang = lang;
	this.def_lang = 'en';
	
	if(!INT[key]) {
		return key+lang_show_failed_keys;
	} else if(INT[key]) {
		if(INT[key][this.lang]) return INT[key][this.lang];
		else if(INT[key][this.def_lang]) return INT[key][this.def_lang];
		else return key+lang_show_failed_keys;
	} else return key+lang_show_failed_keys;
}


//---------------------------------------------------------------------------------------
//-- Menu Functions ---------------------------------------------------------------------
//---------------------------------------------------------------------------------------

function Interface () {
	
	this.window = false;
	this.title = '';
	
	this.init = function() {
		//Ext.ux.Lightbox.register('a.obj-imgs', true);
	}
	
	this.quicksearch = function(event) {
		if(event.keyCode != 13) return;
		this.do_search();
	}
	
	this.do_search = function() {
		document.location.href = '/suche/'+this.quicksearchEL.value;
	}
	
	this.donotinterruptsubmits = function() {
		this.coverbackground('visible',0.8);
		// get sid
		PA = new ProgressAnimation();
		PA.viewProgress(this.cover,false,'Bild wird geladen',false,0.5);
	}
	

	//---------------------------------------------------------------------------------------
	this.adjustSize = function(r) {
		sizeUnit = "%";
		defaultSize = 100;
		maxSize = 160;
		minSize = 98;	
	}


	//---------------------------------------------------------------------------------------
	this.setFooter = function() {
		
		// wie kann ich das anders machen?
		// ohne javascript, wird man den footer nicht sehen, keine gute sache
		// damit kommt man nicht zum impressum
		if(!document.getElementById('footer')) return;
		ft = document.getElementById('footer');
		if(!document.getElementById('innerWrapper')) {
			ft.style.visibility = 'visible';
			return;
		}
		
		/*op = 1;
		ft.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
		ft.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		return;
		*/
		
		if(!PAGEdom) return;
		nt = document.getElementById('content'); // contains left subnav and navboxes
		var nt_dp = PAGEdom.toDocumentPosition(nt); // get document position of navteaserarea
		//DebugDump(nt_dp,'nt_dp.y '+nt_dp.y);
		//DebugDump(scrollTop,'scrollTop '+scrollTop);
		var wHeight = PAGEdom.getWindowHeight();
		var pHeight = document.body.offsetHeight; // Safari needs body.offsetHeight //PAGEdom.getPageHeight();
		//DebugDump(pHeight,'pHeight '+pHeight);
		//DebugDump(wHeight,'wHeight '+wHeight);
		if(wHeight <750) { // not smaller than 800
			nt.style.height = '750px'; // window.height - footer - navteaser position
			this.contentHeight = 750;			
		} else if(pHeight
		&& wHeight
		&& pHeight<wHeight) {
			nt.style.height = (wHeight-ft.offsetHeight-nt_dp.y-1)+'px'; // window.height - footer - navteaser position
			this.contentHeight = (wHeight-ft.offsetHeight-nt_dp.y-1);
		} else this.contentHeight = nt.offsetHeight;

		//ft.style.visibility = 'visible';
		op = 1;
		ft.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
		ft.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		//var pHeight = PAGEdom.getPageHeight();
		//DebugDump(pHeight,'pHeight '+pHeight);
		
		
	}

	//---------------------------------------------------------------------------------------
	this.loginOperation = function(operation) {
		//alert();
		document.forms['iflogin'].operation.value = operation;
		document.forms['iflogin'].onsubmit(); // workaround browser bugs.
		document.forms['iflogin'].submit();
	}

	//---------------------------------------------------------------------------------------
	this.logout = function() {
		document.forms['iflogin'].operation.value = '[logout]';
		document.forms['iflogin'].action = '/';
		document.forms['iflogin'].onsubmit(); // workaround browser bugs.
		document.forms['iflogin'].submit();
	}	
	
	//---------------------------------------------------------------------------------------
	this.toggleMode = function() {
		if(mode) mode_value = mode;
		else if (document.getElementById('list_rdbms')) mode_value = "admin";
		else mode_value = "browse";
		//mode_el = document.getElementById("mymode");
		switch (mode_value) {
			case"admin":
				document.getElementById("mymode").value = 'browse';
				//mode_value = document.getElementById("mymode").value;
				break;
			case"browse":
				document.getElementById("mymode").value = 'admin';
				//mode_value = document.getElementById("mymode").value;
				break;			
		}
		//alert(document.getElementById("mymode").value);
		document.forms['iflogin'].submit();
	}
	
	//---------------------------------------------------------------------------------------

	this.linkExternalLinks = function() {
		if(is_phpos_environment) return;
		//return;
		 var links = document.getElementsByTagName('A');
		 for (var i=0; i<links.length; i++) { 
		  // var anchor = anchors[i]; 
		  var v = links[i].getAttribute("href");
		  var c = links[i].getAttribute("onclick");
		  
		   if (!c
		   && v
		   && v.indexOf('http') != -1) {
			 //DebugDump(c,'external link found');
			 //DebugDump(v,'external link found');
			 //this.addEvent(document,'click',function() {return false;}.bind(this));
			 links[i].setAttribute('target',"_blank");
			}
			
			 
		 } 

		/*links = document.getElementsByTagName('A');
		for(i=0;i<links.length;i++) {
			var atts = links[i].attributes;//getAttribute('href');
			DebugDump(atts,'external link found');
			for(p=0;p<atts.length;p++) {
				DebugDump(atts[p],''+p);
			}		
		}*/
	}

	this.jumpToExternalLink = function(myUrl,myName,hitId,hitName) {
	
		var jumpPage = "/link/external";
		var path = myUrl;
		jumpPage = jumpPage+"?path="+path;
		if ((hitName && hitName.length > 0) && (hitName && hitName.length >0)) jumpPage = jumpPage+"&object_id="+hitId+"&object_name="+hitName;
		mywin = window.open(jumpPage,myName);
		mywin.focus();
		
	}

	// browser
	//---------------------------------------------------------------------------------------
	this.browserSubmit = function(v,i,eidb) {
		//alert('huhu'); return;
		document.getElementById(i).value = v;
		document.forms['contentform'].onsubmit(); // workaround browser bugs.
		document.forms['contentform'].submit();
	}

	this.setDirPath = function(id,order_dir,eidb) {
		document.getElementById(eidb+'order').value = id;
		this.browserSubmit(order_dir,eidb+'order_dir');
	} 
		
	this.changeDirPath = function(id,order_dir,eidb) {
		img_path = '/images_admin/embedded_browser/';
		document.getElementById(eidb+'order').value = id;
		switch(order_dir) {
			case"desc":
				document.getElementById(id+'_order_dir_dot').src = img_path+"asc_blue_dot.gif";
				order_change = 'asc';
			break;
			case"asc":
				document.getElementById(id+'_order_dir_dot').src = img_path+"desc_blue_dot.gif";
				order_change = 'desc';
			break;	
		}	
		this.browserSubmit(order_change,eidb+'order_dir');
	} 
	
	// submit
	this.justSubmit = function(formname) {
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();	
	}

	// submit
	this.setHiddenAndSubmit = function(hidden_value,hidden_id,formname) {
		document.getElementById(hidden_id).value = hidden_value;
		//alert(document.forms[formname]['triggers'].value)
		document.forms[formname].onsubmit(); // workaround browser bugs.
		document.forms[formname].submit();
	}

	//---------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------
	
	
	this.magnifier_is_visible = false;
	this.magnify = function(m,e) {
		var mtop, st, ww;
		
		if(this.magnifier_is_visible == true) {
			//this.hideMagnifier(false);
			setTimeout(function(){ this.magnify(m); }.bind(this), 600);
			return;
		}
		
		
/*
.menuitemGNW {
	position: absolute;
	visibility: hidden;
}

.fllGN {
	background-image: url(/images_admin/icons/kr_hl.png);
	background-repeat: no-repeat;
	background-position: left top;
	width: 36px; 
	height:72px; 
	float:left;
}

.fllGNib {
	background-image: url(/images_admin/icons/kr_hr.png);
	background-repeat: no-repeat;
	background-position: right top;	
	height:72px; 
	width: 36px;
	float:left;
}

.fllGNCT {
	float:left;
	background-color: #000;
	margin: 1px 0 0 0;
	he

*/		
		st = PAGEdom.docScrollTop();
		mtop = (st+160)+'px';
		ww = PAGEdom.getWindowWidth();
		this.mag = document.createElement('div');
		this.mag.style.position = 'absolute';
		this.mag.style.zIndex = 10020;
		this.mag.style.left = 60+'px';
		this.mag.style.top = mtop;		
		this.mag.style.width = (ww-120)+'px';	
		this.mag.style.textAlign = 'center';
		//this.mag.style.height = '180px';
		this.mag.style.padding = '3px';
		this.mag.style.fontWeight = 'bold';
		//this.mag.style.fontSize = '400%';
		this.mag.style.fontSize = '60px';
		this.mag.style.lineHeight = '60px';
		this.mag.style.color = '#fff';
		//this.mag.style.border = '1px solid red';
		
		this.mag.innerHTML = m;
		document.getElementsByTagName('body')[0].appendChild(this.mag);
		
		this.mag_bg = document.createElement('div');
		this.mag_bg.style.position = 'absolute';
		this.mag_bg.style.zIndex = 10019;
		this.mag_bg.style.left = 60+'px';
		this.mag_bg.style.top = mtop;		
		this.mag_bg.style.width = (this.mag.offsetWidth)+'px';//(ww-60)+'px';
		this.mag_bg.style.height = this.mag.offsetHeight+'px';//'200px';
		
		op = 0.1;
		this.mag_bg.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
		this.mag_bg.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
		
		
		rk = document.createElement('div');
		rk.className = 'fllGN';
		this.mag_bg.appendChild(rk);
		
		ct = document.createElement('div');
		ct.style.width = (this.mag.offsetWidth - 72)+'px';
		ct.className = 'fllGNCT';
		this.mag_bg.appendChild(ct);	
		
		lk = document.createElement('div');
		lk.className = 'fllGNib';
		this.mag_bg.appendChild(lk);		
		
		document.getElementsByTagName('body')[0].appendChild(this.mag_bg);
		if(typeof Effect == 'object') {
			new Effect.Opacity(this.mag_bg, {duration:0.3, from:0.1, to:0.7,afterFinish: function() {IF.magnifier_is_visible = true;}});
		} else if(typeof Ext == 'object') {
			var mag_bg = Ext.get(this.mag_bg);
			IF.magnifier_is_visible = true;
			mag_bg.fadeIn({
				endOpacity:.75, 
				duration:.5,
				easing:'easeOut',
				callback:function() {
					IF.magnifier_is_visible = true;
				}
			});
		} else {
			op = 0.7;
			this.mag_bg.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			this.mag_bg.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
			IF.magnifier_is_visible = true;
		}
		//new Effect.Appear(this.mag_bg,{duration:0.5});
		//new Effect.Appear(this.mag,{duration:0.5});
		//new Effect.SlideDown(menuitems[i],{duration:0.8});
		//new Effect.BlindDown(menuitems[i],{duration:0.8});
		//new Effect.Grow(menuitems[i],{duration:0.8});		

		//this.mag.style.backgroundColor = '#ffffff';
		this.addEvent(document,'mousedown',this.hideme = function(event) {this.hideMagnifier(event);}.bind(this));


		if (e && e.stopPropagation) {
			e.stopPropagation();
		} else if(e) {
			e.cancelBubble = true;
		} 
		
	}
	//---------------------------------------------------------------------------------------
	this.hideMagnifier = function(event) {
	
		var el;
		if(event) {
			el = this.gettarget(event);
			
			// If the active button was clicked on, exit.
			if (el == this.mag) return;
			if (el == this.mag_bg) return;
		
			// If the element is not part of a menu, reset and clear the active
			// button.
		}
		PAGEdom.removeNode(this.mag);
		mag_bg = this.mag_bg;
		if(typeof Effect == 'object') {
			new Effect.Opacity(this.mag_bg, {duration:0.3, from:0.7, to:0,afterFinish: this.sau_Effect_rmNode});
		} else if(typeof Ext == 'object') {
			var mag_bg = Ext.get(this.mag_bg);
			mag_bg.fadeOut({
				endOpacity: 0, 
				duration: .5,
				easing:'easeIn',
				remove:true,
				callback:function() {
					IF.magnifier_is_visible = false;
				}
			});
		} else {
			PAGEdom.removeNode(this.mag_bg);
			IF.magnifier_is_visible = false;
		}
		//new Effect.Puff(this.mag_bg, {duration:0.5,afterFinish: rmNode});
		//PAGEdom.removeNode(this.mag_bg);
	}	
	
	this.sau_Effect_rmNode = function(obj) {
		PAGEdom.removeNode(obj.element);
		IF.magnifier_is_visible = false;
	}
	
	//---------------------------------------------------------------------------------------
	this.coverbackground = function(vs,op) {
		
		if(!op) op = 0;
		
		if(!this.cover) {
			this.cover = document.createElement('div');
			this.cover.style.position = 'absolute';
			this.cover.style.zIndex = 5;
			this.cover.style.left = 0+'px';
			this.cover.style.top = 0+'px';
			this.cover.style.opacity = op; // set opacity for effect : filter:alpha(opacity=50); -moz-opacity:0.5; opacity:0.5; 
			this.cover.style.filter = "alpha(opacity:"+Math.round(op*100)+")";
			this.cover.style.backgroundColor = "#fff";
			document.getElementsByTagName('body')[0].appendChild(this.cover);
		}
		
		if(!vs) {
			this.cover.style.visibility = 'hidden';
		} else {
			ww = PAGEdom.getWindowWidth();
			wh = PAGEdom.getWindowHeight();
			st = PAGEdom.docScrollTop();
			bodyheight = st+wh;
			bodyheight = document.body.offsetHeight;
			this.cover.style.width = (ww-15)+'px';
			this.cover.style.height = ((bodyheight-15))+'px';
			this.cover.style.visibility =  'visible';			
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.setField = function(sourcefield_id,targetfield_id,value,disable) {

		sourcefield = $(sourcefield_id);
		targetfield = $(targetfield_id);
		//DebugDump(sourcefield.value,'sourcefield.value');
		if(targetfield.value != value) {
			targetfield.value = value;
		}
	
	}
	//---------------------------------------------------------------------------------------
	this.printDonation = function(printform) {
		
		
		var firstformEL = false;
	//if (!def_printversion_available) return alert('Es ist keine Druckansicht f\u00FCr diese Seite verf\u00FCgbar...');
		var contentEL = document.getElementById('content');
		var contentforms = contentEL.getElementsByTagName('FORM');
		for (var i=0; i<contentforms.length; i++) { 
			if(contentforms[i]) { firstformEL = contentforms[i]; break; }
		}	
		
		if(firstformEL) {
			//var o_target = firstformEL.target;
			var o_action = firstformEL.action;
			//firstformEL.target = printform;
			firstformEL.action = printform;
		}
		this.printVersion();
		//window.print();
		if(firstformEL) {
			//firstformEL.target = o_target;
			firstformEL.action = o_action;	
		}
	}

	this.printVersion = function() {
		var firstformEL = false;
	//if (!def_printversion_available) return alert('Es ist keine Druckansicht f\u00FCr diese Seite verf\u00FCgbar...');
		var contentEL = document.getElementById('content');
		var contentforms = contentEL.getElementsByTagName('FORM');
		for (var i=0; i<contentforms.length; i++) { 
			if(contentforms[i]) { firstformEL = contentforms[i]; break; }
		}
		//firstformEL.submit();
		//alert(firstformEL.name);
		if(firstformEL) var Ppath = firstformEL.action;//parent.content.myPlainPagePath;
		else var Ppath = parent.content.myPlainPagePath;
		
		var Pname = "PrintVersion";
		var no_w = '/none';
		var no_w = checkUrl(no_w);
		var WHeight = GetWindowHeight()-100;
		mywin = window.open(no_w,Pname,"top=20,left=30,width=540,height="+WHeight+",scroll=yes,scrollbars=yes,titlebar=no,status=no,toolbar=no,location=no,directories=no,menubar=yes,resizable=yes");
		
		Ppath = Ppath+"?print=true";
		var Ppath = checkUrl(Ppath);		
		//spendenformulardrucken
		if(firstformEL) {
			
			var o_target = firstformEL.target;
			var o_action = firstformEL.action;
			//alert(o_target);
			firstformEL.target = Pname;
			firstformEL.action = Ppath;
			firstformEL.onsubmit(); // workaround browser bugs.
			firstformEL.submit();
			firstformEL.target = o_target;
			firstformEL.action = o_action;			
		} else {
			mywin.location.href =createUrl(Ppath);
		}
		
		
		
		/*if (document.forms[formname]) { // this part will be true from now on
			var createdTempHidden = false;
			if (document.createElement) {
				switch (SmartAgent){
					case "Netscape6":
					case "MSIE5.5":
					case "Opera5":
					case "Khtml":
						try {
							var tempFormObj;
							var tempHiddenObj;
							tempFormObj = parent.content.document.forms[0];
							var tempHidden = 	parent.content.document.createElement('input');
							tempHidden.setAttribute('type','hidden');
							tempHidden.setAttribute('name','print');
							tempHidden.setAttribute('value','true');
							tempHiddenObj = tempFormObj.appendChild(tempHidden);
							var createdTempHidden = true;
						} catch(e) {
							Ppath = Ppath+"?print=true";
						}
						break;
				case "Netscape4":
				case "MSIE5":
				default:
					var Ppath = Ppath+"?print=true";
					var Ppath = createUrl(Ppath);
					break;
				}
			} else {
				var Ppath = Ppath+"?print=true";
				var Ppath = createUrl(Ppath);
			}
			setActionAndSubmit(Pname,Ppath,'parent.content.document.forms[0]');
			if (createdTempHidden) tempFormObj.removeChild(tempHidden);
		} else {
			var Ppath = Ppath+"?print=true"; 
			mywin.location.href =createUrl(Ppath);
		}
		*/
		
		if(mywin) mywin.focus();
	}

	//---------------------------------------------------------------------------------------
	this.buildWindow = function() {
		
		// window
		//bodyroot = document.getElementsByTagName('form')[0];
		if(!document.getElementById('content')) return;
		bodyroot = document.getElementById('content');
		this.w_wrapper = document.createElement("div");	
		

		this.w_wrapper.id = 'window';
		this.w_wrapper.className = 'window';
		this.w_wrapper.style.position = 'absolute';
		//this.w_wrapper.style.display = 'none';
		this.w_wrapper.style.visibility = 'hidden';
		this.w_wrapper.width = 300;
		this.w_wrapper.height = 300;
		this.w_wrapper.style.width = this.w_wrapper.width+'px';
		this.w_wrapper.style.height = this.w_wrapper.height+'px';
		this.w_wrapper.style.overflow = 'auto';
		//this.w_wrapper.style.border = '1px solid black';
		//this.w_wrapper.style.backgroundColor = 'white';
		//this.w_wrapper.style.zIndex = 100000;
		WWidth = PAGEdom.getWindowWidth();
		WHeight = PAGEdom.getWindowHeight();
		dst = PAGEdom.docScrollTop();
		var topheight = (((WHeight+dst)/2)-(this.w_wrapper.height/2));
		if(topheight<133) topheight = 133;
		this.w_wrapper.style.top = topheight+'px';
		var leftwidth = ((WWidth/2)-(this.w_wrapper.width/2));
		if(leftwidth<250) leftwidth = 250;
		this.w_wrapper.style.left = leftwidth+'px';
		bodyroot.appendChild(this.w_wrapper);

		this.makeNewWndow();
				
	}
	
	this.makeNewWndow = function() {
		this.window = new ContentWindow(this.title,this.w_wrapper.id);
		this.window.client_area_id = 'windowclientarea';
		this.window.title_id = 'windowtitlearea';
		this.window.init(this.window);	
	}
	
	//---------------------------------------------------------------------------------------
	this.gettarget = function(event) {

		if(window
		&& (window.event)
		&& (window.event.srcElement)) {
			t = window.event.srcElement;
		} else {
			t = (event.target.tagName ? event.target : event.target.parentNode);
		}
		return t;
	}	
	

	//---------------------------------------------------------------------------------------
	this.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;
		}
	
	}
	
	//---------------------------------------------------------------------------------------
	this.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;
		}
	
	}
}
IF = new Interface(); 
OnLoadFunctions[OnLoadFunctions.length] = "IF.init();";

var reg = 'phpos'; 
var is_phpos_environment = document.location.href.match(reg);
//OnLoadFunctions[OnLoadFunctions.length] = "DebugDump(found,'found');";
if(!is_phpos_environment) {
	browserSubmit = IF.browserSubmit;
	setDirPath = IF.setDirPath;
	changeDirPath = IF.changeDirPath;
}
//OnLoadFunctions[OnLoadFunctions.length] = "browserSubmit();";
//---------------------------------------------------------------------------------------
function checkSubmit() { // weiss nich, ob ich das brauche... ist der onsubmit gerade
	return true;
}

//---------------------------------------------------------------------------------------
function quicksearch(event) {
	if(event.keyCode != 13) return;
	INTERFACEdo_search();
}
//---------------------------------------------------------------------------------------
function INTERFACEdo_search() {

	setHidden('search','triggers');
	setActionAndSubmit('/suche','_self');
}




//---------------------------------------------------------------------------------------
//-- TinyMCE Settings -------------------------------------------------------------------
//---------------------------------------------------------------------------------------

IF.tinymceSettings = {
	theme : "advanced",
	height: "400", //config.height,
	plugins: "safari,pagebreak,style,advhr,advimage,advlink,emotions,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,noneditable,visualchars,nonbreaking",
	theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,code",
	theme_advanced_buttons3 : "hr,removeformat,|,sub,sup,|,charmap,media,advhr,|,ltr,rtl,|,insertdate,inserttime,preview,|,forecolor",
	//theme_advanced_buttons4 : "styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking",
	
	//theme_advanced_buttons4 : "styleprops,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",
	theme_advanced_resizing : false,
	//extended_valid_elements : //"a[name|href|target|title|onclick],img[class|src|border=0|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name],hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",
	//theme_advanced_blockformats : "p,h1,h2,h3,h4,h5,h6,blockquote,div,address",
	
	
	/* linebreak tests, hier scheint etwas schlimmeres nicht zu stimmen...
	forced_root_block:false,
	remove_linebreaks:false,
	//force_p_newlines:false,
	//force_br_newlines:true,
	apply_source_formatting:true,
	entity_encoding:"",
	cleanup:false,
	cleanup_on_startup:true,
	//convert_newlines_to_brs:true,
	
	force_p_newlines:false,
	force_br_newlines:true,
	convert_newlines_to_brs:false,
	remove_linebreaks:true,					
	cleanup:false,
	
	*/
	cleanup_on_startup:false,
	//cleanup:false,
	verify_html:false,
	//template_external_list_url : "example_template_list.js"
	//file_browser_callback : "FileBrowser"
	file_browser_callback:"ezfilemanager",
	relative_urls:false,
	theme_advanced_enable:"styleselect",
	content_css: "/mcms/wolfundjaeger/_css/wysiwyg.css",
	body_id:'content',
	body_class:'p-normargin',	 
	language:"de"
	//onchange_callback:"myCustomOnChangeHandler"
	//add_form_submit_trigger:true
	//body_id:"content"
};


//---------------------------------------------------------------------------------------
//-- Size Functions -------------------------------------------------------------------
//---------------------------------------------------------------------------------------

function AdjustFontSize() {

	this.sizeUnit = "%";
	this.defaultSize = 100;
	this.maxSize = 125; // Windows 125! / Mac 145
	this.minSize = 90;

	this.init = function() {
		CFS = new CookieManager('fontSize');
		if ( !document.body || !document.getElementById ) return;
		var size = window.location.search? window.location.search.slice(1): CFS.getValue("fontSize");
		size = !isNaN( parseFloat(size) )? parseFloat(size): this.defaultSize;
		// in case default unit changed or size passed in url out of range
		if ( size > this.maxSize || size < this.minSize ) size = this.defaultSize;
		document.body.style.fontSize = size + this.sizeUnit;
	}
  
	this.adjust = function(inc) {
		var size = parseFloat( document.body.style.fontSize );
		/* !!!!! Änderung  Anfang !!!! */
		size = !isNaN( parseFloat(size) )? parseFloat(size): this.defaultSize;
		/* !!!!! Änderung Ende  !!!! */
		size += inc;
		// Test against max and min sizes 
		if (inc > 0) size = Math.min(size, this.maxSize);
		else size = Math.max(size, this.minSize);
		CFS.save( "fontSize", size, 180, "/" );
		document.body.style.fontSize = size + this.sizeUnit;
	}

	this.reset = function() {
		document.body.style.fontSize = this.defaultSize + this.sizeUnit;
		CFS.del("fontSize", "/");
	}
}


function Browser() {

  var ua, s, i;

  this.isIE    = false;  // Internet Explorer
  this.isOP    = false;  // Opera
  this.isNS    = false;  // Netscape
  this.version = null;

  ua = navigator.userAgent;

  s = "Opera";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isOP = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as Netscape 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }

  s = "MSIE";
  if ((i = ua.indexOf(s))) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }
}

var browser = new Browser();


//--------------------------------------------------------------------------------------- //
function KSPL () {
	
	this.init = function() {
		

		//setTimeout(function(){this.initCarousel();}.bind(this), 500);
		


	}

	//---------------------------------------------------------------------------------------
	this.fixContentHeight = function() {
		var h = $('prfcol1').offsetHeight;
		var h2 = $('prfcol2').offsetHeight;
		if(h > h2) {
			$('prfcol2').style.height = h+'px';
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.clearOnFocus = function() {
		/**
		* Clears all input/textareas with classname "clearonfocus"
		* on focus-Mouseevent.
		*/
		$$('.cof').each(function(input) {
			input._defaultValue = input.readAttribute('title');
			input.observe('focus', function(ev) {
				if(input.value == input._defaultValue) {
					input.value = '';
				}
				input.addClassName('on-focus');
			});
			input.observe('blur', function(ev) {
				if(input.value == '') {
					input.value = input._defaultValue;
				}
				input.removeClassName('on-focus');				
			});
			
		});	
	}
	
	//---------------------------------------------------------------------------------------
	this.inputValues = new Array();
	/*
	 * clearOnFocusSA = StandAlone - to be called in html onfocus 
	 */
	this.clearOnFocusSA = function(input) {
	  $(input).addClassName('on-focus');
	  if(this.inputValues[$(input).getAttribute('id')] == null) {
	  	var l_code = $(input).getAttribute('rel');
	  	var value = $(input).value;
	  	if(value != $L(l_code)) return false;
		this.inputValues[$(input).getAttribute('id')] = value;
		$(input).value = '';
	  }
	}
	
	/*
	 * fillOnBlurSA = StandAlone - to be called in html onblur
	 * fills the element with the value stored in Array inputValues[]
	 */
	this.fillOnBlurSA = function(input) {
	  $(input).removeClassName('on-focus');
	  if(input.value == '' && this.inputValues[$(input).getAttribute('id')] != null) {
		$(input).value = this.inputValues[$(input).getAttribute('id')];
		delete this.inputValues[$(input).getAttribute('id')];
	  }
	}
	//---------------------------------------------------------------------------------------
	this.switchToPassword = function(input, target) {
	  Element.hide(input);
	  Element.show(target);
	  Element.removeClassName($(target), 'invisible');
	  $(target).focus();
	  $(target).addClassName('on-focus');
	  $(input).addClassName('on-focus');
	  /*var inputE = $(input);
	  var tabindex = inputE.getAttribute('tabindex');
	  inputE.removeAttribute('tabindex');
	  Element.writeAttribute(target, 'tabindex', tabindex);
		*/
	}
	
	this.switchToTextfield = function(input, target) {
	 
	  if(input.value.length == 0) {
		Element.hide(input);
		Element.show(target);
		/*var inputE = $(input);
		var tabindex = inputE.getAttribute('tabindex');
		inputE.removeAttribute('tabindex');
		$(target).setAttribute('tabindex', tabindex);
	  	*/
	  }
	  $(target).removeClassName('on-focus');
	  $(input).removeClassName('on-focus');
	}
	
	
	
	//---------------------------------------------------------------------------------------
	//---------------------------------------------------------------------------------------
	this.services = {}; this.servicesopen = false; this.hasChanges = false; // formname

	
	this.check4Changes = function(e) {
		
		if(this.hasChanges !== false) {
			
			var tEl = IF.gettarget(e);

			this.showMessage({
				bt: tEl ? tEl : false,
				tEl:tEl,
				height:150,
				width:300,
				iconCls:'x-horsesshuh-ico',
				title:$L('hint'),
				html:'<p class="winmsg">'+$L('you_have_unsaved_changes')+'</p>',
				defaultButton:2,
				y:300,
				buttons:[{
					 text: $L('cancel')
					,scope:this
					,handler:function(button) {
						//FNK.hasChanges = false;
						button.ownerCt.close();
						//location.href = tEl.getAttribute('href');
					}							
				},{
					 text: $L('donot_save')
					,scope:this
					,handler:function(button) {
						FNK.hasChanges = false;
						button.ownerCt.close();
						location.href = tEl.getAttribute('href');
					}							
				},{
					 text: $L('save_changes')
					,scope:this
					,handler:function(button) {
						button.ownerCt.close();
						IF.justSubmit(FNK.hasChanges);
					}							
				}]
			});
						
			return false;
		}
		return true;
	}
	

	
	this.setMissionMessage = function(i,msg) {
		
		// mm1, mmessage1
		// hide 
		var mm = Ext.get('mm'+i);
		if(!mm) return false;
		if(mm.getStyle('display') == 'none') {
			mm.slideIn('t',{
				easing: 'easeOut',
				duration: .5,
				scope:this,
				useDisplay: true
			});	
		}
		$('mmessage'+i).innerHTML= msg;
		
	}
	
	//---------------------------------------------------------------------------------------
	this.hideGlobalMessage = function(id,sid) {
		this.hideMessage(id);
		//$('space-if-no-highlight').removeClassName('invisible');
		
		// save on blacklist
		var post = '';
		post += 'fields[sid]='+URLEncode(sid);
		post += '&control[method]=setread';
		post += '&control[class]=globalmessageblacklist';
		
		var url = '/php-os/app_local/scripts/update.php';		
		Ext.Ajax.request({
			scope:this,
			method:'post',
			sid:sid,
			url: url,
			success: function(response,options){
				//var rData = Ext.util.JSON.decode(response.responseText);//passed back from server
			},
			failure: function(response,options){ 
			},
			params: post
		});					
		
	}
	
	//---------------------------------------------------------------------------------------
	this.autocancel = function(e,sid,o) {
		if(e) {
			var el = Event.element(e);
			if(el.id == ('ieNik'+sid)) return;
			container = PAGEdom.getContainer(el, $('userservice'+sid));
			if(container != null) return;
		}
		if($('ieNik'+sid)) $('ieNik'+sid).style.display='none';
		Event.stopObserving($('ieNik'+sid), 'keydown');
		Event.stopObserving(document.body, 'click');
		if($('ieNikAccept'+sid)) $('ieNikAccept'+sid).style.display='none';
		if($('ieNikID'+sid)) $('ieNikID'+sid).style.display='none';
		if($('servicetitle'+sid)) $('servicetitle'+sid).style.display='';
		//this.bodycancel = 0;
	}
	
	//---------------------------------------------------------------------------------------
	this.checkAllByClassName = function(id,classname) {

	}
	
	//---------------------------------------------------------------------------------------
	this.hideMessage = function(id,context) {
		
		// hide 
		var mm = Ext.get(id);
		if(!mm) return false;
		mm.slideOut('t',{
			easing: 'easeOut',
			duration: .5,
			scope:this,
			//remove: true,
			useDisplay: true
		});
				
	}
	
	//---------------------------------------------------------------------------------------
	this.displayDown = function(e,t) {
		var l = Ext.get(t);
		var p = l.next(false,true);
		var pl = Ext.get(p);
		if(p && pl.hasClass('collapsed-content') && (pl.is('h3') != true)) {
			if(pl.getStyle('display') == 'none') pl.setStyle('display','block');
			else pl.setStyle('display','none');
			this.displayDown(e,p);
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.disable = function(obj) {

		//if(typeof console == 'object') console.log('x obj: %o',obj);
		for(id in obj) {
			//if(typeof console == 'object') console.log('x obj.id: %o',obj.id);
			if(obj && obj.id && obj.id.length >0 && $(obj.id)) {
				$(obj.id).addClassName('disabled');
				$(obj.id).disabled = true;
			}
		}			
	}
	
	this.enable = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if(obj && obj.id && obj.id.length >0 && $(obj.id)) {
				$(obj.id).removeClassName('disabled');
				$(obj.id).disabled = false;
			}
		}
	}
	
	//---------------------------------------------------------------------------------------
	this.hideContainer = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if($(obj.id)) {
				$(obj.id).addClassName('hidden');
				//$(obj.id).disabled = true;
			}
		}			
	}
	
	this.showContainer = function(obj) {
		for(id in obj) {
			//DebugDump(obj.id,id);
			if($(obj.id)) {
				$(obj.id).removeClassName('hidden');
				//$(obj.id).disabled = false;
			}
		}
	}	
	
	//---------------------------------------------------------------------------------------
	this.showMessage = function(o) {
		
		var d = {
			animEl: o.bt ? o.bt.id : false,
			modal: o.modal ? true : false,
			minWidth:350,
			stateful:false,
			shadow:true,
			shadowOffset:8,
			shim:false,	
			closable:false,
			cls:'x-friendnik'
		};
		
		if(typeof o != 'object') var o = {};
		o = Ext.apply(o,d);
		
		var win = new Ext.Window(o);
		if(o.bt) win.show.defer(50, win,[o.bt.id]);
		else win.show.defer(50, win);
	}	
	
	
	this.mask = function(msg) {
		if(!msg) var msg = $L('Loading...')
		var m = Ext.getBody().mask();

		var tpl = '';
		tpl += '<div id="horseloading">';
		tpl += '<img src="/local/media/images/loading/run.png" width="698" height="474" />';
		tpl += '<div class="horse-loading-msgwr">';
		tpl += '<img src="/local/media/images/loading/circle.gif" width="66" height="66" />';
		tpl += msg;
		tpl += '';
		tpl += '';
		tpl += '';
		tpl += '';
		tpl += '</div>';
		tpl += '</div>';
		Ext.getBody().insertHtml('beforeEnd',tpl);
	}
	//---------------------------------------------------------------------------------------
	this.loadData= function(data) {
		//DebugDump(data,'data');
		this.data = data;
	}
	//---------------------------------------------------------------------------------------
	/*this.activeMenuitem = false;
	this.loadContent = function(cid) {
		
		if(this.activeMenuitem == cid) return true;
		
		if(this.activeMenuitem) {
			$(this.activeMenuitem).style.display='none';
		}
		$(cid).style.display='';
		this.activeMenuitem=cid;
	}*/
	
}

var FNK = new KSPL();

//--------------------------------------------------------------------------------------- //
if(typeof Ext == 'object') {
	Ext.BLANK_IMAGE_URL = '/images/spacer.gif';
	// application main entry point
	Ext.onReady(function() {
		IF.setFooter();
		//DebugDump(IF.contentHeight,'contentHeight');
		FNK.init();
		//FNK.loadContent('start');
		// ggogle maps
		var mapwin;
		var button = Ext.get('show-btn');
		
		var use_gmap = true;
		
		if(use_gmap) {
			FNK.overlayIdx=0;
			FNK.panel = new Ext.ux.GMapPanel({
				//layout: 'fit',
				frame: false,
				border: false,
				height: (IF.contentHeight > 0) ? IF.contentHeight : 600,
				width: 780,
				x: 1, 
				y: 1,
				renderTo: 'plan_wr_r',// Ext.getBody(), // 'plan_wr_r',//

				zoomLevel: 13,
				gmapType: 'map',
				mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
				mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
				setCenter: {
					geoCodeAddr: 'Sperber Weg 1, Erkrath, de',
					marker: {title: 'Die Mitte',clear:true},
					mark:'hidden'
				}
			});

			//FNK.panel.show();
			FNK.panel.showLocations('start','start');

		} else { // my map
		
			var i = document.createElement('img');
			i.src = SUBFOLDER_WWW_ROOT+'/images/plan/Erkrath_2009-w1200.png';
			//DebugDump(i,'i' +i.src);
			FNK.panel = new Ext.ux.PanPanel({
				frame: false,
				border: false,
				/*tbar:new Ext.Toolbar({
					items:[{
							xtype: 'tbtext', 
							text: '<img style="" src="/images/spacer.gif" width="1" height="16" />'				
						},
						{xtype:'tbspacer'},{xtype:'tbfill'},
						new Ext.Toolbar.Button({ text: 'Zoom Out', id:'zoomOut',handler: FNK.panel.zoomOut, scope: this }),
						new Ext.Toolbar.Button({ text: 'Zoom In', id:'zoomIn',handler: FNK.panel.zoomIn, scope: this }),
						{xtype:'tbseparator'},
						{xtype:'tbspacer'}]
				}),*/	
				//title: 'A Big photo',
				client: i,
				cls:'x-plan x-local',
				height: 600,
				width: 790,
				floating: true,
				x: 1, 
				y: 1,
				renderTo: 'plan_wr_r',// Ext.getBody(), // 'plan_wr_r',//
				listeners: {
					render: function(p) {
						new Ext.Resizable(p.getEl(), {
							handles: 'all',
							pinned: true,
							transparent: true,
							resizeElement: function() {
								var box = this.proxy.getBox();
								p.updateBox(box);
								if (p.layout) {
									p.doLayout();
								}
								return box;
							}
					   });
					  
				   },
				   show: function(p) {
					 //p.setPos(240,250); //w2000
					 p.setPos(105,167); //w2000
				   }
			   }
			});
			//FNK.panel.setPos(240,250);
			FNK.panel.show();
		}

	}); // eo function onReady

	
	// http://www.extjs.com/forum/showthread.php?t=35505, Ext.ux.PanPanel
	// http://www.extjs.com/forum/showthread.php?t=87081 zoom, rotate
	Ext.ux.PanPanel = Ext.extend(Ext.Panel, {
		constructor: function(config) {
			config.autoScroll = false;
			Ext.ux.PanPanel.superclass.constructor.apply(this, arguments);
			this.transformations = {
				zoom: 100
			};
			
			this.zoomLevels = {
				z1:SUBFOLDER_WWW_ROOT+'/images/plan/Erkrath_2009-w1200.png',
				z2:SUBFOLDER_WWW_ROOT+'/images/plan/Erkrath_2009-w1600.png',
				z3:SUBFOLDER_WWW_ROOT+'/images/plan/Erkrath_2009-w2000.png'
			};
			
			this.activeZoomLevel = 'z1';
			this.activeLocations = false;
			this.openSubmenu = false;
			this.openLocationwindow = false;
			this.locationWin=false;
		},
	
		onRender: function() {
			Ext.ux.PanPanel.superclass.onRender.apply(this, arguments);
			this.body.appendChild(this.client);
			this.client = Ext.get(this.client);
			this.client.on('click', this.onMouseClick, this);
			this.client.on('mousedown', this.onMouseDown, this);
			this.client.setStyle('cursor', 'move');
			
		},
	
		onMouseDown: function(e) {
			e.stopEvent();
			this.mouseX = e.getPageX();
			this.mouseY = e.getPageY();
			Ext.getBody().on('mousemove', this.onMouseMove, this);
			Ext.getDoc().on('mouseup', this.onMouseUp, this);
		},
	
		onMouseMove: function(e) {
			e.stopEvent();
			var x = e.getPageX();
			var y = e.getPageY();
			if (e.within(this.body)) {
				var xDelta = x - this.mouseX;
				var yDelta = y - this.mouseY;
				this.body.dom.scrollLeft -= xDelta;
				this.body.dom.scrollTop -= yDelta;
			}
			this.mouseX = x;
			this.mouseY = y;
		},
	
		onMouseUp: function(e) {
			Ext.getBody().un('mousemove', this.onMouseMove, this);
			Ext.getDoc().un('mouseup', this.onMouseUp, this);
		},
		
		onMouseClick:function(e) {
			e.stopEvent();
			var x = e.getPageX();
			var y = e.getPageY();
			if (e.within(this.body)) {			
				this.showCoordinatesOnClick(x,y);
			}
			
		
		},
		
		getScrollTop:function() {
			return this.body.dom.scrollTop;
		},

		getScrollLeft:function() {
			return this.body.dom.scrollLeft;
		},
		setScrollTop:function(y) {
			this.body.dom.scrollTop = y;
		},
		setScrollLeft:function(x) {
			this.body.dom.scrollLeft = x;
		},
		
		setPos:function(y,x) {
			this.body.dom.scrollTop = y;
			this.body.dom.scrollLeft = x;
			//DebugDump(this.body.dom.scrollTop,'this.body.dom.scrollLeft '+this.body.dom.scrollLeft);
		},

		
		// Zoom - static
		zoomImgIn: function() {
			switch(this.activeZoomLevel) {
				case'z1':
					DebugDump(this.client,'this.client');
					this.client.src=this.zoomLevels.z2;
					this.activeZoomLevel = 'z2';
					break;
			}
		},		
		
		// locations
		showLocation:function(p_id,i_id) { // click on second level menu-item
			
			// highlight 
			this.highlightLocation(p_id,'map_'+i_id);
			// show window
			this.showLocationWindow(p_id,i_id);			
		
		},
		
		showLocations:function(p_id) { // click on first level menu-item 
						
			if(!this.data) this.data = FNK.data; // get from papa
			
			this.client.setOpacity(.5,true);
			
			// show menu
			if(this.openSubmenu != p_id) {
			
				if(this.openSubmenu) {
					// close menu
					var ct = Ext.get('menu_'+this.openSubmenu);
					ct.vis = false;				
					ct.slideOut('t',{
						easing: 'easeIn',
						duration: .5,
						useDisplay:true,
						concurrent:true
					});
					ct.fadeOut({endOpacity:0,duration:.5,concurrent:true});				
				}
				
				// open menu
				var mt = Ext.get('menu_'+p_id);
				mt.slideIn('t',{
					easing: 'easeIn',
					duration: .5,
					useDisplay:true,
					concurrent:true
				});
				mt.fadeIn({endOpacity:1,duration:.5,concurrent:true});
				mt.vis = true;			
				
				this.openSubmenu = p_id;
			
			}
			
			// hide all map icons
			if(this.activeLocations && this.activeLocations != p_id) {
				this.resetLocations(this.activeLocations);
			}
			
			var x1 = this.body.dom.scrollLeft;
			var y1 = this.body.dom.scrollTop;		

			// go through locations and show them
			for(dkey in this.data[p_id]) {
				var io = Ext.get('map_'+dkey);
				if(!io) {
					var i = document.createElement('img');
					i.src = SUBFOLDER_WWW_ROOT+this.data[p_id][dkey]['icon_plan'];
					i.id = 'map_'+dkey;
					this.body.appendChild(i);
					var io = Ext.get(i);
					io.addClass('map-icon');
					//io.setStyle({position:'absolute',left:0,top:0});
					var x = this.data[p_id][dkey]['x']-x1;
					var y = this.data[p_id][dkey]['y']-y1;
					io.setXY([x,y],true);
				} else {
					var vis = io.getStyle('visibility');
					if(vis == 'hidden') io.setStyle({visibility:'visible'});
					this.highlightLocation(p_id,io.id);
				}
			}
			
			this.activeLocations=p_id;
		},
		
		
		resetLocations: function(p_id) {
			// go through locations and hide them
			for(dkey in this.data[p_id]) {
				var io = Ext.get('map_'+dkey);
				DebugDump(io,'io map_'+dkey);
				io.setStyle({visibility:'hidden'});
			}
		},
		
		
		highlightLocation: function(p_id,i_id) {
			
			var io = Ext.get(i_id);
			if(io) {
				//DebugDump(io,'io');
				io.highlight("cb0a1d",{attr:'borderColor',duration:1});
			}
		},

		showLocationWindow: function(p_id,i_id) {
			
			var winHeight = 400;
			var winWidth = 300;
			
			// get position
			var io = Ext.get('map_'+i_id);
			var pos = io.getXY();
			
			var wx = (pos[0]-(winWidth+10));
			var wy = (pos[1]-(winHeight/2)); // half height
			var content = this.getWindowContent(p_id,i_id);
			
			// set x
			var WWidth = GetWindowWidth();
			if(wx > (WWidth/2)) {
				var wx = (pos[0]-(winWidth+10));
			} else var wx = (pos[0]+40);
			
			if(wy < 55) {
				var wy = 55;
			} else if((wy+winHeight) > 660) var wy = 660-winHeight; 
			
			var win = Ext.getCmp('mapwindow');
			
			if(!win) {
				var d = {
					animEl: 'map_'+i_id,
					border:false,
					header:false,
					modal: false,
					id:'mapwindow',
					width:winWidth,
					height:winHeight,
					minWidth:winWidth,
					stateful:false,
					html:content,
					resizable:false,
					style:{zIndex:11999},
					x:wx,
					y:wy,
					shadow:true,
					shadowOffset:8,
					shim:false,	
					closable:false,
					defaultButton:0,
					buttons:[{
						 text: $L('schließen')
						,scope:this
						,handler:function(button) {
							button.ownerCt.close();
						}							
					}],
					cls:'x-local x-max-zindex'
				};
				
				if(typeof o != 'object') var o = {};
				o = Ext.apply(o,d);
				
				win = new Ext.Window(o);
				win.cdata = this.data[p_id][i_id];
				
				win.on("close", this.onCloseWin, this); 
				win.on("show", function(w) {
						
						FNK.panel.checkAndSetPosition(w);
						FNK.panel.setGMap(w.cdata);
					},win,{delay:50}
				); 				
			} else {
				win.cdata = this.data[p_id][i_id];
				win.body.update(content);
				win.setPosition(wx,wy);
				if(!win.hidden) this.setGMap(win.cdata);
			}
			
			
			win.show(['map_'+i_id]);
			this.openLocationwindow = i_id;
			
		},	
		
		onCloseWin:function() {
			this.openLocationwindow=false;
		},



		checkAndSetPosition: function(win) {
			
			scrolltop = PAGEdom.docScrollTop();
			var WHeight = GetWindowHeight();
			var WWidth = GetWindowWidth();
			var update_position = false;
			max = (scrolltop+WHeight);
	
			// height
			if(win.y<0) update_position = true;
			if(win.y<scrolltop) update_position = true;
			if((win.y+win.height)>(scrolltop+WHeight)) update_position = true;
	
			// width
			scrollleft = PAGEdom.docScrollLeft();
			var WWidth = GetWindowWidth();	
			if(win.x<0) update_position = true;
			if(win.x<scrollleft) update_position = true;
			if((win.x+win.width)>(scrollleft+WWidth)) update_position = true;		
	
			if(update_position) {
				win.setPosition(((WWidth/2)-(win.width/2)),(scrolltop+50));
			}
	
		},
			
		
		getWindowContent: function(p_id,i_id) {
			// create content
			
			var data = this.data[p_id][i_id];
			//DebugDump(data,'data');
			
			var tpl='<div id="mapwin_content" class="w-content">';
			tpl+='<h1>';
			tpl+='<img class="w-icon" src="'+data['icon_window']+'" />';
			tpl+=''+data['description'];
			tpl+='</h1>';
			
			tpl+='<div class="w-hr"></div>';
			
			if(data['img'] && data['img'].length>0) tpl+='<img class="w-img" src="'+data['img']+'" />';
			tpl+='<p>';
			tpl+=''+data['street']+' &bull; '+data['city']+'<br />';
			if(data['tel'] && data['tel'].length>0) {
				tpl+='Tel.: '+data['tel']+'<br />';
			}
			if(data['email'] && data['email'].length>0) {
				tpl+='email: <a href="mailto:'+data['email']+'">'+data['email']+'</a><br />';
			}
			if(data['www'] && data['www'].length>0) {
				tpl+='<a href="'+data['www']+'" target="_blank">'+data['www']+'</a><br />';
			}
			tpl+='</p>';
			
			tpl+='<div class="w-hr"></div>';
			
			tpl+='<p>';
			tpl+='<b><a href="'+data['gmap']+'" target="_blank">Google Map: Standort der Kirche</a></b>';
			tpl+='<div id="gmap"></div>';
			tpl+='';
			tpl+='</p>';
			tpl+='';
			tpl+='';
			tpl+='';
			tpl+='</div>';		
			
			return tpl;
		},

		setGMap: function(cdata) {
			if(!cdata['geoCodeAddr'] || cdata['geoCodeAddr'].length==0) {
				cdata['geoCodeAddr'] = cdata['description']+', '+cdata['street']+', '+cdata['city']+', de';
			}

			var gmap = Ext.get('gmap');
			var gmapcontainer = Ext.getCmp('localgmappanel');
			if(gmapcontainer) {
				gmapcontainer.destroy();
				gmapcontainer=false;
			}
			if(!gmapcontainer) {
				new Ext.Container({
					applyTo:gmap,
					id:'gmapcontainer',
					//width:270,
					height:180,
					items:{
						xtype: 'gmappanel',
						id:'localgmappanel',
						zoomLevel: 14,
						style:{border: '1px solid #002b4e'},
						gmapType: 'map',
						mapConfOpts: ['enableScrollWheelZoom','enableDoubleClickZoom','enableDragging'],
						mapControls: ['GSmallMapControl','GMapTypeControl','NonExistantControl'],
						setCenter: {
							geoCodeAddr: cdata['geoCodeAddr']
							,marker: {title: cdata['description']}
						}/*,
						markers: [{
							lat: 42.339641,
							lng: -71.094224,
							marker: {title: 'Boston Museum of Fine Arts'},
							listeners: {
								click: function(e){
									Ext.Msg.alert('Its fine', 'and its art.');
								}
							}
						},{
							lat: 42.339419,
							lng: -71.09077,
							marker: {title: 'Northeastern University'}
						}]*/
					}
				});						
			} else {
				 gmapcontainer.geoCodeLookup(cdata['geoCodeAddr']);
			}
		},
		
		// Zoom - numeric

		zoomIn: function() {
			this.zoom(10);
		},

		zoomOut: function() {
			this.zoom(-10);
		},
		
		canZoomIn: function() {
			return this.transformations.zoom < 100;
		},

		canZoomOut: function() {
			return this.transformations.zoom > 50;
		},		
	
		getZoomSize: function() {
			var size = this.getSize(), zoom = this.transformations.zoom;
			return { width: size.width * zoom / 100, height: size.height * zoom / 100 };
		},

		getSize: function() {
			if (!this.client.size) {
				this.client.size = this.client.getSize(); //this.client.getEl().getSize();
			}
			return this.client.size;
		},

		zoom: function(increment) {
			var el = this.client;
			this.transformations.zoom += increment;
			var newSize = this.getZoomSize();

			el.setSize(newSize.width, newSize.height);

			//this.children.zoomOut.setDisabled(!this.canZoomOut());
			//this.children.zoomIn.setDisabled(!this.canZoomIn());
		},
		
		getZoomLevel:function(e,level) {
			
		},
		
		setZoomLevel:function(e,level) {
			
		},
		
		// utilities
		showCoordinates: function() {
			this.coordEL = Ext.get('coord');
			if(this.coordEL) {
				document.getElementById('coord').innerHTML = 't: '+this.getScrollTop()+', l: '+this.getScrollLeft();
			}
		},
		
		showCoordinatesOnClick: function(x,y) {
			this.coordEL = Ext.get('coord');
			if(this.coordEL) {
				var x1 = (x - this.body.dom.scrollLeft);
				var y1 = (y - this.body.dom.scrollTop);	//' / window: t: '+y1+', l: '+x1 + 

				var x2 = (x + this.body.dom.scrollLeft);
				var y2 = (y + this.body.dom.scrollTop);				
				
				document.getElementById('coord').innerHTML = 'page - t: '+y+', l: '+x + ' / <b>window</b>: t: '+y2+', l: '+x2 ;
			}
		}
		
	});
	


}



/*
function Lf(a,b){
	if(typeof console == 'object') console.log('x a: %o',a);
	if(typeof console == 'object') console.log('x b: %o',b);
	a=a.style;
	a.width=b.getWidthString();
	a.height=b.getHeightString();
}
*/
