G.app.form_ctrl={
	phone:function(){
		var a={0:["区号","exsample_mini"],1:["电话号码","exsample_short"],2:["分机号（可选）","exsample_short"]},
		b=$('<input type="text" value="" class="input_mini" /> - <input type="text" value="" class="input_short" /> - <input type="text" value="" class="input_short" />');
		$.each(a,function(d,e){
			G.ui.tips.swapInput({target:b.filter("input:eq("+d+")"),focusClass:"",blurClass:e[1],defaultValue:e[0]})
		});
		return{
			attach:function(d){$(b).insertAfter(d);d.css("display","none");d.data("phone",this);var c=(function(e){return function(){$(d).val(e.val())}})(this);$.each(a,function(e,f){b.filter("input:eq("+e+")").bind("propertychange",c).bind("keyup",c).bind("paste",c)});return this
			},
			val:function(){
				if(arguments.length>0){
					var d=arguments[0];d=d.split("-");
					if(d.length>3){d.length=3}
					$.each(a,function(e,f){d[e]=$.trim(d[e]);if(d[e]){b.filter("input:eq("+e+")").val(d[e]).focus().blur()}})
				}else{var c=[];$.each(a,function(f,g){var e=$.trim(b.filter("input:eq("+f+")").val());c.push(e==g[0]?"":e)});if(c[2]==""){c.length=2}if(c[1]==""){c.length=1}return c.join("-")
				}
			}
		}
	},
	location:{
		_loc:false,
		getLocInfo:function(a){
			if(!G.util.area){return false}
			if(G.app.form_ctrl.location._loc===false){
				G.app.form_ctrl.location._loc={};
				$.each(G.util.area,function(c,d){$.each(d.l,function(f,e){$.each(e.l,function(g,h){G.app.form_ctrl.location._loc[g]=[h,c,d.n,f,e.n]})})})
			}
			var b=G.app.form_ctrl.location._loc[a];
			if(!b){return false}
			return{name:b[0],provinceId:b[1],provinceName:b[2],cityId:b[3],cityName:b[4]}
		},
		getLocName:function(b){
			var a=G.app.form_ctrl.location.getLocInfo(b);
			if(a===false){return""}
			return a.provinceName+a.cityName+a.name
		},
		locSelection:function(h){
			var f=['<select class="province"><option value="0">---ALL---</option>'],a=[];
			$.each(G.util.area,function(c,d){d.pid=c;a.push(d)});
			a.sort(function(d,c){if(d.c==c.c){if(d.n==c.n){return 0}return d.n>c.n?1:-1}else{return d.c>c.c?1:-1}});
			var b="";
			$.each(a,function(c,j){var d="&nbsp;&nbsp;";if(b!=j.c){b=j.c;d=b+"&nbsp;"}f.push('<option value="'+j.pid+'">'+d+j.n+"</option>")});
			f.push('</select><select class="city"><option value="0">---ALL---</option></select><select class="village"><option value="0">---ALL---</option></select> <span class="nor"></span>');
			//alert(f.join(""));
			var e=$(f.join(""));
			
			var g=e.filter("select:eq(0)"),k=e.filter("select:eq(1)"),i=e.filter("select:eq(2)");
			g.change((function(d,j,c){return function(){var l=d.val();var m=['<option value="0">--- ALL ---</option>'];if(G.util.area[l]){$.each(G.util.area[l].l,function(p,o){var n=false;$.each(o.l,function(r,q){if(G.util.areaIcsonDelivery&&G.util.areaIcsonDelivery[r]){n=true;return false}});m.push('<option value="'+p+'">'+o.n+(n?"":"")+"</option>")})}j.empty().html(m.join(""));if(m.length==2){setTimeout(function(){j[0].selectedIndex=1;j.hide()[0].style.display="";j.change()},1)}else{j.hide()[0].style.display="";j.change()}}})(g,k,i));
			k.change((function(d,j,c){return function(){var n=d.val();var q=j.val();var p=['<option value="0">--- ALL ---</option>'];if(G.util.area[n]&&G.util.area[n].l[q]){var o=$.extend({},G.util.area[n].l[q].l);var m=[];$.each(o,function(r,l){m.push({id:r,name:l})});m.sort(function(r,l){return r.name.toString().localeCompare(l.name.toString())});$.each(m,function(r,l){p.push('<option value="'+l.id+'">'+l.name+(G.util.areaIcsonDelivery&&G.util.areaIcsonDelivery[l.id]?" **":"")+"</option>")});m=null}c.empty().html(p.join(""));if(p.length==2){setTimeout(function(){c[0].selectedIndex=1;c.hide()[0].style.display=""},1)}else{c.hide()[0].style.display=""}}})(g,k,i));
			e.setLocation=function(n){
				var l=$(this).filter("select:eq(0)"),o=$(this).filter("select:eq(1)"),m=$(this).filter("select:eq(2)");var j=G.app.form_ctrl.location.getLocInfo(n);if(j!==false){l.val(j.provinceId).change();setTimeout(function(){o.val(j.cityId).change();setTimeout(function(){m.val(n)},2)},2)}else{l.val(0);l.change()}
			};
			e.getLocId=function(){return $(this).filter("select:eq(2)").val()};
			e.setLocation(h);
			return e
		}
	}
};