// Hier kommen alle JavaScript Funktionen rein, die nicht mit php bearbeitet werden...
// Andernfalls sind sie sichtbar auf der Seite...
// alert("bin da jsript.js")

var wload;
var is_ie;
var is_gecko; 
var is_mac_moz;
var browser;
// Emailver.
var mchar 				= "@"; 
var mstr				="mailto"
var aktueldialog;
var myMouseDownOnGriff;// = null
var LayerPosObj 		= {"side_service":0, "side_serviceHOut":-272, "top_service":0, "top_serviceVOut":-123, "FloatingEditorLayer":0, "FloatingEditorLayerHOut":-420};
var dragobj 			= null; 
var refobj 				= null; 
var FloatingEditorXpos 	= null
var FloatingEditorYpos 	= null
var ServiceXpos 	   	= null
var	ServiceYpos 	   	= null
var clickPageTarget;
var moveableEditLayer 	= 0 // Editlayer nicht dragable
var editorObj = {}
var editorObjTextareaName
var aktueldialogEditor
var tim = 0

checkbrowser(); // soll immer passieren
window.onmousedown 	 = dialogcheck;				// Fuer Mozilla: Sorgt dafuer, dass kleine fenster vorne bleiben
document.onmousedown = startdragIt
document.onmousemove = dragIt 
document.onmouseup   = stopdragIt




//addevent(document.getElementById("FloatingEditorGriff"), "mousedown", 	startdragIt)
//addevent(document.getElementById("FloatingEditorGriff"), "mousemove", 	dragIt)
//addevent(document.getElementById("FloatingEditorGriff"), "mouseup", 	stopdragIt)

// Hier hatte ich Probleme mit Mozilla: Sobald ich die Funktion startdragIt von einer anderen Funktion aufrufen wollte (z. B. mousedownaction),
// wurde das bild weggedraggt. 
 

///////////////////////////////////////////////////////////
function setReiterGroup(whichid,action) { 
// alert("setReiterGroup " + whichid);
	if (document.getElementById("r0")) {
		for (i=0;i<rgroup.length;i++) {
			r = rgroup[i];
			if (whichid == r) {
				// aktivieren
				document.getElementById(r).style.zIndex = 20
				document.getElementById("lichtkante_"+r).bgColor="#FFFFFF"
				document.getElementById("seitel_"+r).src = ir_aktiv_l.src // "images/r_aktiv_l.gif"
				document.getElementById("seiter_"+r).src = ir_aktiv_r.src //"images/r_aktiv_r.gif"
				document.getElementById("flaeche_"+r).bgColor="#EEEEEE"
				//if (document.all) document.getElementById("bereich_"+r).style.display = "inline"
				//else document.getElementById("bereich_"+r).style.display = "table-row"
			} else {
				// deaktivieren
				//alert("seitel_"+r)
				document.getElementById("seitel_"+r).src = ir_iaktiv_l.src // "images/r_iaktiv_l.gif"
				document.getElementById("seiter_"+r).src = ir_iaktiv_r.src // "images/r_iaktiv_r.gif"
				document.getElementById(r).style.zIndex = 0
				document.getElementById("flaeche_"+r).bgColor="#BBBBBB"
				document.getElementById("lichtkante_"+r).bgColor="#CCCCCC"
				//document.getElementById("bereich_"+r).style.display = "none"
			}
		} // end for
		if (action != "noaction") {
			if (whichid=="r1") window.setTimeout("pagePreview('preview')",10);
			if (whichid=="r2") window.setTimeout("pagePreview('design')",10);
		}
	}
}





// Fenstergroesse erfassen
function getStartWindowSize() {
	if (is_ie) fensterhoehe_start = document.body.clientHeight + 29 // Fenster mit Titelleiste
	else 	   fensterhoehe_start = window.outerHeight
	if (is_ie) fensterbreite = document.body.clientWidth + 8 		// fuer Border
	else 	   fensterbreite = window.outerWidth
	//alert("fensterhoehe_start " + fensterhoehe_start)
}

function goClickPageTarget() {
	document.location.href = clickPageTarget;
}
function cancelBubbling(evt) {
	if (is_ie) 		window.event.cancelBubble=1; 
	if ((is_gecko) && (!is_safari)) evt.stopPropagation();
}

function resizeWindow(width,height) {
	// Diese function macht nur bei fester Fenstergoeese Sinn.
	// Sie vergoessert den Fensterbereich fuer en editmodus, z. B. bei der Microsite
	if (is_ie)  window.resizeTo(width,height);
	else 	    window.outerHeight = height
}

function showElement(elname,height,mozdiff) { 
		// macht ein Element sichtbar und vergoessert das Fenster
		// height = heoehe des fensters ie
		mozdiff = 90;
		if (!document.getElementById(elname)) return;
		klappbereich = document.getElementById(elname)
		if (is_ie) fensterbreite = document.body.clientWidth + 8 // fuer Border
		else 	   fensterbreite = window.outerWidth
		//alert(fensterbreite)
		if (klappbereich.style.display == "none")  {
			if (is_ie)	klappbereich.style.display = "inline";
			else 		klappbereich.style.display = "inline";
			document.getElementById("img_"+elname).src = "../images/icon_klapppfeildown.gif";
			if (is_ie) window.resizeTo(fensterbreite,height);
			else 	   window.outerHeight = height + mozdiff;
		} else {
			klappbereich.style.display = "none";
			document.getElementById("img_"+elname).src = "../images/icon_klapppfeilup.gif";
			if (is_ie) 	window.resizeTo(fensterbreite,fensterhoehe_start);
			else 		window.outerHeight = fensterhoehe_start;
		}
	}



function setEditLayerHeigth() {
	//alert("setEditLayerHeigth")
	editLayerHeigth = document.getElementById("maintable").offsetHeight;
	document.getElementById("img_dist_top_service").style.height 		= editLayerHeigth;			// Abstandhalter anpassen
	if (is_ie) document.getElementById("editlayer_dummy").style.height	 = editLayerHeigth; 		// iframe anpassen
	if (document.edit.switch_service.value == "top_service") 	document.edit.editlayerheighttop.value 		= editLayerHeigth;
	else 														document.edit.editlayerheightside.value  	= editLayerHeigth;
	/*
	alert(	"editlayerheighttop " + document.edit.editlayerheighttop.value + "\n" + 
			"editlayerheightside "+ document.edit.editlayerheightside.value + "\n")
			*/
			
}






function getScrollTop() {
	if (!is_ie) myScrollTop = window.scrollY
	if (is_ie) myScrollTop  = document.body.scrollTop
	//alert(myScrollTop)
	return myScrollTop
}

function checkforOpenWindows(){
if ((wload) && (!wload.closed)) {
	wload.focus();
	}
}
 
// Editmode starten
function initEditmode() {
// alert("initEditmode")
	//setReiterGroup('r2','noaction')	// edit aktiveren
	// alert("document.edit.show_all_fields.value " + document.edit.show_all_fields.value)
	if (document.edit.show_all_fields.value==1) activate_all_fields(1); 				// set = 1 -> schaltet alle Felder an
	// if ((document.edit.ecargopos.value !="") || (document.edit.servicepos.value !="")) readPositions();
	// MICROSITES
	//if ((is_editmode) && (Windowtype=="microsite")) resizeWindow(798,800); // vergoessern des Fensters
}



