var getCity1=function(option){
	var dft = {
		province : "#province",
		city : "#city",
		domain : "#domain"
	};
	$.extend(dft,option);
	$obj =$(dft.obj);
	var target
	if ($obj.attr("id").indexOf( "province")>=0){
		_data="province=" +($obj.val());
		target=$(dft.city)	
	}else if ($obj.attr("id").indexOf( "city")>=0){
		_data="city=" + $obj.val();
		target=$(dft.domain)
	}
	$.ajax({
		url: "city.do",
		type : "post",
		data: _data,
		dataType:"json",
		success :function(response){
			target[0].options.length=0;
			$.each(response.city,function(i,n){
				var option = new Option(n,n)
				target[0].options.add(option);
			})
			if (target.attr("id").indexOf( "domain")>=0){
					target[0].options.add(new Option("其他","-1"))
			}
			target[0].options.selectedIndex=-1;
		} 
	});
}
var getCity=function(option){
	var dft = {
		province : "#province",
		city : "#city",
		domain : "#domain"
	};
	$.extend(dft,option);
	$obj =$(dft.obj);
	var target
	if ($obj.attr("id").indexOf("province")>=0){
		_data="province=" +$obj.val();
		target=$(dft.city)[0]	
	}else if ($obj.attr("id").indexOf("city")>=0){
		_data="city=" + $obj.val();
		target=$(dft.domain)[0]	
	}
	$.ajax({
		url: "city.do",
		type : "post",
		data: _data,
		dataType:"json",
		success :function(response){
			target.options.length=0;
			$.each(response.city,function(i,n){
				if (n.indexOf("_")>=0)
					option = new Option(n.split("_")[0],n.split("_")[1]);
				else
					option=new Option(n);
				target.options.add(option);
			})
			if (target.id.indexOf( "domain")>=0){
				target.options.add(new Option("其他","-1"))
			}
			target.options.selectedIndex=-1;
		} 
	});
}


function populateAddressByContact(option){
	var dft = {
		province : "#province1",
		city : "#city1",
		domain : "#domain1",
		address : "#address1"
	};
	$.extend(dft,option)
  	if ($(dft.domain)[0].options[$(dft.domain)[0].selectedIndex].value=="-1"){
  		$(dft.address).val($(dft.province)[0].options[$(dft.province)[0].selectedIndex].text + $(dft.city)[0].options[$(dft.city)[0].selectedIndex].text);
  	}else{
  		$(dft.address).val($(dft.province)[0].options[$(dft.province)[0].selectedIndex].text + $(dft.city)[0].options[$(dft.city)[0].selectedIndex].text + $(dft.domain)[0].options[$(dft.domain)[0].selectedIndex].text);
  	}
  	
  }



function populateAddress(option){
	var dft = {
		province : "#province",
		city : "#city",
		domain : "#domain",
		address : "#receiverAddress"
	};
	$.extend(dft,option)
  	if ($(dft.domain)[0].options[$(dft.domain)[0].selectedIndex].value=="-1"){
  	
  		if($(dft.province).val()==$(dft.city).val()){
  		$(dft.address).val($(dft.province)[0].options[$(dft.province)[0].selectedIndex].text);
  		}
  		else{
  		$(dft.address).val($(dft.province)[0].options[$(dft.province)[0].selectedIndex].text +  $(dft.city)[0].options[$(dft.city)[0].selectedIndex].text);
  		}
  		
  	}else{
  	if($(dft.province).val()==$(dft.city).val()){
  		$(dft.address).val($(dft.province)[0].options[$(dft.province)[0].selectedIndex].text + $(dft.domain)[0].options[$(dft.domain)[0].selectedIndex].text);}
  	else{
  		$(dft.address).val($(dft.province)[0].options[$(dft.province)[0].selectedIndex].text + $(dft.city)[0].options[$(dft.city)[0].selectedIndex].text + $(dft.domain)[0].options[$(dft.domain)[0].selectedIndex].text);}	
  	}
  	
  }

function populateAddress1(option){
	var dft = {
		province : "#province",
		city : "#city",
		domain : "#domain",
		address : "#receiverAddress"
	};
	$.extend(dft,option)
  	if ($(dft.domain)[0].options[$(dft.domain)[0].selectedIndex].value=="-1"){
  	
  		if($(dft.province).val()==$(dft.city).val()){
  		$(dft.address).val($(dft.province).val());
  		}
  		else{
  		$(dft.address).val($(dft.province).val() + $(dft.city).val());
  		}
  		
  	}else{
  	if($(dft.province).val()==$(dft.city).val()){
  		$(dft.address).val($(dft.province).val() + $(dft.domain).val());}
  	else{
  		$(dft.address).val($(dft.province).val() + $(dft.city).val() + $(dft.domain).val());}	
  	}
  	
  }