// Begin JQuery rounded corner
$(document).ready(function(){
   $(".image").corner("br 30px");
   $(".imagesmall").corner("10px");
   $("#pdet_order").corner("10px");
   $("#pdet_seperate").corner("7px");

 });
// End JQuery rounded corner 


// Begin JQuery accordion
jQuery().ready(function(){
	// simple accordion
	jQuery('#list1a').accordion({
	header: 'a.accordtitle',
	active: true,
	alwaysOpen: false,  
	autoheight: false});
	jQuery('#list1b').accordion({autoHeight: false});
});


// End JQuery accordion


function verzend()
{
	if(document.frmOrder.txtVoorletters.value == "")
	{
		alert("U dient uw voorletters in te vullen");
		document.frmOrder.txtVoorletters.focus();
		return false;
	}
	if(document.frmOrder.txtNaam.value == "")
	{
		alert("U dient uw naam in te vullen");
		document.frmOrder.txtNaam.focus();
		return false;
	}
	if(document.frmOrder.txtAdres.value == "")
	{
		alert("U dient uw adres in te vullen");
		document.frmOrder.txtAdres.focus();
		return false;
	}
	if(document.frmOrder.txtPostcode.value == "")
	{
		alert("U dient uw postcode in te vullen");
		document.frmOrder.txtPostcode.focus();
		return false;
	}	
	if(document.frmOrder.txtPlaats.value == "")
	{
		alert("U dient uw plaatsnaam in te vullen");
		document.frmOrder.txtPlaats.focus();
		return false;
	}
	if(document.frmOrder.txtTelefoon.value == "")
	{
		alert("U dient uw telefoonnummer in te vullen");
		document.frmOrder.txtTelefoon.focus();
		return false;
	}
	if(document.frmOrder.txtEmail.value == "")
	{
		alert("U dient uw e-mailadres in te vullen");
		document.frmOrder.txtEmail.focus();
		return false;
	}
	document.frmOrder.btnSend.disabled = true;
	document.frmOrder.btnSend.value = "een moment geduld a.u.b";
	document.frmOrder.submit();
}


function sendForm()
{
	if(document.frmContact.inpNaam.value == "")
	{
		alert("U dient uw naam in te vullen");
		document.frmContact.inpNaam.focus();
		return false;
	}	
	if(document.frmContact.inpPlaats.value == "")
	{
		alert("U dient uw woonplaats in te vullen");
		document.frmContact.inpPlaats.focus();
		return false;
	}	
	if(document.frmContact.inpTelefoon.value == "")
	{
		alert("U dient uw telefoonnummer in te vullen");
		document.frmContact.inpTelefoon.focus();
		return false;
	}	
	if(document.frmContact.inpEmail.value == "")
	{
		alert("U dient uw e-mailadres in te vullen");
		document.frmContact.inpEmail.focus();
		return false;
	}

	if(document.frmContact.inpVraag.value == "")
	{
		alert("U dient een vraag of opmerking in te voeren");
		document.frmContact.inpVraag.focus();
		return false;
	}	
	
	document.frmContact.submit();
}


function popupform(myform, windowname)
{
if (! window.focus)return true;
window.open('', windowname, 'height=550,width=580,scrollbars=yes'); 
myform.target=windowname;
return true;
}

function convertToNumber(value)
{
	return Number(String(value).replace(",","."));
}
function showPrice(price)
{
	if(price != 0)
	{
		return String(roundNumber(price,2)).replace(".",",");
	}
	else
	{
		return "";	
	}
}
function roundNumber(number,decimals) 
{
	var newString;// The new rounded number
	decimals = Number(decimals);
	if (decimals < 1) {
		newString = (Math.round(number)).toString();
	} else {
		var numString = number.toString();
		if (numString.lastIndexOf(".") == -1) {// If there is no decimal point
			numString += ".";// give it one at the end
		}
		var cutoff = numString.lastIndexOf(".") + decimals;// The point at which to truncate the number
		var d1 = Number(numString.substring(cutoff,cutoff+1));// The value of the last decimal place that we'll end up with
		var d2 = Number(numString.substring(cutoff+1,cutoff+2));// The next decimal, after the last one we want
		if (d2 >= 5) {// Do we need to round up at all? If not, the string will just be truncated
			if (d1 == 9 && cutoff > 0) {// If the last digit is 9, find a new cutoff point
				while (cutoff > 0 && (d1 == 9 || isNaN(d1))) {
					if (d1 != ".") {
						cutoff -= 1;
						d1 = Number(numString.substring(cutoff,cutoff+1));
					} else {
						cutoff -= 1;
					}
				}
			}
			d1 += 1;
		} 
		newString = numString.substring(0,cutoff) + d1.toString();
	}
	if (newString.lastIndexOf(".") == -1) {// Do this again, to the new string
		newString += ".";
	}
	var decs = (newString.substring(newString.lastIndexOf(".")+1)).length;
	for(var i=0;i<decimals-decs;i++) newString += "0";
	//var newNumber = Number(newString);// make it a number if you like
	return newString; // Output the result to the form field (change for your purposes)
}
function calculateTotal()
{ 
	var prod_objects = document.getElementsByName("prod_total");
	var total = 0;
	for(i=0;i<prod_objects.length;i++) {
		var price = prod_objects[i].value;
		if(price != "" && price != 0)
		{
			total = total + convertToNumber(price);
		}
	}
	document.getElementById("totalPrice").innerHTML = showPrice(total);
	document.getElementById("totalPrice_hidden").value = showPrice(total);
	
	if(total > 0)
	{
		document.getElementById("verzenden").disabled = false;	
	}else
	{
		document.getElementById("verzenden").disabled = true;
	}
}
function submitOrder()
{
	msg = document.getElementById("spnError");
	if (document.getElementById("txtInstelling").value == "")
		msg.innerHTML = "Vul uw bedrijfsnaam in.";
	else if (document.getElementById("txtNaam").value == "")
		msg.innerHTML = "Vul uw naam in.";
	else if (document.getElementById("txtDeponummer").value == "")
		msg.innerHTML = "Vul uw depositair nummer in.";
	else if (document.getElementById("txtEmail").value == "")
		msg.innerHTML = "Vul uw emailadres in.";
	else document.getElementById("frmOrder").submit();
}