$(document).ready(function() {

	$("#cartId").attr("value", new Date().toUTCString());

	$("#donate_form").validate();
	
	$("#cause").keyup(function() {
	
		var payment_type = $('form input[type=radio]:checked').val();		
		var cause = $("#cause").val();	
		$("#desc").attr("value",payment_type + " || " + cause);
	});
	
	$(".type_of_payment").ready(function(){
		showOrHideCauseSection($(this).val());		  
	}).click(function() {
		showOrHideCauseSection($(this).val());		  
	});
	
	
});

function showOrHideCauseSection(type) {
			
	if ((type == "Donation") || (type == "")) {
		$("#cause_section").hide();
		$("#cause").removeClass("required");
		
		$("#desc").attr("value", "N/A");
	}
	else {
		$("#cause_section").show();
		$("#cause").addClass("required");
		
		//update the value with new payment type
		$("#desc").attr("value",type + " || " + $("#cause").val());
	}	
}