function readPositions() {
	// diese Werte muss man der aktuellen Groesse des Floatingeditors anpassen
	FloatingEditorLayerWidth  	= 434
	FloatingEditorLayerHeight 	= 106
	xyArr = document.edit.ecargopos.value.split("x")
	// alert("readPositions " + document.edit.ecargopos.value)
	FloatingEditorXpos 			= xyArr[0]
	FloatingEditorYpos 			= xyArr[1]
	if (document.edit.ecargosize.value) {
		xyArr = document.edit.ecargosize.value.split("x")
		FloatingEditorLayerWidth 			= xyArr[0]
		FloatingEditorLayerHeight 			= xyArr[1]
	}
	// Position kontrollieren, darf nicht den sichtbaren Bereich verlassen
	if(is_ie) {
			bodyHeight = document.clientHeight
			bodyWidth = document.clientWidth
		} else {
			bodyWidth  = window.innerWidth
			bodyHeight = window.innerHeight
		}
	
	/*
	alert(	"bodyHeight " 					+ bodyHeight + "\n" + 
			"bodyWidth " 					+ bodyWidth + "\n" + 
			"FloatingEditorYpos " 			+ FloatingEditorYpos + "\n" + 
			"FloatingEditorLayerHeight "	+ FloatingEditorLayerHeight + "\n" + 
			"FloatingEditorLayerWidth "		+ FloatingEditorLayerWidth)
			*/
	if (FloatingEditorXpos > (bodyWidth  - FloatingEditorLayerWidth))  FloatingEditorXpos = bodyWidth  - FloatingEditorLayerWidth
	if (FloatingEditorYpos > (bodyHeight - FloatingEditorLayerHeight)) FloatingEditorYpos = bodyHeight - FloatingEditorLayerHeight
}


function writePositions() {
 	// alert("ServciePos: "+ServiceXpos + "x" + ServiceYpos)
	thispos = FloatingEditorXpos + "x" + FloatingEditorYpos
 	document.edit.ecargopos.value  = thispos
	if (window.save_editor_position) save_editor_position(thispos);
	// FloatingEditorXpos + "x" + FloatingEditorYpos
	// checken: erst speichern, wenn eine relevante Verschiebung stattgefunden hat.
	// if ((ServiceYpos > 10) && ((ServiceYpos > 10) || (ServiceYpos < -10)))	document.edit.servicepos.value = ServiceXpos + "x" + ServiceYpos
	// else 																	document.edit.servicepos.value = "_x_"
}





 
 
 
// Preview und Editmode FUnktionen
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 function pagePreview(mode) {
	// alert("pagePreview " + mode); 
	if(mode=="preview") {
		hide_Vmarker(0)			//senkrechte Striche weg
		deactivate_all_fields()
		switch_icm_visiblity("none","preview")
	} else {
		hide_Vmarker(1)			//senkrechte Striche
		// editiermodus weider herstellen, wie ervor previewmode "preview" war
		//switch_icm_visiblity(document.edit.icm_visiblity.value) 	// alte Werte einlesen 
		//activate_all_fields(document.edit.show_all_fields.value)	// alte Werte einlesen 
		
		switch_icm_visiblity("inline") 	// alte Werte einlesen 
		activate_all_fields(document.edit.show_all_fields.value)	// alte Werte einlesen 
	}
}
 
function switch_icm_visiblity(mode,previewmode) {
// alle <div>, die eine id mit haben, weren ausgeblendet				z. B. -> "div id=icm_delete....
	allDivsArr = document.getElementsByTagName("div")
 	allDivsArrLength = allDivsArr.length
	for(i=0;i<allDivsArrLength;i++) {
		myDiv = allDivsArr[i];
		// Erweitert: icm_ || icmp_ : Manche Elemente sollen in der Preview verschwinden, aber zum Bearbeiten sichtbarsein, wenn die Icons ausgeblndet sein
		if (     (myDiv.id.indexOf("icm_") != -1) || (previewmode && myDiv.id.indexOf("icmp_") != -1)          ) { // nur ids mit "icm" erwischen
			if (allDivsArr[i].style.display == "none") 		myVis = "inline" // sichtbar oder nicht, um zu togglen
			else  											myVis = "none"
			// wenn einParameter uebergeben wurde, dann diesen nehmen
			if (mode) myVis = mode
			myDiv.style.display = myVis
		}
 	}
	// status speichern
	// alert("switch_icm_visiblity previewmode " + previewmode)
	document.edit.icm_visiblity.value = myVis;
	//if (previewmode != "preview") 	document.edit.icm_visiblity.value = "inline"
	//else 							document.edit.icm_visiblity.value = "none"
	// alert("previewmode " + previewmode + " document.edit.icm_visiblity.value " + document.edit.icm_visiblity.value);
	//bis 11.10.06) if (previewmode!="preview") document.edit.icm_visiblity.value = myVis
	//alert("icm_visiblity " + document.edit.icm_visiblity.value)
 }
 

 
function activate_all_fields(set,previewmode) {
	// alert(document.edit.show_all_fields.value)
 	// toggeln zwischen show_all_fields und normalmodus
	// set: um den automatismus zu entgehen, der immer den Umkehrzustand activiert kann man uach direkt setzten
	newstate = 0
	aktuelstate = document.edit.show_all_fields.value
	if (aktuelstate==0) newstate = 1; 		// switchmode; wenn 1 -> aus 0, wenn 0 -> an
	if (set) 			newstate = set 		// ueberschreiben mit set
	
	// alert("set " + set + "  newstate " + newstate) 
	// alle an, wenn 0 oder set
	if (newstate == 1) {
		if (previewmode!="preview") document.edit.show_all_fields.value = 1
		allSpansArr 	= document.getElementsByTagName("div")
		allSpanslength = allSpansArr.length
		// testen: Ist das an aoder aus?
		// alert("allSpanslength " + allSpanslength)
		for(i=0;i<allSpanslength;i++) {
			myspan_id = allSpansArr[i].id;
			if (myspan_id.indexOf("elife_") != -1) {
				myspan_feldname = myspan_id.substr(6,100) // name ohne elife
				switchEditMode(myspan_feldname,"all")
			} // end if
		} // end for
		return;
	}
	// alle aus
	if (newstate == 0) {
		deactivate_all_fields() // alle ausschalten
		if (previewmode!="preview")  document.edit.show_all_fields.value = 0
		// switch_icm_visiblity("block")
	}
	//alert("am Ende: " + document.edit.show_all_fields.value)
}
 
 

function fieldover(field) {
	// Rollovereffekte, kann man evtl spater everwenden
	//field.style.border = "1px solid" 
	//field.style.borderColor = "#FFFF00"
	//alert
	//bg = field.style.background();
	//field.style.background = "#DDDDDD"
	//field.style.padding = 0
}
function fieldout(field) {
	//field.style.background = ""
	//field.style.border 	= "0"
	//field.style.borderLeft = "1px solid" 
	//field.style.borderLeftColor = "#CCCCCC" 
	//field.style.borderTopColor 		= "#BBBBBB"
	//field.style.borderRightColor 	= "#FFFFFF"
	//field.style.borderBottomColor 	= "#FFFFFF"
}

