function wincenter(uri, target, width, height)
{
	x = (screen.availWidth - width) / 2;
	y = (screen.availHeight - height) / 2;
	sStyles = "width=" + width + 
				",height=" + height +
				",left=" + x + 
				",top=" + y + 
				",resizable=yes, scrollbars=yes, toolbar=no, menubar=no, status=no ";
	wnd = window.open( uri , target, sStyles );
	wnd.focus();
	
	return wnd;
}

function I(id)
{
	return document.getElementById(id);
}

function confirmdelete(uri_yes) {
	if( confirm("Wirklich löschen ?") == true )
	{
		window.open( uri_yes, "_self" );
		return true;
	}
}

//--- Reisetitel für Suche mit % belegen
function transformReititle(filter)
{
	if(document.getElementById('reititel').value.indexOf("%") == -1)
	{
		document.getElementById('reititel').value += "%";	
	}	
	if(filter)
	{
		document.getElementsByName(filter)[0].submit();		
	}
	
}

//--- tauscht zwei Bilder (Reisedisplay)
function SwapImage(ID1,ID2) 
{	
	var theImage1 = document.getElementById( ID1 );
	var theImage2 = document.getElementById( ID2 );
	var sSrc2 = theImage2.src;
	theImage2.src = theImage1.src;
	theImage1.src = sSrc2;

	var sAlt2 = theImage2.alt;
	theImage2.alt = theImage1.alt;
	theImage1.alt = sAlt2;

	var sTitle2 = theImage2.title;
	theImage2.title = theImage1.title;
	theImage1.title = sTitle2;
}


//--- liest URL und setzt Hotelsterne
function setREIKLASSEasCheckbox()
{
	var parameter = location.search.substr(1,location.search.length - 1);
	parameter = parameter.split("&");	
	for(var i = parameter.length-1; i >= 0; i--)
	{		
		if(parameter[i].indexOf("REIKLASSE") > -1)
		{
			star = parameter[i].split("=");
			if(document.getElementById("REIKLASSE_" + star[1]))
			{
				document.getElementById("REIKLASSE_" + star[1]).checked = true;	
			}
		}		
	}
}

//--- Sortierung in Klasse gekapselt
function cSort(QueryString)
{
	this.arSort = new Array();
	this.QueryString = QueryString;				
	this.cssDown = false;
	this.cssUp = false;
	
	this._init = function(e)
	{
		this._setCss();
		this._createOnClick();
	}
					
	this.init = function(isOnload)
	{
		if(isOnload)
		{
			this._init();
		}else{
			addEvent(window,"load",this._init.scope(this));
		}
	}
	
	//--- onClick erstellen
	this._createOnClick = function()
	{
		for(var id in this.arSort)
		{						
			sort_colname = this.arSort[id];
			var obj = document.getElementById(id);
			if(!obj)
			{
				delete this.arSort[id];
				continue;
			}
			addEvent(obj,"click",this.changeSortOrder.scope(this));
		}
	}
	
	//--- Ids zum sortieren sammeln
	this.load = function(id, sort_colname)
	{
		if( !sort_colname )
			this.arSort[id] = id;
		else
		{
			this.arSort[id] = sort_colname;
		}
	}
	
	this.loadCss = function(cssDown,cssUp)
	{
		this.cssDown = cssDown;
		this.cssUp = cssUp;
	}
	
	this._setCss = function()
	{
		if(!this.cssDown && !this.cssUp)
		{
			return false;
		}
		objSortby = document.getElementById( getSearch(false,"sortby_xml") );		
		sortorder = getSearch(null,"sortorder_xml");
		if(objSortby)
		{
			if(sortorder == "descending")
			{																
				objSortby.className = this.cssDown;
			}else{
				objSortby.className = this.cssUp;
			}
		}	
	}
	
	//--- SortOrder ändern und abschicken
	this.changeSortOrder = function(e)
	{
		var sortby = getETarget(getE(e));
		
		sortby = this.arSort[sortby.id];
		
		var url = "list.reisen.php?" + this.QueryString;
		
		url = rigUrl(url,'sortby_xml',sortby);
		
		sortorder = getSearch(false,"sortorder_xml");	
		if(sortorder != "ascending" || sortby != getSearch(null,'sortby_xml'))
		{
			rigUrl(url,'sortorder_xml','ascending',true);
		}
		else
		{
			rigUrl(url,'sortorder_xml','descending',true);
		}
	}				
}

