var wohnflaeche_text = "<p style='background-color:#FFFFFF'><b>Beheizte Wohnfl&auml;che (m2)</b><br><br>Geben Sie hier die gesamte beheizte Wohnfl&auml;che an. Die beheizte Wohnfl&auml;che ist die zum Wohnen nutzbare Fl&auml;che einer Wohnung oder eines Hauses.</p>";
var leistung_text = "<p style='background-color:#FFFFFF'><b>Anlagenleistung (kWh)</b><br><br>Geben Sie hier die Leistung Ihrer Heizungsanlage an. Die Anlagenleistung bezeichnet die erzeugte Energiemenge, die zum Heizen aufgewendet wird. Sie wird in Kilowattstunden (kWh) gemessen. </p>";
var waermebedarf_text = "<p style='background-color:#FFFFFF'><b>Typischer W&auml;rmebedarf</b><br><br>- Standard<br>- Niedrigenergiehaus<br><br>W&auml;hlen Sie hier zwischen den Begriffen &#x201E;Standard&#x201C; bzw. &#x201E;Niedrigenergiehaus&#x201C;, um Ihren typischen W&auml;rmebedarf pro Jahr zu bestimmen.  <br><br>Als Standardhaus nach EneV (Energieeinsparverordnung) wird ein Haus bezeichnet, das ca. 125 kWh pro m&sup2; beheizter Wohnfl&auml;che und Jahr an Heizenergie verbraucht. Als Niedrigenergiehaus wird ein Haus bezeichnet, das ca. 30 &#150; 50 %<br><br>Heizenergieeinsparung pro Jahr im Vergleich zu einem Standardhaus erm&ouml;glicht.</p>";
var betriebstundene_text = "<p style='background-color:#FFFFFF'><b>Betriebsstunden der Anlage im Jahr</b> <br>(nach Klimazonen berechnet)<br><br>- 1.700 Stunden (Mild)<br>- 1.900 Stunden (Mittel)<br>- 2.100 Stunden (Rau)<br><br>W&auml;hlen Sie hier zwischen den Begriffen &#x201E;1.700 Stunden (Mild) &#x201C;, &#x201E;1.900 Stunden (Mittel)&#x201C; und &#x201E;2.100 Stunden (Rau)&#x201C;, um die Betriebsstunden der Heizungsanlage pro Jahr zu bestimmen. <br><br>Die Klimazone besagt, f&uuml;r welche niedrigste Au&szlig;entemperatur eine Heizungsanlage ausgelegt werden muss. Deutschland ist in insgesamt 3 Klimazonen aufgeteilt: &#x201E;Mild&#x201C; (bis -12&deg;C Au&szlig;entemperatur), Mittel&#x201C; (bis -15&deg;C Au&szlig;entemperatur) und &#x201E;Rau&#x201C;(bis -18&deg;C Au&szlig;entemperatur). </p>";
var anlageinvestition_text_GBH = "<p style='background-color:#FFFFFF'><b>Anlageinvestition (&euro;)</b><br><br>Einschlie&szlig;lich der Kosten f&uuml;r Kessel, Brenner, Regelung, Rauchrohr, Montage Brennwertkessel, Rohrleitungen, Zubeh&ouml;r.</p>";
var anlageinvestition_text_pellets = "<p style='background-color:#FFFFFF'><b>Anlageinvestition (&euro;)</b><br><br>Einschlie&szlig;lich der Kosten f&uuml;r Kessel, Brenner, Regelung, Rauchrohr, Montage Pelletstank, Rohrleitungen, Zubeh&ouml;r</p>";
var anlageinvestition_text_oel = "<p style='background-color:#FFFFFF'><b>Anlageinvestition (&euro;)</b><br><br>Einschlie&szlig;lich der Kosten f&uuml;r Kessel, Brenner, Regelung, Rauchrohr, &Ouml;ltank, Montage, Zuleitungen, Rohrleitungen, Puffer, Zubeh&ouml;r, Tankraum, Kamin</p>";
var anlageinvestition_text_wp = "<p style='background-color:#FFFFFF'><b>Anlageinvestition (&euro;)</b><br><br>Einschlie&szlig;lich der Kosten f&uuml;r W&auml;rmepumpe, Regelung, Erdkollektor, Verteiler, Rohrleitungen, Zubeh&ouml;r, Montage</p>";
var foerdermittel_text = "<p style='background-color:#FFFFFF'><b>F&ouml;rdermittel (&euro;)</b><br><br>Geben Sie hier die Gesamtsumme aller erhaltenen F&ouml;rdermittel an. Die EU, der Bund, L&auml;nder, Gemeinden und die Energieversorger unterst&uuml;tzen  umweltfreundlicher Heizungsanlagen mit einer Vielzahl von F&ouml;rderprogrammen.</p>";
var systemauswahl_text = "<p style='background-color:#FFFFFF'><b>Systemauswahl</b><br><br>- Erdw&auml;rme und Sole <br>- Luft <br>- Grundwasser<br><br>W&auml;hlen Sie hier zwischen den Begriffen &#x201E;Erdw&auml;rme und Sole&#x201C;, &#x201E;Luft&#x201C; und &#x201E;Grundwasser&#x201C;, um das entsprechende W&auml;rmepumpensystem auszuw&auml;hlen.</p>";
var zinssatz_text = "<p style='background-color:#FFFFFF'><b>Zinssatz der Finanzierung (%)</b><br><br>Geben Sie hier die H&ouml;he des Zinssatzes an, der bei der Finanzierung der Heizungsanlage anf&auml;llt.</p>";
var tilgungssatz_text = "<p style='background-color:#FFFFFF'><b>Tilgungssatz (%)</b><br><br>Geben Sie hier die H&ouml;he der j&auml;hrlichen Tilgung an, die bei der Finanzierung der Heizungsanlage festgelegt wurde. </p>";
var anuitaet_text = "<p style='background-color:#FFFFFF'><b>Annuit&auml;t (%)</b><br><br>Geben Sie hier die Annuit&auml;t an. Die Annuit&auml;t bezeichnet Ihre gleich bleibende Jahresrate. Diese Jahresrate setzt sich aus dem f&uuml;r das Darlehen vereinbarten Zinssatz sowie der Darlehenstilgung zusammen.</p>";
var brennstoffkosten_text = "<p style='background-color:#FFFFFF'><b>Brennstoffkosten je Energieeinheit</b><br><br>Geben Sie hier Ihre Brennstoffkosten, inklusive MwSt. und Energiesteuer (&euro;/l bei Fl&uuml;ssiggas/&Ouml;l und &euro;/kg bei Pellets) an. Die Brennstoffkosten sind die j&auml;hrlich anfallenden Kosten f&uuml;r den Kauf von Brennstoffen zum Betrieb Ihrer Heizungsanlage.</p>";
var solar_text = "<p style='background-color:#FFFFFF'><b>PRIMAGAS solar</b><br><br>Geben Sie hier an, ob Sie eine Solaranlage (bestehend aus Kollektoren, Regler, Speicher, Zubeh&ouml;r) zur reinen Warmwasseraufbereitung oder zur kombinierten Warmwasseraufbereitung und Heizungsunterst&uuml;tzung nutzen m&ouml;chten.</p>";
var warning_text = "Sie m\u00fcssen mindestens eines der drei Vergleichs-Systeme\n(Pellets, \u00D6l oder W\u00E4rmepumpe) ausw\u00E4hlen!";


