$.initSelectbox = function() {			
			
	$('.selectbox').each( function(i,selectbox) {
		
		if($(".options",selectbox).height() > $(".select",selectbox).height() ) {
			$(".select",selectbox).addClass("scroll");
		}
		
		$(".select", this).hide();
				
		$(selectbox).click( function() {			
			$(this).addClass("is_active");
			$('.select',this).slideDown("normal");				
			if($('input[name="type"]',selectbox).val()=='input') {
				$('.options .option',selectbox).click(function(){					
					$('input[name="key"]',selectbox).val($('.key',this).html());
					$('input[name="value"]',selectbox).val($('.value',this).html());
					$('input[name="'+$('input[name="name"]',selectbox).val()+'"]',selectbox).val($('.value',this).html());
					
					$('.title',selectbox).html($('.key',this).html());
					
					//	controleren of vervoerder een keuze mag maken
					if ($('#verzendmethode_nl_h2').length) {
						
						//	check for afwijkend adres
						var adres = 'factuuradres[landcode]';
						if ($('#afwijkendadres').attr('checked')) {
							adres = 'afleveradres[landcode]';
						}
						
						if (adres == $('input[name="name"]',selectbox).val()) {
							if ($('.value',this).html() == 'NL') {
								$('#verzendmethode_nl_h2').show();
								$('#verzendmethode_nl_table').show();
							} else {
								$('#verzendmethode_nl_h2').hide();
								$('#verzendmethode_nl_table').hide();
							}
						}
					}
					
					$.hideSelectbox(selectbox);
				});
			} else if($('input[name="type"]',selectbox).val()=='link') {		
				$('.options .option',selectbox).click(function(){					
					location.href=$('.value',this).html();
					$.hideSelectbox(selectbox);
				});
			}						
			setTimeout(
				function(){
					$.hideSelectbox(selectbox);
				},
				50
			);
		});
		
		if($.trim($(".title",selectbox).html())=='') {
			$('input[name="key"]',selectbox).val($('.options .option:eq(0) .key',this).html());
			$('input[name="value"]',selectbox).val($('.options .option:eq(0) .value',this).html());
			$('input[name="'+$('input[name="name"]',selectbox).val()+'"]',selectbox).val($('.options .option:eq(0) .value',this).html());
			
			$('.title',selectbox).html($('.options .option:eq(0) .key',this).html());
		}
	});
	
	$.hideSelectbox = function(selectbox) {		
		$("body").bind("click", function() {
			$('.select',selectbox).slideUp("fast", function() {				
				$(selectbox).removeClass("is_active");
				$("body").unbind("click");				
			});				
		});
	} 
}