function switchEditMode(fieldname,mode) {
	//alert(fieldname)
	span			= document.getElementById("elife_"+fieldname) 	// Das span, in das der Text ausgegeben wurde
 	field			= document.getElementById(fieldname)			// Das feld, das den Text zum editieren aufnimmt -> editierbar
	life_field 		= document.getElementById("life_"+fieldname) 	// 
	infospan 		= document.getElementById("infospan_"+fieldname) // ein unsichtbares span, das Zusatzinformationen enthaelt
	infotext 		= infospan.innerHTML
	/*
	alert(	" span " + span.id + "\n" + 
			" field " + field.id + "\n" + 
			" life_field " + life_field.id) 
	*/
	// alert("switchEditMode " + mode + " " + fieldname)
	
	if (mode != "all") {
		// Alle anderen zuruecksetzten, nur dieses eine aktivieren
		if (span.style.display == "none") { // Dieses Element ist momentan editierbar 
		 	deactivate_all_fields() // alle ausschalten
		} // end if
		// alert("field.id "+ field.id);
		if (!editorObj[field.id]) {
			// alert("kein editorfeld, deaktiviere editorTextareabyUser")
			document.edit.editorTextareabyUser.value = ""; 
		}
	} // mode != "all"
	field.name 					= field.id // ab hier wird das Feld speicherbar !! +++ Achtung!	
	
	/*
	field.style.borderLeftColor 	= "#BBBBBB"
	field.style.borderTopColor 		= "#BBBBBB"
	field.style.borderRightColor 	= "#FFFFFF"
	field.style.borderBottomColor 	= "#FFFFFF"
	if (field.style.background == "") field.style.background = "#F6F6F6"; // nur ueberschreiben, wenn leer
	*/
	// wie bisher...
	//alert(life_field.size)
	//if (life_field.size) field.size = life_field.size
	//alert(field.size)
	
	
	/*
	// STYLE 1:			Rahmen grau
	if (field.style.border == "") field.style.border = "1px solid" 
	field.style.borderColor 	= "#CCCCCC" // Alternativ nur Rahmen
	// field.style.background 	= "#CCCCCC"
	*/
	
	
	/*
	// STYLE 2:			Grau Hinterlegt
	if (field.style.border == "") field.style.border = "0px solid" 
	field.style.background 	= "#CCCCCC"
	*/
	
	
	// STYLE 3:			Miniborder D
	//if (field.style.border == "") field.style.border = "1px solid" 
	field.style.border = "1px solid" 
	field.style.borderLeftColor 	= "#BBBBBB"
	field.style.borderTopColor 		= "#BBBBBB"
	field.style.borderRightColor 	= "#FFFFFF"
	field.style.borderBottomColor 	= "#FFFFFF"
	//alert("field.style.background " + field.style.background)
	//alert("life_field.style.background " + life_field.style.background)
	if (life_field.style.background == "") 	field.style.background = "#F8F8F8"; // nur ueberschreiben, wenn leer
	else 									field.style.background = life_field.style.background; 
	// alert(field.style.background)
	//field.style.background = "#FFFF00"; // nur ueberschreiben, wenn leer
	field.style.margin  	= "0px"
	field.style.padding 	= "0px"
	field.style.paddingLeft = "1px" // wegen des kleinengrauen Balkens links, in Moz kein Problem
	
	// field.style.display 	= "block";
	if (is_ie) {
		field.style.marginTop 		= "-1px" // Das ist eine IE Merkwuerdigkeit
		field.style.marginBottom 	= "-1px" // "
		// alert("field.type " + field.type)
		if (field.type=="text") field.height = life_field.offsetHeight // bei Input Feldern muss man fuer IE die Hoehe definieren
	}
	
	//field.style.margin = "0px" 
	
	
	/*
	// STYLE 4			hellgelb hinterlegt
	if (field.style.border == "") field.style.border = "0px solid" 
	field.style.background 	= "#FFFFAA"
	// field.style.borderLeft = "1px solid #CCCCCC" 
	*/
	
	//alert("rows " + field.rows + "\n" + " cols " + field.cols)
	/*
	alert(
	"life_field.id " + life_field.id + "\n" + 
	"field.id " + field.id + "\n" + 
	"field.style.height " + field.style.height + "\n" + 
	"field.style.width " + field.style.width + "\n" + 
	"rows " + field.rows + "\n" + 
	"cols " + field.cols  + "\n" + 
	"life_field.offsetHeight " + life_field.offsetHeight
	)
	*/
	
	// F E L D G R O S S E N 
	
	// W I D T H
	// wenn keine style.width und keine cols... -> life_field width
	//alert("field.style.width: "+ field.style.width + " cols: "+ field.cols +" rows: "+ field.rows)
	
	// 33er Trick -> das ist ein Dummy wert, der fuer nicht definiert steht
	//alert("life_field.style.width " + life_field.style.width);
	//alert("life_field.offsetWidth " + life_field.offsetWidth);
	//alert("field.style.width " + field.style.width);
	//alert("life_field.style.width " + life_field.style.width);
	//alert("field.cols " + field.cols)
	// alert("field.style.width " + field.style.width);
	lifeWidth = life_field.style.width;
	if ((field.style.width == "") && ((field.cols==33) || (field.size==33)))	 {
		// lifeWidth = life_field.style.width;
		// alert("lifeWidth " + lifeWidth);
		// "l":linke Position: Hier muss vermeidenwerden, daß die textaera/das inputfield 100% nehmen und das Icon nicht mehr passt
		if ((infotext.indexOf("l") != -1) && (lifeWidth=="100%"))  lifeWidth = "80%"; // das ist eine Annäherung, es muss so viel Platz geschaffen werden, daß das Icon Passt
		field.style.width = lifeWidth
	}
	// alert("lifeWidth " + lifeWidth);
	//field.style.width = "70%"
	
	
	// H E I G H T
	// Ausnahmen:
	// wenn mMoz, dann sollen Textfelder grosser geoeffnet werden, damit man mehr reinschreiben kann
	// feldvergroesserungsfactor 	= 1;
	// feldvergroesserungv 		= -2; // mozilla zeigt sonst einen Scrollbalken
	feldvergroesserungv 		= 0; // mozilla zeigt sonst einen Scrollbalken
 	
	lifeHeight = "";
	if ((field.style.height == "") && (field.rows==33)) { 
	// alert(life_field.offsetHeight);
		lifeHeight = life_field.offsetHeight + "" // in string umwandeln // die aktuelle Hoehe
		// alert("lifeHeight " + lifeHeight)
		// if (lifeHeight=="0") lifeHeight = "15"; // Mindesgroesse, bei images
		if (lifeHeight.indexOf("%") != -1) 		lifeHeight = (parseInt(lifeHeight)) +"%" 	// Prozentwerte
		else 									lifeHeight = (parseInt(lifeHeight) + feldvergroesserungv)	 		// Pixel
		// alert(parseInt(lifeHeight))
		if (parseInt(lifeHeight) < 15) lifeHeight = "15";
		// field.style.height = lifeHeight
		//alert("field.style.height " + field.style.height)
		// alert("field.offsetHeight " + field.offsetHeight)
	}
	// alert("life_field.offsetHeight" + life_field.offsetHeight)
	//alert(field.style.width)
	/*
	alert(	"field.style.height " + field.style.height + "\n" + 
			"field.rows " + field.rows + "\n" + 
			"lifeWidth " + lifeWidth)
		*/	
	// alert(life_field.offsetHeight)
	
	// DISABLED
	// +++ Achtug: das geht nur in IE, overflow = visible
	// if (!field.size) field.style.overflow = "visible" // "auto" // kein Scrollbar s fuer textareas
	field.style.overflow = "visible" // "auto" // kein Scrollbar s fuer textareas
	
	if (editorObj[field.id] && editorObj[field.id].isFloatingEditor == 0) {
		// nichts tun
	} else {
		// alert("resette "+span.id)
		if(life_field) {life_field.style.display 			= "none";}
		if (editorObj[field.id])	span.style.display 		= "block"; 	// vorher inline -> Probleme beim Swutchen mit Editoren designmode
		else 						span.style.display 		= "inline"; // inline wird fuer alle nicht editorfelder verwendet, damit das Icon lins stehen kann, sonst enststehen Umbrueche
		// span.style.display 		= "inline";
	}
	if (    (field.nodeName.toLowerCase() == "textarea") && (!field.size) && (window.adjustTextareaHeight)  ) adjustTextareaHeight("init",field)
	if (mode != 'all') {
		if ((fadeEditorbuttons) && editorObj[editorObjTextareaName]) editorObj[editorObjTextareaName].switchButtonModeFade(editorObjTextareaName) 		 
		fadeEditorbuttons = 1;
		try {field.focus()} 
		catch (e) {}
	}
	if(lifeHeight) field.style.height = lifeHeight
	//alert("field.offsetHeight " + field.offsetHeight)
} 







 
 
 function deactivate_all_fields() {
 	//return;
 	// Zuruecksetzen der editierbaren Felder
	allSpansArr 	= document.getElementsByTagName("div")
	allSpanslength 	= allSpansArr.length
	
	
	
	//alert("allSpanslength " + allSpanslength)
	for(i=0;i<allSpanslength;i++) {
		mySpan 			= allSpansArr[i];
		mySpanEditId 	= mySpan.id;
		if (mySpanEditId.indexOf("elife_") != -1) { 		// wenn es ein editerbarer Bereich ist
			if (mySpan.style.display != "none") { 			// Es ist ein sichtbarer editierbarer Bereich
				mySpanId   	= mySpanEditId.substr(1,mySpanEditId.length)
				myFieldId 	= mySpanId.substr(5,mySpanId.length)
				// alert("mySpanEditId " + mySpanEditId + "   mySpanId " + mySpanId + " myFieldId " + myFieldId)
				// alert("deactivate_all_fields " + myFieldId)
				is_editorfield 			= 0
				// ist es ein vom Editor bearbeitetet Feld? Gibt es ein Editorobjekt dazu?
				if (editorObj[myFieldId]) {
				// return;
				// if(mySpanId == "life_"+editorTextareabyUser) {
					//alert( "editorfelf: " + editorTextareabyUser)
					myVal = getContentForField()								// Hier wird der Content gewitcht
					// alert("nach getContentForField() " + myVal);
					is_editorfield = 1
				} else {
					myVal = document.getElementById(myFieldId).value
					myVal = myVal.replace(	/\n/gi			, '<br>') 
				}
				
				//if (editorObj[field.id] && editorObj[field.id].isFloatingEditor == 0) {
				// continue
				//} 
				mySpan.style.display  	= "none";
				myLifeSpan 				= document.getElementById(mySpanId)
				
				// Lifespan sichtbar machen und den aktuellen Inhalt einsetzen
				// Das ist ein Provisorium, hier muss eigenlich sauber berechnet werden, z. B. wenn ich eine Tabelle einfuege
				/*
				alert(	"mySpanEditId (mySpan.id) " 	+ mySpanEditId + "\n" + 
						"mySpanId  " 					+ mySpanId)
				*/
				
				// alert(myVal)
				// myLifeSpan.innerHTML = myVal // Feld.value an life-Span zuruekgeben
				// alert(mySpan.id)
				// alert(myLifeSpan.id)
				// alert(mySpanId)
				// alert("is_editorfield " + is_editorfield + " myVal " + myVal)
				
				// Bilder schonmal zeigen....
				// Voraussetzung: SCF("i",..) -> Abfrage von reinen Bildnamen
				// hier gibt es ein paar probleme mit dem Erkennen der Bilder
				// der Mehrzeilen modus "m" geht nicht, wenn Bilder imtext auftreten, scheint die Bedingung bereits erfuellt zu sein
				
				// testen, ob ein "i" Feld, nur dort soll des Bild eingeblendet werden
				showImage = 0
				infospan = document.getElementById("infospan_"+mySpanId) // ein unsichtbares span, das Zusatzinformationen enthaelt
				if (infospan) {
					infospanText = infospan.innerHTML
					if (infospanText.indexOf("/") != -1) showImage = 1
				}
				if ((!is_editorfield) && showImage && (myVal.match(/^[a-zA-Z0-9-_]+\.(jpg)|(jpeg)|(gif)|(png)$/))     ) {
					//alert ("Bild gefunden: img_+mySpanId " + "img_"+mySpanId)
					//alert("myVal " + myVal)
					if (document.getElementById("img_"+mySpanId)) {
						//alert ("exisiert: img_"+mySpanId)
						// alert(infospan.innerHTML)
						CeImagePath = infospan.innerHTML 			// infotext enthaelt CeImagePath
						// alert("infospan.innerHTML " + infospan.innerHTML)
						document.getElementById("img_"+mySpanId).src = CeImagePath + myVal // JSImagePath wird in JSeditmodefunction definiert
						// alert("JSImagePath + myVal " +JSImagePath + myVal)
						myLifeSpan.style.display = "none" // Feldtext nicht Zeigen
					}
				} else {
					// Ansonsten Inhalt zeigen
					if(myVal == "") myVal = "&nbsp;" ; // ganz leere Felder erzeugen ein strichfoermiges Eingabefeld beim Zuruechswitchen
					myLifeSpan.innerHTML = myVal // Feld.value an life-Span zuruekgeben
					if (mySpanId.indexOf("bild") != -1) myLifeSpan.style.display="none" // Wenn Bildabfrage, Feldtext nicht Zeigen
					// alert("resette "+ myLifeSpan.id + " myVal " + myVal)
					myLifeSpan.style.display  = "block";
				}
			} // end if
		} // end indexOf
	} // end for i
} // end function