function checkBenchmark() {
	if (document.getElementsByName("pellets")[0].checked || document.getElementsByName("oel")[0].checked || document.getElementsByName("waermepumpe")[0].checked) {
		document.forms.calc.submit();
	} else {
		alert(warning_text);
	}
}

function form_reset() {
	document.forms.calc.reset();
	window.location = "/website/de/pub/service/tools_und_infos/vergleichsrechner.cfm";
}

function math_format(input) {
	input = input.replace(/[^\d,\.\-]/g,"").replace(/(\d+)(\.)?(\d{3}($|,))/,"$1$3").replace(/(\d+),(\d+)/,"$1.$2");
	return Number(input);
}

function write_format(input,percision) {
	x = String(input).substring(0,1);
	
	if (x == "-") {
		input = -1 * input;
	} else {
		x = "";
	}
	turky = 0;
	switch (percision) {
		case 10 :
			pattern_1 = /(-?\d{4}$)/;
			pattern_2 = /(\d$)/;
			if (!input) { 
				turky = 1; 
				newinput = "0,0";
			}
			break;
		case 100 :
			pattern_1 = /(-?\d{5}$)/;
			pattern_2 = /(\d{2}$)/;
			if (!input) { 
				turky = 1; 
				newinput = "0,00";
			}
			break;
		case 1000 :
			pattern_1 = /(-?\d{6}$)/;
			pattern_2 = /(\d{3}$)/;
			if (!input) { 
				turky = 1; 
				newinput = "0,000";
			}
			break;
		case 10000 :
			pattern_1 = /(-?\d{7}$)/;
			pattern_2 = /(\d{4}$)/;
			if (!input) { 
				turky = 1; 
				newinput = "0,0000";
			}
			break;
		case 100000 :
			pattern_1 = /(-?\d{8}$)/;
			pattern_2 = /(\d{5}$)/;
			if (!input) { 
				turky = 1; 
				newinput = "0,00000";
			}
			break;
		default:
			pattern_1 = /(-?\d{3}$)/;
			percision = 1;
	}
	input = Math.round(input*percision);
	no_dot_input = input;
	if (input >= 1000*percision) input = String(input).replace(pattern_1, ".$1");
	if (percision > 1) {
		if ( no_dot_input < percision ) {
			input = "0,"+String(input)
		} else {
			input = String(input).replace(pattern_2, ",$1");
		}
	} 
	if (turky) {
		input = newinput; 
	} else {
		input = x + input;
	}
	return input;
}

