$j(window).ready(function() {
	
	$j('#btn_forgott_wachtwoord').click(function() {
		
		//$j(this).css('display', 'none');
		
		$j('#div_forgott_wachtwoord').show("blind", { direction: "vertical" }, 500);
	});
	
	$j('#login_index a').click(function() {
		
		//$j('#login_index_content').show("blind", { direction: "vertical" }, 500);
		$j('#login_index_content').show("blind", { direction: "vertical" }, 500);
		$j('#login_index_table').removeClass('hide');
	});
	
	$j('#login_index_close').click(function() {
		
		$j('#login_index_content').hide("blind", { direction: "vertical" }, 500);
		$j('#login_index_table').addClass('hide');
	});	
	
	if(browser == "Microsoft Internet Explorer"){
			
		var scrolling = 'html';
	}else{
			
		var scrolling = 'html';
	}

});

$j.fn.pause = function(duration) {
    $j(this).animate({ dummy: 1 }, duration);
    return this;
};

function setWinkelwagenLoadingHeigth() {
	
	var winkelwagen_popup_height				= $j('#winkelwagen_popup_items').height();
	var winkelwagen_overzicht_top_height		= $j('.winkelwagen_overzicht_top').height();
	var winkelwagen_overzicht_bottom_height		= $j('#winkelwagen_overzicht_bottom').height() - 20;
	
	//$j('#winkelwagen_overzicht_loading-bg').css('height', Number(winkelwagen_overzicht_top_height) + Number(winkelwagen_overzicht_bottom_height));
	//$j('#winkelwagen_cart_loading-bg').css('height', winkelwagen_popup_height);
}

function displayCartAmount(aantal_producten, subtotaal){
	
	$j('#aantal_producten_html').html(aantal_producten);
	$j('#subtotaal_cart_html').html(subtotaal);
}

function viewCart(show_effect, id_shop_type){
	
	if(id_shop_type == '' || id_shop_type == undefined){
		
		id_shop_type	= 1;
	}

	if(window.shop_type == undefined){
		
		shop_type	= '';
	}

	if(window.lang_id == undefined){
		
		lang_id	= 1;
	}

	$j('#winkelwagen_content_loading').empty();
	//$j('#winkelwagen_cart_loading').css('display', 'block');
	$j('.mainleft_cart_blok_contentblok_content').css('display', 'none');
	$j('#winkelwagen_loading').css('display', 'block');
	
	$j.get(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'viewCart', id_shop_type: id_shop_type, shop_type: shop_type, lang: vars_lang, lang_id: lang_id},function(data){
		
		$j('#winkelwagen_content').html(data);
		$j('#winkelwagen_loading').css('display', 'none');
		$j('.mainleft_cart_blok_contentblok_content').css('display', 'block');
		
		if(show_effect == true){
			
			$j('#winkelwagen_highlight').effect("highlight", {color: '#fff799'}, 3000);
		}
		
		setWinkelwagenLoadingHeigth();
		
		//$j('#winkelwagen_cart_loading').css('display', 'none');
		$j('#winkelwagen_overzicht_loading').css('display', 'none');
		
	});
}

function addCartDirectBestellen(id_product, attribuut, t_direct_bestellen, id_cat){

	var id_attribuut		= 0;
	if(attribuut == 'true'){
		
		id_attribuut	= $j('#select_bestel_direct_'+id_product+'-'+t_direct_bestellen).val();

		if(id_attribuut == ''){
			
			alert('Dit product is niet leverbaar met deze combinatie.\nMaak een andere keuze.');
			return;
		}
	
		if(id_attribuut	 == 0){
			
			alert('Het is niet mogelijk om dit product te bestellen omdat het product niet voorradig is.');
			return;
		}
	}else{

		id_attribuut	= $j('#select_bestel_direct_'+id_product+'-'+t_direct_bestellen).val();
		
		if(id_attribuut != undefined){
					
			if(id_attribuut == ''){
				
				alert('Dit product is niet leverbaar met deze combinatie.\nMaak een andere keuze.');
				return;
			}
		
			if(id_attribuut	 == 0){
				
				alert('Het is niet mogelijk om dit product te bestellen omdat het product niet voorradig is.');
				return;
			}
			
			id_attribuut = 0;
		}	
	}
	
	var aantal	= $j('#select_bestel_direct_aantal_'+id_product+'-'+t_direct_bestellen).val();

	var invoerveld_text		= '';
	var type				= $j('#product_type').val();
	
	if(type == undefined){
		
		var type			= 0;
	}
	
	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'addCart',
															  id_cat: id_cat,
															  id_product: id_product,
															  id_attribuut: id_attribuut,
															  aantal: aantal,
															  type: type,
															  invoerveld_text: invoerveld_text},function(data){
			
			var trimResponse = trim(data);

			viewCart(true, id_shop_type);

			$j('html,body').animate({scrollTop:0},'slow', function(){
				
			});

			if(trimResponse != ''){

				var myStringVar = "max_eenheid";
				var myMatch = trimResponse.search(myStringVar);
				if(myMatch != -1){

					$j('#winkelwagen_box').show("blind", { direction: "vertical" }, 750, function() {
									
						$j('#item-'+id_product+'-'+id_attribuut+'').effect("highlight", {color: '#fff799'}, 3000);
		
					});
						
					$j('#div_product_'+id_product+'-'+t_direct_bestellen).delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
								
					});	
					$j('#product_'+id_product+'-0').delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
								
					});	

					trimResponse_tmp = trimResponse.split(myStringVar);
					alert('Het maximaal aantal stuks te bestellen is: '+trimResponse_tmp[1]);
				}

				if(IsNumeric(trimResponse)){
						
					if(trimResponse == 1){
							
						alert('Er is helaas nog maar '+trimResponse+' stuk op voorraad!');
					}else{
							
						alert('Er zijn helaas nog maar '+trimResponse+' stuks op voorraad!');
					}
				}
			}else{

				$j('#winkelwagen_box').show("blind", { direction: "vertical" }, 750, function() {
								
					$j('#item-'+id_product+'-'+id_attribuut+'').effect("highlight", {color: '#fff799'}, 3000);
	
				});
					
				$j('#div_product_'+id_product+'-'+t_direct_bestellen).delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
							
				});	
				$j('#product_'+id_product+'-0').delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
							
				});	
			}
		});

//	$j("#winkelwagen_box").pause(4000).hide("blind", { direction: "vertical"}, 750, function() {
//																								 
//	});
}

function addCart(id_cat, id_product, id_attribuut, type, direct_bestellen, check, tbremove){ //
	//alert(id_product+'='+id_attribuut+'='+type+'='+check+'=');

	if(type == 0){

		var type				= $j('#product_type').val();
		
		if(type == undefined){
			
			var type			= 0;
		}
	}
	
	if(direct_bestellen == 'FALSE'){
		
		alert("U kunt dit product niet direct bestellen!\n\nOm het product te kunnen bestellen klikt u op \"Bestellen\" of \"Meer informatie\".");
		
		return;
	}
	
	var id_attribuut_effect			= id_attribuut;
	
	// if cehck true checken of er besteld kan worden product detail
	if(check == 'TRUE'){
		
		var bestellen_mogelijk		= $j('#bestellen_mogelijk').val();
		var id_attribuut			= $j('#id_attribuut').val();
		var aantal					= $j('#aantal').val();
		
		if(id_attribuut != 0){
			
			id_attribuut_effect		= 0;
		}
		if(bestellen_mogelijk == 1){
			
			
		}
		if(bestellen_mogelijk == 0){
			
			alert("Dit product is niet leverbaar met deze combinatie.\nMaak een andere keuze.");
			return;
		}
		
		var bestellen_mogelijk_voorraad	= $j('#bestellen_mogelijk_voorraad').val();

		if(bestellen_mogelijk_voorraad == 0){
			
			alert('Het is niet mogelijk om dit product te bestellen omdat het product niet voorradig is.');
			return;
		}
		
	}
	if(check == 'FALSE'){
		
		var aantal		= 1;
	}
	
	if(aantal == '' || aantal == 0){
		
		alert('Er is geen aantal ingevuld!');
		return;
	}
	
	//$j('#winkelwagen_loading').css('display', 'block');
	$j('#winkelwagen_content_loading').empty();
	
	if(id_attribuut == undefined){
		
		id_attribuut = 0;
	}
	
	check_invoerveld 	= 0;
	invoerveld_text		= '';

	if(window.attribuut_invoervelden == undefined){
		
		attribuut_invoervelden = 0;
	}

	if(attribuut_invoervelden == 1){
		
		for(x in attribuutInvoervelden){
			
			if(attribuutInvoervelden[x][verplicht_veld] == 1){
				
				a = $j("input[name='invoerveld["+x+"]']").val();
				if(a == ''){
					
					attribuutnaam	= attribuutInvoervelden[x][attribuut_naam];
					alert(attribuutnaam+' is niet ingevuld! Dit veld is verplicht.');
					check_invoerveld++;
					return;
				}
			}
		}
	
		for(x in attribuutInvoervelden){
			
			invoerveld_text += ''+attribuutInvoervelden[x][attribuut_naam]+': '+$j("input[name='invoerveld["+x+"]']").val()+' ';
		}
		
		var extra_velden_type	= $j('#extra_velden_type').val();
		
		if(extra_velden_type == 0){
			
			invoerveld_text = '';
		}
		if(extra_velden_type == 2){
			
			for(x in attribuutInvoervelden){
								
				a = $j("input[name='invoerveld["+x+"]']").val();
				if(a == ''){

					attribuutnaam	= attribuutInvoervelden[x][attribuut_naam];
					alert(attribuutnaam+' is niet ingevuld! Dit veld is verplicht.');
					check_invoerveld++;
					return;
				}
			}	
		}
	}
	
	if(check_invoerveld == 0){

		$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'addCart',
																  id_cat: id_cat,
																  id_product: id_product,
																  id_attribuut: id_attribuut,
																  aantal: aantal,
																  type: type,
																  invoerveld_text: invoerveld_text},function(data){


			var trimResponse = trim(data);

			viewCart(true, id_shop_type);
			
			var redirect_cart = $j('#redirect_cart_'+id_product+'-'+id_attribuut+'').val();
			if(redirect_cart == 1){
				
				window.location = root_site+"winkelwagen.html";
			}
			
			$j('html,body').animate({scrollTop:0},'slow', function(){
				
			});

			if(trimResponse != ''){

				var myStringVar = "max_eenheid";
				var myMatch = trimResponse.search(myStringVar);
				if(myMatch != -1){

					if(tbremove == 'true'){
										
						tb_remove();
					}
	
					$j('#winkelwagen_box').slideDown(750, function() {
									
						$j('#item-'+id_product+'-'+id_attribuut+'').effect("highlight", {color: '#fff799'}, 3000, function() {
	
							hideCart();
						});
					});

					$j('#product_'+id_product+'-'+id_attribuut_effect+'').delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
									
					});

					trimResponse_tmp = trimResponse.split(myStringVar);
					alert('Het maximaal aantal stuks te bestellen is: '+trimResponse_tmp[1]);
				}
				
				if(IsNumeric(trimResponse)){
						
					if(trimResponse == 1){
						
						alert('Er is helaas nog maar '+trimResponse+' stuk op voorraad!');
					}else{
							
						alert('Er zijn helaas nog maar '+trimResponse+' stuks op voorraad!');
					}
				}
			}else{

				if(tbremove == 'true'){
									
					tb_remove();
				}

				$j('#winkelwagen_box').slideDown(750, function() {
								
					$j('#item-'+id_product+'-'+id_attribuut+'').effect("highlight", {color: '#fff799'}, 3000, function() {

						hideCart();
					});
				});
					
				$j('#product_'+id_product+'-'+id_attribuut_effect+'').delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
								
				});
			}
		
		});

//		$j("#winkelwagen_box").pause(4000).hide("blind", { direction: "vertical"}, 750, function() {
//																								 
//		});
	}
}

function addCartAttribuutProduct(id_product, attribuut, id_cat, aantal_inputfield, tbremove){
	//alert(id_product+'='+id_attribuut+'='+type+'='+check+'=');

	var id_attribuut		= 0;
		
	var id_attribuut		= attribuut;

	if(id_attribuut == ''){
			
		alert('Dit product is niet leverbaar met deze combinatie.\nMaak een andere keuze.');
		return;
	}
	
	if(id_attribuut	 == 0){
			
		alert('Het is niet mogelijk om dit product te bestellen omdat het product niet voorradig is.');
		return;
	}
	
	var aantal	= $j('#'+aantal_inputfield+'').val();

	var invoerveld_text		= '';
	var type				= $j('#product_type').val();
	
	if(type == undefined){
		
		var type			= 0;
	}
	
	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'addCart',
															  id_cat: id_cat,
															  id_product: id_product,
															  id_attribuut: id_attribuut,
															  aantal: aantal,
															  type: type},function(data){
		
			var trimResponse = trim(data);

			viewCart(true, id_shop_type);

			$j('html,body').animate({scrollTop:0},'slow', function(){
				
			});

			if(trimResponse != ''){

				var myStringVar = "max_eenheid";
				var myMatch = trimResponse.search(myStringVar);
				if(myMatch != -1){

					if(tbremove == 'true'){
										
						tb_remove();
					}
	
					$j('#winkelwagen_box').slideToggle(750, function() {
									
						$j('#item-'+id_product+'-'+id_attribuut+'').effect("highlight", {color: '#fff799'}, 3000, function() {
	
							hideCart();
						});
					});

					$j('#product_'+id_product+'-0').delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
									
					});

					trimResponse_tmp = trimResponse.split(myStringVar);
					alert('Het maximaal aantal stuks te bestellen is: '+trimResponse_tmp[1]);
				}

				if(IsNumeric(trimResponse)){
						
					if(trimResponse == 1){
							
						alert('Er is helaas nog maar '+trimResponse+' stuk op voorraad!');
					}else{
							
						alert('Er zijn helaas nog maar '+trimResponse+' stuks op voorraad!');
					}
				}
			}else{

				if(tbremove == 'true'){
									
					tb_remove();
				}

				$j('#winkelwagen_box').slideToggle(750, function() {
								
					$j('#item-'+id_product+'-'+id_attribuut+'').effect("highlight", {color: '#fff799'}, 3000, function() {

						hideCart();
					});
				});
					
				$j('#product_'+id_product+'-0').delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
								
				});
			}
			
	});

//	$j("#winkelwagen_box").pause(4000).hide("blind", { direction: "vertical"}, 750, function() {
//																								 
//	});

//	var id_attribuut_effect			= id_attribuut;
//	
//	// if cehck true checken of er besteld kan worden product detail
//	if(check == 'TRUE'){
//		
//		var id_attribuut			=id_attribuut;
//		var aantal					= $j('#'+aantal_inputfield+'').val();
//		
//		if(id_attribuut != 0){
//			
//			id_attribuut_effect		= 0;
//		}
//	}
//	if(check == 'FALSE'){
//		
//		var aantal		= 1;
//	}
//	
//	//$j('#winkelwagen_loading').css('display', 'block');
//	$j('#winkelwagen_content_loading').empty();
//	
//	if(id_attribuut == undefined){
//		
//		id_attribuut = 0;
//	}
//
//	if(aantal == undefined){
//		
//		aantal = 1;
//	}
//
//	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'addCart',
//															  id_cat: id_cat,
//															  id_product: id_product,
//															  id_attribuut: id_attribuut,
//															  aantal: aantal,
//															  type: type},function(data){
//		
//		viewCart(true, id_shop_type);
//	});
//	
//	$j('html,body').animate({scrollTop:0},'slow', function(){
//
//	});
//
//	$j('#winkelwagen_box').show("blind", { direction: "vertical" }, 750, function() {
//			
//		$j('#item-'+id_product+'-'+id_attribuut+'').effect("highlight", {color: '#fff799'}, 3000);
//	});
//
//	$j('#product_'+id_product+'-'+id_attribuut_effect+'').effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
//			
//	});
}

