//
//                 IFS Research & Development
//
//  This program is protected by copyright law and by international
//  conventions. All licensing, renting, lending or copying (including
//  for private use), and all other use of the program, which is not
//  expressively permitted by IFS Research & Development (IFS), is a
//  violation of the rights of IFS. Such violations will be reported to the
//  appropriate authorities.
//
//  VIOLATIONS OF ANY COPYRIGHT IS PUNISHABLE BY LAW AND CAN LEAD
//  TO UP TO TWO YEARS OF IMPRISONMENT AND LIABILITY TO PAY DAMAGES.
// ----------------------------------------------------------------------------
// File          : clientscript.js
// Description   :
// Notes         :
// ----------------------------------------------------------------------------
// Modified      :
//    Jacek P    1998-Dec-01 - Created. Some functions moved from ASPManager.
//    Jacek P    1999-Jan-11 - Corrected spelling of variable NEWWIN_HEIGHT
//    Jacek P    1999-Feb-01 - Corrected bug (Bug #3136) in function onSubmit().
//    Jacek P    1999-May-14 - Added handling of never expiring pages.
//    Marek D    1999-May-28 - Added support for editable tables
//    Marek D    1999-Jun-02 - Modified setFocus logic in function onLoad()
//    Marek D    1999-Jun-07 - Corrected setFocus logic in function onLoad()
//    Marek D    1999-Jun-08 - Added function sort_()
//    Marek D    1999-Jun-10 - Modified getField_()
//    Jacek P    1999-Jun-21 - Modified getField_() for support of select boxes.
//    Jacek P    1999-Jul-21 - Added multiplication factor for LOV window for
//                             Netscape in function openLOVWindow().
//                             Added new function resetRadioButtons().
//    Jacek P    1999-Aug-02 - Added block name as input parameter to getRowStatus_()
//    Johan S    1999-Aug-16 - Added functions preLoad and loadImages for hover-buttons.
//    Johan S    1999-Aug-18 - moved loadImages to onLoad. Modified preLoad to use generated constants.
//    Jacek P    1999-Aug-25 - Corrected bug in assignSelectBoxValue_(). Function
//                             should find and set an index, not only copy the new value.
//    Jacek P    1999-Sep-08 - Removed (renamed) function loadImages() and preLoad().
//                             Removed call to loadImages() from onLoad() due to
//                             code generation in ASPManager.
//    Jonas C    1999-Sep-22 - Corrected bug (#??) in function commandSet. 
//    Jacek P    1999-Oct-14 - Added support for system alert.
//    Jacek P    1999-Oct-27 - No alert box will be shown on reloading page.
//    Stefan M   2000-Jan-13 - Removed loadImages_() and preLoad_() completely.
//    Stefan M   2000-Mar-23 - setMinimizeImage() added; switches image+hover.
//    Stefan M   2000-Mar-27 - "old" popup script removed in favour of new leaner
//                             script in ASPPage + ASPPopup.
//    Jacek P    2000-May-04 - Added methods for support of portals.
//    Jacek P    2000-May-12 - Netscape support.
//    Stefan M   2000-May-17 - Added storeMinimize(), storeMaximize().
//    Jacek P    2000-Jul-31 - Correctet functions add() and moveSide() (logid 262).
//    Jacek P    2000-Aug-01 - Changes in minimize-portlet algorithm due to problems in Netscape (#123)
//    Jacek P    2000-Oct-09 - Added lovPortal() (log id #298).
//    Artur K    2001-Mar-20 - Added changePortal() function.
//    Artur K    2001-Apr-20 - Changed changePortal() function.
//    Mangala    2001-Apr-23 - Changed clearProfile() (log id #692)
//    Chandana D 2001-May-30 - Changed parameter URL to url in showHelp(topic)    
//    Kingsly P  2001-Jun-14 - Added methods toUpperCase(obj,id) and toLowerCase(obj,id).
//    Mangala    2001-Apr-23 - Changed lovPortal() (log id #768).
//    Chandana   2001-Jun-26 - Change submitCustomization(id).
//    Ramila H   2001-Jul-12 - Changed function lovPortal() to support field validations if necessary. (log # 775).
//    Piotr Z    2001-Aug-21 - Added window.focus() call in showNewBrowser() function.
//    Chandana D 2001-Dec-04 - Introduced xcape(s), getLow(mod) and getHigh(div)[these two methods are called from xcape(s)]
//    Chandana D 2001-Dec-18 - Renamed xcape(s) as encodeUnicode(s)
//    Chandana D 2002-Feb-12 - Removed getLow(mod) and getHigh(div) functions. 
//                             Reimplemented the encodeUnicode(s) function.
//                             Intorduced getHexString(text) and getHex(i) functions.
//    Chandana D 2002-Feb-20 - Introduced decodeUnicode(enc_str), getIntValue(hex) and _16toPower(exp) functions.
//    Jacek P    2002-Feb-20 - Added call to decodeUnicode() when reading from cookies in readMessage().
//    Chandana D 2002-Mar-13 - Removed encodeUnicode()c & decodeUnicode() functions, but they will be provided by ASPConfigFile just like the URLClentEncode() function.
//                             encodeUnicode() function will escape the encoded string before returning the string and
//                             decodeUnicode() function will accept an escaped string as the input parameter as unescaping is done inside the decodeUnicode() function.
//                             Introduced ifsEncode() & ifsDecode() functions which will be called by the encodeUnicode() & decodeUnicode() functions respectively.
//    Chandana D 2002-Mar-16   Fixed bugs in ifsEncode() & ifsDecode() functions.
//    Mangala    2002-Mar-18 - Changes to avoid visiting history of the other users in the browser.
//    Mangala    2002-Apr-02 - Ignore browser history restriction if it is disabled in ASPConfig.ifm
//    Suneth M   2002-May-10 - Changed onLoad() to modify the URL with __CACHE variable. 
//    Chandana D 2002-Jun-18 - Added new function 'removePageMask()' and a call to that function in the 'onLoad()' function.
//    Chandana D 2002-Jun-20 - Modified removePageMask() to support enable/disable 'Inactivate Page At Loading' feature from ASPConfig.ifm
//    Chandana D 2002-Jun-25 - Introduced showLOV() & closeLOV() functions, lov_closed boolean variable and dependent option for the LOV window.(bug # 828)
//    Mangala    2002-Jun-28 - Caching solution is comented out.
//    Chandana D 2002-Jul-09 - Replaced the 'dependent' attribute with a html variable('DEPENDENT') in openLOVWindow function
//    Chandana   2002-Jul-18 - Added new function correctURL(url).
//                           - Used correctURL(url) function to add an ID to the URL.
//    Chandana   2002-Jul-22 - Removed 'Restrict History' coding as it was moved to the ASPConfigFile.java(to include it in the <HEAD> section)
//    Chandana   2002-Jul-30 - Added showtip(current,e,tip) & hideTip() functions.
//    Daniel     2002-Sep-05 - Added CCA() to highlight selected rows.
//    Mangala    2002-Sep-17 - Fixed bug in correctURL
//    Mangala    2002-Oct-03 - Added function assignCheckBoxValue().
//    Chandana   2002-Oct-03 - Included field.focus() statement in a try-catch block in the missingValueError_ function.
//    Chandana   2002-Oct-08 - Changed try-catch block to be compatible with Netscape 4.x
//    Sampath    2002-Oct-09 - moved javaScript functions to ClientScript.js from the page.
//    Mangala    2002-Oct-09 - Log Id 984. Changed showNewBrowser(),
//    Mangala    2002-Oct-09 - Removed unnecessary replacements from URLClientEncode() method.
//    ChandanaD  2002-Oct-21 - Prefixes CURRENT_USER infront of the cookie name in readCookie(),writeCookie()writePersistentCookie & removeCookie() functions.
//    ChandanaD  2002-Oct-28 - Made compatible with NE6 and above.
//    Ramila     2002-Nov-04 - Bug 33981, Changed index of selectbox to 0 if --- selected.
//    Sampath    2002-Now-05 - changed _menu and show menu to display "mylinks" in sub menus in NE6 
//    Chandana D 2002-Nov-05 - Prevents appending user id to the name of the __Authorized_User_ cookie.
//    Sampath    2002-Nov-06 - add script selectAllRows() deselectAllRows() and invertselection()
//    Chandana D 2002-Nov-20 - Modified showMenu_ function to suport NE6 and above.
//    Ramila H   2002-Dec-02 - Log id 762. Added methods checkNumberValue_ and invalidNumberError_.
//    Suneth M   2002-Dec-11 - Log Id 1002, Added new method getAllSelectedValues().
//    Chandana D 2002-Dec-13 - Added formatNumber_(num).
//    Ramila H   2002-Dec-13 - Log id 933. Added methods to save and delete queries.
//    Sampath    2002-Dec-16 - added function to zoom-in portlets
//    Ramila H   2002-Dec-16 - added check in populateFields method.
//    Chandana D 2002-Dec-18 - Log Id 567, Added several methods.
//    Chandana D 2002-Dec-26 - Log Id 967, Added rowClicked(elm) function and 'cca' boolean variable.
//    Chandana D 2003-Jan-02 - Bug corrected in Log Id 967.
//    Ramila H   2003-Jan-08 - Overloaded showNewBrowser.
//    Sampath    2003-Jan-10 - add functions __connect(), pause() to move clientutil applet methods into clientscript.js  
//    Ramila H   2003-Jan-14 - added function showNewBrowser_ to be able to pass the new window width and height.
//    Chandana D 2003-Jan-22 - Added ifsAlert(msg) method.
//    Chandana D 2003-Jan-28 - Modified removePageMask() method.
//    Rifki R    2003-Feb=19 - Used a try-catch to set initial focus in onLoad(). Avoids errors when using group boxes.
//    Johan S    2003-Mar-04 - rewrote the cookie handling, see ASPManager for more info.
//    Chanaka A  2003-Mar-06 - Add support to kill Crystal Report sessions when QuickReportQuery.page is closed
//                             Modifications to the OnUnLoad() function. Add new function submitHandlerNS6() and
//                             variables cr_logoff_path and is_submit
//    Chandana D 2003-Mar-17 - Changed showNewBrowser_ function to support surpressing scrollbars.
//    Chanaka A  2003-Mar-19 - Fixed calling the logoff.csp from sql reports in quick reports.
//    Chandana D 2003-Mar-19 - Added new function applyPageMask() and called it in submit() function.
//    Chandana D 2003-Mar-20 - Suffixed a "/" APP_PATH in the writCookie() function.
//    Chandana D 2003-Mar-24 - Corrected a bug in showMenu_ function.
//    Chandana D 2003-Mar-25 - Modified msgLoad() function to set the focus to the OK button in IFS_DIALOG s.
//    Mangala    2003-Mar-26 - Changes for more validation mechanism possibilities.
//    Chandana D 2003-Mar-27 - Removed selectActiveCommand() and deselectActiveCommand() functions.
//    Sampath    2003-Apr-17 - made changes to IfsAlert() to display more_info
//    Chandana D 2003-Apr-29 - Corrected a bug in hideSubmenus() function.
//    Chandana D 2003-May-06 - Corrected a bug for Netscape 6 in hideSubmenus() function.
//    Chandana D 2003-May-22 - Added setFooter() function.
//    Chandana D 2003-May-27 - Removed setFooter() function.
//    Chandana D 2003-May-27 - Declared LOV_ALWAYS_ON_TOP variable with null.
//    Chandana D 2003-Jun-02 - Added new function menuClicked and modified the showMenu_ function to place the popups in a proper place.
//    Chandana D 2003-Jun-05 - Changed widht/height and top/left of the save query dialog window.
//    Chandana D 2003-Jun-06 - Opened submenus on the left side if there's not enough space on the right.
//    Chandana D 2003-Jun-09 - Triggered onChange event for a field if available before executing the default command when Enter is pressed. 
//    Mangala    2003-Jun-26 - Corrected bug in remove cookie
//    Sampath    2003-Jul-18 - Insert javaScript Trim functions. 
//    Chanaka    2003-Aug-06 - Remove obsolete code for CR from OnUnload. 
//    Chandana D 2003-Aug-12 - Changed rowCliked function.
//    Sampath    2003-Aug-13 - changed openLOVWindow to support new LOV features.
//    Ramila H   2003-Sep-04 - Added method showNewStyledBrowser.
//    Ramila H   2003-Sep-04 - Changed split character in populateField().
//    Chandana D 2003-Sep-12 - Removed any % in the formatNumber_ function.
//    Chandana D 2003-Sep-18 - Called hideMenus() in the showMenuNav4() to fix a bug in Netscape 4.x
//    Chandana D 2003-Oct-07 - Added new function removePercentage(num1).
//    Suneth M   2003-Oct-15 - Changed onLoad() to fix a problem of line breaks in translated popup messages.
//    Ramila H   2003-Oct-15 - Call id 107696, Add function clearAllQueryFields()
//    Chandana D 2003-Dec-10 - Bug 40925, Fixed a bug showing blank lines in popup menus in NE7.x
//    Suneth M   2003-Dec-15 - Bug 40904, Changed closeLOVWindow() to close LOV window correctly in NS7.x
//    Chandana D 2003-Dec-16 - Fixed Bug 40908.
//    Suneth M   2003-Dec-24 - Bug 40914, Changed getValue_() to get the selected value of a combo box correctly.
//    Suneth M   2003-Dec-24 - Bug 41846, Changed closeLOVWindow().
//    Chandana D 2004-Jan-12 - Bug 41996, fixed.
//    Suneth M   2004-Jan-13 - Bug 40926, Changed commandSet().
//    Suneth M   2004-Jan-27 - Bug 42321, Changed closeLOVWindow().
//    Rifki R    2004-Jan-27 - Bug 40903, Context cache improvements.
//    Chandana D 2004-Jan-27 - Bug 42299, Modified __connect() and __connectURL()
//    Suneth M   2004-Jan-29 - Bug 42321, Changed closeLOVWindow().
//    Rifki R    2004-Feb-09 - Undo changes for Bug 40903, Context cache improvements.
//    Chandana D 2004-Feb-11 - Bug 42662 fixed.
//    Chandana D 2004-Feb-11 - Bug 42691 fixed.
//    Chandana D 2004-Feb-12 - Bug 42727 fixed.
//    Rifki R    2004-Feb-13 - Bug 40903, chanegs for new context cache algortihm.
//    Mangala P  2004-Feb-19 - Bug 42811, Changed closeLOVWindow()
//    Chandana D 2004-Feb-19 - Bug 42867, Added new method removeAllPageIdCookies().
//    Rifki R    2004-Feb-20 - Bug 40903, changed __open() and __showModalDailog() to append 
//                             __CONTEXT_ID only when its not present in url
//    Chandana D 2004-Feb-25 - Bug 42997, commented out window.frames.__CUIF.location.replace(""); statements. 
//    Chandana D 2004-Mar-17 - Bug 43527, Cookie prefix constant declerations moved to the top.
//    Rifki R    2004-Apr-07 - Bug 43673, Avoid caching in __connectURL() for activex validations.
//    Suneth M   2004-Jul-14 - Bug 45937, Changed showHelp() to maximize the minimized help window when selecting a new topic.
//    Suneth M   2004-Aug-03 - Bug 46227, Changed checkStatus_() & invalidNumberError_().
// ---------------------------------------------------------------------------------------------------------------------

