var gp_antiakw = 7.95;
var ap_antiakw = 0.234;

var einpersonenhh =1500; 	//1500 kWh/Jahr 
var zweipersonenhh =2400;	//2400 kWh/Jahr
var dreipersonenhh =3200;	//3200 kWh/Jahr
var vierpersonenhh =4000; 	//3960 kWh/Jahr

var strompreis_active = '';

var gasrechner_active = false;

function SuchenUndErsetzen(QuellText, SuchText, ErsatzText)
{   
    QuellText = String(QuellText);
    SuchText = String(SuchText);
    ErsatzText = String(ErsatzText);

    if ((QuellText == null) || (SuchText == null))           { return null; }
    if ((QuellText.length == 0) || (SuchText.length == 0))   { return QuellText; }

    if ((ErsatzText == null) || (ErsatzText.length == 0))    { ErsatzText = ""; }

    var LaengeSuchText = SuchText.length;
    var LaengeErsatzText = ErsatzText.length;
    var Pos = QuellText.indexOf(SuchText, 0);

    while (Pos >= 0)
    {
        QuellText = QuellText.substring(0, Pos) + ErsatzText + QuellText.substring(Pos + LaengeSuchText);
        Pos = QuellText.indexOf(SuchText, Pos + LaengeErsatzText);
    }
    return QuellText;
}	

function CheckZahl (Wert) 
{
	if (isNaN(Wert))
	{
		alert("Bitte geben Sie einen Zahlenwert ein!");
	}
	else
	{
		if (Wert > 9999)
		{
			var fb  = confirm("Dieser Strompreisrechner gilt nur für einen Verbrauch unter 10.000 kWh/Jahr." + String.fromCharCode(10) + "Ab einem Verbrauch von 10.000 kWh/Jahr unterbreiten wir Ihnen gerne ein individuelles Angebot in unserem Gewerbekundenbereich." + String.fromCharCode(10) + String.fromCharCode(10) + "Klicken Sie auf " + String.fromCharCode(34) + "Ok" + String.fromCharCode(34) + ", wenn Sie sich vertippt haben" + String.fromCharCode(10) + String.fromCharCode(10) + "Klicken Sie auf " + String.fromCharCode(34) + "Abbrechen" + String.fromCharCode(34) + ", wenn Sie einen Verbrauch ab 10.000 kWh/Jahr haben" + String.fromCharCode(10));
			if (fb == false) {
				self.location.href='/unser-strom/gewerbekunden/';			
			}  else {
				// document.getElementById('_strom1_stand_nt3').value='';
			}
		}
	}
}

function CheckZahl_gas (Wert) 
{
	if (isNaN(Wert))
	{
		alert("Bitte geben Sie einen Zahlenwert ein!");
	}
	else
	{
		if (Wert > 39999)
		{
			var fb  = confirm("Dieser Gaspreisrechner gilt nur für einen Verbrauch unter 40.000 kWh/Jahr." + String.fromCharCode(10) + "Ab einem Verbrauch von 40.000 kWh/Jahr unterbreiten wir Ihnen gerne ein individuelles Angebot in unserem Gewerbekundenbereich." + String.fromCharCode(10) + String.fromCharCode(10) + "Klicken Sie auf " + String.fromCharCode(34) + "Ok" + String.fromCharCode(34) + ", wenn Sie sich vertippt haben" + String.fromCharCode(10) + String.fromCharCode(10) + "Klicken Sie auf " + String.fromCharCode(34) + "Abbrechen" + String.fromCharCode(34) + ", wenn Sie einen Verbrauch ab 40.000 kWh/Jahr haben" + String.fromCharCode(10));
			if (fb == false) {
				self.location.href='/unser-gas/gewerbekunden/';			
			}  else {
				// document.getElementById('_strom1_stand_nt3').value='';
			}
		}
	}
}

function wertuebergabe(wertangabe)
{
	document.getElementById("eingabefeldkwh").value= wertangabe;
}

