//This method is used in software_registration.aspx page. It validates the textboxes
function ValidateSoftwareRegistrationForm()
{
//firstname;
	 if(document.frmSR.txtFirstName.value=="")
	  { 
	  
		 alert ("First Name is a required field. Please enter the appropriate information in the box corresponding to First Name. " );
		 document.frmSR.txtFirstName.value="";
		 document.frmSR.txtFirstName.focus();
		 return false ;
	  }
	  //txtComments
	  if( document.frmSR.txtPhone.value=="")  
	  { 
		 alert ("Phone is a required field. Please enter the appropriate information in the box corresponding to Phone. " );
		 document.frmSR.txtPhone.value="";
		 document.frmSR.txtPhone.focus() ;
		 return false ;
	  }	  
	  if (IsAlphaNumCheck(document.frmSR.txtPhone.value,'txtPhone')==false){
			alert("Please enter a valid phone number");
			document.frmSR.txtPhone.value="";
			document.frmSR.txtPhone.focus();
			return false;
		}
	  //email	  
	if( document.frmSR.txtEmail.value=="")  
	  { 
		 alert ("E-mail is a required field. Please enter the appropriate information in the box corresponding to E-mail. " );
		 document.frmSR.txtEmail.value="";		 
		 document.frmSR.txtEmail.focus() ;
		 return false ;
	  }	  
	  //Check valid email
	  if (checkEMail(document.frmSR.txtEmail.value)==false){
		document.frmSR.txtEmail.value="";
		document.frmSR.txtEmailConfirm.value="";
		document.frmSR.txtEmail.focus();
		return false;
	  }
	  if(document.frmSR.txtEmail.value != document.frmSR.txtEmailConfirm.value)
	  {
			alert("Please correct the email address entered. Email and confirm email address should be same value.");
			document.frmSR.txtEmailConfirm.value="";
			document.frmSR.txtEmailConfirm.focus();
			return false;
	  }						  
	 //Company; 
	  if( document.frmSR.txtCompany.value=="" )
	  { 
		 alert ("Company is a required field. Please enter the appropriate information in the box corresponding to Company. " );
		 document.frmSR.txtCompany.value="";
		 document.frmSR.txtCompany.focus() ;
		 return false ;
	  } 
	  //Address; 
	  if( document.frmSR.txtAddress.value=="" )
	  { 
		 alert ("Address is a required field. Please enter the appropriate information in the box corresponding to E-mail Address. " );
		 document.frmSR.txtAddress.value="";
		 document.frmSR.txtAddress.focus() ;
		 return false ;
	  }
	  //City; 
	  if( document.frmSR.txtCity.value=="" )
	  { 
		 alert ("City is a required field. Please enter the appropriate information in the box corresponding to City. " );
		 document.frmSR.txtCity.value="";
		 document.frmSR.txtCity.focus() ;
		 return false ;
	  }
	  //State; 
	  if( document.frmSR.ddlState.selectedIndex==0 )
	  { 
		 alert ("State is a required field. Please select the appropriate information in the drop down list corresponding to State. " );		 
		 document.frmSR.ddlState.focus() ;
		 return false ;
	  }
	  //Zip; 
	  if( document.frmSR.txtZip.value=="" )
	  { 
		 alert ("Zip is a required field. Please enter the appropriate information in the box corresponding to Zip. " );
		 document.frmSR.txtZip.value="";
		 document.frmSR.txtZip.focus() ;
		 return false ;
	  }	
	  //Product; 
	  if( document.frmSR.txtProduct.value=="" )
	  { 
		 alert ("Product is a required field. Please enter the appropriate information in the box corresponding to Product. " );
		 document.frmSR.txtProduct.value="";
		 document.frmSR.txtProduct.focus() ;
		 return false ;
	  }		
	  //txtSerialNumber	  
	  if( document.frmSR.txtSerialNumber.value=="" )
	  { 
		 alert ("Serial Number is a required field. Please enter the appropriate information in the box corresponding to Serial number. " );
		 document.frmSR.txtSerialNumber.value="";
		 document.frmSR.txtSerialNumber.focus() ;
		 return false ;
	  }		
	  return true;
	  //end
}

