// JavaScript Document
function calculate () {
	var income = $('#income').val();
	var type = $('#type').val();
	var msg = "<p><span class='ui-icon ui-icon-alert' style='float: left; margin-right: .3em;'></span>Please check the following errors:-<ul>";
	var res = true;
	
	if(income.length == 0)
	{
		msg += "<li>Please enter the amount of income you actually received.</li>";
		res = false;
	}	
	
	msg += "</ul></p>";
	if(res == false)
	{
		$('#dialog').html(msg);
		$('#dialog').dialog('open');
		return false;
	}
	else{
		
		var a = type;
		var b = income;
		var r = 0;
		var s = 0;
		
		if (a == 1) r = (b / .8);
		if (a == 1) s = (b / 4);
	
		if (a == 2) r = (b / .9); 
		if (a == 2) s = (b / 9);
							
		$('#results').html("&pound;" + round(r));
		$('#results2').html("&pound;" + round(s));
		$('#result_area').show('slow');
	}
}
function round(x) {
	return Math.round(x*100)/100;
}