function tab(uit,aan,button_uit,button_aan)
{	
	var info   		= "vitamine_info"+uit; 
	var extra  		= "vitamine_extra"+uit; 
	var vraag  		= "vitamine_vraag"+uit; 
	var waarom 		= "vitamine_waarom"+uit; 
	
	var btn_info	= "btn_info"+button_uit; 
	var btn_extra	= "btn_extra"+button_uit;
	var btn_vraag	= "btn_vraag"+button_uit;
	var btn_waarom	= "btn_waarom"+button_uit;

	document.getElementById(info).style.display="none";
	document.getElementById(extra).style.display="none";
	document.getElementById(vraag).style.display="none";
	document.getElementById(waarom).style.display="none";
	
	document.getElementById(aan).style.display="block";
	
	document.getElementById(btn_info).style.fontWeight="";
	document.getElementById(btn_extra).style.fontWeight="";
	document.getElementById(btn_vraag).style.fontWeight="";
	document.getElementById(btn_waarom).style.fontWeight=""; 
	
	document.getElementById(button_aan).style.fontWeight="bold";
}


function winkelwagen(id,goed)
{
	var xmlhttp 	= makeXmlHttp();
	var product		= id;
	var goedmelding = goed;
	
	xmlhttp.open('POST','inc/winkelwagen_opslaan.php',true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send('product=' + product)
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{	
			document.getElementById(goedmelding).style.display = "block";
			refreshwinkelwagen();
			setTimeout("window.location.replace('index.php?page=bestellen')",1000);
		}
	}
}


function refreshwinkelwagen()
{
	var xmlhttp 	= makeXmlHttp();
	
	document.getElementById('winkelwagen_inhoud').innerHTML='Updaten winkelwagen';
	
	xmlhttp.open('GET','inc/winkelwagen_ophaal.php',true);
	xmlhttp.send('null')
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{
			document.getElementById('winkelwagen_inhoud').innerHTML=xmlhttp.responseText;
		}
	}
}


function number_format(a, b, c, d) {
 a = Math.round(a * Math.pow(10, b)) / Math.pow(10, b);
 e = a + '';
 f = e.split('.');
 if (!f[0]) {
  f[0] = '0';
 }
 if (!f[1]) {
  f[1] = '';
 }
 if (f[1].length < b) {
  g = f[1];
  for (i=f[1].length + 1; i <= b; i++) {
   g += '0';
  }
  f[1] = g;
 }
 if(d != '' && f[0].length > 3) {
  h = f[0];
  f[0] = '';
  for(j = 3; j < h.length; j+=3) {
   i = h.slice(h.length - j, h.length - j + 3);
   f[0] = d + i +  f[0] + '';
  }
  j = h.substr(0, (h.length % 3 == 0) ? 3 : (h.length % 3));
  f[0] = j + f[0];
 }
 c = (b <= 0) ? '' : c;
 return f[0] + c + f[1];
}


function checknumbers(evt)
{
	var charCode = (evt.which) ? evt.which : evt.keyCode;
	
	if ((charCode >= 48 && charCode <=57) || charCode == 8)
	{
		return true; 
	} 
	
	return false;
}


function berekenen(aantal,prijs,waar,productID,DIVverzend,aantalproducten)
{
	var aantal = document.getElementById(aantal).value;
	var prijs  = prijs;
	var totaal = aantal * prijs;
	var eindtotaal = 0;
	var bedrag	   = 0;

	var totaalverzend = aantal * 4.95;
	//document.getElementById(DIVverzend).value = number_format(totaalverzend, 2, '.', '');
	
	totaal = totaal + totaalverzend;
	
	document.getElementById(waar).value = number_format(totaal, 2, '.', '');
	
	for (i = 0; i < aantalproducten; i++ )
	{				
		subtotaal = document.getElementById('totaal'+i).value;
		subtotaal = parseFloat(subtotaal);	
		eindtotaal = eindtotaal + subtotaal;		
	}
	
	eindtotaal = number_format(eindtotaal, 2, ',', '.');
	document.getElementById('eindbedrag').innerHTML = 'Totaal bedrag: &euro; '+eindtotaal;

	var xmlhttp 	= makeXmlHttp();
	
	xmlhttp.open('POST','inc/winkelwagen_updateaantal.php',true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.send('productID='+ productID+'&aantal='+ aantal);
}


function verwijder_product(Pid)
{
		var productID = Pid;
		
		var agree=confirm("Weet u zeker dat u dit product wilt verwijderen?");
		if (agree) 
		{
			var xmlhttp   = makeXmlHttp();
			
			xmlhttp.open('POST','inc/winkelwagen_verwijder.php',true);
			xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
			xmlhttp.send('productID='+ productID);
			xmlhttp.onreadystatechange = function()
			{
				if (xmlhttp.readyState == 4)
				{
					reload_page()
				}
			}
		}
		else
		{
			return false;
		}
}


function reload_page()
{
	var sURL = unescape(window.location.pathname);
	window.location.reload(true);
}