//--- Verbindet einen Karteikartenkopf mit dem Inhalt und setzt ein onclick event
function cKarteikarte(headMain, contentMain, activeCSS, inactiveCSS, active)
{
	this.arKartei = new Array();

	this.headMain = (headMain) ? headMain : "";
	this.contentMain = (contentMain) ? contentMain : "";

	this.activeCSS = (activeCSS) ? activeCSS : false;
	this.inactiveCSS = (inactiveCSS) ? inactiveCSS : false;

	this.active = (active) ? active : false;	
	this.arCFG = new Array();
	
	//--- Verknüpfung Karteikarte und Content herstellen
	this.load = function(head,content)
	{
		if((!head && !this.headMain) || (!content && !this.contentMain))
		{
			return false;
		}
		head 	= this.headMain + head + "";			//--- Id des Karteikarten Kopfes
		content = this.contentMain + content + "";		//--- Id des dazu gehörigen Karteikarten Content
		this.arKartei[head] = new Array();
		this.arKartei[head]['content'] = content;		//--- Verbindung merken
	}
	
	//--- Konfiguration
	this.config = function(displayNoContent, noClickEvent)
	{
		this.arCFG['displayNoContent'] = (displayNoContent) ? true : false;
		this.arCFG['noClickEvent'] = (noClickEvent) ? true : false;
		
	}
	
	//--- ein Hilfsfeld speichert mit welche Karteikarte momentan aktiv ist
	this.activateWithField = function(field)
	{
		this.activateField = (field) ? field : false;;		
	}
	
	//--- Karteikarte initialisieren
	this._init = function()
	{
		
		this.activateField 	= document.getElementById(this.activateField);
		this.activateField 	= (this.activateField) ? this.activateField : false;
		this.active 		= (this.activateField && this.activateField.value) ? this.activateField.value : this.active;
		
		for(var head in this.arKartei)
		{
			content = document.getElementById(this.arKartei[head]['content']);
			objHead = document.getElementById(head);					
			if(!objHead)
			{
				continue;
			}
			if(!content)
			{
				if(!this.arCFG['displayNoContent'])
				{
					objHead.style.display = "none";
				}
				continue;
			}else if(!this.arCFG['noClickEvent']){
				content.style.display = "none";				
				addEvent(objHead,"click",this._visible.scope(this));
			}
			this.arKartei[head]['obj'] = objHead;
			this.arKartei[head]['content'] = content;	
			if(!this.active)
			{						
				this.active = head;
				this.arKartei[head]['obj'].className = this.activeCSS;
			}else{
				this.arKartei[head]['obj'].className = this.inactiveCSS;
			}
		}
		if(this.active)
		{
			this.visible(document.getElementById(this.active));
		}
	}
	
	//--- Wenn bei Window onload dann true übergeben um das init direkt auf zu rufen, ansonsten wird ein Event gebaut
	this.init = function(isOnload)
	{
		if(isOnload)
		{
			this._init(false);
		}else{
			addEvent(window,"load",this._init.scope(this));
		}
	}

	this._visible = function(e)
	{
		var active = getETarget(getE(e));				
		this.visible(active);
		
	}
	
	//--- alte Karteikarte ausblenden und aktive einblenden
	this.visible = function(obj)
	{
		active = obj.id ? obj.id : this.headMain + obj;
		if(!this.arKartei[active] || !this.arKartei[active]['content']
		|| (typeof(this.arKartei[active]['content']) != "OBJECT" && typeof(this.arKartei[active]['content']) != "object"))
		{
			return false;
		}
		
		//--- war mal aktiv
		this.arKartei[this.active]['content'].style.display = "none";
		if(this.inactiveCSS)
		{
			document.getElementById(this.active).className = this.inactiveCSS;
		}

		//--- ist aktiv
		this.arKartei[active]['content'].style.display = "";
		if(this.activeCSS)
		{
			document.getElementById(active).className = this.activeCSS;
		}
		this.active = active;
		if(this.activateField)
		{
			this.activateField.value = this.active;
		}		
	}
	
}