function addCartAttribuutOptionsProduct(id_cat, id_product, tbremove) {
		
	var check_verplicht				= 0;
	var check_verplicht_radio		= 0;
	var check_verplicht_checkbox	= 0;

	if(window.productProductAttribuutVerplichtList != undefined){
		
		for(i in productProductAttribuutVerplichtList){
			
			var id_attribuut_options_groep	= productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_id_attribuut_options_groep];
			
			if(productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_verplicht] == 1){
				
				if(productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_type] == 0){
					
					if($j('#dl_attribuut_options_groep_'+id_attribuut_options_groep+' select').val() == 0){
						
						$j('#dl_attribuut_options_groep_'+id_attribuut_options_groep+' select').addClass('inputfield_error');
						$j('#error_attribuut_options_groep_'+id_attribuut_options_groep+'').removeClass('hide');
						
						check_verplicht++;
					}else{
						
						$j('#dl_attribuut_options_groep_'+id_attribuut_options_groep+' select').removeClass('inputfield_error');
						$j('#error_attribuut_options_groep_'+id_attribuut_options_groep+'').addClass('hide');
					}
				}
				if(productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_type] == 1){
	
					$j('#dl_attribuut_options_groep_'+id_attribuut_options_groep+' input[type="radio"]').each(function() {
						
						if($j(this).attr('checked')){
							
							check_verplicht_radio++;
						}else{
							
						}	
					});

					if(check_verplicht_radio == 0){
							
						$j('#dl_attribuut_options_groep_'+id_attribuut_options_groep+' select').addClass('inputfield_error');
						$j('#error_attribuut_options_groep_'+id_attribuut_options_groep+'').removeClass('hide');
							
						check_verplicht++;
					}else{
							
						$j('#dl_attribuut_options_groep_'+id_attribuut_options_groep+' select').removeClass('inputfield_error');
						$j('#error_attribuut_options_groep_'+id_attribuut_options_groep+'').addClass('hide');
					}
				}
				if(productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_type] == 2){
					
					$j('#dl_attribuut_options_groep_'+id_attribuut_options_groep+' input[type="checkbox"]').each(function() {
						
						if($j(this).attr('checked')){
							
							check_verplicht_checkbox++;
						}else{
							
						}	
					});

					if(check_verplicht_checkbox == 0){
							
						$j('#dl_attribuut_options_groep_'+id_attribuut_options_groep+' select').addClass('inputfield_error');
						$j('#error_attribuut_options_groep_'+id_attribuut_options_groep+'').removeClass('hide');
							
						check_verplicht++;
					}else{
							
						$j('#dl_attribuut_options_groep_'+id_attribuut_options_groep+' select').removeClass('inputfield_error');
						$j('#error_attribuut_options_groep_'+id_attribuut_options_groep+'').addClass('hide');
					}
				}
				
				if(productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_type] == 3){
					
					for(t in productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_attributen]){
						
						var attributen_verplicht_array_tmp	= productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_attributen][t].split(',');
						
						for(a in attributen_verplicht_array_tmp){
	
							if($j('#dl_attribuut_options_'+attributen_verplicht_array_tmp[a]+' input').val() == ''){
								
								$j('#dl_attribuut_options_'+attributen_verplicht_array_tmp[a]+' input').addClass('inputfield_error');
								$j('#error_attribuut_options_'+attributen_verplicht_array_tmp[a]+'').removeClass('hide');
								
								check_verplicht++;
							}else{
								
								$j('#dl_attribuut_options_'+attributen_verplicht_array_tmp[a]+' input').removeClass('inputfield_error');
								$j('#error_attribuut_options_'+attributen_verplicht_array_tmp[a]+'').addClass('hide');
							}
						}
					}
				}
				if(productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_type] == 4){
	
					for(t in productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_attributen]){
						
						var attributen_verplicht_array_tmp	= productProductAttribuutVerplichtList[i][product_attribuut_verplicht_list_attributen][t].split(',');
						
						for(a in attributen_verplicht_array_tmp){
	
							if($j('#dl_attribuut_options_'+attributen_verplicht_array_tmp[a]+' textarea').val() == ''){
								
								$j('#dl_attribuut_options_'+attributen_verplicht_array_tmp[a]+' textarea').addClass('inputfield_error');
								$j('#error_attribuut_options_'+attributen_verplicht_array_tmp[a]+'').removeClass('hide');
								
								check_verplicht++;
							}else{
								
								$j('#dl_attribuut_options_'+attributen_verplicht_array_tmp[a]+' textarea').removeClass('inputfield_error');
								$j('#error_attribuut_options_'+attributen_verplicht_array_tmp[a]+'').addClass('hide');
							}
						}
					}
				}
			}
		}
	}

	if(check_verplicht != 0){

		$j('html,body').animate({scrollTop:0},'slow', function(){
			
		});
		alert('Niet alles is goed gekozen!');
		return false;
	}

	var bestellen_mogelijk		= $j('#bestellen_mogelijk').val();
	var aantal					= $j('#aantal').val();
		
	if(bestellen_mogelijk == 0){
			
		alert("Dit product is niet leverbaar met deze combinatie.\nMaak een andere keuze.");
		return;
	}
		
	var bestellen_mogelijk_voorraad	= $j('#bestellen_mogelijk_voorraad').val();

	if(bestellen_mogelijk_voorraad == 0){
			
		alert('Het is niet mogelijk om dit product te bestellen omdat het product niet voorradig is.');
		return;
	}

	if(aantal == '' || aantal == 0){
		
		alert('Er is geen aantal ingevuld!');
		return;
	}

	var type				= $j('#product_type').val();
	
	if(type == undefined){
		
		var type			= 0;
	}

	$j('.product_detail_right_box_attributen select').each(function() {

	});	
	
	var attribuut_options	= $j('.product_detail_right_box_attributen select, .product_detail_right_box_attributen input, .product_detail_right_box_attributen textarea').serialize();
	
	var html_extra_value 	= [];
	
	var valuta_replace		= 'VALUTA_EURO';
	var valuta_replace_min	= 'VALUTA_EURO_MIN';
	
	var checkbox_t			= 0;
	
	$j('.class_product_attributen').each(function() {
		
		var type_product_attribuut	= $j(this).attr('type');
		if(typeof(type_product_attribuut) == 'undefined'){
				
			type_product_attribuut	= $j(this).prop('type');
		}
		
		switch(type_product_attribuut){
			
		case 'select-one':
			
			if($j(this).val() != 0){
				
				var id_attribuut_options 	= $j(this).val();
				//var a = '<strong>'+productProductAttribuutList[id_attribuut_options][attribuut_groep_naam]+':</strong>';
				var a = '<label><strong><i>'+productProductAttribuutList[id_attribuut_options][attribuut_groep_naam]+':</i></strong></label>';
				var b = '<br />SPATIE_REPLACE|'+productProductAttribuutList[id_attribuut_options][attribuut_naam];
				if(productProductAttribuutList[id_attribuut_options][prijs_verhoging] != '0.00'){
					
					var c = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verhoging]).formatMoney(2, ',', '.')+')</small></i>';
				}else if(productProductAttribuutList[id_attribuut_options][prijs_verlaging] != '0.00'){
						
					var c = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verlaging]).formatMoney(2, ',', '.')+')</small></i><br />';
				}else{
					
					var c = ' ';
				}
				var d = '<br />';
				
				var extra_value		= a+b+c+d;
				
				html_extra_value.push(extra_value);
			}
			
			break;
		
		case 'radio':

			if($j(this).val() != ''){
				
				if($j(this).attr('checked')){
					
					var id_tmp 				= $j(this).attr('id');
					id_attribuut_options	= id_tmp.replace("select_","");
	
					var a = '<label><strong><i>'+productProductAttribuutList[id_attribuut_options][attribuut_groep_naam]+':</i></strong></label>';
					var b = '<br />SPATIE_REPLACE|'+productProductAttribuutList[id_attribuut_options][attribuut_naam];
					if(productProductAttribuutList[id_attribuut_options][prijs_verhoging] != '0.00'){
					
						var c = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verhoging]).formatMoney(2, ',', '.')+')</small></i>';
					}else if(productProductAttribuutList[id_attribuut_options][prijs_verlaging] != '0.00'){
						
						var c = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verlaging]).formatMoney(2, ',', '.')+')</small></i><br />';
					}else{
					
						var c = ' ';
					}
					var d = '<br />';
					
					var extra_value		= a+b+c+d;
					
					html_extra_value.push(extra_value);
				}
			}

		break;

		case 'checkbox':

			if($j(this).val() != ''){
								
				if($j(this).attr('checked')){
					
					checkbox_t++;
					var id_tmp 				= $j(this).attr('id');
					id_attribuut_options	= id_tmp.replace("select_","");
					
					if(checkbox_t == 1){
						
					var a = '<label><strong><i>'+productProductAttribuutList[id_attribuut_options][attribuut_groep_naam]+':</i></strong></label><br />';
					}else{
					
					var a = '';
					}
					var b = 'SPATIE_REPLACE|'+productProductAttribuutList[id_attribuut_options][attribuut_naam];
					if(productProductAttribuutList[id_attribuut_options][prijs_verhoging] != '0.00'){
					
						var c = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verhoging]).formatMoney(2, ',', '.')+')</small></i>';
					}else if(productProductAttribuutList[id_attribuut_options][prijs_verlaging] != '0.00'){
						
						var c = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verlaging]).formatMoney(2, ',', '.')+')</small></i><br />';
					}else{
					
						var c = ' ';
					}
					var d = '<br />';
					
					var extra_value		= a+b+c+d;
					
					html_extra_value.push(extra_value);
				}
			}

		break;

		case 'text':

			if($j(this).val() != ''){
				
				if($j(this).val() != ''){
					
					var id_tmp 				= $j(this).attr('id');
					id_attribuut_options	= id_tmp.replace("select_","");
	
					//var a = '<label><strong><i>'+productProductAttribuutList[id_attribuut_options][attribuut_groep_naam]+' - ';
					var a = '<label><strong><i>';
					var b = ''+productProductAttribuutList[id_attribuut_options][attribuut_naam]+':</i></strong></label>';
					var c = '<br />SPATIE_REPLACE|'+$j(this).val()+'';

					if(productProductAttribuutList[id_attribuut_options][prijs_verhoging] != '0.00'){
					
						var d = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verhoging]).formatMoney(2, ',', '.')+')</small></i><br />';
					}else if(productProductAttribuutList[id_attribuut_options][prijs_verlaging] != '0.00'){
						
						var d = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verlaging]).formatMoney(2, ',', '.')+')</small></i><br />';
					}else{
						
						var d = '<br />';
					}
					
					var extra_value		= a+b+c+d;
					
					html_extra_value.push(extra_value);
				}
			}

		break;

		case 'textarea':

			if($j(this).val() != ''){
				
				if($j(this).val() != ''){
					
					var id_tmp 				= $j(this).attr('id');
					id_attribuut_options	= id_tmp.replace("select_","");
	
					var a = '<label><strong><i>';
					var b = ''+productProductAttribuutList[id_attribuut_options][attribuut_naam]+':</i></strong></label>';
					var c = '<br />SPATIE_REPLACE|'+$j(this).val()+'';

					if(productProductAttribuutList[id_attribuut_options][prijs_verhoging] != '0.00'){
					
						var d = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verhoging]).formatMoney(2, ',', '.')+')</small></i><br />';
					}else if(productProductAttribuutList[id_attribuut_options][prijs_verlaging] != '0.00'){
						
						var d = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList[id_attribuut_options][prijs_verlaging]).formatMoney(2, ',', '.')+')</small></i><br />';
					}else{
						
						var d = '<br />';
					}

					var extra_value		= a+b+c+d;
					
					html_extra_value.push(extra_value);
				}
			}

		break;

		default:
		  
		}
	});	
			
	//html_extra_value	= html_extra_value.replace(",","");
	
	$j.ajax({
						
		url: ""+root_site+"docs/ajaxrequest/cart_request.php",
		type: "POST",
		data: attribuut_options+'&action=addCartAttribuutOptionsProduct&id_cat='+id_cat+'&id_product='+id_product+'&aantal='+aantal+'&type='+type+'&extra_value='+html_extra_value+'',
		success: function(data){

			var trimResponse = trim(data);

			viewCart(true, id_shop_type);

			$j('html,body').animate({scrollTop:0},'slow', function(){
				
			});

			if(trimResponse != ''){

				var myStringVar = "max_eenheid";
				var myMatch = trimResponse.search(myStringVar);
				if(myMatch != -1){

					if(tbremove == 'true'){
										
						tb_remove();
					}
	
					$j('#winkelwagen_box').slideToggle(750, function() {
								
					});
						
					$j('#product_'+id_product+'-0').effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
									
					});

					trimResponse_tmp = trimResponse.split(myStringVar);
					alert('Het maximaal aantal stuks te bestellen is: '+trimResponse_tmp[1]);
				}

				if(IsNumeric(trimResponse)){
						
					if(trimResponse == 1){
							
						alert('Er is helaas nog maar '+trimResponse+' stuk op voorraad!');
					}else{
							
						alert('Er zijn helaas nog maar '+trimResponse+' stuks op voorraad!');
					}
				}
			}else{

				if(tbremove == 'true'){
									
					tb_remove();
				}

				$j('#winkelwagen_box').slideDown(750, function() {
								
					$j('.winkelwagen-items').last().effect("highlight", {color: '#fff799'}, 3000, function() {

						hideCart();
					});
				});
					
				$j('#product_'+id_product+'-0').effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
								
				});
			}
		}
	});				

//	$j("#winkelwagen_box").pause(4000).hide("blind", { direction: "vertical"}, 750, function() {
//																								 
//	});
}

