/*
 * 制作人 : 
 * 文件名 : mdmall_order_edit.php
 * ============================
 * 处理定单信息..
 *	 
 *
 */

// 대행수수료
function get_agent_fee(ccoun , price , quan , m_grade, exchange_rate)
{
	//var agent_fee = 0.0;
	//switch(link_kind) {
	//	case 'B' :	//구매대행
	//		agent_fee = get_buying_agent_fee(price * quan , memid, country);
	//	break;
	//	case 'G' :	// 나도MD
	//		agent_fee = get_mdmall_agent_fee(price * quan , memid, country);
	//	break;
	//}
	var agent_fee = 0.0;
	var agent_fee_rmb = 0;
	var total_goods_price_rmb = price * quan * exchange_rate;
	m_grade = eval(m_grade);
	switch(m_grade) {
		case 10 : // 신규/일반
			
			if(ccoun == 'KR'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.10;
				else return 0;
			}
			else if(ccoun == 'US'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.10;
				else return 0;
			}
			else if(ccoun == 'JP'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.10;
				else return 0;
			}
			else if(ccoun == 'CN'){
				return 0;
			}
			else {
				return 0;
			}
			
		break;
		case 30 : // 우수
			
			if(ccoun == 'KR'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'US'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'JP'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'CN'){
				return 0;
			}
			else {
				return 0;
			}
			
		break;
		case 50 : // 프리미엄
			
			if(ccoun == 'KR'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'US'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.08;
				else return 0;
			}
			else if(ccoun == 'JP'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.08;
				else return 0;
			}
			else if(ccoun == 'CN'){
				return 0;
			}
			else {
				return 0;
			}
			
		break;
	}
	agent_fee = Math.ceil(agent_fee_rmb / exchange_rate * 100) / 100;
	return agent_fee;
}




// 대행수수료 구매대행
function get_buying_agent_fee(price , quan , m_grade, exchange_rate)
{
	var agent_fee = 0.0;
	var agent_fee_rmb = 0;
	var price = eval(price);
	var quan = eval(quan);
	var m_grade = eval(m_grade);
	var exchange_rate = 1;
	var total_goods_price_rmb = price * quan;
	switch(m_grade) {
		case 10 : // 신규/일반
			
			if(ccoun == 'KR'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.10;
				else return 0;
			}
			else if(ccoun == 'US'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.10;
				else return 0;
			}
			else if(ccoun == 'JP'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.10;
				else return 0;
			}
			else if(ccoun == 'CN'){
				return 0;
			}
			else {
				return 0;
			}
			
		break;
		case 30 : // 우수
			
			if(ccoun == 'KR'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'US'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'JP'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'CN'){
				return 0;
			}
			else {
				return 0;
			}
			
		break;
		case 50 : // 프리미엄
			
			if(ccoun == 'KR'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'US'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.08;
				else return 0;
			}
			else if(ccoun == 'JP'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.08;
				else return 0;
			}
			else if(ccoun == 'CN'){
				return 0;
			}
			else {
				return 0;
			}
			
		break;
	}
	agent_fee = Math.ceil(agent_fee_rmb / exchange_rate * 100) / 100;
	return agent_fee;
}



// 대행수수료 MD Mall
function get_mdmall_agent_fee(price , quan , m_grade, ccoun)
{
	var agent_fee = 0.0;
	var agent_fee_rmb = 0;
	var total_goods_price_rmb = price * quan;
	switch(m_grade) {
		case 10 : // 신규/일반
			if(ccoun == 'KR'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.10;
				else return 0;
			}
			else if(ccoun == 'US'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.10;
				else return 0;
			}
			else if(ccoun == 'JP'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.10;
				else return 0;
			}
			else if(ccoun == 'CN'){
				return 0;
			}
			else {
				return 0;
			}
		break;
		case 30 : // 우수
			if(ccoun == 'KR'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'US'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'JP'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'CN'){
				return 0;
			}
			else {
				return 0;
			}
		break;
		case 50 : // 프리미엄
			if(ccoun == 'KR'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.09;
				else return 0;
			}
			else if(ccoun == 'US'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.08;
				else return 0;
			}
			else if(ccoun == 'JP'){
				if(total_goods_price_rmb > 0) agent_fee_rmb = total_goods_price_rmb * 0.08;
				else return 0;
			}
			else if(ccoun == 'CN'){
				return 0;
			}
			else {
				return 0;
			}
		break;
	}
	agent_fee = Math.ceil(agent_fee_rmb * 100) / 100;
	return agent_fee;
}




// 에스크로 비용
function get_escrow_fee(use_escrow, link_kind , price , quan)
{
	if(use_escrow == 'N' || !use_escrow) return 0;
	var escrow_fee = 0.0;
	switch(link_kind) {
		case 'B' :	//구매대행
			escrow_fee = Math.ceil(price * quan * 5 / 100);
		break;
		case 'G' :	//MDmall
			escrow_fee = Math.ceil(price * quan * 5 / 100);
		break;
	}
	return escrow_fee;
}




// ****************************
// 추정 송금수수료
// 预算 当地汇款手续费
// ****************************
function get_presumed_remit_fee(country)
{
	var remit_fee = 0.0;
	switch(country) {
		case 'KR' : remit_fee = 0; break;
		case 'JP' : remit_fee = 300; break;
		case 'US' : remit_fee = 0; break;
		case 'CN' : remit_fee = 0; break;
	}
	return remit_fee;
}



// ****************************
// 추정 현지배송료
// 预算 当地货运费
// ****************************
function get_presumed_field_shipping_costs(country)
{
	var field_shipping_costs = 0.0;
	switch(country) {
		case 'KR' : field_shipping_costs = 3500; break;
		case 'JP' : field_shipping_costs = 800; break;
		case 'US' : field_shipping_costs = 12; break;
		case 'CN' : field_shipping_costs = 0; break;
	}
	return field_shipping_costs;
}


