﻿var subcat = new Array();
subcat[0] = new Array('10','ODIN™ Video Phone','ODIN™ Video Phone')
subcat[1] = new Array('10','CardGuard™','CardGuard™')
subcat[2] = new Array('10','360°','360°')
subcat[3] = new Array('10','Others','Others')
subcat[4] = new Array('20','Home Automation','Home Automation')
subcat[5] = new Array('20','Telemedicare','Telemedicare')
subcat[6] = new Array('20','Vending Machine','Vending Machine')
subcat[7] = new Array('20','Others','Others')
subcat[8] = new Array('30','ODIN™ Video Phone','ODIN™ Video Phone')
subcat[9] = new Array('30','CardGuard™','CardGuard™')
subcat[10] = new Array('30','360°','360°')
subcat[11] = new Array('30','ome Automation','Home Automation')
subcat[12] = new Array('30','Telemedicare','Telemedicare')
subcat[13] = new Array('30','Vending Machine','Vending Machine')

function changeselect1(locationid)
{
	document.action_form.s2.length = 0;
	document.action_form.s2.options[0] = new Option('Select','');
	for (i=0; i<subcat.length; i++)
	{
		if (subcat[i][0] == locationid)
		{document.action_form.s2.options[document.action_form.s2.length] = new Option(subcat[i][1], subcat[i][2]);}
	}
}
//用户登录
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;
}
