function pruefung(fieldname) {
	tempwert=document.pk.elements[fieldname].value;
	if(isNaN(tempwert)) {
		tempwert=tempwert.replace(",",".");
		if(isNaN(tempwert)) {
			document.pk.elements[fieldname].value=0;
		} else {
			document.pk.elements[fieldname].value=tempwert;
		};
	};
}


function berechnung() {
	stundeneigenwert=document.pk.stundeneigen.value*1;
	stundensatzwert=document.pk.stundensatz.value*1;
	if(stundeneigenwert == 0) {
		stundensystemwert=document.pk.minh.value*1+((document.pk.projektumfang.value*1-1)*document.pk.differenzh.value*1);
		document.pk.kalkaufwand.value=(stundensystemwert*stundensatzwert).toFixed(2);
		document.pk.stundensystem.value=stundensystemwert;
	} else {
		document.pk.kalkaufwand.value=(stundeneigenwert*stundensatzwert).toFixed(2);	
	};
	
	nreigenwert=document.pk.nreigen.value*1;
	nreigenverwendenwert=document.pk.nreigenverwenden.checked;
	if(nreigenverwendenwert == false) {
		nrw1wert=document.pk.nrw1.value*1;
		nrw2wert=document.pk.nrw2.value*1;
		nrw3wert=document.pk.nrw3.value*1;
		kalkaufwandwert=document.pk.kalkaufwand.value*1;
		
		arrNRraumwert=arrNRraum[1][nrw1wert-1];
		arrNRraumwert=arrNRraumwert.replace(",",".")*1;
		arrNRzeitwert=arrNRzeit[1][nrw2wert-1];
		arrNRzeitwert=arrNRzeitwert.replace(",",".")*1;
		arrNRinhaltwert=arrNRinhalt[1][nrw3wert-1];
		arrNRinhaltwert=arrNRinhaltwert.replace(",",".")*1;
		
		document.pk.nrraum.value=(arrNRraumwert*kalkaufwandwert).toFixed(2);
		document.pk.nrzeit.value=(arrNRzeitwert*kalkaufwandwert).toFixed(2);
		document.pk.nrinhalt.value=(arrNRinhaltwert*kalkaufwandwert).toFixed(2);

		if(nrw3wert>1) {
			summenw=document.pk.nrinhalt.value*1;
		} else {
			summenw=document.pk.nrraum.value*1 + document.pk.nrzeit.value*1;
		};
		document.pk.kalknr.value=summenw.toFixed(2);	
		
		//nrraumwert=document.pk.nrraum.value*1;
		//nrzeitwert=document.pk.nrzeit.value*1;
		//nrinhaltwert=document.pk.nrinhalt.value*1;
		//document.pk.kalknr.value=(nrraumwert+nrzeitwert+nrinhaltwert).toFixed(2);
	} else {
		document.pk.kalknr.value=(document.pk.nreigen.value*1).toFixed(2);
	};	

	kalkaufwandwert=document.pk.kalkaufwand.value*1;
	kalknrwert=document.pk.kalknr.value*1;
	document.pk.kalksumme.value=(kalkaufwandwert+kalknrwert).toFixed(2);
}

function projektlisteschreiben(seitenurl,projektgruppe,projektgruppebezeichnung,arrayname) {
	document.getElementById("divProjektgruppe").style.visibility='hidden';
	var projektid=0;
	document.pk.projektgruppeid.value=projektgruppe;
	document.pk.projektgruppebezeichnung.value=projektgruppebezeichnung;
	var layerinhalt='<div class="divFensterSchliessen"><h2><a href="javascript:projektauswahlSchliessen();">Abbrechen X</a></h2></div>';
	layerinhalt=layerinhalt + '<img src="../../includes/images/projektauswahlRot.gif" alt="1. Projektauswahl"/>';
	layerinhalt=layerinhalt + '<h1>Wählen Sie ein Projekt</h1>';
	layerinhalt=layerinhalt + '<p>Wählen Sie nun ein Projekt aus der Gruppe >>' + document.pk.projektgruppebezeichnung.value + '<< für die Berechnung aus.<br/>';
	layerinhalt=layerinhalt + 'Falls Sie doch ein Projekt aus einer anderen Gruppe berechnen wollen, <a href="javascript:projektauswahlSchliessen();projektauswahlStarten();">klicken Sie hier</a>.</p>';
	var i=0;
	while (arrayname[0][i] != undefined) {
		projektid=arrayname[0][i];
		projektbezeichnung=arrayname[1][i];
		projektbeschreibung=arrayname[2][i];
		layerinhalt=layerinhalt + '<div class="divProjektauswahlBox" title="bezeichnung" auswählen" onclick="location.href=\'' + seitenurl + projektid + '\';">';
		layerinhalt=layerinhalt + '<h2><a href="' + seitenurl + projektid + '" title="' + projektbezeichnung + ' auswählen">' + projektbezeichnung + '</a></h2>';
		layerinhalt=layerinhalt + '<p>' + projektbeschreibung + '</p>';
		layerinhalt=layerinhalt + '</div>';	
		i=i+1;
	}	
	document.getElementById("divProjekt").innerHTML = layerinhalt;
	document.getElementById("divProjekt").style.visibility='visible';
}


