function serializeSelectWithAttributes(id) {
	// Initialize variables
	var output  = {},
		key     = null,
		field   = null,
		attrKey = null;
	
	// Iterate through rows
	$("div#custom-"+id+" tr").each(function() {
		// Fetch selection key
		key = $(this).attr("id").split("-")[2];
		
		// Is selection checked?
		if ($("input[name='"+id+"-"+key+"']", this).is(":checked")) {
			// Update output array
			output[key] = {};
			
			if ($("input[name='"+id+"-"+key+"-other']")) {
				output[key]["other"] = $("input[name='"+id+"-"+key+"-other']").val();
			}
						
			// Iterate through custom attributes
			$("input.customAttr", this).each(function() {
				// Find attribute key
				field	= $(this);
				attrKey = field.attr("name").split("-")[2];
				
				// Add value to output if checked or entered
				if		(field.attr("type") == "checkbox" && field.is(":checked")) output[key][attrKey] = "Yes";
				else if (field.attr("type") == "text" && field.val().length)	   output[key][attrKey] = field.val();				
			});
		}
	});
	
	// JSON serialize custom field value
	output = JSON.stringify(output);
	
	// Store custom field value
	$("input[name="+id+"]").attr("value", output);
}

function serializeSelectWithOther(id) {
	// Initialize variables
	var output = {},
		field  = null,
		index  = null,
		value  = "";
	
	// Iterate through fields
	$("div#custom-"+id+" input:enabled").each(function() {
		// Fetch index and value
		field = $(this);
		index = field.attr("name").split("-")[1];
		value = field.val();
		
		// Add value to output if checked or entered
		if		(field.attr("type") == "checkbox" && field.is(":checked")) output[index] = value;
		else if (field.attr("type") == "text" && field.val().length)	   output[index] = value;
	});
	
	// JSON serialize custom field value
	output = JSON.stringify(output);
	
	// Store custom field value
	$("input[name="+id+"]").attr("value", output);
}
