var centerPos = 0;
var wRahmen = 0;
var actEntry = new Array();
var speed = new Array();
var moveIntervalId = new Array();
var wMenu = new Array();
var actPos = new Array();
var isIE=false;
var ctrlPressed=false;



function browserweiche()
{
// Alte Netscapes und IEs herausfiltern
var name = navigator.appName;
var version = navigator.appVersion;
var ieversion = version.substr(22,1);
var nsversion = version.substr(0,1); 

//alert(name.indexOf('Microsoft Internet Explorer'));

//if(!((name.indexOf('Microsoft Internet Explorer')!=-1 && ieversion<5) || (name.indexOf('Netscape')!=-1 && nsversion<5)))
//window.location.href = 'http://www.xxxx.com/index.php';
//else
//window.location.href = 'http://www.xxxx.com//old_browser/oldbrowser.html';
}


function check_fields(){
	alertString="";
	n=0;
//	if(document.forms["kontakt"].elements["anrede"].value==0){
//		alertString+="- Bitte eine Anrede auswählen\n\n";
//		n++;
//	}
	if(document.forms["kontakt"].elements["name"].value.length<4){
		alertString+="- Bitte gültigen Namen eintragen\n\n";
		n++;
	}
	if(document.forms["kontakt"].elements["str"].value.match(/\d/)==null					// keine Ziffern enthalten
				|| document.forms["kontakt"].elements["str"].value.match(/\D/)==null){	// keine Buchstaben enthalten
		alertString+="- Bitte Straße und Hausnr. eintragen\n\n";
		n++;
	}
	if(document.forms["kontakt"].elements["plz_ort"].value.match(/\d/)==null					// keine Ziffern enthalten
				|| document.forms["kontakt"].elements["plz_ort"].value.match(/\D/)==null){	// keine Buchstaben enthalten
		alertString+="- Bitte PLZ und Ort eintragen\n\n";
		n++;
	}
	if (document.forms["kontakt"].elements["email"].value.length<9 
				|| document.forms["kontakt"].elements["email"].value.indexOf("@")==-1
				|| document.forms["kontakt"].elements["email"].value.indexOf(".")==-1){
		alertString+="- Bitte gültige email-Adresse eintragen\n\n";
		n++;
	}
	if(alertString!="") {
		if (n==1) alertString="Es ist folgender Eingabefehler im Formular:\n\n"+alertString;
		else alertString="Es sind folgende "+n+" Eingabefehler im Formular:\n\n"+alertString;
		alert(alertString);
	} else document.forms["kontakt"].submit();
}


function showHideHelpdiv(){
	if(document.getElementById("helpdiv1").innerHTML==""){	// Hilfe anzeigen
		savepos=new domXml("inc/custom/na_sued/help_1.php");
		document.getElementById("helpdiv1").innerHTML=savepos.xmlDoc.responseText;
		savepos=new domXml("inc/custom/na_sued/help_2.php");
		document.getElementById("helpdiv2").innerHTML=savepos.xmlDoc.responseText;
		
		document.getElementById("help_btn").src="images/hilfe.gif";
	
	} else {												// Hilfe verstecken
		document.getElementById("helpdiv1").innerHTML="";
		document.getElementById("helpdiv2").innerHTML="";

		document.getElementById("help_btn").src="images/hilfe_pass.gif";
	}
	
}



		function executeEditTextSave(parms,pathPrefix){
			var getstr='&'+parms+'&called=jscript';
			my_response=new domXml(pathPrefix+"act/edit_text_save.php",getstr);
//alert("pathPrefix="+pathPrefix);
//			alert(my_response.xmlDoc.responseText);
//			window.location.href="index.php?"+parms;
		}
		function executeMoveSortTexte(parms,pathPrefix){
			var getstr='&'+parms;
			my_response=new domXml("act/move_sort_texte.php",getstr);
//			alert(my_response.xmlDoc.responseText);
		}

		function showHideBG(parms){			// Ein-/Ausblenden der Box-Umrandung
			hideOver();
//# 'kat_box_id' parm für die IDs von enclose-div und button-Image extraheren
			firstChar=parms.indexOf("kat_box_id=")+11;
			anzChar=parms.substr(firstChar).indexOf("&");
			kat_box_id=parms.substr(firstChar,anzChar);
	// TxtBoxInhalt obj adressieren
			encloseName='enclose_'+kat_box_id;
			thisBox=document.getElementById(encloseName);
	// button(img) obj adressieren
			buttonName='button_'+kat_box_id;
			thisImg=document.getElementById(buttonName);

//# 'action' Parm extrahieren
			firstChar=parms.indexOf("action=")+7;
			action=parms.substr(firstChar);
//	alert(action);

//# HTML code der Box holen
			var getstr='&task=boxCode&'+parms;
			my_response=new domXml("act/showHideBG.php",getstr);
			thisBox.innerHTML=my_response.xmlDoc.responseText;

//# HTML code des buttons(img) holen
			var getstr='&task=buttCode&'+parms;
			my_response=new domXml("act/showHideBG.php",getstr);
			thisImg.parentNode.innerHTML=my_response.xmlDoc.responseText;
//			alert(my_response.xmlDoc.responseText);

		}





