//******************************************************************************
// *  Filename:  w_form_util.js
// *  Purpose :  This file contains common utility functions used throughout IQRS 
// *  Author :   Sunil Kumar  
//******************************************************************************

var statu;   // Status of the validation
var err_msg;  // Current Error Msg String

// ---------------------------------------
// setError sets the statu to false, and 
// update the error message
// ---------------------------------------
function setError(message)
{
        statu = false;
        err_msg = err_msg + message + " \n";
}

// --------------------------------------
// Shows the Javascript Error 
// This seems to be needed in netscape 
// --------------------------------------

function showError(msg, url, ln) 
{
    alert("JavaScript Error: " + msg + '\n' + ln);
    return true;
}
window.onerror = showError;

// --------------------------
// This is a DEBUG function
// --------------------------
function showFormObjs(form)
{
var i;
var str = "";

for(i=0; i < form.length; i++)
{
   str = str + "\n" + form.elements[i].name + " " + 
                                          form.elements[i].value + "   " +
                                          form.elements[i].type;

   if ((i % 30) == 0) 
   {
      alert(str);
          str = "";
   }
}
alert(str);
}

//-----------------------------------------------
// This function returns a full year
// ----------------------------------------------
function getFullYear(date)
{
  var y = date.getYear();
  if (y < 1000)
     y += 1900;
  return y;
}

// ---------------------------------------------- 
// This function validates a data element
// ensuring it is all numeric digits.
// Returns : TRUE - All Numeric
//           FALSE - Not All Numeric
// ---------------------------------------------- 
function isValidNumber(passedVal) 
{
  for ( i=0; i < passedVal.length; i++) 
  {
        digit = passedVal.charAt(i);
        if ((digit < "0") || (digit > "9")) 
        {
                return false
        }
  }

  return true
}
// ---------------------------------------------- 
// This function validates a data element
// ensuring it is a valid ammount in the 
// format XXXXX.XX
// Returns : TRUE - Valid
//           FALSE - Not Valid
// ---------------------------------------------- 
function isValidAmount(passedVal)
{
var rc = true;

  if (passedVal.charAt(passedVal.length - 3) != ".") 
  { 
          rc =  false; 
  }
  else if  (
                (!isValidNumber(passedVal.substring(0, passedVal.length - 3))) ||
                (!isValidNumber(passedVal.substring(passedVal.length - 2, passedVal.length)))
           )
  {
       rc =  false;
  }
return rc;
}


// ---------------------------------------------- 
// This function validates a data element
// ensuring it is all numeric digits.
// Returns : TRUE - All Numeric
//           FALSE - Not All Numeric
// ---------------------------------------------- 
function isValidCharacter(passedVal) 
{
  for ( n=0; n < passedVal.length; n++) 
  {
        character = passedVal.charAt(n);
        if (((character < "a") || (character > "z")) && ((character < "0") || (character > "9")) &&
              ((character < "A") || (character > "Z")))
        {
               return false
        }
  }
  return true
}

function validYear(inYear)
{
   if ( (inYear.length != 4) || !isValidNumber(inYear) )
   {
      return false;
   }
  
   if (inYear >2100 || inYear < 1900)
   {
      return false;
   }

   return true;
}

function validGrad15 (gradyear, birthdate)
{
birthyear = birthdate.substring(4,8)
if (gradyear != "") 
{
 gradnum = gradyear - 0
 birthnum = birthyear - 0
 diffnum = gradnum - birthnum

 if ((diffnum <= 14) && (gradnum != 0))
 {
  // alert("All graduation years must be at least 15 years later than the year of birth.  Please verify all years.")
  return false
 }
}
return true
} 

// ---------------------------------------------------------------
// Given a radio button array, returns the value that is selected
// ---------------------------------------------------------------
function getRadioValue(r_arr)
{
        for (i=0; i< r_arr.length; i++)
        {
                if (r_arr[i].checked) return r_arr[i].value;
        }
        return null;
}

// ----------------------------------------------------
// Determines if the string object passed in is above
// 160 characters or not
// the function checkLength can not be used because
// check length alerts the user directly.
// ----------------------------------------------------
function above160(str_obj)
{
    return (str_obj.length > 160);
}

// ----------------------------------------------------
// Determines if the string object passed in is above
// 2000 characters or not
// ----------------------------------------------------
function above2000(str_obj)
{
        return (str_obj.length > 2000);
}


