<script type="text/javascript" charset="utf-8" src="<?php echo $this->getSkinUrl('kadobon/js/jquery-1.4.4.min.js');?>"></script>
<script>
jQuery.noConflict();

var loader='<div id="buckaroo_loader" style="float: left; display: inline-block;"><img src="<?php echo $this->getSkinUrl('kadobon/media/ajax-loader.gif');?>" /></div>';
var statuses_url='<?php echo $this->getUrl('admin_kadobon/adminhtml_statuses');?>';

jQuery(document).ready(function($){

	  $('#payment_kadobon_order_state_betaald').change(function() {
		    $('#payment_kadobon_order_status_betaald').attr('disabled',true);
		    $('#payment_kadobon_order_status_betaald').after(loader);

		    var state=$('#payment_kadobon_order_state_betaald').val();

		    $.getJSON(statuses_url,
		                   {'state': state},
		                   function(data)
		                   {
		                       var options='';

		                       for(var i=0; i<data.length; i++)
		                       {
		                           options+='<option value="'+data[i].value+'">'+data[i].label+'</option>'+"\n";
		                       }

		                       $('#payment_kadobon_order_status_betaald').empty();
		                       $('#payment_kadobon_order_status_betaald').html(options); 
		                       $('#payment_kadobon_order_status_betaald').attr('disabled',false);
		                       $('#buckaroo_loader').remove(); 
		                   }
		              );

		});

	    $('#payment_kadobon_order_state_wachten').change(function() {
	        $('#payment_kadobon_order_status_wachten').attr('disabled',true);
	        $('#payment_kadobon_order_status_wachten').after(loader);

	        var state=$('#payment_kadobon_order_state_wachten').val();
	        
	        $.getJSON(statuses_url,
	                {'state': state},
	                function(data)
	                {
	                    var options='';

	                    for(var i=0; i<data.length; i++)
	                    {
	                        options+='<option value="'+data[i].value+'">'+data[i].label+'</option>'+"\n";
	                    }

	                    $('#payment_kadobon_order_status_wachten').empty();
	                    $('#payment_kadobon_order_status_wachten').html(options); 
	                    $('#payment_kadobon_order_status_wachten').attr('disabled',false);
	                    $('#buckaroo_loader').remove(); 
	                }
	           );
	    }); 

	    $('#payment_kadobon_order_state_mislukt').change(function() {
	        $('#payment_kadobon_order_status_mislukt').attr('disabled',true);
	        $('#payment_kadobon_order_status_mislukt').after(loader);

	        var state=$('#payment_kadobon_order_state_mislukt').val();
	        
	        $.getJSON(statuses_url,
	                {'state': state},
	                function(data)
	                {
	                    var options='';

	                    for(var i=0; i<data.length; i++)
	                    {
	                        options+='<option value="'+data[i].value+'">'+data[i].label+'</option>'+"\n";
	                    }

	                    $('#payment_kadobon_order_status_mislukt').empty();
	                    $('#payment_kadobon_order_status_mislukt').html(options); 
	                    $('#payment_kadobon_order_status_mislukt').attr('disabled',false);
	                    $('#buckaroo_loader').remove(); 
	                }
	           );
	    }); 
    
});

</script>