//--- Wenn Anzahl von Personen geändert wurde, soll manchmal auch die Anzahl einiger Leistungen geändert werden
//--- Dies kann entweder fest über die Anforderung (z.B. "F") passieren oder dynmaisch durch den Kunden im PHP geählt -> Leistungsabhängig
function cSetAnzahl(KinderActive,BabyActive)
{
	this.KinderActive   = (KinderActive) ? KinderActive : false;		//--- Sollen Kinder mitgezählt werden
	this.BabyActive   	= (BabyActive) ? BabyActive : false;			//--- Sollen Kinder mitgezählt werden
	this.arAnforderung 	= new Array();									//--- Anforderung bei der Anzahl berücksichtig werden
	this.arLeistung 	= new Array();									//--- Leistungen bei der Anzahl berücksichtig werden
	this.arMSB			= new Array();
	this.arAnzahlSelect = new Array();									//--- Id für Anzahlfelder -> wenn gesetzt wird Anzahlfeld unsichtbar gemacht
	this.anzPersonen 	= 0;
	
	this.__constuct = function()
	{
		this.objEltern 		= document.getElementById('ANZAHL_ERWACHSENE');	//--- Selectbox Eltern
		this.objKinder 		= document.getElementById('ANZAHL_KINDER');		//--- Selectbox Kinder
		this.objBaby 		= document.getElementById('ANZAHL_BABY');		//--- Selectbox Babys		

		//--- Onchange Event hinzufügen
		addEvent(this.objEltern,"change",this.setAnzahl.scope(this));
		if(this.KinderActive && this.objKinder)
		{
			addEvent(this.objKinder,"change",this.setAnzahl.scope(this));
		}
		if(this.BabyActive && this.objBaby)
		{
			addEvent(this.objBaby,"change",this.setAnzahl.scope(this));
		}
	}

	this._init = function(e)
	{
		this.__constuct();		
		this._calcAnzahl();
		this._setAnforderung();
		this._setLeistung();		
	}

	this.init = function(isOnload)
	{
		if(isOnload)
		{
			this._init();
		}else{
			addEvent(window,"load",this._init.scope(this));
		}
	}
	
	
	//--- Anzahl neu berechnen und alle Anforderungen und Leistungen neu setzen
	this.setAnzahl = function()
	{
		this._calcAnzahl();
		this._setAnforderung();
		this._setLeistung();
	}

	//--- Anzahl Personen berechnen
	this._calcAnzahl = function()
	{										
		this.anzPersonen = parseFloat(this.objEltern.value);
		if(this.KinderActive && this.objKinder && this.objKinder.selectedIndex > 0 )
		{
			this.anzPersonen += parseFloat(this.objKinder.value);
		}
		if(this.BabyActive && this.BabyActive && this.objBaby.selectedIndex > 0 )
		{
			this.anzPersonen += parseFloat(this.objBaby.value);
		}
	}

	//--- Anforderung hizufügen
	this.addAnfoderung = function(anfoderung,hiddenObj)
	{					
		this.arAnforderung.push(anfoderung);		
		this.arAnzahlSelect[anfoderung] = hiddenObj;
	}

	//--- Leistung hizufügen
	this.addLeistung = function(leistung,status, msb_suffix)
	{					
		if(status == "K")
		{
			this.arLeistung.push(leistung);
			if (msb_suffix)
				this.arMSB[leistung] = msb_suffix;
			
		}
	}
	
	//--- Anzahl der angegebenen Anforderungen setzen
	this._setAnforderung = function()
	{		
		var suffix = '';
		for(var wert in this.arAnforderung)
		{			
		
			suffix = '';
			if(this.arMSB[wert])
				suffix = this.arMSB[wert];
			objAnforderung = document.getElementsByName("ANFORDERUNG_" + this.arAnforderung[wert]);
			for( i = 0; i < objAnforderung.length; i++)	
			{				
				document.getElementsByName("LEIST_" + objAnforderung[i].value + "_ANZAHL" + suffix)[0].selectedIndex = this.anzPersonen - 1;
				if(this.arAnzahlSelect[ this.arAnforderung[wert] ] && document.getElementById(this.arAnzahlSelect[ this.arAnforderung[wert] ] + objAnforderung[i].value))
				{
					document.getElementById(this.arAnzahlSelect[ this.arAnforderung[wert] ] + objAnforderung[i].value).style.display = "none";
				}
			}			
		}
	}
	
	//--- Anzahl der angegebenen Leistung setzen
	this._setLeistung = function()
	{
		var suffix = '';
		for(var wert in this.arLeistung)
		{	
			suffix = '';
			if(this.arMSB[wert])
				suffix = this.arMSB[wert];
			document.getElementById("LEIST_" + this.arLeistung[wert] + "_ANZAHL" + suffix).selectedIndex = this.anzPersonen - 1;
		}				
	}

	//--- Anzahl Personen zurückgeben
	this.getAnzahl = function()
	{
		return this.anzPersonen;
	}
	
	this.__constuct();
}

