﻿// user defined jQuery JavaScript functions (optional)
// dialog Link for opening Brunner video

function countBrochures() {
	var iCount = 0;
	
	if ($("#Dialog input[name='bInfoBroschuere']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoHKD']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoHBO']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoKamine']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoGrundofen']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoKT']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoES']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoPelletmodul']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoIrondog']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoWertigkeit']").is(':checked')) { iCount++; }
	if ($("#Dialog input[name='bPrintInfoAufwertprogramm']").is(':checked')) { iCount++; }
	
	return iCount;
}

function init_jQuery() {
	// disable if we are on the right form
	$("#Dialog input[name='sName']").attr('disabled', true).css('background', '#888');
	$("#Dialog input[name='sVorname']").attr('disabled', true).css('background', '#888');
	$("#Dialog input[name='sStrasse']").attr('disabled', true).css('background', '#888');
	$("#Dialog input[name='sPLZ']").attr('disabled', true).css('background', '#888');
	$("#Dialog input[name='sOrt']").attr('disabled', true).css('background', '#888');
	$("#Dialog select[name='sLand']").attr('disabled', true).css('background', '#888');
	$("#Dialog input[name='sEMail']").attr('disabled', true).css('background', '#888');
	$("#Dialog input[name='sBeratungTelefon']").attr('disabled', true).css('background', '#888');
	$("#Dialog select[name='sBeratungWochentag']").attr('disabled', true).css('background', '#888');
	$("#Dialog input[name='sBeratungZeitFrom']").attr('disabled', true).css('background', '#888');
	$("#Dialog input[name='sBeratungZeitTo']").attr('disabled', true).css('background', '#888');
	
	$("#Dialog input[name='bInfoBroschuere']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoHKD']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoHBO']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoKamine']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoGrundofen']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoKT']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoES']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoPelletmodul']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoIrondog']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoWertigkeit']").attr('disabled', true);
	$("#Dialog input[name='bPrintInfoAufwertprogramm']").attr('disabled', true);

	$("#Dialog input[type='submit'][action='1035']").attr('disabled', true).css('background', '#888');
	
	$("#Dialog input[name='bConsultingCoupon']").click(function () 
	{	// enable all input fields
		if ($("#Dialog input[name='bConsultingCoupon']").is(':checked')) {
			$("#Dialog input[name='sName']").removeAttr("disabled").css('background', '#333');
			$("#Dialog input[name='sVorname']").removeAttr("disabled").css('background', '#333');
			$("#Dialog input[name='sStrasse']").removeAttr("disabled").css('background', '#333');
			$("#Dialog input[name='sPLZ']").removeAttr("disabled").css('background', '#333');
			$("#Dialog input[name='sOrt']").removeAttr("disabled").css('background', '#333');
			$("#Dialog select[name='sLand']").removeAttr("disabled").css('background', '#333');
			$("#Dialog input[name='sEMail']").removeAttr("disabled").css('background', '#333');
			$("#Dialog input[name='sBeratungTelefon']").removeAttr("disabled").css('background', '#333');
			$("#Dialog select[name='sBeratungWochentag']").removeAttr("disabled").css('background', '#333');
			$("#Dialog input[name='sBeratungZeitFrom']").removeAttr("disabled").css('background', '#333');
			$("#Dialog input[name='sBeratungZeitTo']").removeAttr("disabled").css('background', '#333');

			$("#Dialog input[name='bInfoBroschuere']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoHKD']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoHBO']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoKamine']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoGrundofen']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoKT']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoES']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoPelletmodul']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoIrondog']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoWertigkeit']").removeAttr("disabled");
			$("#Dialog input[name='bPrintInfoAufwertprogramm']").removeAttr("disabled");

			$("#Dialog input[type='submit'][action='1035']").removeAttr("disabled").css('background', '#333');
		}
		else 
		{	// disable all controls
			$("#Dialog input[name='sName']").attr('disabled', true).css('background', '#888'); 
			$("#Dialog input[name='sVorname']").attr('disabled', true).css('background', '#888');
			$("#Dialog input[name='sStrasse']").attr('disabled', true).css('background', '#888');
			$("#Dialog input[name='sPLZ']").attr('disabled', true).css('background', '#888');
			$("#Dialog input[name='sOrt']").attr('disabled', true).css('background', '#888');
			$("#Dialog select[name='sLand']").attr('disabled', true).css('background', '#888');
			$("#Dialog input[name='sEMail']").attr('disabled', true).css('background', '#888');
			$("#Dialog input[name='sBeratungTelefon']").attr('disabled', true).css('background', '#888');
			$("#Dialog select[name='sBeratungWochentag']").attr('disabled', true).css('background', '#888');
			$("#Dialog input[name='sBeratungZeitFrom']").attr('disabled', true).css('background', '#888');
			$("#Dialog input[name='sBeratungZeitTo']").attr('disabled', true).css('background', '#888');
			
			$("#Dialog input[name='bInfoBroschuere']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoHKD']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoHBO']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoKamine']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoGrundofen']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoKT']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoES']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoPelletmodul']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoIrondog']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoWertigkeit']").attr('disabled', true);
			$("#Dialog input[name='bPrintInfoAufwertprogramm']").attr('disabled', true);

			$("#Dialog input[type='submit'][action='1035']").attr('disabled', true).css('background', '#888');
		}
		
		return true;
	});

	$("#Dialog input[name='bInfoBroschuere']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});
	
	$("#Dialog input[name='bPrintInfoHKD']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});

	$("#Dialog input[name='bPrintInfoHBO']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});

	$("#Dialog input[name='bPrintInfoKamine']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});

	$("#Dialog input[name='bPrintInfoGrundofen']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});

	$("#Dialog input[name='bPrintInfoKT']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});

	$("#Dialog input[name='bPrintInfoES']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});

	$("#Dialog input[name='bPrintInfoPelletmodul']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});

	$("#Dialog input[name='bPrintInfoIrondog']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});

	$("#Dialog input[name='bPrintInfoWertigkeit']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});

	$("#Dialog input[name='bPrintInfoAufwertprogramm']").click(function () 
	{	// check number of checkboxes already selected
		if (countBrochures() > 2) { 
			alert("Bitte wählen Sie nur zwei Prospekte aus!");
			return false;
		}
	});
	
}