//This method is used in corporate_feedback.aspx page. Its validates the textboxes
function ValidateMe()
{	
	//firstname;
	 if(document.Form1.txtName.value =="" )
	  { 
		 alert ("Name is a required field. Please enter the appropriate information in the box corresponding to Name. " );
		 document.Form1.txtName.value="";
		 document.Form1.txtName.focus() ;
		 return false ;
	  }
	 //lastname; 
	  if( document.Form1.txtCompany.value=="" )
	  { 
		 alert ("Company is a required field. Please enter the appropriate information in the box corresponding to Company. " );
		 document.Form1.txtCompany.value="";
		 document.Form1.txtCompany.focus() ;
		 return false ;
	  } 
	 //email	  
					if( document.Form1.txtEmail.value=="")  
					{ 
						alert ("E-mail is a required field. Please enter the appropriate information in the box corresponding to E-mail Address. " );
						document.Form1.txtEmail.value="";
						document.Form1.txtEmailConfirm.value="";
						document.Form1.txtEmail.focus() ;
						return false ;
					}
					//Check valid email
					if (checkEMail(document.Form1.txtEmail.value)==false) {
						document.Form1.txtEmail.value="";
						document.Form1.txtEmailConfirm.value="";
						document.Form1.txtEmail.focus();
						return false;
					}
					if(document.Form1.txtEmail.value != document.Form1.txtEmailConfirm.value)
					{
						alert("Please correct the email address entered. Email and confirm email address should be same value.");
						document.Form1.txtEmailConfirm.value="";
						document.Form1.txtEmailConfirm.focus();
						return false;
					}										
	//txtComments
	  if( document.Form1.txtComments.value=="")  
	  { 
		 alert ("You have not filled in a required field. Please submit your Comments/Questions in the corresponding box provided therein. " );
		 document.Form1.txtComments.value="";
		 document.Form1.txtComments.focus() ;
		 return false ;
	  }	  
	  
	  return true;
	  //end
}	

//Function for validate email values

function checkEMail(emailStr) {

/* The following variable tells the rest of the function whether or not
to verify that the address ends in a two-letter country or well-known
TLD.  1 means check it, 0 means don't. */

var checkTLD=1;
/* The following is the list of known Domains that an e-mail address must end with. */

var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|mobi|cat|jobs|travel|COM|NET|ORG|EDU|INT|MIL|GOV|ARPA|BIZ|AERO|NAME|COOP|INFO|PRO|MUSEUM|MOBI|CAT|JOBS|TRAVEL)$/;

/* The following pattern is used to check if the entered e-mail address
fits the user@domain format.  It also is used to separate the username
from the domain. */

var emailPat=/^(.+)@(.+)$/;

/* The following string represents the pattern for matching all special
characters.  We don't want to allow special characters in the address. 
These characters include ( ) < > @ , ; : \ " . [ ] */

var specialChars="\\(\\)><@,';:\\\\\\\"\\.\\[\\]";

/* The following string represents the range of characters allowed in a 
username or domainname.  It really states which chars aren't allowed.*/

var validChars="\[^\\s" + specialChars + "\]";

/* The following pattern applies if the "user" is a quoted string (in
which case, there are no rules about which characters are allowed
and which aren't; anything goes).  E.g. "jiminy cricket"@disney.com
is a legal e-mail address. */

var quotedUser="(\"[^\"]*\")";

/* The following pattern applies for domains that are IP addresses,
rather than symbolic names.  E.g. joe@[123.124.233.4] is a legal
e-mail address. NOTE: The square brackets are required. */

var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;

/* The following string represents an atom (basically a series of non-special characters.) */

var atom=validChars + '+';

/* The following string represents one word in the typical username.
For example, in john.doe@somewhere.com, john and doe are words.
Basically, a word is either an atom or quoted string. */

var word="(" + atom + "|" + quotedUser + ")";

// The following pattern describes the structure of the user

var userPat=new RegExp("^" + word + "(\\." + word + ")*$");

/* The following pattern describes the structure of a normal symbolic
domain, as opposed to ipDomainPat, shown above. */