function rechnung() 
{
	var eingabefeld = document.getElementById('eingabefeldkwh').value;
						
	//antiakw	

	var temp = SuchenUndErsetzen(gp_antiakw, ".", ",");
	var dezteile = temp.split(",");
	if (temp.indexOf(",") > 0)
	{
		var dezteile = temp.split(",");
		if (dezteile[1].length == 1) {temp = temp + "0";}
	}
	else
	{
		temp = temp + ".00";
	}
	document.getElementById("monatgpantiakw").value = '€ '+ temp +' Grundpreis';
	
	var temp = SuchenUndErsetzen((Math.round((ap_antiakw * eingabefeld/12)*100)/100), ".", ",");
	var dezteile = temp.split(",");
	if (temp.indexOf(",") > 0)
	{
		var dezteile = temp.split(",");
		if (dezteile[1].length == 1) {temp = temp + "0";}
	}
	else
	{
		temp = temp + ".00";
	}
	document.getElementById("monatapantiakw").value = '€ '+ temp +' Arbeitspreis';
	
					
	var temp = SuchenUndErsetzen((Math.round((Number((ap_antiakw * eingabefeld)/12) + Number(gp_antiakw))*100)/100), ".", ",");
	var dezteile = temp.split(",");
	if (temp.indexOf(",") > 0)
	{
		var dezteile = temp.split(",");
		if (dezteile[1].length == 1) {temp = temp + "0";}
	}
	else
	{
		temp = temp + ".00";
	}
	document.getElementById("monatsgesamtantiakw").value = '€ '+ temp +' pro Monat';
	
	
	var temp = SuchenUndErsetzen(gp_antiakw*12, ".", ",");
	if (temp.indexOf(",") > 0)
	{
		var dezteile = temp.split(",");
		if (dezteile[1].length == 1) {temp = temp + "0";}
	}
	else
	{
		temp = temp + ".00";
	}
	document.getElementById("jahresgpantiakw").value = '€ '+ temp+' Grundpreis';
	
	
	var temp = SuchenUndErsetzen((Math.round((ap_antiakw * eingabefeld)*100)/100), ".", ",");
	if (temp.indexOf(",") > 0)
	{
		var dezteile = temp.split(",");
		if (dezteile[1].length == 1) {temp = temp + "0";}
	}
	else
	{
		temp = temp + ".00";
	}
	document.getElementById("jahresapantiakw").value = '€ '+ temp +' Arbeitspreis';
	
	var temp = SuchenUndErsetzen((Math.round((Number((ap_antiakw * eingabefeld)) + Number(gp_antiakw*12))*100)/100), ".", ",");
	var dezteile = temp.split(",");
	if (temp.indexOf(",") > 0)
	{
		var dezteile = temp.split(",");
		if (dezteile[1].length == 1) {temp = temp + "0";}
	}
	else
	{
		temp = temp + ".00";
	}
	document.getElementById("jahresgesamtantiakw").value = '€ '+ temp +' pro Jahr';
			
}


function swapStrompreisImages(which, click) {

	if (which == 1) {
		document.images["austausch1"].src='fileadmin/templates/pics/button_single.gif';
		document.images["austausch2"].src='fileadmin/templates/pics/button_double.gif';
		document.images["austausch3"].src='fileadmin/templates/pics/button_double_one_kid.gif';		
		document.images["austausch4"].src='fileadmin/templates/pics/button_double_two_kid.gif';				
		if (click == true) {
			strompreis_active = 'single';
		}
	} else if (which == 2) {
		document.images["austausch1"].src='fileadmin/templates/pics/button_single.gif';
		document.images["austausch2"].src='fileadmin/templates/pics/button_double_MO.gif';
		document.images["austausch3"].src='fileadmin/templates/pics/button_double_one_kid.gif';		
		document.images["austausch4"].src='fileadmin/templates/pics/button_double_two_kid.gif';					
		if (click == true) {
			strompreis_active = 'double';
		}
	} else if (which == 3) {
		document.images["austausch1"].src='fileadmin/templates/pics/button_single.gif';
		document.images["austausch2"].src='fileadmin/templates/pics/button_double.gif';
		document.images["austausch3"].src='fileadmin/templates/pics/button_double_one_kid_MO.gif';		
		document.images["austausch4"].src='fileadmin/templates/pics/button_double_two_kid.gif';						
		if (click == true) {
			strompreis_active = 'double_one';
		}
	} else if (which == 4) {
		document.images["austausch1"].src='fileadmin/templates/pics/button_single.gif';
		document.images["austausch2"].src='fileadmin/templates/pics/button_double.gif';
		document.images["austausch3"].src='fileadmin/templates/pics/button_double_one_kid.gif';		
		document.images["austausch4"].src='fileadmin/templates/pics/button_double_two_kid_MO.gif';					
		if (click == true) {
			strompreis_active = 'double_two';		
		}
	}
}

function restoreStrompreisImages(which) {
	document.images["austausch1"].src='fileadmin/templates/pics/button_single.gif';
	document.images["austausch2"].src='fileadmin/templates/pics/button_double.gif';
	document.images["austausch3"].src='fileadmin/templates/pics/button_double_one_kid.gif';		
	document.images["austausch4"].src='fileadmin/templates/pics/button_double_two_kid.gif';	
	
	if (strompreis_active == 'single') {
		document.images["austausch1"].src='fileadmin/templates/pics/button_single_MO.gif';
	}
	if (strompreis_active == 'double') {
		document.images["austausch2"].src='fileadmin/templates/pics/button_double_MO.gif';
	}
	if (strompreis_active == 'double_one') {
		document.images["austausch3"].src='fileadmin/templates/pics/button_double_one_kid_MO.gif';
	}
	if (strompreis_active == 'double_two') {
		document.images["austausch4"].src='fileadmin/templates/pics/button_double_two_kid_MO.gif';
	}
}