/*
var lov_row_nr = null;
var lov_field_name = null;
var lov_window = null;
var post_lov_function = null;
*/

//Bug 43527, start
TRANSIENT_PREFIX = "fndwebTran_";
TEMPORARY_PREFIX = "fndwebPageID_";
VIC_PREFIX = "fndweb_";
//Bug 43527, end

var _new_x = 0;
var _new_y = 0; 
var dir_changed = false;
var MAX_MENU_WIDTH =120;
cca = false;
default_command = null;
lov_window = null;
calendar_window = null;
LOV_ALWAYS_ON_TOP = null;

var map = new Array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F');

var C29 = String.fromCharCode(29);
var C30 = String.fromCharCode(30);
var C31 = String.fromCharCode(31);

var lov_closed=false;
var f = document.forms[0];
var __row_select=false;

var cr_logoff_path = null;
var is_submit = '';
   
//Bug 40903, start
tmp1 = window.open+'';
if(tmp1.indexOf("[native code]")!=-1)
{
   tmp_open = window.open;                    
   window.open = __open; 
   tmp_sm = window.showModalDialog;                     
   window.showModalDialog = __showModalDialog;
}
//Bug 40903, end

function onLoad()
{

 //Bug 40908, start
    f.autocomplete='off';
 //Bug 40908, end

 if(__row_select==true)
     CCA_All();

   removePageMask();
   if(opener)
   {
      if(document.getElementById)
         eval("try {opener.lov_closed=false;}catch(e){}");
      else
         opener.lov_closed=false;
   }
   
   if(f.__RESTORE_POSITION)
   {
      var y=f.__RESTORE_POSITION.value;
      if (y!="" && y > 0)
      {
            if(IS_EXPLORER)
               document.body.scrollTop=y;   
            else
               window.scrollTo(0,y);   
      }
   }

  if(!readMessage())
  {
    reloadPage();
    return;
  }

  
  f.__COMMAND.value = '';
  f.__LINK.value = '';
  f.__POSTED.value = '';
  msg = f.__SYSTEM_ALERT.value;
  f.__SYSTEM_ALERT.value = '';
  if( msg!='' ) ifsAlert(msg);
  msg = f.__ALERT.value;
  while(msg.indexOf("\\n") != -1)
     msg = replaceString(msg,"\\n",String.fromCharCode(10));
  f.__ALERT.value = '';
  if( msg!='' ) ifsAlert(msg);
  x = f.__FOCUS.value;
  
  __READY = true;
  
  if( x!='' )
  {
    x = eval('f.'+x);
    if( x+''=='undefined' )
      return;
    if( x.length==1 )
      x = x[0];
    else if( x.length>1 )
      x = x[1];

    if( x.type!='hidden' )
    {
       if(document.getElementById)
          eval("try{x.focus();}catch(e){}");
       else
          x.focus();
    }
  }

  if(BROWSER_CACHE_DISABLED)
     for(i=0;i<document.links.length;i++)
        if(document.links[i].href.indexOf('.page')!=-1)
           document.links[i].href = correctURL(document.links[i].href);  
  
  cca = false;

  //Bug 40903, start
  if (window.name=='')
   window.name=(new Date()).getTime();
      
  if (f.__CONTEXT_ID.value=='') 
	 f.__CONTEXT_ID.value=window.name;  //new CONTEXT_ID for subsequent POSTs after initial GET
  //Bug 40903, end
   
 
}


function readMessage()
{
  if(NEVER_EXPIRE)
     ret = true;
  else
     ret = false;
  var cookie_name = f.__PAGE_ID.value;
  message = new String(decodeUnicode(readCookie(cookie_name)));
  removeCookie(cookie_name,APP_PATH);

  if(message!='')
  {
    if(message.length>1 || message=="*")
    {
      ret=true;
      if(message.length>1)
      {
        cookie_name = f.__PAGE_ID.value+ADD_MSG;
        add_message = new String(decodeUnicode(readCookie(cookie_name)));
        removeCookie(cookie_name,APP_PATH);
        if(add_message!='')
        {
          if(add_message.length>1)
          {
            if(MESSAGE_PAGE_PATH == null)
              {
                if(confirm(message+"\n\n"+MORE_INFO_MSG))
                  ifsAlert(add_message);
              
                else
                  ifsAlert(message);  
              }
              else
                 ifsAlert(message+C31+add_message);
          }
          else
            ifsAlert(message);
        }
        else
          ifsAlert(message);

      }
    }
  }
  //Bug 42867, start
  removeAllPageIdCookies();
  //bug 42867, end
  return(ret);
}

//Bug 42867, start
function removeAllPageIdCookies()
{
    var cookie_string = document.cookie;
    var cookie_set = cookie_string.split(';');
    var set_size = cookie_set.length;
    var cookie_pieces;
    for(x=0;x<set_size;x++)
    {
       cookie_pieces = cookie_set[x].split('=');
       if(cookie_pieces[0].substring(0,1)==' ')
          cookie_pieces[0]=cookie_pieces[0].substring(1,cookie_pieces[0].length);
       cookie_name = cookie_pieces[0];
       if(cookie_name.indexOf('PageID_')>0)
          document.cookie = cookie_name+"=test"+
             ";expires="+(new Date("January 1, 1990")).toGMTString()+
             ";path="+APP_PATH;
    }
}
//Bug 42867, end

function reloadPage()
{
  //if ( !NEW_PAGE ) 
  //  alert(EXPIRE_MSG);
  if ( IS_EXPLORER )
    location.replace(CURRENT_URL);
  else   
    location.reload(true);
}