//--- Wenn nur eine Selectbox nur einen Eintrag hat, wird sie Unsichtbar gemacht und der Eintrag wird als normaler Text ins HTML geschrieben
function cOneEntry()
{
	this.arSelect = new Array();
	this.arCss = new Array();
	
	this._init = function(e)
	{
		this.execute();
	}
	
	this.init = function(isOnload)
	{
		if(isOnload)
		{
			this._init();
		}else{
			addEvent(window,"load",this._init.scope(this));
		}
	}

	//--- Feld hinzufügen
	this.add = function(id,css)
	{
		this.arSelect[id] = id;
		this.arCss[id] = css;
	}
	
	this.execute = function()
	{
		var objText = null;
		for(var id in this.arSelect)
		{
			this.arSelect[id] = document.getElementById(this.arSelect[id]);
			if(!this.arSelect[id] || this.arSelect[id].nodeName != "SELECT")
			{
				delete(this.arSelect[id]);
				continue;
			}
			
			if(this.arSelect[id].options.length == 1)
			{
				this.arSelect[id].style.display = "none";
				objText = new CElement(false,"div",true);
				objText.obj.innerHTML = this.arSelect[id].options[0].innerHTML;
				objText.setClass(this.arCss[id]);
				objText.insertBefore(this.arSelect[id]);
			}
		}
	}
}

//--- Kann Leistung anchecken
function hidden_leistung(idNr,zwang,checked,firstSetting,anzeigen)
{
	if( (!document.getElementById("LEIST_"+idNr).checked && !firstSetting) || (checked && checked.indexOf("checked") > -1 ))
	{
		document.getElementById("LEIST_"+idNr).checked = true;
		document.getElementById("leistungs_box_"+idNr).style.display = "";
		document.getElementById("leistungs_checkbox_box_"+idNr).style.display = "none";
	}else{
		document.getElementById("LEIST_"+idNr).checked = false;
		document.getElementById("leistungs_box_"+idNr).style.display = "none";
		document.getElementById("leistungs_checkbox_box_"+idNr).style.display = "";
	}

	if(zwang)
	{					
		document.getElementById("LEIST_"+idNr).checked = true;
		document.getElementById("leistungs_box_"+idNr).style.display = "";
		document.getElementById("leistungs_checkbox_box_"+idNr).style.display = "none";
		document.getElementById("leistungs_fakecheckbox1_"+idNr).style.display = "none";
		document.getElementById("leistungs_fakecheckbox2_"+idNr).style.display = "none";
	}
	
	anzeigen = anzeigen + "";
	
	if((!anzeigen || parseFloat(anzeigen) == 0) && firstSetting)
	{
		document.getElementById("LEIST_"+idNr).checked = true;
		document.getElementById("leistungs_box_"+idNr).style.display = "none";
		document.getElementById("leistungs_checkbox_box_"+idNr).style.display = "none";
		document.getElementById("leistungs_fakecheckbox1_"+idNr).style.display = "none";
		document.getElementById("leistungs_fakecheckbox2_"+idNr).style.display = "none";				
	}
}		