function addCartAttribuutGroepenProduct(id_cat, id_product, id_attribuut_groep) {
	
	var tbremove	= false;
	
	var aantal 		= $j('#aantal_'+id_product+'-'+id_attribuut_groep).val();
	
	if(aantal == 0){
		
		alert('Kies een aantal!');
		return;
	}

	var bestellen_mogelijk		= $j('#bestellen_mogelijk').val();
		
	if(bestellen_mogelijk == 0){
			
		alert("Dit product is niet leverbaar met deze combinatie.\nMaak een andere keuze.");
		return;
	}
		
	var bestellen_mogelijk_voorraad	= $j('#bestellen_mogelijk_voorraad').val();

	if(bestellen_mogelijk_voorraad == 0){
			
		alert('Het is niet mogelijk om dit product te bestellen omdat het product niet voorradig is.');
		return;
	}

	var type				= $j('#product_type').val();
	
	if(type == undefined){
		
		var type			= 0;
	}
	
	var attribuut_options	= $j('#td_attributen_'+id_attribuut_groep+' select, .product_detail_right_box_attributen input, .product_detail_right_box_attributen textarea').serialize();
	
	var html_extra_value 	= [];
	
	var valuta_replace		= 'VALUTA_EURO';
	var valuta_replace_min	= 'VALUTA_EURO_MIN';
	
	var checkbox_t			= 0;
	
	$j('.class_product_attributen_'+id_attribuut_groep+'').each(function() {
		
		var type_product_attribuut	= $j(this).attr('type');
		if(typeof(type_product_attribuut) == 'undefined'){
				
			type_product_attribuut	= $j(this).prop('type');
		}

		switch(type_product_attribuut){
			
		case 'select-one':
			
			if($j(this).val() != 0){
				
				var id_attribuut_options 	= $j(this).val();
				//var a = '<strong>'+productProductAttribuutList[id_attribuut_options][attribuut_groep_naam]+':</strong>';
				
				var teller_id	= $j(this).attr('id');
				if(typeof(teller_id) == 'undefined'){
						
					teller_id	= $j(this).prop('type');
				}
				
				var a = '';
				
				if(teller_id == 'select_1' && productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_groep_naam_300] != ''){
				
					var a = '<label><strong><i>'+productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_groep_naam_300]+'</i></strong></label><br />';
				}
				var b = 'SPATIE_REPLACE|'+productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_naam_300];
				if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300] != '0.00'){
					
					var c = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300]).formatMoney(2, ',', '.')+')</small></i>';
				}else if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verlaging_300] != '0.00'){
						
					var c = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verlaging_300]).formatMoney(2, ',', '.')+')</small></i><br />';
				}else{
					
					var c = ' ';
				}
				var d = '<br />';
				
				var extra_value		= a+b+c+d;
				
				html_extra_value.push(extra_value);
			}
			
			break;
		
		case 'radio':

			if($j(this).val() != ''){
				
				if($j(this).attr('checked')){
					
					var id_tmp 				= $j(this).attr('id');
					id_attribuut_options	= id_tmp.replace("select_","");

					var a = '';
					
					if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_groep_naam_300] != ''){

						var a = '<label><strong><i>'+productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_groep_naam_300]+'</i></strong></label><br />';
					}
					var b = 'SPATIE_REPLACE|'+productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_naam_300];
					if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300] != '0.00'){
					
						var c = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300]).formatMoney(2, ',', '.')+')</small></i>';
					}else if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verlaging_300] != '0.00'){
						
						var c = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verlaging_300]).formatMoney(2, ',', '.')+')</small></i><br />';
					}else{
					
						var c = ' ';
					}
					var d = '<br />';
					
					var extra_value		= a+b+c+d;
					
					html_extra_value.push(extra_value);
				}
			}

		break;

		case 'checkbox':

			if($j(this).val() != ''){
								
				if($j(this).attr('checked')){
					
					checkbox_t++;
					var id_tmp 				= $j(this).attr('id');
					id_attribuut_options	= id_tmp.replace("select_","");
					
					if(checkbox_t == 1 && productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_groep_naam_300] != ''){
						
					var a = '<label><strong><i>'+productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_groep_naam_300]+'</i></strong></label><br />';
					}else{
					
					var a = '';
					}
					var b = 'SPATIE_REPLACE|'+productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_naam_300];
					if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300] != '0.00'){
					
						var c = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300]).formatMoney(2, ',', '.')+')</small></i>';
					}else if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_groep][id_attribuut_options][prijs_verlaging_300] != '0.00'){
						
						var c = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verlaging_300]).formatMoney(2, ',', '.')+')</small></i><br />';
					}else{
					
						var c = ' ';
					}
					var d = '<br />';
					
					var extra_value		= a+b+c+d;
					
					html_extra_value.push(extra_value);
				}
			}

		break;

		case 'text':

			if($j(this).val() != ''){
									
				var id_tmp 				= $j(this).attr('id');
				id_attribuut_options	= id_tmp.replace("select_","");
	
				//var a = '<label><strong><i>'+productProductAttribuutList_300[id_attribuut_options][attribuut_groep_naam]+' - ';
				var a = '<label><strong><i>';
				var b = ''+productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_naam_300]+':</i></strong></label>';
				var c = '<br />SPATIE_REPLACE|'+$j(this).val()+'';

				if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300] != '0.00'){
					
					var d = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300]).formatMoney(2, ',', '.')+')</small></i><br />';
				}else if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verlaging_300] != '0.00'){
						
					var d = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verlaging_300]).formatMoney(2, ',', '.')+')</small></i><br />';
				}else{
						
					var d = '<br />';
				}
					
				var extra_value		= a+b+c+d;
					
				html_extra_value.push(extra_value);
			}

		break;

		case 'textarea':

			if($j(this).val() != ''){
					
				var id_tmp 				= $j(this).attr('id');
				id_attribuut_options	= id_tmp.replace("select_","");
	
				var a = '<label><strong><i>';
				var b = ''+productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][attribuut_naam_300]+':</i></strong></label>';
				var c = '<br />SPATIE_REPLACE|'+$j(this).val()+'';

				if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300] != '0.00'){
					
					var d = ' <i><small>('+valuta_replace+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verhoging_300]).formatMoney(2, ',', '.')+')</small></i><br />';
				}else if(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verlaging_300] != '0.00'){
						
					var d = ' <i><small>('+valuta_replace_min+' '+eval(productProductAttribuutList_300[id_attribuut_groep][id_attribuut_options][prijs_verlaging_300]).formatMoney(2, ',', '.')+')</small></i><br />';
				}else{
					
					var d = '<br />';
				}

				var extra_value		= a+b+c+d;
					
				html_extra_value.push(extra_value);
			}

		break;
		
		case 'hidden':
			
			if($j(this).val() != ''){

				var a = '<label><strong><i>';
				var b = ''+productProductAttribuutList_300[id_attribuut_groep][0][attribuut_groep_naam_300]+':</i></strong></label>';
				var c = '<br />';
				var d = '';

				var extra_value		= a+b+c+d;
					
				html_extra_value.push(extra_value);
			}
			
		break;

		default:

		}
	});	
			
	//html_extra_value	= html_extra_value.replace(",","");
	
	$j.ajax({
						
		url: ""+root_site+"docs/ajaxrequest/cart_request.php",
		type: "POST",
		data: attribuut_options+'&action=addCartAttribuutOptionsProduct&id_cat='+id_cat+'&id_product='+id_product+'&aantal='+aantal+'&type='+type+'&extra_value='+html_extra_value+'',
		success: function(data){

			var trimResponse = trim(data);

			viewCart(true, id_shop_type);

			$j('html,body').animate({scrollTop:0},'slow', function(){
				
			});

			if(trimResponse != ''){

				var myStringVar = "max_eenheid";
				var myMatch = trimResponse.search(myStringVar);
				if(myMatch != -1){

					if(tbremove == 'true'){
										
						tb_remove();
					}
	
					$j('#winkelwagen_box').slideToggle(750, function() {
								
					});
						
					$j('#product_'+id_product+'-0').effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
									
					});

					trimResponse_tmp = trimResponse.split(myStringVar);
					alert('Het maximaal aantal stuks te bestellen is: '+trimResponse_tmp[1]);
				}

				if(IsNumeric(trimResponse)){
						
					if(trimResponse == 1){
							
						alert('Er is helaas nog maar '+trimResponse+' stuk op voorraad!');
					}else{
							
						alert('Er zijn helaas nog maar '+trimResponse+' stuks op voorraad!');
					}
				}
			}else{

				if(tbremove == 'true'){
									
					tb_remove();
				}

				$j('#winkelwagen_box').slideDown(750, function() {
								
					$j('.winkelwagen-items').last().effect("highlight", {color: '#fff799'}, 3000, function() {

						hideCart();
					});
				});
					
				$j('#product_'+id_product+'-0').effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
								
				});
			}
		}
	});				

}

function addCartRelevantProduct(id_cat, id_product, id_attribuut, type, direct_bestellen, check, aantal_inputfield){
	//alert(id_product+'='+id_attribuut+'='+type+'='+check+'=');
		
	if(direct_bestellen == 'FALSE'){
		
		alert("U kunt dit product niet direct bestellen!\n\nOm het product te kunnen bestellen klikt u op \"Bestellen\" of \"Meer informatie\".");
		
		return;
	}
	
	var id_attribuut_effect			= id_attribuut;
	
	// if cehck true checken of er besteld kan worden product detail
	if(check == 'TRUE'){
		
		var id_attribuut			=id_attribuut;
		var aantal					= $j('#'+aantal_inputfield+'').val();
		
		if(id_attribuut != 0){
			
			id_attribuut_effect		= 0;
		}
	}
	if(check == 'FALSE'){
		
		var aantal		= 1;
	}
	
	//$j('#winkelwagen_loading').css('display', 'block');
	$j('#winkelwagen_content_loading').empty();
	
	if(id_attribuut == undefined){
		
		id_attribuut = 0;
	}

	if(aantal == undefined){
		
		aantal = 1;
	}

	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'addCart',
															  id_cat: id_cat,
															  id_product: id_product,
															  id_attribuut: id_attribuut,
															  aantal: aantal,
															  type: type},function(data){
		
			var trimResponse = trim(data);

			viewCart(true, id_shop_type);

			$j('html,body').animate({scrollTop:0},'slow', function(){
				
			});

			if(trimResponse != ''){

				$j('#winkelwagen_box').slideToggle(750, function() {
								
					$j('#item-'+id_product+'-'+id_attribuut+'').effect("highlight", {color: '#fff799'}, 3000, function() {

						hideCart();
					});
				});
					
				$j('#product_'+id_product+'-'+id_attribuut_effect+'').delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
								
				});

				var myStringVar = "max_eenheid";
				var myMatch = trimResponse.search(myStringVar);
				if(myMatch != -1){
					
					trimResponse_tmp = trimResponse.split(myStringVar);
					alert('Het maximaal aantal stuks te bestellen is: '+trimResponse_tmp[1]);
				}

				if(IsNumeric(trimResponse)){
						
					if(trimResponse == 1){
							
						alert('Er is helaas nog maar '+trimResponse+' stuk op voorraad!');
					}else{
							
						alert('Er zijn helaas nog maar '+trimResponse+' stuks op voorraad!');
					}
				}
			}else{

				$j('#winkelwagen_box').slideToggle(750, function() {
								
					$j('#item-'+id_product+'-'+id_attribuut+'').effect("highlight", {color: '#fff799'}, 3000, function() {

						hideCart();
					});
				});
					
				$j('#product_'+id_product+'-'+id_attribuut_effect+'').delay(200).effect("transfer", { to: "div#winkelwagen_box" }, 800, function(){
								
				});
			}
	});
		
//	$j("#winkelwagen_box").pause(4000).hide("blind", { direction: "vertical"}, 750, function() {
//																								 
//	});	
}

function updateCartItemWinkelwagen(id, id_div, afname_eenheid, minimale_afname, maximale_afname, aantal, action){
	
	if(id == undefined){
		
		return;
	}
	
	setWinkelwagenLoadingHeigth();
	$j('#winkelwagen_overzicht_loading').css('display', 'block');
	
	var aantal						= Number(aantal);
	var afname_eenheid				= Number(afname_eenheid);
	var minimale_afname				= Number(minimale_afname);
	
	if(action == 'less'){
		
		aantal						= aantal - afname_eenheid;
	}
	if(action == 'more'){
		
		aantal						= eval(aantal + afname_eenheid);
	}
	
	if(aantal < minimale_afname){
		
		aantal						= 0;
	}

	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'updateCart',
															  id: id,
															  aantal: aantal},function(data){
		
		var trimResponse = trim(data);
		
		if(window.request_url != undefined){
			
			if(request_url == 'bestellen.html' || request_url == vars_lang+'/bestellen.html' || request_url == 'zakelijk/bestellen.html' || request_url == 'zakelijk/'+vars_lang+'/bestellen.html'){
				
				loadWinkelwagenOverzicht('update','TRUE');
			}else{
				
				loadWinkelwagenOverzicht('update','FALSE');
			}
				
		}else{
			
			loadWinkelwagenOverzicht('update','FALSE');
		}

		viewCart(false, id_shop_type);

		if(trimResponse != ''){

			$j('#item-'+id_div+'').effect("highlight", {color: '#fff799'}, 3000, function(){
	
			});				

			var myStringVar = "max_eenheid";
			var myMatch = trimResponse.search(myStringVar);
			if(myMatch != -1){
					
				trimResponse_tmp = trimResponse.split(myStringVar);
				alert('Het maximaal aantal stuks te bestellen is: '+trimResponse_tmp[1]);
			}

			if(IsNumeric(trimResponse)){
						
				if(trimResponse == 1){
							
					alert('Er is helaas nog maar '+trimResponse+' stuk op voorraad!');
				}else{
							
					alert('Er zijn helaas nog maar '+trimResponse+' stuks op voorraad!');
				}
			}
		}else{

			$j('#item-'+id_div+'').effect("highlight", {color: '#fff799'}, 3000, function(){
	
			});				
		}
	});	
	
	if(aantal == 0){
		
		deleteCartItem(id);
	}
}

function updateVerzendkostenDefault() {

	var betaalwijze_tmp		= $j('input:checked[type="radio"][name="betaalwijze"]').val();
	var aflevermethode_tmp	= $j('input:checked[type="radio"][name="aflevermethode"]').val();

	if(aflevermethode_tmp == undefined){
			
		aflevermethode_tmp	= $j('#aflevermethode :selected').val();
			
		if(aflevermethode_tmp == undefined){
				
			aflevermethode_tmp	= 0;
		}
	}
//alert(betaalwijze_tmp);
	if(betaalwijze_tmp == undefined){
			
		var betaalwijze_tmp		= 4;
	}

	$j('#betaalwijze_value').val(betaalwijze_tmp);
	$j('#aflevermethode_value').val(aflevermethode_tmp);

	//setWinkelwagenLoadingHeigth();
	$j('#winkelwagen_overzicht_loading').css('display', 'block');

	var betaalwijze_tmp		= $j('input:checked[type="radio"][name="betaalwijze"]').val();
	//alert(betaalwijze_tmp);
	if(betaalwijze_tmp == undefined){
			
		//var betaalwijze_tmp		= 4;
	}
	var aflevermethode_tmp	= $j('input:checked[type="radio"][name="aflevermethode"]').val();
	$j('#betaalwijze_value').val(betaalwijze_tmp);
	$j('#aflevermethode_value').val(aflevermethode_tmp);
		
	var betaalwijze		= $j('#betaalwijze_value').val();
	var aflevermethode	= $j('#aflevermethode_value').val();
	//alert(betaalwijze_tmp);
	if(aflevermethode == undefined){
			
		aflevermethode = 0;
	}
		
	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'modifyBetaalwijze', betaalwijze: betaalwijze, aflevermethode: aflevermethode, id_shop_type: id_shop_type, lang: vars_lang, lang_id: lang_id},function(data){
																										
	});
}