// ----------------------------------------------------
// Checks the length of a string in textarea ta. If it is longer than
// len, display a area and force the user to correct it.
// ----------------------------------------------------
function checkLength(ta, len) {
  if( ta.value.length > len ) {
    alert("There are " + ta.value.length + " characters in the field.\n" +
          "The maximum number of character allowed is " + len + ".");
    //
    // Test Issue 13 # Removed the ta.focus() call as it was putting us into
    // an infinite loop.
    //
  }
}

// -------------------------------------------------------------------------------
// These functions validates a license.  validLic returns false
// if the license number doesn't have at least one digit.
// -------------------------------------------------------------------------------
function validLic(passedVal) 
{

  for ( j=0; j <passedVal.length; j++) 
  {
      digit = passedVal.charAt(j);
      if ((digit>= "0") && (digit <= "9")) 
      {
          return true
      }
  }
  return false
}

// -------------------------------------------------------------------------------
// This function removes the dashes from all SSNs if they are present
// The assumption is that all strings are valid SSNs in format xxx-xx-xxxx
// -------------------------------------------------------------------------------
function stripSSNDelimeters(inputForm)
{
        if (inputForm != null)
        {
          f = inputForm; 
        }
        if ((f.SSN_1 != null) && (!isNone(f.SSN_1.value))) 
        { 
        f.SSN_1.value = f.SSN_1.value.substring(0,3) + f.SSN_1.value.substring(4,6) + f.SSN_1.value.substring(7,11); 
        }
        
        if ((f.SSN_2 != null) && (!isNone(f.SSN_2.value))) 
        { 
        f.SSN_2.value = f.SSN_2.value.substring(0,3) + f.SSN_2.value.substring(4,6) + f.SSN_2.value.substring(7,11); 
        }

        if ((f.SSN_3 != null) && (!isNone(f.SSN_3.value)))
        {
        f.SSN_3.value = f.SSN_3.value.substring(0,3) + f.SSN_3.value.substring(4,6) + f.SSN_3.value.substring(7,11); 
        }

        if ((f.SSN_4 != null) && (!isNone(f.SSN_4.value)))
        { 
        f.SSN_4.value = f.SSN_4.value.substring(0,3) + f.SSN_4.value.substring(4,6) + f.SSN_4.value.substring(7,11); 
        }

        if ((f.PRCT_SSN != null) && (!isNone(f.PRCT_SSN.value)))
        { 
        f.PRCT_SSN.value = f.PRCT_SSN.value.substring(0,3) + f.PRCT_SSN.value.substring(4,6) + f.PRCT_SSN.value.substring(7,11); 
        }
        
}

// -------------------------------------------------------------------------------
// This function validates a Social Security Number.
// It verifies the format of data entry to be xxx-xx-xxxx
// and checks to see that all values are numeric.
// -------------------------------------------------------------------------------

function validSSN(inSSN)
{
      if (inSSN == "")
      {
             return true
      }

      //get the first hyphen position
      firstpos = inSSN.indexOf("-",0)
      if (firstpos == -1)
      {
            // alert("SSN must be in the format xxx-xx-xxxx.")
            return false
      }

      first = inSSN.substring(0,firstpos)
      otherstring = inSSN.substring(firstpos+1, inSSN.length)

      secondpos = otherstring.indexOf("-",0)
      second = otherstring.substring(0, secondpos)

      third = otherstring.substring(secondpos+1, inSSN.length)

      if (first.length != "3") 
      {
             // alert("SSN must be in the format xxx-xx-xxxx.")
             return false
      }

      for (k=0; k<first.length; k++)
     {
          digit = first.charAt(k)

          if (!isValidNumber(digit))
         {
            //    alert("SSN must be numeric.")
               return false
          }
     }

     if (second.length != "2") 
    {
          // alert("SSN must be in the format xxx-xx-xxxx.")
          return false
     }

     for (b=0; b<second.length; b++)
     {
           digit = second.charAt(b)
           if (!isValidNumber(digit))
          {
              //  alert("SSN must be numeric.")
               return false
          }
     }

     if (third.length != "4") 
     {
            // alert("SSN must be in the format xxx-xx-xxxx.")
            return false
     }

     for (c=0; c<third.length; c++)
    {
          digit = third.charAt(c)
          if (!isValidNumber(digit))
          {
             //   alert("SSN must be numeric.")
               return false
          }
    }

     if( (first == 0) && (second == 0) && (third == 0) ) {
       setError("Social Security number cannot be all zeroes (0s)");
       return false;
     }

    return true
}