//--- einen Stepper initialisieren
/*
	var stepper = new cStepper();

	stepper.loadLevel(0);
	stepper.load("formular_caption_box1",true,"formular_caption_box_aktive");
	stepper.load("form_step1","");			
	stepper.load("stepper_button_1","");

	stepper.loadLevel(1);
	stepper.load("formular_caption_box2",true,"formular_caption_box_aktive");
	stepper.load("form_step2","");			
	stepper.load("stepper_button_2","");
*/
function cStepper()
{
	this.arStepper = new Array();
	this.step = 0;
	
	//--- neues Level beim Array aufmachen
	this.loadLevel = function(step)
	{
		this.step = step;
		if(!this.arStepper[this.step])
		{
			this.arStepper[this.step] = new Array();
		}
		
	}
	
	//--- Stepper laden
	this.load = function(id,css)
	{
		this.arStepper[this.step][id] = new Array()
		this.arStepper[this.step][id]['css'] = css;		
	}
	
	//--- Stepper durchgehen nur das sichtbar schalten was bei diesem Step sichtbar sein soll
	this._init = function(e)
	{
		for(var level in this.arStepper)
		{
			for(var id in this.arStepper[level])
			{
				obj = document.getElementById(id);
				if(obj)
				{
					//--- wenn normales CSS schon gespeichern wurde -> wieder laden
					if(this.arStepper[level][id]['normalCSS'])
					{
						obj.className = this.arStepper[level][id]['normalCSS'];
					}
				
					//--- expliziet diese id wieder sichtbar gemacht werden soll
					obj.style.display = "none";								
				}			
			}		//--- id schleife		
		}  			//--- Level schleife


		//--- nur die angegebene Ebene sichtbar schalten
		for(var id in this.arStepper[this.step])
		{
			obj = document.getElementById(id);
			if(obj)
			{
				//--- Alle Elemente in diesem Level sichtbar schalten
				obj.style.display = "";
				this.arStepper[this.step][id]['normalCSS'] = obj.className;
				if(this.arStepper[this.step][id]['css'])
				{
					obj.className += " " + this.arStepper[this.step][id]['css'];
				}
			}
		}
	}
	
	this.init = function(step,isNotOnload)
	{
		this.isNotOnload = isNotOnload;
		this.step = step;
		if(!this.isNotOnload)
		{
			this._init(false);
		}else{
			addEvent(window,"load",this._init.scope(this));
		}		
	}
	
	this.getStepper = function()
	{
		return this.step;
	}
}


