jQuery(document).ready(function() {
								
								
	
			jQuery("#ajax_loading").hide();
			
						jQuery('#analysis').hide();
						jQuery('#yearlysalary').change(function(){
										var amt = jQuery('#yearlysalary').val();
										var formt = addCommas(amt);
										jQuery('#yearlysalary').val(formt);
												 });
			jQuery("#regis").validationEngine({
													
					success :  function() {
						
						jQuery('#regis').ajaxSubmit(function(data) { 
						//alert(data);
						
												if(data==123){
													jQuery('#loginform').hide();
													jQuery('#analysis').show();
													jQuery('#error').html('<div style="color:#FF0000">Retirement Age must be greater than current age</div>');
													jQuery('#result1').html('');
													}
												else{
													//jQuery('#ajax_loading').show();
													//jQuery('#ajax_loading').html('Processing...<br/><img src="images/loader.gif"/>');
													//setTimeout('loadresult('+data+')',3000);
													jQuery('#error').html('');
													jQuery('#nextstep').hide();
													jQuery('#loginform').hide();
													jQuery('#analysis').show();
													jQuery('#result1').html(data);
													scrollWin();
													
												}
												
				});
						
						
						},
					failure : function() { 
					//alert("fail"); 
					jQuery(".formError").css("display","block");
					setTimeout('clear_alert()',3000); 
					}
			});
			
								});


function loadresult(y){
	//alert(y);
//	jQuery('#analysis').show();
	document.getElementById("analysis").style.display="block";
				//jQuery('#ajax_loading').html('');
				document.getElementById("ajax_loading").innerHTML="";
				//jQuery('#ajax_loading').hide();
					document.getElementById("ajax_loading").style.display="none";
			//	jQuery('#error').html('');
				
				//jQuery('#result').html(data);
				document.getElementById('result1').innerHTML	=y;
				scrollWin();
				//jQuery('#nextstep').html('');
				//jQuery('#nextstep').html('<a href="budget.php"><img src="images/next.png" width="102" height="37" border="0" /></a>');
	
}

function addCommas(nStr)
{
	nStr += '';
	x = nStr.split('.');
	x1 = x[0];
	x1 =x1.replace(',','');
	x2 = x.length > 1 ? '.' + x[1] : '';
	var rgx = /(\d+)(\d{3})/;
	while (rgx.test(x1)) {
		x1 = x1.replace(rgx, '$1' + ',' + '$2');
	}
	return x1 + x2;
}

function scrollWin(){
jQuery('html, body').animate({
scrollTop: jQuery("#analysis").offset().top
}, 2000);
}		
		

