function checklogin(frm)
{
	document.getElementById('sp_err1').innerHTML='please enter your account name and password.';
	document.getElementById('fn_account1').color='#000000';
	document.getElementById('fn_password').color='#000000';
	var ok=true;
	if(frm.account.value=='')
	{
		document.getElementById('fn_account1').color='#FF3300';
		ok=false;
	}
	if(frm.password.value=='')
	{
		document.getElementById('fn_password').color='#FF3300';
		ok=false;
	}
	if(/^[A-Za-z0-9]*$/.test(frm.account.value)==false || frm.account.value.length<3)
	{
		if(ok)
		{
			document.getElementById('sp_err1').innerHTML='<font color=\"#FF3300\"><b>Error:</b> Invalid account name</font>';
			document.getElementById('fn_account1').color='#FF3300';
			ok=false;
		}
	}
	if(ok)
	{
		frm.btnSubmit.disabled=true;
	}
	return ok;
}

function retrieve(frm)
{
	document.getElementById('sp_err3').innerHTML='please fill in your account name';
	document.getElementById('fn_account3').color='#000000';
	var ok=true;
	if(frm.txtAccount.value=='')
	{
		document.getElementById('fn_account3').color='#FF3300';
		ok=false;
	}
	else if(/^[A-Za-z0-9]*$/.test(frm.txtAccount.value)==false || frm.txtAccount.value.length<3)
	{
		document.getElementById('sp_err3').innerHTML='<font color=\"#FF3300\"><b>Error:</b> Invalid account name</font>';
		document.getElementById('fn_account3').color='#FF3300';
		ok=false;
	}
	if(ok)
	{
		frm.btnSubmit.disabled=true;
	}
	return ok;
}

function resetpsw(frm)
{
	document.getElementById('sp_err4').innerHTML='please fill in your email address';
	document.getElementById('fn_email').color='#000000';
	var ok=true;
	if(frm.txtEmail.value=='')
	{
		document.getElementById('fn_email').color='#FF3300';
		ok= false;
	}
	else if(/^.+@.+\..{2,4}$/.test(frm.txtEmail.value)==false)
	{
		document.getElementById('sp_err4').innerHTML='<font color=\"#FF3300\">please input a valid email address</font>';
		document.getElementById('fn_email').color='#FF3300';
		ok= false;
	}
	if(ok)
	{
		frm.btnSubmit.disabled=true;
	}
	return ok;
}

function checksignup(frm)
{
	document.getElementById('sp_err2').innerHTML='input your desired account name';
	document.getElementById('fn_account2').color='#000000';
	document.getElementById('fn_company').color='#000000';
	var ok=true;
	if(frm.txtAccount.value=='')
	{
		document.getElementById('fn_account2').color='#FF3300';
		ok=false;
	}
	else if(/^[A-Za-z0-9]*$/.test(frm.txtAccount.value)==false || frm.txtAccount.value.length<3)
	{
		document.getElementById('sp_err2').innerHTML='<font color=\"#FF3300\"><b>Error:</b> Invalid account name</font>';
		document.getElementById('fn_account2').color='#FF3300';
		ok=false;
	}
	if(frm.txtCompany.value=='')
	{
		document.getElementById('fn_company').color='#FF3300';
		ok=false;
	}
	if(ok)
	{
		frm.btnSubmit.disabled=true;
	}
	return ok;
}

function checkstep1(frm, account_err, company_err)
{
	var ok=true;
	if(account_err!=0)
	{
		document.getElementById('fn_account').color='#000000';
		if(/^[A-Za-z0-9]*$/.test(frm.txtAccount.value)==false || frm.txtAccount.value.length<3)
		{
			document.getElementById('fn_account').color='#FF3300';
			ok=false;
		}
	}
	if(company_err!=0)
	{
		document.getElementById('fn_company').color='#000000';
		var type=frm.hidType.value;
		if(type==0 || type==2)
		{
			if(frm.txtCompany1.value=='')
			{
				document.getElementById('fn_company').color='#FF3300';
				ok=false;
			}
			else
			{
				frm.txtCompany.value=frm.txtCompany1.value;
			}
		}
		if(type==1 || type==3)
		{
			frm.txtCompany.value=frm.txtCompany2.value;
		}
	}
	if(ok)
	{
		frm.btnSubmit.disabled=true;
	}
	return ok;
}

function checkaccount(frm)
{
	document.getElementById('sp_err').innerHTML='<font color=\"#000000\">Please input your account information:</font>';
	document.getElementById('fn_password').color='#000000';
	document.getElementById('fn_password2').color='#000000';
	document.getElementById('fn_contact').color='#000000';
	document.getElementById('fn_email').color='#000000';
	var ok=true;
	var msg='<b>Error:</b> Your entry is incomplete or erroneous!';
	if(frm.password.value.length<4)
	{
		document.getElementById('fn_password').color='#FF3300';
		ok=false;
		msg='<b>Error:</b> Your password is too short!';
	}
	if(frm.password.value=='')
	{
		document.getElementById('fn_password').color='#FF3300';
		ok=false;
		msg='<b>Error:</b> Your entry is incomplete or erroneous!';
	}
	if(frm.password.value!=frm.password2.value)
	{
		document.getElementById('fn_password').color='#FF3300';
		document.getElementById('fn_password2').color='#FF3300';
		msg='<b>Error:</b> \'Password/Confirm Password\' does not match!';
		ok=false;
	}
	if(frm.contact.value=='')
	{
		document.getElementById('fn_contact').color='#FF3300';
		ok=false;
	}
	if(/^.+@.+\..{2,4}$/.test(frm.email.value)==false)
	{
		document.getElementById('fn_email').color='#FF3300';
		ok=false;
	}
	if(ok==false)
	{
		document.getElementById('sp_err').innerHTML=msg;
	}
	else
	{
		frm.btnSubmit.disabled=true;
	}
	return ok;
}

function checkownership(frm)
{
	var ok=true;
	document.getElementById('fn_email').color='#000000';
	if(frm.email.value=='')
	{
		document.getElementById('fn_email').color='#FF3300';
		ok=false;
	}
	if(/^.+@.+\..{2,4}$/.test(frm.email.value))
	{
		document.getElementById('fn_email').color='#FF3300';
		ok=false;
	}
	if(ok)
	{
		frm.btnSubmit.disabled=true;
	}
	return ok;
}