/** 
 * Function called onChange on nobel:select with products 
 * that does the get request to our url and parses the result.
 */
function changeProductDenominations(){
	
    var product = document.getElementById("product.id").options[document.getElementById("product.id").selectedIndex].value;
    document.getElementById("denomination.id").value = 0;
    var automaticRechargeEnabledDisabled = document.getElementById("inventoryItemCallingCardAutorecharge.automaticRechargeEnabled.checkbox").checked;
    
	$.ajax({
		   type: "GET",
		   url: "/retail/pricing/viewProductDenominationsEmpty.htm",
		   data: ({ "product.id": product}),
		   success: function(data){
				document.getElementById("productDenominationSpanId").innerHTML=data;
		   		},
		   error: function(data,options,error){
				document.getElementById("productDenominationSpanId").innerHTML='Error Code '+data.status	
				}
		 });
	
	$.ajax({
		   type: "GET",
		   url: "/eshop/pricing/viewProductAutoRechargeDenominationEmpty.htm",
		   data: ({ "product.id": product}),
		   success: function(data){
				document.getElementById("refill-amount").innerHTML=data;
				document.getElementById("inventoryItemCallingCardAutorecharge.rechargeAmount.amount").disabled=!automaticRechargeEnabledDisabled;				
		   		},
		   error: function(data,options,error){
				document.getElementById("refill-amount").innerHTML='Error Code '+data.status	
				}
		 });
	
    $.ajax({
        type: "GET",
        url: "/eshop/pricing/viewProductAutoRechargeThresholdDenominationEmpty.htm",
        data: ({ "product.id": product}),
        success: function(data){
             document.getElementById("refill-threshold").innerHTML=data;
             document.getElementById("inventoryItemCallingCardAutorecharge.rechargeThreshold.amount").disabled=!automaticRechargeEnabledDisabled;
             },
        error: function(data,options,error){
             document.getElementById("refill-threshold").innerHTML='Error Code '+data.status    
             }
      });
}
