﻿function form_check()
{
	var reg= /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	var mail=document.action_form.form_mail.value;	
	
	if(document.action_form.form_content.value == "")
	{
		window.alert ("Please enter the Comments！")
		document.action_form.form_content.focus();
		return false;
	}
	if (mail != '')
	{
    	if(reg.test(mail) == false)
		{
			window.alert("Your E-mail address is incorrect,please try again！");
			document.action_form.form_mail.focus();
			return false;
		}
	}else
	{
		window.alert ("Please enter E-mail address！")
		document.action_form.form_mail.focus();
		return false;
	}
	return true;
}

function form_check1()
{
	var reg= /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	var mail=document.action_form.form_mail.value;	
	
	if (mail != '')
	{
    	if(reg.test(mail) == false)
		{
			window.alert("Your E-mail address is incorrect,please try again！");
			document.action_form.form_mail.focus();
			return false;
		}
	}else
	{
		window.alert ("Please enter E-mail address！")
		document.action_form.form_mail.focus();
		return false;
	}
	
	if(document.action_form.form_brand.value == "")
	{
		window.alert ("Please enter the computer brand！")
		document.action_form.form_brand.focus();
		return false;
	}
	if(document.action_form.form_content.value == "")
	{
		window.alert ("Please enter your computer issues！")
		document.action_form.form_content.focus();
		return false;
	}
	return true;
}


function form_check2()
{
	var reg= /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	var mail=document.action_form.form_mail.value;	
	var mail2=document.action_form.form_mail2.value;	
	
	if(document.action_form.form_content.value == "")
	{
		window.alert ("Please enter the Comments！")
		document.action_form.form_content.focus();
		return false;
	}
	if(document.action_form.form_name.value == "")
	{
		window.alert ("Please enter your name！")
		document.action_form.form_name.focus();
		return false;
	}
	
	if (mail != '')
	{
    	if(reg.test(mail) == false)
		{
			window.alert("Your E-mail address is incorrect,please try again！");
			document.action_form.form_mail.focus();
			return false;
		}
	}else
	{
		window.alert ("Please enter E-mail address！")
		document.action_form.form_mail.focus();
		return false;
	}
	
	if(document.action_form.form_tel.value == "")
	{
		window.alert ("Please enter your telphone number！")
		document.action_form.form_tel.focus();
		return false;
	}
	if(document.action_form.form_address.value == "")
	{
		window.alert ("Please enter your street address ！")
		document.action_form.form_address.focus();
		return false;
	}
	
	if(document.action_form.form_city.value == "")
	{
		window.alert ("Please enter your city ！")
		document.action_form.form_city.focus();
		return false;
	}
	if(document.action_form.form_state.value == "")
	{
		window.alert ("Please enter your state ！")
		document.action_form.form_state.focus();
		return false;
	}
	if(document.action_form.form_zip.value == "")
	{
		window.alert ("Please enter your zip ！")
		document.action_form.form_zip.focus();
		return false;
	}
	if(document.action_form.form_name2.value == "")
	{
		window.alert ("Please enter the Referral Name ！")
		document.action_form.form_name2.focus();
		return false;
	}
	
	if (mail2 != '')
	{
    	if(reg.test(mail2) == false)
		{
			window.alert("The Referral E-mail address is incorrect,please try again！");
			document.action_form.form_mail2.focus();
			return false;
		}
	}else
	{
		window.alert ("Please enter the Referral E-mail address！")
		document.action_form.form_mail2.focus();
		return false;
	}
	
	if(document.action_form.form_tel2.value == "")
	{
		window.alert ("Please enter the Referral Tel ！")
		document.action_form.form_tel2.focus();
		return false;
	}
	
	if(document.action_form.form_address2.value == "")
	{
		window.alert ("Please enter the Referral Street Address ！")
		document.action_form.form_address2.focus();
		return false;
	}
	
	if(document.action_form.form_city2.value == "")
	{
		window.alert ("Please enter the Referral City ！")
		document.action_form.form_city2.focus();
		return false;
	}
	
	

	return true;
}

//用户登录
function user_login()
{	

	if(document.login_form.user_name.value == "")
	{
		window.alert ("Please enter the user name！")
		document.login_form.user_name.focus();
		return false;
	}

	if (document.login_form.user_pwd.value == "")
	{
		window.alert ("Please enter password！")
		document.login_form.user_pwd.focus();
		return false;
	}
	
	return true;
	
}

//用户注册
function user_reg()
{		
	var reg= /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	var mail=document.action_form.user_mail.value;


	if(document.action_form.user_name.value == "")
	{
		window.alert ("Please enter user name！")
		document.action_form.user_name.focus();
		return false;
	}

	if (document.action_form.user_pwd.value == "")
	{
		window.alert ("Please enter password！")
		document.action_form.user_pwd.focus();
		return false;
	}
	if (document.action_form.user_pwd1.value == "")
	{
		window.alert ("Please enter the password again！")
		document.action_form.user_pwd1.focus();
		return false;
	}
	
	if (document.action_form.user_pwd.value != "" && document.action_form.user_pwd.value.length < 6  )
	{
		window.alert ("The password can not less 6 characters！")
		document.action_form.user_pwd.focus();
		return false;
	}
	
	if (document.action_form.user_pwd.value != document.action_form.user_pwd1.value)
	{
		window.alert ("Your password is not the same！")
		document.action_form.user_pwd.focus();
		return false;
	}
	

	if (document.action_form.user_true_name.value == "")
	{
		window.alert ("Please enter your real name！")
		document.action_form.user_true_name.focus();
		return false;
	}	
	
	if (mail != '')
	{
    	if(reg.test(mail) == false)
		{
			window.alert("Your E-mail address is incorrect,please try again！");
			document.action_form.user_mail.focus();
			return false;
		}
	}else
	{
		window.alert ("Please enter E-mail address！")
		document.action_form.user_mail.focus();
		return false;
	}
	
	if (document.action_form.user_mail_bk.value != '')
	{
    	if(reg.test(document.action_form.user_mail_bk.value) == false)
		{
			window.alert("Your email address is incorrect, please try again！");
			document.action_form.user_mail_bk.focus();
			return false;
		}
	}
	
	if (document.action_form.vcode.value == "")
	{
		window.alert ("Please enter verifiation code！")
		document.action_form.vcode.focus();
		return false;
	}
	
	return true;
	
}

