$(document).ready(function(){
	$("#fldState_id").bind("change", function(){
		$("#fldLocality_id").load("/users/get-localities/?state_id="+$("#fldState_id").attr("value"), function()
				{
					html = $("#fldLocality_id").html();
					html = html + '<option value="X"> Alta localitate...</option>'
					$("#fldLocality_id").html(html);
				});
	});	
	
	$("#fldLocality_id").bind("change", function(){
		if ($("#fldLocality_id").attr("value") == 'X')
		{
			$("#fldLocality_id").parent().html('<input name="fldLocality_id" class="input_bg" type="text" value=""/>');
		}
	});		
	
	function show(type)
	{
		if (type=="fizica")
		{
			document.getElementById("cui").style.display="none";
			document.getElementById("banca").style.display="none";
			document.getElementById("nr_reg_com").style.display="none";
			document.getElementById("iban").style.display="none";
			document.getElementById("numele_firmei").style.display="none";
			document.getElementById("cnp").style.display="";
		}
		if (type=="juridica")
		{
			document.getElementById("cui").style.display="";
			document.getElementById("banca").style.display="";
			document.getElementById("nr_reg_com").style.display="";
			document.getElementById("iban").style.display="";
			document.getElementById("numele_firmei").style.display="";
			document.getElementById("cnp").style.display="none";
		}
	}
	show($("#fldAccount_type").val());

	$("#fldAccount_type").bind("change", function(){
		show($("#fldAccount_type").val());
	});
});