function loadWinkelwagenOverzicht(action,verzendkosten){
	
	//setWinkelwagenLoadingHeigth();
	$j('#winkelwagen_overzicht_loading').css('display', 'block');

	var betaalwijze		= 0;
	var id_land			= $j('#id_land').val();
	
	if(id_land == undefined){
		
		id_land 	= 1;
	}

	if(window.id_shop_type == undefined){
		
		id_shop_type	= 1;
		//var id_shop_type	= 1;
	}
	if(window.lang_id == undefined){
		
		lang_id	= 1;
	}	

	if(action == 'updateverzendkosten' || action == 'updateVerzendkostenOverzicht'){
		
		var betaalwijze_tmp		= $j('input:checked[type="radio"][name="betaalwijze"]').val();
		var aflevermethode_tmp	= $j('input:checked[type="radio"][name="aflevermethode"]').val();

		if(aflevermethode_tmp == undefined){
			
			aflevermethode_tmp	= $j('#aflevermethode :selected').val();
			
			if(aflevermethode_tmp == undefined){
				
				aflevermethode_tmp	= 0;
			}
		}
//alert(betaalwijze_tmp);
		if(betaalwijze_tmp == undefined){
			
			var betaalwijze_tmp		= 4;
		}
		//alert(aflevermethode_tmp);
		$j('#betaalwijze_value').val(betaalwijze_tmp);
		$j('#aflevermethode_value').val(aflevermethode_tmp);
		action = 'view';
	}
	
	if(verzendkosten == 'TRUE'){

		//setWinkelwagenLoadingHeigth();
		$j('#winkelwagen_overzicht_loading').css('display', 'block');

//		var betaalwijze_tmp		= $j('input:checked[type="radio"][name="betaalwijze"]').val();
//		//alert(betaalwijze_tmp);
//		if(betaalwijze_tmp == undefined){
//			
//			//var betaalwijze_tmp		= 4;
//		}
//		var aflevermethode_tmp	= $j('input:checked[type="radio"][name="aflevermethode"]').val();
//	
//		//alert(aflevermethode_tmp);
//		$j('#betaalwijze_value').val(betaalwijze_tmp);
//		$j('#aflevermethode_value').val(aflevermethode_tmp);

		var betaalwijze		= $j('#betaalwijze_value').val();
		var aflevermethode	= $j('#aflevermethode_value').val();
		//alert(betaalwijze_tmp);
		if(aflevermethode == undefined){
			
			aflevermethode = 0;
		}
		//alert(aflevermethode);
		//alert('');
		$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'modifyBetaalwijze', betaalwijze: betaalwijze, aflevermethode: aflevermethode, id_shop_type: id_shop_type, lang: vars_lang, lang_id: lang_id},function(data){
																										
		});
	}
	
	if(verzendkosten == 'DISPLAY'){
		
		$j('#winkelwagen_overzicht_loading').css('display', 'block');
	}
	
	if(action == 'new' || action == 'view' || action == 'update'){
		
		$j('#winkelwagen_body').empty();
	}
	
	$j('#winkelwagen_vouchers').empty();
	$j('#winkelwagen_korting_klant').empty();
	$j('#bestel_overzicht_body').empty();
	
	$j.getJSON(""+root_site+"docs/ajaxrequest/cart_request.php?action=getCart&verzendkosten="+verzendkosten+"&betaalwijze="+betaalwijze+"&aflevermethode="+aflevermethode+"&id_land="+id_land+"&id_shop_type="+id_shop_type+"&lang="+vars_lang+"&lang_id="+lang_id+"",
			
		function(data){

			if(data.verzendkosten == '0'){
					
				data.verzendkosten	= '0.00';
			}

			if(data.aantal_producten == '0' && data.message != undefined){
				
				var html = '';
								
				html += '<dl class="winkelwagen_overzicht_body winkelwagen_overzicht">';
				html += '<dt class="dt_1 dt_winkelwagen_leeg">'+data.message+'</dt>';
				html += '<dt class="dt_2 dt_winkelwagen_leeg">&nbsp;</dt>';
				html += '<dt class="dt_3 dt_winkelwagen_leeg">&nbsp;</dt>';
				html += '<dt class="dt_4 dt_winkelwagen_leeg">&nbsp;</dt>';
				html += '<dt class="dt_5 dt_winkelwagen_leeg">&nbsp;</dt>';
				html += '</dl>';
				
				$j('#winkelwagen_body').append(html);
				
				$j('.winkelwagen_overzicht_legen, .dt_legen').css('display', 'none');
				$j('#winkelwagen_coupon').css('display', 'none');
				$j('.step_2 a').attr('href', '#');
				$j('#button_volgende_stap').css('display', 'none');
				
				$j('#subtotaal_html').html(data.subtotaal);
				$j('#btw_html').html(data.btw);
				$j('#totaalprijs_html').html(data.totaalprijs);
				
				$j('#dl_klant_korting').css('display', 'none');
				$j('#dl_voucher_korting').css('display', 'none');
				$j('#winkelwagen_overzicht_loading').css('display', 'none');
				
				return;
			}

			if(action == 'view'){
					
				$j('#winkelwagen_body').html('');
			}

			$j.each(data.items, function(i,item){
			
			var html = '';
			
			if(action == 'new' || action == 'view' || action == 'update'){
				
				html += '<dl class="winkelwagen_overzicht_body winkelwagen_overzicht" id="dl_product_'+item.id+'">';
				if(item.afbeelding == ''){

				html += '<dt class="dt_1"><div class="div_img_winkelwagen_overzicht"><!----></div><a href="'+item.url+'" title="'+item.product_naam+'<br />'+item.attribuut_naam+'" class="simple-tooltip_yellow">'+item.product_naam+'</a><br /><small></a><span class="artikelnummer_winkelwagen_overzicht">'+item.artikelnummer+'</span></small><br /><span class="attribuut_naam_winkelwagen_overzicht">'+item.attribuut_naam+'</span></dt>';
				}
				if(item.afbeelding != ''){
				
				html += '<dt class="dt_1"><div class="div_img_winkelwagen_overzicht"><img src="'+root_site+'images/products/resize40/'+item.afbeelding+'" class="img_winkelwagen_overzicht"></div><a href="'+item.url+'" title="'+item.product_naam+'<br />'+item.attribuut_naam+'" class="simple-tooltip_yellow">'+item.product_naam+'</a><br /><small></a><span class="artikelnummer_winkelwagen_overzicht">'+item.artikelnummer+'</span></small><br /><span class="attribuut_naam_winkelwagen_overzicht">'+item.attribuut_naam+'</span></dt>';
				}
				
				if(item.product_type == '101'){

					html += '<dt class="dt_2">Staal aanvraag</dt>';
				}else{
					
//					if(action == 'view'){
//					
//					html += '<dt class="dt_2">'+item.aantal+'<br /><small>'+item.prijs_per+'</small></dt>';
//					}else{
//					html += '<dt class="dt_2"><!--<input type="text" name="aantal_'+item.id+'" id="aantal_'+item.id+'" style="width:25px;" value="'+item.aantal+'" class="inputfield" onkeyup="checkNumber(this.id); updateCartItem(\''+item.id+'\');" />--><span class="aantal_cart">'+item.aantal+'<br /><small>'+item.prijs_per+'</small></span><span class="update_aantal_cart"><img src="'+root_site+'docs/img/cart-minus.png" onclick="updateCartItemWinkelwagen(\''+item.id+'\',\''+item.id_url+'\',\''+item.afname_eenheid+'\',\''+item.minimale_afname+'\',\''+item.maximale_afname+'\',\''+item.aantal+'\',\'less\');"/> <img src="'+root_site+'docs/img/cart-plus.png" onclick="updateCartItemWinkelwagen(\''+item.id+'\',\''+item.id_url+'\',\''+item.afname_eenheid+'\',\''+item.minimale_afname+'\',\''+item.maximale_afname+'\',\''+item.aantal+'\',\'more\');"/></span></dt>';
//					}
					
					html += '<dt class="dt_2"><!--<input type="text" name="aantal_'+item.id+'" id="aantal_'+item.id+'" style="width:25px;" value="'+item.aantal+'" class="inputfield" onkeyup="checkNumber(this.id); updateCartItem(\''+item.id+'\');" />--><span class="aantal_cart">'+item.aantal+'<br /><small>'+item.prijs_per+'</small></span><span class="update_aantal_cart"><img src="'+root_site+'docs/img/cart-minus.png" onclick="updateCartItemWinkelwagen(\''+item.id+'\',\''+item.id_url+'\',\''+item.afname_eenheid+'\',\''+item.minimale_afname+'\',\''+item.maximale_afname+'\',\''+item.aantal+'\',\'less\');"/> <img src="'+root_site+'docs/img/cart-plus.png" onclick="updateCartItemWinkelwagen(\''+item.id+'\',\''+item.id_url+'\',\''+item.afname_eenheid+'\',\''+item.minimale_afname+'\',\''+item.maximale_afname+'\',\''+item.aantal+'\',\'more\');"/></span></dt>';
				}
				
				if(item.product_type == '30'){

				html += '<dt class="dt_3"><span id="prijs_'+item.id+'">Offerte aanvraag</span></dt>';
				html += '<dt class="dt_4"><span id="prijs_totaal_'+item.id+'">Offerte aanvraag</span></dt>';

				}else{
				
				html += '<dt class="dt_3"><span id="prijs_'+item.id+'">'+item.prijs+item.prijs_product+'</span></dt>';
				html += '<dt class="dt_4"><span id="prijs_totaal_'+item.id+'"><span class="left">'+data.valuta+'</span> <span class="right">'+item.totaal_prijs_product_display+'</span></span></dt>';
				}
				
				html += '<dt class="dt_5"><input type="checkbox" name="verwijderen" id="verwijderen" value="1" onclick="deleteCartItem(\''+item.id+'\');" /></dt>';
				
				html += '</dl><div class="clear"><!----></div><!--END clear-->';
			
				$j('#winkelwagen_body').append(html);
				
				$j('#subtotaal_html').html(data.subtotaal);	
				$j('#btw_html').html(data.btw);	
				$j('#totaalprijs_html').html(data.totaalprijs);	
				
				if(data.voucher_korting != '0.00' && data.voucher_korting != '0,00'){

					$j('#dl_voucher_korting').css('display', 'block');
					$j('#voucher_korting_html').html('- '+data.voucher_korting);	
				}else{
					
					$j('#dl_voucher_korting').css('display', 'none');
				}

				if(data.klant_korting != '0.00' && data.klant_korting != '0,00'){
					
					$j('#dl_klant_korting').css('display', 'block');
					$j('#klant_korting_html').html('- '+data.klant_korting);	
				}else{
					
					$j('#dl_klant_korting').css('display', 'none');
				}

				if(verzendkosten == 'TRUE' || verzendkosten == 'DISPLAY' ){
					
					$j('#winkelwagen_overzicht_verzendkosten').css('display', 'block');
					$j('#verzendkosten_html').html(' + '+data.verzendkosten);
					
					if(data.extrakosten != '0.00' && data.extrakosten != '0,00'){
						
						$j('#winkelwagen_overzicht_extraverzendkosten').css('display', 'block');
						$j('#bestel_overzicht_extraverzendkosten').css('display', 'block');
						$j('#omschrijving_extrakosten_html').html(data.omschrijving_extrakosten);
						$j('#extrakosten_html').html(' + '+data.extrakosten);
					}else{
						
						$j('#winkelwagen_overzicht_extraverzendkosten').css('display', 'none');
						$j('#bestel_overzicht_extraverzendkosten').css('display', 'none');
					}
					if(data.extra_kosten_verzending != '0.00' && data.extra_kosten_verzending != '0,00'){
						
						$j('#winkelwagen_overzicht_extraverzending').css('display', 'block');
						$j('#bestel_overzicht_extraverzending').css('display', 'block');
						$j('#omschrijving_extrakosten_verzending_html').html(data.extra_kosten_verzending_omschrijving);
						$j('#extrakosten_verzending_html').html(' + '+data.extra_kosten_verzending);
					}else{
						
						$j('#winkelwagen_overzicht_extraverzending').css('display', 'none');
						$j('#bestel_overzicht_extraverzending').css('display', 'none');
					}
				}

				$j('#button_volgende_stap').css('display', 'block');
				$j('#dl_minimaal_order_bedrag').css('display', 'none');

				if(data.afrekenen_mogelijk == 0){
					
					$j('#button_volgende_stap').css('display', 'none');
					$j('#dl_minimaal_order_bedrag').css('display', 'block');
					$j('#minimaal_order_bedrag_html').html(data.minimaal_order_bedrag);
				}
			}
						
//			if(action == 'update'){
//				
//				$j('#prijs_'+item.id+'').html(item.prijs+item.prijs_product);
//				$j('#prijs_totaal_'+item.id+'').html(item.totaal_prijs_product_display);
//				$j('#subtotaal_html').html(data.valuta+data.subtotaal);
//				$j('#btw_html').html(data.valuta+data.btw);
//				$j('#totaalprijs_html').html(data.valuta+data.totaalprijs);
//			}
			
			if(action == 'updateverzendkosten' || action == 'updateVerzendkostenOverzicht'){
								
				$j('#winkelwagen_overzicht_verzendkosten').fadeIn(500);
				$j('#verzendkosten_html').html(' + '+data.verzendkosten);
				$j('#totaalprijs_html').html(data.totaalprijs);
					
				if(data.extrakosten != '0.00' && data.extrakosten != '0,00'){

					$j('#winkelwagen_overzicht_extraverzendkosten').fadeIn(500);
					$j('#bestel_overzicht_extraverzendkosten').fadeIn(500);
					$j('#omschrijving_extrakosten_html').html(data.omschrijving_extrakosten);
					$j('#extrakosten_html').html(' + '+data.extrakosten);
	
				}else{
					
					$j('#winkelwagen_overzicht_extraverzendkosten').css('display', 'none');
					$j('#bestel_overzicht_extraverzendkosten').css('display', 'none');
				}
				if(data.extra_kosten_verzending != '0.00' && data.extra_kosten_verzending != '0,00'){
						
					$j('#winkelwagen_overzicht_extraverzending').css('display', 'block');
					$j('#bestel_overzicht_extraverzending').css('display', 'block');
					$j('#omschrijving_extrakosten_verzending_html').html(data.extra_kosten_verzending_omschrijving);
					$j('#extrakosten_verzending_html').html(' + '+data.extra_kosten_verzending);
				}else{
						
					$j('#winkelwagen_overzicht_extraverzending').css('display', 'none');
					$j('#bestel_overzicht_extraverzending').css('display', 'none');
				}				
			}

			//Overzicht bestel overzicht (gegevens.html)
			if(action == 'overzicht' || action == 'updateVerzendkostenOverzicht'){
				
				html += '<div class="bestel_overzicht_producten">';
				
				html += '<div class="bestel_overzicht_producten_top">'+item.product_naam+'<br />'+item.attribuut_naam+'</div><!--END bestel_overzicht_producten_top-->';
				html += '<div class="bestel_overzicht_producten_bottom">';
				html += '<span class="bestel_overzicht_aantal">Aantal: '+item.aantal+'</span><span class="bestel_overzicht_euro">'+data.valuta+' </span><span class="bestel_overzicht_totaal_right">'+item.totaal_prijs_product_display+'</span>';
				html += '</div><!--END bestel_overzicht_producten_bottom-->';
				html += '<div class="clear"><!----></div><!--END clear-->';
				html += '</div><!--END bestel_overzicht_producten-->';
				
				$j('#bestel_overzicht_body').append(html);
			
				$j('#subtotaal_html').html(data.subtotaal);	
				$j('#btw_html').html(data.btw);	
				$j('#totaalprijs_html').html(data.totaalprijs);	
				$j('#verzendkosten_html').html(' + '+data.verzendkosten);

				if(data.extrakosten != '0.00' && data.extrakosten != '0,00'){
					
					$j('#winkelwagen_overzicht_extraverzendkosten').css('display', 'block');
					$j('#bestel_overzicht_extraverzendkosten').css('display', 'block');
					$j('#omschrijving_extrakosten_html').html(data.omschrijving_extrakosten+' '+data.valuta);
					$j('#extrakosten_html').html('+ '+data.extrakosten);
	
				}else{
					
					$j('#winkelwagen_overzicht_extraverzendkosten').css('display', 'none');
					$j('#bestel_overzicht_extraverzendkosten').css('display', 'none');
				}
				if(data.extra_kosten_verzending != '0.00' && data.extra_kosten_verzending != '0,00'){
						
					$j('#winkelwagen_overzicht_extraverzending').css('display', 'block');
					$j('#bestel_overzicht_extraverzending').css('display', 'block');
					$j('#omschrijving_extrakosten_verzending_html').html(data.extra_kosten_verzending_omschrijving+': '+data.valuta);
					$j('#extrakosten_verzending_html').html(' + '+data.extra_kosten_verzending);
				}else{
						
					$j('#winkelwagen_overzicht_extraverzending').css('display', 'none');
					$j('#bestel_overzicht_extraverzending').css('display', 'none');
				}

				if(data.voucher_korting != '0.00' && data.voucher_korting != '0,00'){
					
					$j('#bestel_overzicht_voucher').css('display', 'block');
					$j('#voucher_korting_totaal_html').css('display', 'block');
					$j('#voucher_korting_html').html('- '+data.voucher_korting);
					$j('#bestel_overzicht_totaal_voucher').css('display', 'block');
					$j('#voucher_korting_totaal_html').html('- '+data.voucher_korting);
				}else{
				
					$j('#bestel_overzicht_voucher').css('display', 'none');
					$j('#bestel_overzicht_totaal_voucher').css('display', 'none');
					$j('#voucher_korting_totaal_html').css('display', 'none');
				}

				if(data.klant_korting != '0.00' && data.klant_korting != '0,00'){
					
					$j('#bestel_overzicht_klant').css('display', 'block');
					$j('#klant_korting_totaal_html').css('display', 'block');
					$j('#klant_korting_html').html('- '+data.klant_korting);
					$j('#bestel_overzicht_totaal_klant').css('display', 'block');
					$j('#klant_korting_totaal_html').html('- '+data.klant_korting);
				}else{
				
					$j('#bestel_overzicht_klant').css('display', 'none');
					$j('#bestel_overzicht_totaal_klant').css('display', 'none');
					$j('#klantr_korting_totaal_html').css('display', 'none');
				}
			}
		});

		$j.each(data.vouchers, function(i,item){
			
			var html = '';
			
			html += '<dl class="winkelwagen_overzicht_voucher winkelwagen_overzicht" id="dl_product_'+item.id_voucher+'">';
			html += '<dt class="dt_1"><div class="div_img_winkelwagen_overzicht"><!----></div><span class="voucher_color">Korting  voucher: <strong>'+item.voucher+'</strong></span><br />'+item.omschrijving+'</dt>';
			html += '<dt class="dt_2"><img src="'+root_site+'docs/img/delete.gif" onclick="deleteVoucher(\''+item.id_voucher+'\')" /></dt>';
			html += '<dt class="dt_3">&nbsp;</dt>';
			html += '<dt class="dt_4"><span class="left">'+data.valuta+' -</span> <span class="right">'+item.korting_voucher+'</span></dt>';
			html += '<dt class="dt_5">&nbsp;</dt>';
			html += '</dl>';	
			
			$j('#winkelwagen_vouchers').append(html);
			
		});
		
		$j.each(data.korting_klant, function(i,item){
			
			var html = '';
			
			html += '<dl class="winkelwagen_overzicht_voucher winkelwagen_overzicht" id="dl_product_'+item.id_korting_klant+'">';
			html += '<dt class="dt_1"><div class="div_img_winkelwagen_overzicht"><!----></div><span class="voucher_color">Persoonlijke korting:</span><br />'+item.omschrijving+'</dt>';
			html += '<dt class="dt_2">&nbsp;</dt>';
			html += '<dt class="dt_3">&nbsp;</dt>';
			html += '<dt class="dt_4">'+data.valuta+' - '+item.korting_klant+'</dt>';
			html += '<dt class="dt_5">&nbsp;</dt>';
			html += '</dl>';	
			
			$j('#winkelwagen_korting_klant').append(html);
			
		});
				
		if(action == 'view'){
			
			$j('.winkelwagen_overzicht_voucher dt.dt_2 img').each(function(){
				
				$j(this).css('display', 'none');
			});
		}

		$j('#winkelwagen_overzicht_loading').css('display', 'none');
		$j(".simple-tooltip_yellow").simpletooltip_yellow();
		
	});
}