function calculateCosts(value_left, value_right) {

    var frm = document.forms["calc"];
    
    frm.slider_left.value     = value_left + ' %';
    frm.slider_right.value    = value_right + ' %';
}

	
function check_percent(me) {
	switch (me) {
		case 'A':
			document.getElementsByName("D3")[0].value = 100 -Math.round(math_format(document.getElementsByName("D2")[0].value));
			break;
		case 'B':
			document.getElementsByName("D2")[0].value = 100 -Math.round(math_format(document.getElementsByName("D3")[0].value));
			break;
		case 'C':
			document.getElementsByName("C19")[0].value = 100 -Math.round(math_format(document.getElementsByName("C18")[0].value));
			break;
		case 'D':
			document.getElementsByName("C18")[0].value = 100 -Math.round(math_format(document.getElementsByName("C19")[0].value));
	}
	first_calculation();
}

function set_to_zero(oposite) {
	document.getElementsByName(oposite)[0].value = 0;
	first_calculation();
}
	
function first_calculation() {

	Pellets = new Array();
	Oel = new Array();
	Primagas = new Array();
	Waermepumpe = new Array();
	
	A = math_format(document.getElementsByName("wohnflaeche")[0].value);
	B = document.getElementsByName("waermebedarf")[0].value;
	C = document.getElementsByName("betriebsstunden")[0].value;
	F = A*B*C; // Berechnung Jahresenergiebedarf
	solar = document.getElementsByName("solar")[0].value;
	solarfactor = document.getElementsByName("solarfactor")[0].value;
	if (solar == 1 && document.getElementsByName("solar")[0].tagName == "INPUT") {
		if (A < 161) {
			solar = document.getElementsByName("solar_300")[0].value;
		} else if (A > 210) {
			solar = document.getElementsByName("solar_500")[0].value;
		} else {
			solar = document.getElementsByName("solar_400")[0].value;
		}
		solarfactor = 0.88;
		document.getElementsByName("solar")[0].value = solar;
		document.getElementsByName("solarfactor")[0].value = solarfactor;
	}
	if (solar == "2" && document.getElementsByName("solar")[0].tagName == "INPUT") {
		if (A < 161) {
			solar = document.getElementsByName("solar_700")[0].value;
		} else {
			solar = document.getElementsByName("solar_1000")[0].value;
		}
		solarfactor = 0.63;
		document.getElementsByName("solar")[0].value = solar;
		document.getElementsByName("solarfactor")[0].value = solarfactor;
	}
	if ( document.getElementsByName("dont_ask_me")[0] ) {
		document.getElementsByName("dont_ask_me")[0].value = write_format(solar,100);
   }

	// Berechnung Jahresenergieverbrauchsmengen
	G_1 = F/4.9/0.88*solarfactor;
 	G_2 = F/7.3/1.02*solarfactor;
 	G_3 = F/10/0.97*solarfactor; 
	// Berechnung Jahresbrennstoffkosten
	H_1 = math_format(document.getElementsByName("pellets_brennstoffkosten")[0].value);
	H_2 = math_format(document.getElementsByName("primagas_brennstoffkosten")[0].value);
	H_3 = math_format(document.getElementsByName("oel_brennstoffkosten")[0].value);
	I_1 = Math.round(100*G_1*H_1)/100; 
	I_2 = Math.round(100*G_2*H_2)/100; 
	I_3 = Math.round(100*G_3*H_3)/100; 
	
	if (document.getElementsByName("fussboden")[0]) {
		L_name = "fussboden";
		N_name = "radiator";
	} else {
		L_name = "slider_left";
		N_name = "slider_right";
	}
	
	// Berechnung Jahresenergieverbrauchsmengen Fussbodenheizung
	J_1 = 4;
	J_2 = 2.8;
	J_3 = 4.2;
	L = math_format(document.getElementsByName(L_name)[0].value);
	M_1 = F/J_1*L/100*solarfactor; 
	M_2 = F/J_2*L/100*solarfactor; 
	M_3 = F/J_3*L/100*solarfactor; 
	// Berechnung Jahresenergieverbrauchsmengen Radiatorheizung
	K_1 = 3.4;
	K_2 = 2.4;
	K_3 = 3.6;
	N = math_format(document.getElementsByName(N_name)[0].value);
	O_1 = F/K_1*N/100*solarfactor; 
	O_2 = F/K_2*N/100*solarfactor; 
	O_3 = F/K_3*N/100*solarfactor; 
	
	if (document.getElementsByName("hochtarif_prozent")[0]) {
		P_name = "hochtarif_prozent";
		R_name = "niedertarif_prozent";
	} else {
		P_name = "slider_left";
		R_name = "slider_right";
	}
	
	P = math_format(document.getElementsByName(P_name)[0].value);
	Q = math_format(document.getElementsByName(R_name)[0].value);
	R = math_format(document.getElementsByName("hochtarif")[0].value);
	S = math_format(document.getElementsByName("niedertarif")[0].value);
	T_1 = (((M_1+O_1)*P*Q)+((M_1+O_1)*R*S))/10000;
	T_2 = (((M_2+O_2)*P*Q)+((M_2+O_2)*R*S))/10000;
	T_3 = (((M_3+O_3)*P*Q)+((M_3+O_3)*R*S))/10000;
	U = math_format(document.getElementsByName("leistung")[0].value)
	document.getElementsByName("wohnflaeche")[0].value = write_format(A);
	document.getElementsByName(L_name)[0].value = write_format(L);
	document.getElementsByName(N_name)[0].value = write_format(N);
	document.getElementsByName("leistung")[0].value = write_format(U);
	document.getElementsByName("jahresenergiebedarf")[0].value = write_format(F);
	
	document.getElementsByName("pellets_brennstoffkosten")[0].value = write_format(H_1,10000);
	document.getElementsByName("primagas_brennstoffkosten")[0].value = write_format(H_2,10000);
	document.getElementsByName("oel_brennstoffkosten")[0].value = write_format(H_3,10000);
 	if (document.getElementsByName("pellets_brennstoffkosten")[0].type == "text") document.getElementsByName("jahresenergiebedarf")[0].value = write_format(G_1);
	if (document.getElementsByName("primagas_brennstoffkosten")[0].type == "text") document.getElementsByName("jahresenergiebedarf")[0].value = write_format(G_2);
	if (document.getElementsByName("oel_brennstoffkosten")[0].type == "text") document.getElementsByName("jahresenergiebedarf")[0].value = write_format(G_3);
	document.getElementsByName("pellets_jahresbrennstoffkosten")[0].value = write_format(I_1,100);
	document.getElementsByName("primagas_jahresbrennstoffkosten")[0].value = write_format(I_2,100);
	document.getElementsByName("oel_jahresbrennstoffkosten")[0].value = write_format(I_3,100);
	
	document.getElementsByName(P_name)[0].value = write_format(P);
	document.getElementsByName("hochtarif")[0].value = write_format(R,100);
	document.getElementsByName(R_name)[0].value = write_format(Q);
	document.getElementsByName("niedertarif")[0].value = write_format(S,100);
	document.getElementsByName("waermepumpe_jahresbrennstoffkosten")[0].value = write_format(eval("T"+document.getElementsByName("waermepumpe_system")[0].value),100);
	if (document.getElementsByName("waermepumpe_jahresbrennstoffkosten")[0].type == "text") {
		G_4 = eval("M"+document.getElementsByName("waermepumpe_system")[0].value) +eval("O"+document.getElementsByName("waermepumpe_system")[0].value);
		document.getElementsByName("jahresenergiebedarf")[0].value = write_format(G_4);
	}
	//Berechnung der Anlagekosten
	
	Fact1 = math_format(document.getElementsByName("pellets_anlageinvestition")[0].value);
	Fact2 = math_format(document.getElementsByName("pellets_foerdermittel")[0].value);
	V1 = math_format(solar)+parseFloat(Fact1)-parseFloat(Fact2)+300;
	document.getElementsByName("pellets_anlageinvestition")[0].value = write_format(Fact1,100);	
	document.getElementsByName("pellets_foerdermittel")[0].value = write_format(Fact2,100);	
	document.getElementsByName("pellets_anlagekosten")[0].value = write_format(V1,100);			
	
	Fact1 = math_format(document.getElementsByName("primagas_anlageinvestition")[0].value);
	Fact2 = math_format(document.getElementsByName("primagas_foerdermittel")[0].value);
	V2 = math_format(solar)+parseFloat(Fact1)-parseFloat(Fact2)+300;
	document.getElementsByName("primagas_anlageinvestition")[0].value = write_format(Fact1,100);	
	document.getElementsByName("primagas_foerdermittel")[0].value = write_format(Fact2,100);	
	document.getElementsByName("primagas_anlagekosten")[0].value = write_format(V2,100);			
	
	Fact1 = math_format(document.getElementsByName("oel_anlageinvestition")[0].value);
	Fact2 = math_format(document.getElementsByName("oel_foerdermittel")[0].value);
	V3 = math_format(solar)+parseFloat(Fact1)-parseFloat(Fact2)+300;
	document.getElementsByName("oel_anlageinvestition")[0].value = write_format(Fact1,100);	
	document.getElementsByName("oel_foerdermittel")[0].value = write_format(Fact2,100);	
	document.getElementsByName("oel_anlagekosten")[0].value = write_format(V3,100);					
	
	Fact1 = math_format(document.getElementsByName("waermepumpe_anlageinvestition")[0].value);
	Fact2 = math_format(document.getElementsByName("waermepumpe_foerdermittel")[0].value);
	V4 = math_format(solar)+parseFloat(Fact1)-parseFloat(Fact2)+300;
	document.getElementsByName("waermepumpe_anlageinvestition")[0].value = write_format(Fact1,100);	
	document.getElementsByName("waermepumpe_foerdermittel")[0].value = write_format(Fact2,100);	
	document.getElementsByName("waermepumpe_anlagekosten")[0].value = write_format(V4,100);	
	
	//berechnung Annuit�t
	Fact_A = parseFloat(math_format(document.getElementsByName("finanzierung")[0].value));
	Fact_B = parseFloat(math_format(document.getElementsByName("tilgung")[0].value));
	if (Fact_B < 1) Fact_B = 1;
	X = (Fact_A+Fact_B);
	document.getElementsByName("finanzierung")[0].value = write_format(Fact_A,10);	
	document.getElementsByName("tilgung")[0].value = write_format(Fact_B,10);	
	document.getElementsByName("annuitaet")[0].value = write_format(X,10);	
	X = X/100;
	
	document.getElementsByName("pellets_fifteen_years")[0].value = fifteen_years(V1);	
	document.getElementsByName("primagas_fifteen_years")[0].value = fifteen_years(V2);	
	document.getElementsByName("oel_fifteen_years")[0].value = fifteen_years(V3);	
	document.getElementsByName("waermepumpe_fifteen_years")[0].value = fifteen_years(V4);
	
	V1 = V1*X;
	V2 = V2*X;
	V3 = V3*X;
	V4 = V4*X;
	
	document.getElementsByName("pellets_finanzierungskosten")[0].value = write_format(V1,100);	
	document.getElementsByName("primagas_finanzierungskosten")[0].value = write_format(V2,100);	
	document.getElementsByName("oel_finanzierungskosten")[0].value = write_format(V3,100);	
	document.getElementsByName("waermepumpe_finanzierungskosten")[0].value = write_format(V4,100);
	
	if (document.getElementById("a1")) { draw_chart(); }
}