function confirmReloadPage()
{
  if( confirm(EXPIRE_MSG) )
  {
    if ( IS_EXPLORER )
      location.replace(CURRENT_URL);
    else
      location.reload(true);
  }
}

/* Some cookie-constants */

/* When writing cookies from javascript you should
   set the path to the constant APP_PATH.
*/

//Bug 43527, start
/*
TRANSIENT_PREFIX = "fndwebTran_";
TEMPORARY_PREFIX = "fndwebPageID_";
VIC_PREFIX = "fndweb_";
*/
//Bug 43527, end

function writePersistentTransientCookie(name, value)
{
   if(CURRENT_USER!='null' && name.indexOf(CURRENT_USER)==-1 && name.indexOf(AUTH_COOKIE)==-1)
      name = CURRENT_USER+'_'+name;
   var expire = new Date();
   expire.setTime(2145916800000);
   writeTransientCookie(name, value, expire);
}


function writeTransientCookie(name, value, expires, path, domain, secure)
{
  if(CURRENT_USER!='null' && name.indexOf(CURRENT_USER)==-1 && name.indexOf(AUTH_COOKIE)==-1)
     name = CURRENT_USER+'_'+name;
  name = TRANSIENT_PREFIX+name; 
  document.cookie = name+"="+escape(value)+
    ((expires) ? ";expires="+expires.toGMTString() : "")+
    ((path) ? ";path="+path : ";path="+APP_PATH)+
    ((domain) ? ";domain="+domain : "")+
    ((secure) ? ";secure" : "");
}


function writePersistentCookie(name, value)
{
   if(CURRENT_USER!='null' && name.indexOf(CURRENT_USER)==-1 && name.indexOf(AUTH_COOKIE)==-1)
      name = CURRENT_USER+'_'+name;
   var expire = new Date();
   expire.setTime(2145916800000);
   writeCookie(name, value, expire);
}


function writeCookie(name, value, expires, path, domain, secure)
{
  if(CURRENT_USER!='null' && name.indexOf(CURRENT_USER)==-1 && name.indexOf(AUTH_COOKIE)==-1)
     name = CURRENT_USER+'_'+name; 
   name = VIC_PREFIX+name;
  document.cookie = name+"="+escape(value)+
    ((expires) ? ";expires="+expires.toGMTString() : "")+
    ((path) ? ";path="+path : ";path="+APP_PATH+"/")+
    ((domain) ? ";domain="+domain : "")+
    ((secure) ? ";secure" : "");
}

function writePageIDCookie(name, value, expires, path, domain, secure)
{
   name = TEMPORARY_PREFIX+name;
  document.cookie = name+"="+escape(value)+
    ((expires) ? ";expires="+expires.toGMTString() : "")+
    ((path) ? ";path="+path : ";path="+APP_PATH)+
    ((domain) ? ";domain="+domain : "")+
    ((secure) ? ";secure" : "");
}


function readCookie(name)
{
  var pid_name = name;
  if(CURRENT_USER!='null' && name.indexOf(CURRENT_USER)==-1 && name.indexOf(AUTH_COOKIE)==-1)
     name = CURRENT_USER+'_'+name;
  var cookie_string = document.cookie;
  var cookie_set = cookie_string.split(';');
  var set_size = cookie_set.length;
  var cookie_pieces;
  for(x=0;x<set_size;x++)
  {
    cookie_pieces = cookie_set[x].split('=');
    if(cookie_pieces[0].substring(0,1)==' ')
      cookie_pieces[0]=cookie_pieces[0].substring(1,cookie_pieces[0].length);
    cookie_name = cookie_pieces[0];
    if(cookie_name == VIC_PREFIX+name || cookie_name == TRANSIENT_PREFIX+name || cookie_name == TEMPORARY_PREFIX+name || cookie_name == TEMPORARY_PREFIX+pid_name)
      return unescape(cookie_pieces[1]);
  }
  return '';
}


function removeCookie(name, path, domain)
{
  pid_name = name;
  if(CURRENT_USER!='null' && name.indexOf(CURRENT_USER)==-1 && name.indexOf(AUTH_COOKIE)==-1)
     name = CURRENT_USER+'_'+name;
  document.cookie = VIC_PREFIX + name + "=*;expires="+(new Date("January 1, 1990")).toGMTString() +
    ((path) ? ";path="+path : "")+
    ((domain) ? ";domain="+domain : "");
  document.cookie = TRANSIENT_PREFIX + name + "=*;expires="+(new Date("January 1, 1990")).toGMTString() +
    ((path) ? ";path="+path : "")+
    ((domain) ? ";domain="+domain : "");
  document.cookie = TEMPORARY_PREFIX + pid_name + "=*;expires="+(new Date("January 1, 1990")).toGMTString() +
    ((path) ? ";path="+path : "")+
    ((domain) ? ";domain="+domain : "");
}

function onSubmit()
{
  if ( f.__POSTED.value == '*' )
  {
    confirmReloadPage();
    return false;
  }  
  else
  {
    f.__POSTED.value = '*';
    dummy = f.__POSTED.value;
  }
  return true;
}


function submit()
{
  applyPageMask();
  onSubmit();
  f.submit();
}

 var MASK ="";
 var MULTICH ="";
 var PARAM ="";
 var FIELDKEYVALUE ="";
 var KEY_VALUE="";

function openLOVWindow(name,row_nr,url,width,height,post_function)  
{  
  lov_field_name = name;  
  lov_row_nr = row_nr;  
  post_lov_function = post_function;  
  url = url + (url.indexOf('?')>0 ? '&' : '?');
  if( !document.getElementById )
  {
     width  = width  * 1.55;
     height = height * 1.05;
  }
  
  if (url.indexOf(lov_field_name)==-1)
  {
      tstr = lov_field_name+"="+URLClientEncode(KEY_VALUE)+"&"
      url = url+tstr;
  }
   var str  = "";
   if ((url.indexOf("MULTICHOICE")<0) && (MULTICH != "")) 
      str = str+"MULTICHOICE="+MULTICH;
   if(!PARAM=="")
      str = str + PARAM;
   if((url.indexOf("__KEY_VALUE")<0) && (FIELDKEYVALUE != ""))
       str = str + FIELDKEYVALUE;
   if((url.indexOf("__MASK")<0) && (MASK != ""))
      str = str + "&__MASK="+MASK+'&';
   else if (str!="")
           str = str + '&';
   str1 = url.substring(0,url.indexOf("?")+1);  
   str2 = url.substring(url.indexOf("?")+1);
   if(str.indexOf('&')==0)
       str = str.substring(1);
   url = str1 + str + str2;
  
  
   lov_window = window.open(correctURL(url+'LOV='+name+'&WIDTH='+width+'&HEIGHT='+height),
                           'LOV',
                           'status,resizable,scrollbars,'+DEPENDENT+'width='+width+',height='+height+LOV_POSITION);
  

   MASK ="";
   MULTICH ="";
   PARAM ="";
   FIELDKEYVALUE ="";
   KEY_VALUE="";
}

function closeLOVWindow(value)
{
  fld = getField_(lov_field_name,lov_row_nr);
  fld.value = value;
  // Bug 42811, start
  if (fld.type.toUpperCase()!="HIDDEN")
  // Bug 42811, end    
      fld.focus();
   
  // Bug 42388, start
  lov_window.close();
  lov_window = null;
  // Bug 41846, start
  //lov_window.close();
  // Bug 42321, start
  //lov_window = null;
  // Bug 42321, end
  // Bug 41846, end
  // Bug 40904, start
  setTimeout("eval(post_lov_function+'(lov_row_nr);')",0);
  // Workaround for Netscape 7.1
  // Bug 40904, end
  // Bug 42388, end
}


function cancelLOVWindow()
{
  lov_window.close();
  lov_window = null;
}


var help_window = null;

function showHelp(topic)
{
  url = HELP_URL;  
  url = HELP_URL + '?url=' + topic;  
  help_window = window.open(url,'HELP',HELP_FEATURES+",width="+HELP_WIDTH+",height="+HELP_HEIGHT+HELP_POS);
  // Bug 45937, start
  help_window.focus();
  // Bug 45937, end
}

var zoom_portlet_window = null;

function zoomOutPortlet(id)
{
   url = SEARCHBASE;
   url = url + (url.indexOf('?')>0 ? '&' : '?');
   url = url +"__ISZOOM=Y&__PH_ID="+id;
   zoom_window = window.open(correctURL(url),'',config='toolbar=yes,scrollbars=yes' );
                          
   
}


function closeHelpWindow()
{
  help_window.close()
  help_window = null;
}

function endHelp()
{
  opener.closeHelpWindow();
}

function setValue(selectedValue)
{
  fixed_value = selectedValue.replace("<DQ>","\"");
  fixed_value = selectedValue.replace("<SQ>","'");

  opener.closeLOVWindow(fixed_value);
}

function cancelValue()
{
  opener.cancelLOVWindow();
}


function checkStatus_(result,name,i,label)
{
  field = getField_(name,i);
  the_status = result.substring(0,1);
  if( the_status=='E' )
  {
    ifsAlert(result.substring(1));
    // Bug 46227, start
    setTimeout('field.focus()',1);
    // Bug 46227, end
    return false;
  }
  else if( the_status=='F' )
  {
    if( result=='F' )
      ifsAlert(INVVAL_MSG + label + ']');
    else
      ifsAlert(result.substring(1));
    // Bug 46227, start
    setTimeout('field.focus()',1);
    // Bug 46227, end
    return false;
  }
  else
    return true;
}


function checkMandatory_(field,label,msg)  
{
  if( field.type.substr(0,6)=='select' )  
  {  
    if( field.options[field.selectedIndex].value=='' )
      return missingValueError_(field,label,msg);  
  }  
  else  
  {  
    if( field.value == '' )  
      return missingValueError_(field,label,msg);  
  }  
  return true;  
}


function missingValueError_(field,label,msg)
{
  if( msg == '' )
    ifsAlert(REQVAL_MSG + label + ']');
  else
    ifsAlert(msg);
  if(document.getElementById)
     eval("try{field.focus();}catch(e){}");
  else
     field.focus();
  return false;
}


function assignValue_(field,pos)  
{  
  field.value = field.defaultValue = __getValidateValue(pos);  
}

function getField2_(name)
{
   var x = eval('f.'+name);
   return x;
}