// ****************************
// 기본 국제배송 수단
// 默认 国际货运方式
// ****************************
function get_default_shipping_way(country)
{
	var shipping_way = '';
	switch(country) {
		case 'KR' : shipping_way = 'EMS'; break;
		case 'JP' : shipping_way = 'EMS'; break;
		case 'US' : shipping_way = 'AAE'; break;
		case 'CN' : shipping_way = 'EMS'; break;
	}
	return shipping_way;
}



// 추정 국제배송료
function get_presumed_abroad_shipping_costs(weight, country)
{
	if(!weight || !country) return 0;
	var abroad_shipping_costs = 0.0;
	var default_shipping_way = get_default_shipping_way(country);
	abroad_shipping_costs = get_abroad_shipping_costs(weight, country, default_shipping_way);
	return abroad_shipping_costs;
}



// 국제배송료
function get_abroad_shipping_costs(weight, country, shipping_way)
{
	var costs = 0.0;
	if(!weight || !country || !shipping_way) return 0;
	// 1 파운드 = 0.454 Kg
	// 용적 중량 = 종 x 횡 x 높이 (인치) ÷ 166
	// new Array(한국 , 일본 , 미국)
	
	switch(shipping_way) {
		case 'EMS' :	//##################  EMS  ##################
			switch(country) {
				case 'KR' :
					if(weight <= 0.5)		costs = 14400; 
					else if(weight <= 1.0)	costs = 16200; 
					else if(weight <= 1.5)	costs = 18300; 
					else if(weight <= 2.0)	costs = 20800;
					else if(weight <= 2.5)	costs = 22100;
					else if(weight <= 3.0)	costs = 23300;
					else if(weight <= 3.5)	costs = 24600;
					else if(weight <= 4.0)	costs = 25800;
					else if(weight <= 4.5)	costs = 27100;
					else if(weight <= 5.0)	costs = 28400;
					else if(weight <= 5.5)	costs = 29600;
					else if(weight <= 6.0)	costs = 30900;
					else if(weight <= 6.5)	costs = 32100;
					else if(weight <= 7.0)	costs = 33400;
					else if(weight <= 7.5)	costs = 34700;
					else if(weight <= 8.0)	costs = 35900;
					else if(weight <= 8.5)	costs = 37200;
					else if(weight <= 9.0)	costs = 38400; 
					else if(weight <= 9.5)	costs = 39700; 
					else if(weight <= 10.0)	costs = 41000; 
					else if(weight <= 10.5)	costs = 42200; 
					else if(weight <= 11.0)	costs = 43500; 
					else if(weight <= 11.5)	costs = 44700; 
					else if(weight <= 12.0)	costs = 46000; 
					else if(weight <= 12.5)	costs = 47300; 
					else if(weight <= 13.0)	costs = 48500; 
					else if(weight <= 13.5)	costs = 49800; 
					else if(weight <= 14.0)	costs = 51000; 
					else if(weight <= 14.5)	costs = 52300; 
					else if(weight <= 15.0)	costs = 53600; 
					else if(weight <= 15.5)	costs = 54800;
					else if(weight <= 16.0)	costs = 56100;
					else if(weight <= 16.5)	costs = 57300;
					else if(weight <= 17.0)	costs = 58600;
					else if(weight <= 17.5)	costs = 59900;
					else if(weight <= 18.0)	costs = 61100;
					else if(weight <= 18.5)	costs = 62400;
					else if(weight <= 19.0)	costs = 63600;
					else if(weight <= 19.5)	costs = 64900;
					else if(weight <= 20.0)	costs = 66200;
					else if(weight <= 20.5)	costs = 67400;
					else if(weight <= 21.0)	costs = 68700;
					else if(weight <= 21.5)	costs = 69900;
					else if(weight <= 22.0)	costs = 71200;
					else if(weight <= 22.5)	costs = 72500;
					else if(weight <= 23.0)	costs = 73700;
					else if(weight <= 23.5)	costs = 75000;
					else if(weight <= 24.0)	costs = 76200;
					else if(weight <= 24.5)	costs = 77500;
					else if(weight <= 25.0)	costs = 78500;
					else if(weight <= 25.5)	costs = 79500;
					else if(weight <= 26.0)	costs = 80500;
					else if(weight <= 26.5)	costs = 81500;
					else if(weight <= 27.0)	costs = 82400;
					else if(weight <= 27.5)	costs = 83400;
					else if(weight <= 28.0)	costs = 84400;
					else if(weight <= 28.5)	costs = 85400;
					else if(weight <= 29.0)	costs = 86400;
					else if(weight <= 29.5)	costs = 87400;
					else if(weight <= 30.0)	costs = 88400;
					else return 0;	// EMS는 66 파운드(30 Kg)를 넘을수 없습니다.
				break;
				
				case 'JP' :
					if(weight <= 0.3)			costs = 900;
					else if(weight <= 0.30)	costs = 900;
					else if(weight <= 0.50)	costs = 1100;
					else if(weight <= 0.60)	costs = 1240;
					else if(weight <= 0.70)	costs = 1380;
					else if(weight <= 0.80)	costs = 1520;
					else if(weight <= 0.90)	costs = 1660;
					else if(weight <= 1.00)	costs = 1800;
					else if(weight <= 1.25)	costs = 2100;
					else if(weight <= 1.50)	costs = 2400;
					else if(weight <= 1.75)	costs = 2700;
					else if(weight <= 2.00)	costs = 3000;
					else if(weight <= 2.50)	costs = 3500;
					else if(weight <= 3.00)	costs = 4000;
					else if(weight <= 3.50)	costs = 4500;
					else if(weight <= 4.00)	costs = 5000;
					else if(weight <= 4.50)	costs = 5500;
					else if(weight <= 5.00)	costs = 6000;
					else if(weight <= 5.50)	costs = 6500;
					else if(weight <= 6.00)	costs = 7000;
					else if(weight <= 6.50)	costs = 7800;
					else if(weight <= 7.00)	costs = 7800;
					else if(weight <= 7.50)	costs = 8600;
					else if(weight <= 8.00)	costs = 8600;
					else if(weight <= 8.50)	costs = 9400;
					else if(weight <= 9.00)	costs = 9400;
					else if(weight <= 9.50)	costs = 10200;
					else if(weight <= 10.00)	costs = 10200;
					else if(weight <= 11.00)	costs = 11000;
					else if(weight <= 12.00)	costs = 11800;
					else if(weight <= 13.00)	costs = 12600;
					else if(weight <= 14.00)	costs = 13400;
					else if(weight <= 15.00)	costs = 14200;
					else if(weight <= 16.00)	costs = 15000;
					else if(weight <= 17.00)	costs = 15800;
					else if(weight <= 18.00)	costs = 16600;
					else if(weight <= 19.00)	costs = 17400;
					else if(weight <= 20.00)	costs = 18200;
					else if(weight <= 21.00)	costs = 19000;
					else if(weight <= 22.00)	costs = 19800;
					else if(weight <= 23.00)	costs = 20600;
					else if(weight <= 24.00)	costs = 21400;
					else if(weight <= 25.00)	costs = 22200;
					else if(weight <= 26.00)	costs = 23000;
					else if(weight <= 27.00)	costs = 23800;
					else if(weight <= 28.00)	costs = 24600;
					else if(weight <= 29.00)	costs = 25400;
					else if(weight <= 30.00)	costs = 26200;
					else {	// 30kg 초과시 kg당 451엔 추가	
						costs = 26200 + (Math.ceil(weight-30) * 451);	
					}
				break;

				case 'US' :
					if(weight <= 0.227)				costs = 20;
					else if(weight <= 0.454)		costs = 24;
					else if(weight <= 0.908)		costs = 27.45;
					else if(weight <= 1.362)		costs = 32.15;
					else if(weight <= 1.816)		costs = 36.8;
					else if(weight <= 2.27)		costs = 41.3;
					else if(weight <= 2.724)		costs = 45.8;
					else if(weight <= 3.178)		costs = 50.3;
					else if(weight <= 3.632)		costs = 54.75;
					else if(weight <= 4.086)		costs = 59.25;
					else if(weight <= 4.54)		costs = 63.7;
					else if(weight <= 4.994)		costs = 68.2;
					else if(weight <= 5.448)		costs = 72.65;
					else if(weight <= 5.902)		costs = 77.15;
					else if(weight <= 6.356)		costs = 81.65;
					else if(weight <= 6.81)		costs = 86.1;
					else if(weight <= 7.264)		costs = 90.6;
					else if(weight <= 7.718)		costs = 95.05;
					else if(weight <= 8.172)		costs = 99.55;
					else if(weight <= 8.626)		costs = 104.05;
					else if(weight <= 9.08)		costs = 108.5;
					else if(weight <= 9.534)		costs = 113;
					else if(weight <= 9.988)		costs = 117.45;
					else if(weight <= 10.442)	costs = 121.95;
					else if(weight <= 10.896)	costs = 126.45;
					else if(weight <= 11.35)		costs = 130.9;
					else if(weight <= 11.804)	costs = 135.4;
					else if(weight <= 12.258)	costs = 139.85;
					else if(weight <= 12.712)	costs = 144.35;
					else if(weight <= 13.166)	costs = 148.8;
					else if(weight <= 13.62)		costs = 153.3;
					else if(weight <= 14.074)	costs = 157.8;
					else if(weight <= 14.528)	costs = 162.25;
					else if(weight <= 14.982)	costs = 166.75;
					else if(weight <= 15.436)	costs = 171.2;
					else if(weight <= 15.89)		costs = 175.7;
					else if(weight <= 16.344)	costs = 180.2;
					else if(weight <= 16.798)	costs = 184.65;
					else if(weight <= 17.252)	costs = 189.15;
					else if(weight <= 17.706)	costs = 193.6;
					else if(weight <= 18.16)		costs = 198.1;
					else if(weight <= 18.614)	costs = 202.6;
					else if(weight <= 19.068)	costs = 207.05;
					else if(weight <= 19.522)	costs = 211.55;
					else if(weight <= 19.976)	costs = 216;
					else if(weight <= 20.43)		costs = 220.5;
					else if(weight <= 20.884)	costs = 225;
					else if(weight <= 21.338)	costs = 229.45;
					else if(weight <= 21.792)	costs = 233.95;
					else if(weight <= 22.246)	costs = 238.4;
					else if(weight <= 22.7)		costs = 242.9;
					else if(weight <= 23.154)	costs = 247.35;
					else if(weight <= 23.608)	costs = 256.35;
					else if(weight <= 24.062)	costs = 260.35;
					else if(weight <= 24.516)	costs = 260.8;
					else if(weight <= 24.97)		costs = 265.3;
					else if(weight <= 25.424)	costs = 269.75;
					else if(weight <= 25.878)	costs = 274.25;
					else if(weight <= 26.332)	costs = 278.75;
					else if(weight <= 26.786)	costs = 283.2;
					else if(weight <= 27.24)		costs = 287.7;
					else if(weight <= 27.694)	costs = 292.15;
					else if(weight <= 28.148)	costs = 296.65;
					else if(weight <= 28.602)	costs = 301.15;
					else if(weight <= 29.056)	costs = 305.6;
					else if(weight <= 29.51)		costs = 310.1;
					else if(weight <= 29.964)	costs = 314.55;
					else return 0;	// EMS는 66 파운드(30 Kg)를 넘을수 없습니다.
				break;
				case 'CN' :
					return 0;
				break;
			} // EMS => switch(country) end
		break;


		case 'DHL' :	//##################  DHL  ##################
			switch(country) {
				case 'KR' :
					if(weight <= 0.5)			costs = 35795.45;
					else if(weight <= 1.0)	costs = 40909.09;
					else if(weight <= 1.5)	costs = 46022.73;
					else if(weight <= 2.0)	costs = 51136.36;
					else if(weight <= 2.5)	costs = 56250.00;
					else if(weight <= 3.0)	costs = 61363.64;
					else if(weight <= 3.5)	costs = 66477.27;
					else if(weight <= 4.0)	costs = 71590.91;
					else if(weight <= 4.5)	costs = 76704.55;
					else if(weight <= 5.0)	costs = 81818.18;
					else if(weight <= 5.5)	costs = 86477.27;
					else if(weight <= 6.0)	costs = 91136.36;
					else if(weight <= 6.5)	costs = 95795.45;
					else if(weight <= 7.0)	costs = 100454.55;
					else if(weight <= 7.5)	costs = 105113.64;
					else if(weight <= 8.0)	costs = 109772.73;
					else if(weight <= 8.5)	costs = 114431.82;
					else if(weight <= 9.0)	costs = 119090.91;
					else if(weight <= 9.5)	costs = 123750.00;
					else if(weight <= 10.0)	costs = 128409.09;
					else if(weight <= 10.5)	costs = 132500.00;
					else if(weight <= 11.0)	costs = 136590.91;
					else if(weight <= 11.5)	costs = 140681.82;
					else if(weight <= 12.0)	costs = 144772.73;
					else if(weight <= 12.5)	costs = 148863.64;
					else if(weight <= 13.0)	costs = 152954.55;
					else if(weight <= 13.5)	costs = 157045.45;
					else if(weight <= 14.0)	costs = 161136.36;
					else if(weight <= 14.5)	costs = 165227.27;
					else if(weight <= 15.0)	costs = 169318.18;
					else if(weight <= 15.5)	costs = 173636.36;
					else if(weight <= 16.0)	costs = 177500.00;
					else if(weight <= 16.5)	costs = 181590.91;
					else if(weight <= 17.0)	costs = 185681.82;
					else if(weight <= 17.5)	costs = 189772.73;
					else if(weight <= 18.0)	costs = 193863.64;
					else if(weight <= 18.5)	costs = 197954.55;
					else if(weight <= 19.0)	costs = 202045.45;
					else if(weight <= 19.5)	costs = 206136.36;
					else if(weight <= 20.0)	costs = 210227.27;
					else if(weight <= 20.5)	costs = 214318.18;
					else if(weight <= 21.0)	costs = 218409.09;
					else if(weight <= 21.5)	costs = 221818.18;
					else if(weight <= 22.0)	costs = 226590.91;
					else if(weight <= 22.5)	costs = 230681.82;
					else if(weight <= 23.0)	costs = 234772.73;
					else if(weight <= 23.5)	costs = 238863.64;
					else if(weight <= 24.0)	costs = 242954.55;
					else if(weight <= 24.5)	costs = 247045.45;
					else if(weight <= 25.0)	costs = 251136.36;
					else if(weight <= 25.5)	costs = 254772.73;
					else if(weight <= 26.0)	costs = 258409.09;
					else if(weight <= 26.5)	costs = 262045.45;
					else if(weight <= 27.0)	costs = 265681.82;
					else if(weight <= 27.5)	costs = 269318.18;
					else if(weight <= 28.0)	costs = 272954.55;
					else if(weight <= 28.5)	costs = 276590.91;
					else if(weight <= 29.0)	costs = 280454.55;
					else if(weight <= 29.5)	costs = 283863.64;
					else if(weight <= 30.0)	costs = 287500.00;
					else return 0;
				break;
				case 'JP' :
					if(weight <= 0.5)			costs = 4863.01; 
					else if(weight <= 1.0)	costs = 5479.45; 
					else if(weight <= 1.5)	costs = 6095.89; 
					else if(weight <= 2.0)	costs = 6712.33; 
					else if(weight <= 2.5)	costs = 7328.77; 
					else if(weight <= 3.0)	costs = 7945.21; 
					else if(weight <= 3.5)	costs = 8561.64; 
					else if(weight <= 4.0)	costs = 9178.08; 
					else if(weight <= 4.5)	costs = 9794.52; 
					else if(weight <= 5.0)	costs = 10410.96;
					else if(weight <= 5.5)	costs = 10972.60;
					else if(weight <= 6.0)	costs = 11534.25;
					else if(weight <= 6.5)	costs = 12095.89;
					else if(weight <= 7.0)	costs = 12657.53;
					else if(weight <= 7.5)	costs = 13219.18;
					else if(weight <= 8.0)	costs = 13780.82;
					else if(weight <= 8.5)	costs = 14342.47;
					else if(weight <= 9.0)	costs = 14904.11;
					else if(weight <= 9.5)	costs = 15465.75;
					else if(weight <= 10.0)	costs = 16027.40;
					else if(weight <= 10.5)	costs = 16520.55;
					else if(weight <= 11.0)	costs = 17013.70;
					else if(weight <= 11.5)	costs = 17506.85;
					else if(weight <= 12.0)	costs = 18000.00;
					else if(weight <= 12.5)	costs = 18493.15;
					else if(weight <= 13.0)	costs = 18986.30;
					else if(weight <= 13.5)	costs = 19479.45;
					else if(weight <= 14.0)	costs = 19972.60;
					else if(weight <= 14.5)	costs = 20465.75;
					else if(weight <= 15.0)	costs = 20958.90;
					else if(weight <= 15.5)	costs = 21452.05;
					else if(weight <= 16.0)	costs = 21945.21;
					else if(weight <= 16.5)	costs = 22438.36;
					else if(weight <= 17.0)	costs = 22931.51;
					else if(weight <= 17.5)	costs = 23424.66;
					else if(weight <= 18.0)	costs = 23917.81;
					else if(weight <= 18.5)	costs = 24410.96;
					else if(weight <= 19.0)	costs = 24904.11;
					else if(weight <= 19.5)	costs = 25397.26;
					else if(weight <= 20.0)	costs = 25753.42;
					else if(weight <= 20.5)	costs = 26383.56;
					else if(weight <= 21.0)	costs = 26876.71;
					else if(weight <= 21.5)	costs = 27232.88;
					else if(weight <= 22.0)	costs = 27863.01;
					else if(weight <= 22.5)	costs = 28356.16;
					else if(weight <= 23.0)	costs = 28849.32;
					else if(weight <= 23.5)	costs = 29342.47;
					else if(weight <= 24.0)	costs = 29835.62;
					else if(weight <= 24.5)	costs = 30328.77;
					else if(weight <= 25.0)	costs = 30821.92;
					else if(weight <= 25.5)	costs = 31260.27;
					else if(weight <= 26.0)	costs = 31698.63;
					else if(weight <= 26.5)	costs = 32136.99;
					else if(weight <= 27.0)	costs = 32575.34;
					else if(weight <= 27.5)	costs = 33013.70;
					else if(weight <= 28.0)	costs = 33452.05;
					else if(weight <= 28.5)	costs = 33890.41;
					else if(weight <= 29.0)	costs = 34328.77;
					else if(weight <= 29.5)	costs = 34767.12;
					else if(weight <= 30.0)	costs = 35205.48;
					else return 0;
				break;
				case 'US' :
					if(weight <= 0.5)			costs = 49.08;
					else if(weight <= 1.0)	costs = 58.90; 
					else if(weight <= 1.5)	costs = 68.71; 
					else if(weight <= 2.0)	costs = 78.53; 
					else if(weight <= 2.5)	costs = 88.34; 
					else if(weight <= 3.0)	costs = 98.16; 
					else if(weight <= 3.5)	costs = 107.98;
					else if(weight <= 4.0)	costs = 117.79;
					else if(weight <= 4.5)	costs = 127.61;
					else if(weight <= 5.0)	costs = 137.42;
					else if(weight <= 5.5)	costs = 146.26;
					else if(weight <= 6.0)	costs = 155.09;
					else if(weight <= 6.5)	costs = 163.93;
					else if(weight <= 7.0)	costs = 172.76;
					else if(weight <= 7.5)	costs = 181.60;
					else if(weight <= 8.0)	costs = 190.43;
					else if(weight <= 8.5)	costs = 199.26;
					else if(weight <= 9.0)	costs = 208.10;
					else if(weight <= 9.5)	costs = 216.93;
					else if(weight <= 10.0)	costs = 225.77;
					else if(weight <= 10.5)	costs = 233.62;
					else if(weight <= 11.0)	costs = 241.47;
					else if(weight <= 11.5)	costs = 249.33;
					else if(weight <= 12.0)	costs = 257.18;
					else if(weight <= 12.5)	costs = 265.03;
					else if(weight <= 13.0)	costs = 272.88;
					else if(weight <= 13.5)	costs = 280.74;
					else if(weight <= 14.0)	costs = 288.59;
					else if(weight <= 14.5)	costs = 296.44;
					else if(weight <= 15.0)	costs = 304.29;
					else if(weight <= 15.5)	costs = 312.15;
					else if(weight <= 16.0)	costs = 320.00;
					else if(weight <= 16.5)	costs = 327.85;
					else if(weight <= 17.0)	costs = 335.71;
					else if(weight <= 17.5)	costs = 343.56;
					else if(weight <= 18.0)	costs = 351.41;
					else if(weight <= 18.5)	costs = 359.26;
					else if(weight <= 19.0)	costs = 367.12;
					else if(weight <= 19.5)	costs = 374.97;
					else if(weight <= 20.0)	costs = 382.82;
					else if(weight <= 20.5)	costs = 390.67;
					else if(weight <= 21.0)	costs = 398.53;
					else if(weight <= 21.5)	costs = 406.38;
					else if(weight <= 22.0)	costs = 414.23;
					else if(weight <= 22.5)	costs = 422.09;
					else if(weight <= 23.0)	costs = 429.94;
					else if(weight <= 23.5)	costs = 437.79;
					else if(weight <= 24.0)	costs = 445.64;
					else if(weight <= 24.5)	costs = 453.50;
					else if(weight <= 25.0)	costs = 461.35;
					else if(weight <= 25.5)	costs = 468.22;
					else if(weight <= 26.0)	costs = 475.09;
					else if(weight <= 26.5)	costs = 481.96;
					else if(weight <= 27.0)	costs = 488.83;
					else if(weight <= 27.5)	costs = 495.71;
					else if(weight <= 28.0)	costs = 502.58;
					else if(weight <= 28.5)	costs = 509.45;
					else if(weight <= 29.0)	costs = 516.32;
					else if(weight <= 29.5)	costs = 523.19;
					else if(weight <= 30.0)	costs = 530.06;
					else return 0;
				break;
				case 'CN' :
					return 0;
				break;
			}
		break;


		case 'AIR' :	//##################  AIR  ##################
			switch(country) {
				case 'KR' :
					if(weight <= 0.5)			costs = 13900.00; 
					else if(weight <= 1.0)	costs = 15500.00;
					else if(weight <= 1.5)	costs = 17100.00;
					else if(weight <= 2.0)	costs = 18700.00;
					else if(weight <= 2.5)	costs = 20300.00;
					else if(weight <= 3.0)	costs = 21900.00;
					else if(weight <= 3.5)	costs = 23500.00;
					else if(weight <= 4.0)	costs = 25100.00;
					else if(weight <= 4.5)	costs = 26700.00;
					else if(weight <= 5.0)	costs = 28300.00;
					else if(weight <= 5.5)	costs = 29900.00;
					else if(weight <= 6.0)	costs = 31500.00;
					else if(weight <= 6.5)	costs = 33100.00;
					else if(weight <= 7.0)	costs = 34700.00;
					else if(weight <= 7.5)	costs = 36300.00;
					else if(weight <= 8.0)	costs = 37900.00;
					else if(weight <= 8.5)	costs = 39500.00;
					else if(weight <= 9.0)	costs = 41100.00;
					else if(weight <= 9.5)	costs = 42700.00;
					else if(weight <= 10.0)	costs = 44300.00;
					else if(weight <= 10.5)	costs = 45900.00;
					else if(weight <= 11.0)	costs = 47500.00;
					else if(weight <= 11.5)	costs = 49100.00;
					else if(weight <= 12.0)	costs = 50700.00;
					else if(weight <= 12.5)	costs = 52300.00;
					else if(weight <= 13.0)	costs = 53900.00;
					else if(weight <= 13.5)	costs = 55500.00;
					else if(weight <= 14.0)	costs = 57100.00;
					else if(weight <= 14.5)	costs = 58700.00;
					else if(weight <= 15.0)	costs = 60300.00;
					else if(weight <= 15.5)	costs = 61900.00;
					else if(weight <= 16.0)	costs = 63500.00;
					else if(weight <= 16.5)	costs = 65100.00;
					else if(weight <= 17.0)	costs = 66700.00;
					else if(weight <= 17.5)	costs = 68300.00;
					else if(weight <= 18.0)	costs = 69900.00;
					else if(weight <= 18.5)	costs = 71500.00;
					else if(weight <= 19.0)	costs = 73100.00;
					else if(weight <= 19.5)	costs = 74700.00;
					else if(weight <= 20.0)	costs = 76300.00; 
					else return 0;
				break;
				case 'JP' :
					if(weight <= 0.3)			costs = 1700.00; 
					else if(weight <= 0.50)		costs = 1700.00; 
					else if(weight <= 0.60)		costs = 2050.00; 
					else if(weight <= 0.70)		costs = 2050.00; 
					else if(weight <= 0.80)		costs = 2050.00; 
					else if(weight <= 0.90)		costs = 2050.00; 
					else if(weight <= 1.00)		costs = 2050.00; 
					else if(weight <= 1.25)		costs = 2400.00; 
					else if(weight <= 1.50)		costs = 2400.00; 
					else if(weight <= 1.75)		costs = 2750.00; 
					else if(weight <= 2.00)		costs = 2750.00; 
					else if(weight <= 2.50)		costs = 3100.00; 
					else if(weight <= 3.00)		costs = 3450.00; 
					else if(weight <= 3.50)		costs = 3800.00; 
					else if(weight <= 4.00)		costs = 4150.00; 
					else if(weight <= 4.50)		costs = 4500.00; 
					else if(weight <= 5.00)		costs = 4850.00; 
					else if(weight <= 5.50)		costs = 5150.00; 
					else if(weight <= 6.00)		costs = 5450.00; 
					else if(weight <= 6.50)		costs = 5750.00; 
					else if(weight <= 7.00)		costs = 6050.00; 
					else if(weight <= 7.50)		costs = 6350.00;
					else if(weight <= 8.00)		costs = 6650.00; 
					else if(weight <= 8.50)		costs = 6950.00; 
					else if(weight <= 9.00)		costs = 7300.00; 
					else if(weight <= 9.50)		costs = 7550.00;
					else if(weight <= 10.00)	costs = 7850.00;
					else if(weight <= 11.00)	costs = 8300.00;
					else if(weight <= 12.00)	costs = 8650.00;
					else if(weight <= 13.00)	costs = 9050.00;
					else if(weight <= 14.00)	costs = 9450.00;
					else if(weight <= 15.00)	costs = 9850.00;
					else if(weight <= 16.00)	costs = 10300.00;
					else if(weight <= 17.00)	costs = 10650.00;
					else if(weight <= 18.00)	costs = 11050.00;
					else if(weight <= 19.00)	costs = 11450.00;
					else if(weight <= 20.00)	costs = 11850.00;
					else return 0;
				break;
				case 'US' :
					return 0;
				break;
				case 'CN' :
					return 0;
				break;
			}
		break;
		

		case 'SEA' :	//##################  SEA  ##################
			switch(country) {
				case 'KR' :
					if(weight <= 2.0)			costs = 10000.00; 
					else if(weight <= 4.0)	costs = 13000.00;
					else if(weight <= 6.0)	costs = 16000.00;
					else if(weight <= 8.0)	costs = 19000.00;
					else if(weight <= 10.0)	costs = 22000.00;
					else if(weight <= 12.0)	costs = 25000.00;
					else if(weight <= 14.0)	costs = 28000.00;
					else if(weight <= 16.0)	costs = 31000.00;
					else if(weight <= 18.0)	costs = 34000.00;
					else if(weight <= 20.0)	costs = 37000.00;
					else return 0;
				break;
				case 'JP' :
					if(weight <= 0.3)				costs = 1500.00;
					else if(weight <= 0.50)		costs = 1500.00;
					else if(weight <= 0.60)		costs = 1500.00;
					else if(weight <= 0.70)		costs = 1500.00;
					else if(weight <= 0.80)		costs = 1500.00;
					else if(weight <= 0.90)		costs = 1500.00;
					else if(weight <= 1.00)		costs = 1500.00;
					else if(weight <= 1.25)		costs = 1750.00;
					else if(weight <= 1.50)		costs = 1750.00;
					else if(weight <= 1.75)		costs = 1750.00;
					else if(weight <= 2.00)		costs = 1750.00;
					else if(weight <= 2.50)		costs = 2000.00;
					else if(weight <= 3.00)		costs = 2000.00;
					else if(weight <= 3.50)		costs = 2300.00;
					else if(weight <= 4.00)		costs = 2300.00;
					else if(weight <= 4.50)		costs = 2500.00;
					else if(weight <= 5.00)		costs = 2500.00;
					else if(weight <= 5.50)		costs = 2750.00;
					else if(weight <= 6.00)		costs = 2750.00;
					else if(weight <= 6.50)		costs = 3000.00;
					else if(weight <= 7.00)		costs = 3000.00;
					else if(weight <= 7.50)		costs = 3300.00;
					else if(weight <= 8.00)		costs = 3300.00;
					else if(weight <= 8.50)		costs = 3500.00;
					else if(weight <= 9.00)		costs = 3500.00;
					else if(weight <= 9.50)		costs = 3750.00;
					else if(weight <= 10.00)	costs = 3750.00;
					else if(weight <= 11.00)	costs = 3950.00;
					else if(weight <= 12.00)	costs = 4150.00;
					else if(weight <= 13.00)	costs = 4350.00;
					else if(weight <= 14.00)	costs = 4550.00;
					else if(weight <= 15.00)	costs = 4750.00;
					else if(weight <= 16.00)	costs = 4950.00;
					else if(weight <= 17.00)	costs = 5150.00;
					else if(weight <= 18.00)	costs = 5350.00;
					else if(weight <= 19.00)	costs = 5550.00;
					else if(weight <= 20.00)	costs = 5750.00;
					else return 0;
				break;
				case 'US' :
					return 0;
				break;
				case 'CN' :
					return 0;
				break;
			}
		break;
		
		case 'AAE' :	//##################  SEA  ##################
			switch(country) {
				case 'KR' :
					return 0;
				break;
				case 'JP' :
					return 0;
				break;
				case 'US' :
					// 1 LB = 0.454 Kg
					weight = weight * 0.454;
					if(weight <= 1.00)				costs = 9.08;
					else if(weight <= 2.00)		costs = 12.09;
					else if(weight <= 3.00)		costs = 15.10;
					else if(weight <= 4.00)		costs = 18.11;
					else if(weight <= 5.00)		costs = 21.12;
					else if(weight <= 6.00)		costs = 24.13;
					else if(weight <= 7.00)		costs = 27.14;
					else if(weight <= 8.00)		costs = 30.15;
					else if(weight <= 9.00)		costs = 33.16;
					else if(weight <= 10.00)		costs = 36.17;
					else if(weight <= 11.00)		costs = 39.18;
					else if(weight <= 12.00)		costs = 42.19;
					else if(weight <= 13.00)		costs = 45.20;
					else if(weight <= 14.00)		costs = 48.21;
					else if(weight <= 15.00)		costs = 51.22;
					else if(weight <= 16.00)		costs = 54.23;
					else if(weight <= 17.00)		costs = 57.24;
					else if(weight <= 18.00)		costs = 60.25;
					else if(weight <= 19.00)		costs = 63.26;
					else if(weight <= 20.00)		costs = 66.27;
					else if(weight <= 21.00)	costs = 69.28;
					else if(weight <= 22.00)	costs = 72.29;
					else if(weight <= 23.00)	costs = 75.30;
					else if(weight <= 24.00)	costs = 78.31;
					else if(weight <= 25.00)	costs = 81.32;
					else if(weight <= 26.00)	costs = 84.33;
					else if(weight <= 27.00)	costs = 87.34;
					else if(weight <= 28.00)	costs = 90.35;
					else if(weight <= 29.00)	costs = 93.36;
					else if(weight <= 30.00)	costs = 96.37;
					else if(weight <= 31.00)	costs = 99.38;
					else if(weight <= 32.00)	costs = 102.39;
					else if(weight <= 33.00)	costs = 105.40;
					else if(weight <= 34.00)	costs = 108.41;
					else if(weight <= 35.00)	costs = 111.42;
					else if(weight <= 36.00)	costs = 114.43;
					else if(weight <= 37.00)	costs = 117.44;
					else if(weight <= 38.00)	costs = 120.45;
					else if(weight <= 39.00)	costs = 123.46;
					else if(weight <= 40.00)	costs = 126.47;
					else if(weight <= 41.00)	costs = 129.48;
					else if(weight <= 42.00)	costs = 132.49;
					else if(weight <= 43.00)	costs = 135.50;
					else if(weight <= 44.00)	costs = 138.51;
					else if(weight <= 45.00)	costs = 141.52;
					else if(weight <= 46.00)	costs = 144.53;
					else if(weight <= 47.00)	costs = 147.54;
					else if(weight <= 48.00)	costs = 150.55;
					else if(weight <= 49.00)	costs = 153.56;
					else if(weight <= 50.00)	costs = 156.57;
					else if(weight <= 51.00)	costs = 159.58;
					else if(weight <= 52.00)	costs = 162.59;
					else if(weight <= 53.00)	costs = 165.60;
					else if(weight <= 54.00)	costs = 168.61;
					else if(weight <= 55.00)	costs = 171.62;
					else if(weight <= 56.00)	costs = 174.63;
					else if(weight <= 57.00)	costs = 177.64;
					else if(weight <= 58.00)	costs = 180.65;
					else if(weight <= 59.00)	costs = 183.66;
					else if(weight <= 60.00)	costs = 186.67;
					else if(weight <= 61.00)	costs = 189.68;
					else if(weight <= 62.00)	costs = 192.69;
					else if(weight <= 63.00)	costs = 195.70;
					else if(weight <= 64.00)	costs = 198.71;
					else if(weight <= 65.00)	costs = 201.72;
					else if(weight <= 66.00)	costs = 204.73;
					else if(weight <= 67.00)	costs = 207.74;
					else if(weight <= 68.00)	costs = 210.75;
					else if(weight <= 69.00)	costs = 213.76;
					else if(weight <= 70.00)	costs = 216.77;
					else if(weight <= 71.00)	costs = 219.78;
					else if(weight <= 72.00)	costs = 222.79;
					else if(weight <= 73.00)	costs = 225.80;
					else if(weight <= 74.00)	costs = 228.81;
					else if(weight <= 75.00)	costs = 231.82;
					else if(weight <= 76.00)	costs = 234.83;
					else if(weight <= 77.00)	costs = 237.84;
					else if(weight <= 78.00)	costs = 240.85;
					else if(weight <= 79.00)	costs = 243.86;
					else if(weight <= 80.00)	costs = 246.87;
					else if(weight <= 81.00)	costs = 249.88;
					else if(weight <= 82.00)	costs = 252.89;
					else if(weight <= 83.00)	costs = 255.90;
					else if(weight <= 84.00)	costs = 258.91;
					else if(weight <= 85.00)	costs = 261.92;
					else if(weight <= 86.00)	costs = 264.93;
					else if(weight <= 87.00)	costs = 267.94;
					else if(weight <= 88.00)	costs = 270.95;
					else if(weight <= 89.00)	costs = 273.96;
					else if(weight <= 90.00)	costs = 276.97;
					else if(weight <= 91.00)	costs = 279.98;
					else if(weight <= 92.00)	costs = 282.99;
					else if(weight <= 93.00)	costs = 286.00;
					else if(weight <= 94.00)	costs = 289.01;
					else if(weight <= 95.00)	costs = 292.02;
					else if(weight <= 96.00)	costs = 295.03;
					else if(weight <= 97.00)	costs = 298.04;
					else if(weight <= 98.00)	costs = 301.05;
					else if(weight <= 99.00)	costs = 304.06;
					else if(weight <= 100.00)	costs = 307.07;
					else {	// 100LB 초과시 LB당 451엔 추가	
						costs = 307.07 + (ceil(weight-100) * 3.01);	
					}
					costs = costs * 1.12;	// 燃油附加费
				break;
				case 'CN' :
					return 0;
				break;
			}
		break;


		default :
			return 0;
		break;
	}
	return costs;
}