function hide_Vmarker(anaus) {
	allSpansArr 	= document.getElementsByTagName("div")
	allSpanslength = allSpansArr.length
	for(i=0;i<allSpanslength;i++) {
		mySpan 			= allSpansArr[i];
		mySpanEditId 	= mySpan.id;
		//alert(mySpanEditId)
		if (mySpanEditId.indexOf("life_") != -1) { // wenn es ein editerbarer Bereich ist
			if (anaus==0) 	mySpan.style.borderLeftWidth = 0;
			else 			mySpan.style.borderLeftWidth = 1;
		}
	}
}


function test() {
	alert("test");
}

function submitWarn(warn,form) {
	// alert(form.name);
	if(confirm(warn)==true) form.submit();
}


function submitform(form) {
	//alert(form.sprachauswahl.value);
	//form.action=form.sprachauswahl.value;
	form.submit();
	
}

function submitsprachauswahl(form) {
	//alert(form.sprachauswahl.value);
	//alert(form.name)
	//form.submit();
	document.selectversion.submit();
}




function fensterauf(fenstertyp,vars,url) {
	// alert("fenstertyp: "+fenstertyp + " url: "+ url+vars);
	// return;
	if(fenstertyp=="kmicrosite"){
		(url.indexOf("emode=1") != -1) ? res = "yes"  : res = "no";
		{F2 = window.open(url,'microsite','toolbar=no,location=no,menubar=no,statusbar=no,scrollbars=no,resizable='+res+',width=798,height=560,left=0,top=0');}
	}
	/*if(fenstertyp=="kmicrosite"){
		if(!window.opener) {
			// Fenster soll im editmode resizable geoffnet werden
			(vars.indexOf("emode=1") != -1) ? res = "yes"  : res = "no";
			F2 = window.open(url+vars,'microsite','toolbar=no,location=no,menubar=no,statusbar=no,scrollbars=no,resizable='+res+',width=798,height=560,left=0,top=0');
		}
	}
	*/
	if(fenstertyp=="edituserrigths") 			{F2 = window.open('userrights.php?'                     		  	+vars,'','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=700,left=10,top=10');}
	if(fenstertyp=="PDFgen")         			{F2 = window.open('/cms/pdf_generation/pdfgen.php?'               	+vars,'','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=480,height=720,left=0,top=0');}
	if(fenstertyp=="email")          			{F2 = window.open('/cms/email.php?'                               	+vars,'','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=500,left=0,top=0');}
	if(fenstertyp=="productfeatures")			{F2 = window.open('/cms/productfeatures.php?'                     	+vars,'','toolbar=no,location=no,menubar=no,scrollbars=no,resizable=yes,width=520,height=280,left=0,top=0');}
	if(fenstertyp=="productfeatures_icon_only")	{F2 = window.open('/cms/productfeatures.php?'                 		+vars,'','toolbar=no,location=no,menubar=no,scrollbars=no,resizable=yes,width=260,height=280,left=0,top=0');}
	if(fenstertyp=="formgenerator")				{F2 = window.open('/cms/mod/formgenerator/formgenerator.php?'     	+vars,'','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=600,left=0,top=0');}
	if(fenstertyp=="compareproducts")			{F2 = window.open(url                 								+vars,'','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=1024,height=810,left=0,top=0');}
	if(fenstertyp=="productform")				{F2 = window.open(url      											+vars,'','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=800,left=0,top=0');}
	if(fenstertyp=="cleaningagents_details")	{F2 = window.open(url      											+vars,'','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=640,height=800,left=0,top=0');}
	if(fenstertyp=="appadvisor")				{F2 = window.open(url                 								+vars,'','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=800,height=1000,left=20,top=20');}
}






