function hideEm(theNb){
	lvl=theNb.split("_");
	lvlOfBrothers="";
	for(l=0;l<lvl.length-1;l++){
		if(l>0) lvlOfBrothers+="_";
		lvlOfBrothers=lvl[l];
	}	
	for(n=0;n<20;n++){
	
		if((document.getElementById("ch"+lvlOfBrothers+"_"+n))&&(lvlOfBrothers.length>0)){
			document.getElementById("ch"+lvlOfBrothers+"_"+n).style.display="none";
		}	
		else if((document.getElementById("ch"+n))&&(lvlOfBrothers.length<1)){
			document.getElementById("ch"+n).style.display="none";	
		}	
	}
}
cnt=0;
blocked=false;
function countUp(){
	cnt++;
	if(cnt>10){
		//alert("100, neu");
		cnt=0;
		blocked=false;
	}
}
function ss(theNb){
	
	document.getElementById("s"+theNb).style.display="block";
}
function hs(theNb){
	document.getElementById("s"+theNb).style.display="none";
}

function mv(theNb){
	cnt=0;
	//if(!blocked){
	//	else 
	//		document.getElementById("deb").innerHTML="a>> "+theNb;

		hideEm(theNb);
		
		for(nc=0;nc<20;nc++){
			//hideEm(theNb+"_"+nc);
		}
		if(document.getElementById("ch"+theNb)){
			document.getElementById("ch"+theNb).style.color="blue";
			document.getElementById("ch"+theNb).style.display="block";
		}
	//}

	blocked=true;
}
function mo(theNb){

	hideEm;
	if(document.getElementById("ch"+theNb)){
		document.getElementById("ch"+theNb).style.display="none";
	}	
}
function omo(theNb){
	cnt=0;
	lvl=theNb.split("_");
}

function array_multisortJS(theArray, theField){
	
	var sortieren=new Array();
	for (var i=0;i<theArray.length;i++)
	{
		if(!isNaN(theArray[i][theField])){
			if(theArray[i][theField]<10)
				sortieren[i]="0"+theArray[i][theField]+";"+i;
			else
				sortieren[i]=theArray[i][theField]+";"+i; 
		}
		else{
			sortieren[i]=theArray[i][theField]+";"+i;
		}
		
	}

	sortieren.sort();
	sortedArray=new Array();
	
	for (var i=0;i<sortieren.length;i++) {
		var felderInNumArr = sortieren[i].split(";");
		var oldIndex=felderInNumArr[1];
		sortedArray[i]=new Array();
		sortedArray[i]=theArray[felderInNumArr[1]];
	
		for(var k in theArray[oldIndex]){	
			sortedArray[i][k]=theArray[oldIndex][k];
		}	
	}
	return sortedArray;

}
function submitLogin(){
	if((document.forms["logForm"].elements["lgm_username"].value.length>0)&&(document.forms["logForm"].elements["lgm_pwd"].value.length>0)){
        loc = document.location.href.split("?");
        loc = loc[0];
         //alert(loc);
		document.forms["logForm"].action = loc;
		document.forms["logForm"].submit();
	}
}

function doNothing(){

}
function logout(){
	
	document.forms["logForm"].action=document.location.href;
	document.forms["logForm"].submit();
	
}
currentClient=-1;
currentClientRow = -1;

function setEditableClient(theClientUid, theRowId){

	if(currentClient > -1){
		if(currentClientRow % 2 == 0) oldBkColor ="#ffffff";
		else  oldBkColor ="#f6f6f8";
		document.getElementById("klrow"+currentClientRow).style.backgroundColor = oldBkColor;	
	}
	currentClient = theClientUid;
	currentClientRow =  theRowId;
	document.getElementById("klrow"+theRowId).style.backgroundColor = "#999999";
}
/* Aktion der Kundenliste - Seite  */
function deleteClient(){
	if(currentClient > 0){
		showDialogWin("Best�tigungsaufforderung", "Soll die markierte Person wirklich gel�scht werden?", "reallyDeleteClient();");
	}
	else showDialogWin("Fehler", "Bitte w�hlen Sie zun�chst eine Person aus, die gel�scht werden soll!", "closeDialog();");
}
function reallyDeleteClient(){
	document.forms["kundenlisteForm"].elements['clientuid'].value = currentClient;
	document.forms["kundenlisteForm"].elements['act'].value = 2;
	document.forms["kundenlisteForm"].action="index.php?uid=20";
	document.forms["kundenlisteForm"].submit();
}
function editClient(){
	if(currentClient > 0){
		document.location.href="index.php?uid=22&clientuid="+currentClient;
	}
	else showDialogWin("Fehler", "Bitte markieren Sie zun�chst die Person in der Liste, die editiert werden soll.", "closeDialog();");
}
function newClient(){
		document.location.href="index.php?uid=22&clientuid=0&act=3";
}