function updateCartItem(id){
	
	if(id == undefined){
		
		return;
	}
	
	//setWinkelwagenLoadingHeigth();
	$j('#winkelwagen_overzicht_loading').css('display', 'block');
	
	var aantal						= $j('#aantal_'+id+'').val();
	if(aantal == ''){
		
		aantal						= 0;
	}

	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'updateCart', 
															  id: id,
															  aantal: aantal},function(data){
		
		loadWinkelwagenOverzicht('update','FALSE');
		viewCart(false, id_shop_type);
		
	});	
}

function deleteCartItem(id){
	
	//Confirm
	var answer = confirm("Wilt u het product uit uw winkelwagen verwijderen?");
		
	if (answer){
				
		$j('#dl_product_'+id+'').fadeOut(500);
		
		$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'deleteCartItem', 
																  id: id},function(data){
			
			loadWinkelwagenOverzicht('update','FALSE');
			viewCart(false, id_shop_type);
		});			
		//return true;
	}else{
			
		return false;
	}
}

function deleteCart(){
	
	var answer = confirm("Wilt alles uit uw winkelwagen verwijderen?");
	
	if (answer){
	
		
		$j('.winkelwagen_overzicht_body').each(function(){
			
			$j(this).fadeOut(500);
		});
		
		$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'deleteCart'},function(data){
			
			loadWinkelwagenOverzicht('update','FALSE');

			if(browser == "Microsoft Internet Explorer"){
				
				window.location = root_site+"winkelwagen.html";
			}
			
			viewCart(false, id_shop_type);
			
		});	
				
	}else{
		
		return;
	}
}

function getBetaalwijzeKeuzesLand(check) {
	
	var id_land = $j('#id_land_verzending').val();
	
	if(id_land == undefined){
	
		id_land = $j('#land :selected').val();
	}

	if(window.id_shop_type == undefined){
		
		id_shop_type	= 1;
	}

	var actionOnchange = $j('#actionOnchange').val();
	
	$j('#winkelwagen_overzicht_loading').css('display', 'none');

	$j.get(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'getBetaalwijzeKeuzes', id_land: id_land, actionOnchange: actionOnchange, id_shop_type: id_shop_type},function(data){
		
		$j('#betaalwijze_div').html(data);
		$j('#winkelwagen_overzicht_loading').css('display', 'block');
		
		if(check == 1){
			
			loadWinkelwagenOverzicht('view','TRUE');
		}else{
			
			if(actionOnchange != undefined && actionOnchange != ''){
				
				loadWinkelwagenOverzicht('updateVerzendkostenOverzicht','TRUE');
			}else{
				
				loadWinkelwagenOverzicht('updateverzendkosten','TRUE');
			}
		}
	});
}

function getBetaalwijzeKeuzesLandRadio(check) {
	
	var id_land = $j('input[name=id_land_verzending]:checked').val();
	
	if(id_land == undefined){
		
	
		id_land = 1;
	}

	if(window.id_shop_type == undefined){
		
		id_shop_type	= 1;
	}

	if(window.lang_id == undefined){
		
		lang_id	= 1;
	}

	var actionOnchange = $j('#actionOnchange').val();
	
	$j('#winkelwagen_overzicht_loading').css('display', 'none');

	$j.get(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'getBetaalwijzeKeuzes', id_land: id_land, actionOnchange: actionOnchange, id_shop_type: id_shop_type, lang: vars_lang, lang_id: lang_id},function(data){
		//alert(data);
		$j('#betaalwijze_div').html(data);
		$j('#winkelwagen_overzicht_loading').css('display', 'block');
		
		if(check == 1){
			
			loadWinkelwagenOverzicht('view','TRUE');
		}else{
			
			if(actionOnchange != undefined && actionOnchange != ''){
				
				loadWinkelwagenOverzicht('updateVerzendkostenOverzicht','TRUE');
			}else{
				
				loadWinkelwagenOverzicht('updateverzendkosten','TRUE');
			}
		}
	});
}

function setIdVerzendingExtra() {
	
	var id_verzending_extra	= $j('#id_verzending_extra:checked').val();
	
	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'setIdVerzendingExtra',
															  id_verzending_extra: id_verzending_extra},function(data){
		
		loadWinkelwagenOverzicht('updateverzendkosten','TRUE');
	});
}

function getVoucher(action) {
	
	$j('#voucher_error_msg').css('display', 'none');
	$j('#winkelwagen_overzicht_loading').css('display', 'block');
	
	var voucher_input	= $j('#voucher_input').val();
	
	if(voucher_input == ''){
		
		alert("Er is geen voucher ingevuld!");
		$j('#winkelwagen_overzicht_loading').css('display', 'none');
		return;
	}
	
	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'checkVoucher',
															  voucher: voucher_input},function(data){
		
		if(trim(data) == false){
			
			$j('#voucher_error_msg').css('display', 'block');
			//loadWinkelwagenOverzicht('new','FALSE');
		}
		if(trim(data) == true){
			
			$j('#voucher_input').val('');
			$j('#voucher_error_msg').css('display', 'none');
			$j('#winkelwagen_body').empty();
			if(action == 1){
				
				loadWinkelwagenOverzicht('new','TRUE');
				//loadWinkelwagenOverzicht('view','TRUE');

			}
			if(action == 2){
				
				loadWinkelwagenOverzicht('new','TRUE');
				//loadWinkelwagenOverzicht('view','TRUE');

			}			
			if(action == 3){
				
				loadWinkelwagenOverzicht('overzicht','TRUE');
			}
		}	
		$j('#winkelwagen_overzicht_loading').css('display', 'none');
		//alert(trim(data));
	});
}

function deleteVoucher(id_voucher) {

	var answer = confirm("Wilt u de voucher verwijderen?");
	
	if (answer){
		
		$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'deleteVoucher',
																  id_voucher: id_voucher},function(data){
			
			loadWinkelwagenOverzicht('update','FALSE');

			if(browser == "Microsoft Internet Explorer"){
				
				window.location = root_site+"winkelwagen.html";
			}
			
			viewCart(false, id_shop_type);
			
		});	
				
	}else{
		
		return;
	}

}

function changeLandGegevensForm(id_land) {
	
	$j('#bezorgland').val(id_land);
}

function checkBestelMethode(id) {
	
	$j('input[name="bestel_methode"]').each(function(){
		
		$j(this).attr('checked', false);
	});
	
	$j('input[id="'+id+'"]').attr('checked', true);
}

function fillDeliveryAdress() {

	if($j('input[name=afleveradres]').is(':checked')){
		
		$j('#delivery_adress_div').show("blind", { direction: "vertical" }, 750);
	}else{
		
		if(document.getElementById("delivery_adress_div").style.display != "none"){
			
			$j('#delivery_adress_div').hide("blind", { direction: "vertical" }, 750);
		}
	}
	
	var check_ander_afleveradres	= $j('#afleveradres').attr('checked');
	
	if(check_ander_afleveradres == false){
		
		$j('#land').val($j('#bezorgland').val());
		//$j('#land').attr('disabled', true);
	}else{
						
		//$j('#land').attr('disabled', false);
	}
}

function getKlantOrderTmp(){

	if(window.lang_id == undefined){
		
		lang_id	= 1;
	}

	$j.getJSON(""+root_site+"docs/ajaxrequest/cart_request.php?action=getKlantOrderTmp&lang="+vars_lang+"&lang_id="+lang_id+"",
			
		function(data){

			if(data.gegevens == ''){

				return;
			}

			$j.each(data.gegevens, function(i,item){
								
				if(item.array == 'empty'){
					
					return;
				}
								
				$j('#aanhef').val(item.aanhef);
				$j('#voorletters').val(item.voorletters);
				$j('#bedrijfsnaam').val(item.bedrijfsnaam);
				if(item.bedrijfsnaam != ''){
					
					$j('#bedrijf_registreren').attr('checked', true);
					changeFormRegistrerenBedrijf();
				}
				$j('#voornaam').val(item.voornaam);
				$j('#tussenvoegsel').val(item.tussenvoegsel);
				$j('#achternaam').val(item.achternaam);
				$j('#adres').val(item.adres);
				$j('#straatnaam').val(item.straat);
				$j('#huisnummer').val(item.huisnummer);
				$j('#toevoeging').val(item.toevoeging);
				$j('#postcode').val(item.postcode);
				$j('#plaats').val(item.plaats);
				$j('#land').val(item.land);
				$j('#bezorgland').val(item.land);
				$j('#telefoonnummer').val(item.telefoonnummer);
				$j('#telefoonnummer_2').val(item.telefoonnummer_2);
				$j('#email_adres').val(item.email);
				$j('#opmerkingen').val(str_replace('<br />','\n',item.opmerkingen));
				
				$j('#po_nummer').val(item.ponummer);
				$j('#kvknummer').val(item.kvknummer);
				$j('#btwnummer').val(item.btwnummer);
				
				$j('#bank_type').val(item.bank_type);
				$j('#rekeningnummer').val(item.rekeningnummer);
				$j('#banknaam').val(item.banknaam);
				
				$j('#geboortedatum_dag').val(item.geboortedatum_dag);
				$j('#geboortedatum_maand').val(item.geboortedatum_maand);
				$j('#geboortedatum_jaar').val(item.geboortedatum_jaar);

				if(item.afleveren_bij_buren == 1){
					
					$j('#afleveren_bij_buren').attr('checked', true);
				}

				$j('#p_gegevens_sub_2').html(item.message);
				$j('#p_gegevens_main_overzicht').html(item.message_overzicht);
				
				$j('#gegevens_sub_2').addClass('gegevens_main_wrapper_active');
				
				$j('#p_gegevens_sub_2').removeClass('hide');
				
				$j.each(data.aflever_gegevens, function(i,item){
					
					if(item.ander_afleveradres == 1){
						
						$j('#afleveradres').attr('checked', true);
						fillDeliveryAdress();
						
						$j('#tav').val(item.tav);
						$j('#bezorgadres').val(item.bezorgadres);
						$j('#bezorgstraatnaam').val(item.bezorgstraat);
						$j('#bezorghuisnummer').val(item.bezorghuisnummer);
						$j('#bezorgtoevoeging').val(item.bezorgtoevoeging);
						$j('#bezorgpostcode').val(item.bezorgpostcode);
						$j('#bezorgplaats').val(item.bezorgplaats);
						$j('#bezorgland').val(item.bezorgland);
					}
				});
			});
					
		$j('#bestel_overzicht_loading').css('display', 'none');
	});	
}