function assignSelectBoxValue_(name,i,pos)  
{
//      fld = getField_(name);
      fld = eval('f.'+name);
      if(!fld.type)    // undefined, so it's an array.
         fld = fld[i];
   
  var newval = __getValidateValue(pos);

  for(i=0;i<fld.length;i++)
  {
     if(fld.options[i].value==newval)
     {
        fld.selectedIndex = fld.options[i].index;

        return;
     }
  }

  sbx = fld.options[fld.selectedIndex];  
  sbx.value = sbx.text = newval;
}


function changedValueError_(label)
{
  ifsAlert('['+ label +'] '+ ROFLD_MSG );
}


function checkReadOnly_(field,label)  
{  
  if( field.type.substr(0,6)=='select' )  
  {  
    x = 0;  
    for( i=0; i<field.length; i++ )  
      if( field.options[i].defaultSelected )  
        x = i;  
    if( field.selectedIndex == x )  
      return true;  
    changedValueError_(label);  
    field.selectedIndex = x;  
  }  
  else  
  {  
    if( field.value == field.defaultValue )  
      return true;  
    changedValueError_(label);  
    field.value = field.defaultValue;  
  }  
  field.focus();  
  return false;  
}


var dirtyFlag = false;

function setDirty()
{
  dirtyFlag = true;
}

function clearDirty()
{
  dirtyFlag = false;
}

function isNotDirty()
{
  if( dirtyFlag )
    return !confirm(DIRTY_MSG);
  else
    return true;
}


function commandSet(cmd,func)
{


   if( !__READY )
      return;

   if (IS_EXPLORER)
      f.__LAST_POSITION.value=document.body.scrollTop;
   else
      f.__LAST_POSITION.value=window.pageYOffset;

  if( func=='' )
    ok = true;
  else
    if(func.indexOf('(')>-1)
       eval('ok = '+func+';');
    else
       eval('ok = '+func+'();');
  if( !ok ) return;
  f.__COMMAND.value = cmd;

  __READY = false;

  submit();
  
  // Bug 40926, start
  if (cmd.indexOf('OutputChannel')>-1) 
  {
     removePageMask();
     __READY = true;
     f.__POSTED.value = '';
  }
  // Bug 40926, end
}


function commandClick(cmd)
{
  f.__LINK.value = cmd;
  submit();
}

function submitForm(action)
{
  f.action = action;
  submit();
}


function showNewBrowser_(action, win_width, win_height, scrollbars )
{
   if (action.indexOf(".page")>0) 
   {
      var index = action.indexOf("?");
      if (index<0)
         action += "?__NEWWIN=Y";
      else
         action += (index == action.length)?"__NEWWIN=Y":"&__NEWWIN=Y";
      
   }
   
   //Bug 40903, start
   window.open(action,window.name+'_1',NEWWIN_FEATURES+",width="+win_width+",height="+win_height+NEWWIN_POS+((scrollbars=='NO')?",scrollbars=NO":"")).focus();
   //Bug 40903, end
  
}


function showNewBrowser(action)
{
    showNewBrowser_(action, NEWWIN_WIDTH, NEWWIN_HEIGHT )
}


function showNewStyledBrowser(action, styles )
{
   if (action.indexOf(".page")>0) 
   {
      var index = action.indexOf("?");
      if (index<0)
         action += "?__NEWWIN=Y";
      else
         action += (index == action.length)?"__NEWWIN=Y":"&__NEWWIN=Y";
   }
   
   //Bug 40903, start
   window.open(action,window.name+'_1',styles).focus();
   //Bug 40903, end
  
}


//Bug 40903, start
function __showModalDialog(url,args,features){
   if (url.indexOf(".page")>0) 
   { 
	 if (url.indexOf('__CONTEXT_ID')<0) {

	   var index = url.indexOf("?");
       if (index<0)
	    url += "?__CONTEXT_ID="+window.name+'_1';
	   else
	    url += (index == url.length)?"__CONTEXT_ID="+window.name+'_1':"&__CONTEXT_ID="+window.name+'_1';
	 }

   }

   //get actual native method
   window.showModalDialog = tmp_sm;

   if (!args)
	  args='';
   if (!features)
	  features='';
   
   var new_win =  window.showModalDialog(url,args,features);

   //set to override again
   tmp_sm = window.showModalDialog;                     
   window.showModalDialog = __showModalDialog;

   return new_win; 
}

function __open(url, name, features){
   
   if (url.indexOf(".page")>0) 
   {
	 if (name==null||name=='') 
	   name=window.name+'_1'; 
	  
	 if (url.indexOf('__CONTEXT_ID')<0) {
	 
       var index = url.indexOf("?");
	   if (index<0)
	     url += "?__CONTEXT_ID="+name;
	   else
	     url += (index == url.length)?"__CONTEXT_ID="+name:"&__CONTEXT_ID="+name;
	 }

	} 

   //get actual native method
   window.open = tmp_open;

   if (!features)
	  features='';

   var new_win = window.open(url,name,features);

   //set to override again
   tmp_open = window.open;                    
   window.open = __open;

   return new_win;
}
//Bug 40903, end


function loadFavoriteUrl(url)
{
  top.location.assign(APP_ROOT+'default.asp?URL='+url);
}

function quickEdit(rowno, first, cmd, func, tabno, seltype)
{
  if( seltype=='M' )
     eval("f.__SELECTED"+tabno+"[rowno-first].checked = true;");
  else if( seltype=='O' )
     eval("f.__SELECTED"+tabno+".checked = true;");
  else
     eval("f.__SELECTED"+tabno+"[rowno-first].value = rowno;");
  commandSet(cmd, func);
}

function setCheckBox_(name,boolval,i,strval)
{
  getField_(name,i).value = (boolval ? strval : "");
}

function getField_(name,i)
{
    var x = eval('f.'+name);
/*
    if(IS_EXPLORER)
        if(x.type=="select-one") return x;
    else
        if(x.type=="select-one") return x.options[x.selectedIndex];
*/

//   alert("name: " + name + "\nfield: " + x.name + "\ntype: " + x.type);
//   if(x.type == undefined)
//      alert("undefined: " + x.name + "  (" + name + " - " + i + ")");
   
//   if(x.type=="select-one") return x;
//   if(IS_EXPLORER)
//       return x.length>i ? x[i] : x;
//   else
     return x.type ? x: x[i];
}

function getField_Old(name,i)
{
        return eval('f.'+name + (i<0 ? '' : '['+i+']'));
}

function getValue_(name,i)
{
    var fld = getField_(name,i);
    if (fld.type == 'checkbox' && !fld.checked)
        return '';
    // Bug 40914, start
    else if (fld.type == 'select-one') 
       return fld.options[fld.selectedIndex].value;
    // Bug 40914, end
    else
        return fld.value;
    //return getField_(name,i).value;
}

function getRowStatus_(blk,i)
{
  return getField_('__'+blk+'_ROWSTATUS',i).value;
}

function assignValue_(name,i,pos)  
{  
   fld = getField_(name,i);
   fld.value = fld.defaultValue = __getValidateValue(pos);   
}

function assignCheckBoxValue_(name,i,pos,value)
{
    fld = getField_(name,i);
    fld.checked = (value == __getValidateValue(pos));
}

function toUpper_(name,i)
{
  fld = getField_(name,i);
  fld.value = fld.value.toUpperCase();
}  

function sort_(tabname,colname,cmdid)
{
  f.__SORT.value = tabname + '.' + colname;
  commandSet(tabname + '.' + cmdid,'');
}   

function resetRadioButtons(radiobtn)
{
   eval("r = f."+radiobtn.name);
   for(i=0; i<r.length; i++)
      r[i].checked=r[i].defaultChecked;
}

function toggleStyleDisplay(el,id)
{
      el = document.getElementById(el); 

        if(el.style.display!='none')
      {
            el.style.display='none';
            if(id)
            storeMinimize(id);
      }
        else
      {
            el.style.display='block';
         if(id)
            storeMaximize(id);
      }
}

function setMinimizeImage(minimizeImage,minimizedBlock)
{
        minimizedBlock = document.getElementById(minimizedBlock);

        if(minimizedBlock.style.display!='none')
           minimizeImage.src=Minimize_nrm.src;
        else
         minimizeImage.src=Maximize_nrm.src;
}

function storeMinimize(id)
{
   min = readCookie('__CBLOCKS');
   min = replaceString(min, 'Y'+id+',','');
   min = replaceString(min, 'N'+id,',','');
   writeTransientCookie('__CBLOCKS', min + 'N' + id + ',');
}

function storeMaximize(id)
{
   min = readCookie('__CBLOCKS');
   min = replaceString(min, 'Y'+id+',','');
   min = replaceString(min, 'N'+id+',','');
   writeTransientCookie('__CBLOCKS', min + 'Y' + id + ',');
}

function getPortletFieldName( id, name )
{
   return "_"+id.toUpperCase().replace(/\./gi,'_')+"_"+name;
}

function getPortletField( id, name )
{
   var fname = getPortletFieldName(id,name);
   return getField_(fname);
}

function setPortalMode( mode, id )
{
   f.__PORTAL_MODE.value = mode;
   f.__PORTLET_ID.value  = id;
}

function changePortal(s)
{
   var url = s.options[s.selectedIndex].value; 
   if (url == '---') url = s.options[0].value;
   window.top.location.href = url;
}


function submitPortlet(id)
{
   setPortalMode('N',id);
   submit();
}

function submitCustomization(id)
{
   if(id=='')
   {
      if(f.colnum.value < maxcolno)
         if(!checkColumns())
            return false;
      var colstr = '';
      for(c=0; c<maxcolno; c++)
      {
         colwid = eval('f.col'+c+'width').value;
         colstr = colstr + 'C=' + c + ',';
         var box = eval('f.col_'+c);
         for(i=0; i<box.length-1; i++)
         {
            var txt = box.options[i].text;
            var val = box.options[i].value;
            var pos = val.indexOf('.');
            var wid = val.substr(0,pos);
            var nam = val.substr(pos+1);
            if(wid > colwid)
            {
               ifsAlert(WIDE_PORTLET_CHK1 + txt + WIDE_PORTLET_CHK2);
               return false;
            }
            colstr = colstr + nam + ",";
         }
      }
      f.__PORTAL_COLUMNS.value = colstr;
      setPortalMode('S','');
      submit();
   }
   else
   {
      setPortalMode('S',id);
      submit();
   }
}


function checkColumns()
{
   var notempty = 0;
   for(c=0; c<maxcolno; c++)
   {
      var box = eval('f.col_'+c);
      if(box.length>1)
        notempty++;
   }
   if(notempty > f.colnum.value)
   {
      ifsAlert(NO_EMPTY_COL);
      return false;
   }
   return true;
}