function openNewWindow(theURL,winName,features) {
//alert(path)
	window.open(theURL,winName,features);
}
function Dfensterauf(path,name,xy) {
// Downloadfenster fŸr PDF...
//alert(path);
F2 = window.open(path,'download','toolbar=no,location=no,menubar=no,scrollbars=yes,resizable=yes,width=340,height=160,left=-10,top=-10');
}

function popup(path,w,h) {
	// $downloadlink = '<a href="javascrip:\"Dfensterauf(/cms/download.php?path='$ImagePath.$thissrc.'&name='.$bu.');">'.$bu.'</a>';
	//alert(fenstertyp);
	F2 = window.open(path,'download','toolbar=no,location=no,menubar=no,scrollbars=no,resizable=yes,width='+w+',height='+h+',left=-10,top=-10');
}


var lastColor="#FFFFFF";
var lastObj;
function roll(obj,mybgColor) { 
	if(lastObj) lastObj.bgColor = lastColor; // zuraecksetzen
	lastColor = obj.bgColor // speichern
	obj.bgColor = mybgColor;
	lastObj = obj;
}
function rollback(obj) {
	obj.bgColor = lastColor;
}
function rollclass(obj,myclass) { 
	obj.className = myclass;
}
function rollImg(thisimg, wObj){ 
	document[thisimg].src = wObj.src;
}
function rollImgBg(imgName, wObj, bgElName,col){ 
// Aendert farbe + 1 Bild
	//document.getElementById(imgName).src = wObj.src;
	document.getElementById(imgName).src = wObj.src;
	document.getElementById(bgElName).bgColor = col;
}




function activateInputField(obj) {
	myobj = document.getElementById(obj)
	d = myobj.disabled
	//alert(d)
	if (d == 1) myobj.disabled = 0;
	else 		myobj.disabled = 1
}



function btn_Set(obj,className) 		{obj.className=className}
function btn_hover(obj) 	{obj.className="btn_hover"}
function btn_out(obj) 		{obj.className="btn"}
function btn_down(obj) 		{obj.className="btn_active"}
function btn_up(obj) 		{obj.className="btn"}
function btntop_hover(obj) 	{obj.className="btntop_hover"}
function btntop_out(obj) 	{obj.className="btntop"}
function btntop_down(obj) 	{obj.className="btntop_active"}
function btntop_up(obj) 	{obj.className="btntop"}
function btnhell_hover(obj) {obj.className="btnhell_hover"}
function btnhell_out(obj) 	{obj.className="btnhell"}
function btnhell_down(obj) 	{obj.className="btnhell_active"}
function btnhell_up(obj) 	{obj.className="btnhell"}

