
function validateForm()
{
	var docF=document.frmWebRegister;
	var jCol;
	var iserror=0;
	var error_msg='';
	var alreadyFocussed = false;

	// if getElementById  works in this browser 
	if(document.getElementById)
		jCol=1; // set the green flag
	else
		jCol=0; //  wow man a prehistoric browser found!!!!

	if(docF.isDecline.value==1)
		return true;//No validation incase user has clicked on decline button

	if(jCol==1)
	{
		// if green flag: paint all labels black.
		document.getElementById('spanClientName').style.color='#000000';
		document.getElementById('spanContactPerson').style.color='#000000';
		document.getElementById('spanContactEmail').style.color='#000000';
		document.getElementById('spanPhone').style.color='#000000';
		document.getElementById('spanAddress').style.color='#000000';
		document.getElementById('spanCity').style.color='#000000';
		document.getElementById('spanState').style.color='#000000';
		document.getElementById('spanCountry').style.color='#000000';
		document.getElementById('spanDescription').style.color='#000000';
		document.getElementById('spanURL').style.color='#000000';
		document.getElementById('spanServerSpace').style.color='#000000';
		document.getElementById('spanDomainRegister').style.color='#000000';
		document.getElementById('spanLastRenewel').style.color = '#000000';
		document.getElementById('spanExpiry').style.color = '#000000';
		document.getElementById('spanOffEmailsId').style.color = '#000000';
		document.getElementById('spanPerEmailsId').style.color = '#000000';
		document.getElementById('spanPaymentDetails').style.color = '#000000';
		document.getElementById('spanNofify').style.color = '#000000';
		document.getElementById('spanLogo').style.color = '#000000';
		document.getElementById('spanClientStatus').style.color = '#000000';
		document.getElementById('spanTerms').style.color = '#000000';
		document.getElementById('spanFTPUName').style.color = '#000000';
		document.getElementById('spanFTPPassword').style.color = '#000000';
		document.getElementById('spanWebsiteStatus').style.color = '#000000';
		document.getElementById('spanWorkStatus').style.color = '#000000';
		document.getElementById('spanServerType').style.color = '#000000';
	}


/*************************** CHECK CLIENT NAME **************************************************/
        
        if(akey_trim(docF.txtClientName.value)=="")
        {
                error_msg+="\nPlease enter client name.";
                if(jCol==1)
                {
                        document.getElementById('spanClientName').style.color = 'red';
                }
                if (! alreadyFocussed)
                {
                        docF.txtClientName.focus();
                        alreadyFocussed = true;
                }
		iserror++;
        }
 
 /*************************** CHECK CONTACT PERSON **************************************************/
         
         if(akey_trim(docF.txtContactPerson.value)=="")
         {
                 error_msg+="\nPlease enter contact person name.";
                 if(jCol==1)
                 {
                         document.getElementById('spanContactPerson').style.color = 'red';
                 }
                 if (! alreadyFocussed)
                 {
                         docF.txtContactPerson.focus();
                         alreadyFocussed = true;
                 }
 		iserror++;
         }
  	if(!akey_isValidName(akey_trim(docF.txtContactPerson.value)))
  	{
 		error_msg+= "\n'" + docF.txtContactPerson.value + "' is not a valid contact person name. Please enter a name.";
 		if(jCol==1)
  		{
  			document.getElementById('spanContactPerson').style.color = 'red';
  		}
  		if (! alreadyFocussed)
  		{
  			docF.txtContactPerson.focus();
  			alreadyFocussed = true;
  		}
 		iserror++;
 	}
 
 
 /************************************ CHECKING CONTACT EMAIL ID ********************************************/
 	
 	if(akey_trim(docF.txtContactEmail.value)=="")
 	{
 		error_msg+="\nPlease specify email-id.";
 		if(jCol==1)
 		{
 			document.getElementById('spanContactEmail').style.color = 'red';
 		}
                 if (! alreadyFocussed)
                 {
                       docF.txtContactEmail.focus();
                       alreadyFocussed = true;
                 }
 		iserror++;
	}
	else
	if(!akey_isValidEmail(akey_trim(docF.txtContactEmail.value)))
	{
		error_msg+= "\n'" + docF.txtContactEmail.value + "' is not a valid email-id. Please enter a valid email-id.";
		if(jCol==1)
		{
			document.getElementById('spanContactEmail').style.color = 'red';
		}
                if (! alreadyFocussed)
                {
                      docF.txtContactEmail.focus();
                      alreadyFocussed = true;
                }
		iserror++;
	}

/*************************** CHECK PHONE NUMBER **************************************************/
	

        if(akey_trim(docF.txtTel.value)=="" && akey_trim(docF.txtMob.value)=="")
        {
                error_msg+="\nPlease specify atleast one phone number.";
                if(jCol==1)
                {
                        document.getElementById('spanPhone').style.color = 'red';
                }
                if (! alreadyFocussed)
                {
                        docF.txtTel.focus();
                        alreadyFocussed = true;
                }
                iserror++;
        }
        else
        if(akey_trim(docF.txtTel.value)!="")
        {
		if(docF.txtTel.value==0 || !akey_isValidReferencePhone(docF.txtTel.value))
		{
			 error_msg+="\nPlease enter a valid phone no.";
			 if(jCol==1)
			 {
				 document.getElementById('spanPhone').style.color = 'red';
			 }
			 if (! alreadyFocussed)
			 {
				 docF.txtTel.focus();
				 alreadyFocussed = true;
			 }
			iserror++;
		}
	}
        if(akey_trim(docF.txtMob.value)!="")
        {
		if(docF.txtMob.value==0 || !akey_isValidReferencePhone(docF.txtMob.value))
		{
			  error_msg+="\nPlease enter a valid mobile no.";
			  if(jCol==1)
			  {
				  document.getElementById('spanPhone').style.color = 'red';
			  }
			  if (! alreadyFocussed)
			  {
				  docF.txtMob.focus();
				  alreadyFocussed = true;
			  }
			 iserror++;
		}
	}
 
  /************************************ CHECKING ADDRESS ********************************************/
  	
  	if(akey_trim(docF.txtAddress.value)=="")
  	{
  		error_msg+="\nPlease enter address.";
  		if(jCol==1)
  		{
  			document.getElementById('spanAddress').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtAddress.focus();
			alreadyFocussed = true;
		}
		iserror++;
	}
	
  /************************************ CHECKING CITY ********************************************/
  	
  	if(akey_trim(docF.txtCity.value)=="")
  	{
  		error_msg+="\nPlease enter city name.";
  		if(jCol==1)
  		{
  			document.getElementById('spanCity').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtCity.focus();
			alreadyFocussed = true;
		}
		iserror++;
	}
	
  /************************************ CHECKING STATE ********************************************/
  	
  	if(akey_trim(docF.txtState.value)=="")
  	{
  		error_msg+="\nPlease enter state.";
  		if(jCol==1)
  		{
  			document.getElementById('spanState').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtState.focus();
			alreadyFocussed = true;
		}
  		iserror++;
	}

  /************************************ CHECKING COUNTRY ********************************************/
  	
  	if(akey_trim(docF.txtCountry.value)=="Select")
  	{
  		error_msg+="\nPlease select country.";
  		if(jCol==1)
  		{
  			document.getElementById('spanCountry').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtCountry.focus();
			alreadyFocussed = true;
		}
  		iserror++;
	}

  /************************************ CHECKING CLIENT STATUS ********************************************/
  	
  	if(akey_trim(docF.txtClientStatus.value)=="Select")
  	{
  		error_msg+="\nPlease select client status.";
  		if(jCol==1)
  		{
  			document.getElementById('spanClientStatus').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtClientStatus.focus();
			alreadyFocussed = true;
		}
  		iserror++;
	}
	
	
  /************************************ CHECKING DESCRIPTION ********************************************/
  	
  	if(akey_trim(docF.txtDescription.value)=="")
  	{
  		error_msg+="\nPlease enter description.";
  		if(jCol==1)
  		{
  			document.getElementById('spanDescription').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtDescription.focus();
			alreadyFocussed = true;
		}
  		iserror++;
	}
	
  /************************************ CHECKING TERMS & CONDITIONS ********************************************/
  	
  	if(akey_trim(docF.txtTerms.value)=="")
  	{
  		error_msg+="\nPlease enter terms & conditions.";
  		if(jCol==1)
  		{
  			document.getElementById('spanTerms').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtTerms.focus();
			alreadyFocussed = true;
		}
  		iserror++;
	}

	if(docF.optWorkType(0).checked)
	{
		  /************************************ CHECKING URL ********************************************/

			if(akey_trim(docF.txtURL.value)=="")
			{
				error_msg+="\nPlease enter URL.";
				if(jCol==1)
				{
					document.getElementById('spanURL').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtURL.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}

		  /************************************ CHECKING SERVER TYPE ********************************************/

			if(akey_trim(docF.txtServerType.value)=="Select")
			{
				error_msg+="\nPlease select server type.";
				if(jCol==1)
				{
					document.getElementById('spanServerType').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtServerType.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}
			
		  /************************************ CHECKING FTP USER NAME ********************************************/

			if(akey_trim(docF.txtFTPUName.value)=="")
			{
				error_msg+="\nPlease enter FTP user name.";
				if(jCol==1)
				{
					document.getElementById('spanFTPUName').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtFTPUName.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}

		  /************************************ CHECKING FTP PASSWORD ********************************************/

			if(akey_trim(docF.txtFTPPassword.value)=="")
			{
				error_msg+="\nPlease enter FTP password.";
				if(jCol==1)
				{
					document.getElementById('spanFTPPassword').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtFTPPassword.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}

		  /************************************ CHECKING WEB SITE STATUS ********************************************/

			if(akey_trim(docF.txtWebsiteStatus.value)=="Select")
			{
				error_msg+="\nPlease select website status.";
				if(jCol==1)
				{
					document.getElementById('spanWebsiteStatus').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtWebsiteStatus.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}

		  /************************************ CHECKING SERVER SPACE ********************************************/

			if(akey_trim(docF.txtSpaceRec.value)=="")
			{
				error_msg+="\nPlease enter recomended space.";
				if(jCol==1)
				{
					document.getElementById('spanServerSpace').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtSpaceRec.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}
			else
			if(akey_trim(docF.txtSpaceAct.value)=="")
			{
				error_msg+="\nPlease enter required space.";
				if(jCol==1)
				{
					document.getElementById('spanServerSpace').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtSpaceAct.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}
			
		/*************************** CHECK DOMAIN REGISTER DATE **************************************************/


			if(docF.txtDomainRegisterDay.value=="Select" || docF.txtDomainRegisterMonth.value=="Select" || docF.txtDomainRegisterYear.value=="Select")
			{
				error_msg+="\nPlease select a valid domain register date.";
				if(jCol==1)
				{
					document.getElementById('spanDomainRegister').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
				      docF.txtDomainRegisterDay.focus();
				      alreadyFocussed = true;
				}
				iserror++;
			}
			else
			if(!akey_checkDate(docF.txtDomainRegisterDay.value,docF.txtDomainRegisterMonth.value,docF.txtDomainRegisterYear.value))
			{
				error_msg+="\nYou selected an invalid domain register date.";
				if(jCol==1)
				{
					document.getElementById('spanDomainRegister').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
				      docF.txtDomainRegisterDay.focus();
				      alreadyFocussed = true;
				}
				iserror++;
			}	

		/*************************** CHECK LAST RENEWEL DATE **************************************************/


			if(docF.txtLastRenewelDay.value=="Select" || docF.txtLastRenewelMonth.value=="Select" || docF.txtLastRenewelYear.value=="Select")
			{
				error_msg+="\nPlease select a valid last revewel date.";
				if(jCol==1)
				{
					document.getElementById('spanLastRenewel').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
				      docF.txtLastRenewelDay.focus();
				      alreadyFocussed = true;
				}
				iserror++;
			}
			else
			if(!akey_checkDate(docF.txtLastRenewelDay.value,docF.txtLastRenewelMonth.value,docF.txtLastRenewelYear.value))
			{
				error_msg+="\nYou selected an invalid last revewel date.";
				if(jCol==1)
				{
					document.getElementById('spanLastRenewel').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
				      docF.txtLastRenewelDay.focus();
				      alreadyFocussed = true;
				}
				iserror++;
			}	


		/*************************** CHECK EXPIRY DATE **************************************************/


			if(docF.txtExpiryDay.value=="Select" || docF.txtExpiryMonth.value=="Select" || docF.txtExpiryYear.value=="Select")
			{
				error_msg+="\nPlease select a valid expiry date.";
				if(jCol==1)
				{
					document.getElementById('spanExpiry').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
				      docF.txtExpiryDay.focus();
				      alreadyFocussed = true;
				}
				iserror++;
			}
			else
			if(!akey_checkDate(docF.txtExpiryDay.value,docF.txtExpiryMonth.value,docF.txtExpiryYear.value))
			{
				error_msg+="\nYou selected an invalid expiry date.";
				if(jCol==1)
				{
					document.getElementById('spanExpiry').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
				      docF.txtExpiryDay.focus();
				      alreadyFocussed = true;
				}
				iserror++;
			}	


		  /************************************ CHECKING OFFICIAL E-MAIL ********************************************/

			if(akey_trim(docF.txtOffEmailsId.value)=="")
			{
				error_msg+="\nPlease enter official e-mail ids.";
				if(jCol==1)
				{
					document.getElementById('spanOffEmailsId').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtOffEmailsId.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}


		  /************************************ CHECKING PERSONEL E-MAIL ********************************************/

			if(akey_trim(docF.txtPerEmailId.value)=="")
			{
				error_msg+="\nPlease enter personel e-mail ids.";
				if(jCol==1)
				{
					document.getElementById('spanPerEmailsId').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtPerEmailId.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}
		  /************************************ CHECKING LOGO ********************************************/

			if(!docF.optNotify2Month.checked && !docF.optNotify1Month.checked && !docF.optNotify20Days.checked  && !docF.optNotify10Days.checked && !docF.optNotify5Days.checked && !docF.optNotifyAllRest.checked)
			{
				error_msg+="\nPlease select at least one notifcation type.";
				if(jCol==1)
				{
					document.getElementById('spanNofify').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.optNotify2Month.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}
			
		  /************************************ CHECKING LOGO ********************************************/

			if(akey_trim(docF.txtLogo.value)=="")
			{
				error_msg+="\nPlease select logo file.";
				if(jCol==1)
				{
					document.getElementById('spanLogo').style.color = 'red';
				}
				if (! alreadyFocussed)
				{
					docF.txtLogo.focus();
					alreadyFocussed = true;
				}
				iserror++;
			}

	}
	

  /************************************ CHECKING WORK STATUS ********************************************/
  	
  	if(akey_trim(docF.txtWorkStatus.value)=="Select")
  	{
  		error_msg+="\nPlease select work status.";
  		if(jCol==1)
  		{
  			document.getElementById('spanWorkStatus').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtWorkStatus.focus();
			alreadyFocussed = true;
		}
  		iserror++;
	}
	

  /************************************ CHECKING PAYMENT STATUS ********************************************/
  	
  	if(akey_trim(docF.txtPaymentStatus.value)=="Select")
  	{
  		error_msg+="\nPlease select payment status.";
  		if(jCol==1)
  		{
  			document.getElementById('spanPaymentStatus').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtPaymentStatus.focus();
			alreadyFocussed = true;
		}
  		iserror++;
	}
	
  /************************************ CHECKING PAYMENT DETAILS ********************************************/
  	
  	if(akey_trim(docF.txtPaymentDetails.value)=="")
  	{
  		error_msg+="\nPlease enter payment details.";
  		if(jCol==1)
  		{
  			document.getElementById('spanPaymentDetails').style.color = 'red';
  		}
		if (! alreadyFocussed)
		{
			docF.txtPaymentDetails.focus();
			alreadyFocussed = true;
		}
  		iserror++;
	}
	
 /*************************** END FORM VALIDATION SCRIPT CODE **************************************************/
 
 	// TEST CODE
	alert('No of errors :'+iserror);
 
 	if(iserror > 0)
 	{// if no of errors on the form is greater than 0
 		alert(error_msg);
 		return false;
 	}
 	else
 	{// no error. well done man
 		docF.message.value="";
 		return true;
 	}
}