// -----------------------------------------------
// This function validates a date
//       - checks date is in mm/dd/yyyy format
//       - checks month is numeric and is between JAN(01) and DEC(12)
//       - checks day is numeric and  is valid for that month
//           (does leap year calculation)
//       - checks year is numeric
// Returns : TRUE if valid
//           FALSE if invalid
// ------------------------------------------------

function validDate(month, day, year)
{
  var monthDays  =new Array(31,29,31,30,31,30 ,31,31,30,31,30,31)


// DEBUG -- Alerts need to be changed to setErrors....


  //validate the month
  //if the month is more than 2 digits, not numeric, 
  //not between 1 and 12 then it is not a valid month
  if (!isValidNumber(month))
  {
        // alert("Invalid month. Month must be numeric.")
        return false
  }

  if (month.length != "2") 
  {
     // alert("Invalid month. Month must be two digit long.")
     return false
  }

  monthnum = month - 0                  // convert to number
  if ((monthnum < 1) || (monthnum > 12))
  {
     // alert("Invalid month. Month must be between 1 and 12.")
     return false
  }

  //validate the day
  //if the  day is less than 1 or more than number of days
  //in that month then it is not a valid day
  if (!isValidNumber(day))
  {
       //  alert("Invalid day. Day must be numeric.")
        return false
  }
 
  if (day.length != "2") 
  {
     // alert("Invalid day. Day must be two digit long.")
     return false
  }

  dayNum = day - 0                               // convert to number
  if ((dayNum < 1 ) || (dayNum > monthDays[monthnum - 1]))
  {
     // alert("Invalid day. Not a valid day in this month.")
     return false
  }

  //validate the year
  if (!validYear(year))
     return false;

  if (year.length != "4") 
  {
     // alert("Invalid year. Year must be four digit long.")
     return false
  }

  //In a leap year February has 29 days otherwise it has 28 days. If the year is a not a leap year and the number of 
  //days exceeds 28 then it is an invalid day 
  yearNum = year - 0                   // convert to number
  leapYear = false
  if (monthnum == 2)
  {
     leapYear = (((yearNum % 4 == 0) && (yearNum % 100 != 0)) || (yearNum % 400 == 0))
     if (!leapYear && (dayNum > 28))
     {
       //   alert("Invalid day. Number of days in February is 28.")
          return false
      } 
   }
  return true 
}

// -------------------------------------------------
// This function determines if a date is in the future
// Returns : TRUE if in the future
//           FALSE if either today or in the past
// -------------------------------------------------
function isDateFuture(dateValue)
{
    var isDateInFuture = true;

    month = dateValue.substring(0,2);
    day = dateValue.substring(2,4);
    year  = dateValue.substring(4,8);

    var currDate = new Date();
    sysmonth = currDate.getMonth();
    sysmonth++;
    sysyear = currDate.getFullYear();
    sysday = currDate.getDate();

    if (sysyear > year)
    {
      isDateInFuture = false;
    }
    else if ((sysyear == year) && (sysmonth > month))
    {
      isDateInFuture = false;
    }
    else if ((sysyear == year) && (sysmonth == month) && (sysday >= day))
    {
      isDateInFuture = false;
    }
    return isDateInFuture;
}

// ---------------------------------------------- 
// This function checks all the checkboxes on a page.
// Returns : None
// ---------------------------------------------- 
function checkAll(field)
{
  for (i = 1; i < field.length; i++) 
  {
    field[i].checked = field[0].checked;
  }
}

// ----------------------------------------------
// This function checks is at least one checkbox
// has been checked.
// Returns:  true - one checked
//           false - none checked
// ----------------------------------------------
function oneCheckboxChecked(field)
{
    var index = 0;
    var oneChecked = false;

    if (field[0] == undefined)
    {
        if (field.checked)
        {
            oneChecked = true;
        }
    }
    else
    {
        for (index = 0; (index < field.length) && !oneChecked; index++)
        {
            if (field[index].checked)
            {
                oneChecked = true;
            }
        }
    }

    return oneChecked;
}

