function CalculatePrice(parameters)
{
	callAjax('CalculatePrice', parameters, null, CalculatePriceRequest);
}

function CalculatePriceRequest(Request)
{
	try
    {
    	calculate_prices = ajax_unserialize(Request);
	}
	catch(e)
	{
	   	return false;
	}

	var index = calculate_prices['index'];
    for(NodeId in calculate_prices)
    {
       	if(NodeId == 'siteaccess' || NodeId == 'index')
       	{
       		continue;
       	}

		for(id in index)
		{
			if(index[id] == NodeId)
			{
				stock_el = document.getElementById('stock_'+id);
        		price_el = document.getElementById('price_'+id);
                staffel_el = document.getElementById('staffel_'+id);
                staffel_row_el = document.getElementById('staffel_row_'+id);

        		if(stock_el && price_el && staffel_el)
		        {
		        	if(!calculate_prices[NodeId])
		            {
		            	stock_el.innerHTML = '<img src="/design/'+calculate_prices['siteaccess']+'/images/navision_off.gif" alt="keine Auskunft" />';
		                price_el.innerHTML = '<img src="/design/'+calculate_prices['siteaccess']+'/images/anrufen2.gif" alt="keine Auskunft" />';
		                staffel_el.innerHTML = '';
		            }
		            else
		            {
		            	var product = calculate_prices[NodeId];
		                if(product['AVAILABILITY_NUMERIC'] == 0)
		                {
		                    stock_el.innerHTML = '<img src="/design/'+calculate_prices['siteaccess']+'/images/ver_nok.gif" alt="nicht auf Lager" />';
		                }
		                else
		                {
		                	stock_el.innerHTML = '<img src="/design/'+calculate_prices['siteaccess']+'/images/ver_ok.gif" alt="auf Lager" />';
		                }

		                if(product['AMOUNT'] != '-')
		                {
		                	price_el.innerHTML = ' '+product['AMOUNT'];
		               	}
		               	else
		               	{
		               		price_el.innerHTML = '<img src="/design/'+calculate_prices['siteaccess']+'/images/anrufen2.gif" alt="keine Auskunft" />';
		               	}

		               	if (product['STAFFEL'].length != 0)
		               	{
                            var staffelpreis = "";
                            
                            for ( var i=0; i < product['STAFFEL'].length; i++ )
                            {
                                staffelpreis = staffelpreis + "ab " + product['STAFFEL'][i]['MIN_QTY'] + ": " + product['STAFFEL'][i]['SALES_PRICE_CURRENCY'] + "<br />";
                            }
    		               	staffel_row_el.innerHTML = staffelpreis;
                            staffel_el.style.visibility="visible";
    		            }
		            }
		        }
			}
		}
	}
}