function projektauswahlStarten() {
	document.getElementById("divHide").style.visibility='visible';
	document.getElementById("divProjektgruppe").style.visibility='visible';
}

function projektauswahlSchliessen() {
	document.getElementById("divHide").style.visibility='hidden';
	document.getElementById("divProjektgruppe").style.visibility='hidden';
	document.getElementById("divProjekt").style.visibility='hidden';
	document.getElementById("divImpressum").style.visibility='hidden';
	document.getElementById("divQuickGuide").style.visibility='hidden';
}

function zeigeImpressum() {
	document.getElementById("divHide").style.visibility='visible';
	document.getElementById("divImpressum").style.visibility='visible';
}

function zeigeQuickGuide() {
	document.getElementById("divHide").style.visibility='visible';
	document.getElementById("divQuickGuide").style.visibility='visible';
}

//function zeigeHilfePopup(hilfeFensterName,x,y,e) {
//	if (!e) var e = window.event;
//	document.getElementById(""+hilfeFensterName).style.left  = e.clientX + 10 + "px";
//	document.getElementById(""+hilfeFensterName).style.top = e.clientY - y - 10 + "px";
//	document.getElementById(""+hilfeFensterName).style.visibility='visible';
//}

function zeigeHilfePopupRechts(hilfeFensterName,e) { 
// capture the mouse position 
	var breite = document.getElementById(""+hilfeFensterName).clientWidth;
	var hoehe = document.getElementById(""+hilfeFensterName).clientHeight;
    var posx = 0; 
    var posy = 0; 
    if (!e) var e = window.event; 
    if (e.pageX || e.pageY) 
    { 
        posx = e.pageX; 
        posy = e.pageY; 
    } 
    else if (e.clientX || e.clientY) 
    { 
        posx = e.clientX; 
        posy = e.clientY; 
    } 
//document.getElementById('pos').innerHTML = 'Mouse position is: X='+posx+' Y='+posy; 
document.getElementById(""+hilfeFensterName).style.left  = posx + 10 + "px";
document.getElementById(""+hilfeFensterName).style.top = posy - hoehe + 10 + "px";
document.getElementById(""+hilfeFensterName).style.visibility='visible';
}

function zeigeHilfePopupLinks(hilfeFensterName,e) { 
// capture the mouse position 
	var breite = document.getElementById(""+hilfeFensterName).clientWidth;
	var hoehe = document.getElementById(""+hilfeFensterName).clientHeight;
    var posx = 0; 
    var posy = 0; 
    if (!e) var e = window.event; 
    if (e.pageX || e.pageY) 
    { 
        posx = e.pageX; 
        posy = e.pageY; 
    } 
    else if (e.clientX || e.clientY) 
    { 
        posx = e.clientX; 
        posy = e.clientY; 
    } 
//document.getElementById('pos').innerHTML = 'Mouse position is: X='+posx+' Y='+posy; 
document.getElementById(""+hilfeFensterName).style.left  = posx - breite - 10 + "px";
document.getElementById(""+hilfeFensterName).style.top = posy - hoehe + 10 + "px";
document.getElementById(""+hilfeFensterName).style.visibility='visible';
}


function versteckeHilfePopup(hilfeFensterName) {
	document.getElementById(""+hilfeFensterName).style.visibility='hidden';
}