// ---------------------------------------------- 
// This function validates the dbid field.
// Makes sure it's 15 characters long and numeric.
// Returns : None
// ---------------------------------------------- 
function validateDbid(dbid)
{
    var dbidSize = 15;

        if ((!isEmptyStr(dbid)) && (dbid.value.length != dbidSize))
    {
        setError("The DBID is not the correct length.  It must be 15 characters long.");
    }
    if (!isValidNumber(dbid.value))
    {
        setError("The DBID has to contain only numbers.");
    }
}

// -------------------------------------------------
// This function validates the date of birth 
// Returns : TRUE if valid
//           FALSE if invalid
// -------------------------------------------------
function validBirthDate(inDate)
{
  if (inDate == "")
  {
     setError("Date of birth is required.")
     return false
  }

  month = inDate.substring(0,2);
  day = inDate.substring(2,4);
  year  = inDate.substring(4,8);

  var now = new Date
  currYear = getFullYear(now)
  currMonth = now.getMonth()
  yearNum = year - 0
  monthNum = month - 0
  dayNum = day - 0

   validbirthdate = validDate(month, day, year)

   if ( (yearNum < 1900) || (yearNum + 15 > currYear) ||
          ((yearNum + 15 == currYear) && (monthNum > currMonth + 1)) ||
          (yearNum == 1900 && monthNum == 1 && dayNum == 1) )
     {
         setError("Date of birth must be at least 15 years before today's date and after 1900.")
         return false
     }

    if (validbirthdate == false)
    {
     setError("Invalid date of birth. Must be in format MMDDYYYY");
     return false
    }
  return true
}

// ---------------------------------------------- 
// This function validates a zip code
// Returns : TRUE - all numeric
//           FALSE - not all numeric
// ---------------------------------------------- 
function validNumericZip(inZip)
{
  if ((isValidNumber(inZip)))
  {
     return true
  }
  else
  {
         setError("ZIP code must be numeric.")
         return false
  }
} 

// ---------------------------------------------- 
// This function validates a zip code
// Returns : TRUE - all alphanumeric
//           FALSE - not all alphanumeric
// ---------------------------------------------- 
function validAlphaNumericZip(inZip)
{
  if  (isValidCharacter(inZip))
  {
     return true
  }
  else
  {
         setError("ZIP code must be alphanumeric.")
         return false
  }
} 

// ------------------------------------------------
// Checks if an address is valid
// returns : true for a valid address
//                   false for an invalid address
//                       null for an empty address
// ------------------------------------------------
function isValidAddress(address, city, state, country, zip, zip4)
{

var state_val = state.options[state.selectedIndex].value;

        // ----------------------------------
        // First check for a blank address 
        // ---------------------------------
   if ((address.value == "") &&
      (city.value == "") &&
          (country.value == "") &&
          (zip.value == "") &&
          (zip4.value == "")
          )
   {
       return null;
   }

   // Address is filled in and thus must be validated

// changed alerts to setError -SCR 651

   if (address.value  == "")
   {
       setError("Street address required.")
      //    return false;
   }

  if (city.value  == "")
  {
          
       setError("City required.")
      //city.focus()
      //city.select()
      //return false
  }

  if (country.value  == "")
     {
         if (state_val  == "")
         {
             setError("For U.S. addresses, State is required; leave Country field blank.  For other countries, leave State field blank and use City/Country fields only.")
             //state.focus()
             //state.select()
             //return false
         }

         // if state provided/country not provided zip and zip4 must be numeric
         else
         {
             if (!validNumericZip(zip.value)) 
             {
                 //zip.focus()
                 //zip.select()
                 return false
             }

                if (zip.value.length != "5")
                {
                   setError("For U.S. addresses, ZIP code must be 5 digits.")
                           //zip.focus()
               //zip.select()
             return false
                        }

                        if ((zip4.value.length != "4") && (zip4.value.length != "0"))
                        {
                                setError("For U.S. addresses, ZIP4 must be 4 digits.  If unknown, leave blank.")
                            //zip4.focus()
                //zip4.select()
             return false
                        }

          if (!validNumericZip(zip4.value))
          {
                 // zip4.focus()
                 // zip4.select()
                 return false
          }
        }
     }
     
   // if country provided state should not be provided
     else
     {
         if (state_val != "")
         {
              setError("For U.S. addresses, State is required; leave Country field blank.  For other countries, leave State field blank and use City/Country fields only.")
             // state.focus()
             // state.select()
             return false
         }

         // if country provided/state not provided zip and zip4 must be alphanumeric
         else
         {
             if (!validAlphaNumericZip(zip.value))
             {
                 // zip.focus()
                 // zip.select()
                 return false
             }

             if (!validAlphaNumericZip(zip4.value))
             {
                 // zip4.focus()
                 // zip4.select()
                 return false
             }
         }
     }
return true;
}   

