//<![CDATA[

function closeWelkom(what)
	{
	what.style.display = 'none';
	}

var hash = 'bbc58dafd86306df3f6774aaefc3c4fb';
var cijfers = new Array('nul', '&eacute;&eacute;n', 'twee', 'drie', 'vier', 'vijf', 'zes', 'zeven', 'acht', 'negen', 'tien', 'elf');
var x = Math.floor(11*Math.random());
var y = Math.floor(11*Math.random());
var z = x+y;

function fillSum ()
	{
	document.getElementById('x').innerHTML = cijfers[x];
	document.getElementById('y').innerHTML = cijfers[y];
	}

function CheckAll (what)
	{
	var mandatory = new Array();
	var error = '';
	var tmp = '';

	if (what.name == 'contact')
		{
		mandatory[2] = 'achternaam';
		mandatory[4] = 'e-mail adres';
		mandatory[5] = 'telefoonnummer';
		}

	if (what.name == 'informatie')
		{
		mandatory[1] = 'naam werknemer';
		mandatory[2] = 'straat';
		mandatory[3] = 'postcode en plaats';
		mandatory[4] = 'telefoonnumer';
		mandatory[12] = 'naam bedrijf';
		mandatory[13] = 'contactpersoon';
		mandatory[14] = 'telefoonnummer';
		}
	
	if (mandatory.length == 0)
		return (false);
	else
		{
		for (key in mandatory)
			if (document.getElementById('fieldnm_'+key).value.length == 0)
				error += mandatory[key] + ' is niet ingevuld.\n';
		
		if (document.getElementById('z').value != z)
			error += 'De anti spam controle is niet goed ingevuld.\n';
		else
			what.hash.value = hash;
			
		if (error.length > 0)
			{
			alert(error);
			return (false);
			}
		else
			return (true);
		}
	}

function berekenOCA()
	{
	// Zijn alle waardes ingevuld
	if (document.getElementById('a').value != '' &&
		document.getElementById('b').value != ''
		)
		{
		// Haal waardes op
		var a = parseFloat(document.getElementById('a').value.replace(',', '.'));
		var b = parseFloat(document.getElementById('b').value.replace(',', '.')) / 100;
		//var c = parseFloat(document.getElementById('c').value.replace(',', '.'));

		var c 			= 30; // Deze is fixed op 30 dagen
		var ziektePd	= 255; // Deze is fixed
		var kostenOCA	= 2500; // Deze is fixed
		
		// Maak berekeningen
		var d = a*b*(c*ziektePd);
		var totaalOCA = a*b*kostenOCA;
		var voordeel = d - totaalOCA;
		
		// Toon waardes
		//document.getElementById('uwv').innerHTML = d.toFixed(2);
		//document.getElementById('oca').innerHTML = totaalOCA.toFixed(2);
		logOca (a.toFixed(2), b.toFixed(2), voordeel.toFixed(2)); // Leg vast in log bestand
		document.getElementById('besparing').value = voordeel.toFixed(2);
		document.getElementById('meerinfo').style.display = 'inline';
		}
	}

// Maakt log aan
function logOca (medewerkers, verzuimpercentage, besparing)
	{
	http = getXmlHttpObject();
	http.open("POST", "besparing.php",true);
	http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	http.onreadystatechange=function() {
		if (http.readyState==4) {
			document.getElementById('d').value = http.responseText;
			//alert (http.responseText);
			}
		}
	http.send('medewerkers='+medewerkers+'&verzuimpercentage='+verzuimpercentage+'&besparing='+besparing);
	}


function getXmlHttpObject()
	{
	var xmlhttp=false;
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	  } catch (E) {
	   xmlhttp = false;
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')
		{
		xmlhttp = new XMLHttpRequest();
		}
	return xmlhttp;
	}

// ]]>
