// JavaScript Document
	//COPY www.rotavdrag2009.se 2009-01-01
	//Do not remove and also please link back to www.rotavdrag2009.se

<!-- Begin
function TaxCalc(form) {
	//COPY www.rotavdrag2009.se 2009-01-01
	//Do not remove and also please link back to www.rotavdrag2009.se
	var totkost = document.getElementById('totkost').value;
	var matkost = document.getElementById('matkost').value;
	var reskost = document.getElementById('reskost').value;
	var antalpers = document.getElementById('antalpers').value;
	var skattredpp = document.getElementById('skattredpp').value;
	var ok = 0;
	
	//this values will be calculated
	var arbkost = document.getElementById('arbkost').value;
	var skattred = document.getElementById('skattred').value;
	
	
	//Checks field 1 - 3 for perfect formating
	if (!totkost || isNaN(totkost) || !matkost || isNaN(matkost) || !reskost || isNaN(reskost) ) {
	alert("Fyll i Rutorna 1-3 med bara siffror, klicka sen på räkna");
	return;
	}
	
	//Checks field 1 - 3 for perfect formating
	if ((totkost - matkost - reskost) < 0 ) {
	alert("Kontrollera din räkning igen totalkostnad ska vara mer än material o resorna annars är det ingen idé");
	return;
	}
	//If formation ok, checks they not empty and calculate
	if (totkost != "" && matkost != "" && reskost != "" ) {
		document.getElementById('arbkost').value = (totkost - matkost - reskost); ok++;
		if ( ( (totkost - matkost - reskost)/2) >= (antalpers * skattredpp)) {
			document.getElementById('skattred').value =  (antalpers * skattredpp); ok++; 
		} else {
			document.getElementById('skattred').value =  ( (totkost - matkost - reskost)/2); ok++; 
		}
		//COPY www.rotavdrag2009.se
	}
	var incomplete = "Oj! Det verkar som om du inte fyllt i alla 3 fälten, fyll i dem och klicka på räkna knappen.";
	if (!ok) alert(incomplete);  // they did not enter at least 2 fields
}

