// JavaScript Document

function focuson()
{ 
	document.evaluation.number.focus()
}

function check()
{
	if(document.evaluation.txtfname.value=='')
	{
		alert("Please Enter First Name.");
		document.evaluation.txtfname.focus();
		return false;
	}
	if(document.evaluation.txtlname.value=='')
	{
		alert("Please Enter Last Name.");
		document.evaluation.txtlname.focus();
		return false;
	}
	if(document.evaluation.txttitle.value=='')
	{
		alert("Please Enter Title.");
		document.evaluation.txttitle.focus();
		return false;
	}
	if(document.evaluation.txtcompany.value=='')
	{
		alert("Please Enter Company.");
		document.evaluation.txtcompany.focus();
		return false;
	}
	
	if(document.evaluation.txtemail.value=='')
	{
		alert("Please Enter Email.");
		document.evaluation.txtemail.focus();
		return false;
	}
	if(trim(document.evaluation.txtemail.value)!="")
	{
		var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
		var ans = document.evaluation.txtemail.value.match(emailExp);
		if(ans!=document.evaluation.txtemail.value)
		{
			alert("Please Enter Valid Email.");
			document.evaluation.txtemail.focus();
			return false;				
		}
	}
	

	
	if(document.evaluation.txtphone.value=='')
	{
		alert("Please Enter Phone.");
		document.evaluation.txtphone.focus();
		return false;
	}
	if(IsNumeric(document.evaluation.txtphone.value) == false) 
	{
		alert('Phone Should be Numeric.');
		document.getElementById('txtphone').focus();
		return false; 
	}
	/*if(document.evaluation.txtext.value=='')
	{
		alert("Please Enter ext.");
		document.evaluation.txtext.focus();
		return false;
	}
	if(IsNumeric(document.evaluation.txtext.value) == false) 
	{
		alert('ext Should be Numeric.');
		document.getElementById('txtext').focus();
		return false; 
	}*/
	
	if(document.evaluation.txtaddress.value=='')
	{
		alert("Please Enter Address.");
		document.evaluation.txtaddress.focus();
		return false;
	}
	if(document.evaluation.txtcity.value=='')
	{
		alert("Please Enter City.");
		document.evaluation.txtcity.focus();
		return false;
	}
	if(document.evaluation.txtzip.value=='')
	{
		alert("Please Enter Zip.");
		document.evaluation.txtzip.focus();
		return false;
	}
	
	if(document.evaluation.txtindustry.selectedIndex==0)
	{
		alert("Please Select Industry.");
		document.getElementById('txtindustry').focus();
		return false;
	}
	if(document.evaluation.txtusage.selectedIndex==0)
	{
		alert("Please Select ProcessModel Usage.");
		document.getElementById('txtusage').focus();
		return false;
	}
	if(document.evaluation.txtreferred.selectedIndex==0)
	{
		alert("Please Select How were you referred?");
		document.getElementById('txtreferred').focus();
		return false;
	}
	if(document.evaluation.txthearabout.value=='')
	{
		alert("Please Enter How did you hear about ProcessModel?");
		document.evaluation.txthearabout.focus();
		return false;
	}
	if(document.evaluation.txtprimaryproducts.value=='')
	{
alert("Please Enter What are the primary products or services that your company or division provides?");
		document.evaluation.txtprimaryproducts.focus();
		return false;
	}
	if(document.evaluation.txtbusinessproblems.value=='')
	{
		alert("Please Enter What are the detailed business problems you are faced with that would be addressed by ProcessModel?");
		document.evaluation.txtbusinessproblems.focus();
		return false;
	}
	if(document.evaluation.number.value=='')
	{
		alert("Please Enter verification code.");
		document.evaluation.number.focus();
		return false;
	}
	
}

function IsNumeric(strString)
   //  check for valid numeric strings	
   {
   var strValidChars = "0123456789.-";
   var strChar;
   var blnResult = true;

   if (strString.length == 0) return false;

   //  test strString consists of valid characters listed above
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function trim(stringToTrim)
{
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}



function checkblur()
{
	if(document.evaluation.txtemail.value=='')
	{
		alert("Please Enter Email.");
		document.evaluation.txtemail.focus();
		return false;
	}
	if(trim(document.evaluation.txtemail.value)!="")
	{
		var emailExp = /^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-z0-9]{2,4}$/;
		var ans = document.evaluation.txtemail.value.match(emailExp);
		if(ans!=document.evaluation.txtemail.value)
		{
			alert("Please Enter Valid Email.");
			document.evaluation.txtemail.focus();
			return false;				
		}
	}
	
	
	if(document.evaluation.txtemail.value!='')
	{
		var email = document.evaluation.txtemail.value.split("@")
		email[1] = email[1].toLowerCase();
		if(email[1] == 'hotmail.com' || 
		   email[1] == 'gmail.com' || 
		   email[1] == 'yahoo.com' || 
		   email[1] == 'msn.com' || 
		   email[1] == 'aol.com')
		{
			alert('Each request for evaluation is reviewed by a person. Email addresses that are not from a company or government entity will be denied. Hotmail, Yahoo, gmail and MSN domains are not sufficient for ProcessModel to provide you an evaluation copy.');
			return false;
		}
		
		var temp = "";
		var s = document.evaluation.txtemail.value;
		
		/*for(var i=3;i<0;i--)
		{
		
		alert(i);
		alert(s.charAt(s.length-i));
  		  //temp += s[i]; 
		}*/
		temp = s.charAt(s.length-3);
		temp += s.charAt(s.length-2);
		temp += s.charAt(s.length-1);
		temp = temp.toLowerCase(); 
		if(temp == 'edu')
		{
         var chkcon = confirm("Each request for evaluation is reviewed by a person. If you are a professor please help us to understand your needs and we will provide you with an evaluation. We do not provide evaluation copies to students.\n\nIf you are a professor select OK, if you are a student, select cancel and you will be taken to the student version purchase page.");
		  
		if(chkcon == true)
		  {
			 //return true;
          }
          else if(chkcon == false)
          {//alert("dev");
              window.location="academic.php?student=Yes";
			  return false;
		  }
		 
			  
         }

		 		
		  //}
//		else
//		{
//		  alert("no");return false;				
//		}
	}	
	
}