// FlyText Funktionalität
// siehe auch func -> flyText: onMouseOver='showOver(this,\"Anzeigetext\");' onMouseOut='hideOver();'
// wenn flyText verwendet wird, muss die gesamte HTML-Zeile in einem print() ausgegeben werden!!!
// diese Zeile nach dem BODY-Tag einsetzen: 	<div id="overWindow"  class="flyTextDiv">test</div>
// diese Zeile vor dem BODY-Ende-Tag einsetzen: 	<script>infoWindow=document.getElementById('overWindow');</script>

var posx;
var posy;
infoWindow=document.getElementById('overWindow');
infoWindowBox=document.getElementById('overWindowBox');

function showOver(obj,showText){
//### HTML-Entities anzeigbar machen
//alert(showText);
	showText=showText.replace(/</g, "&lt;");
	showText=showText.replace(/>/g, "&gt;");
	showText=showText.replace(/&lt;br&gt;/g, "<br>");
//### innerHTML füllen
	infoWindow.innerHTML="<nobr>"+showText+"</nobr>";
	
//	infoWindow.zIndex=1000;
//alert("showText="+showText+" innerHTML:"+infoWindow.innerHTML+" posx="+posx+"  posy="+posy+" zIndex="+infoWindow.style.zIndex);
//	if(posx<50) posx=50;
//	if(posy<40) posy=40;
//	infoWindow.style.top=(posy-40)+'px';
//	infoWindow.style.left=(posx-50)+'px';
	infoWindow.style.visibility="visible";

}

function hideOver(){
	infoWindow=document.getElementById('overWindow');
	infoWindow.style.visibility="hidden";
}

function showOverBox(showText){
//### HTML-Entities anzeigbar machen
//alert(showText);
	showText=showText.replace(/</g, "&lt;");
	showText=showText.replace(/>/g, "&gt;");
	showText=showText.replace(/&lt;br&gt;/g, "<br>");
//### innerHTML füllen
	tableTextVor="<table><tr><td height='100%'>";
	tableTextNach="</td></tr></table>";
	infoWindowBox.childNodes[1].childNodes[1].childNodes[1].innerHTML=tableTextVor+showText+tableTextNach;
//	alert(infoWindowBox.childNodes[1].childNodes[1].childNodes[1].childNodes[1].childNodes[1].innerHTML);
	
//	infoWindow.zIndex=1000;
//alert("showText="+showText+" innerHTML:"+infoWindow.innerHTML+" posx="+posx+"  posy="+posy+" zIndex="+infoWindow.style.zIndex);
//	if(posx<50) posx=50;
//	if(posy<40) posy=40;
//	infoWindow.style.top=(posy-40)+'px';
//	infoWindow.style.left=(posx-50)+'px';
	infoWindowBox.style.visibility="visible";
//alert(infoWindowBox.innerHTML);

}

function hideOverBox(){
	infoWindowBox=document.getElementById('overWindowBox');
	infoWindowBox.style.visibility="hidden";
}