/*--- Funktioniert nur wenn:
		- eine Box um die ganz Leistung existiert (mainBox)
		- die Hidden Funktion um die Kannleistung aus zu blenden auf "onclick" liegt
		- Javascript_lib eingebunden ist (addEvent)
*/
function cCombLeist()
{
	this.arAdultLeist = new Array();
	this.arChildLeist = new Array();
	this.arIds = new Array();
	
	//--- Definieren Welche zwei Leistungen zusammen gehören
	this.loadLeistung = function(adultLeist, childLeistung)
	{		
		this.arAdultLeist[adultLeist] = new Array();
		this.arAdultLeist[adultLeist]['id'] = false;
		this.arAdultLeist[adultLeist]['childLeistung'] = childLeistung;
		this.arChildLeist[childLeistung] = new Array();
		this.arChildLeist[childLeistung]['id'] = false;
		this.arChildLeist[childLeistung]['adultLeistung'] = adultLeist;					
	}
	
	this.loadIds = function(mainBox,uncheckedBox,checkedBox)
	{
		this.arIds['mainBox'] = mainBox;
		this.arIds['uncheckedBox'] = uncheckedBox;
		this.arIds['checkedBox'] = checkedBox;
	}
	
	//--- In der Wiederholgruppe Leistung und ID zusammen laden				
	this.checkLeistung = function(leistung, id, zwang, checked, sichtbar )
	{					
		if(this.arAdultLeist[leistung])
		{
			this.arAdultLeist[leistung]['id'] = id;
			this.arAdultLeist[leistung]['zwang'] = zwang;
			this.arAdultLeist[leistung]['checked'] = checked;
			this.arAdultLeist[leistung]['sichtbar'] = sichtbar;
		}

		if(this.arChildLeist[leistung])
		{
			this.arChildLeist[leistung]['id'] = id;
			this.arChildLeist[leistung]['zwang'] = zwang;
			this.arChildLeist[leistung]['checked'] = checked;
			this.arChildLeist[leistung]['sichtbar'] = sichtbar;
		}					
	}
	
	//--- Leistung mit Action belegen
	this.init = function()
	{
		for(var leistung in this.arAdultLeist)
		{
			if(this.arAdultLeist[leistung]['id'] && !this.arAdultLeist[leistung]['zwang'] && this.arAdultLeist[leistung]['sichtbar'])
			{
				childLeistung = this.arAdultLeist[leistung]['childLeistung'];							
				childLeistungId = this.arChildLeist[childLeistung]['id'];
				if(document.getElementById(this.arIds['mainBox'] + childLeistungId))
				{					
					if(this.arAdultLeist[leistung]['checked'].indexOf('checked') == -1)
					{						
						document.getElementById(this.arIds['mainBox'] + childLeistungId).style.display = "none";
					}
					if(document.getElementById(this.arIds['uncheckedBox'] + this.arAdultLeist[leistung]['id']))
					{
						addEvent(document.getElementById(this.arIds['uncheckedBox'] + this.arAdultLeist[leistung]['id']) 
								, "click" , this.visible.scope(this,leistung));
					}
					if(document.getElementById(this.arIds['checkedBox'] + this.arAdultLeist[leistung]['id']))
					{
						addEvent(document.getElementById(this.arIds['checkedBox'] + this.arAdultLeist[leistung]['id']) 
								, "click" , this.invisible.scope(this,leistung));
					}
				}
			}
		}
	}
	
	//--- Leistung sichtbar machen
	this.visible = function(e,arArray)
	{
		adultLeistung = arArray[1];
		childLeistung = this.arAdultLeist[adultLeistung]['childLeistung']; 
		childLeistungId = this.arChildLeist[childLeistung]['id'];		
		if(document.getElementById(this.arIds['mainBox'] + childLeistungId))
		{
			document.getElementById(this.arIds['mainBox'] + childLeistungId).style.display = "";
		}					
	}				

	//--- Leistung unsichtbar machen
	this.invisible = function(e,arArray)
	{
		leistung = arArray[1];		
		childLeistung = this.arAdultLeist[leistung]['childLeistung']; 
		childLeistungId = this.arChildLeist[childLeistung]['id'];		
		if(document.getElementById(this.arIds['mainBox'] + childLeistungId) && !this.arAdultLeist[leistung]['zwang'] && this.arAdultLeist[leistung]['sichtbar'])
		{
			document.getElementById(this.arIds['mainBox'] + childLeistungId).style.display = "none";
			if(document.getElementById("LEIST_" + childLeistungId).checked 
				&& !this.arChildLeist[childLeistung]['zwang'] 
				&& this.arChildLeist[childLeistung]['sichtbar']
			)
			{
				document.getElementById(this.arIds['checkedBox'] + childLeistungId ).onclick();
			}
		}
		if(this.arAdultLeist[childLeistung] && this.arAdultLeist[childLeistung]['childLeistung'])
		{
			arArray = new Array();			
			arArray[0] = e;
			arArray[1] = childLeistung;
			this.invisible(e,arArray);
		}		
	}
}


//--- Macht einen Block sichtbar (läd eventuell die eingegebenen Daten) oder unsichtbar (speichert die Daten und macht Block unsichtbar)
/*--- Beispiel: 
	<select>
		<option value='1'>1</option>
		<option value='2'>2</option>
	</select>
	<div id='1'>
		<input type='text' name='1' />
	</div>
	<div id='2'>
		<input type='text' name='2' />
	</div>
	
	//--- wenn Option 1 ausgewählt wurde, soll id 1 sichtbar sein. Somit soll id 2 unsichtbar gemacht werden. (soweit einfaches display - none
	//--- Wenn id 2 schon sichtbar war, könnte in input 2 schon etwas stehen -> dies wiederum kann zu problemen im php führen
	//--- Diese Klasse macht nicht nur den id Bereich unsichtbar, sondern setzt alle eingabefelder auf default 
	//--- !!! speichert aber (wenn schon was eingegeben wurde) die Eingabe, falls der Bereich wieder sichtbar wird
---*/
	