var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");

/* Finally, let's start trying to figure out if the supplied address is valid. */

/* Begin with the coarse pattern to simply break up user@domain into
different pieces that are easy to analyze. */

var matchArray=emailStr.match(emailPat);

if (matchArray==null) {

/* Too many/few @'s or something; basically, this address doesn't
even fit the general mould of a valid e-mail address. */

alert("Invalid Email Address");
return false;
}
var user=matchArray[1];
var domain=matchArray[2];

// Start by checking that only basic ASCII characters are in the strings (0-127).

for (i=0; i<user.length; i++) {
if (user.charCodeAt(i)>127) {
alert("Invalid Email Address");
return false;
   }
}
for (i=0; i<domain.length; i++) {
if (domain.charCodeAt(i)>127) {
alert("Invalid Email Address");
return false;
   }
}

// See if "user" is valid 

if (user.match(userPat)==null) {

// user is not valid

alert("Invalid Email Address");
return false;
}

/* if the e-mail address is at an IP address (as opposed to a symbolic
host name) make sure the IP address is valid. */

var IPArray=domain.match(ipDomainPat);
if (IPArray!=null) {

// this is an IP address

for (var i=1;i<=4;i++) {
if (IPArray[i]>255) {
alert("Invalid Email Address");
return false;
   }
}
return true;
}

// Domain is symbolic name.  Check if it's valid.
 
var atomPat=new RegExp("^" + atom + "$");
var domArr=domain.split(".");
var len=domArr.length;
for (i=0;i<len;i++) {
if (domArr[i].search(atomPat)==-1) {
alert("Invalid Email Address");
return false;
   }
}

/* domain name seems valid, but now make sure that it ends in a
known top-level domain (like com, edu, gov) or a two-letter word,
representing country (uk, nl), and that there's a hostname preceding 
the domain or country. */

if (checkTLD && domArr[domArr.length-1].length!=2 && 
domArr[domArr.length-1].search(knownDomsPat)==-1) {
alert("Invalid Email Address");
return false;
}

// Make sure there's a host name preceding the domain.

if (len<2) {
alert("Invalid Email Address");
return false;
}