//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+                                                                 +
//+                                                                 +
//+                                                                 +
//+                            +FENSTER                             +  
//+                                                                 +
//+                                                                 +
//+                                                                 +
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
function openDialog(DialogData)  {
		// Dialogfenster bekommen ein Beschreibungsobjekt mit, das aus 3 Elementen besteht
		// 1) url und andere Fensterparameter
		// 2) args: 			dcmd=Befahl, der nach dem Schissen des Fenster ausgefuehrt wird, obligaorisch
		//					    color= irgendwelche anderen Daten fuer das Fenster
		// bsp: dialogData = {url:"select_color.html", w:250, h:180, args:{dcmd:"forecolor", color:"#FFFFFF"}}
		// damit lassen isch alle gaengigen Dialoge bewaeltigen 
		url = DialogData.url
		
		
		if (!DialogData.h)        h       = 100;        else h = DialogData.h;
		if (!DialogData.w)        w       = 100;        else w = DialogData.w;
		if (!DialogData.t)        t       = 100;        else t = DialogData.t;
		if (!DialogData.l)        l       = 100;        else l = DialogData.l;
		if (!DialogData.resize)   resize  = 0;          else resize = DialogData.resize;
		if (!DialogData.status)   status  = 0;          else status = DialogData.status;
		if (!DialogData.scrollen) scrollen= 0;          else scrollen = DialogData.scrollen;
		if (!DialogData.edge)     edge    = "raised";   else edge = DialogData.edge;
		if (!DialogData.loc)      loc     = 0;    		else loc = DialogData.loc;
		if (!DialogData.modus)    modus   = "modeless"; else modus = DialogData.modus;
		
		// DialogData.args muss mindestens 1en wer enthalten: dcmd, der ruft dei Function "doDialogCommand" nach Schliessen des Fensters auf...
		myDialogArguments = DialogData.args // wird von Mozilla abgerufen, wenn ein Fenster geoeffnet wurde
		// +++ Achtung: Ausnahme popupeditor, hier gibt es ein Problem mit dem iframe in einem modelessdialog
		if ((is_ie) && (modus != "normal")) {
			if (modus == "modeless") 	aktueldialog = showModelessDialog(url, window, 'resizable: '+resize+'; help: no; status: '+status+'; dialogHeight:'+h+'px; dialogWidth:'+w+'px; dialogTop:'+t+'px; dialogLeft:'+l+'px; scroll:'+scrollen+'; edge:'+edge+';');
			else 						aktueldialog = showModalDialog(   url, window, 'resizable: '+resize+'; help: no; status: '+status+'; dialogHeight:'+h+'px; dialogWidth:'+w+'px; dialogTop:'+t+'px; dialogLeft:'+l+'px; scroll:'+scrollen+'; edge:'+edge+';');
			//alert(aktueldialog)
			//if (aktueldialog) doDialogCommand(aktueldialog) // sofort ausfuehren, wenn ein result vom Fenster kommt
		} else {
			aktueldialog = window.open(url, "", 'menuebar = 0, width='+(w-12)+', height='+(h-26)+', left='+l+', top='+t+',status='+status+', toolbar=0, scrollbars='+scrollen+', resizable='+resize+', location='+loc+',fullscreen = 0');
		}
		return aktueldialog
}


function dialogcheck() { // Dialoge kontrollieren
	// chekcen, ob es die Focus function gibt
	// Editorfenster ueberwachen
	if ((aktueldialogEditor) && (aktueldialogEditor.focus)) aktueldialogEditor.focus() 
	// cms Fenster ueberwachen
	if ((wload) && (!wload.closed)) {
		if ((aktueldialog) && (aktueldialog.focus)) aktueldialog.focus() 
	}
}

















function switch_service_direction() {
// alert("switch_service_direction")
// alert("input "+ document.edit.switch_service.value)
	if (document.edit.switch_service.value == "top_service") {
		document.edit.switch_service.value = "side_service"
	} else {
		document.edit.switch_service.value = "top_service"
	}
	// alert("output " + document.edit.switch_service.value)
	document.edit.submit()
}






////////////////////////////////
// Draging Elements
function startdragIt(evt) {
	if (window.toggleTicker) {toggleTicker()}
	MouseUpMenue = 0; 				// wird fuer Menues bnoetigt
	checkforOpenWindows();
	evt = (evt) ? evt : event;
	dragobj 	= (evt.target) ? evt.target : evt.srcElement;
	refobj 		= null;
	if (dragobj) {
		el = dragobj.id
		switch (el) {
			case "FloatingEditorGriff":
				dragobj = document.getElementById("FloatingEditorLayer")
				refobj  = document.getElementById("FloatingEditorLayer")
				if (is_mac_moz) {
					moveDummy 					= document.getElementById("moveDummy")
					FloatingEditorLayer 		= document.getElementById("FloatingEditorLayer")
					FloatingEditorTable 		= document.getElementById("FloatingEditorTable")
					moveDummy.style.display 	= "block"
					moveDummy.style.width 		= FloatingEditorTable.offsetWidth
					moveDummy.style.height 		= FloatingEditorTable.offsetHeight
					moveDummy.style.left 		= FloatingEditorLayer.offsetLeft
					moveDummy.style.top 		= FloatingEditorLayer.offsetTop
					dragobj = moveDummy
				}
			break;
			case "FloatingEditorLayer":
				dragobj = document.getElementById("FloatingEditorLayer")
				refobj  = document.getElementById("FloatingEditorLayer")
				if (is_mac_moz) {
					moveDummy 					= document.getElementById("moveDummy")
					FloatingEditorLayer 		= document.getElementById("FloatingEditorLayer")
					FloatingEditorTable 		= document.getElementById("FloatingEditorTable")
					moveDummy.style.display 	= "block"
					moveDummy.style.width 		= FloatingEditorTable.offsetWidth
					moveDummy.style.height 		= FloatingEditorTable.offsetHeight
					moveDummy.style.left 		= FloatingEditorLayer.offsetLeft
					moveDummy.style.top 		= FloatingEditorLayer.offsetTop
					dragobj = moveDummy
				}
			break;
			
		} // end switch
		if (refobj) {
			OffsetLeft 		= parseInt(refobj.offsetLeft) 
			OffsetTop 	 	= parseInt(refobj.offsetTop) 
		 	dragdistLeft 	= parseInt(evt.clientX) - OffsetLeft
			dragdistTop  	= parseInt(evt.clientY) - OffsetTop
		}
		// benoetigt, sonst keine sauberes Dragging in Moz, aber auch kein eingeben in Felder moeglich
		// deshlb testen, ob ein Drag Element angeklickt wurde (dann muss ein refobj vorliegen) 
		if (refobj) return false;
	}
}

function dragIt(evt) {
	evt = (evt) ? evt : event;
	if ((dragobj) && (refobj)){
		thisposH  = evt.clientX - dragdistLeft
		thisposV  = evt.clientY - dragdistTop
		//thisposH  = evt.pageX - dragdistLeft
		//thisposV  = evt.pageY - dragdistTop
		
		dragobj.style.left = thisposH
		dragobj.style.top  = thisposV
		FloatingEditorXpos = thisposH
		FloatingEditorYpos = thisposV
		// document.getElementById("ilayer").innerHTML = "thisposH: "+ thisposH + " thisposV: "+ thisposV; 
		// document.getElementById("infolayer").style.display = "block";
		// document.getElementById("infolayer").innerHTML = "thisposH:" + thisposH +"<br>" + "thisposV:" + thisposV +"<br>" + "dragdistLeft:" + dragdistLeft +"<br>" + "dragdistTop:" + dragdistTop +"<br>"
		if (is_ie) return false;
		evt.cancelBubble = true;
		return false;
	}
}

function stopdragIt(evt) {
	if (window.M_out)					M_out()
	if (window.checkforOpenWindows)  	checkforOpenWindows()
	if ((dragobj) && (refobj)) {
		
		if ((is_mac_moz) && (dragobj.id=="moveDummy")){
			moveDummy 					= document.getElementById("moveDummy")
			moveDummy.style.display 	= "none"
			FloatingEditorLayer 		= document.getElementById("FloatingEditorLayer")
			FloatingEditorLayer.style.left = moveDummy.style.left
			FloatingEditorLayer.style.top = moveDummy.style.top
		}
		if (window.writePositions) writePositions()		
	} // end if
	dragobj = null;	
	refobj  = null;	
}



