// JavaScript Document

function scroller(Url){
	var Url;
	var scr;
	if(navigator.appName == "Microsoft Internet Explorer")
		scr=document.documentElement.scrollTop;
	else
		scr=window.pageYOffset;
	document.location.href = Url + "&scroll=" + scr;
}


function Monate(Wer,Objekt){
	Name = Objekt.id;
	TagName = Name.substring(0,Name.length-1)+1;
	MonatName = Name.substring(0,Name.length-1)+2;
	JahrName = Name.substring(0,Name.length-1)+3;
	Monat = document.getElementById(MonatName).value;
	Jahr = document.getElementById(JahrName).value % 4
	if(Jahr==0&&Monat==2){
		if(document.getElementById(TagName).length==28){
		  	NeuerEintrag = new Option(29, 29, false, false);
			document.getElementById(TagName)[28] = NeuerEintrag;
		}else if(document.getElementById(TagName).length==31){
			document.getElementById(TagName)[30] = null;
			document.getElementById(TagName)[29] = null;
		}else if(document.getElementById(TagName).length==30){
			document.getElementById(TagName)[29] = null;
		}
	}else if(Jahr!=0&&Monat==2){
		if(document.getElementById(TagName).length==31){
			document.getElementById(TagName)[30] = null;
			document.getElementById(TagName)[29] = null;
			document.getElementById(TagName)[28] = null;
		}else if(document.getElementById(TagName).length==30){
			document.getElementById(TagName)[29] = null;
			document.getElementById(TagName)[28] = null;
		}else
			document.getElementById(TagName)[28] = null;
	}else if(Monat==1||Monat==3||Monat==5||Monat==7||Monat==8||Monat==10||Monat==12){
		if(document.getElementById(TagName).length==28){
		  	NeuerEintrag = new Option(29, 29, false, false);
			document.getElementById(TagName)[28] = NeuerEintrag;
		  	NeuerEintrag = new Option(30, 30, false, false);
			document.getElementById(TagName)[29] = NeuerEintrag;
		  	NeuerEintrag = new Option(31, 31, false, false);
			document.getElementById(TagName)[30] = NeuerEintrag;
		}else if(document.getElementById(TagName).length==29){
		  	NeuerEintrag = new Option(30, 30, false, false);
			document.getElementById(TagName)[29] = NeuerEintrag;
		  	NeuerEintrag = new Option(31, 31, false, false);
			document.getElementById(TagName)[30] = NeuerEintrag;
		}else if(document.getElementById(TagName).length==30){
		  	NeuerEintrag = new Option(31, 31, false, false);
			document.getElementById(TagName)[30] = NeuerEintrag;
		}
	}else{
		if(document.getElementById(TagName).length==31)
			document.getElementById(TagName)[30] = null;
		else if(document.getElementById(TagName).length==28){
		  	NeuerEintrag = new Option(29, 29, false, false);
			document.getElementById(TagName)[28] = NeuerEintrag;
		  	NeuerEintrag = new Option(30, 30, false, false);
			document.getElementById(TagName)[29] = NeuerEintrag;
		}else if(document.getElementById(TagName).length==29){
		  	NeuerEintrag = new Option(30, 30, false, false);
			document.getElementById(TagName)[29] = NeuerEintrag;
		}
	}
}

function summ(was,zahl){
	var anzahl = document.getElementById('anzahl').value;
	var OldSum = document.getElementById('Gesamtpreis').value;	
	var GesSum = 0;
	for(var v=1;v<=anzahl;v++){
		prae = "p";		
		kat = (prae+v);	
		pre = "zp";
		zwi = (pre+v);			
		if(was == kat){
			var ReisP = document.getElementById(kat).value;
			document.getElementById(zwi).value = (ReisP*zahl);		
		}
		GesSum += eval(document.getElementById(zwi).value);
	}
	document.getElementById('Gesamtpreis').value = GesSum;
	kommazahl();
}

function kommazahl(){
	var num = document.getElementById('Gesamtpreis').value;
	var Cent = num*100;
	var CentStr = Cent.toString();
	var Eurozahl = CentStr.substr(0,CentStr.length-2);
	if(Eurozahl.length < 1) Eurozahl = "0";
	var Centzahl = CentStr.substr(CentStr.length-2,2);
	if(Centzahl.length < 2) Centzahl += "0";
	document.getElementById('Anzeige').value = Eurozahl + "," + Centzahl;
}


function LadeNach(was,incl,elmt){	
	var xmlHttp = null;
	// Mozilla, Opera, Safari sowie Internet Explorer (ab v7)
	if (typeof XMLHttpRequest != 'undefined') {
		xmlHttp = new XMLHttpRequest();
	}
	if (!xmlHttp) {
		// Internet Explorer 6 und älter
		try {
			xmlHttp  = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				xmlHttp  = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				xmlHttp  = null;
			}
		}
	}
	if (xmlHttp) {
		xmlHttp.open('GET', incl + '?' + was, true);
		xmlHttp.onreadystatechange = function () {
			if (xmlHttp.readyState == 4) {
				document.getElementById(elmt).innerHTML = xmlHttp.responseText;
			}
		};
		xmlHttp.send(null);
	}
}
