// function returns false if the passed control have any other character other than alphanumeric, dot and space.
function maxAllowed(l_frm_control)
{
   var l_str_string = ""; // local variable to store the string
   // check for not null function
   if (checkNotNull(l_frm_control) == false)
   {
      return false;
   } // end of checknotnull if

   l_str_string = new String(l_frm_control.value);

   // if not allowed characters present in input field
   if (l_str_string.match(/["\\{}']/))
   {
      alert(TXT_Var14215);
      l_frm_control.select();
      l_frm_control.focus();
      return false;
   }
   else
   {  // else allowed characters present in input field but dots present consecutively
/*
      var l_b_alpha_flag1 = l_str_string.search(/[a-zA-Z0-9]/);

      // if not allowed characters present in input field
      if(l_b_alpha_flag1 < 0)
      {
         alert(TXT_Var14216);
         l_frm_control.select();
         l_frm_control.focus();
         return false;
      }
*/
   }

   return true;
} // end of maxAllowed function

// function returns false if the passed control have any other character other than alphanumeric, dot and space.
function checkAllowedName(l_frm_control)
{
   var l_str_string = ""; // local variable to store the string

   // check for not null function
   if (checkNotNull(l_frm_control) == false)
   {
      return false;
   } // end of checknotnull if

   l_str_string = new String(l_frm_control.value);

   // if not allowed characters present in input field
   //****if(l_str_string.match(/[^a-zA-Z0-9. ]/))
   //if(!(checkForm1UnicodeText(l_str_string)))   //for checking the allowed chars
   if(!(checkForm4UnicodeText(l_str_string," ||.||'")))   //for checking the allowed chars
   {
      alert(TXT_Var14217);
      l_frm_control.select();
      l_frm_control.focus();
      return false;
   }
   else
   {  // else allowed characters present in input field but dots present consecutively

   var l_b_alpha_flag1 = l_str_string.search(/[a-zA-Z0-9]/);

   // if not allowed characters present in input field
//****   if(l_b_alpha_flag1 < 0)
	if(!(checkForm4UnicodeText(l_str_string," ||.||'")))
   {
      alert(TXT_Var14216);
      l_frm_control.select();
      l_frm_control.focus();
      return false;
   }
   else
   {
      // local variable to store the length of string
      var l_int_length = (l_str_string.length - 1);
      var l_int_ind = 0;

      l_int_ind = l_str_string.indexOf(".", l_int_ind);

      while ((l_int_ind != -1) && (l_int_ind < l_int_length))
      {
         if (l_str_string.charAt(l_int_ind + 1) == '.')
         {
            alert(TXT_Var14219);
            l_frm_control.select();
            l_frm_control.focus();
            return false;
         }

         l_int_ind = l_str_string.indexOf(".", (l_int_ind + 1));

      }  // end of while
   }  // allowed character validation
   }

   return true;
} // end of checkAllowedName function

/**
   Mandatory address1 validation
*/
function checkAddr1_man()
{
   var l_ctrl_addr1 = document.frm_registration.txt_address1;

   // check for not null function
   if (checkNotNull(l_ctrl_addr1) == false)
   {
      return false;
   } // end of checknotnull if

   if (!(check_Address1(l_ctrl_addr1)))
   {
      l_ctrl_addr1.select();
      l_ctrl_addr1.focus();
      return false;
   }   // end of address check if   
   return true;
}

/**
   Non Mandatory address1 validation
*/
function checkAddr1_nm()
{
   var l_ctrl_addr1 = document.frm_registration.txt_address1;
   var l_ctrl_addr1_val = document.frm_registration.txt_address1.value;

   // checks the address field
   if (trim(l_ctrl_addr1_val).length > 0)
   {
      return checkAddr1_man();
   }
   else
   {
      if ((l_ctrl_addr1_val.length > 0) && (trim(l_ctrl_addr1_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_addr1.select();
         l_ctrl_addr1.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory address2 validation
*/
function checkAddr2_man()
{
   var l_ctrl_addr2 = document.frm_registration.txt_address2;

   // check for not null function
   if (checkNotNull(l_ctrl_addr2) == false)
   {
      return false;
   } // end of checknotnull if

   if (! (check_Address2(l_ctrl_addr2)))
   {
      l_ctrl_addr2.select();
      l_ctrl_addr2.focus();
      return false;
   }   // end of address check if
   return true;
}

/**
   Non Mandatory address2 validation
*/
function checkAddr2_nm()
{
   var l_ctrl_addr2 = document.frm_registration.txt_address2;
   var l_ctrl_addr2_val = document.frm_registration.txt_address2.value;

   // checks for address length
   if (trim(l_ctrl_addr2_val).length > 0)   // checks the address field
   {
      return checkAddr2_man();
   }   // end of address length check if
   else
   {
      if ((l_ctrl_addr2_val.length > 0) && (trim(l_ctrl_addr2_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_addr2.select();
         l_ctrl_addr2.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory city validation
*/
function checkCity_man()
{//alert("checkCity_man called");
   var l_ctrl_city = document.frm_registration.txt_city;

   // check for not null function
   if (checkNotNull(l_ctrl_city) == false)
   {
      return false;
   } // end of checknotnull if

   if (! (checkTextOnly(l_ctrl_city)))
   {
      return false;
   } // end of city check if
   return true;
}

/**
   Non Mandatory city validation
*/
function checkCity_nm()
{//alert("checkCity_nm called");
   var l_ctrl_city = document.frm_registration.txt_city;
   var l_ctrl_city_val = document.frm_registration.txt_city.value;

   // check the city field
   if (trim(l_ctrl_city_val).length > 0)
   {
      return checkCity_man();
   }   //end of city validation if
   else
   {
      if ((l_ctrl_city_val.length > 0) && (trim(l_ctrl_city_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_city.select();
         l_ctrl_city.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory state validation
*/
function checkState_man()
{//alert("checkState_man called");
   var l_ctrl_state = document.frm_registration.txt_state;

   // check for not null function
   if (checkNotNull(l_ctrl_state) == false)
   {
      return false;
   } // end of checknotnull if

   if (! (checkTextOnly(l_ctrl_state)))
   {
      return false;
   } // end of city check if
   return true;
}

/**
   Non Mandatory state validation
*/
function checkState_nm()
{//alert("checkState_nm called");
   var l_ctrl_state = document.frm_registration.txt_state;
   var l_ctrl_state_val = document.frm_registration.txt_state.value;

   // check the state field
   if (trim(l_ctrl_state_val).length > 0)
   {
      return checkState_man();
   }   //end of state validation if
   else
   {
      if ((l_ctrl_state_val.length > 0) && (trim(l_ctrl_state_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_state.select();
         l_ctrl_state.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory postal/zip code validation
*/
function checkZip_man()
{//alert("checkZip_man called");
   var l_ctrl_zip = document.frm_registration.txt_zip_postal_code;

   if(!checkPinCode(l_ctrl_zip))
   {
      return false;
   } // end of zipcode check if
   return true;
}

/**
   Non Mandatory postal/zip-code validation
*/
function checkZip_nm()
{//alert("checkZip_nm called");
   var l_ctrl_zip = document.frm_registration.txt_zip_postal_code;
   var l_ctrl_zip_val = document.frm_registration.txt_zip_postal_code.value;

   // checks zipcode
   if (trim(l_ctrl_zip_val).length > 0)
   {
      return checkZip_man();
   }   //end of if loop pin code validation
   else
   {
      if ((l_ctrl_zip_val.length > 0) && (trim(l_ctrl_zip_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_zip.select();
         l_ctrl_zip.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory email validation
*/
function checkEmail_man()
{
   var l_ctrl_email = document.frm_registration.txt_email;

   // check for not null function
   if (checkNotNull(l_ctrl_email) == false)
   {
      return false;
   } // end of checknotnull if

   // checks for email
   if (!(checkEmail(l_ctrl_email)))
   {
      return false;
   } // end of email check if

   return true;
}

/**
   Non Mandatory email validation
*/
function checkEmail_nm()
{
   var l_ctrl_email = document.frm_registration.txt_email;
   var l_ctrl_email_val = document.frm_registration.txt_email.value;

   // checks for email length
   if (trim(l_ctrl_email_val).length > 0)   // checks the email field
   {
      return checkEmail_man();
   }   // end of email length check if
   else
   {
      if ((l_ctrl_email_val.length > 0) && (trim(l_ctrl_email_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_email.select();
         l_ctrl_email.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory phone validation
*/
function checkPhone_man()
{//alert("checkPhone_man called");
   var l_ctrl_phone = document.frm_registration.txt_phone;

   // checks for phone value
   if (!(maxAllowed(l_ctrl_phone)))
   {
      return false;
   } // end of phone value check if
   return true;
}

/**
   Non Mandatory phone validation
*/
function checkPhone_nm()
{//alert("checkPhone_nm called");
   var l_ctrl_phone = document.frm_registration.txt_phone;
   var l_ctrl_phone_val = document.frm_registration.txt_phone.value;

   // checks for phone length
   if(trim(l_ctrl_phone_val).length>0)
   {
      return checkPhone_man();
   } // end of phone length check if   
   else
   {
      if ((l_ctrl_phone_val.length > 0) && (trim(l_ctrl_phone_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_phone.select();
         l_ctrl_phone.focus();
         return false;
      }
   }
   return true;
}


/**
   Mandatory pc_website_url validation
*/
function checkPcurl_man()
{
   var l_ctrl_pc_website_url = document.frm_registration.txt_pc_web_url;

   // checks for pc_website_url value
   if (!(maxAllowed(l_ctrl_pc_website_url)))
   {
      return false;
   } // end of pc_website_url value check if
   return true;
}

/**
   Non Mandatory pc_website_url validation
*/
function checkPcurl_nm()
{
   var l_ctrl_pc_website_url = document.frm_registration.txt_pc_web_url;
   var l_ctrl_pc_website_url_val = document.frm_registration.txt_pc_web_url.value;

   // checks for pc_website_url length
   if(trim(l_ctrl_pc_website_url_val).length>0)
   {
      return checkPcurl_man();
   } // end of pc_website_url length check if   
   else
   {
      if ((l_ctrl_pc_website_url_val.length>0) && (trim(l_ctrl_pc_website_url_val).length==0))
      {
         alert(TXT_Var14220)
         l_ctrl_pc_website_url.select();
         l_ctrl_pc_website_url.focus();
         return false;
      }
   }
   return true;
}


/**
   Mandatory website_purpose validation
*/
function checkWspur_man()
{
	var l_ctrl_website_purpose = document.frm_registration.txt_wspur;

	// checks for website_purpose value
	if(l_ctrl_website_purpose.selectedIndex==0 )
	{
		alert(TXT_Var14006);
		l_ctrl_website_purpose.focus();
		return false;
	}

	return true;
}

/**
   Non Mandatory website_purpose validation
*/
function checkWspur_nm()
{
   var l_ctrl_website_purpose = document.frm_registration.txt_wspur;
   var l_ctrl_website_purpose_val = document.frm_registration.txt_wspur.value;

   // checks for website_purpose length
   if(trim(l_ctrl_website_purpose_val).length>0)
   {
      return checkWspur_man();
   } // end of website_purpose length check if   
   else
   {
      if ((l_ctrl_website_purpose_val.length > 0) && (trim(l_ctrl_website_purpose_val).length == 0))
      {
         alert(TXT_Var14220)
         //l_ctrl_website_purpose.select();
         l_ctrl_website_purpose.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory mobile validation
*/
function checkMobile_man()
{//alert("checkMobile_man called");
   var l_ctrl_mobile = document.frm_registration.txt_mobile;

   // checks for mobile value
   if (!(maxAllowed(l_ctrl_mobile)))
   {
      return false;
   } // end of mobile value check if
   return true;
}

/**
   Non Mandatory mobile validation
*/
function checkMobile_nm()
{//alert("checkMobile_nm called");
   var l_ctrl_mobile = document.frm_registration.txt_mobile;
   var l_ctrl_mobile_val = document.frm_registration.txt_mobile.value;

   // checks for mobile length
   if(trim(l_ctrl_mobile_val).length>0)
   {
      return checkMobile_man();
   } // end of mobile length check if   
   else
   {
      if ((l_ctrl_mobile_val.length > 0) && (trim(l_ctrl_mobile_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_mobile.select();
         l_ctrl_mobile.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory fax validation
*/
function checkFax_man()
{//alert("checkFax_man called");
   var l_ctrl_fax = document.frm_registration.txt_fax;

   // checks for fax value
   if (!(maxAllowed(l_ctrl_fax)))
   {
      return false;
   } // end of fax value check if
   return true;
}

/**
   Non Mandatory fax validation
*/
function checkFax_nm()
{//alert("checkFax_nm called");
   var l_ctrl_fax = document.frm_registration.txt_fax;
   var l_ctrl_fax_val = document.frm_registration.txt_fax.value;

   // checks for fax length
   if(trim(l_ctrl_fax_val).length>0)
   {
      return checkFax_man();
   } // end of fax length check if   
   else
   {
      if ((l_ctrl_fax_val.length > 0) && (trim(l_ctrl_fax_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_fax.select();
         l_ctrl_fax.focus();
         return false;
      }
   }
   return true;
}


/**
   Mandatory Vatno validation 
*/
function checkVat_man()
{//alert("check Vatno_man called");
   var l_ctrl_vatno = document.frm_registration.txt_vatno;

   // checks for fax value
   if (!(maxAllowed(l_ctrl_vatno)))
   {
      return false;
   } // end of fax value check if
   return true;
}

/**
   Non Mandatory Vatno validation
*/
function checkVat_nm()
{	//alert("checkVatNo_nm called");
   var l_ctrl_vatno = document.frm_registration.txt_vat;
   var l_ctrl_vatno_val = document.frm_registration.txt_vatno.value;

   // checks for Vatno length
   if(trim(l_ctrl_vatno_val).length>0)
   {
      return checkVat_man();
   } // end of Vatno length check if   
   else
   {
      if ((l_ctrl_vatno_val.length > 0) && (trim(l_ctrl_vatno_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_vatno.select();
         l_ctrl_vatno.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory Url Check box validation 
*/
function checkUrl_man()
{//alert("check Vatno_man called");
   var l_ctrl_url_flag = document.frm_registration.chk_url_flag;

   // checks for fax value
   if (!(l_ctrl_url_flag.checked == true))
   {
      alert(TXT_Var14235);	
      l_ctrl_url_flag.select();
      l_ctrl_url_flag.focus();
      return false;
   } 
   return true;
}


/**
   Mandatory company name validation
*/
function checkComp_man()
{//alert("checkComp_man called");
   var l_ctrl_comp = document.frm_registration.txt_company_name;

   // checks for company name
   if (!(maxAllowed(l_ctrl_comp)))
   {
      return false;
   } // end of default value check if  
   return true;
}

/**
   Non Mandatory company name validation
*/
function checkComp_nm()
{//alert("checkComp_nm called");
   var l_ctrl_comp = document.frm_registration.txt_company_name;
   var l_ctrl_comp_val = document.frm_registration.txt_company_name.value;

   // checks for comp length
   if(trim(l_ctrl_comp_val).length>0)
   {
      return checkComp_man();
   } // end of comp length check if   
   else
   {
      if ((l_ctrl_comp_val.length > 0) && (trim(l_ctrl_comp_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_comp.select();
         l_ctrl_comp.focus();
         return false;
      }
   }
   return true;
}

/**
   Mandatory date validation
*/
function checkDate_man()
{//alert("checkDate_man called");
   var l_ctrl_year = document.frm_registration.txt_date_of_birth_year;
   var l_ctrl_year_val = document.frm_registration.txt_date_of_birth_year.value;

   // check the year length
   if(document.frm_registration.lst_date_of_birth_month.selectedIndex == 0)
   {
         alert(TXT_Var14230);
         document.frm_registration.lst_date_of_birth_month.focus();
         return false;
   }

   // check the year length
   if(document.frm_registration.lst_date_of_birth_day.selectedIndex == 0)
   {
         alert(TXT_Var14231);
         document.frm_registration.lst_date_of_birth_day.focus();
         return false;
   }

   // check for not null function
   if (checkNotNull(l_ctrl_year) == false)
   {
      return false;
   } // end of checknotnull if

      if (! (trim(l_ctrl_year_val).length == 4))
      {
         alert(TXT_Var14232);
         l_ctrl_year.select();
         l_ctrl_year.focus();
         return false;
      } // end of year length check if
      else
      {
         l_int_day = document.frm_registration.lst_date_of_birth_day.options[document.frm_registration.lst_date_of_birth_day.options.selectedIndex].value;
         l_int_month = document.frm_registration.lst_date_of_birth_month.options[document.frm_registration.lst_date_of_birth_month.options.selectedIndex].value;
         l_int_year = l_ctrl_year_val;
         if (! (isValidDate(l_int_day, l_int_month, l_int_year)))
         { // check for valid date
            l_ctrl_year.select();
            l_ctrl_year.focus();
            return false;
         } // end of valid date check if
         if (! (checkPastDate(l_int_day, l_int_month, l_int_year)))
         {
            l_ctrl_year.select();
            l_ctrl_year.focus();
            return false;
         }
         if(new Date().getYear() < 1000) // checks for the current year
         {
            l_int_cur_year = new Date().getYear() + 1900;
         } // end of current year check if
         else
         {
            l_int_cur_year = new Date().getYear();
         } // end of current year check else

         // checks for year
         if ((l_int_cur_year - l_ctrl_year_val) >= 100)
         {
            alert (TXT_Var14233);
            l_ctrl_year.select();
            l_ctrl_year.focus();
            return false;
         } // end of valid year check if
      } // end of year length check else
   return true;
}

/**
   Non Mandatory date validation
*/
function checkDate_nm()
{//alert("checkDate_nm called");
   var l_ctrl_year = document.frm_registration.txt_date_of_birth_year;
   var l_ctrl_year_val = document.frm_registration.txt_date_of_birth_year.value;

   // check the year length
   if(document.frm_registration.lst_date_of_birth_month.selectedIndex > 0 || document.frm_registration.lst_date_of_birth_day.selectedIndex > 0 || (trim(l_ctrl_year_val).length >0))
   {
      return checkDate_man();
   }   //end of date function
   else
   {
      if ((l_ctrl_year_val.length > 0) && (trim(l_ctrl_year_val).length == 0))
      {
         alert(TXT_Var14220)
         l_ctrl_year.select();
         l_ctrl_year.focus();
         return false;
      }
   }
   return true;
}