// by sklam
// JAPAN EMS cost
function get_jpems_shipping_costs(weight) {
	var costs = 0;
	if (weight <= 0.3)		costs = 900;
	else if(weight <= 0.5)	costs = 1100;
	else if(weight <= 0.6)	costs = 1240;
	else if(weight <= 0.7)	costs = 1380;
	else if(weight <= 0.8)	costs = 1520;
	else if(weight <= 0.9)	costs = 1660;
	else if(weight <= 1)	costs = 1800;
	else if(weight <= 1.25)	costs = 2100;
	else if(weight <= 1.5)	costs = 2400;
	else if(weight <= 1.75)	costs = 2700;
	else if(weight <= 2)	costs = 3000;
	else if(weight <= 2.5)	costs = 3500;
	else if(weight <= 3)	costs = 4000;
	else if(weight <= 3.5)	costs = 4500;
	else if(weight <= 4)	costs = 5000;
	else if(weight <= 4.5)	costs = 5500;
	else if(weight <= 5)	costs = 6000;
	else if(weight <= 5.5)	costs = 6500;
	else if(weight <= 6)	costs = 7000;
	else if(weight <= 7)	costs = 7800;
	else if(weight <= 8)	costs = 8600;
	else if(weight <= 9)	costs = 9400;
	else if(weight <= 10)	costs = 10200;
	else if(weight <= 11)	costs = 11000;
	else if(weight <= 12)	costs = 11800;
	else if(weight <= 13)	costs = 12600;
	else if(weight <= 14)	costs = 13400;
	else if(weight <= 15)	costs = 14200;
	else if(weight <= 16)	costs = 15000;
	else if(weight <= 17)	costs = 15800;
	else if(weight <= 18)	costs = 16600;
	else if(weight <= 19)	costs = 17400;
	else if(weight <= 20)	costs = 18200;
	else if(weight <= 21)	costs = 19000;
	else if(weight <= 22)	costs = 19800;
	else if(weight <= 23)	costs = 20600;
	else if(weight <= 24)	costs = 21400;
	else if(weight <= 25)	costs = 22200;
	else if(weight <= 26)	costs = 23000;
	else if(weight <= 27)	costs = 23800;
	else if(weight <= 28)	costs = 24600;
	else if(weight <= 29)	costs = 25400;
	else if(weight <= 30)	costs = 26200;
	else return 0;

	return costs;
}