
/*  file variables */
var f_str_astring = null;     // holds string
var f_int_min_integer = null;  // holds min value
var f_int_max_integer = null;  // holds max value
var f_str_message1 = null;     // holds message
var f_str_value = null;        // holds string value


/* constant  */
var STR_MODE = "revisit";
var STR_TRUE = "true"             // holds flag
var STR_FALSE = "false"           // holds flag
var STR_MESS1 = "improper user name entry"    // holds message
var STR_MESS2 = "improper password entry"      // holds message
var F_STR_PAGE = "../seadmin/admin_commonlogin.jsp"  // holds url

function onSub()
{
validate();
return false;
}



// checks length
  function checkLength1(f_str_astring,f_int_min_integer,f_int_max_integer )
 {
     this.f_str_astring = f_str_astring;
     this.f_int_min_integer = f_int_min_integer;
     this.f_int_max_integer = f_int_max_integer;

// checks length for min and max value
    if((f_str_astring.length + 1 <= f_int_max_integer)&& (f_str_astring.length +1 >= f_int_min_integer))
    { 
     return STR_TRUE;
    }
// checks min value
    else if(f_str_astring.length + 1 <= f_int_min_integer)
    { 
     return STR_TRUE;
    } 
    else
    {
     f_str_message1 = "total no of characters should be within" +  f_int_min_integer + "and " + f_int_max_integer;
                   document.nam.txt_user_name.select();                                  
     alert(f_str_message1);
     return STR_FALSE;
    }   
 }


// checks length
  function checkLength2(f_str_astring,f_int_min_integer,f_int_max_integer )
 {
     this.f_str_astring =f_str_astring;
     this.f_int_min_integer = f_int_min_integer;
     this.f_int_max_integer = f_int_max_integer;

// checks  length between min and max value
    if((f_str_astring.length + 1 <= f_int_max_integer)&& (f_str_astring.length + 1 >= f_int_min_integer))
    { 
     return STR_TRUE;
    }

// checks min value
    else if(f_str_astring.length + 1 <= f_int_min_integer)
    { 
     return STR_TRUE;
    } 
    else
    {
     f_str_message1 = "total no of characters should be within" + f_int_min_integer +"and " + f_int_max_integer;
     document.nam.pwd_password.select(); 
     document.nam.pwd_password.focus();                                 
     alert(f_str_message1);
     return STR_FALSE;
   }   
 }


// called by JSP
function validate()
{
   var l_str_string = "";                    // local variable to store the string

   l_frm_control = document.nam.txt_user_name;
   l_str_string = trim(l_frm_control.value); // local variable to store the string
   
   if (l_str_string.length == 0)             // check for length of the string
   {
      alert('Please type in your Username.');
      l_frm_control.select();
      l_frm_control.focus();
      return false;
   } // end of check for length if  

  f_str_value = checkUserName(document.nam.txt_user_name,f_int_id_length);

// checks boolean
   if(f_str_value == false)
   {
       return false;
   }

   l_frm_control = document.nam.pwd_password;
   l_str_string = trim(l_frm_control.value); // local variable to store the string
   
   if (l_str_string.length == 0)             // check for length of the string
   {
      alert('Please type in your Password.');
      l_frm_control.select();
      l_frm_control.focus();
      return false;
   } // end of check for length if  

    f_str_value = checkPassword(document.nam.pwd_password,f_int_password_length);  

//checks return value
   if(f_str_value == false)
   {
       
       return false;
   }
   document.nam.method = 'post';
   document.nam.hid_mode.value = STR_MODE ;
   document.nam.action = F_STR_PAGE;
   document.nam.submit();
      return true;
}

