<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>{echo: lp{m_u_center};/}</title>
<link rel="stylesheet" type="text/css" href="skin/{echo: $SYSINFO['templates'];/}/css/modules.css">
<link rel="stylesheet" type="text/css" href="skin/{echo: $SYSINFO['templates'];/}/css/layout.css">
<link rel="stylesheet" type="text/css" href="skin/{echo: $SYSINFO['templates'];/}/css/style.css">
<script type="text/javascript" src="skin/{echo: $SYSINFO['templates'];/}/js/userchangeStyle.js"></script>
<script language="JavaScript" type="text/javascript" src="servtools/NewDialog/Dialog.js"></script>
<link href="servtools/NewDialog/skin/default.css" rel="stylesheet" />
<style type="text/css">
th{background:#EFEFEF}
td span{color:red;}
</style>
</head>
<body onload="menu_style_change('user_my_order');changeMenu();">
{inc: require("shop/index_header.php");/}
	<div class="site_map">
	  {echo:lp{m_current_position};/}<A href="index.php">{echo:$SYSINFO['sys_name'];/}</A>/<a href="modules.php">{echo:lp{m_u_center};/}</a>/&nbsp;&nbsp;{echo: lp{m_my_order};/}
	</div>
    <div class="clear"></div>
	{inc: require("modules/left_menu.php");/}

		<div class="main_right">
  <div class="cont">
  
            <div class="title_uc"><h3>{echo: lp{m_my_order};/}</h3></div>
            <hr />
             <div id="stepTip" class="clearfix">
     <ul class="list_step1 clearfix">
     <li class="now">{echo:lp{m_u_first};/}:<br />{echo:lp{m_ordernow_add};/}</li>
     <li>{echo:lp{m_u_secound};/}:<br />{echo:lp{m_sure_ordernow};/}</li>
     <li style="padding-right:0">{echo:lp{m_u_third};/}:<br />{echo:lp{m_accomplish};/}</li>
     </ul>
     </div>
     
		<form action="modules.php?app=user_order&gid={echo:implode(',',$goods_id);/}&v={echo:implode(',',$order_num);/}" method="post" name="for{echo: lp{m_profile};/}" onsubmit="return checkform();">


		<table width="100%" class="form_table">
			<tr class="center"><th colspan="7">{echo:lp{m_getgoods_addresslist};/}</th></tr>
			{sta:if(empty($address_rs))[exc]}
				<tr><td class="center" colspan="7">{echo:lp{m_dontsave_getgoods_addresslist};/}</td></tr>
			{end:if/}
			{sta:foreach($address_rs as $val)[loop]}
			<tr>
				<td class="center"><input type="radio" name="address_id" value="{echo:$val['address_id'];/}" onclick="changeurl({echo:$val['address_id'];/});" {sta:if($val['address_id']==$address_id)[exc]} checked {end:if/} /></td>
				<td class="center">{echo:$val['to_user_name'];/}</td>
				<td>{echo:$areas_info[0][$val['user_country']]['area_name'];/} {echo:$areas_info[1][$val['user_province']]['area_name'];/} {echo:$areas_info[2][$val['user_city']]['area_name'];/} {echo:$areas_info[3][$val['user_district']]['area_name'];/}</td>
				<td>{echo:$val['full_address'];/}</td><td class="center">{echo:$val['zipcode'];/}</td>
				<td class="center">{echo:$val['mobile'];/}/{echo:$val['telphone'];/}</td>
				<td class="center">{echo:$val['email'];/}</td>
			</tr>
			{end:foreach/}
			<tr>
			    <td class="center"><input type="radio" name="address_id" value="" onclick="newAddress();" {sta:if(empty($address_rs))[exc]} checked {end:if/}/></td>
			    <td class="left" colspan="4">{echo:lp{m_userother_address};/}</td><td></td><td class="center"></td>
			</tr>
		</table>

       <table id="newAddress" width="100%" border="0" cellspacing="0">
					<tr>
						<th align="left" width="30%">&nbsp;&nbsp;{echo: lp{m_order_getsting};/}</th><th width="70%"><span></span></th>
					</tr>
					<tr><td class="textright">{echo: lp{m_contact};/}：</td>
						<td align="left"><input type="text" name="to_user_name" value="{echo: $user_info['to_user_name'];/}" maxlength="12" /></td></tr>
					<tr>
						<td class="textright">{echo: lp{m_stayarea};/}：</td>
						<td>
							<span id="user_country"><select name="country" onchange="areachanged(this.value,0);">
								<option value='0'>{echo: lp{m_select_country};/}</option>
							{sta: foreach($areas_info[0] as $v)[loop]}
								<option value="{echo: $v['area_id'];/}"
									{sta: if($v['area_id']==$user_info['user_country']){echo 'selected';if/}>{echo: $v['area_name'];/}</option>
							{end:foreach/}
							</select></span>
							<span id="user_province">{sta:if($user_info['user_country']) [exc]}
							<select name="province" id="province" onchange="areachanged(this.value,1);">
								<option value='0'>{echo: lp{m_select_province};/}</option>
							{sta: foreach($areas_info[1] as $v) {
									if($v['parent_id'] == $user_info['user_country']) [exc]}
								<option value="{echo: $v['area_id'];/}"
								{sta: if($v['area_id']==$user_info['user_province']){echo 'selected';if/}>{echo: $v['area_name'];/}</option>
							{end:if/}
							{end:foreach/}
							</select>
							{end:if/}</span>
							<span id="user_city">{sta: if($user_info['user_province']) [exc]}
							<select name="city" onchange="areachanged(this.value,2);">
								<option value='0'>{echo: lp{m_select_city};/}</option>
							{sta: foreach($areas_info[2] as $v) {
									if($v['parent_id'] == $user_info['user_province'])[exc]}
								<option value="{echo: $v['area_id'];/}"
								{sta: if($v['area_id']==$user_info['user_city']){echo 'selected';if/}>{echo: $v['area_name'];/}</option>
							{end:if/}
							{end:foreach/}</select>
							{end:if/}</span>
							<span id="user_district">{sta:  if($user_info['user_city']) [exc]}
							<select name="district">
								<option value='0'>{echo: lp{m_select_district};/}</option>
							{sta: foreach($areas_info[3] as $v) {
									if($v['parent_id'] == $user_info['user_city']) [exc]}
								<option value="{echo: $v['area_id'];/}"
								{sta: if($v['area_id']==$user_info['user_district']){echo 'selected';if/}>{echo: $v['area_name'];/}</option>
							{end:if/}
							{end:foreach/}</select>
							{end:if/}</span>
						</td>
					</tr>
					<tr><td class="textright">{echo: lp{m_address};/}：</td>
					<td><input type="text" name="full_address" value="{echo: $user_info['full_address'];/}" style="width:250px;" maxlength="200" /></td></tr>
					<tr><td class="textright">{echo: lp{m_zipcode};/}：</td>
					<td><input type="text" name="zipcode" value="{echo: $user_info['zipcode'];/}" maxlength="6" /></td></tr>
					<tr><td class="textright">{echo: lp{m_mobile};/}：</td>
						<td><input type="text" name="mobile" value="{echo: $user_info['mobile'];/}" maxlength="20" /></td></tr>
					<tr><td class="textright">{echo: lp{m_telphone};/}：</td>
						<td><input type="text" name="telphone" value="{echo: $user_info['telphone'];/}" maxlength="20" /></td></tr>
					<tr><td class="textright">{echo: lp{m_email};/}：</td>
						<td><input type="text" name="email" value="{echo:$user_info['email'];/}" maxlength="20" /></td></tr>
						
						<tr><td class="textright"></td><td align="left"><input type="checkbox" name="issave" value="1" />{echo: lp{m_add_list};/}</td></tr>
					<tr><td></td><td><span>{echo: lp{m_sureaddress_rcgoods};/}</span><input type=hidden name="newadd" id="newadd" value="0" /></td></tr>
					<tr><td></td><td><span><input type="submit" name="submit" value="{echo: lp{m_post_order};/}" /></span></td></tr>
				</table>

		</form>
        </div>
        </div>
    </div>
<div class="clear"></div>
{inc: require("shop/index_footer.php");/}
<script language="JavaScript" src="servtools/ajax_client/ajax.js"></script>
<script language="JavaScript">
function newAddress(){
	document.getElementById("newadd").value='1';
	clearaddress();
}

<!--
function areachanged(value,type){
	if(value > 0) {
		ajax("do.php?act=ajax_areas","POST","value="+value+"&type="+type,function(return_text){
			var return_text = return_text.replace(/[\n\r]/g,"");
			if(return_text==""){
				alert("");
			} else {
				if(type==0) {
					document.getElementById("user_province").innerHTML = return_text;
					show("user_province");
					hide("user_city");
					hide("user_district");
				} else if(type==1) {
					document.getElementById("user_city").innerHTML = return_text;
					show("user_city");
					hide("user_district");
				} else if(type==2) {
					document.getElementById("user_district").innerHTML = return_text;
					show("user_district");
				}
			}
			var obj = document.getElementsByName('transporttype');
			for(i=0;i<obj.length;i++){
				if(obj[i].checked){
					var transporttype_value=obj[i].value;
				}
			}
			//getallpay(transporttype_value);
		});
	} else {
		if(type==2) {
			hide("user_district");
		} else if(type==1) {
			hide("user_district");
			hide("user_city");
		} else if(type==0) {
			hide("user_district");
			hide("user_city");
			hide("user_province");
		}
	}
}
function getallpay(type){
	var area_id = document.getElementById('province').value;
	var goods_id = {echo:$goods_info['goods_id'];/};
	var goods_num = {echo:$order_num;/};
	ajax("do.php?act=gettransportprice","POST","area_id="+area_id+"&goods_id="+goods_id+"&goods_num="+goods_num+"&type="+type,function(data){
		document.getElementById("order_amount").value=parseInt(parseInt({echo:$goods_info['goods_price'];/})*goods_num+parseInt(data));
		document.getElementById("allpay").innerHTML=document.getElementById("order_amount").value;
		document.getElementById("transportprice").innerHTML=data;
		document.getElementById("transport_price").value=data;
	});
}
function hide(id) {
	document.getElementById(id).style.display = 'none';
}

function show(id) {
	document.getElementById(id).style.display = '';
}


function checkform(){
	var to_user_name = document.getElementsByName('to_user_name')[0];
	if(to_user_name.value==''){
		alert('{echo:lp{m_pl_getgoods_name};/}');
		return false;
	}

	var province = document.getElementsByName('province')[0];
	if(province.value==0){
		alert('{echo:lp{m_pl_getgoods_province};/}');
		return false;
	}

	var city = document.getElementsByName('city')[0];
	if(city.value==0){
		alert('{echo:lp{m_pl_getgoods_city};/}');
		return false;
	}

	var district = document.getElementsByName('district')[0];
	if(district.value==0){
		alert('{echo:lp{m_pl_getgoods_district};/}');
		return false;
	}

	var full_address = document.getElementsByName('full_address')[0];
	if(full_address.value==''){
		alert('{echo:lp{m_pl_getgoods_address};/}');
		return false;
	}

	var zipcode = document.getElementsByName('zipcode')[0];
	if(zipcode.value==''){
		alert('{echo:lp{m_pl_getgoods_zipcode};/}');
		return false;
	}

	var email = document.getElementsByName('email')[0];
	var user_email_reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
	if(!email.value=='' && !user_email_reg.test(email.value)){
		alert('{echo:lp{m_email_type_notine};/}');
		return false;
	}

	var user_mobile = document.getElementsByName('mobile')[0];
	var reg = /^\d+(\.d+)?$/;

	var user_telphone = document.getElementsByName('telphone')[0];
	var tel_reg=/^([0-9]|[-])+$/g ;

	if(user_mobile.value=='' && user_telphone.value=='') {
		alert('{echo:lp{m_sorry_p_mselectone};/}');
		return false;
	} else if(!user_mobile.value=='' && !reg.test(user_mobile.value)) {
		alert('{echo:lp{m_sorry_mobiletype};/}');
		return false;
	} else if(!user_telphone.value=='' && !tel_reg.test(user_telphone.value)) {
		alert('{echo:lp{m_sorry_phonetype};/}');
		return false;
	}else {
		return true;
	}
}

function changeurl(v){
	var re = /&address_id=[0-9]+/g;
	var url = location.href.replace(re,"")+"&address_id="+v+"{echo:$url_param;/}";
	location.href = url;
}

function clearaddress() {
	areachanged(1,0);
	var to_user_name = document.getElementsByName('to_user_name')[0];
	to_user_name.value="";
	var full_address = document.getElementsByName('full_address')[0];
	full_address.value="";
	var zipcode = document.getElementsByName('zipcode')[0];
	zipcode.value="";
	var mobile = document.getElementsByName('mobile')[0];
	mobile.value="";
	var telphone = document.getElementsByName('telphone')[0];
	telphone.value="";
	var email = document.getElementsByName('email')[0];
	email.value="";
	var address_id = document.getElementsByName('address_id')[0];
	address_id.value="";
}
//-->
</script>
</body>
</html>