function ismaxlength(obj){
	var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length>mlength)
	obj.value=obj.value.substring(0,mlength)
}


/*  
function getStyle() {   
            var Farbe;
            if(window.getComputedStyle) {
               Farbe= window.getComputedStyle(document.getElementById("lorem"),"").getPropertyValue("background-color");
            } else if(document.getElementById("lorem").currentStyle) {
               Farbe= document.getElementById("lorem").currentStyle.backgroundColor;
            } else if(document.ids) {
               Farbe= document.layers["lorem"].bgColor;            
            } else if(document.all) {
               Farbe=   document.all.lorem.style.backgroundColor; }
            alert(Farbe);
*/
function getCSSStyle(el,attribut) {   
	if (window.getComputedStyle) { //Moz
		//alert("getComputedStyle")
         attributVal = window.getComputedStyle(el,"").getPropertyValue(attribut);
	  } else if (el.currentStyle) {
		//alert("currentStyle")
		attributVal= el.currentStyle[attribut];
	}
	return attributVal;
}





/*
function adjustTextareaHeightSet(elID) {
	el = document.getElementById(elID)
	if (el.style.height != el.scrollHeight + 2) {
		el.style.height = el.scrollHeight+2;
	}
}
*/

function adjustTextareaHeight(ev,el) {
	if (!is_ie) {
		// alert("ev.keyCode " + ev.keyCode)
		/*
		alert(	"el.style.height " + el.style.height + "\n" + 
				"el.scrollHeight " + el.scrollHeight + "\n" 
		);
		*/
		// alert(el.id)
		//window.setTimeout("adjustTextareaHeightSet('"+el.id+"')",1);
		if (parseInt(el.style.height) != parseInt(el.scrollHeight + 2)) {
			el.style.height = el.scrollHeight + 2;
		}
	}
}

function adjustTextareaHeightIframe(Aktuelkey,iframe,iframebody,textarea,thiseditorObjTextareaName) {
	// getElementInfo(el)
	/*
	alert(	"iframebody.style.height " + iframebody.style.height + "\n" + 
			"iframebody.scrollHeight " + iframebody.scrollHeight + "\n" 
	);
	*/
	if (is_ie) {
		if (parseInt(iframebody.style.height+2) != parseInt(iframebody.scrollHeight)) {
			iframe.scrollTop = 0;
			iframe.height 			= iframebody.scrollHeight + 2;
			//textarea.style.height 	= iframebody.scrollHeight + 2;
			res 					= iframebody.scrollHeight + 2;
			// iframe.scrollTop = 0;
			// alert("iframe.scrollTop " + iframe.scrollTop)
			
		}
	} else {
		if (parseInt(iframebody.style.height+2) != parseInt(iframebody.scrollHeight)) {
		
			
			iframe.height 			= iframebody.scrollHeight;
			//textarea.style.height 	= iframebody.scrollHeight;
			res 					= iframebody.scrollHeight;
			//iframe.contentWindow.scrollY = 0 // hgat keine Wirkung...
			
			/*
				alert(	"iframe.height " 				+ iframe.scrollHeight		 	+ "\n" + 
						"iframe.scrollHeight " 			+ iframe.scrollHeight		 	+ "\n" + 
						"iframebody.scrollHeight " 		+ iframe.scrollHeight		+ "\n" + 
						"iframe.scrollTop " 			+ iframe.scrollTop		 	+ "\n" + 
						"iframebody.scrollTop " 		+ iframebody.scrollTop 		+ "\n" +
						"iframe.contentWindow.scrollTop " + iframe.contentWindow.scrollTop  + "\n" + 
						"iframe.contentWindow.document.body.scrollTop " + iframe.contentWindow.document.body.scrollTop  + "\n" + 
						"iframe.scrolling " 			+ iframe.scrolling		 	+ "\n" + 
						"iframebody.scrolling " 		+ iframebody.scrolling 		+ "\n" +
						"iframe.contentWindow.scrolling " + iframe.contentWindow.scrolling  + "\n" + 
						"iframe.contentWindow.document.scrolling " + iframe.contentWindow.document.scrolling  + "\n" + 
						"iframe.scrollY " 				+ iframe.scrollY 			+ "\n" + 
						"iframebody.scrollY " 			+ iframebody.scrollY 		+ "\n" + 
						"iframe.contentWindow.scrollY " + iframe.contentWindow.scrollY  + "\n" + 
						"iframe.contentWindow.scrollTop " + iframe.contentWindow.scrollTop  + "\n" + 
						"iframe.contentWindow.document.body.scrollY " + iframe.contentWindow.document.body.scrollY  + "\n" + 
						""
			)*/
			//iframe.contentWindow.scrollY =  -14
			
			// alert("res " + res)
		}
	}
	// merken
	
	document.getElementById("tempid__"+thiseditorObjTextareaName+"_editorHeightbyUser").value = res
	// alert("save thiseditorObjTextareaName " + thiseditorObjTextareaName + "  " + document.getElementById("tempid__"+thiseditorObjTextareaName+"_editorHeightbyUser").value)
}





function _adjustTextareaHeight(ev,el) {
//return;
		/* Offene Problme: 
		Die Berechung der lineheigt bei fontsize 100% = 100%8 * 1.2
		Das geht so eigentlich nicht....ich mussete wissen, was 100% px ist, daraus koennte ich es dann korrekt ableiten...
		Dafuer muesste ich aber den Browserdefult kennen ...
		
		getCSSStyle(el,attribut) muss ich erst noch testen!
		*/
	if(!is_ie) {
		// Problem 1: Das Feld schrumpft nicht mehr, wenn es einmal vergroessert ist
		// Problem 1: Wenn ien horizontaler Scrollbar auftritt, stimmt die Rechnung nicht mehr
		// Border muß angepasst werden
		//alert(el.style.lineHeight)
		// alert(el.style.fontSize)
		// alert("el.style.borderWidth " + el.style.borderWidth)
		thisborder = readCSSRule(el.className,"border")
		// alert("thisborder " + thisborder)
		
		if (  (el.style.borderWidth.indexOf("1px")!=-1) || (thisborder.indexOf("1px")!=-1)   ) 		border = 2; // 1px = cargorahmen
		else 					 					 												border = 4; // 2px = Standardrahmen
		
	
		//alert("border "+ border)
		lh 			   = 18;	// lineheight, muss evtl dyn abgefragt werden	
		_offsetHeight  = el.offsetHeight
		_scrollHeight  = el.scrollHeight
		
		// Berechnen der LineHeigt
		// +++ Achtung: Diese Methode ist nicht ganz sicher...
		// wenn andere Maßeinheiten wie em bestimmt sind, muß ich hier noch nachbessern
		// Je nach Grundeinstellung des Browsers ist der Prozentwert nich in px umzurechen
		// z. Z. wird berechnet: %,px
		thisfontsize = "";
		// ???
		//thislineheight = getCSSStyle(el,"line-height") // warum gibt gerade Line-Heibt "normal zurueck??? Selbst wenn line-height:200%; 
		//alert("thislineheight " +thislineheight);
		thislineheight = readCSSRule(el.className,"lineHeight")
		//alert("el.className "+ el.className)
		// alert("thislineheight " + thislineheight)
		if (!thislineheight) {	
		// alert("!val")
			thisfontsize = readCSSRule(el.className,"fontSize")
			//alert("fontSize " + val)
			if (thisfontsize) {
				// alert("lineHeight berechen aus fontsize")
				if(thisfontsize.indexOf("%")!=-1) 	thislineheight = (parseInt(thisfontsize)/8) *1.2 // 140% = 14px
				else 								thislineheight = parseInt(thisfontsize)*1.2
			}
		}
		// alert(val)
		// alert("thislineheight " + thislineheight + " thisfontsize " + thisfontsize)
		//alert("thisfontsize " + thisfontsize)
		if(thislineheight) lh = parseInt(thislineheight) + 1 // parseInt(thislineheight/2)// warum 8? Weiss ich nicht, geht aber...
		// alert("lh " + lh)
		//lh = 10
		//alert(lh)
		// alert(el.id + " h: " + h + " _scrollHeight:" + _scrollHeight)
		// alert(document.getElementById(id).style.fontSize)
		// var rules = document.styleSheets[i].rules ? document.styleSheets[".head"].rules : document.styleSheets[".head"].cssRules;
		if (ev != "init") { // nicht init
			if (ev.keyCode == 13)  { // return
				var ev = (window.Event) ? ev : window.event
				//alert("return")
				//document.getElementById(el.id).style.height = (_scrollHeight+(border)+lh);
				document.getElementById(el.id).style.height = (_scrollHeight+(border)+lh);
				// window.setTimeout("adjustTextareaHeightAfterReturn(\""+el.id+"\"," +(_scrollHeight+border+lh)+ ")",1)
			} else {
				// alert("else")
				if ((_offsetHeight-border) !=_scrollHeight) {el.style.height = (_scrollHeight+border+1)}
			}
		} else { // init
			el.style.height = (_scrollHeight+border);
		}
	}
}

