$(document).ready(function() {
	$('#pointsresults').hide();
	$('#loadingimage').hide();
	$('#errorblock').hide();
    // bind form using ajaxForm 

    $('#checkpointsform').ajaxForm({ 
        dataType:  'xml', 
        beforeSubmit: loading,
        success:   pointsonlyresponse 
    }); 
});

function loading() {
	$('#pointsresults').hide();
	$('#errorblock').hide();
	$('#pointsbalance').text('');
	$('#loadingimage').fadeIn();
	$('#dollarvalue').text('');
}

function pointsonlyresponse(responseXML) { 
	// 'responseXML' is the XML document returned by the server; we use 
	// jQuery to extract the content of the message node from the XML doc 
	var bonusPoints = $('BonusPoints', responseXML).text(); 
	if (bonusPoints == '') {
		$('#loadingimage').hide();
		$('#errorblock').fadeIn();
	} else {
		$('#pointsbalance').text(bonusPoints);
		var bonusPointsValue = $('BonusPointsValue', responseXML).text(); 
		$('#dollarvalue').text('$'+bonusPointsValue);
		$('#loadingimage').hide();
		$('#pointsresults').fadeIn();
	}
}