// A function to handle calculationg totals in the place ad page
// It calls the reCalculate action in the AdCalculate class (see AJAX/classes)
// Then passes the response to the processResponse functiion
function calculateTotal(newCost, checked) 
{
	var params	=	'new_cost=' + escape(newCost) + 
					'&module=AdCalculator' + 
					'&action=reCalculate' + 
					'&basead=' + document.getElementById('basead').innerHTML + 
					'&addons_subtotal=' + document.getElementById('addons_subtotal').innerHTML + 
					'&checked=' + (checked ? 1 : 0);
					
	YAHOO.util.Connect.asyncRequest('POST',
									'/ajax/?'+params,
									{
										'success': handleResponse,
										'failure': null
									});
}
	

// A function to handle the ajax response by spliting the response text
// then update the required fields.
function handleResponse(response)
{
	response_arr = response.responseText.split(",");
	
	document.getElementById('addons_subtotal').innerHTML = response_arr[ 0 ] ;
	document.getElementById('total').innerHTML = response_arr[ 1 ];
}

