$(document).ready( function() {
	$("#compare").click( function() {
		$.ajax({
			type: "get",
			url: "process.php",
			data: "s1=" + $("#s1").val() + "&s2=" + $("#s2").val(),
			cache: false,
			async: true,
			beforeSend: function() {
				$("#status").html('Processing...please wait :)');
				//getStatus(true);
			},
			success: function(r) {
				getStatus();
			}
		});
		return false;
	});
});

function getStatus() {
	$.ajax({
		type: "get",
		url: "getStatus.php",
		cache: false,
		async: false,
		success: function(r) {
			$("#status").html(r);
			if (r == 'Done!') {
				getResults("1");
				getResults("2");
			}
		}
	});
}

function getResults(num) {
	$.ajax({
		type: "get",
		url: "getResults.php",
		data: "r=" + num,
		cache: false,
		success: function(r) {
			$("#m" + num).html(r);
		}
	});
}