function cVisibleFields()
{
	this.arParent 	= new Array();		//--- alle ParentIds -> allgemein Infos und value des Parent -> Kindknoten die beim aktiven Value sichtbar sein sollen
	this.arChild 	= new Array();		//--- alle ChildIds -> allgemein Infos und arField -> Elemente die disabled werden sollen, wenn Kind nicht sichtbar ist
	this.arSearchNode = new Array();	//--- Hilfsarray, damit nicht viele parameter von einer methode in die andere übergeben werden müssen
	
	this._init = function(e)
	{
		this._initObj();
	}
	
	this.init = function(isOnload)
	{
		if(isOnload)
		{
			this._init();
		}else{
			addEvent(window,"load",this._init.scope(this));
		}
	}
	
	//--- Objekte laden
	this._initObj = function()
	{
		var child = "";
		//--- Kindknoten nach Elementen durchforsten (z.B. Input, Select)
		for(var child in this.arChild)
		{
			this.arChild[child] = new Array();
			this.arChild[child]['obj'] = document.getElementById(child);						
			if(!this.arChild[child]['obj'])
			{
				delete(this.arChild[child]);
			}					
			
			//--- Kind und länge merken (spart übergabeparameter)
			this.arSearchNode['child'] = child;
			this.arSearchNode['length'] = 0;			
			this._searchNode(this.arChild[child]['obj']);
			this.arChild[child]['obj'].style.display = "none";
		}
		
		//--- Elternknoten initialiseren
		for(var parent in this.arParent)
		{						
			this.arParent[parent]['obj'] = document.getElementById(parent);								
			//--- wenn es den Parentknoten nicht gibt alle Kinder aus Array löschen und dann Parent selbst
			if(!this.arParent[parent]['obj'])
			{						
				for(var parentvalue in this.arParent[parent])
				{
					for(var child in this.arParent[parent][parentvalue])
					{					
						if(this.arChild[child])
						{
							delete(this.arChild[child]);
						}
					}
				}
				delete(this.arParent[parent]);
				continue;
			}

			//--- Wenn es Parentknoten gibt, den Typ merken (checkboxen andere logik) ... 
			this.arParent[parent]['type'] = this.arParent[parent]['obj'].nodeName;
			if(this.arParent[parent]['type'] == "INPUT")
			{
				if(this.arParent[parent]['obj'].type == "checkbox")
				{
					this.arParent[parent]['type'] = "CHECKBOX";
				}else if(this.arParent[parent]['obj'].type == "radio")
				{
					this.arParent[parent]['type'] = "RADIO";
				}
			}			
			
			//--- ... Event laden und erstmaliges Initialisieren
			addEvent(this.arParent[parent]['obj'],"change",this._checkVisible.scope(this));
			this.checkVisible(parent);
		}		
	}
	
	//--- sucht nach Eingabe Elementen
	this._searchNode = function(searchNode)
	{						
		if(searchNode && searchNode.nodeType == 1)
		{			
			//--- Eingabe Felder speichern			
			if(searchNode.nodeName == "SELECT" || searchNode.nodeName == "INPUT" || searchNode.nodeName == "TEXTAREA")
			{	
				if(!this.arChild[ this.arSearchNode['child'] ]['arField'])
				{
					this.arChild[ this.arSearchNode['child'] ]['arField'] = new Array();
				}
				this.arChild[ this.arSearchNode['child'] ]['arField'][ this.arSearchNode['length'] ] = searchNode;
				searchNode.disabled = "disabled";
				this.arSearchNode['length'] += 1;								
			}			
			
			//--- Wenn Knoten weitere Kinder hat
			if(searchNode.hasChildNodes())
			{
				for(var i = 0;i <= searchNode.childNodes.length; i++)
				{
					this._searchNode(searchNode.childNodes[i]);
				}
			}
		}
		return;
	}
	
	//--- Verbindung zwischen zwei Feldern und Value des Elternteils schaffen
	this.load = function(parent,child,parentvalue,close)
	{					
		parentvalue = (parentvalue === true) ? 1 : (parentvalue === false) ? 0 : parentvalue;
		this.arChild[child] = "";
		if(!this.arParent[parent])
		{
			this.arParent[parent] = new Array();
			this.arParent[parent]['obj'] = "";
			this.arParent[parent]['type'] = "";
			this.arParent[parent]['close'] = close;
			this.arParent[parent]['lastValue'] = "";
		}
		
		if(!this.arParent[parent][parentvalue])
		{
			this.arParent[parent][parentvalue] = new Array();
		}
		this.arParent[parent][parentvalue][child] = child;
	}
	
	//--- Hilfsfunktion um checkVisible sauber auf zu rufen
	this._checkVisible = function(e)
	{
		var target = getETarget(getE(e));				
		this.checkVisible( target.id );
	}
	
	//--- je nach Typ des Parents wird andere Logik eingeschlagen und sichtbar bzw. unsichtbar gemacht
	this.checkVisible = function(parent)
	{		
		if(!this.arParent[parent])
		{
			return false;
		}
		
		//--- checkbox kann nur 2 zustände haben
		if(this.arParent[parent]['type'] == "CHECKBOX")
		{
			if(!this.arParent[parent]['obj'].checked)
			{				
				this._setInvisible(parent,1);
				this._setVisible(parent,0);
			}else{
				this._setInvisible(parent,0);
				this._setVisible(parent,1);
			}
		}else{
			var parentvalue = this.arParent[parent]['obj'].value;					
			if(!this.arParent[parent][parentvalue])
			{
				if(this.arParent[parent]['close'])
				{
					this._setInvisible(parent,parentvalue);
				}
				return false;
			}
			this._setInvisible(parent,parentvalue);
			this._setVisible(parent,parentvalue);
		}		
	}
	
	//--- geht alle Kinder durch, die dem Parentvalue zugeordnet sind und macht die Elemente der Kinder unsichtbar
	this._setInvisible = function(parent,parentvalue)
	{
		if(this.arParent[parent]['type'] != "CHECKBOX" && (!this.arParent[parent]['lastValue'] || this.arParent[parent]['lastValue'] == parentvalue))
		{
			return false;
		}		

		var parentvalue = this.arParent[parent]['lastValue'];		
		for(var child in this.arParent[parent][parentvalue])
		{
			if(!this.arChild[child])
			{
				continue;
			}
			//--- da Bereich sichtbar gemacht wird, sollte Memory geladen werden
			for(var field in this.arChild[child]['arField'])
			{			
				this.arChild[child]['arField'][field].disabled = "disabled";
			}		
			this.arChild[child]['obj'].style.display = "none";
		}
	}
	
	//--- geht alle Kinder durch, die dem Parentvalue zugeordnet sind und macht die Elemente der Kinder sichtbar
	this._setVisible = function(parent,parentvalue)
	{				
		for(var child in this.arParent[parent][parentvalue])
		{			
			if(!this.arChild[child])
			{
				continue;
			}
			//--- da Bereich sichtbar gemacht wird, sollte Memory geladen werden
			for(var field in this.arChild[child]['arField'])
			{			
				this.arChild[child]['arField'][field].disabled = "";
			}		
			this.arChild[child]['obj'].style.display = "";
		}
		this.arParent[parent]['lastValue'] = parentvalue;
	}	
}

//--- kopiert und umbenannt von tosform
function cFelderConnect(feld, felder, trennzeichen, type)
{
    this.feld = feld;
    this.felder = felder;
    this.trennzeichen = trennzeichen;	
	this.allSet = true;	
	this.type = type;
	
    this.setWert = function(wert)
    {
        I(this.feld).value = wert;
        
        var werte = wert.split(this.trennzeichen);

        for (var i = 0; i < this.felder.length; i++)
		{
            if (werte[i] != null)
                I(this.felder[i]).value = werte[i];
		}
    }

    this.changeWerte = function()
    {
        var wert = I(this.felder[0]).value;		
		this.allSet = true;
        for (var i = 1; i < this.felder.length; i++)
		{
            wert = wert + this.trennzeichen + I(this.felder[i]).value;
			if(!I(this.felder[i]).value)
			{
				this.allSet = false;
			}
		}
        var obj = I(this.feld);
        if(!obj)
        {
        	alert("!!!! DEV Element id:" + this.feld + " existiert nicht");
        }
		obj.value = wert;
		if(this.allSet && this.type == "date")
		{			
			if(!checkDate(obj,this.trennzeichen))
			{				
				this.setWert(this.trennzeichen + this.trennzeichen);
			}
		}		
    }	
}
