

function _mobfinaf_set_field_hiding(ifselect,tohide) {

	val=$("#"+ifselect).val();

	if (val==0 || val=="")  {
		tochange=$("#"+tohide);
		tochange.hide();
	};

	$("#"+ifselect).change(function () {
		y=$(this).val();
		tochange=$("#"+tohide);
		if (y==1 && y!="") {
			tochange.show();
		} else {
			tochange.hide().
				find(":input").val("");
		};
	});

}

$(document).ready(function () {

//place your code here

//	_mobfinaf_set_comment_hiding("edit-bankrupcies","form-element-comments");

	
	$("#mobfinaf-fieldset-postal-address_2").prepend("<a href='javascript:;' "+
													" id='sameasabove-button'>Same as above</a>");
		
	$("#sameasabove-button").click(function () {
			ids=  {"phone_2":"phone",
					"pa_address_2":"pa_address",
					"pa_postcode_2":"pa_postcode",
					}
			
			for(i in ids) {
				src="edit-"+ids[i].replace(/_/g,"-");
				dst="edit-"+i.replace(/_/g,"-");
				$("#"+dst).val($("#"+src).val());
			}

			ids2=  {"pa_state_2":"pa_state",
					"pa_timethere_2":"pa_timethere",
					"pa_status_2":"pa_status",
					}

			for(i in ids2) {
				src=ids2[i]; dst=i;
				$("#form-element-" + src + " .form-radios input").each(function(index) {
					if (this.checked)
						$("#form-element-" + dst + " .form-radios input")[index].checked = true;
				});
			}
		return false;		 
	});
	
	
//...................//
});