// ------------------------------------------------
// This function ensures a string is not emtpy
// or all spaces
// ------------------------------------------------
function isEmptyStr(str_obj)
{
 var str_obj_value;
 if (str_obj.type == "select-one") // select object
 {
   str_obj_value = str_obj.options[str_obj.selectedIndex].value;
 }
 else // not a select object
 {
   str_obj_value = str_obj.value;
 }

 if (str_obj_value == "") 
 {
    return true;
 }

 for (i=0; i<str_obj_value.length; i++)
 {
        if (str_obj_value.charAt(i) != " ")
        {
                return false;
        }
 }
  
return true;
}

// ---------------------------------------------
// Check if an SSN entered is valid or not
// Expects format 123456789 (no dashes. etc..)
// ---------------------------------------------
function isValidSSN(in_ssn)
{

   var flag = false;

      if (isEmptyStr(in_ssn)) 
        { 
        return null; 
        }
      else if ((f.FORM_NAME.value != 'FORM_SUBJ_EDIT') && ((f.ACTION_TYPE.value == 96) || (f.ACTION_TYPE.value == 97))) 
          {
          if (isNone(in_ssn.value)) 
          {
          flag = true; 
          }
        else
            {
            flag = (validSSN(in_ssn.value));
            }
          }
        else if(validSSN(in_ssn.value))
          {
        flag = true;
        }
      else
        {
        flag = false;
        }

  return flag;
}

// ---------------------------------------------
// Check if a Self Query has an SSN of "NONE"
// Expects any case of the word none.
// ---------------------------------------------
function isNone(in_ssn)
{
        var tmp_str=in_ssn;

        tmp_str=tmp_str.toUpperCase();
        
        if(tmp_str == "NONE")   
          { 
          return true; 
          }
        else 
          { 
          return false; 
          }
}

// -----------------------------------
// Takes a group of text fields and
// moves all the values into adjacent
// text fields starting with the 1st
// so that there are no blanks. 
// ----------------------------------- 
function compressTextFields(fields)
{
    if(fields==null) return;
    for(var i=0; i<fields.length; i++) 
    {
        if(fields[i]==null) return;

        if(isEmptyStr(fields[i])) 
        {
            for(var j=i+1; j<fields.length; j++)
            {
                if(!isEmptyStr(fields[j]))
                {
                    fields[i].value=fields[j].value;
                    fields[j].value="";
                    break;
                }
            }
        }
    }
}
 
// -----------------------------------------------------
// Check that all schools have grad years and vice versa
// -----------------------------------------------------
function is_valid_grad(year, school)
{
        if (
             (isEmptyStr(year) && !isEmptyStr(school)) ||
             (!isEmptyStr(year) && isEmptyStr(school))
           )
        {
                return 1;
        }
return 0;
}


function isValidDcn(dcnField)
{
    if (!dcnField)
    {
        setError("Invalid dcn input field, programmer error.");
    }
    else if (dcnField.value.length != 16)
    {
        setError("DCN's must be 16 digits long.");
    }
    else if (!isValidNumber(dcnField.value))
    {
        setError("DCN's must contain only digits.");
    }

    return statu;
}