function getKlantOrderIngelogd() {

	$j.getJSON(""+root_site+"docs/ajaxrequest/cart_request.php?action=getKlantOrderIngelogd",
			
		function(data){

			$j.each(data.gegevens, function(i,item){
		
				if(item.array == 'empty'){
					
					return;
				}
				
				$j('#aanhef').val(trim(item.aanhef));
				$j('#voorletters').val(item.voorletters);
				$j('#bedrijfsnaam').val(item.bedrijfsnaam);
				if(item.bedrijfsnaam != ''){
					
					$j('#bedrijf_registreren').attr('checked', true);
					changeFormRegistrerenBedrijf();
				}
				$j('#voornaam').val(item.voornaam);
				$j('#tussenvoegsel').val(item.tussenvoegsel);
				$j('#achternaam').val(item.achternaam);
				$j('#adres').val(item.adres);
				$j('#straatnaam').val(item.straat);
				$j('#huisnummer').val(item.huisnummer);
				$j('#toevoeging').val(item.toevoeging);				
				$j('#postcode').val(item.postcode);
				$j('#plaats').val(item.plaats);
				$j('#land').val(item.land);
				$j('#bezorgland').val(item.land);
				$j('#telefoonnummer').val(item.telefoonnummer);
				$j('#email_adres').val(item.email);
				$j('#opmerkingen').val(str_replace('<br />','\n',item.opmerkingen));
				
				$j('#po_nummer').val(item.ponummer);
				$j('#kvknummer').val(item.kvknummer);
				$j('#btwnummer').val(item.btwnummer);

				$j('#bank_type').val(item.bank_type);
				$j('#rekeningnummer').val(item.rekeningnummer);
				$j('#banknaam').val(item.banknaam);
				
				$j('#geboortedatum_dag').val(item.geboortedatum_dag);
				$j('#geboortedatum_maand').val(item.geboortedatum_maand);
				$j('#geboortedatum_jaar').val(item.geboortedatum_jaar);

				if(item.afleveren_bij_buren == 1){
					
					$j('#afleveren_bij_buren').attr('checked', true);
				}

				$j('#p_gegevens_sub_2').html(item.message);
				$j('#p_gegevens_main_overzicht').html(item.message_overzicht);
				
				$j('#gegevens_sub_2').addClass('gegevens_main_wrapper_active');
				$j('#gegevens_sub_2 a').removeClass('hide');
				$j('#p_gegevens_sub_2').removeClass('hide');
				
			});
			
			if(data.aflever_gegevens != ''){
				
				$j.each(data.aflever_gegevens, function(i,item){
					
					if(item.ander_afleveradres == 1){
						
						$j('#afleveradres').attr('checked', true);
						fillDeliveryAdress();
						
						$j('#tav').val(item.tav);
						$j('#bezorgadres').val(item.bezorgadres);
						$j('#bezorgstraatnaam').val(item.bezorgstraat);
						$j('#bezorghuisnummer').val(item.bezorghuisnummer);
						$j('#bezorgtoevoeging').val(item.bezorgtoevoeging);						
						$j('#bezorgpostcode').val(item.bezorgpostcode);
						$j('#bezorgplaats').val(item.bezorgplaats);
						$j('#bezorgland').val(item.bezorgland);
					}
				});
			}
			
			$j('#bestel_overzicht_loading').css('display', 'none');
	});
}

function bestelFirstStep(number,action){
	
	setBestelOverzichtLoading();
	
	$j('#afleveradres').attr('disabled', false);
	for(i in verplichte_velden_afleveradres){
			
		$j('#'+verplichte_velden_afleveradres[i]+'').attr('disabled', false);
	}
	
	//$j('#land').attr('disabled', false);
	
	$j('#error_registreren').addClass('hide');
	$j('#error_inloggen').addClass('hide');
	
	var number = Number(number);

	if(action == 'choice'){
		
		if($j('input[name=bestel_methode]').is(':checked')){
			
			$j('#bestel_overzicht_loading').css('display', 'block');
			
			var bestelmethode	= $j('input[name=bestel_methode]:checked').val();
	
			$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'setBestelMethode',
																  	  bestelmethode: bestelmethode},function(data){
																	  
				$j('#gegevens_main_'+number+'').hide("blind", { direction: "vertical" }, 750,function(){

					if(bestelmethode == 'zakelijk'){
													
						$j('#gegevens_main_zakelijk').show("blind", { direction: "vertical" }, 750);
						$j('#gegevens_main_wrapper_'+(number + 1)+'').addClass('gegevens_main_wrapper_active');
						$j('#gegevens_sub_'+(number)+'').addClass('gegevens_main_wrapper_active');
						$j('#gegevens_sub_'+(number)+' a').removeClass('hide');
						$j('#account_edit_'+number+'').removeClass('hide');
						$j('#p_gegevens_sub_'+number+'').removeClass('hide');
						$j('#p_gegevens_sub_1').html(data);
							
						$j('#bestel_overzicht_loading').css('display', 'none');
						
						return;
					}

					getKlantOrderTmp();
					
					$j('#bestel_overzicht_loading').css('display', 'none');
					$j('#gegevens_main_'+(number + 1)+'').show("blind", { direction: "vertical" }, 750);
					$j('#gegevens_main_wrapper_'+(number + 1)+'').addClass('gegevens_main_wrapper_active');
					$j('#gegevens_sub_'+(number)+'').addClass('gegevens_main_wrapper_active');
					$j('#gegevens_sub_'+(number)+' a').removeClass('hide');
					$j('#account_edit_'+number+'').removeClass('hide');
					$j('#p_gegevens_sub_'+number+'').removeClass('hide');
					$j('#p_gegevens_sub_1').html(data);
					
					if(bestelmethode == 'registreer'){
						
						$j('#gegevens_wachtwoord').removeClass('hide');
					}else{
						
						$j('#gegevens_wachtwoord').addClass('hide');
					}
					
					var check_ander_afleveradres	= $j('#afleveradres').attr('checked');
					
					if(check_ander_afleveradres == false){
						
						$j('#land').val($j('#bezorgland').val());
						//$j('#land').attr('disabled', true);
					}else{
						
						//$j('#land').attr('disabled', false);
					}
				});
			});
			
		}else{
			
			alert("Maak een keuze of u wilt bestellen als:\n\nGast\nof\nDat u zich wilt registeren.");
		}
	}
}

function bestelFirstStepIngelogd(number){
	
	//window.location.hash = '';
	
	var number = Number(number);
	
	$j('#bestel_overzicht_loading').css('display', 'block');
	
	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'setBestelMethode',bestelmethode: 'ingelogd'});
	
	$j('#gegevens_main_'+number+'').hide("blind", { direction: "vertical" }, 750,function(){
		
		getKlantOrderIngelogd();
		
		$j('#gegevens_main_wrapper_'+(number + 1)+'').addClass('gegevens_main_wrapper_active');
		$j('#gegevens_sub_'+(number)+'').addClass('gegevens_main_wrapper_active');
		$j('#gegevens_sub_'+(number)+' a').removeClass('hide');
		$j('#account_edit_'+number+'').removeClass('hide');
		$j('#p_gegevens_sub_'+number+'').removeClass('hide');
		
		$j.get(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'getLoginInfo'},function(data){
			
			var html = 'Ingelogd als:<br />'+data+'';
			$j('#p_gegevens_sub_1').html(html);
		});
	});

	$j('#gegevens_main_'+(number + 1)+'').show("blind", { direction: "vertical" }, 750);
	
	$j('#gegevens_wachtwoord').addClass('hide');
	$j('#bestel_overzicht_loading').css('display', 'none');
}

function bestelFormStep(number){
	
	var number 			= Number(number);
	
	var form 			= $j('#form_gegevens').serialize();
	var bestelmethode	= $j('input[name=bestel_methode]:checked').val();

	$j('#bestel_overzicht_loading').css('display', 'block');
	
	$j('#p_gegevens_sub_2').show("blind", { direction: "vertical" }, 750);
	$j('#gegevens_main_'+number+'').hide("blind", { direction: "vertical" }, 750,function(){
		
		if(bestelmethode == 'registreer'){

			//Check of aanmelding al bestaat
			$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
					 type: "POST",
					 data: form+'&action=checkAanmelding',
					 success: function(response){
						
						if(trim(response) == true){
							
							$j('#error_registreren').addClass('hide');
							
							bestelFormPost(number);
						}
						if(trim(response) == false){
							
							$j('#error_registreren').removeClass('hide');
							var email = $j('#email').val();
							if(email == undefined){
								
								email	= $j('#email_adres').val();
							}
							
							html = 'Er is reeds een account gevonden met het opgegeven e-mail adres <strong>'+email+'</strong>.<br />Mocht u uw wachtwoord zijn vergeten, dan kunt u <a href="'+root_site+'registreren.html?action=forgottpassword">hier klikken</a> om een nieuw wachtwoord op te vragen.<br /><br /><i>(Het is mogelijk dat u uw account nog moet activeren. U heeft hierover een e-mail bericht gekregen.<br />Controleer uw e-mail inbox of <a href="'+root_site+'activeren.html?action=activicatie_mail&mail='+email+'">klik hier</a> om de activeringsmail opnieuw te ontvangen.)<br /></i>';
							$j('#error_registreer_msg').html(html);
							
							$j('#gegevens_main_'+number+'').show("blind", { direction: "vertical" }, 750,function(){
								
								$j('#bestel_overzicht_loading').css('display', 'none');
							});
						}						
					}
			});
			
		}else{
			
			bestelFormPost(number);
		}
	});
}

function bestelFormPost(number) {
	
	$j('#afleveradres').attr('disabled', false);
	for(i in verplichte_velden_afleveradres){
			
		$j('#'+verplichte_velden_afleveradres[i]+'').attr('disabled', false);
	}

	//$j('#land').attr('disabled', false);
	var number 			= Number(number);
	
	var form 			= $j('#form_gegevens').serialize();
	var bestelmethode	= $j('input[name=bestel_methode]:checked').val();
	
	if(bestelmethode == undefined){
		
		var bestelmethode = 'gast';
	}
	
	$j('#gegevens_main_wrapper_'+(number + 1)+'').addClass('gegevens_main_wrapper_active');
	$j('#gegevens_sub_'+(number + 1)+'').addClass('gegevens_main_wrapper_active');
	$j('#gegevens_sub_'+(number)+'').addClass('gegevens_main_wrapper_active');
	$j('#gegevens_sub_'+(number)+' a').removeClass('hide');		
	$j('#account_edit_'+number+'').removeClass('hide');
	
	var ingelogd = $j('#ingelogd').val();
	
	if(ingelogd == undefined){
		
		ingelogd = 0;
	}
	
	if(ingelogd == 0){
		
		$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
				 type: "POST",
				 data: form+'&action=addKlantOrderTmp',
				 success: function(response){
							
					getKlantOrderTmp();
					$j('#gegevens_main_'+(number + 1)+'').show("blind", { direction: "vertical" }, 750);
					
					if(number == 100){
						
						lastStep();
					}
					//$j('#bestel_overzicht_loading').css('display', 'none');
				}
		});
	}

	if(ingelogd == 1){
		
		$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
				 type: "POST",
				 data: form+'&action=addKlantOrderTmp',
				 success: function(response){
							
					getKlantOrderIngelogd();
					$j('#gegevens_main_'+(number + 1)+'').show("blind", { direction: "vertical" }, 750);
							
					//$j('#bestel_overzicht_loading').css('display', 'none');
				}
		});
	}
	
	//$j('#land').attr('disabled', true);
	$j('#afleveradres').attr('disabled', true);
	for(i in verplichte_velden_afleveradres){
			
		$j('#'+verplichte_velden_afleveradres[i]+'').attr('disabled', true);
	}	
}

function bestelPrevStep(number){
	
	var number = Number(number);
	
	$j('.gegevens_main_content_container').each(function(){
		
		var id_css = $j(this).attr("id");
		
		if(document.getElementById(id_css).style.display != "none"){
			
			$j(this).hide("blind", { direction: "vertical" }, 750,function(){
				
				$j('#gegevens_main_'+(number)+'').show("blind", { direction: "vertical" }, 750);
				
			});
		}
	});
	
	$j('.gegevens_main_wrapper').each(function(){
		
		$j(this).removeClass('gegevens_main_wrapper_active');
	});

	$j('.gegevens_main_wrapper .actions a, .gegevens_main_wrapper .edit a').each(function(){
		
		$j(this).addClass('hide');
	});

	for(i = 1; i <= number; i++){
			
		$j('#gegevens_main_wrapper_'+(i)+'').addClass('gegevens_main_wrapper_active');
		$j('#gegevens_sub_'+(i)+'').addClass('gegevens_main_wrapper_active');
		if(number > i){
			
			$j('#account_edit_'+(i)+', #gegevens_sub_'+(i)+' a').removeClass('hide');
		}
	}
	
	for(i = 1; i < 4; i++){
		
		if(i > number){

			$j('#p_gegevens_sub_'+(i)+'').hide("blind", { direction: "vertical" }, 750);
		}
	}

	$j('#afleveradres').attr('disabled', false);
	for(i in verplichte_velden_afleveradres){
			
		$j('#'+verplichte_velden_afleveradres[i]+'').attr('disabled', false);
	}

//	if(number == 1){
//		
//		$j('#p_gegevens_sub_2').hide("blind", { direction: "vertical" }, 750);
//	}
}

function fillTav(){
	
	var voornaam		= $j('#voornaam').val();
	var tussenvoegsel	= $j('#tussenvoegsel').val();
	if(tussenvoegsel != ''){
		
		tussenvoegsel	= ' '+tussenvoegsel;
	}
	var achternaam		= $j('#achternaam').val();
	
	$j('#tav').val(voornaam+''+tussenvoegsel+' '+achternaam);
}