function readCSSRule(classname,prop) {
	//alert(document.styleSheets.item(3).href)
	//alert("classname " + classname + " prop " + prop)
	
	var rules
	var docstyle = document.styleSheets.item(document.styleSheets.length-2); // Achtung: hier muß das richtige Stylesheet verwendet werden
	// styles sind mit items numeriert, ich nehme das letzte -> standardstytes
	//alert(docstyle.disabled)
	if (docstyle.rules)		rules=docstyle.rules;
  	if (docstyle.cssRules)	rules=docstyle.cssRules;
  	var rl=rules.length;
	for(var i=0;i<rl;i++){
    	//if(rules.item(i).selectorText=="."+classname) return rules.item(i).style[prop];
		// alert(rules.item(i).selectorText);
	// alert("classname "+ classname + " prop " + prop + " selectorText "  + rules.item(i).selectorText +"  " + rules.item(i).style[prop])
	// alert(rules.item(i))
		if(rules.item(i).selectorText==("."+classname)) {
			//alert(" selectorText "  + rules.item(i).selectorText + " prop " + prop + rules.item(i).style[prop])
			return rules.item(i).style[prop];
		}
  	}
}


function changeQueryPars(url,getVarName,getVarValue) {
	// Tauscht einen Parameter einer url aus, bzw hängt ihn an, wenn noch nicht definiert
	// alert("url: " + url)
	//alert("url: " + url + " getVarName: "+ getVarName +" getVarValue: " + getVarValue)
	if (url.indexOf(getVarName)!=-1){ 								// gibt es ihn schon ?
		// Value ersetzten
		seachrstr  = getVarName + "=[^&]*";
		replacestr = getVarName + "="+getVarValue
		// alert("seachrstr: " + seachrstr + " replacestr: "  + replacestr)
		newUrl = url.replace(new RegExp(seachrstr),replacestr); 		// Wert ersetztn
	} else {
		if (url.indexOf("?")==-1) newUrl =  url + "?"+getVarName+"=" + getVarValue
		else 					  newUrl =  url + "&"+getVarName+"=" + getVarValue
	}
	//alert("newUrl: " + newUrl)
	return newUrl
}


function switchLangTabs(ce_ID,ce_lang) {
	allLangTabs = document.getElementsByTagName("div")
	allLangTabsL = allLangTabs.length
	// alert("allLangTabsL " + allLangTabsL)
	// all wegschalten, ausser dem passenden
	//alert("langTab_"+ce_ID +"_"+ce_lang);
	for(i=0;i<allLangTabsL;i++) {
		thisTab = allLangTabs[i]
		// thisTab.style.display = "none"
		if (thisTab.id.indexOf("langTab_"+ce_ID+"_bar") != -1) {
			// alert("thisTab.id " + thisTab.id)
			if (thisTab.id == "langTab_"+ce_ID +"_bar_"+ce_lang) 	{
				//thisTab.style.display = ""
				//thisTab.style.left = "0"
				thisTab.style.position 	= ""
				thisTab.style.top 		= "0"
				//document.getElementById("langTab_"+ce_ID +"_marker_"+ce_lang).style.visibility = ""
			} else { 												
				//thisTab.style.display = "none"
				thisTab.style.position 	= "absolute"
				thisTab.style.top		= "-10000"
				//thisTab.style.left = "-10000"
				// document.getElementById("langTab_"+ce_ID +"_marker_"+ce_lang).style.visibility = "hidden"
			}
		}
	} // end for
	// alert ("langTab_"+ce_ID +"_marker_"+ce_lang)
	//document.getElementById("langTab_"+ce_ID +"_marker_"+ce_lang).style.visibility = ""
	//document.getElementById("langTab_"+ce_ID +"_marker_"+ce_lang).style.display = ""
}

function synchronizeInputElement(el) {
	thisNodeName = el.nodeName
	val 	 	 = el.value
	id2	= el.getAttribute("id2") // Fantasie Attribut, ID ist belegt fuer andere Funktionen
	// alert("thisNodeName: "+ thisNodeName);
	// alert("val "+ val);
	// alert("id2 "+ id2);
	id2Stamm = id2.split("_synchonize_")[0]
	
	if (thisNodeName.toLowerCase() == "select" ){						// alle selects synchonisieren
		allEl 		= document.getElementsByTagName("select")    
		allElLength = allEl.length
		for(i=0;i<allElLength;i++) {
			thisel = allEl[i]
			if (thisel.getAttribute("id2") && (thisel.getAttribute("id2").indexOf(id2Stamm) != -1)) {
				//alert("aendere select " + thisel.getAttribute("id2"))
				thisel.value = val
			}
		} // end for
	}
	if (thisNodeName.toLowerCase() == "input" ){						// alle inputs synchonisieren
		allEl 		= document.getElementsByTagName("input")    
		allElLength = allEl.length
		for(i=0;i<allElLength;i++) {
			thisel = allEl[i]
			// alert("thisel.id2 "+thisel.getAttribute("id2"))
			if (thisel.getAttribute("id2") && (thisel.getAttribute("id2").indexOf(id2Stamm) != -1)) {
				//alert("aendere input " + thisel.getAttribute("id2"))
				thisel.value = val
			}
		} // end for
	}
}