//Function to validate Date Range
function validateDateRange(fromDate, toDate)
{
    statu = true;
    err_msg = "";

   from_dt_yr = fromDate.value.substring(4,8);
   from_dt_mon = fromDate.value.substring(0,2);
   from_dt_day = fromDate.value.substring(2,4);

    to_dt_yr = toDate.value.substring(4,8);
    to_dt_mon = toDate.value.substring(0,2);
    to_dt_day = toDate.value.substring(2,4);

    validFrom = validDate(from_dt_mon, from_dt_day, from_dt_yr);
    validTo = validDate(to_dt_mon, to_dt_day, to_dt_yr);
   
    if ((isEmptyStr(fromDate)) || (isEmptyStr(toDate)))
    {
        setError("Must specify From and To dates.");
    }
   
    if (!isEmptyStr(fromDate))
    {
        if (validFrom !=true)
        {
            setError("The date in the From field is invalid.  Date must be in MMDDYYYY format.");
        }
    }

    if (!isEmptyStr(toDate))
    {
        if (validTo !=true)
        {
            setError("The date in the To field is invalid.  Date must be in MMDDYYYY format.");
        }
    }

    START_DATE = from_dt_yr + from_dt_mon + from_dt_day;
    END_DATE =   to_dt_yr + to_dt_mon + to_dt_day;

    if (validFrom && validTo)
    {
        if ( START_DATE >=  END_DATE )
        {
            setError("The date in the From field must precede the date in the To field.");
        }
    }

    return statu;
}

// Function to trim spaces from all text field on a web page
function trimSpaces()
{
    var numForm = document.forms.length;
    var blankLineExp = /^ +$/;
    var startBlankExp = /^ +/;
    var endBlankExp = / +$/;

    // loop through all of the forms on the page
    for (formCount = 0; formCount < numForm; formCount++)
    {
        var numFields = document.forms[formCount].elements.length;

        // loop through all of the fields in the form
        for (fieldCount = 0; fieldCount < numFields; fieldCount++)
        {
            var tempElement = document.forms[formCount].elements[fieldCount];

            // if a text field or textarea then trim space
            if ((tempElement.type == "text") || (tempElement.type == "textarea"))
            {
                // check if value all space, if so then set to empty string
                if (tempElement.value.search(blankLineExp) != -1)
                {
                    tempElement.value = "";
                }
                else
                {
                    // trim starting spaces
                    if (tempElement.value.search(startBlankExp) != -1)
                    {
                        var tempStr = tempElement.value.replace(startBlankExp, "");
                        tempElement.value = tempStr;
                    }

                    // trim trailing spaces
                    if (tempElement.value.search(endBlankExp) != -1)
                    {
                        var tempStr = tempElement.value.replace(endBlankExp, "");
                        tempElement.value = tempStr;
                    }
                }
            }
        }
    }
}

// check that a text area does not have too much text in it
// param textArea The text area field in the form
// param length The maxLength The length to check against
// param textAreaTitle The title of the text area, used in the
//       error message if the length is too long. (eg. "Subject Statement")
// returns boolean True or false and calls setError()
function checkTextAreaLength(textArea, maxLength, textAreaTitle)
{
    if (textArea.value.length > maxLength)
    {
        setError("The " + textAreaTitle + " cannot be more than " + formatNumber(maxLength) + 
                " characters. The " + textAreaTitle + " as written has " + 
                formatNumber(textArea.value.length) + 
                " characters, including spaces and punctuation. Please resubmit.");

        return false;
    }

    return true;
}

// put in comma's in a number if required
// only works up to 999,999
// param number The unformatted number
// returns String The formatted number
function formatNumber(number)
{
    if (number < 999)
    {
        return number; 
    }
    else 
    {
        var numberStr = "" + number; // convert to string if its passed in as a number
        numberStr = numberStr.substr(0, (numberStr.length - 3)) + "," + numberStr.substr(numberStr.length - 3);
               //',' + numberStr.substr(numberStr.length - 3));
        return numberStr;
    }
}

var submissions = 0;

// Function to check that the user hasn't already submitted 
// a page (prevents double-clicking).  Only call this once
// the user has passed all validation.
// Use the function in your code as follows:
// 
// Validation code, setError(), etc.
// if (statu && isDuplicateSubmission())
// {
//     statu = false;
// }
// else
// {
//    alert(err_msg);
// }
// return statu;
// See ReportResponseSecReviewJs.jsp for an example
// OR
// If this is the only validation on your page
// have the button onClick="return !isDuplicateSubmission();"
function isDuplicateSubmission()
{
    return ++submissions > 1;
}

// -----------------------------------------------------
//function to perform validation using Validate.js
// submitValidation executes the array of
// validation functions
// -----------------------------------------------------
function submitValidation()
{
    trimSpaces();
    statu = true;
    err_msg = "";
    pageValidate.executeValidation();
    if (!statu)
    {
       alert(err_msg);
    }
    return statu;
}
// End hiding script
// -->

