var curARvwFlag;
function AARvw_Action(argOver)
{
    if (curARvwFlag == argOver)
    {
        return;
    }
     switch (argOver)
    {
        case "A" :
        {
        document.getElementById('pard').style.display = "";
        document.getElementById('pard1').style.display = "none";
        break;
        }
        case "B" :
        {
        document.getElementById('pard').style.display = "none";
        document.getElementById('pard1').style.display = "";
         break;
        }
        default :
        {
            break;
        }
    }
}

function BBRvw_Action(argOver)
{
    if (curARvwFlag == argOver)
    {
        return;
    }
     switch (argOver)
    {
        case "A" :
        {
        document.getElementById('hop10_i').style.display = "";
        document.getElementById('hop10_i1').style.display = "none";
        break;
        }
        case "B" :
        {
        document.getElementById('hop10_i').style.display = "none";
        document.getElementById('hop10_i1').style.display = "";
         break;
        }
        default :
        {
            break;
        }
    }
}

function createAjax() {		
	var _xmlhttp;
	try {	
		_xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");	
	}
	catch (e) {
		try {
			
			
			if (window.XMLHttpRequest)
             {// code for IE7+, Firefox, Chrome, Opera, Safari
             _xmlhttp=new XMLHttpRequest();
              }
             else
            {// code for IE6, IE5
            _xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
 
			//_xmlhttp=new XMLHttpRequest();	
		}
		catch (e) {
			_xmlhttp=false;	
		}
	}
	return _xmlhttp;
}

function ajax_taiwan_c(searchkey) {	
	var xmlhttp=createAjax();	
	if (xmlhttp) {	
		var imglist=document.getElementById('m_menu1');	
		xmlhttp.open('get','ajax_t.php?searchkey='+escape(searchkey),true);	
		xmlhttp.onreadystatechange=function() {		
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
				imglist.innerHTML=unescape(xmlhttp.responseText);
				
				obj=document.getElementById("m_menu1").getElementsByTagName("li"); 
				j=obj.length 
				PagesLen=Math.ceil(j/listNum);
				upPage1(0) 


			}
			else {
				imglist.innerHTML='<div id="loading"><img src="images/loading.gif" /></div>';	
			}
		}
		xmlhttp.send(null);	
	}
} 

function ajax_japan_c(searchkey) {	
	var xmlhttp=createAjax();	
	if (xmlhttp) {	
		var imglist=document.getElementById('m_menu');	
		xmlhttp.open('get','ajax_p.php?searchkey='+escape(searchkey),true);	
		xmlhttp.onreadystatechange=function() {		
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
				imglist.innerHTML=unescape(xmlhttp.responseText);
				
				obj=document.getElementById("m_menu").getElementsByTagName("li"); 
				j=obj.length 
				PagesLen=Math.ceil(j/listNum); 
				upPage(0) 
				
				
				
 	
				
				
			}
			else {
				imglist.innerHTML='<div id="loading"><img src="images/loading.gif" /></div>';	
			}
		}
		xmlhttp.send(null);	
	}
} 




















function signupform(theform){
if(!CheckEmail(theform.t_mail)) return false;
if(!CheckEmpty(theform.t_password, "密碼")) return false;
if(!CheckMinLength(theform.t_password,6,"密碼")) return false;
if(!CheckRepeat2(theform.t_password,theform.t_password1,"密碼")) return false;
if(!CheckEmpty(theform.t_name,"姓名")) return false;
if(!CheckEmpty(theform.t_tel, "聯絡電話")) return false;
if(!CheckEmpty(theform.c_code, "驗證碼")) return false;
}


function contactusform(theform){
if(!CheckEmpty(theform.c_name,"姓名")) return false;
if(!CheckEmpty(theform.c_con_name, "公司名稱")) return false;
if(!CheckEmail(theform.c_mail)) return false;
if(!CheckEmpty(theform.c_tel, "電話")) return false;
if(!CheckEmpty(theform.c_code, "驗證碼")) return false;
}

function passwordform(theform){
if(!CheckEmpty(theform.p_mail,"電子郵件")) return false;
 if(!CheckEmail(theform.p_mail)) return false;
 if(!CheckEmpty(theform.c_code, "驗證碼")) return false;
}

function logingoform(theform){
if(!CheckEmpty(theform.login_email,"電子郵件")) return false;
 if(!CheckEmail(theform.login_email)) return false;
 if(!CheckEmpty(theform.password, "密碼")) return false;
 if(!CheckEmpty(theform.vcode, "驗證碼")) return false;
 
}