function fifteen_years(me) {
	Finanzierung = me;
	Zins = parseFloat(math_format(document.getElementsByName("finanzierung")[0].value));
	Tilgung = parseFloat(math_format(document.getElementsByName("tilgung")[0].value));
	Anuitaet = Finanzierung*(Zins+Tilgung)/100;
	Dauer = 0;
	Zinsaufwand = 0;
	while(Dauer < 15) {
		Dauer++;
		a = Finanzierung*Zins/100;
		Zinsaufwand += a;
		b = Anuitaet-a;
		Finanzierung -= b;
	}
	return (write_format(me+Zinsaufwand,100));
}

function size_down(a,b,c) {
	me = math_format(a);
	me = me/b*c;
	return Math.round(me);
}

function draw_chart() {
	
	A1 = size_down(document.getElementsByName("primagas_finanzierungskosten")[0].value,1000,78);
	B1 = size_down(document.getElementsByName("pellets_finanzierungskosten")[0].value,1000,78);
	C1 = size_down(document.getElementsByName("oel_finanzierungskosten")[0].value,1000,78);
	D1 = size_down(document.getElementsByName("waermepumpe_finanzierungskosten")[0].value,1000,78);	

	A2 = size_down(document.getElementsByName("primagas_jahresbrennstoffkosten")[0].value,1000,78);	
	B2 = size_down(document.getElementsByName("pellets_jahresbrennstoffkosten")[0].value,1000,78);	
	C2 = size_down(document.getElementsByName("oel_jahresbrennstoffkosten")[0].value,1000,78);	
	D2 = size_down(document.getElementsByName("waermepumpe_jahresbrennstoffkosten")[0].value,1000,78);	
	
	A3 = size_down(document.getElementsByName("primagas_fifteen_years")[0].value,10000,39);	
	B3 = size_down(document.getElementsByName("pellets_fifteen_years")[0].value,10000,39);	
	C3 = size_down(document.getElementsByName("oel_fifteen_years")[0].value,10000,39);	
	D3 = size_down(document.getElementsByName("waermepumpe_fifteen_years")[0].value,10000,39);
	
	document.getElementById("a1").style.height = A1+"px"; 
	document.getElementById("a1").style.lineHeight = A1+"px";
	document.getElementById("a2").style.height = A2+"px"; 
	document.getElementById("a2").style.lineHeight = A2+"px";
	document.getElementById("a3").style.height = A3+"px"; 
	document.getElementById("a3").style.lineHeight = A3+"px";
	
	if (document.getElementsByName("pellets")[0].value == 1) {
		document.getElementById("b1").style.height = B1+"px"; 
		document.getElementById("b1").style.lineHeight = B1+"px";
		document.getElementById("b2").style.height = B2+"px"; 
		document.getElementById("b2").style.lineHeight = B2+"px";
		document.getElementById("b3").style.height = B3+"px"; 
		document.getElementById("b3").style.lineHeight = B3+"px";
	} else {
		document.getElementById("b1").style.visibility = "hidden";
		document.getElementById("b2").style.visibility = "hidden";
		document.getElementById("b3").style.visibility = "hidden";
	}
	
	if (document.getElementsByName("oel")[0].value == 1) {
		document.getElementById("c1").style.height = C1+"px"; 
		document.getElementById("c1").style.lineHeight = C1+"px";
		document.getElementById("c2").style.height = C2+"px"; 
		document.getElementById("c2").style.lineHeight = C2+"px";
		document.getElementById("c3").style.height = C3+"px"; 
		document.getElementById("c3").style.lineHeight = C3+"px";
	} else {
		document.getElementById("c1").style.visibility = "hidden";
		document.getElementById("c2").style.visibility = "hidden";
		document.getElementById("c3").style.visibility = "hidden";
	}
	
	if (document.getElementsByName("waermepumpe")[0].value == 1) {
		document.getElementById("d1").style.height = D1+"px"; 
		document.getElementById("d1").style.lineHeight = D1+"px";
		document.getElementById("d2").style.height = D2+"px"; 
		document.getElementById("d2").style.lineHeight = D2+"px";
		document.getElementById("d3").style.height = D3+"px"; 
		document.getElementById("d3").style.lineHeight = D3+"px";
	} else {
		document.getElementById("d1").style.visibility = "hidden";
		document.getElementById("d2").style.visibility = "hidden";
		document.getElementById("d3").style.visibility = "hidden";
	} 
}