function clearProfile(id)
{
   if (confirm(id==''? REM_PORTAL_PROFILE_MSG : REM_PORTLET_PROFILE_MSG ))
   {
      setPortalMode('R',id);
      submit();
   }
}

function customizeBox(id)
{
   setPortalMode('C',id);
   submit();
}

function customizePage()
{
   setPortalMode('C','');
   submit();
}

function refreshPortal()
{
   setPortalMode('N','');
   submit();
}

function minimizeBox(id)
{
   var min = readCookie(min_boxes);
   if(min=='') min = '*';
   writePersistentTransientCookie(min_boxes, min+','+id+',');

   if(document.getElementById)
   {
      var t = document.getElementById('tab_'+id);
      t.style.display='none';
      t = document.getElementById('max_head_'+id);
      t.style.display='none';
      t = document.getElementById('min_head_'+id);
      t.style.display='block';
      /*
      t = eval('tdmin_'+id);
      t.style.display='none';
      t = eval('tdmax_'+id);
      t.style.display='block';
      t = eval('hmin_'+id);
      t.style.display='block';
      t = eval('hmax_'+id);
      t.style.display='none';
      */
   }
   else
   {
      setPortalMode('N','*');
      submit();
   }
}

function maximizeBox(id)
{
   var min = readCookie(min_boxes);
   if(min=='') min = '*';
   min = replaceString(min, ','+id+',', '');
   if(min=='') min = '*';
   writePersistentTransientCookie(min_boxes, min);

   if(document.getElementById)
   {
      var t = document.getElementById('tab_'+id);
      t.style.display='block';
      t = document.getElementById('min_head_'+id);
      t.style.display='none';
      t = document.getElementById('max_head_'+id);
      t.style.display='block';
    /*
      t = eval('tdmin_'+id);
      t.style.display='block';
      t = eval('tdmax_'+id);
      t.style.display='none';
      t = eval('hmin_'+id);
      t.style.display='none';
      t = eval('hmax_'+id);
      t.style.display='block';
      */
   }
   else
   {
      setPortalMode('N','*');
      submit();
   }
}

function moveUp(col)
{
   var box = eval('f.col_'+col);
   var selected = new Array();
   var j=0;
   for(i=0; i<box.length; i++)
   {
      if(box.options[i].selected == true)
      {
         if(i==0) break;
         if(i > 0)
         {
            selected[j]=i;
            j++;
         }
      }
   }
   for(j=0 ; j<selected.length ; j++)
   {
      var index = selected[j];
      if( index>0 && index<box.length-1 )
      {
         var tmp = box.options[index-1].text;
         var val = box.options[index-1].value;
         box.options[index-1].text     = box.options[index].text;
         box.options[index-1].value    = box.options[index].value;
         box.options[index].text       = tmp;
         box.options[index].value      = val;
         box.options[index].selected   = false;
         box.options[index-1].selected = true;
      }
   }
}

function moveDown(col)
{
   var box = eval('f.col_'+col);
   var max = box.length-1
   var selected = new Array();
   var j = 0;
   for(i=0; i<max; i++)
   {
      if(box.options[i].selected == true)
      {
         selected[j]=i;
         j++;
      }
   }
   if(selected[j-1] < max-1)
   {
      for(j=selected.length-1; j>=0 ; j--)
      {
         var index = selected[j];
         var max = box.length-1
         if( index < max-1)
         {
            var tmp = box.options[index+1].text;
            var val = box.options[index+1].value;
            box.options[index+1].text     = box.options[index].text;
            box.options[index+1].value    = box.options[index].value;
            box.options[index].text       = tmp;
            box.options[index].value      = val;
            box.options[index].selected   = false;
            box.options[index+1].selected = true;
         }
      }
   }
}

function moveSide(src,dst)
{
   var srcbox = eval('f.col_'+src);
   var selected = new Array();
   var j = 0;
   for(ix=0; ix<srcbox.length-1;)
   {
      if(srcbox.options[ix].selected==true)
      {
         var val = srcbox.options[ix].value;
         var wid = val.substr(0,val.indexOf('.'));
         for(i=dst; i!=src;)
         {
            if(wid <= eval('f.col'+i+'width').value)
            {
               var dstbox = eval('f.col_'+i);
               var tmp = dstbox.options[dstbox.length-1].text;
               dstbox.options[dstbox.length-1].text  = srcbox.options[ix].text;
               dstbox.options[dstbox.length-1].value = val;
               dstbox.options[dstbox.length] = new Option(tmp);
               srcbox.options[ix] = null;
               return;
            }
            else if( dst-src==1 || (src==maxcolno-1 && dst==0) )
            {
               i++;
               if(i==maxcolno) i=0;
            }
            else
            {
               i--;
               if(i<0) i=maxcolno-1;
            }
         }
         ifsAlert(NO_OTHER_COLUMN);
         return;
      }
      else
         ix++;
   }
}

function add()
{
   var srcbox = f.addProvider;
   var selected = new Array();
   var j = 0;
   for(ix=1; ix<srcbox.length; ix++)
   {
      if(srcbox.options[ix].selected == true)
      {
         var val = srcbox.options[ix].value;
         var ind = val.indexOf('.');
         var wid = val.substr(0,ind);
         var cls = val.substr(ind+1);
         for(i=0; i<maxcolno; i++)
         {
            if(wid <= eval('f.col'+i+'width').value)
            {
               var dstbox = eval('f.col_'+i);
               var tmp = dstbox.options[dstbox.length-1].text;
               dstbox.options[dstbox.length-1].text  = srcbox.options[ix].text;
               dstbox.options[dstbox.length-1].value = wid+'.P='+cls;
               dstbox.options[dstbox.length] = new Option(tmp);
               return;
            }
            else if(i==maxcolno-1)
            {
               ifsAlert(WIDE_PORTLET);
               return;
            }
         }
      }
   }
}

function remove(col)
{
   var box = eval('f.col_'+col);
   for(i=0; i<box.length; i++)
   {
      if(box.options[i].selected == true)
      {
         if(i < box.length - 1)
            box.options[i] = null;
      }
   }
}

function replaceString(str, oldstr, newstr)
{
   for(var i=0; i<str.length; i++)
      if( str.substring(i,i+oldstr.length) == oldstr)
         str = str.substring(0,i)+newstr+str.substring(i+oldstr.length,str.length);
   return str;
}

function lovPortal(id,fld,url,title,auto,where,orderby,groupby,width,height)
{
   if(title!='')   url = url + (url.indexOf('?')>0 ? '&' : '?') + "__TITLE="       + URLClientEncode(title);
   if(auto!='')    url = url + (url.indexOf('?')>0 ? '&' : '?') + "__AUTO_SEARCH=" + URLClientEncode(auto);
   if(where!='')   url = url + (url.indexOf('?')>0 ? '&' : '?') + "__WHERE="       + URLClientEncode(where);
   if(orderby!='') url = url + (url.indexOf('?')>0 ? '&' : '?') + "__ORDER_BY="    + URLClientEncode(orderby);
   if(groupby!='') url = url + (url.indexOf('?')>0 ? '&' : '?') + "__GROUP_BY="    + URLClientEncode(groupby);

   __FIELD_NAME = getPortletFieldName(id,fld); 
   openLOVWindow(__FIELD_NAME,-1,url,width,height,'postLOVPortal');
}


function postLOVPortal(no)
{
}

function toUpperCase(obj,id)
{
  obj.value = obj.value.toUpperCase();
}

function toLowerCase(obj,id)
{
  obj.value = obj.value.toLowerCase();
}

//Encodes a string to hex.
//Called by the encodeUnicode() javascript method provided by ASPConfigFile.
function ifsEncode(work, char_count)
{
   var hex = '';
   var num = '';
   var pad = '0000';
   
   if(char_count == 0)
      return work;
   else
      if(char_count*100/work.length < 60)
      {
         for (var i = 0; i < work.length; i++)
         {
            if(work.charCodeAt(i) >  127 || 
               work.charCodeAt(i) == 43  || // + sign
               work.charCodeAt(i) == 39  || // ' sign
               work.charAt(i) == C29     ||
               work.charAt(i) == C30     || 
               work.charAt(i) == C31)
            {
               num = toHexString(work.charCodeAt(i));
               num = C29 + pad.substring(0, 4-num.length) + num;
            }
            else
               num = work.charAt(i);
            hex += num;
         }
         return C29 + hex;
      }
      else
      { 
         for (var i = 0; i < work.length; i++)
         {
            num = toHexString(work.charCodeAt(i));
            hex += pad.substring(0, 4-num.length) + num;
         }
         return C30 + hex;
      }
}

function toHexString(num)
{
   var s='';
   var idx = 0;
   var div = num;

   for( i=0; i<4; i++ )
   {
      if(num > 15)
      {
         div = num / 16;
         mod = num % 16;
         idx = 0;
         idx = new String( div ).indexOf( '.' );
         if( idx != -1 )
            div = new String( div ).substring( 0, idx );
         else
            div = new String( div );
         idx = new String( mod ).indexOf( '.' );
         if( idx != -1 )
            mod = new String( mod ).substring( 0, idx );
         else
            mod = new String( mod );
         s = map[mod] + s;
      }
      else
      {
         s = map[div] + s;
         div='0';
         break;
      }
      num = div;
   }
   return s;
}

//Decodes a hex encoded string.
//Called by the decodeUnicode() javascript method provided by ASPConfigFile.
function ifsDecode(hexarr) 
{  
    var temp = '';
    var work = '';

    if(hexarr.charAt(0) == C29)
    {
       for(var r=1; r < hexarr.length; r++)
       {
          if(hexarr.charAt(r) == C29)
          {
             r++ ;
             temp = String.fromCharCode(getIntValue(hexarr.substring(r, r+4)));
             r += 3;
          }
          else
             temp = hexarr.charAt(r);
          work += temp;
       }
    }
    else
       if(hexarr.charAt(0) == C30)
       {
          for(var r=1; r < hexarr.length; r++)
          {
             temp = String.fromCharCode(getIntValue(hexarr.substring(r, r+4)));
             r += 3;
             work += temp;
          }
       }
    else
       work = hexarr;
    return work;
}

function getIntValue(hex)
{
    var pos;
    var val=0;
    var expo=hex.length-1;

    for( n=0; n < hex.length; n++ )
    {
       pos = 0;
       while( hex.charAt(n) != map[pos])
            pos++;
       val += _16toPower(expo) * pos;
       expo--;
    }
   return val;
}

