﻿
function chkAuswahl_CheckedChanged(control) {
	var anzahl = getAuswahlAnzahl();

	if (control == null) {
		return;
	}

	if (anzahl > 3) {
		control.checked = !control.checked;
		alert('Bitte wählen Sie maximal 3 Auswahlkriterien für die grafische Darstellung aus.');
		return;
	}
}
function checkAuswahlAnzahl() {
	if (getAuswahlAnzahl() != 0)
		return true;
	else {
		alert('Bitte wählen Sie 1 bis 3 Auswahlkriterien für die grafische Darstellung aus.');
		return false;
	}
}
function checkAuswahl() {
	if (!checkZeitraum()) {
		alert('Bitte überprüfen Sie die Datumseingaben.');
		return false;
	}

	if (getAuswahlAnzahl() != 0)
		return true;
	else {
		var chkBG1980 = document.getElementById("chkBG1980");
		var chkBGE_5 = document.getElementById("chkBGE_5");
		var chkBGE_10 = document.getElementById("chkBGE_10");
		var chkBGE_15 = document.getElementById("chkBGE_15");

		if (chkBG1980.checked) {
			if (chkBGE_5.checked || chkBGE_10.checked || chkBGE_15.checked) {
				return true;
			}
			else {
				alert('Bitte wählen Sie 1 bis 3 Auswahlkriterien für die grafische Darstellung aus.');
				return false;
			}
		}
		else {
			alert('Bitte wählen Sie 1 bis 3 Auswahlkriterien für die grafische Darstellung aus.');
			return false;
		}
	}
}
function checkBaugeldAuswahl(control) {
	var chkBGE_5 = document.getElementById("chkBGE_5");
	var chkBGE_10 = document.getElementById("chkBGE_10");
	var chkBGE_15 = document.getElementById("chkBGE_15");
	var cboZeitraumJahrVon = document.getElementById("cboZeitraumJahrVon");
	var cboZeitraumJahrBis = document.getElementById("cboZeitraumJahrBis");
	var count = 0;
	var i;

	if (chkBGE_5.checked) count += 1;
	if (chkBGE_10.checked) count += 1;
	if (chkBGE_15.checked) count += 1;

	if (count == 1 && control.checked) {
		for (i = 0; i <= 12; i++) {
			cboZeitraumJahrVon.options[i].disabled = false;
			cboZeitraumJahrBis.options[i].disabled = false;
		}
	}
	if (count == 0) {
		for (i = 0; i <= 12; i++) {
			cboZeitraumJahrVon.options[i].disabled = true;
			cboZeitraumJahrBis.options[i].disabled = true;
		}
		cboZeitraumJahrVon.options[15].selected = true;
		cboZeitraumJahrBis.options[15].selected = true;
	}
}
function checkZeitraum() {
	cboZeitraumMonatVon = document.getElementById("cboZeitraumMonatVon");
	cboZeitraumJahrVon = document.getElementById("cboZeitraumJahrVon");
	cboZeitraumMonatBis = document.getElementById("cboZeitraumMonatBis");
	cboZeitraumJahrBis = document.getElementById("cboZeitraumJahrBis");

	var monatVon = parseInt(cboZeitraumMonatVon.value);
	var jahrVon = parseInt(cboZeitraumJahrVon.value);
	var monatBis = parseInt(cboZeitraumMonatBis.value);
	var jahrBis = parseInt(cboZeitraumJahrBis.value);

	if (jahrVon > jahrBis) {
		return false;
	}
	else {
		if (jahrVon == jahrBis) {
			if (monatVon > monatBis) {
				return false;
			}
		}
	}

	return true;
}

function getAuswahlAnzahl() {
	var anzahl = 0;
	var control = null;

	control = document.getElementById("chkTG_Basis");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkTG_5000");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkTG_50000");
	if (control != null && control.checked) anzahl += 1;

	control = document.getElementById("chkFG_3");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkFG_6");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkFG_12");
	if (control != null && control.checked) anzahl += 1;

	control = document.getElementById("chkFG_50000_3");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkFG_50000_6");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkFG_50000_12");
	if (control != null && control.checked) anzahl += 1;

	control = document.getElementById("chkSB_2");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkSB_4");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkSB_5");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkSB_7");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkSB_10");
	if (control != null && control.checked) anzahl += 1;

	control = document.getElementById("chkSpareckzins");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkSpareinlage_50000");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkSpareinlage_1");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkSpareinlage_4");
	if (control != null && control.checked) anzahl += 1;

	control = document.getElementById("chkBG_5");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkBG_10");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkBG_15");
	if (control != null && control.checked) anzahl += 1;

	control = document.getElementById("chkRK_36");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkRK_48");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkRK_60");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkRK_72");
	if (control != null && control.checked) anzahl += 1;

	control = document.getElementById("chkGD");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkGDPlus");
	if (control != null && control.checked) anzahl += 1;

	control = document.getElementById("chkEuribor_3");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkEuribor_6");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkEonia");
	if (control != null && control.checked) anzahl += 1;

	control = document.getElementById("chkEZB");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkInflation");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkUmlaufrendite");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkDGZF_10");
	if (control != null && control.checked) anzahl += 1;
	control = document.getElementById("chkKFW_124");
	if (control != null && control.checked) anzahl += 1;

	return anzahl;
}
