function getid(element)
{
	result = document.getElementById(element);
	return result;
}

function checkfield(element)
{
	if (getid(element).value == "")
	return 1;
	else
	return 0;
}

function checkradio(element)
{
	if (getid(element).checked)
	return 1
	else
	return 0

}

function checkselect(element)
{
	if (getid(element).selectedIndex == 0)
	return 1
	else
	return 0
}

//mail filtering! gevonden op: http://www.quirksmode.org/js/mailcheck.html
function checkmail(element)
{
	var email = element.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	check = email.match(filter);
	if (check == null)
	{
		return 1
	}
	else
	{
		return 0
	}
}

function check1()
{
	result = "";
	result += checkfield("w_vestiging");
	if (result != 0) { getid("msg").innerHTML = "<p>Geef a.u.b aan bij welke vestiging u onderhoud wilt uitvoeren</p>";}
	return result;
}

function check2()
{
	result = "";
	result += checkfield("kenteken_deel_1");
	result += checkfield("kenteken_deel_2");
	result += checkfield("kenteken_deel_3");
	if (result != 0) { getid("msg2").innerHTML = "<p>Vul a.u.b. het volledige kenteken van uw auto in"; return result;}
	return result;
}

function check3_2()
{
	result = "";
	result += checkfield("w_datum");
	if (result != 0) { getid("msg3").innerHTML = "<p>Selecteer a.u.b. een datum voor de afspraak</p>";return result;}
/*	result += checkselect("dienstId");
	if (result != 0) { getid("msg3").innerHTML = "<p>Geef a.u.b aan welk onderhoud u wilt uitvoeren</p>";return result;}
*/	return result;
	
}
function check3(prices, old_price, old_option)
{
	getid("selectop").innerHTML = selectedopt();
	option = parseFloat(getid("w_vervoer").value);

	t = Math.round(option * 100 ) / 100 ;
	t = t.toFixed(2);
	getid("selectop2").innerHTML = getid("w_vervoer").options[getid("w_vervoer").selectedIndex].innerHTML;
	getid("price2").innerHTML = t;
	getid("w_vervangend_vervoer").value = getid("w_vervoer").options[getid("w_vervoer").selectedIndex].innerHTML;
	getid("price").innerHTML = prices[getid("dienstId").selectedIndex];
	getid("totaal_optieprijs").innerHTML = parseFloat(prices[getid("dienstId").selectedIndex]) + option;
	if (getid("totaalprijs").value == "0.00")
	{
		a = getid("totaalprijs").value = parseFloat(prices[getid("dienstId").selectedIndex]) + option;
		t = Math.round(a * 100 ) / 100 ;
		t = t.toFixed(2);
		getid("totaal_optieprijs").innerHTML = t;
	}
	else
	{
		t = Math.round( (parseFloat(prices[getid("dienstId").selectedIndex]) + parseFloat(getid("totaalprijs").value) + option - parseFloat(old_price) - old_option) * 100 ) / 100 ;
		t = t.toFixed(2);
		getid("totaal_optieprijs").innerHTML = t;

		getid("totaalprijs").value =  Math.round((parseFloat(prices[getid("dienstId").selectedIndex]) + parseFloat(getid("totaalprijs").value) + option - parseFloat(old_price) - old_option)* 100 ) / 100;
	}
	getid("w_vervoer2").value = option;
	result = "";
	result += checkselect("dienstId");
	if (result != 0) { getid("msg2").innerHTML = "<p>Geef a.u.b aan welk onderhoud u wilt uitvoeren</p>";}
	return result;
}


function check4()
{
	result = 0;
	result = checkfield("w_naam");
	if (result != 0) { getid("msg5").innerHTML = "<p>Vul a.u.b. uw naam in"; return result;}
	result = checkfield("w_tel");
	if (result != 0) { getid("msg5").innerHTML = "<p>Vul a.u.b. uw telefoonnummer in</p>";return result;}
	if (getid("w_email").value == "")
	{
		result = 0;
	}
	else
	{
		result = checkmail( getid("w_email") );
		if (result != 0) { getid("msg4").innerHTML = "<p>Vul a.u.b. een correct emailadres in"; return result;}
		else { result = 0; 	}

	}
	return result;

}

function check6()
{

}

function selectedopt()
{
	result =  getid("dienstId").options[getid("dienstId").selectedIndex].innerHTML +" op "+ getid("w_datum2").value + " *";
	return  result;
}