function _16toPower(exp)
{
  if (exp == 0)
    return 1;
  return 16 * _16toPower( exp-1 );
}

function removePageMask()
{
   if (document.getElementById && document.getElementById('hidepage')) //IE5, NS6
      document.getElementById('hidepage').style.visibility= 'hidden';
   else if (document.layers && document.hidepage)                      // Netscape
      document.hidepage.visibility = 'hidden';
}

function applyPageMask()
{
   if (document.getElementById && document.getElementById('hidepage')) //IE5, NS6
      document.getElementById('hidepage').style.visibility= 'visible';
   else if (document.layers && document.hidepage)                      // Netscape
      document.hidepage.visibility = 'visible';
}

function OnFocus()
{
   if (LOV_ALWAYS_ON_TOP && lov_window)
   {
         if(lov_window.focus && !IS_EXPLORER) // Netscape 4.0+ & NS6
            lov_window.focus();
         else if(IS_EXPLORER && !lov_closed){ //IE 5.0+ 
            lov_window.events=null;
            lov_window.events=null;
            lov_window.focus();
         }
   }
   
   if (calendar_window)
   {
       calendar_window.close();
       calendar_window = null;
   }
}

function OnUnLoad()
{
   if(LOV_ALWAYS_ON_TOP)
   {
     if(opener)
     {
        if(document.getElementById)
           eval("try{opener.lov_closed=true;} catch(e){}");
        else
           opener.lov_closed=true;
     }
     else if(lov_window)
     {
        lov_window.close();
        lov_window = null;
     }
   }
}

//Appends an ID to a given URL. If the URL is having a query string
//the ID will be placed inbetween the URL & the query string.
function correctURL(url)
{
   if(BROWSER_CACHE_DISABLED)
   {

       page_index = url.indexOf(".page");
       if (page_index < 1) 
          return url;
       page_last_index = page_index + 5;
       if (url.indexOf('?')==-1)
          return url.substring(0,page_last_index) +'?__ID='+Math.round(Math.random()*1000000) + (page_last_index<url.length ? url.substring(page_last_index):"");

       /*if (url.indexOf('?')==-1)
          return url+'?__ID='+Math.round(Math.random()*1000000);*/
       else if (url.indexOf('&__ID')!=-1){
          link = url.substring(0,url.indexOf('?'));
          qrystr = '';
          if (url.indexOf('&')!=-1 && 
              url.indexOf('?') == url.lastIndexOf('?') &&
              url.indexOf('&')<=url.indexOf('&__ID'))
                 qrystr = "&"+url.substring(url.indexOf('?')+1,url.indexOf('&__ID'));
                 return link+'?__ID='+Math.round(Math.random()*1000000)+qrystr;
       } else if (url.indexOf('?')!=-1 && 
                  url.lastIndexOf('?')+1!=url.length && 
                  url.indexOf('?') == url.lastIndexOf('?') &&
                  url.indexOf('?__ID')==-1) {
          link = url.substring(0,url.indexOf("?"));
          qrystr = '&'+url.substring(url.indexOf('?')+1,url.length);
          return link+'?__ID='+Math.round(Math.random()*1000000)+qrystr;
       }
       else {
          link = url.substring(0,url.indexOf('?'));
          qrystr = '';
          if (url.indexOf('&')!=-1)
             qrystr = '&'+url.substring(url.indexOf('&')+1,url.length);
          return url.substring(0,url.indexOf('?'))+'?__ID='+Math.round(Math.random()*1000000)+qrystr;
       }
   }
   else
      return url;
}
function showtip(current,e,tip)
{
   if (document.getElementById) { // Netscape 6.0+ and IE 5.0+
      elm=document.getElementById("tooltip")
      elml=current
      elm.innerHTML=tip
      elm.style.height=elml.style.height
      if (window.innerHeight)     //Netscape 6.0+ 
      {
         elm.style.top  = e.clientY+window.pageYOffset-10;
         elm.style.left = e.clientX+window.pageXOffset+10;
      }
      else if (document.body)     //IE 5.0+
      {
         elm.style.top  = e.clientY+document.body.scrollTop-10;
         elm.style.left = e.clientX+document.body.scrollLeft+10;
      }
      elm.style.visibility = "visible"
   }
}

function hidetip()
{
   if (document.getElementById) // Netscape 6.0+ and IE 5.0+
      elm.style.visibility="hidden" 
}


function CCA_All()
{
    for(i=0;i<f.elements.length;i++)
    {
//       alert(f.elements[i].type+" "+f.elements[i].name+" "+f.elements[i].Value);
       if (f.elements[i].type=="checkbox" && f.elements[i].name.substring(0,10)=="__SELECTED" )
       {
          CCA(f.elements[i]);
       }
    }
}


function CCA(CB)
{
    cca = true;
    if (CB.checked)
        highLight(CB);
    else
        downLight(CB);
}

function highLight(Elmt)
{
   if (document.getElementById) 
   {
       while (Elmt.tagName!="TR")
       {
           if(IS_EXPLORER)
              Elmt=Elmt.parentElement;
           else
              Elmt=Elmt.parentNode;
   
       }
       Elmt.className = "H";
   }
}

function downLight(Elmt)
{
   if (document.getElementById) 
   {
      while (Elmt.tagName!="TR")
      {
         if(IS_EXPLORER)
            Elmt=Elmt.parentElement;
         else
            Elmt=Elmt.parentNode;
      }
      Elmt.className = "";
   }
}

function URLClientEncode(s)
{ 
   s = encodeUnicode(s);
   s = s.replace( /\+/gi , "%2B");
   s = s.replace( /\@/gi , "%40");
   s = s.replace( /\\/gi , "%5C");
   return s;
} 

  function SelectURLClientEncode(s,i)
{
   
   if(getField_(s,i).options)
      __selurl=getField_(s,i).options[getField_(s,i).selectedIndex].value;
   else   
   {
      __selurl=getField_(s,i).value;
   }
   return URLClientEncode(__selurl);
}

function encodeUnicode(s){
   if(s == null)
      return s;
   else
      s = s + '';
   var char_count=0;
   for(var i = 0; i < s.length; i++)
      if(s.charCodeAt(i)>127  ||
         s.charCodeAt(i) == 43|| // + sign
         s.charCodeAt(i)==39  || // ' sign
         s.charAt(i) == C29   ||
         s.charAt(i) == C30   ||
         s.charAt(i) == C31)
            char_count++;
   if (BASE64_ENABLED) 
   {
      if(char_count*100/s.length > 60 && s.length > 5 )
         s = document.applets[0].ifsEncode(s);
      else
         s = ifsEncode(s,char_count);
   }
   else  
      s = ifsEncode(s,char_count);
   return escape(s);
}

function decodeUnicode(enc){
   if(enc == null)
      return enc;
   else
      enc = enc + '';
   enc = unescape(enc);
   if (BASE64_ENABLED) {
        if(enc.charCodeAt(0)==31)
            enc = document.applets[0].ifsDecode(enc);
        else
            enc = ifsDecode(enc);
   }
   else  
       enc = ifsDecode(enc);
   //enc = ifsDecode(enc);
   return enc;
}

function showMenu(obj, lines,submenu)
{
   if(document.getElementById)
      showMenu_(obj, lines,submenu);
   else
      showMenuNav4_(obj, lines,submenu);
}
   
function showMenu_(obj, lines,submenu)
{
   var visible_lines = 1;
   for(x = 0;x<=lines.length-1;x++)
   {
      if(lines[x] == true)
         visible_lines = visible_lines + 1;
   }
   var h = visible_lines * 18;
   
   if(IS_EXPLORER){
      var x = document.body.scrollLeft + mouseX;
      var y = document.body.scrollTop + mouseY;
   }
   else{
      var x = mouseX;
      var y = mouseY;
   }

   if(IS_EXPLORER)
   {
      if((y + h - document.body.scrollTop) > document.body.clientHeight)
      {
        if(!submenu && _new_x != 0)
          _new_y = document.body.clientHeight + document.body.scrollTop - h;
        else
          y = y - (y + h - document.body.clientHeight) + document.body.scrollTop;
      }
   }
   else
   {
      if(!submenu && _new_x != 0)
         _new_y = _new_y;
      else
         y = mouseY;
   }

   if(y<0)
      y = 0;
   if(submenu) {
      _submenus[_submenus.length] = document.getElementById(obj);
      x = parseInt(_current_menu.style.left) + parseInt(_current_menu.style.width);
   }
   _current_menu = document.getElementById(obj);
   
   if(IS_EXPLORER)
   {
      if((x + MAX_MENU_WIDTH) > document.body.clientWidth)
      {
         x = (x - MAX_MENU_WIDTH*2)+1;
         dir_changed = true;
      }
      else
      {
         dir_changed = false;
         x = x -1;
      }
   }
   else
   {
      if((x + MAX_MENU_WIDTH) > window.innerWidth)
      {
         x = (x - MAX_MENU_WIDTH*2)+1;   
         dir_changed = true;
      }
      else
      {
         dir_changed = false;
         x = x -1;
      }
   }
   
   if(!submenu && _new_x != 0)
   {  
      document.getElementById(obj).style.left = _new_x;
      document.getElementById(obj).style.top = _new_y;
   }
   else
   {
      document.getElementById(obj).style.left = x;
      document.getElementById(obj).style.top = y;
   }

   _new_x=0;
   _new_y=0;

   document.getElementById(obj).style.visibility = "visible";
   
   for(x = 0;x<=lines.length-1;x++)
   {
      _line = document.getElementById(obj+x);
      if(lines[x] == true)
      {
         //Bug 42727, start
         //Bug 42691, start
         //Bug 40925, start
         if(_line.style.display != "block" )
         //Bug 40925, end
         //Bug 42691, end
         //Bug 42727, end
            _line.style.display = "block";
      }
      else
          _line.style.display = "none";
   }
}