function profileform(theform){
if(!CheckEmpty(theform.t_name,"姓名")) return false;	
if(!CheckEmpty(theform.t_dateofbirth,"生日")) return false;
if(!CheckEmpty(theform.t_tel, "聯絡電話")) return false;
 if(!CheckEmpty(theform.t_postalcode, "郵遞區號")) return false;
if(!CheckEmpty(theform.t_addressline1, "地址")) return false;
 }
 
 
function pwform(theform){
if(!CheckEmpty(theform.t_pw, "密碼")) return false;
if(!CheckEmpty(theform.t_pw1, "新密碼")) return false;
if(!CheckMinLength(theform.t_pw1,6,"新密碼")) return false;
if(!CheckRepeat2(theform.t_pw1,theform.t_pw2,"新密碼")) return false;
}


function show_shop(){
 document.getElementById('New4').style.display = "";
 document.getElementById('New5').style.display = "";
 document.getElementById('New6').style.display = "";
 document.getElementById('New7').style.display = "";
 document.getElementById('New8').style.display = "";
 document.getElementById('New9').style.display = "";
 document.getElementById('New10').style.display = "";
 }
 
 
function total(comm,exchange,fun,transfer,transfer2,troky,fun2_t,fun3_t,top_f,tban){
	
	if(!CheckEmpty(form2.sp_url1,"網址")) return false;	
	if(!CheckEmpty(form2.sp_item1,"商品名稱")) return false;
 	if(!CheckEmpty(form2.sp_qty1,"數量")) return false;
	if(!CheckInteger(form2.sp_qty1,"數量")) return false;
	if(!CheckEmpty(form2.sp_price1,"金額")) return false;
    if(!CheckInteger(form2.sp_price1,"金額")) return false;
	
	var sum=Math.ceil(document.form2.sp_price1.value*document.form2.sp_qty1.value);
	var shopM=1;
	for(f=2;f<=10;f++){
		var fsd=eval("document.form2.sp_url"+f);
		var furl=eval("form2.sp_url"+f);
		var fitem=eval("form2.sp_item"+f);
		var fsize=eval("form2.sp_size"+f);
		var fprice=eval("form2.sp_price"+f);
		var fqty=eval("form2.sp_qty"+f);
		
	   	 if (fsd.value!=''){
			if(!CheckEmpty(furl,"網址")) return false;	
			 if(!CheckEmpty(fitem,"商品名稱")) return false;
			 if(!CheckEmpty(fqty,"數量")) return false;
			 if(!CheckInteger(fqty,"數量")) return false;
			 if(!CheckEmpty(fprice,"金額")) return false;
    		 if(!CheckInteger(fprice,"金額")) return false;
			 
			 var sum=sum+Math.ceil(fqty.value*fprice.value);
			 var shopM=f;
 		
		 }
		
		
		}
	
	/*日本*/
	    document.form2.taotal.value=sum;
		
	if(comm==1){
		var funTaolat=Math.ceil(fun*shopM);
		if(funTaolat>top_f){funTaolat=top_f;}
		document.getElementById('totalsum').innerHTML=sum;
		
 		document.getElementById('ffun1').innerHTML=funTaolat;
		document.form2.funok.value=funTaolat;
		
		
		
		document.getElementById('jpy').style.display = "";
		document.getElementById('ntw').style.display = "none";
		if(sum>=troky){
		var sum=Math.ceil(sum*exchange)+parseInt(funTaolat)+Math.ceil(transfer2*exchange);
		//todf
		document.getElementById('todf').innerHTML=transfer2;
		document.form2.todfok.value=transfer2;
		}else{var sum=Math.ceil(sum*exchange)+parseInt(funTaolat)+Math.ceil(transfer*exchange);
		document.getElementById('todf').innerHTML=transfer;
		document.form2.todfok.value=transfer;
		}
		
		document.form2.jpysum.value=sum;
		document.form2.jpysum_ok.value=sum;
		document.getElementById('j_ps').innerHTML='未知款項 a.日本當地運費 + b.國際運費 + c.國內宅配費用 + d.其他額外費用';
		}
		
	/*台灣*/	
	if(comm==2){
		//計算手續費
		var fun2=Math.ceil(parseInt(sum)*(parseInt(fun2_t)/100));
		if(fun2<fun3_t){fun2=fun3_t;}
		document.form2.todfok.value=parseInt(tban);
  		document.getElementById('totalsum2').innerHTML=sum;
		document.getElementById('ffun2').innerHTML=fun2;
		document.getElementById('ffun4').innerHTML=tban;
		document.form2.funok.value=fun2;
		document.getElementById('ntw').style.display = "";
		document.getElementById('jpy').style.display = "none";
		var sum=Math.ceil(parseInt(sum)+parseInt(fun2)+parseInt(tban));
		document.form2.twsum.value=sum;
		document.form2.twsum_ok.value=sum;
		document.getElementById('j_ps').innerHTML='未知款項 a.國內運費 + b.國際運費 + c.其他額外費用';
		}
	
  } 
 
 
 
 
 
 
 function shopform(comm,theform){
	 
	if(!CheckEmpty(theform.sp_url1,"網址")) return false;	
	if(!CheckEmpty(theform.sp_item1,"商品名稱")) return false;
 	if(!CheckEmpty(theform.sp_qty1,"數量")) return false;
	if(!CheckInteger(theform.sp_qty1,"數量")) return false;
	if(!CheckEmpty(theform.sp_price1,"金額")) return false;
    if(!CheckInteger(theform.sp_price1,"金額")) return false;	 
	 
     for(f=2;f<=10;f++){
		var fsd=eval("document.form2.sp_url"+f);
		var furl=eval("form2.sp_url"+f);
		var fitem=eval("form2.sp_item"+f);
		var fsize=eval("form2.sp_size"+f);
		var fprice=eval("form2.sp_price"+f);
		var fqty=eval("form2.sp_qty"+f);
		
	   	 if (fsd.value!=''){
			if(!CheckEmpty(furl,"網址")) return false;	
			 if(!CheckEmpty(fitem,"商品名稱")) return false;
 			 if(!CheckEmpty(fqty,"數量")) return false;
			 if(!CheckInteger(fqty,"數量")) return false;
			 if(!CheckEmpty(fprice,"金額")) return false;
    		 if(!CheckInteger(fprice,"金額")) return false;
 		 }
     }   
	 
      if(comm==1){
		  if(!CheckEmpty(theform.jpysum_ok,"結算金額")) return false;
          if(!CheckInteger(theform.jpysum_ok,"結算金額")) return false;	 
  		}
		
	/*台灣*/	
	if(comm==2){
		  if(!CheckEmpty(theform.twsum_ok,"結算金額")) return false;
          if(!CheckInteger(theform.twsum_ok,"結算金額")) return false;	 
  		}
	
  	 
    if(!CheckEmpty(theform.s_name,"收件人姓名")) return false;	
    if(!CheckEmpty(theform.s_tel, "聯絡電話")) return false;
     if(!CheckEmpty(theform.s_pos, "郵遞區號")) return false;
    if(!CheckEmpty(theform.s_add, "收件人地址")) return false;
	 
	 
 }
 
 function delok(sid,pto,sf,d001,amount) {
	
  if(confirm('執行此動作，確定嗎﹖'))
  {
	  
	  
	  
	  
	var xmlhttp=createAjax();	
	if (xmlhttp) {	
	
	    if(sf==2){
			var fqty='dA'+d001;
			
			if(amount<pto){
		  alert("儲存金不足！請補足後再支付！");
           return false;
		  }
 			}
			
		if(sf==5){
			var fqty='dA'+d001;
			
			if(amount<pto){
		  alert("儲存金不足！請補足後再支付！");
           return false;
		  }
 			}	
			
			
		if(sf==1){
			var fqty='dB'+d001;
		}
		
		
		
		
		
		var imglist=document.getElementById(fqty);	
		xmlhttp.open('get','save_form.php?action=orddel&sid='+sid+'&ptoto='+pto+'&to='+sf,true);	
		xmlhttp.onreadystatechange=function() {		
			if (xmlhttp.readyState==4 && xmlhttp.status==200) {	
				imglist.innerHTML=unescape(xmlhttp.responseText);
			}
			else {
				imglist.innerHTML='<div id="loading"><img src="images/loading.gif" /></div>';	
			}
		}
		xmlhttp.send(null);	
	}


 	 
  }else
{
alert("此動作已經被取消");
return false;
}
 }
 
 
 
 function bankoutform(theform){
if(!CheckEmpty(theform.bank_name, "銀行名稱")) return false;
if(!CheckEmpty(theform.bank_name1, "分行名稱")) return false;
if(!CheckEmpty(theform.us_name, "帳戶名")) return false;
if(!CheckEmpty(theform.bank_id, "帳號")) return false;
 }
 
  function usermsgform(theform){
if(!CheckEmpty(theform.title, "標題")) return false;
if(!CheckEmpty(theform.content, "內容")) return false;
 }
 
 
 
 
 function total_text(comm,t1,t2,t3,theform,troky,price1_to,ex,gogo_to,fun,fun2,fun3,shipping,see_to,cdd){
	if(!CheckEmpty(theform.price1_to,"金額")) return false;
    if(!CheckInteger(theform.price1_to,"金額")) return false;	
	if(!CheckEmpty(theform.gogo_to,"當地運費")) return false;
    if(!CheckInteger(theform.gogo_to,"當地運費")) return false;		
	if(!CheckEmpty(theform.see_to,"國際運輸")) return false;
    if(!CheckInteger(theform.see_to,"國際運輸")) return false;		
	
	
	
    //日本
    if(comm==1){
		var jpto=Math.ceil(parseInt(gogo_to)+parseInt(price1_to));
		document.getElementById('NT').innerHTML='JPY$';
		document.getElementById('NT2').innerHTML='JPY$';
		if(price1_to>troky){document.getElementById('transfer_to').innerHTML=t2; jpto=Math.ceil(jpto+parseInt(t2));}
		if(price1_to<=troky){document.getElementById('transfer_to').innerHTML=t1; jpto=Math.ceil(jpto+parseInt(t1));}
		jpto=Math.ceil(jpto*ex+parseInt(fun));
		document.getElementById('freefee').innerHTML=fun;
		document.getElementById('s01').innerHTML='一筆5萬円 ( 含 )以下收350円 ；一筆5萬円以上收630円。';
		document.getElementById('s02').innerHTML='500~2500円（日本店家收多少，我們就收多少）。請參考您要購買的商品網頁關於運費說明';
		document.getElementById('s03').innerHTML='日本代購手續費一筆100元！最多收取500元';
		document.getElementById('s04').innerHTML='<strong>國際運費：</strong><em >重量</em><label><input name="see_to" type="text" id="see_to" value="'+parseInt(see_to)+'" size="8" />KG X 運費NT$'+parseInt(shipping)+'</label><span class="dfg">&lt;&lt;&lt;請輸入</span>';
		document.getElementById('s05').innerHTML='以重量計算，每公斤280元 ( 特殊商品除外 )';
		document.getElementById('s06').innerHTML='公司為長期大量簽約戶， 宅配費用全台超便宜。';
		jpto=Math.ceil(jpto+parseInt(see_to)*parseInt(shipping)+parseInt(cdd));
		document.getElementById('tatol').innerHTML=jpto;
 		
		}
    //台灣
    if(comm==2){
		var jpto=Math.ceil(parseInt(price1_to)+parseInt(t3));
		document.getElementById('gogo_to').value=0;
		document.getElementById('NT').innerHTML='NT$';
		document.getElementById('NT2').innerHTML='NT$';
		document.getElementById('transfer_to').innerHTML=t3;
		var fuunn=Math.ceil(parseInt(price1_to)*(parseInt(fun2)/100));
		if(fuunn<fun3){fuunn=fun3;}
		document.getElementById('freefee').innerHTML=fuunn;
		jpto=Math.ceil(jpto+parseInt(fuunn)+parseInt(see_to)+parseInt(cdd));
		document.getElementById('s01').innerHTML='一筆收NT$17';
		document.getElementById('s02').innerHTML='台灣代購無此流程不需收款。';
		document.getElementById('s03').innerHTML='商品台幣含稅價的'+fun2+'%，最低收NT$'+fun3;
		document.getElementById('s04').innerHTML='<strong>國際運費：</strong><label><em>NT$</em><input name="see_to" type="text" id="see_to" value="'+parseInt(see_to)+'" size="8" /></label> <span class="dfg">&lt;&lt;&lt;請輸入</span>';
		document.getElementById('s05').innerHTML='請參考 EMS國際快遞<a href="http://www.post.gov.tw/post/internet/a_mail/index.jsp?ID=16200" target="_blank">中華郵政國際快捷郵件資費表</a>，並輸入資料';
		document.getElementById('s06').innerHTML='50~80元（店家收多少，我們就收多少）';
		document.getElementById('tatol').innerHTML=jpto;
		}
 	 
	 
 }
 
 
 function total_1(){
	
	if(!CheckEmpty(form2.sp_url1,"網址")) return false;	
	if(!CheckEmpty(form2.sp_item1,"商品名稱")) return false;
 	if(!CheckEmpty(form2.sp_qty1,"數量")) return false;
	if(!CheckInteger(form2.sp_qty1,"數量")) return false;
	if(!CheckEmpty(form2.sp_price1,"金額")) return false;
    if(!CheckInteger(form2.sp_price1,"金額")) return false;
	 
	
  } 
 
 
 
