/**
 * @author Kovacs Gabriel
 */

$(document).ready(function(){ 
		
		function ajax_total_plata(form_values) {
			$(".submitButton").attr("disabled", "disabled");
			
			$.ajax({ 
				type: "GET",
				url: "total_plata_echo.php",
				data: form_values,
				success: function(html){ //so, if data is retrieved, store it in html 
					//alert(html);
					$("#total-plata-echo").html(html); //show the html inside .content div 
					$(".submitButton").removeAttr("disabled");
				} //
			}); //end $.ajax
		}
		
		function showValues() {
	      var str = $(".uniForm").serialize();
		  return str;
	    }	
		
        //Apply serializing on chosen events
		$(":radio").click(showValues);
		$("select").change(showValues);
		
		$(":radio, select, table label").mouseout(function(){
			ajax_total_plata(showValues());
		}
		);
		
		//In case of an form error OR refresh, send needed info for Total plata
		var radio_medici_value = $("input[name='medici']:checked").val();
		

		if( radio_medici_value != '' ) {
			ajax_total_plata(showValues());
		}
		
})
