function isMail(address)
{
	if (address=="") return false;
	if (address.indexOf("@")==-1||address.indexOf("@")==0||address.indexOf("@")==address.length-1) return false;
	if (address.indexOf("@")!=address.lastIndexOf("@")) return false;
	if (address.indexOf(".")==-1||address.indexOf(".")==0) return false;
	return true;
}

function isPhone(Phone)
{
	if (Phone=="") return false;
	if (Phone.length<=7) return false;
	return true;
}

function getRadioValue(str)
{
 var r=document.getElementsByName(str);
 for (var i=0;i<r.length;i++)
 if(r[i].checked) return r[i].value;
}

function ConfirmInput() {
	if(confirm('We recommend you using company email. You will receive the license information and download URL of the evaluation copy in 10 minutes. Click Cancel to refill in the application form. Click OK to send the current one. ')) {
		return true;
	}
	return false;
}
function submit_form()
{

/*
	if (getRadioValue("AcceptLicense") == "No")
	{
		alert ("Sorry. If you do not accept the license agreement for the product, you will not be able to download it.");
		document.DownloadForm.AcceptLicense[1].focus();
		return false;
	}
	else if (getRadioValue("AcceptLicense") == "Yes")
	{
		// ok
	}
	else
	{
		alert ("Please indicate whether you accept or do not accept the download license agreement.");
		document.DownloadForm.AcceptLicense[0].focus();
		return false;
	}


alert ("OK");
*/
/*  DownloadForm  */
		if (document.DownloadForm.FirstName.value == "")
		{
			alert ("Please input your first name"); 
			document.DownloadForm.FirstName.focus();
			return false;
		}
	
		if (document.DownloadForm.LastName.value == "")
		{
			alert ("Please input your last name"); 
			document.DownloadForm.LastName.focus();
			return false;
		}
	
		if (document.DownloadForm.Email.value == "")
		{
			alert ("Please input your E-mail address"); 
			document.DownloadForm.Email.focus();
			return false;
		}
	
		if (!isMail(document.DownloadForm.Email.value))
		{
			alert ("The e-mail address is invalid");
			document.DownloadForm.Email.focus();
			return false;
		}
		return true;
}

function submit_form2()
{
/*  ApplyCapsa  */
		if (document.ApplyCapsa.FirstName.value == "")
		{
			alert ("Please input your first name"); 
			document.ApplyCapsa.FirstName.focus();
			return false;
		}
	
		if (document.ApplyCapsa.LastName.value == "")
		{
			alert ("Please input your last name"); 
			document.ApplyCapsa.LastName.focus();
			return false;
		}
			

		if (document.ApplyCapsa.Country.value == "Please Select One")
		{
			alert ("Please select your country."); 
			document.ApplyCapsa.Country.focus();
			return false;
		}	
		
		if (document.ApplyCapsa.Company.value == "")
		{
			alert ("Please input your company name"); 
			document.ApplyCapsa.Company.focus();
			return false;
		}
		
		if (document.ApplyCapsa.Email.value == "")
		{
			alert ("Please input your E-mail address"); 
			document.ApplyCapsa.Email.focus();
			return false;
		}
	
		if (!isMail(document.ApplyCapsa.Email.value))
		{
			alert ("The e-mail address is invalid");
			document.ApplyCapsa.Email.focus();
			return false;
		}		
		
		if (document.ApplyCapsa.Phone.value == "")
		{
			alert ("Please input your Phone Number"); 
			document.ApplyCapsa.Phone.focus();
			return false;
		}

		if (!isPhone(document.ApplyCapsa.Phone.value))
		{
			alert ("The Phone Number is invalid");
			document.ApplyCapsa.Phone.focus();
			return false;
		}

	return true;
}

function submit_form3()
{
/*  ApplyCapsa in download capsa page  */
		if (document.ApplyCapsa.Country.value == "Please Select One")
		{
			alert ("Please select your country."); 
			document.ApplyCapsa.Country.focus();
			return false;
		}	
		
		if (document.ApplyCapsa.Company.value == "")
		{
			alert ("Please input your company name"); 
			document.ApplyCapsa.Company.focus();
			return false;
		}
		
		if (document.ApplyCapsa.Phone.value == "")
		{
			alert ("Please input your Phone Number"); 
			document.ApplyCapsa.Phone.focus();
			return false;
		}

		if (!isPhone(document.ApplyCapsa.Phone.value))
		{
			alert ("The Phone Number is invalid");
			document.ApplyCapsa.Phone.focus();
			return false;
		}

	return true;
}

function submit_form4()
{
/*  Capsa 7 Beta Feedback  */
	var a="~`#$%^(){}[]|<>"
	var v=document.feedback_form.comments.value
	
		for(i=0;i<v.length;i++)   
		{   
		  if(a.indexOf(v.substr(i,1))>-1)     
		  {   
			  alert(v.substr(i,1)+" Illegal characters found, please input again.");  
			  return false;  
		  }
		}
		
		if (document.feedback_form.comments.value == "") {
			alert ("comments is null.");
			document.feedback_form.comments.focus();
			return false;
		}
		
		if (document.feedback_form.user_name.value == "") {
			alert ("Please input your name.");
			document.feedback_form.user_name.focus();
			return false;
		}
		
		if (document.feedback_form.user_mail.value == "")
		{
			alert ("Please input your E-mail address"); 
			document.feedback_form.user_mail.focus();
			return false;
		}
	
		if (!isMail(document.feedback_form.user_mail.value))
		{
			alert ("The e-mail address is invalid");
			document.feedback_form.user_mail.focus();
			return false;
		}	
return true;
}