function moveInfoWindow(e){
			if(!e) e = window.event;
			if (e.pageX || e.pageY) 	{
				posx = e.pageX;
				posy = e.pageY;
				isIE=true;
			}
			else if (e.clientX || e.clientY) 	{
				posx = e.clientX + document.body.scrollLeft
					+ document.documentElement.scrollLeft;
				posy = e.clientY + document.body.scrollTop
					+ document.documentElement.scrollTop;
			}
			if(infoWindow){
		//### <br>-Tags bei Positionierung berücksichtigen
				restString=infoWindow.innerHTML;
//				restString=restString.substr(6);								// <nobr> am Anfang entfernen
//				restString=restString.substr(0,restString.indexOf("</nobr>"));	// <nobr> am Ende entfernen
				infoWindowLength=restString.length;
				maxLen=0; last_BR_Pos=0; anzBRs=0;
				BR_Pos=restString.indexOf("<br>");
				while(BR_Pos>0){
					anzBRs++;
					if((BR_Pos-last_BR_Pos)>maxLen) maxLen=BR_Pos-last_BR_Pos;
					last_BR_Pos=BR_Pos;
					restString=restString.substr(BR_Pos+2);
					BR_Pos=restString.indexOf("<br>");
				}
				if (maxLen>0){
					if((restString.length)>maxLen) maxLen=restString.length;
				} else
		//### keine <br>-Tags
					maxLen=infoWindow.innerHTML.length;

				if(posx>(document.body.offsetWidth-maxLen*4.2)) {
					posx=document.body.offsetWidth-maxLen*4.2;
				}
				if(posx<50) posx=50;
				if(posy<40) posy=40;
				posy=posy-anzBRs*10;
				infoWindow.style.left=(posx-50)+'px';
				infoWindow.style.top=(posy-40)+'px';
			}
			if(infoWindowBox){
		//### <br>-Tags bei Positionierung berücksichtigen
				restString=infoWindowBox.innerHTML;
//				restString=restString.substr(6);								// <nobr> am Anfang entfernen
//				restString=restString.substr(0,restString.indexOf("</nobr>"));	// <nobr> am Ende entfernen
				infoWindowLength=restString.length;
				maxLen=0; last_BR_Pos=0; anzBRs=0;
				BR_Pos=restString.indexOf("<br>");
				while(BR_Pos>0){
					anzBRs++;
					if((BR_Pos-last_BR_Pos)>maxLen) maxLen=BR_Pos-last_BR_Pos;
					last_BR_Pos=BR_Pos;
					restString=restString.substr(BR_Pos+2);
					BR_Pos=restString.indexOf("<br>");
				}
				if (maxLen>0){
					if((restString.length)>maxLen) maxLen=restString.length;
				} else
		//### keine <br>-Tags
					maxLen=infoWindow.innerHTML.length;
				posx=posx+7;
//				if(posx>(document.body.offsetWidth-maxLen*4.2)) {
//					posx=document.body.offsetWidth-maxLen*4.2;
//				}
				if(posx<50) posx=50;
				if(posy<40) posy=40;
				posy=posy-anzBRs*10-20;
				infoWindowBox.style.left=(posx-50)+'px';
				infoWindowBox.style.top=(posy-40)+'px';
			}
}


function coveredEmail(mailAdr){
	mPrefix=mailAdr.substr(0,mailAdr.indexOf("[at]"));
	mSuffix=mailAdr.substr(mailAdr.indexOf("[at]")+4);
	location.href="mailto:"+mPrefix+"@"+mSuffix;
}


function NNKeyCap(thisOne) {
//alert(thisOne.which);
    if ((thisOne.which == 191 || thisOne.which == 35) && (ctrlPressed)) {
	    document.getElementById('loginWin').style.visibility='visible';
//		alert('That\'s it!'+document.getElementById('loginWin').style.visibility);
	}
	if(thisOne.which==17) ctrlPressed=true;
//alert(thisOne.which);
//alert("Mozz: "+thisOne.which);
}

function IEKeyCap() {
//alert(window.event.ctrlKey);
	if (window.event.ctrlKey) {
	    if (window.event.keyCode == 191) {
	    	document.getElementById('loginWin').style.visibility='visible';
//       		alert('That\'s it!'+document.getElementById('loginWin').style.visibility);
       	}
	}
	
	
//	if(window.event.keyCode!=17) alert("IE: "+window.event.keyCode);
}



function keyDown(e){
//alert(e);
	if(!e) {
		e = window.event;
		IEKeyCap(e);
	} else NNKeyCap(e);
}



document.onmousemove = moveInfoWindow;

document.onkeydown = keyDown;
document.onkeyup = function resetKepressed() {ctrlPressed=false;}