//用户修改
function user_edit()
{		
	var reg= /^[\w-]+(\.[\w-]+)*@[\w-]+(\.[\w-]+)+$/;
	var mail=document.action_form.user_mail.value;


	if (document.action_form.check_pwd.value == "")
	{
		window.alert ("Please enter password！")
		document.action_form.check_pwd.focus();
		return false;
	}

	if (document.action_form.user_pwd.value != "" && document.action_form.user_pwd.value.length < 6  )
	{
		window.alert ("The password can not less 6 characters！")
		document.action_form.user_pwd.focus();
		return false;
	}
	if (document.action_form.user_pwd.value != document.action_form.user_pwd1.value)
	{
		window.alert ("Your password is not the same！")
		document.action_form.user_pwd.focus();
		return false;
	}
	
	if (document.action_form.user_true_name.value == "")
	{
		window.alert ("Please enter your real name！")
		document.action_form.user_true_name.focus();
		return false;
	}	
	
	
	if (mail != '')
	{
    	if(reg.test(mail) == false)
		{
			window.alert("Your E-mail address is incorrect,please try again！");
			document.action_form.user_mail.focus();
			return false;
		}
	}else
	{
		window.alert ("Please enter E-mail address！")
		document.action_form.user_mail.focus();
		return false;
	}
	
	if (document.action_form.user_mail_bk.value != '')
	{
    	if(reg.test(document.action_form.user_mail_bk.value) == false)
		{
			window.alert("Your E-mail address is incorrect,please try again！");
			document.action_form.user_mail_bk.focus();
			return false;
		}
	}
	
	
	return true;
	
}



function search_check(root_url)
{
	if(document.search_form.search_key.value == "")
	{
		window.alert ("Please enter the content！")
		document.search_form.search_key.focus();
		return false;  
	}
	
	if(document.search_form.type.value == "5")
	{
		//文件搜索
		document.search_form.action=root_url+"modules/file_list.php";
		document.search_form.submit();
	}else
	{
		//文章搜索
		document.search_form.action=root_url+"modules/article_list.php";
		document.search_form.submit();
	}
	return true;
}


function reply_check()
{
	if(document.reply_form.reply_title.value == "")
	{
		window.alert ("Please enter the title！")
		document.reply_form.reply_title.focus();
		return false;  
	}
	
	if(document.reply_form.reply_user_name.value == "")
	{
		window.alert ("Please enter the user name！")
		document.reply_form.reply_user_name.focus();
		return false;  
	}
	
	if(document.reply_form.reply_content.value == "")
	{
		window.alert ("Please enter the content！")
		document.reply_form.reply_content.focus();
		return false;  
	}
	if (document.reply_form.vcode.value == "")
	{
		window.alert ("Please enter the authentication code！")
		document.reply_form.vcode.focus();
		return false;
	}
	return true;
}

function advice_check()
{
	if(document.action_form.ad_user.value == "")
	{
		window.alert ("Please enter your name！")
		document.action_form.ad_user.focus();
		return false;  
	}
	
	if(document.action_form.ad_phone.value == "")
	{
		window.alert ("Please enter your phone！")
		document.action_form.ad_phone.focus();
		return false;  
	}
	
	if(document.action_form.ad_mail.value == "")
	{
		window.alert ("Please enter your E-mail！")
		document.action_form.ad_mail.focus();
		return false;  
	}
	if(document.action_form.s1.value == "")
	{
		window.alert ("Please choose the title！")
		document.action_form.s1.focus();
		return false;  
	}
	if(document.action_form.ad_content.value == "")
	{
		window.alert ("Please enter the content！")
		document.action_form.ad_content.focus();
		return false;  
	}

	return true;
}

function partner_check()
{
	if(document.action_form.p_country.value == "")
	{
		window.alert ("Please enter the country name！")
		document.action_form.p_country.focus();
		return false;  
	}

	if(document.action_form.p_company.value == "")
	{
		window.alert ("Please enter the company name！")
		document.action_form.p_company.focus();
		return false;  
	}

	if(document.action_form.p_name.value == "")
	{
		window.alert ("Please enter the contact！")
		document.action_form.p_name.focus();
		return false;  
	}
	
		if(document.action_form.p_phone.value == "")
	{
		window.alert ("Please enter your phone！")
		document.action_form.p_phone.focus();
		return false;  
	}
	
		if(document.action_form.p_mail.value == "")
	{
		window.alert ("Please enter your E-mail！")
		document.action_form.p_mail.focus();
		return false;  
	}

	return true;
}