function verstuurFormOneStep(){

	var teller = 0;
	var bestelmethode			= $j('input[name=bestel_methode]:checked').val();
					
	for(i in verplichte_velden){
		
		if($j('#'+verplichte_velden[i]+'').val() == ''){
			
			teller++;
			$j('#'+verplichte_velden[i]+'').addClass('inputfield_error');
			$j('#error_'+verplichte_velden[i]+'').removeClass('hide');
		}else{
			
			$j('#'+verplichte_velden[i]+'').removeClass('inputfield_error');
			$j('#error_'+verplichte_velden[i]+'').addClass('hide');
		}
				
		if(isValidEmailAddress($j('#email_adres').val())){
			
			$j('#email_adres').removeClass('inputfield_error');
			$j('#error_email_adres').addClass('hide');
		}else{

			teller++;
			$j('#email_adres').addClass('inputfield_error');
			$j('#error_email_adres').removeClass('hide');
		}
		
		if(bestelmethode == 'registreer'){
			
			if($j('#wachtwoord_1_registreer').val() == '' || $j('#wachtwoord_1_registreer').val().length < 4){
				
				teller++;
				$j('#wachtwoord_1_registreer').addClass('inputfield_error');
				$j('#error_wachtwoord_1_registreer').removeClass('hide');
			}else{
				
				$j('#wachtwoord_1_registreer').removeClass('inputfield_error');
				$j('#error_wachtwoord_1_registreer').addClass('hide');
			}
			
			if($j('#wachtwoord_1_registreer').val() != '' && $j('#wachtwoord_2_registreer').val() == ''){
				
				teller++;
				$j('#wachtwoord_2_registreer').addClass('inputfield_error');
				$j('#error_wachtwoord_2_registreer').removeClass('hide');
			}else{
				
				$j('#wachtwoord_2_registreer').removeClass('inputfield_error');
				$j('#error_wachtwoord_2_registreer').addClass('hide');
				
				if($j('#wachtwoord_1_registreer').val() != $j('#wachtwoord_2_registreer').val()){
					
					teller++;
					$j('#wachtwoord_2_registreer').addClass('inputfield_error');
					$j('#error_wachtwoord_2_registreer').removeClass('hide');
				}else{

					$j('#wachtwoord_2_registreer').removeClass('inputfield_error');
					$j('#error_wachtwoord_2_registreer').addClass('hide');
				}
			}						
		}
	}
	
//		if(isAlphanumeric('adres')){
//			
//			alert('1');
//			
//		}else{
//			
//			alert('2');
//		}
	
	
	if($j('input[name=afleveradres]').is(':checked')){
		
		for(i in verplichte_velden_afleveradres){
			
			if($j('#'+verplichte_velden_afleveradres[i]+'').val() == ''){
				
				teller++;
				$j('#'+verplichte_velden_afleveradres[i]+'').addClass('inputfield_error');
				$j('#error_'+verplichte_velden_afleveradres[i]+'').removeClass('hide');
			}else{
				
				$j('#'+verplichte_velden_afleveradres[i]+'').removeClass('inputfield_error');
				$j('#error_'+verplichte_velden_afleveradres[i]+'').addClass('hide');
			}
		}
	}
	
	if(teller == 0){
		
		bestelFormPost('100');
	}else{
		
		alert(teller);
	}
}

function checkboxNieuwsbriefAanmelden() {
	
	if($j('#checkbox_nieuwsbrief_aanmelden').is(':checked')){
		
		$j('#nieuwsbrief_aanmelden').val(1);
	}else{
		
		$j('#nieuwsbrief_aanmelden').val(0);
	}
}

function verstuurForm(){

	var teller = 0;
	var bestelmethode			= $j('input[name=bestel_methode]:checked').val();
					
	for(i in verplichte_velden){
		
		if($j('#'+verplichte_velden[i]+'').val() == ''){
			
			teller++;
			$j('#'+verplichte_velden[i]+'').addClass('inputfield_error');
			$j('#error_'+verplichte_velden[i]+'').removeClass('hide');
		}else{
			
			$j('#'+verplichte_velden[i]+'').removeClass('inputfield_error');
			$j('#error_'+verplichte_velden[i]+'').addClass('hide');
		}
				
		if(isValidEmailAddress($j('#email_adres').val())){
			
			$j('#email_adres').removeClass('inputfield_error');
			$j('#error_email_adres').addClass('hide');
		}else{

			teller++;
			$j('#email_adres').addClass('inputfield_error');
			$j('#error_email_adres').removeClass('hide');
		}
				
		if(bestelmethode == 'registreer'){
			
			if($j('#wachtwoord_1_registreer').val() == '' || $j('#wachtwoord_1_registreer').val().length < 4){
				
				teller++;
				$j('#wachtwoord_1_registreer').addClass('inputfield_error');
				$j('#error_wachtwoord_1_registreer').removeClass('hide');
			}else{
				
				$j('#wachtwoord_1_registreer').removeClass('inputfield_error');
				$j('#error_wachtwoord_1_registreer').addClass('hide');
			}
			
			if($j('#wachtwoord_1_registreer').val() != '' && $j('#wachtwoord_2_registreer').val() == ''){
				
				teller++;
				$j('#wachtwoord_2_registreer').addClass('inputfield_error');
				$j('#error_wachtwoord_2_registreer').removeClass('hide');
			}else{
				
				$j('#wachtwoord_2_registreer').removeClass('inputfield_error');
				$j('#error_wachtwoord_2_registreer').addClass('hide');
				
				if($j('#wachtwoord_1_registreer').val() != $j('#wachtwoord_2_registreer').val()){
					
					teller++;
					$j('#wachtwoord_2_registreer').addClass('inputfield_error');
					$j('#error_wachtwoord_2_registreer').removeClass('hide');
				}else{

					$j('#wachtwoord_2_registreer').removeClass('inputfield_error');
					$j('#error_wachtwoord_2_registreer').addClass('hide');
				}
			}						
		}
	}

	if($j('#bedrijf_registreren').is(':checked')){
		
		for(i in verplichte_velden_bedrijf){

			if($j('#'+verplichte_velden_bedrijf[i]+'').val() == ''){
				
				teller++;
				$j('#'+verplichte_velden_bedrijf[i]+'').addClass('inputfield_error');
				$j('#error_'+verplichte_velden_bedrijf[i]+'').removeClass('hide');
			}else{
				
				$j('#'+verplichte_velden_bedrijf[i]+'').removeClass('inputfield_error');
				$j('#error_'+verplichte_velden_bedrijf[i]+'').addClass('hide');
			}
		}
	}else{
		
		if(window.verplichte_velden_bedrijf != undefined){
			
			for(i in verplichte_velden_bedrijf){
	
				$j('#'+verplichte_velden_bedrijf[i]+'').removeClass('inputfield_error');
				$j('#error_'+verplichte_velden_bedrijf[i]+'').addClass('hide');
			}
		}
	}

	if($j('input[name=afleveradres]').is(':checked')){
		
		for(i in verplichte_velden_afleveradres){
			
			if($j('#'+verplichte_velden_afleveradres[i]+'').val() == ''){
				
				teller++;
				$j('#'+verplichte_velden_afleveradres[i]+'').addClass('inputfield_error');
				$j('#error_'+verplichte_velden_afleveradres[i]+'').removeClass('hide');
			}else{
				
				$j('#'+verplichte_velden_afleveradres[i]+'').removeClass('inputfield_error');
				$j('#error_'+verplichte_velden_afleveradres[i]+'').addClass('hide');
			}
		}
		
		var id_aflevermethode_extra_optie_value	= $j('#id_aflevermethode_extra_optie_value').val();
		
		if(id_aflevermethode_extra_optie_value == 1){
		
			var check_pakjegemak = strstr($j('#tav').val(), 'Postkantoor');

			$j('#tav').removeClass('inputfield_error');
			$j('#error_tav').addClass('hide');

			if(check_pakjegemak == false){
				
				alert('Er is geen juiste postkantoor gekozen.\nGebruik de locatiekiezer om een postkantoor te selecteren.');
				$j('#tav').addClass('inputfield_error');
				$j('#error_tav').removeClass('hide');
				teller++;
			}
		
		}
		
		if(teller == 0){
			
			bestelFormStep('2');
		}
	}

	var form_p_c				= $j('#form_p_c').val();
		
	if(form_p_c != undefined && form_p_c == 1){

		if($j('#postcode').val() != ''){
			
			var postcode_check		= $j('#postcode').val();
			if($j('input[name=afleveradres]').is(':checked')){
				
				var postcode_check	= $j('#bezorgpostcode').val();
			}
			var form_p_c				= $j('#form_p_c').val();
			
			if(form_p_c != undefined && form_p_c == 1){
				
				if(GBrowserIsCompatible())
				{
					var naar = postcode_check+",Nederland";
					gdir = new GDirections();
					GEvent.addListener(gdir, "load", onGDirectionsLoadGegevensForm);
					gdir.load("from: "+start+" to: "+naar, { "locale": taal });
				}
			}
		}
		
		$j('#form_p_c_step').val(teller);
		
	}else if($j('#adres').val() != ''){

		if(teller == 0){
					
			bestelFormStep('2');
		}else{
			
			$j('html,body').animate({scrollTop:0},'slow', function(){

			});
			
			alert('Niet alle velden zijn (juist) ingevuld!');
		}
	}else{

		if(teller == 0){
			
			bestelFormStep('2');
		}else{
	
			$j('html,body').animate({scrollTop:0},'slow', function(){

			});

			alert('Niet alle velden zijn (juist) ingevuld!');
		}
	}
}

function onGDirectionsLoadGegevensForm(){
	
	var km = gdir.getDistance().meters / 1000;
	km = Math.round(km);

	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'addModifyRitAfstand',
															  km: km},function(data){
		
		//$j('#form_p_c_step').val(data.afrekenen_mogelijk);
		loadWinkelwagenOverzicht('overzicht','TRUE');	
		//verstuurForm();
		if($j('#form_p_c_step').val() == 0 && data.afrekenen_mogelijk == 1){
			
			bestelFormStep('2');
		}
		if(data.afrekenen_mogelijk == 0){
			
			$j('#minimaal_order_bedrag_checkout').css('display', 'block');
			$j('#minimaal_order_bedrag_html').html(data.minimaal_order_bedrag);
			
			var form 			= $j('#form_gegevens').serialize();
			
			var ingelogd = $j('#ingelogd').val();
			
			if(ingelogd == undefined){
				
				ingelogd = 0;
			}
			
			if(ingelogd == 0){
				
				$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
						 type: "POST",
						 data: form+'&action=addKlantOrderTmp',
						 success: function(response){}
				});
			}
		
			if(ingelogd == 1){
				
				$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
						 type: "POST",
						 data: form+'&action=addKlantOrderTmp',
						 success: function(response){}
				});
			}

		}
		
	}, 'json');	
}

function lastStep() {
	
	$j('#bestel_overzicht_loading').css('display', 'block');
	
	var nieuwsbrief_aanmelden 	= $j('#nieuwsbrief_aanmelden').val();
	if(nieuwsbrief_aanmelden == undefined){
		
		nieuwsbrief_aanmelden	= 0
	}
		
	var alg_voorwaarden = $j('#algemene_voorwaarden').val();

	var url = root_site+"order.html";

	if(vars_lang != 'nl'){
		
		url		= root_site+vars_lang+'/order.html';
	}

	if(shop_type == 'zakelijk'){
				
		var url	= root_site+"zakelijk/order.html";

		if(vars_lang != 'nl'){
			
			url		= root_site+'zakelijk/'+vars_lang+'/order.html';
		}
	}

	if(alg_voorwaarden != undefined){
		if($j('input[name=algemene_voorwaarden]').is(':checked')){
			
			var alg_voorwaarden_afterpay = $j('#algemene_voorwaarden_afterpay').val();
			
			if(alg_voorwaarden_afterpay != undefined){
				
				if(! $j('input[name=algemene_voorwaarden_afterpay]').is(':checked')){
					
				alert("U moet akkoord gaan met de algemene voorwaarden van Afterpay om een bestelling te plaatsen.");
				$j('#bestel_overzicht_loading').css('display', 'none');
					return false;
				}
			}
			
			window.location = url+'?nieuwsbrief_aanmelden='+nieuwsbrief_aanmelden+'';
			
		}else{
			
			alert("U moet akkoord gaan met de algemene voorwaarden om een bestelling te plaatsen.");
			$j('#bestel_overzicht_loading').css('display', 'none');
		}
	}
	if(alg_voorwaarden == undefined){

//		var alg_voorwaarden_afterpay = $j('#algemene_voorwaarden_afterpay').val();
//			
//		if(alg_voorwaarden_afterpay != undefined){
//				
//			if(! $j('input[name=algemene_voorwaarden_afterpay]').is(':checked')){
//					
//			alert("U moet akkoord gaan met de algemene voorwaarden van Afterpay om een bestelling te plaatsen.");
//			$j('#bestel_overzicht_loading').css('display', 'none');
//				return false;
//			}
//		}

		window.location = url+'?nieuwsbrief_aanmelden='+nieuwsbrief_aanmelden+'';
	}
}

function lastStepKlarna() {

	$j('#bestel_overzicht_loading').css('display', 'block');

	var url = root_site+"order.html";

	if(vars_lang != 'nl'){
		
		url		= root_site+vars_lang+'/order.html';
	}

	if(shop_type == 'zakelijk'){
				
		var url	= root_site+"zakelijk/order.html";

		if(vars_lang != 'nl'){
			
			url		= root_site+'zakelijk/'+vars_lang+'/order.html';
		}
	}

	var url_bestellen 		= root_site+"bestellen.html";

	if(vars_lang != 'nl'){
		
		url_bestellen		= root_site+vars_lang+'/bestellen.html';
	}

	if(shop_type == 'zakelijk'){
				
		var url_bestellen	= root_site+"zakelijk/bestellen.html";

		if(vars_lang != 'nl'){
			
			url_bestellen	= root_site+'zakelijk/'+vars_lang+'/bestellen.html';
		}
	}

	var nieuwsbrief_aanmelden 	= $j('#nieuwsbrief_aanmelden').val();
	if(nieuwsbrief_aanmelden == undefined){
		
		nieuwsbrief_aanmelden	= 0
	}
		
	var alg_voorwaarden = $j('#algemene_voorwaarden').val();

	if(alg_voorwaarden != undefined){
		if($j('input[name=algemene_voorwaarden]').is(':checked')){
			
			var alg_voorwaarden_klarna = $j('#algemene_voorwaarden_klarna').val();
			
			if(alg_voorwaarden_klarna != undefined){
				
				if(! $j('input[name=algemene_voorwaarden_klarna]').is(':checked')){
					
				alert("U moet akkoord gaan met de algemene voorwaarden van Klarna om een bestelling te plaatsen.");
				$j('#bestel_overzicht_loading').css('display', 'none');
					return false;
				}
			}
			
			$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'orderKlarna',
																	  nieuwsbrief_aanmelden: nieuwsbrief_aanmelden},function(data){
				
				if(data.status == 0){
					
					alert('Niet alle velden zijn juist ingevuld.\nHet kan zijn dat de ingevoerde velden niet volledig of ongeldig zijn.\n\nControleer uw gegevens en probeer het opnieuw.');
					
					if(data.error_field == 'postcode'){

						$j('#postcode').addClass('inputfield_error');
						$j('#error_postcode').removeClass('hide');
					}
					
					if(data.error_field == 'telefoonnummer'){

						$j('#telefoonnummer').addClass('inputfield_error');
						$j('#error_telefoonnummer').removeClass('hide');
					}

					if(data.error_field == 'straat'){

						$j('#straatnaam').addClass('inputfield_error');
						$j('#error_straatnaam').removeClass('hide');
					}

					if(data.error_field == 'huisnummer'){

						$j('#huisnummer').addClass('inputfield_error');
						$j('#error_huisnummer').removeClass('hide');
					}

					if(data.error_field == 'adres'){

						$j('#straatnaam').addClass('inputfield_error');
						$j('#error_straatnaam').removeClass('hide');
						$j('#huisnummer').addClass('inputfield_error');
						$j('#error_huisnummer').removeClass('hide');
					}

					if(data.error_field == 'plaats'){

						$j('#plaats').addClass('inputfield_error');
						$j('#error_plaats').removeClass('hide');
					}

					if(data.error_field == 'geboortedatum'){

						$j('#geboortedatum_dag').addClass('inputfield_error');
						$j('#geboortedatum_maand').addClass('inputfield_error');
						$j('#geboortedatum_jaar').addClass('inputfield_error');
						$j('#error_geboortedatum_dag').removeClass('hide');
					}

					bestelPrevStep('2');
					$j('#bestel_overzicht_loading').css('display', 'none');
				}
				
				else if(data.status == 1){
					
					window.location = url+'?nieuwsbrief_aanmelden='+nieuwsbrief_aanmelden+'';
				}
				else if(data.status == 3){
					
					alert(data.msg);
					window.location = url_bestellen;
				}				
				else{
					
					alert('Er is een probleem ontstaan in de communicatie met Klarna, dat ons factureringssysteem beheert.\nGelieve contact op te nemen met Klarna (http://www.klarna.nl) voor meer informatie, of kies een andere betalingswijze.');
					$j('#bestel_overzicht_loading').css('display', 'none');
				}	
			}, 'json');
			
		}else{
			
			alert("U moet akkoord gaan met de algemene voorwaarden om een bestelling te plaatsen.");
			$j('#bestel_overzicht_loading').css('display', 'none');
		}
	}
	
	if(alg_voorwaarden == undefined){

		var alg_voorwaarden_klarna = $j('#algemene_voorwaarden_klarna').val();
			
		if(alg_voorwaarden_klarna != undefined){
				
			if(! $j('input[name=algemene_voorwaarden_klarna]').is(':checked')){
					
			alert("U moet akkoord gaan met de algemene voorwaarden van Klarna om een bestelling te plaatsen.");
			$j('#bestel_overzicht_loading').css('display', 'none');
				return false;
			}
		}
			
		$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'orderKlarna',
																	  nieuwsbrief_aanmelden: nieuwsbrief_aanmelden},function(data){
				
			if(data.status == 0){
					
				alert('Niet alle velden zijn juist ingevuld');
					
				if(data.error_field == 'postcode'){

					$j('#postcode').addClass('inputfield_error');
					$j('#error_postcode').removeClass('hide');
				}
					
				if(data.error_field == 'telefoonnummer'){

					$j('#telefoonnummer').addClass('inputfield_error');
					$j('#error_telefoonnummer').removeClass('hide');
				}
					
				bestelPrevStep('2');
				$j('#bestel_overzicht_loading').css('display', 'none');
			}
				
			if(data.status == 1){
					
				window.location = url+'?nieuwsbrief_aanmelden='+nieuwsbrief_aanmelden+'';
			}
			if(data.status == 3){
					
				alert(data.msg);
				window.location = url_bestellen;
			}				
				
		}, 'json');
	}
}

