function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) 
  x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; 
  if(d.images){ 
  if(!d.MM_p) 
	d.MM_p=new Array();
	var i,j=d.MM_p.length,a=MM_preloadImages.arguments; 
	for(i=0; i<a.length; i++)
	if (a[i].indexOf("#")!=0){ 
		d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}
		}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  
  if(!d) d=document; 
  if((p=n.indexOf("?"))>0&&parent.frames.length) {
	d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function small2big(where)
{
	where.value=where.value.toUpperCase();
}	

/*
*		個人身份証字號檢查程式 START
*/
function output1(city,sex,mid)
/* 輸出檢查碼 */
{
	var i=0;
	var ret=0;
	var calsex=0;
	var calmid=0;
	var calcity=0;
	/* 
	* 開始計算所有的加權值 
	*/
	/* 計算 sex 的加權值 */
	calsex = eval(sex)*8;
	/* 計算中間值的加權值 */
	for (i=0 ; i < mid.length ; i++)
	{
		calmid = calmid + (7-i) * eval(mid.substring(i,i+1));
	}
	/* 計算縣市的加權值 */
	calcity = eval(city.substring(0,1)) + eval(city.substring(1,2)) * 9;
	/* 
	* 結束計算所有的加權值 
	*/
	
	ret = calcity+calsex+calmid;

	ret = ret % 10;
	ret = 10 - ret;
	ret = ret % 10;


	return ret;
}

function personal_id_check(_personal_id)
{
	var thestr = _personal_id;
	var i=0;
	var ret2 = 0;
	
	//out001.a.value = "分析中 analyzing...";
	if (thestr.length != 10)
	{
		//out001.a.value = "invalid(length) 長度不正確";
		//return 0;
		alert("您的會員帳號（您的身份證字號）輸入錯誤，請重新輸入！");
		return false;
	}
	var city = thestr.substring(0,1).toUpperCase();
	var sex  = thestr.substring(1,2);
	var mid  = thestr.substring(2,9);
	
	/* 分析縣市 */
	var acc = 0;
	var city_tmp;

	if ((city == "A") || (city == "a")) { acc = 10; }
	else if ((city == "B") || (city == "b")) { acc = 11; }
	else if ((city == "C") || (city == "c")) { acc = 12; }
	else if ((city == "D") || (city == "d")) { acc = 13; }
	else if ((city == "E") || (city == "e")) { acc = 14; }
	else if ((city == "F") || (city == "f")) { acc = 15; }
	else if ((city == "G") || (city == "g")) { acc = 16; }
	else if ((city == "H") || (city == "h")) { acc = 17; }
	else if ((city == "J") || (city == "j")) { acc = 18; }
	else if ((city == "K") || (city == "k")) { acc = 19; }
	else if ((city == "L") || (city == "l")) { acc = 20; }
	else if ((city == "M") || (city == "m")) { acc = 21; }
	else if ((city == "N") || (city == "n")) { acc = 22; }
	else if ((city == "P") || (city == "p")) { acc = 23; }
	else if ((city == "Q") || (city == "q")) { acc = 24; }
	else if ((city == "R") || (city == "r")) { acc = 25; }
	else if ((city == "S") || (city == "s")) { acc = 26; }
	else if ((city == "T") || (city == "t")) { acc = 27; }
	else if ((city == "U") || (city == "u")) { acc = 28; }
	else if ((city == "V") || (city == "v")) { acc = 29; }
	else if ((city == "W") || (city == "w")) { acc = 30; }
	else if ((city == "X") || (city == "x")) { acc = 31; }
	else if ((city == "Y") || (city == "y")) { acc = 32; }
	else if ((city == "Z") || (city == "z")) { acc = 33; }
	else if ((city == "I") || (city == "i")) { acc = 34; }
	else if ((city == "O") || (city == "o")) { acc = 35; }
	city_tmp = acc+city;
	
	if (i >= city_tmp.length)
	{
		//out001.a.value = "invalid(city) 縣市不正確";
		//return 0;
		alert("您的會員帳號（您的身份證字號）輸入錯誤，請重新輸入！");
		return false;
	}
	/* 分析性別 */
	if (sex!="1" && sex!="2")
	{
		//out001.a.value = "invalid(gender) 性別不正確";
		//return 0;
		alert("您的會員帳號（您的身份證字號）輸入錯誤，請重新輸入！");
		return false;
	}
	/* 分析中間值 */
	if (!checkdigitString(mid) )
	{
		//out001.a.value = "invalid(serial) 流水號不正確";
		//return 0;
		alert("您的會員帳號（您的身份證字號）輸入錯誤，請重新輸入！");
		return false;
	}
	/* 計算檢查碼 */
	ret2 = output1(city_tmp,sex,mid);

	if (ret2.toString() != thestr.substring(9,10) )
	{
		//out001.a.value = "invalid(check) 檢查碼不正確";
		//return 0;
		alert("您的會員帳號（您的身份證字號）輸入錯誤，請重新輸入！");
		return false;
	}
	//out001.a.value = "valid 正確";
	return true;
}
/*
*		個人身份証字號檢查程式 END
*/

function personal_id_check1(_personal_id) {
        var acc = 0;
        d0 = _personal_id.charAt(0);
        d1 = _personal_id.charAt(1);
        d2 = _personal_id.charAt(2);
        d3 = _personal_id.charAt(3);
        d4 = _personal_id.charAt(4);
        d5 = _personal_id.charAt(5);
        d6 = _personal_id.charAt(6);
        d7 = _personal_id.charAt(7);
        d8 = _personal_id.charAt(8);
        d9 = _personal_id.charAt(9);
        if ((d0 == "A") || (d0 == "a")) { acc = 10; }
        else if ((d0 == "B") || (d0 == "b")) { acc = 11; }
        else if ((d0 == "C") || (d0 == "c")) { acc = 12; }
        else if ((d0 == "D") || (d0 == "d")) { acc = 13; }
        else if ((d0 == "E") || (d0 == "e")) { acc = 14; }
        else if ((d0 == "F") || (d0 == "f")) { acc = 15; }
        else if ((d0 == "G") || (d0 == "g")) { acc = 16; }
        else if ((d0 == "H") || (d0 == "h")) { acc = 17; }
        else if ((d0 == "J") || (d0 == "j")) { acc = 18; }
        else if ((d0 == "K") || (d0 == "k")) { acc = 19; }
        else if ((d0 == "L") || (d0 == "l")) { acc = 20; }
        else if ((d0 == "M") || (d0 == "m")) { acc = 21; }
        else if ((d0 == "N") || (d0 == "n")) { acc = 22; }
        else if ((d0 == "P") || (d0 == "p")) { acc = 23; }
        else if ((d0 == "Q") || (d0 == "q")) { acc = 24; }
        else if ((d0 == "R") || (d0 == "r")) { acc = 25; }
        else if ((d0 == "S") || (d0 == "s")) { acc = 26; }
        else if ((d0 == "T") || (d0 == "t")) { acc = 27; }
        else if ((d0 == "U") || (d0 == "u")) { acc = 28; }
        else if ((d0 == "V") || (d0 == "v")) { acc = 29; }
        else if ((d0 == "W") || (d0 == "w")) { acc = 30; }
        else if ((d0 == "X") || (d0 == "x")) { acc = 31; }
        else if ((d0 == "Y") || (d0 == "y")) { acc = 32; }
        else if ((d0 == "Z") || (d0 == "z")) { acc = 33; }
        else if ((d0 == "I") || (d0 == "i")) { acc = 34; }
        else if ((d0 == "O") || (d0 == "o")) { acc = 35; }
        if (acc == 0) {
                alert("請輸入您的『身份證號碼』第一個英文字母！");
                return false;
        } else {
                accstr = new String(acc);
                acc_1 = (accstr).charAt(0);
                acc_2 = (accstr).charAt(1);
                certsum = 1*acc_1 + 9*acc_2 + 8*d1 + 7*d2 + 6*d3 + 5*d4 + 4*d5 + 3*d6 + 2*d7 + 1*d8;
                certsum_2 = parseInt(certsum%10);
                certsum_3 = 10 - certsum_2;
                if (d9 != certsum_3) {
                        alert("您的會員帳號（您的身份證字號）輸入錯誤，請重新輸入！");
                        return false;
                }
        }
		return true;
}

function check_number_format(_cell){							//檢查電話格式是否純數值
        if(_cell.match(/^([0-9]|[\-])+$/g) && (_cell.length>9 && _cell.length<15)){
            return true;
        }else{
			return false;
		}
}

function isTel(str){											//檢查電話程式2
       var reg=/^([0-9]|[\-])+$/g ;
       if(str.length<10 || str.length>15){
        return false;
       }else{
         return reg.exec(str);
       }
}

function check_email_format(_email) {							//檢查email格式
  err = '';
  i = 0;
  reg = new RegExp("^[a-zA-Z0-9\-\.\_]+\@[a-zA-Z0-9\-\.]+(\\.)+([a-zA-Z]{2,4})$","gi");
  if((_email.value == '') || (!reg.test(_email.value))) 
  {
	  return false;
  }
  	return true;
}


function checkForm(form){
	if (form['total_price'].value == '0') {
		alert('你尚未選擇要買的商品');
		form['total_price'].focus();
		return false;
	}
	return true;
}

function check_vip_buy_form(form){
	if ( (form['point_type'][0].checked == true || form['point_type'][1].checked == true) ) {
		if(form['point_type'][0].checked == true) {
			if( (form['point'][0].checked == true || form['point'][1].checked == true || form['point'][2].checked == true || form['point'][3].checked == true) ) {
				if(document.getElementById('creditcard').checked)
					alert('銀行認證提醒:\n\n親愛的客戶您好：為確保您的交易安全，即日起部份發卡銀行會要求您註冊網路刷卡安全驗証，\n以確保您的卡片不會遭到盜刷，您僅需透過一次安全驗證，未來即可使用於其他網路上刷卡服務。\n以下是需要進行「信用卡安全驗證」之行庫:\n\n‧中國信託商業銀行	‧新光銀行	‧日盛銀行\n‧國泰世華銀行		‧台新銀行	‧永豐銀行\n‧台灣中小企業銀行	‧第一銀行	‧土地銀行\n‧合作金庫銀行		‧彰化銀行	‧聯邦銀行\n');
				form.submit();
				return true;
			}
		}else if( (form['point_type'][1].checked == true) ) {
				if(document.getElementById('creditcard').checked)
					alert('銀行認證提醒:\n\n親愛的客戶您好：為確保您的交易安全，即日起部份發卡銀行會要求您註冊網路刷卡安全驗証，\n以確保您的卡片不會遭到盜刷，您僅需透過一次安全驗證，未來即可使用於其他網路上刷卡服務。\n以下是需要進行「信用卡安全驗證」之行庫:\n\n‧中國信託商業銀行	‧新光銀行	‧日盛銀行\n‧國泰世華銀行		‧台新銀行	‧永豐銀行\n‧台灣中小企業銀行	‧第一銀行	‧土地銀行\n‧合作金庫銀行		‧彰化銀行	‧聯邦銀行\n');
				form.submit();
				return true;
		}
		alert('您尚未選擇要買的加值項目 , 請先選擇一項欲購買的加值項目');
		return false;
	}
	alert('您尚未選擇要買的加值項目 , 請先選擇一項欲購買的加值項目');
	return false;
}

function check_login_form() {

    if(document.getElementById('userdata_personal_id').value == ''){
    	alert('請輸入您的會員帳號（您的身份證字號）');
      	document.getElementById('userdata_personal_id').focus();
      	return false;
    
    }else if(document.getElementById('userdata_passwd').value == ''){
      
      alert('請輸入您的登入密碼');
		document.getElementById('userdata_passwd').focus();
      	return false;
    
    }else if(!personal_id_check(document.getElementById('userdata_personal_id').value)){

		document.getElementById('userdata_personal_id').focus();
		return false
	}

    return true;
    
  }

function check_form_regdata(form) {	
	if(document.getElementById('personal_id').value == ''){
		alert('請輸入您的身份証字號，做為您的會員帳號');
		document.getElementById('personal_id').focus();
		return false;
	}else if(!check_number_format(document.getElementById('cellphone').value)){
		alert('請輸入您的行動電話號碼');
		document.getElementById('cellphone').focus();
		return false;
	}else if(document.getElementById('name').value == ''){
		alert('請輸入您的姓名');
		document.getElementById('name').focus();
		return false;
	}else if(document.getElementById('email').value == ''){
		alert('請輸入您的email信箱');
		document.getElementById('email').focus();
		return false;		
	}else if( document.getElementById('passwd').value != document.getElementById('passwd2').value || document.getElementById('passwd').value == ''){
	      alert('您輸入的登入密碼兩者比對不符，請重新輸入');
	      document.getElementById('passwd').focus();
		  return false
    }else if(!personal_id_check(document.getElementById('personal_id').value)){
		return false
	}else if(!document.getElementById('law_rule_agree').checked){
		alert('請確實詳閱會員使用條款！詳閱後請勾選同意欄位，謝謝!');
		document.getElementById('law_rule_agree').focus();
		return false;
	}else{							//最後如果在上述所有條件全達成的情況下則進行送出此表單。
		form.submit();
		return true;
	}
}


function check_login(form) {


	if(form['u_cellphone'].value == ''){
	      
	      alert('請輸入您的會員帳號');
	      form['u_cellphone'].focus();
	
	}else if(form['u_email'].value == ''){
	      
	      alert('請輸入您的登入密碼');
	      form['u_email'].focus();
	    
	}else{
		
		form.submit();
		
	}
}

function alertAndToIndex() {
    alert('謝謝!您將導回至首頁');
    location.href='../index.php';
}

function countPrice(result , num , price)
{
	result.value=num*price;
}

function countTotalPrice(total_price , total_number)
{
	var sum=0;
	for(var i=0 ; i<total_number ; i++)
	{
		sum+=parseInt(document.purchase['price'+i].value);
	}
	total_price.value = sum;
}

function check_buy(form){
	if(form.personal_id.value == ''){
		alert('請輸入您的身份証字號，做為您的會員帳號');
		form.personal_id.focus();
		return false;
	}else if(!check_number_format(form.cellphone.value)){
		alert('請輸入您的行動電話號碼');
		form.cellphone.focus();
		return false;
	}else if(form.name.value == ''){
		alert('請輸入您的姓名');
		form.name.focus();
		return false;
	}else if(form.email.value == ''){
		alert('請輸入您的email信箱');
		form.email.focus();
		return false;		
	}else if( form.passwd.value != form.passwd2.value || form.passwd.value == ''){
	      alert('您輸入的登入密碼兩者比對不符，請重新輸入');
	      form.passwd.focus();
		  return false;
    }else if(!personal_id_check(form.personal_id.value)){
 		  return false;
	}else{
		form.submit();
		return true;
	}
}

function countpoint()                                    //對應personal_buy.php的計算點程式。
{
    var main_form=document.vip_buy_form;
    if(main_form['point_type'][0].checked) {
        if(main_form['point'][0].checked){                //第1個radiobutton 以秒計費型點卡
            main_form["totalmoney1"].value =  main_form['point'][0].id;
            main_form["totalmoney2"].value = 0;
            main_form['totalcount'].value = parseInt(main_form["totalmoney1"].value) + parseInt(main_form["totalmoney2"].value);
        }else if(main_form['point'][1].checked){        //第2個radiobutton 以秒計費型點卡
            main_form["totalmoney1"].value = main_form['point'][1].id;
            main_form["totalmoney2"].value = 0;
            main_form['totalcount'].value = parseInt(main_form["totalmoney1"].value) + parseInt(main_form["totalmoney2"].value);
        }else if(main_form['point'][2].checked){        //第3個radiobutton 以秒計費型點卡
            main_form["totalmoney1"].value = main_form['point'][2].id;
            main_form["totalmoney2"].value = 0;
            main_form['totalcount'].value = parseInt(main_form["totalmoney1"].value) + parseInt(main_form["totalmoney2"].value);
        }else {
            main_form['totalcount'].value=0;
        }
    }else if(main_form['point_type'][1].checked){        //500點 以次計費型點卡
        main_form["totalmoney1"].value = 0;
        //main_form["totalmoney2"].value =  main_form['point'][3].id;
        t = document.getElementsByName('point').length-1;
        main_form["totalmoney2"].value =  main_form['point'][t].id;
        main_form['totalcount'].value = parseInt(main_form["totalmoney1"].value) + parseInt(main_form["totalmoney2"].value);        
    }else {
        main_form['totalcount'].value= 0;
    }
        
}

function countmoney(islogin)
{
	//if(this.form["products_type[1]"].checked)this.form.totalmoney.value  = this.form.point1.value * this.form.amount1.value;
	if(islogin)
	{
		if( document.getElementById("products_type[1]").checked && document.getElementById("products_type[2]").checked )
		{
			document.purchase.totalmoney1.value = parseInt(document.purchase.point1.value) * parseInt(document.purchase.amount1.value);
			document.purchase.totalmoney2.value = parseInt(document.purchase.point2.value) * parseInt(document.purchase.amount2.value);
			document.purchase.totalcount.value =  parseInt(document.purchase.totalmoney1.value) + parseInt(document.purchase.totalmoney2.value);
		}
		else if( document.getElementById("products_type[1]").checked && !document.getElementById("products_type[2]").checked)
		{
			//document.purchase.point2.value = 0;
			document.purchase.amount2.value = 0;
			document.purchase.totalmoney1.value = parseInt(document.purchase.point1.value) * parseInt(document.purchase.amount1.value);
			document.purchase.totalmoney2.value = parseInt(document.purchase.point2.value) * parseInt(document.purchase.amount2.value);
			document.purchase.totalcount.value =  parseInt(document.purchase.totalmoney1.value) + parseInt(document.purchase.totalmoney2.value);
		}
		else if( document.getElementById("products_type[2]").checked && !document.getElementById("products_type[1]").checked)
		{
			document.purchase.point1.value = 0;
			document.purchase.amount1.value = 0;
			document.purchase.totalmoney1.value = parseInt(document.purchase.point1.value) * parseInt(document.purchase.amount1.value);
			document.purchase.totalmoney2.value = parseInt(document.purchase.point2.value) * parseInt(document.purchase.amount2.value);
			document.purchase.totalcount.value =  parseInt(document.purchase.totalmoney1.value) + parseInt(document.purchase.totalmoney2.value);
		}
		else
		{
			document.purchase.point1.value = 0;
			document.purchase.amount1.value = 0;
			//document.purchase.point2.value = 0;
			document.purchase.amount2.value = 0;
			document.purchase.totalmoney1.value = parseInt(document.purchase.point1.value) * parseInt(document.purchase.amount1.value);
			document.purchase.totalcount.value =  parseInt(document.purchase.totalmoney1.value) + parseInt(document.purchase.totalmoney2.value);
		}
	}
	else
	{
		var sum=0;
		if( document.getElementById("products_type[1]").checked && document.getElementById("products_type[2]").checked )
		{
			document.purchase.totalmoney1.value = parseInt(document.purchase.point1.value) * parseInt(document.purchase.amount1.value);
			document.purchase.totalmoney2.value = parseInt(document.purchase.point2.value) * parseInt(document.purchase.amount2.value);
			document.purchase.totalcount.value = parseInt(document.purchase.usertype_price.value) + parseInt(document.purchase.totalmoney1.value) + parseInt(document.purchase.totalmoney2.value);
		}
		else if( document.getElementById("products_type[1]").checked && !document.getElementById("products_type[2]").checked)
		{
			//document.purchase.point2.value = 0;
			document.purchase.amount2.value = 0;
			document.purchase.totalmoney1.value = parseInt(document.purchase.point1.value) * parseInt(document.purchase.amount1.value);
			document.purchase.totalmoney2.value = parseInt(document.purchase.point2.value) * parseInt(document.purchase.amount2.value);
			document.purchase.totalcount.value = parseInt(document.purchase.usertype_price.value) + parseInt(document.purchase.totalmoney1.value) + parseInt(document.purchase.totalmoney2.value);
		}
		else if( document.getElementById("products_type[2]").checked && !document.getElementById("products_type[1]").checked)
		{
			document.purchase.point1.value = 0;
			document.purchase.amount1.value = 0;
			document.purchase.totalmoney1.value = parseInt(document.purchase.point1.value) * parseInt(document.purchase.amount1.value);
			document.purchase.totalmoney2.value = parseInt(document.purchase.point2.value) * parseInt(document.purchase.amount2.value);
			document.purchase.totalcount.value = parseInt(document.purchase.usertype_price.value) + parseInt(document.purchase.totalmoney1.value) + parseInt(document.purchase.totalmoney2.value);
		}
		else
		{
			document.purchase.point1.value = 0;
			document.purchase.amount1.value = 0;
			//document.purchase.point2.value = 0;
			document.purchase.amount2.value = 0;
			document.purchase.totalmoney1.value = parseInt(document.purchase.point1.value) * parseInt(document.purchase.amount1.value);
			document.purchase.totalcount.value = parseInt(document.purchase.usertype_price.value) + parseInt(document.purchase.totalmoney1.value) + parseInt(document.purchase.totalmoney2.value);
		}
	}
}

function pay_mod_select()
{
	/*
	switch (document.form_pay_mod.pay_mod.value) {
		case 0:
			location.href = "./vip_sales_buy-4_atm.php";
			break;
		case 1:
			location.href = "./vip_sales_buy-4_card.php";
			break;
	}*/
	
	if(document.form_pay_mod.pay_mod[0].checked){
		location.href = "./vip_sales_buy-4_atm.php?pay_mod=1";
	}else if(document.form_pay_mod.pay_mod[1].checked){
		location.href = "./vip_sales_buy-4_card.php?pay_mod=2";
	}
}	

function printthispage(){
	window.print();
}

function checkreg(form) {
	if( form['u_id_number'].value == '' ){		//Check 身份証字號
		alert('請輸入您的會員帳號');
		form['u_id_number'].focus();
	}else if( form['u_password'].value == '' ){	//Check 密碼
		alert('請輸入您的登入密碼');
		form['u_password'].focus();
	}else if( form['u_type'].value == '0' ){	//Check 會員類型
		alert('請選擇你欲升級的會員方案');
		form['u_type'].focus();
	}else if( form['u_name'].value == '' ){	//Check 會員姓名
		alert('請輸入您的真實姓名');
		form['u_name'].focus();
	}else if( form['u_cellphone'].value == '' ){	//Check 會員手機
		alert('請輸入您的手機');
		form['u_cellphone'].focus();
	}else if( form['u_email'].value == '' ){	//Check 會員E-Mail信箱
		alert('請輸入您的E-Mail信箱');
		form['u_email'].focus();
	}else if( form['u_address'].value == '' ){	//Check 會員聯絡地址
		alert('請輸入您的聯絡地址');
		form['u_address'].focus();
	}else{
		form.submit();
	}
}

function gen_area_code(_type , _city_code){				//接收傳入的城市碼 同步化電話的區碼。  配合資料表同時有對應區域碼之用的。
		if(_type == 'city')
			document.getElementById('userdata_phone').value = _city_code;
		if(_type == 'phone_code')
			document.getElementById('userdata_addr_city').value = _city_code;
}

function AddUpload(){
  up++;
  var images=document.getElementById('images');
  images.innerHTML+='圖 片 '+up+' <input type="file" name="pic[]" size="30"><br />';
}

function show_div(div_id) {
	// hide all the divs
	//document.getElementById('invoice_table_1').style.display = 'div_id';

	// show the requested div
	document.getElementById("invoice_table").style.display = div_id;
}

function show_tr(n, looptime , _name){ //依不同的案例產生不同的選單， n 指定的顯示原素編號  looptime 指定的檢查圈數，  elementname 指定的原素名
	var dis = "";
	var i;
	var	result = "";
	for (i = 1; i <= (looptime); i++) {
		if (i == n) {
			var dis = "";
		}
		else {
			var dis = "none";
		}
		result = _name+i;
		result = result+'';
		if(document.getElementById('_name + i') != null)
			document.getElementById('result').style.display = dis;
	}
}
 
function lock_msg(kururu) {
	if( kururu == '3939889' ) {
		return true;
	}
	else {
		alert('所有灰色功能將在未來完全開放、請耐心等候，\n如有任何不便盡請見諒，或來電客戶我們將為你直接服務謝謝!');
		return false;
	}

}

function count_satisfy_point() {					//計算律師評鑑總分。personal_lawyergrade.php
	var total_grade1 = 0;
	var total_grade2 = 0;
	var total_grade3 = 0;
	var total = 0;
	for( var i = 0 ; i <document.lawyer_satisfy['grade1'].length ; i++) {		//偵測radio box陣列的位數 來進行迴圈取值
		if(document.lawyer_satisfy['grade1'][i].checked)
			total_grade1 = document.lawyer_satisfy['grade1'][i].value;
	}
	for( var i = 0 ; i <document.lawyer_satisfy['grade2'].length ; i++) {		//偵測radio box陣列的位數 來進行迴圈取值
		if(document.lawyer_satisfy['grade2'][i].checked)
			total_grade2 = document.lawyer_satisfy['grade2'][i].value;
	}
	for( var i = 0 ; i <document.lawyer_satisfy['grade3'].length ; i++) {		//偵測radio box陣列的位數 來進行迴圈取值
		if(document.lawyer_satisfy['grade3'][i].checked)
			total_grade3 = document.lawyer_satisfy['grade3'][i].value;
	}
	total = parseInt(total_grade1) + parseInt(total_grade2) + parseInt(total_grade3);	//計算三個值的加總
	document.lawyer_satisfy['calculate_satisfy_point'].value = total;					//寫入頁面的總值input box
}

function check_form_personal_lawyergrade( radioname , numberofradio ) {
	var value1 = document.getElementById('case_type_selection').value;
	var value2 = document.getElementById('lawyer_selection').value;
	if( value1 == 0 ) {
		alert('請選擇此次諮詢的問題類型');
		return false;
	}
	if( value2 == 0 ) {
		alert('請選擇此次諮詢的律師');
		return false;
	}
	for( var ary_x = 0 ; ary_x <= parseInt(numberofradio) ; ary_x++ ) {						//設定三圍陣列，因為有三行Radio Button所以跑三次。
		for( var i = 0 ; i < document.getElementsByName(radioname+ary_x).length ; i++) {	//偵測radio box陣列的位數 來進行迴圈取值
			if(document.getElementsByName(radioname+ary_x)[i].checked) {
				break;
			}else if( i+1 == document.getElementsByName(radioname+ary_x).length ){
				alert('請針對此次的諮詢感想，幫律師打個分數喔! \n 共有三種評分類別 \n 請依照您對於這位律師的三種滿意程度投下您保貴的評鑑分數 \n 分數的程度由1分到5分  1分為很不滿意 ~ 5分為非常滿意 \n 1.律師的問題解決滿意程度 \n 2.律師的專業度 \n 3.律師的親和力 \n 您的 第' + ary_x + '評鑑類別需評分');
				return false;
			}			
		}	
	}
	if (confirm('確定要送出嗎?!')) {
		document.lawyer_satisfy.submit();
	}else 
		this.disabled='disabled';
		return false;
}

/**
 * 計算頁面中所有物件被點擊的總數，便於計算使用者是否有正確的選取頁面中所有的物件後才進送出表單之類的處理。
 *
*/
function check_form_objChecker( formname , numberofradio ) {

    var objForm = document.forms[formname];
    var objLen = objForm.length;
	var cc=0;
    for (var iCount = 0; iCount < objLen ; iCount++) {
            if (objForm.elements[iCount].type == "radio") {
                    if (objForm.elements[iCount].checked )
			cc+=1;
            }
    }
	alert(cc);
return false;
}

function saysomething(msgtosay , confirmthis , url) {
	if(confirmthis) {
		if(confirm(msgtosay))
			location.href=url;
		return false;
	} else {
		alert(msgtosay);
		return true;
	}
	return false;

}

/* 傳入確認訊息與表單ID即可 */
function submitandconfirmtheform(form , msg) {
	if (confirm(msg)) {
		this.getElementById(form).submit();
		return true;
	}
	else {
		return false;
	}
	return false;
}

//function check_lawyer_satisfy(form) {				//計算律師評鑑情況 。personal_lawyergrade.php
//	for(var i=0 ; i<document.getElementsByName('grade1').length ; i++) {
//		if(document.getElementsByName('grade1').item(i).checked == true) {
//			somethingchecked = true;
//		}
//	}
//	if(somethingchecked != true) {
//		alert('somethingnotchecked');
//	}
//}


/*

// 收貨人同購買人
function RecInfo(){
	var form1 = document.form1;
	form1.Receiver.value = form1.CusName.value;
	form1.RecTel.value = form1.InvTel.value;
	form1.RecMobile.value = form1.InvMobile.value;
	form1.RecZip.value = form1.InvZip.value;
	form1.RecAddress.value = form1.InvAddress.value;
	if($('ODVRECMAIL'))
		form1.ODVRECMAIL.value = form1.ODVINVMAIL.value;

	BnameSwitch();
}*/