function showMenuNav4_(obj, lines,submenu)
{
   var isNav6 = document.getElementById;
   _hide_menus = false;
   if(lines == null)
      return;
   var visible_lines = 1;

   for(x=0;x<lines.length;x++)
   {
      if(lines[x])
          visible_lines = visible_lines + 1;
   }

   var h = visible_lines * 12;
   var y = mouseY;

   if((y + h - window.pageYOffset) > window.innerHeight)
      y = y - (y + h - window.innerHeight) + window.pageYOffset;
   if(y<0)
      y = 0;

   theX = mouseX;

   if(submenu)
      if(isNav6)
         theX = parseInt(document.getElementById(_last_menu + 'Start').style.left) + eval(_last_menu + 'Width') + 1;
      else
         theX = document.layers[_last_menu + 'Start'].left + eval(_last_menu + 'Width') + 1;
   else
   {
       _last_menu = obj;
       hideMenus();
   }

   if((theX + 100 + window.pageXOffset) > window.innerWidth)
      theX = theX - 100;

   if(!isNav6)
   {
      _obj0 = document.layers[obj + '0'];
      _objStart = document.layers[obj + 'Start'];
   }
   else
   {
      _obj0 = document.getElementById(obj + '0').style;
      _objStart = document.getElementById(obj + 'Start').style;
   }

   _obj0.top = y;
   _obj0.left = theX;
   _objStart.top = y - 1;
   _objStart.left = theX;
   _objStart.visibility = (isNav6)?'visible':'show';

   currentY = y;

   if(submenu)
   {
      if(!isNav6)
      {
         _submenus[_submenus.length] = document.layers[obj + 'Start'];
         _submenus[_submenus.length] = document.layers[obj + 'End'];
      }
      else
      {
         _submenus[_submenus.length] = document.getElementById(obj + 'Start').style;
         _submenus[_submenus.length] = document.getElementById(obj + 'End').style;
      }
   }

   if(!isNav6)
      myh=document.layers[obj + '0'].clip.height;
   else
      myh=parseInt(document.defaultView.getComputedStyle(document.getElementById(obj + '0'),"").getPropertyValue("height"));

   for(x=0;x<lines.length;x++)
   {
      _obj = (isNav6)?document.getElementById(obj + x).style:document.layers[obj + x];

      if(submenu)
         _submenus[_submenus.length] = _obj;

      if(lines[x])
      {
         _obj.visibility=(isNav6)?'visible':'show';
         _obj.top = currentY;
         _obj.left = theX;
         _obj.width = 200;
         currentY = currentY + myh;
      }
      else
      {
         _obj.visibility="hide";
      }
   }

   if(!isNav6)
   {
      _obj = document.layers[obj + 'End'];
   }
   else
   {
      _obj = document.getElementById(obj + 'End').style;
   }

   _obj.top = currentY;
   _obj.left = theX;
   _obj.visibility=(isNav6)?'visible':'show';

}


function _menu(sub)
{
   if(document.getElementById)
   {
   
      if(document.getElementById(sub))
         hideSubmenus(document.getElementById(sub).style.left);
      else
          hideSubmenus(0);
      if(sub != 0) 
      {
         _handle_menus = true;
         _current_menu = document.getElementById(sub);
      }
   }
   else
   {
      if(sub != 0) 
      {
         _hide_menus = false;
         hideSubmenus(document.layers[sub + 'Start'].left);
         _last_menu = sub;
      }
   }
}


function mousePressed(e)
{
   setTimeout("updateMenus()",100);
}

function updateMenus()
{
   if(_hide_menus)
      hideMenus();
   _hide_menus = true;
}


function hideSubmenus(pos)
{
   pos = pos+'';
   if (pos.indexOf('px')!=-1)
      pos = pos.substring(0,pos.indexOf('px'));
   
   if(document.getElementById)
   {
      for(_i=0;_i<_submenus.length;_i++) 
      {
         xpos = _submenus[_i].style.left;
         if (xpos.indexOf('px')!=-1)
            xpos = xpos.substring(0,xpos.indexOf('px'));
         
         a = new Number(xpos);
         b = new Number(pos);

         if(dir_changed)
         {
           if(a < b )
               _submenus[_i].style.visibility = "hidden";
         }
         else
         {
            if(a > b )
               _submenus[_i].style.visibility = "hidden";
         }
      }
   }
   else
   {
      for(_i=0;_i<_submenus.length;_i++)
         if(_submenus[_i].left > pos)
             _submenus[_i].visibility = "hidden";
   }
}

function selectAllRows(s)
{
   t = eval("f."+s);
   if(t.length)
   {
       for (i=0;i<t.length;i++)
       {
          t[i].checked = true;
          CCA(t[i]);
       }
   }
   else
   {
       t.checked = true;
       CCA(t);
   }
}

function deselectAllRows(s)
{
   t = eval("f."+s);
   if(t.length)
   {
       for(i=0;i<t.length;i++)
       {
          t[i].checked = false;
          CCA(t[i]);
       }
   }
   else
   {
       t.checked = false;
       CCA(t);
   }
}

function invertselection(s)
{
   t = eval("f."+s);
   if(t.length)
   {
       for(i=0;i<t.length;i++)
       {
          if (t[i].checked)
             t[i].checked = false;
          else
             t[i].checked = true;
          CCA(t[i]);
       }
   }
   else
   {
       if (t.checked)
          t.checked = false;
       else
          t.checked = true;
       CCA(t);
   }
}

function removePercentage(num1)
{
  //removes any % characters
  if(num1.indexOf('%')!=-1)
  {
     n = num1.split('%');
     n1='';
     for(i=0;i<n.length;i++)
        n1 += n[i]; 
     num1 = n1;
  }
  return num1;
} 

function formatNumber_(num)
{
  //removes the group separator
  var p1='';
  if(num.indexOf(DECIMAL_SEPARATOR)!=-1)
  {
     p1 = num.substring(0,num.indexOf(DECIMAL_SEPARATOR));
     p3 = num.substring(num.indexOf(DECIMAL_SEPARATOR)+1,num.length);
     p2 = p1.split(GROUP_SEPARATOR);
     p1='';
     for(i=0;i<p2.length;i++)
        p1 += p2[i]; 
     p1 = p1 +'.'+p3;
  }
  else if (num.indexOf(GROUP_SEPARATOR)!=-1)
  {
     var p2 = num.split(GROUP_SEPARATOR);
     p1='';
     for(i=0;i<p2.length;i++)
        p1 += p2[i]; 
  }
  else
     p1 = num;  
  
  return p1;
}

function checkNumberValue_(field,label,msg)
{
    x = new Number(formatNumber_(removePercentage(field.value)));
    if (isNaN(x))
        return invalidNumberError_(field,label,msg);

    return true;
}


function invalidNumberError_(field,label,msg)
{
    if( msg == '' )
      ifsAlert(INVNUMVAL_MSG + label + ']');
    else
      ifsAlert(msg);
    // Bug 46227, start
    fld = field;
    setTimeout('fld.focus()',1);
    // Bug 46227, end
    return false;
}

function getAllSelectedValues()
{
    checkbox_array = f.__SELECTED;
    str = "";
    if(checkbox_array != null)
    {
        size = checkbox_array.length;
    
        for (i=0;i<size; i++)
        {
            if (checkbox_array[i].checked)
                str += (str==""?"":";")+checkbox_array[i].value;
        }
    }
    setValue(str);
}


function deleteQuery(cmd)
{
    if (f.__SAVED_QUERY.selectedIndex > 1)
    {
        f.__QUERY_INDEX.value = f.__SAVED_QUERY.selectedIndex -1;
        commandSet(cmd,'');
    }
}


function saveQuery(value)
{
    f.__QUERY_NAME.value = value;

    if (f.__SAVED_QUERY.options[1].text == value)
    {
        alert(PREVIOUSQUERYNAME_MSG);
    }
    else if (queryExists(value) && !confirm(EXISTINGQUERYNAME_MSG))
    {
        f.__QUERY_NAME.value = '';
        return;

    }
    else
        commandSet(action,'');
}

function queryExists(value)
{
    for (i=2; i<f.__SAVED_QUERY.length; i++)
    {
        if (f.__SAVED_QUERY.options[i].text == value)
            return true
    }
    
    return false
}


function openSaveQueryDlg(cmd,link)
{
     action = cmd;

     if (f.__SAVED_QUERY.selectedIndex > 1)
         f.__QUERY_NAME.value = URLClientEncode(f.__SAVED_QUERY.options[f.__SAVED_QUERY.selectedIndex].text);
     else
         f.__QUERY_NAME.value = '';

     ind = link.indexOf('?');
     if (ind > 0)
         url = link.substring(0,ind) + "?QUERY_NAME=" +f.__QUERY_NAME.value +"&"+ link.substring(ind+1,link.length);
     else
         url = link + "?QUERY_NAME=" +f.__QUERY_NAME.value;

     window.open(url,'NEWWIN',"width=300,height=170,left=200,top=250 resizable=yes").focus();  
}

function populateFields()
{
    clearAllQueryFields();

    if (f.__SAVED_QUERY.selectedIndex ==0) return;

    selected_value = f.__SAVED_QUERY.options[f.__SAVED_QUERY.selectedIndex].value;

    if (selected_value == "__EMPTY")
        selected_value = f.__SAVED_QUERY.options[0].value;

    value_array = selected_value.split(C31);

    size = value_array.length;

    for (i=0; i<size-1; i++)
    {
        row_val = value_array[i].split("^");
        eval("fld = f."+ row_val[0]);
        
        if (fld)
        {
            fld.value = row_val[1];

            if ( i == 0)
                (fld.value == 'Y')? f.__CASESS.checked = true : f.__CASESS.checked = false;
        }
    }
}


function clearAllQueryFields()
{
    var selected_value = f.__SAVED_QUERY.options[0].value;
    var value_array = selected_value.split(C31);
    var size = value_array.length;

    for (i=0; i<size-1; i++)
    {
        row_val = value_array[i].split("^");
        eval("fld = f."+ row_val[0]);
        
        if (fld)
        {
            fld.value = "";

            if ( i == 0)
                (row_val[1] == 'Y')? f.__CASESS.checked = true : f.__CASESS.checked = false;

        }

    }
}


function keyPressed(e) 
{  
   targ = null;

   if(IS_EXPLORER)
       key = window.event.keyCode;
   else
       key = e.which;

   for(i = 0;i<document.links.length;i++)
   {
     if (!e) var e = window.event;
     if (e && e.target) targ = e.target;
      
     else if (e && e.srcElement) targ = e.srcElement;
      
     if(targ!=null && document.links[i].href == targ)
          return;
   }
   
   if (default_command==true)
   { 
      if(targ && targ.name && key==13)
      {
         fld = getField2_(targ.name);
         if(fld && fld.onchange)
            fld.onchange();
      }
      executeCommand(e);
   }
}


function rowClicked(elm,box,i)
{
   if(!cca)
   {
      if(box!=null)
      {
         if(box.length>1)
           row = box[i];
         else
           row = box;
         if(row.checked)
         {
            row.checked=false;
            CCA(row);
         }
         else
         {
            row.checked=true;
            CCA(row);
         }
      }
      else
      {
         clearAllRows(elm);
         if(elm.className == '')
            elm.className='H';
         else
            elm.className='';
      }
  }
  cca = false;
}

