function KormosTgkWizard() {
}

KormosTgkWizard.prototype.compute = function() {
	var postData = {};
	postData.p = jQuery("#wizP").val();
	postData.n = jQuery("#wizN").val();
	//postData.i = jQuery("#wizI").val();
	postData.fs = jQuery("#wizFS").val();
	postData.d1 = jQuery("#wizD1").val();
	postData.d2 = jQuery("#wizD2").val();
	//alert(postData.toSource());
	
	this.clearSolution();
	
	var owner = this;
	
	jQuery.ajax({
		url: "/?page=AjaxKormosTgkWizard",
		data: postData,
        cache: false,
        complete: function(jsonResponse, stat){
      		if (stat == "success") { 
        		var toEval = "(" + jsonResponse.responseText + ")";
        		var theData = eval(toEval);
        		owner.showSolution(theData);
        	}
		}
    });
}

KormosTgkWizard.prototype.clearSolution = function() {
	jQuery("#yt").html('');
	jQuery("#y1").html('');
	jQuery("#y2").html('');
	jQuery("#rt").html('');
	jQuery("#r1").html('');
	jQuery("#r2").html('');
}

KormosTgkWizard.prototype.showSolution = function(d) {
	if (d.code != 0) {
		alert(d.msg);
	} else {
		jQuery("#yt").html(d.pieces[0].type);
		jQuery("#y1").html(d.pieces[0].halfD1);
		jQuery("#y2").html(d.pieces[0].halfD2);
		jQuery("#rt").html(d.pieces[1].type);
		jQuery("#r1").html(d.pieces[1].halfD1);
		jQuery("#r2").html(d.pieces[1].halfD2);
	}
}
