function jsonpost(func, value, value2, value3)
		{
			if (typeof(value3) == "undefined"){ var value3 = ''; }
			$.post('/include/call.php',
			   {
				   jsonpost: func,
				   value: value,
				   value2: value2,
				   value3: value3				   
  			   },
			   function(data, textStatus, XMLHttpRequest)
			   {	if (data['type'] == "jsreturn") {eval(data['message']);}
			   		if (data['type'] == "data") {
			   			writetierprice(data['message']);  		
			   		}
				   	if (data['type'] == "success") {location.reload();}
				   	if (data['type'] == "error") {
				   	document.getElementById("status").innerHTML = data['message'] ;
				   $("#status").addClass("error");
				   setTimeout(function() { $('#status').fadeOut(); }, 4000);
				   }
			   },'json');
		} 

function formpost(formname)
		{ 
		var data = $(formname).serialize();
		//alert(data); 
		$.post('/include/call.php', data,
			   function(data, textStatus, XMLHttpRequest)
			   {
			   	   if (data['type'] == "jsreturn") {eval(data['message']);}
				   if (data['type'] == "success") {
				   			//document.getElementById("status").innerHTML = data['message'] ;
				   			$(".status").addClass("success").show();
				   			$('.status').html(data['message']);
				   }
				   if (data['type'] == "error") {
				   	
				   $('.status').html(data['message']);
				   $('.status').show();
				   $(".status").addClass("error");
				   setTimeout(function() { $('.status').fadeOut(); }, 4000);
				   }
			   }, 'json');
} 

function writetierprice(data) {
var p = data;
var count=0; var price = 0;
var tierpricehtml='<ul>';
var before = '<div class="tierprice_col1"><span class="tierprice_l1">aantal</span><span><strong>Prijs (&euro;)</strong></span><span>Prijs/stuk</span></div>';
var qtyselector = '<span class="qtyselector">Aantal: <select name="select_qty" id="select_qty">';

for (var key in p) {
if (p.hasOwnProperty(key)) {
	//alert(key + " -> " + p[key]);
		qtyselector += '<option value="'+key+'">'+key+'</option>';
		count++; if (count == 1){tierpricehtml += '<li>'+before;}
		price = (key * p[key]).toFixed(2); p[key] = p[key] * 1;
		price = price.toString();p[key] = p[key].toString();
		price = price.replace(".", ",");p[key] = p[key].replace(".", ",");
		
		tierpricehtml += "<div><span class='tierprice_l1'>"+key+"<\/span><span>"+price+"<\/span><span>"+p[key]+"<\/span><\/div>";
		if (count ==6){tierpricehtml += '</li>'; count=0;}
}
}
if(count < 6){ 	var diff = 6 -count;
	for (var x = 1; x <= diff; x++) {tierpricehtml += "<div><span class='tierprice_l1'> <\/span><span> <\/span><span> <\/span><\/div>"; }	
}

qtyselector += '</select>';
tierpricehtml += '</ul></span>';

$(document).ready(function(){  
	$('.toevoegen').prepend(qtyselector);$('#tierpirce').html(tierpricehtml);
	if (tierpricehtml.length > 5){ $("#tierpirce").easySlider(); $("#nextBtn").show();$("#prevBtn").show();$("#tierpirce").show();  }
});
}
