// INFO		
function CloseInfo() {	// Schließt alle Info fenster
	allInfo = document.getElementsByTagName('blockquote'); // Array Infofenster
	for(i = 0; i < allInfo.length; i++) { // Entfernt die class Active
			allInfo[i].className = allInfo[i].className.replace(new RegExp(" Active\\b"), "");
	}
}
function ToggleInfo(toActive) {	// Ruft ActiveInfo(); auf
		var funcMove = function() {ActiveInfo(toActive);}	// nötig für timeout mit Variable
		setTimeout(funcMove, 30);	// Timeout um CloseInfo(); abzuwarten
}
function ActiveInfo(toActive) {	// Setzt die Klasse Active für das zu öffnende Info fenster
	 toActive.className += " Active";	
}
document.onclick = function() {CloseInfo();} // Klick irgendwo schließt, Info fenster

// Energie
function energie(i) {
	if (i == 0) type = "Strom";
	if (i == 1) type = "Oel";
	if (i == 2) type = "Gas";
	if (i == 3) type = "Fernwärme";
	 document.getElementById('RowEnergie').className = type;
	 Gas(document.getElementById('GaskWh').parentNode.parentNode, true);
	}

// RADIO
function Gas(El, change) {	// Radio auswahl
	 ToBlur = El.parentNode.getElementsByTagName('div');
	 for(i = 0; i < ToBlur.length; i++) {	// Entfernt Active klasse
		 ToBlur[i].className = ToBlur[i].className.replace("Active", "");
	}
	El.className += " Active";	// Setzt active klasse
	El.getElementsByTagName('input')[0].checked = true;	// Zur Sicherheit wird das Radio ausgewählt
	
	if(change == true) {
		if(document.getElementById('GasVolumen').checked == true) {
			document.getElementById('RowEnergie').className = "Gas Volume";
		}
	 	else {
			document.getElementById('RowEnergie').className = document.getElementById('RowEnergie').className.replace("Volume", "");
		}
	}
	
}


// Runden auf 2 Komma stellen 
function valueRound(El, type) {
	El.parentNode.className = El.parentNode.className.replace(" Incorrect", "");
	ElValue = El.value;
	if(!isNaN(ElValue.replace(",", ".")) && ElValue != "") {
		if(type == "price") {
			ElValue = El.value.replace(",", ".");
			ElValue = parseFloat(ElValue);
			ElValue = ElValue.toFixed(2);
			El.value = ElValue.replace(".", ",");
		}
		else if(type == "int") {
			ElValue = El.value.replace(",", ".");
			ElValue = parseFloat(ElValue);
			ElValue = ElValue.toFixed(0);
			El.value = ElValue.replace(".", ",");
		}
	}
	else {
		El.parentNode.className += " Incorrect";		// Setzt incorrect class
	}
	if(El.name == "br-tage" && El.value > 365) {
		El.value = 365;
	}
}

// Cufon Remove

function remove_cufon(selector) {
$(selector).html( cufon_text(selector) );
return true;
}

function cufon_text(selector) {
var g = '';
$(selector +' cufon cufontext').each(function() {
    g = g + $(this).html();
}); 
return $.trim(g);
}

