// 會員登入表單檢驗
function login_form_check(form)
{
	if (check_character(form.is_uu.value)==false)
	{
		alert("[會員帳號] 僅能使用英文或數字");
		form.is_uu.focus();    
		return false;
	}

	if (check_character(form.is_pp.value)==false)
	{
		alert("[會員密碼] 僅能使用英文或數字");
		form.is_pp.focus();    
		return false;
	}
	
	if (form.is_uu.value == "")
	{
		alert("請輸入您的 [會員帳號]");
		form.is_uu.focus();    
		return false;
	}

	if (form.is_pp.value == "")
	{
		alert("請輸入您的 [會員密碼]");
		form.is_pp.focus();
		return false;
	}

	if (form.verify_code.value == "")
	{
		alert("請輸入 [驗證碼]");
		form.verify_code.focus();
		return false;
	}

	return true;
}

// 聯絡我們表單檢驗
function contact_us_form_check(form)
{
	if (form.name.value == "")
	{
		alert("請填寫您的 [姓名]");
		form.name.focus();    
		return false;
	}

	if (form.email.value.indexOf("@") == -1 || form.email.value.indexOf(".") == -1)
	{
		alert("請填寫正確的 [E-mail]");
		form.email.focus();    
		return false;
	}
     
	re=/^([()0-9-#]){7,}$/;
	if  (form.tel.value.search(re) == -1)
	{
		alert("請填寫正確的 [電話]");
		form.tel.focus();
		return false;
	} 

	if (form.content.value == "")
	{
		alert("請填寫 [聯絡內容]，謝謝 !!");
		form.content.focus();
		return false;
	}

	if (form.verify_code.value == "")
	{
		alert("請輸入 [驗證碼]");
		form.verify_code.focus();
		return false;
	}

	return true;
}

// 檢查字元是否為英文或數字
function check_character(p_id)
{
	var score_i=0,score_c=0;
	var l_str='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789_';

	for (var i = 0;  i < p_id.length;  i++)
  	{
    		if (l_str.indexOf(p_id.charAt(i),0)>=0) 
    		{
    			score_c+=1;
    		}      
	}
	
	if (score_c == p_id.length)
		return true;
	return false;	
}


// 檢查身份證字號格式
function check_id(p_cid)
{
	 p_cid=p_cid.toUpperCase();
	 
	 var l_idstr='          ABCDEFGHJKLMNPQRSTUVXYWZIO' ;
       
     var n=0;
    
     var tot1 = Math.floor((l_idstr.indexOf(p_cid.charAt(0),0)+0)/10) + ((parseFloat(l_idstr.indexOf(p_cid.charAt(0),0)+0)%10) * 9);
     var tot2 = 0;
     for(i=1;i<p_cid.length-1;i++)
     {
		    tot2 = tot2 + p_cid.charAt(i)*(9-i);
     }
     var tot3 = parseFloat(p_cid.charAt(9));
     var tot4 = tot1 + tot2 + tot3;
     if((tot4 % 10)!=0)
        return false;
  return true;	
}


// 檢查日期格式
function check_date_format(p_Year,p_Month,p_Day)
{
	var l_LegalDay = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	var Current_Date = new Date();
	var l_Month = Current_Date.getMonth();
	var l_Year = Current_Date.getYear();
	var l_Day=Current_Date.getDate();
	
	if (!Check_NumValue(p_Year,"0123456789")) return false;
	if (!Check_NumValue(p_Month,"0123456789")) return false;
	if (!Check_NumValue(p_Day,"0123456789")) return false;
		
	if ((p_Year % 400 == 0) || ((p_Year % 4 == 0) && (p_Year % 100 != 0))) l_LegalDay[1] = 29;	
	
	if (p_Month > 12 || p_Month < 1 )  return false;
	
	if (p_Day > l_LegalDay[p_Month-1]  || p_Day < 1 )  return false;
	
	//if (p_Year+"."+p_Month+"."+p_Day > l_Year+"."+l_Month+"."+l_Day) return false;
		
	return true;
}