function inloggen() {
	
	$j('#error_inloggen').addClass('hide');
	setBestelOverzichtLoading();
	
	$j('#error_inloggen').addClass('hide');
	
	var login_name		= $j('#login_name').val();
	var password		= $j('#password').val();
	
	if(login_name == ''){
		
		$j('#error_inloggen').removeClass('hide');
		return;
	}
	
	if(password == ''){
		
		$j('#error_inloggen').removeClass('hide');
		return;
	}	

	$j('#bestel_overzicht_loading').css('display', 'block');

		$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
				 type: "POST",
				 data: 'action=loginKlant&login='+login_name+'&password='+md5(password)+'',
				 success: function(response){
					
					if(response == false){
						
						$j('#ingelogd').val(0);
						$j('#error_inloggen').removeClass('hide');	
					}
					if(response == true){
						
						ingelogd();
						loadWinkelwagenOverzicht('overzicht','TRUE');
					}
					
					$j('#bestel_overzicht_loading').css('display', 'none');
				}
		});
}

function inloggenMain(type) {
	
	if(type == 1){
		
		var login_name		= $j('#email_adres_login_main').val();
		var password		= $j('#wachtwoord_login_main').val();
	}
	
	if(type == 2){
		
		var login_name		= $j('#email_adres_login_account').val();
		var password		= $j('#wachtwoord_login_account').val();
	}

	if(type == 3){
		
		var login_name		= $j('#email_adres_login_blok').val();
		var password		= $j('#wachtwoord_login_blok').val();
	}

	var bewaren				= $j('#bewaren_main').val();
	
	if(login_name == ''){
		
		alert("Niet alle velden zijn ingevuld!");
		return;
	}
	
	if(password == ''){
		
		alert("Niet alle velden zijn ingevuld!");
		return;
	}	
	
	$j('#login_index_btn').css('display', 'none');
	$j('#login_index_loading').css('display', 'block');
	$j('#bestel_overzicht_loading').css('display', 'block');
	
		$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
				 type: "POST",
				 data: 'action=loginKlant&login='+login_name+'&password='+md5(password)+'&bewaren='+bewaren+'',
				 success: function(response){
					
					if(response == false){
						
						$j('#login_index_btn').css('display', 'block');
						$j('#login_index_loading').css('display', 'none');
						$j('#bestel_overzicht_loading').css('display', 'none');

						var url = root_site+"account.html";
						
						if(shop_type == 'zakelijk'){
							
							var url	= root_site+"zakelijk/account.html";
						}
				
						window.location = url+"?do=false&login="+login_name+"";	
					}
					if(response == true){
						
						$j.get(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'getLoginType'},function(data){
							
							//$j('#login_index_content').hide("blind", { direction: "vertical" }, 500);
							//$j('#login_index').addClass('hide');
							//$j('#ingelogd_index').removeClass('hide');
							//$j('#ingelog_html').html(''+trim(data)+'');
							if(data == 1){
								
								window.location = root_site+"zakelijk/";
							}
							else{
								
								window.location = root_site+"";
							}
							//window.location = root_site+"account.html";
						});
					}					
				}
		});
	
}

function ingelogd() {
	
	$j('input[name="bestel_methode"]').each(function(){
		
		$j(this).attr('checked', false);
	});
	
	$j('#error_inloggen').addClass('hide');
						
	$j('#p_inlogscherm').empty();
						
	$j.get(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'getLoginInfo'},function(data){
		
		$j('#gegevens_main_content_left_loading').removeClass('hide');
		$j('#ingelogd').val(1);
							
			var html = '<strong>'+data+'</strong><br />Uw bent succesvol ingelogd!<br /><br /><a href="javascript:uitloggen(\'2\');" class="link">Uitloggen</a><br /><a href="javascript:bestelFirstStepIngelogd(\'1\');" class="btn_alg1" style="float:left; margin-top:35px;*margin-top:40px;">Doorgaan</a>';
			$j('#p_inlogscherm').html(html);
							
			//bestelFirstStepIngelogd('1');
	});
}

function uitloggen(action) {
	
	$j.post(''+root_site+'docs/ajaxrequest/cart_request.php',{action: 'getLogout'},function(data){
		
		if(action == 1){
			
			var url = root_site+"account.html";
			
			if(shop_type == 'zakelijk'){
				
				var url	= root_site+"zakelijk/account.html";
			}
			
			window.location = url;
		}
		
		if(action == 2){

			var url = root_site+"gegevens.html";
			
			if(shop_type == 'zakelijk'){
				
				var url	= root_site+"zakelijk/gegevens.html";
			}

			window.location = url;
		}
	});
}

function sendForgotPassword() {
	
	var email	= $j('#email_wachtwoord_request').val();
	
	if(email == ''){
		
		alert("Er is geen e-mail adres ingevuld!");
		return;
	}
		
		$j('#bestel_overzicht_loading').css('display', 'none');
		
		$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
				 type: "POST",
				 data: 'action=sendForgottPassword&email='+email+'',
				 success: function(response){
					
					if(trim(response) != ''){
						
						$j('#div_forgott_wachtwoord').empty();
						$j('#div_forgott_wachtwoord').html(response);
						$j('#bestel_overzicht_loading').css('display', 'none');
					}if(trim(response) == ''){
						
						$j('#bestel_overzicht_loading').css('display', 'none');
						alert('Aanvragen nieuw wachtwoord niet gelukt.\n\nHet opgegeven e-mail adres is bij ons niet bekend.');
					}
				}
		});		
}

function setBestelOverzichtLoading() {
	
	var height = $j('#gegevens_main_left').height();
	
	//$j('#bestel_overzicht_loading-bg').css('height', height);
}

function changeFormRegistrerenZakelijk() {
	
	if($j('#zakelijk_registreren').is(':checked')){
		
		$j('#div_table_registreren_zakelijk').slideDown(500);
	}else{
		
		$j('#div_table_registreren_zakelijk').slideUp(500);
	}
}

function changeFormRegistrerenBedrijf() {
	
	if($j('#bedrijf_registreren').is(':checked')){
		
		$j('#div_table_registreren_bedrijf').slideDown(500);
	}else{
		
		$j('#div_table_registreren_bedrijf').slideUp(500);
	}
}

function checkFormRegistreren(){
	
	var teller = 0;
					
	for(i in verplichte_velden){
		
		if($j('#'+verplichte_velden[i]+'').val() == ''){
			
			teller++;
			$j('#'+verplichte_velden[i]+'').addClass('inputfield_error');
			$j('#error_'+verplichte_velden[i]+'').removeClass('hide');
		}else{
			
			$j('#'+verplichte_velden[i]+'').removeClass('inputfield_error');
			$j('#error_'+verplichte_velden[i]+'').addClass('hide');
		}
		
		if(isValidEmailAddress($j('#email_adres').val())){
			
			$j('#email_adres').removeClass('inputfield_error');
			$j('#error_email_adres').addClass('hide');
		}else{

			teller++;
			$j('#email_adres').addClass('inputfield_error');
			$j('#error_email_adres').removeClass('hide');
		}
	}
			if($j('#wachtwoord_1_registreer').val() == '' || $j('#wachtwoord_1_registreer').val().length < 4){
				
				teller++;
				$j('#wachtwoord_1_registreer').addClass('inputfield_error');
				$j('#error_wachtwoord_1_registreer').removeClass('hide');
			}else{
				
				$j('#wachtwoord_1_registreer').removeClass('inputfield_error');
				$j('#error_wachtwoord_1_registreer').addClass('hide');
			}
			
			if($j('#wachtwoord_1_registreer').val() != '' && $j('#wachtwoord_2_registreer').val() == ''){
				
				teller++;
				$j('#wachtwoord_2_registreer').addClass('inputfield_error');
				$j('#error_wachtwoord_2_registreer').removeClass('hide');
			}else{
				
				$j('#wachtwoord_2_registreer').removeClass('inputfield_error');
				$j('#error_wachtwoord_2_registreer').addClass('hide');
				
				if($j('#wachtwoord_1_registreer').val() != $j('#wachtwoord_2_registreer').val()){
					
					teller++;
					$j('#wachtwoord_2_registreer').addClass('inputfield_error');
					$j('#error_wachtwoord_2_registreer').removeClass('hide');
				}else{

					$j('#wachtwoord_2_registreer').removeClass('inputfield_error');
					$j('#error_wachtwoord_2_registreer').addClass('hide');
				}
			}
	if($j('#zakelijk_registreren').is(':checked')){
		
		for(i in verplichte_velden_zakelijk){

			if($j('#'+verplichte_velden_zakelijk[i]+'').val() == ''){
				
				teller++;
				$j('#'+verplichte_velden_zakelijk[i]+'').addClass('inputfield_error');
				$j('#error_'+verplichte_velden_zakelijk[i]+'').removeClass('hide');
			}else{
				
				$j('#'+verplichte_velden_zakelijk[i]+'').removeClass('inputfield_error');
				$j('#error_'+verplichte_velden_zakelijk[i]+'').addClass('hide');
			}
		}
	}

	if($j('#bedrijf_registreren').is(':checked')){
		
		for(i in verplichte_velden_bedrijf){

			if($j('#'+verplichte_velden_bedrijf[i]+'').val() == ''){
				
				teller++;
				$j('#'+verplichte_velden_bedrijf[i]+'').addClass('inputfield_error');
				$j('#error_'+verplichte_velden_bedrijf[i]+'').removeClass('hide');
			}else{
				
				$j('#'+verplichte_velden_bedrijf[i]+'').removeClass('inputfield_error');
				$j('#error_'+verplichte_velden_bedrijf[i]+'').addClass('hide');
			}
		}
	}

	$j('html,body').animate({scrollTop:0},'slow', function(){
		
	});

	if(teller == 0){
		
		verstuurFormRegistreren();
	}
}

function verstuurFormRegistreren(){

	var form 			= $j('#form_gegevens').serialize();
	var email 			= $j('#email_adres').val();
	
	$j('#bestel_overzicht_loading').css('display', 'block');
	
			//Check of aanmelding al bestaat
			$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
					 type: "POST",
					 data: form+'&action=checkAanmelding',
					 success: function(response){
						
						if(trim(response) == true){
							
//							alert($j('#id_shop_type').val());
							$j.ajax({url: ''+root_site+'docs/ajaxrequest/cart_request.php',
									 type: "POST",
									 data: form+'&action=addAanmelding',
									 success: function(response){
										
										$j('#error_registreren').addClass('hide');
										$j('#contact_form_content').empty();
										$j('#contact_form_content').html(response);
										$j('#bestel_overzicht_loading').css('display', 'none');
									}
							});
						}
						if(trim(response) == false){
							
							$j('#error_registreren').removeClass('hide');
							var email = $j('#email_adres').val();
							
							html = 'Er is reeds een account gevonden met het opgegeven e-mail adres <strong>'+email+'</strong>.<br />Mocht u uw wachtwoord zijn vergeten, dan kunt u <a href="'+root_site+'registreren.html?action=forgottpassword">hier klikken</a> om een nieuw wachtwoord op te vragen.<br /><br /><i>(Het is mogelijk dat u uw account nog moet activeren. U heeft hierover een e-mail bericht gekregen.<br />Controleer uw e-mail inbox of <a href="'+root_site+'activeren.html?action=activicatie_mail&email='+email+'">klik hier</a> om de activeringsmail opnieuw te ontvangen.)<br /></i>';
							$j('#error_registreer_msg').html(html);
							
							$j('#bestel_overzicht_loading').css('display', 'none');
						}						
					}
			});		
}

function addOptionAttributen(id, bestel_value, aantal){
	
	var bestel_value = bestel_value;

	$j('#td_attributen_'+id+' .aantal_select_attributen').each(function() {
	
		$j(this).remove();
	});
	$j('#td_attributen_'+id+' .aantal_span_attributen').each(function() {
	
		$j(this).remove();
	});
	
	var option_selects	= eval(bestel_value * aantal);
	
	if(bestel_value == 1){
		
		//option_selects	= aantal;
	}
	
	for (i=2;i<=option_selects;i++){
		$j('#td_attributen_'+id+'').append('<span class="span_attributen_'+id+' aantal_span_attributen hide">Pot '+i+':</span><select name="select[select][]" id="select_'+id+'>" class="class_product_attributen_'+id+' aantal_select_attributen">'+attribuut_naam_option_array_select_300[id]+'</select>');
	}
	
	$j('.span_attributen_'+id+'').removeClass('hide');
	
	if(aantal == 0){
			
		$j('.span_attributen_'+id+'').addClass('hide');		
	}
	if($j('#count_attributen_'+id+'').val() == 1){
		
		$j('.span_attributen_'+id+'').addClass('hide');		
	}
}