function clearAllRows(tr)
{
    if(document.getElementById)
    {
        rows=f.getElementsByTagName("tr");
        for(i=0; i<rows.length; i++)
         rows[i].className='';
    }
}

 var last_response_script;
 var found;
 var iframeloaded = false;

function setiframeloaded()
{
   iframeloaded = true;
}

//Bug 42299, start
function __connect(url)
{
    var res = '';
    last_response_script= '';

    if(VALIDATION_METHOD == 'APPLET')                // Applet(IE, Netscape7.x and Netscape 4.x)
    {
        res = __connectURL(url,true);
        return res;
    }
    else                                           // ActiveX(IE), Script(Netscape7.x) and IFrame(IE)
    {   
        res = __connectURL(url,false);
        
        FNDERRMSG_BEGIN = "<FNDERRMSG>";
        FNDERRMSG_END   = "</FNDERRMSG>";

        if(res.indexOf("MTS_Exception: ")== 0)
           return "E"+ res;
        if(res.indexOf("No_Data_Found")== 0)
           return "F" + (res.length==13? "" : res.substring(13));
        
        fnd0 = res.indexOf(FNDERRMSG_BEGIN);

        if(fnd0 > 0)
        {
           fnd1 = res.indexOf(FNDERRMSG_END);
           if(fnd1 > fnd0)
              return "F" + res.substring( fnd0+FNDERRMSG_BEGIN.length, fnd1 );
        } 

        if(VALIDATION_METHOD == 'IFRAME') // IE only
        {
            if(iframeloaded)
               iframeloaded = false;
            else
            {
               //Bug 42997, start
               //window.frames.__CUIF.location.replace("");
               //Bug 42997, end
               return "E"+VALIDATE_TIME_OUT_MSG;
            }
        }
        
        addToVector(res);
        return " "+res;
    }
}
//Bug 42299, end

function pause(numberMillis)
{
   var dialogScript = 
       'window.setTimeout(' +
       ' function () { window.close(); }, ' + numberMillis + ');';
    var result = 
    window.showModalDialog(
    'javascript:document.writeln(' +
    '"<script>' + dialogScript + '<' + '/script>")');
}

function addToVector(s)
{
  last_response_script = s.split('^');
} 


function __getValidateValue(index)
{
   //Bug 42299, start
   if(VALIDATION_METHOD=='APPLET')
   {
      if(document.getElementById)
         return document.ClientUtil.getValue(index);
      else
         return document.applets[0].getValue(index);
   }
   //Bug 42299, end
   else
      return last_response_script[index];
}     

function __lookup(url, datasource, attrlist, restriclist, orderby)
{
   return __connect( url +
               "VALIDATE=Y&DATA_SOURCE="    + (datasource==null?"":datasource)  +
               "&ATTR_LIST="     + (attrlist==null?"":attrlist)    +
               "&RESTRICT_LIST=" + (restriclist==null?"":restriclist) +
               "&ORDER_BY="      + (orderby==null?"":orderby));
}

function HTMLDecode(text)
{
     
   htmlbuf = "";  
   if (text=="")
      return text;
   
   len = text.length;
   for (i=0; i<len; i++ )
   {
      ch = text.charAt(i);
      if ( ch=='&' )
      {
         if ( i<len-3 )
         {
            ch1 = text.charAt(i+1);
            ch2 = text.charAt(i+2);
            ch3 = text.charAt(i+3);

            if ( ch3==';' )
            {
               if ( ch1=='l' && ch2=='t' )
               {
                  htmlbuf = htmlbuf.concat('<');
                  i = i+3;
                  continue;
               }
               else if ( ch1=='g' && ch2=='t' )
               {
                  htmlbuf = htmlbuf.concat('>');
                  i = i+3;
                  continue;
               }
           }
           else if ( i<len-4 )
           {
              ch4 = text.charAt(i+4);
              if ( ch1=='a' && ch2=='m' && ch3=='p' && ch4==';' )
              {
                 htmlbuf = htmlbuf.concat('&');
                 i = i+4;
                 continue;
              }
              else if ( i<len-5 && ch1=='q' && ch2=='u' && ch3=='o' && ch4=='t' && text.charAt(i+5)==';' )
              {
                 htmlbuf = htmlbuf.concat('"');
                 i = i+5;
                 continue;
              }
           }
        }
     }
     htmlbuf = htmlbuf.concat(ch);
  }
  return htmlbuf;
} 

function ifsAlert(msg)
{
    if(MESSAGE_PAGE_PATH != null)
    {
        j = msg.indexOf(C31)
        if(j>0)
        {
            err_msg = msg.substring(0,j);
            info_msg = msg.substring(j);
        }
        else
        {               
            err_msg = msg;
            info_msg = "";
        }
        lines = err_msg.split("\n");
        formatted_msg = '';
        ext_lines = lines.length;
        longest_line_lenght =0; 
        for(i=0;i<lines.length;i++)
        {
           formatted_msg+=lines[i]+'<br>'
           if(lines[i].length > longest_line_lenght)
              longest_line_lenght = lines[i].length;
        }
        
        width=0;
        height=0;
        
        if(msg.length<75)
        {  
           width = (formatted_msg.length*6)+30;
           height = 120+((((formatted_msg.length-75)/75)+ext_lines)*5);
        }
        else
        {
            width = (longest_line_lenght*6)+30;
            height = 120+((((formatted_msg.length-75)/75)+ext_lines)*5);    
        }
        formatted_msg = formatted_msg + info_msg;
        if(IS_EXPLORER)
        {
            vReturnValue = window.showModalDialog(MESSAGE_PAGE_PATH,formatted_msg,"dialogHeight:"+height+"px;dialogWidth:"+width+"px;help:no;scroll:no;status:no");
        }
        else
        {
            height =height + 20;
            xpos =  parseInt((screen.width-width)/2);
            ypos =  parseInt((screen.height-height)/2);
            window.open(MESSAGE_PAGE_PATH+"?MSG="+escape(formatted_msg),'msg','status=no,scrollbars=no,'+DEPENDENT+'width='+width+',height='+height+',screenx='+xpos+',screeny='+ypos);
        }
    }
    else
       alert(msg);
}

function msgLoad()
{
    window.focus();
    if(document.getElementById)
       document.getElementById("MSG_OK").focus();
    else
       document.message.MSG_OK.focus();
}

function msgUnLoad(){}

function submitHandlerNS6()
{
    is_submit='true';
}

function menuClicked(item)
{
   _new_x = getX(item);
   _new_y = getY(item)+item.height+1;
    
   if(IS_EXPLORER)
   {
      if((_new_x + MAX_MENU_WIDTH) > document.body.clientWidth)
        _new_x = document.body.clientWidth - MAX_MENU_WIDTH - 1;
   }
   else
   {
       if((_new_x + MAX_MENU_WIDTH) > window.innerWidth)
         _new_x = window.innerWidth - MAX_MENU_WIDTH - 1;
   }
}

function getX(obj)
{
  return( obj.offsetParent==null ? obj.offsetLeft : obj.offsetLeft+getX(obj.offsetParent) );
}

function getY(obj)
{
  return( obj.offsetParent==null ? obj.offsetTop : obj.offsetTop+getY(obj.offsetParent) );
}


function LTrim(str)
{
   var st=0;
   var s = new String(str);
   var len = s.length;
   while((st<len) && (s.charAt(st)<=' '))
   {
       st++;
   }
   return (st>0)? s.substring(st,len):s;
}

function RTrim(str)
{
   var s = new String(str);
   var st = s.length;
   while((st>0) && (s.charAt(st-1)<=' '))
   {
       st--;
   }
   return (st<s.length)? s.substring(0,st):s;
}

function Trim(str)
{
   return RTrim(LTrim(str));
}

function sbumenuDummy(grp_name){}

//Bug 41996, start
//Bug 42299, start
function __connectURL(url,connect)
{
    var res ='';

    //Appends 'VALIDATE=Y' to the querystring if not present.
    if(url.indexOf('?') == -1)
       url = url + '?VALIDATE=Y';
    else if(url.indexOf('VALIDATE=') == -1)
    {
       if(url.indexOf('?') == url.length-1)
          url = url + 'VALIDATE=Y';
       else if(url.lastIndexOf('&') == url.length-1)
          url = url + 'VALIDATE=Y'; 
       else
          url = url + '&VALIDATE=Y'; 
    }

    //Bug 40903, start
	if (url.indexOf('__PAGE_ID')>0) 
	   url = url + '&__CONTEXT_ID='+window.name;
    //Bug 40903, end

    if(VALIDATION_METHOD == 'ACTIVEX')     // IE only
    {
	   //Bug 43673, start
	   url = correctURL(url);
	   //Bug 43673, end
       var req = new ActiveXObject("Microsoft.XMLHTTP");
       req.Open( "GET", url, false );
       req.Send();
       res = req.responseText;
    }
    else if(VALIDATION_METHOD == 'IFRAME') // IE only
    {
       //Bug 42662, start
       while(url.indexOf("&REG") != -1)
       {
          url = url.replace("&REG","&__REG");
       }
       //Bug 42662, end

       //Bug 42997, start
       //window.frames.__CUIF.location.replace("");
       //Bug 42997, end
       window.frames.__CUIF.location.replace(url);

       for (var i=1;i<=(parseInt(VALIDATION_TIMEOUT_TIME)*2);i++)
       {
           pause(500);
           if(!iframeloaded)
              continue;
           res = __ClientUtilIFrame.document.ifform.iftxt.value; 
           res =  res.substring(4,res.lastIndexOf('-->')); 
           break;
       }
    }
    else if(VALIDATION_METHOD == 'SCRIPT') // Netscape7x only
    {
       var req = new XMLHttpRequest();
       req.open("GET", url, false);
       req.send(null);
       res = req.responseText;
    }
    else   //VALIDATION_METHOD == 'APPLET'  - IE, Netscape7x and Netscape4x
    {
       if(connect)
       {
          if(document.getElementById)
             res = document.ClientUtil.connect(url);
          else
             res = document.applets[0].connect(url);
       }
       else
       {
          if(document.getElementById)
             res = document.ClientUtil.connectURL(url);
          else
             res = document.applets[0].connectURL(url);
       }
       if(res)
          res = new String(res.toString());
       else
          res = '';
    }
    
    if(res)
       return res;
    else
       return '';
}
//Bug 42299, end
//Bug 41996, end