/* --- Ende Aktionen auf Kundenliste-Seite */
/* Aktionen auf Kunden-Editier--Seite `*/
function delClientFrEditPage(theClientUid){
	currentClient = theClientUid;
	showDialogWin("Best�tigungsaufforderung", "Soll die Person wirklich gel�scht werden?", "reallyDeleteClient();");
}
function refreshKundenEditPage(){
	document.location.href="index.php?uid=22&clientuid="+document.forms["kundenlisteForm"].elements["clientuid"].value;
}

/* --- Ende Aktionen auf Kunden-Editier--Seite */


function closeDialog(){
	de("dialogPwdBody").style.display="none";
	de("lgm_dialog").style.display="none";
}
function showDialogWin(headerTxt, bodyTxt, okAction){
	if(!okAction) okAction="";
	de("dialogHd").innerHTML="<span>"+headerTxt+"</span>";	
	de("dialogBody").innerHTML=bodyTxt;
	if((okAction.length)>0) de("dialogBody").innerHTML+='<br/><br/><a href="javascript:'+okAction+'">Ok</a><a href="javascript:closeDialog();">'+WEBLABEL[144]+'</a>';
	else de("dialogBody").innerHTML+='<br/><br/><a href="javascript:closeDialog();">'+WEBLABEL[145]+'</a>';
	de("lgm_dialog").style.display="block";
}
function showNoPermissionError(){
    de("dialogHd").innerHTML = "<span>" + WEBLABEL[146] + "</span>";
	de("dialogBody").innerHTML = WEBLABEL[147];
    de("dialogBody").innerHTML += '<br/><br/><a href="javascript:closeDialog();">' + WEBLABEL[145] + '</a>';
    de("dialogBody").innerHTML += '<a href="javascript:closeDialog(); goToUid(11);">' + WEBLABEL[700] + '</a>';
	de("lgm_dialog").style.display="block";
// 	showDialogWin(WEBLABEL[146], WEBLABEL[147]);
}
// request the home page
function goToUid(uid) {
//    document.location.href += "&uid=11";
//     alert(langID);
    document.location.href = uidToHref(uid);
}

function uidToHref(uid) {
    return "index.php?uid=" + uid + "&langID=" + langID;
}

function pwdForgotten(){
	de("dialogPwdBody").style.display="block";
	de("lgm_dialog").style.display="block";
}
function submitPwdForgottenMail(){
	closeDialog();
	document.forms['dialogForm'].elements['act'].value="sendPWD";
	document.forms['dialogForm'].submit();
	
}
function showNews(theId){
		newWindow = open("../news.php?id="+theId, "news",
			    "width=560,height=650,menubar=no,resizable=no,locationbar=no,dependent=no,scrollbars=1");
}
function aendereMailIntervall(){
	de("mailConfigWin").style.display="block";	
}
function closeMailConfigWin(){
	de("mailConfigWin").style.display="none";	
}
function saveMailIntervall(){
	
	for(m=0;m<7;m++){
		for(ms=0;ms<maxslots;ms++){
			if(document.forms["diagrConf"].elements["mailslotuid"+m+"_"+ms]){
				if(document.forms["mailConfForm"].elements["mailconfig"+m+"_"+ms+"_isused"].checked)
					document.forms["diagrConf"].elements["mailslotisused"+m+"_"+ms].value=1;
				else document.forms["diagrConf"].elements["mailslotisused"+m+"_"+ms].value=0;
				
			}
		}
	}
	document.forms["diagrConf"].elements["act"].value = "saveMailConf";
	document.forms["diagrConf"].submit();
	
}
function changeCo2Image(laenderId){
	
	document.getElementById("co2image").src="co2/erzeugeCo2Diagramm.php?countryid="+laenderId+"&langID="+document.forms["dialogForm"].elements["langID"].value;
	document.getElementById("co2image2").src="co2/erzeugeCo2Diagramm.php?co2typ=2&countryid="+laenderId+"&langID="+document.forms["dialogForm"].elements["langID"].value;
	document.getElementById("co2image3").src="co2/erzeugeCo2Diagramm.php?co2typ=3&countryid="+laenderId+"&langID="+document.forms["dialogForm"].elements["langID"].value;
	document.getElementById("co2image4").src="co2/erzeugeCo2Diagramm.php?co2typ=4&countryid="+laenderId+"&langID="+document.forms["dialogForm"].elements["langID"].value;
	document.getElementById("co2image5").src="co2/erzeugeCo2Diagramm.php?co2typ=5&countryid="+laenderId+"&langID="+document.forms["dialogForm"].elements["langID"].value;
		document.getElementById("co2image6").src="co2/erzeugeCo2Diagramm.php?co2typ=6&countryid="+laenderId+"&langID="+document.forms["dialogForm"].elements["langID"].value;
//	if(laenderid<>26) document.getElementById("lastUeber").innerHTML="Temperaturabweichung gegen�ber langj�hrigem Mittel"; 
	//document.getElementById("co2detailLink").href="index.php?uid=41&lcode="+laenderId;
}
function showCRMDet(typNr){
	document.getElementById("crmDetail"+typNr).style.display="block";
}
function hideCRMDet(typNr){
	document.getElementById("crmDetail"+typNr).style.display="none";
}
window.setInterval("countUp()", 10);
