
//Check member form
function MemberFormCheck(obj) {
    if (obj.m_account.value == "") {
		alert("Notice! The field of Account was still blank.");
		obj.m_account.focus();
		return false;   
	}
	if (obj.m_password.value == "") {
		alert("Notice! The field of Password was still blank.");
		obj.m_password.focus();
		return false;   
	}
	if (obj.m_password.value != obj.v_password.value) {
		alert("Password and Confirm Password must be the same.");
		obj.v_password.focus();
		return false;   
	}
	if (obj.m_name.value == "") {
		alert("Notice! The field of Name was still blank.");
		obj.m_name.focus();
		return false;   
	}
	if (obj.m_birthday.value == "") {
		alert("Notice! The field of Birthday was still blank.");
		obj.m_birthday.focus();
		return false;   
	}
	if (obj.m_address.value == "") {
		alert("Notice! The field of Address was still blank.");
		obj.m_address.focus();
		return false;   
	}
	if (obj.m_tel.value == "") {
		alert("Notice! The field of Tel was still blank.");
		obj.m_tel.focus();
		return false;   
	}
	if (obj.m_email.value == "") {
		alert("Notice! The field of e-mail was still blank");
		obj.m_email.focus();
		return false;   
	} else {
		if (obj.m_email.value.indexOf("@") == -1 || obj.m_email.value.indexOf(".") == -1) {
			alert("Your e-mail are not in correct format.");
			obj.m_email.focus();
			return false;
		}
	}
	return true;
}
function CartMemberFormCheck(obj) {
	if (obj.m_name.value == "") {
		alert("Notice! The field of Name was still blank.");
		obj.m_name.focus();
		return false;   
	}
	if (obj.m_address.value == "") {
		alert("Notice! The field of Address was still blank.");
		obj.m_address.focus();
		return false;   
	}
	if (obj.m_tel.value == "") {
		alert("Notice! The field of Tel was still blank.");
		obj.m_tel.focus();
		return false;   
	}
	if (obj.m_email.value == "") {
		alert("Notice! The field of e-mail was still blank");
		obj.m_email.focus();
		return false;   
	} else {
		if (obj.m_email.value.indexOf("@") == -1 || obj.m_email.value.indexOf(".") == -1) {
			alert("Your e-mail are not in correct format.");
			obj.m_email.focus();
			return false;
		}
	}
	return true;
}

//Check contact us form
function ContactusFormCheck(obj) {
	if (obj.cu_name.value == "") {
		alert("Notice! The field of Name was still blank.");
		obj.cu_name.focus();
		return false;   
	}
	if (obj.cu_tel.value == "") {
		alert("Notice! The field of Tel was still blank.");
		obj.cu_tel.focus();
		return false;   
	}
	if (obj.cu_email.value == "") {
		alert("Notice! The field of e-mail was still blank.");
		obj.cu_email.focus();
		return false;   
	} else {
		if (obj.cu_email.value.indexOf("@") == -1 || obj.cu_email.value.indexOf(".") == -1) {
			alert("Your e-mail are not in correct format.");
			obj.cu_email.focus();
			return false;
		}
	}
	if (obj.cu_content.value == "") {
		alert("Notice! The field of Content was still blank.");
		obj.cu_content.focus();
		return false;   
	}
	return true;
}

function CheckTerm(form){
    if(form.m_agree_term.checked){
        document.getElementById('div_send_show').style.display='';
    }else{
        document.getElementById('div_send_show').style.display='none';
    }
}

/* 產品列表直接勾選詢價車時之檢查事項 */
function FormCheckCart(form) {
    var cart = form['p_id[]'];
    var cartchecked = 0;
    
    for(var i=0; i<cart.length; i++){
        if(cart[i].checked) cartchecked++;
    }
    if(!cartchecked) {
        alert("Does not have the product to choose!!");
        return false;
    }
    return true;
}