function makeSublist(parent,child,isSubselectOptional,childVal)
{
	$("body").append("<select style='display:none' id='"+parent+child+"'></select>");
	$('#'+parent+child).html($("#"+child+" option"));

		var parentValue = $('#'+parent).attr('value');
		$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());

	childVal = (typeof childVal == "undefined")? "" : childVal ;
	$("#"+child+' option[@value="'+ childVal +'"]').attr('selected','selected');

	$('#'+parent).change( 
		function()
		{
			var parentValue = $('#'+parent).attr('value');
			$('#'+child).html($("#"+parent+child+" .sub_"+parentValue).clone());
			if(isSubselectOptional) $('#'+child).prepend("<option value='none'> -- Select -- </option>");
			$('#'+child).trigger("change");
						$('#'+child).focus();
		}
	);
}

$(document).ready(function()
{
	makeSublist('age','period', false, '1');	
});



function calculate(age, period, exchange) {
$.ajax(
		{
			type: "POST",
			url: "fileadmin/php/calculate.php",
			data: "age=" + age + "&period=" + period + "&exchange=" + exchange,
			beforeSend: function() {
			},

			success: function(txt) {
				$('#result').html(txt);
			},

			error: function(txt) {
			}
		}
	);
} 	
	
