var expressArea, areaCont, areaList = $("#areaList"), areaTop = areaList.offset().top;
/*初始化省份*/
var itemid = 1;
var itemlevel = 1;
function intProvince(level,id) {
	if(level==1&&id==1){itemid = 1;itemlevel = 1;}
	var url = APP+'Mobile/Ajax/getarearegion';
	var query = new Object;
	query.level = level;
	query.id = id;
	$.ajax({
		url: url,
		type: "post",
		data: query,
		dataType: "json",
		success: function (ret) {
			//alert(JSON.stringify(ret));
			if (ret.status) {
				areaList.html(ret.data);
				$("#areaBox").scrollTop(0);
				if(level==2){
					itemid = id;itemlevel = level;$("#backUp").show();
				}else{
					$("#backUp").attr("onClick", "intProvince("+itemlevel+","+itemid+");").show();
				}
				if(level==1){
					$("#backUp").hide();$('#areaLayer .choose-header h3').html('选择地区');
				}
				if(ret.datanames){
					if(ret.datanames.strnames&&level==1){
						$('#areaLayer .choose-header h3').html(ret.datanames.strnames);
						var html='<dt>送至</dt>';
                        html+='<dd>'+ret.datanames.strnames+'<i class="iconfont">&#xe6d5;</i></dd>';
						$('#expressArea').html(html);
					}
					// if(ret.datanames.cityname){
					// 	$('#expressArea').html(ret.datanames.cityname+'<i class="iconfont">&#xe661;</i>');
					// }
				}
			}
		}
	});
	if(level==4)clockArea();
}
intProvince(1,1);
/*关闭省市区选项*/
function clockArea() {
	$("#areaMask").fadeOut();
	$("#areaLayer").animate({"top": "100%"});
	intProvince(1,1);
}

$(function() {
	/*打开省市区选项*/
	$("#expressArea").click(function() {
		$("#areaMask").fadeIn();
		$("#areaLayer").animate({"top": 0});
	});
	/*关闭省市区选项*/
	$("#areaMask, #closeArea").click(function() {
		clockArea();
	});
});