// If we've gotten this far, everything's valid!
return true;
}
	
	
	//Function for validate character values
	//return IsCharacter(txtValue.value,'txtValue');
	function IsCharacter(strString,strElement)
	{
		var strValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz .";
		var strChar;
		var blnResult = true;
		for (i = 0; i < strString.length && blnResult == true; i++)
		{
				strChar = strString.charAt(i);
				if (strValidChars.indexOf(strChar) == -1)
				{
							blnResult = false;
								break;
				}
		}
		if(!blnResult)
		{
				alert("Characters Expected!");
				document.getElementById(strElement).value="";
				document.getElementById(strElement).focus();
		}
	}
	
	
	//Function for validate alphanumeric values for phone fax and zip
    //return IsAlphaNumCheck(txtValue.value,'txtValue');
    function IsAlphaNumCheck(strString,strElement)
    {
        var strValidChars = "0123456789()-+/xextEXT. ";
        var strChar;
        var blnResult = true;
                for (i = 0; i < strString.length && blnResult == true; i++)
                {	
                        strChar = strString.charAt(i);
                        if(strChar=="-" || strChar=="(" || strChar==")" || strChar=="+" || strChar==" ")
                        {
							if(i != strString.length - 1)
							{
								if(strChar==strString.charAt(i+1))
								{
									blnResult = false;
									break;
								}
							}
                        }
                        if (strValidChars.indexOf(strChar) == -1)
                        {
                                blnResult = false;
                                break;
                        }
                }
                return blnResult;
        /*if(!blnResult)
		{
				alert("Please enter a valid phone number");
				document.getElementById(strElement).value="";
				document.getElementById(strElement).focus();
		}*/
    }
    
    //Function for validate alphanumeric values for phone fax and zip
    //return IsAlphaNumCheck(txtValue.value,'txtValue');
    function IsAlphaNumCheckFax(strString,strElement)
    {
        var strValidChars = "0123456789()-+/xext. ";
        var strChar;
        var blnResult = true;
                for (i = 0; i < strString.length && blnResult == true; i++)
                {						
                        strChar = strString.charAt(i);
                        if(strChar=="-" || strChar=="(" || strChar==")" || strChar=="+" || strChar==" ")
                        {
							if(i != strString.length - 1)
							{
								if(strChar==strString.charAt(i+1))
								{
									blnResult = false;
									break;
								}
							}
                        }
                        if (strValidChars.indexOf(strChar) == -1)
                        {
                                blnResult = false;
                                break;
                        }
                }
        if(!blnResult)
		{
				alert("Please enter a valid fax number");
				document.getElementById(strElement).value="";
				document.getElementById(strElement).focus();
		}
    }
    
    //Function for validate alphanumeric values for phone fax and zip
    //return IsAlphaNumCheck(txtValue.value,'txtValue');
    function IsAlphaNumCheckZip(strString,strElement)
    {
        var strValidChars = "0123456789()-+ ";
        var strChar;
        var blnResult = true;
                for (i = 0; i < strString.length && blnResult == true; i++)
                {						
                        strChar = strString.charAt(i);
                        if(strChar=="-" || strChar=="(" || strChar==")" || strChar=="+" || strChar==" ")
                        {
							if(i != strString.length - 1)
							{
								if(strChar==strString.charAt(i+1))
								{
									blnResult = false;
									break;
								}
							}
                        }
                        if (strValidChars.indexOf(strChar) == -1)
                        {
                                blnResult = false;
                                break;
                        }
                }
        if(!blnResult)
		{
				alert("Please enter a valid zip number");
				document.getElementById(strElement).value="";
				document.getElementById(strElement).focus();
		}
    }
                   
	
	//Function for validate alphanumeric values
    //return IsAlphaNum(txtValue.value,'txtValue');
    function IsAlphaNum(strString,strElement)
    {
        var strValidChars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789 ";
        var strChar;
        var blnResult = true;
                for (i = 0; i < strString.length && blnResult == true; i++)
                {
                        strChar = strString.charAt(i);
                        if (strValidChars.indexOf(strChar) == -1)
                        {
                                blnResult = false;
                                break;
                        }
                }
        if(!blnResult)
		{
				alert("Only alphanumeric's allowed");
				document.getElementById(strElement).value="";
				document.getElementById(strElement).focus();
		}
    }
    
	//Function for validate numeric value
	//return IsNumeric(txtValue.value,'txtValue');
	function IsNumeric(strString,strElement)
	{
		var strValidChars = "0123456789.-";
		var strChar;
		var blnResult = true;
				for (i = 0; i < strString.length && blnResult == true; i++)
				{
						strChar = strString.charAt(i);
						if (strValidChars.indexOf(strChar) == -1)
						{
								blnResult = false;
								break;
						}
				}
		if(!blnResult)
		{
			alert("Numeric Value Expected!");
			document.getElementById(strElement).value="";
			document.getElementById(strElement).focus();
		}
	}

/*
function ValidateForm(){
	var emailID=document.frmSample.txtEmail
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (checkEMail(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }
 
 //email
	/*   var email=new String(document.CreateProfileForm.emailAddress.value);
		if(email!='') {
		 if(email.indexOf("@")==-1 ||  email.indexOf(".")==-1 || email.indexOf("@") > email.lastIndexOf(".")) {
			alert("Please enter a valid email");
			document.CreateProfileForm.emailAddress.focus() ;
			return false;
		}
				}
		else {
			alert("Please enter email");
			document.CreateProfileForm.emailAddress.focus() ;
			return false;
		}
		
	if( document.CreateProfileForm.emailAddress.value=="")  
	  { 
		 alert ("E-Mail address can not be blank !!!! " );
		 document.CreateProfileForm.emailAddress.value="";
		 document.CreateProfileForm.emailAddress.focus() ;
		 return false ;
	  }
	  var email=new String(document.CreateProfileForm.emailAddress.value);
		var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
		if (filter.test(email))
		var testresults=true
		else{
		alert("Please input a valid email address!");
		document.CreateProfileForm.emailAddress.focus() ;
		return false ;
		}
	*/


