/*************************************************************************************************************
application.js

application specific javascript functions

   
how to use:
===========
include this script in the page (after the enformisUtils):
      <!-- application specific script. instanciate a window level object enApplication-->
      &lt;script language="JavaScript" type="text/javascript"
         src="../Static/Include/application.js"&gt;&lt;/script&gt;

the script will create an object named enApplication (or window.enApplication)
   all functions are the object's methods result=enApplication.fnName();

enApplication Properties
=========================
global            an object to hold custom data for the application usage
   .URLs            an object with url names to be used in js.
                  values should be set in the page header
      .home         home url
      .login         login page
   .mainFocusInUse      weather main focus iframe is being used
   .mainFocusVisible   weather main focus iframe is currently visible
   .mainFocusResPos   restore position of main focus
   .mainFocusResState   restore state (max / res)
   .zfMainArray      array that contain the new order of the components
   .zfHideCells      string that contain the items that should be hide
   .currentPageName   page name, set in header
   .defaultPageName   default page name
   .isHomePage         is this page a home page?
   .currentSkinName   skin name, set in header
   .linkManagePageMethod    method to open page management screen (page name - popup, mainfocus, or empty)
   .baseUrl         base url to use in getBaseUrl
   .enSrcElmntToMove   the element that the moveCells menu will open from
   .moveCellsFlag      flag that check if was movement
   .moveCellsMenuHeight contain the move cells menu height 
   .pagePrefrencesUrl   contain the url that the prefrebces popup will be open   
   .currentScrollPos   current scroling position
   .useProgressBar      use progress bar with hidden execution
   .disableButtonOnExecute - disable buttons on execution
   .disableButtonList   - list of buttons to disable
   .progressBarVars   object to hold: 
                  progressLength (no of dbl lines); progressAt (lines counter); progressId (window interval id)
   .dirtyFlag          flag that sign if we should save personalization to DB.
   .confirmAutoRefresh confirm with user before auto reloading the window
   .autoRefreshRate   no of miliseconds for refresh
   .mapZonesToCells   an array to map zone names to cell ids on the page
   .mapComponentsToCells   an array to map component names to cell ids on the page
   .isRTL            is page direction RTL 
   .charset         client charset in use
   
   .defaultHelpFile    default help file for the current page
   .specificHelpFile    specific help file for the current page (comes from zone..)
   .isMainFocus      is the window in main focus?
   .supportsMainFocus   does the current page supports main focus?
   .mainFocusHeight   height of
   .mainFocusIsRelative use relative height (true/false)
   
   .sendToFriend      allow send to friend
   .sendToFriendComp    allow send component to friend
   
enApplication functions
=========================
(name)               (description)
-------------------------------------------------------------
general
-------------------------------------------------------------
favsPromptTitle         prompt user for favs title
runAppFile            run client side application using ENLauncher(ActivX)
filterZoneObjects      filter zone objects view
filterZoneNotifObjects    filter zone objects view by notifications
linkManageCurrPage       link to current page management
reloadNotifsCell      reload notifd component cell
reloadOnComboChange    reload on combo change
backupScrollPos        save current scrolling position in global.currentScrollPos
restoreScrollPos       sets current scrolling position
getSkinImgPath         builds the path to an image based on the current skin
alertNotLoginAndClose   give alert and closing the window
confirmAndRefresh       confirm user and refresh window
setAutoRefreshTimeout   set window timeout to refresh page
setAutoRefreshCellInterval set window timeout to refresh cell
setDisableButtonList   set list of buttons to disable on execution
getBaseUrl             get base url (application root)

-------------------------------------------------------------
   online help
-------------------------------------------------------------
openPopUpHelp         open a window with online help
cancelIEHelp          cancel IE help event
getHelpOnF1            open help on F1

-------------------------------------------------------------
floating Ifreame functions
-------------------------------------------------------------

general
-----------
   closeWindowOrFloatingIfrOnEsc    close window or floating frame
   closeAllFloatingIfrs         close all iframes (called from document click)
   countAllFloatingIfrs         count all open iframes
   closeAllFloatingIfrsOnEsc      close all the iframes when press Esc (called from docuemnt.keyup)
   

sort Table
------------   
   sortTableMarkCell            sign or unsign the cell onmouseover or onmouseout
   
color picker
-------------
   showColorPicker         Build a color Picker
   hideColorPicker         Hiding the color picker
   hideColorPickerOnEsc    hide color picker on escape press
   showColorPickerCbfn    call back function to be called from the color picker

Tool tip
------------
   showToolTip            show tool tip onMouseOver
   hideToolTip            hide tool tip onMoseOut   

Move Cells
------------
   setUserCellsOrder      build a array that contain all the data about the new order
                     of the cells.
   saveUserCellsOrder      save the new order of the components
   imgMoveClick         move the components
   moveCellsCbfn         check if the update is Done.
   showOrHideCell         show or hide cells
   moveCellsCreateHtml      create the HTML that will build the move cells menu
   canMoveTd            checks to what directions the td can be moved
-------------------------------------------------------------
Home page components
-------------------------------------------------------------
showMoveCellsPopup         show Move Cells board
hideMoveCellsPopup         hide Move Cells board
moveTd                  Move the cells
switchTd               this function gets the td to move and the basic movement: R,L,U,D.
showMainFocus            shows the main div 'divMainFocus' according to a base elmnt (embeded in HomePage)
hideMainFocus            hides the main div 'divMainFocus'
setMainFocusIntIfrSize       set internal iframe element size
toggleMainFocusVisibility   show or hide main focus
setMainFocusTitle         set the title of the main focus floating frame
toggleMainFocusMaxRes       toggle main focus max / restore
maxMainFocus             maximize main focus
restoreMainFocus          restore main focus
toggleCellMinRes         toggle cell min / restore
printCell               print an individual cell
getCellsByZone            return a comma separated list of cell ids for a given zone name
getCellsByComponent            return a comma separated list of cell ids for a given component name
reloadCell               reload a cell
reloadCellCallBack         reload call back
reloadHomePageCompByZone   reload home page component by zone name
openSendToFriend         send page tp a friend

-------------------------------------------------------------
Hirarchic tree
-------------------------------------------------------------
treeNodeClick         change look for picked and put its system name & title in a window variable 
elmntExpandOrCollapseTree open or close all the levels on tree
elmntToggleShowHide      show or hide next level of tree and change icon fron '+' to '-'
                  or from '-' to '+'
reloadChildrenNodes      insert next level nodes
ENUITree methods
------------------------
getENUITreeNode         retrievs an object reresenting a node
getENUITreeRootNode      get the tree root node treNode object
pickENUITreeNode      default ENUITree pick function.
expandENUITreeNode      default ENUITree expand function
filterENUITree         default ENUITree user filter function
fullexpandENUITree      full expand function (serevr/client side opening)
collpaseENUITree      full collpase function (client side closing)
genENUITreeNodeCbfn      default ENUITree expand callback function
handleMultiENUITree      chenges the tree multi select behavior
handleSegmentsENUITree   Enables/disables prev & next images according to the current segment & total segments
convertFSPath         Converts FS pathe to HTML compatible name and backwards

Form functions
---------------------------------
rowsBrwsrDuplicate    duplicate a form row.
rowsBrwsrDelete      will erase all form elemnts in the buttonDelete's "row"

arrays functions
---------------------------------
arrayRemoveExistingRow    remove an existing (database) row of elements
arrayHandleGaps    handle array gaps
arrayGetAttrMaxIx    get max index of an array attribute control
arraySyncNames       yncronize names in array of elements 
arrayHandleNames    handle array names - assign new names to conform with arrays naming convention (ATT_NAME_i)
arrayBuildQueryString    converts elements arrays (name and value) to a querystring

Progress bar
-------------------
showProgressaBar   initialize the progress bar
updateProgressaBar   updates the progress bar (for inner use - private)
hideProgressaBar   hide the progress bar

file system browser
---------------------
openFsBrowser      opens the file system browser window and set its focus
fsBrowserCbfn      call back function to be called from the file system browser

expression builder
------------------------
openExprBuilder      opens the expression builder window and set its focus
exprBuilderCbfn      call back function to be called from the expression builder.

system object picker
-----------------------
showSysEntitiesPicker      opens the system Entities picker for the right object type.
sysEntitiesPickerCbfn      call back function to be called from the Entities picker.
hideSysEntitiesPicker      hide Entities picker 
hideSysEntitiesPickerOnEsc   hide Entities picker (iframe) on escape press
sysEntitiesPickerClear       clear entity picker content

Calendar
------------
showCalendar      opens the calendar in iframe.
hideCalendar      close the calendar.
showCalendarCbfn   The function to get back the date and handle it.

Class QBE
--------------
openClassQbe      opens the Class QBE window and set its focus
classQbeCbfn      call back function to be called from the Class QBE.
*************************************************************************************************************/

//enApplication construstor function
function enApplicationConstrustor()
{
   /*---------------------------------------------------------------------------------------
      Properties
   ---------------------------------------------------------------------------------------*/
   //an object to hold custom data for the application usage
   var global=new Object();
   //an object with url names to be used in js.
   global.URLs=new Object();
   global.URLs.home=null;
   global.URLs.login=null;
   global.baseUrl="../";
   
   global.mainFocusInUse=false;
   global.mainFocusVisible=false;
   global.zfMainArray=new Array();
   global.zfHideCells="";
   //progress bar variables
   global.useProgressBar=false;
   global.disableButtonOnExecute=true;
   global.progressBarVars=new Object();
   global.progressBarVars.progressLength=40;
   global.progressBarVars.progressAt=0;
   global.progressBarVars.progressId=null;
   
   global.confirmAutoRefresh=true;
   global.isRTL=false;
   global.isMainFocus=false;
   global.supportsMainFocus=true;
   
   global.sendToFriend=true;
   global.sendToFriendComp=true;
   
   this.global = global ;

   /*---------------------------------------------------------------------------------------
      general
   ---------------------------------------------------------------------------------------*/

   /*
      prompt user for favs title
      params:
         path - path to open
         title - initial title
         target - to open the window in
   */
   var favsPromptTitle=function(path,title,target)
   {
      //before u start - check hidden execution with no flaging
      if(enUtils.isExecAsync('fraExec',null,null,null,true))return;
      if(!enUtils.isSet(path))return;
      title=!enUtils.isEmpty(title)?title:"";
      //allow user to change title
      var usrTitle=window.prompt(enMsg.get("enApplication.promptFavsTitle"),title);
      //if user canceled - exit
      if(usrTitle==null)return;
      
      //check hidden execution with flaging
      if(enUtils.isExecAsync('fraExec'))return;
      //if emrty, use original title
      usrTitle=!enUtils.isEmpty(usrTitle)?usrTitle:title;
      //change path - add title parameter
      path=enUtils.addQueryStringParam(path,"zoneLinkTITLE",usrTitle);
      //mark as javascript unicode string
      path=enUtils.addQueryStringParam(path,"enaJSU","1");
      if(enUtils.isEmpty(target))
      {
         enUtils.setWinLocation(window,path);
      }
      else
      {
         window.open(path,target);
      }
   }
   this.favsPromptTitle=favsPromptTitle;

   var runAppFile=function(path)
   {
      if(enUtils.isEmpty(path))return;
      var launcher=window.objENLauncher;
      //if we have launcher
      if(!enUtils.isEmpty(launcher))
      {
         try
         {
            window.objENLauncher.runFile(path);
         }
         catch(e){}
      }
      //if not - open in new window
      else
      {
         window.open(path,"_blank");
      }
   }
   this.runAppFile=runAppFile;
   
   //filter zone objects view
   var filterZoneObjects=function(status)
   {
      //def status
      if(enUtils.isEmpty(status))status=null;
      //build path
      var path=window.location.href;
      path=enUtils.addQueryStringParam(path,"enaFilterView",status);      
      //redirect
      enUtils.setWinLocation(null,path);
   }
   this.filterZoneObjects=filterZoneObjects;      
   
   //filter zone objects view by notifications
   var filterZoneNotifObjects=function(action)
   {
      //def action
      if(enUtils.isEmpty(action))action=null;
      //build path
      var path=window.location.href;
      path=enUtils.addQueryStringParam(path,"enaFilterNotif",action);      
      //redirect
      enUtils.setWinLocation(null,path);
   }
   this.filterZoneNotifObjects=filterZoneNotifObjects;      
   
   /*
      link to current page management
      assignes current page as a parameter and opens in a popup
   */
   var linkManageCurrPage=function()
   {
      var path="en.jsp?enPage="+enApplication.global.linkManagePageMethod
         +"&enInfolet=Administration/administratePageProp.jsp";
      path=enUtils.addQueryStringParam(path,"editPropOfPageName",enApplication.global.currentPageName);
      path=enUtils.addQueryStringParam(path,"enPageTitle","Pages Management");   
      switch(enApplication.global.linkManagePageMethod)
      {
         case "PopupPage":
            enUtils.openPopupWindow(path,"enAdminPage",null,750,600);      
            break;
         case "MainFocus":
            showMainFocus(path);
            break;
         default:
            path=enUtils.addQueryStringParam(path,"enPage",enApplication.global.defaultPageName);
            enUtils.setWinLocation(null,path);
      }
   }
   this.linkManageCurrPage=linkManageCurrPage;
   
   /*
      reload notifd component cell
      params:
         cbo - selected filter type (combo box)
         cellId - cell id to reload
         
   */
   var reloadNotifsCell=function (cbo,cellId)
   {
      reloadOnComboChange(cbo,"enaActionType",cellId);
   }
   this.reloadNotifsCell=reloadNotifsCell;
   
   /*
      reload on combo change
      params:
         cbo - selected filter type (combo box)
         paramName - request param to append
         cellId - cell id to reload. if ommited, the page is reloaded
   */
   var reloadOnComboChange=function (cbo,paramName,cellId)
   {
      if(enUtils.isEmpty(cbo))return;
      if(cbo.options.selectedIndex==-1)return;
      var paramValue=enUtils.getValueOf(cbo);
      //if cell id is passed - reload cell
      if(enUtils.isInteger(cellId))
      {
         var extraQryStr=paramName+"="+paramValue;
         reloadCell(cellId,null,null,extraQryStr);
      }
      //else - reload page
      else
      {
         var path=window.location.href;
         path=enUtils.addQueryStringParam(path,paramName,paramValue);
         enUtils.setWinLocation(null,path);
      }
   }
   this.reloadOnComboChange=reloadOnComboChange;
   
   /*
      save current scrolling position in global.currentScrollPos
      params:
         win - window to handle (optional)
      returns:
         the object assigned to global.currentScrollPos:
            obj.left
            obj.top
   */
   var backupScrollPos=function (win)
   {
      var currScroll=new Object();
      var winPos=enUtils.getWindowPos(win);
      currScroll.top=winPos.top;
      currScroll.left=winPos.left;
      //set in application global
      global.currentScrollPos=currScroll;
      return currScroll;
   }
   //expose
   this.backupScrollPos=backupScrollPos;
   

   /*
      sets current scrolling position
      params:
         toScrollPos - new sctoling position (optional)
         win - window to handle (optional)
   */
   var restoreScrollPos=function (toScrollPos,win)
   {
      if(enUtils.isEmpty(win))win=window;
      if(enUtils.isEmpty(toScrollPos))toScrollPos=global.currentScrollPos;
      win.scrollTo(toScrollPos.left,toScrollPos.top);
   }
   //expose
   this.restoreScrollPos=restoreScrollPos;
   
   /*
      builds the path to an image based on the current skin
      params:
         imgName - image to find - start bellow the skin folder
      returns - the full img path
   */
   var getSkinImgPath=function(imgName)
   {
      if(enUtils.isEmpty(imgName))return "";
      //get base url
      var path=enUtils.getBaseUrl();
      path+="Static/Images/Skins/";
      path+=global.currentSkinName+"/";
      path+=imgName;
      return path;
   }
   this.getSkinImgPath=getSkinImgPath;

   /*
      give alert and close the current window
      optional param:
         msg - the alert messege. 
   */
   var alertNotLoginAndClose=function(msg)
   {
      if(enUtils.isEmpty(msg)) msg=enMsg.get("enApplication.alertNotLoginAndClose") ;
      alert(msg);
      enUtils.absoluteRedirect(enApplication.global.URLs.login);
   }
   this.alertNotLoginAndClose=alertNotLoginAndClose;
   
   /*
      confirm user and refresh window
      checks global.promptAutoRefresh as a silent default param
      optional param:
         msg - the alert messege. to avoid use '$none$' 
   */
   var confirmAndRefresh=function(msg)
   {
      var confirmFirst=global.confirmAutoRefresh;
      if(!enUtils.isEmpty(msg) && msg.toLowerCase().equals("$none$"))
      {
         confirmFirst=false;
      }
      if(confirmFirst)
      {
         //get msg
         if(enUtils.isEmpty(msg)) msg=enMsg.get("enApplication.confirmRefresh");
         //confirm with user
         if(!confirm(msg))return;
      }
      //reload
      window.location.reload(true);
   }
   this.confirmAndRefresh=confirmAndRefresh;
   
   /*
      set window timeout to refresh page
   */
   var setAutoRefreshTimeout=function()
   {
      window.setTimeout("enApplication.confirmAndRefresh();",global.autoRefreshRate);
   }
   this.setAutoRefreshTimeout=setAutoRefreshTimeout;
   
   /*
      setAutoRefreshCellInterval set window timeout to refresh cell
      params:
         cellId - id of cell
         interval - interval in seconds (complete)
         extraQryString - query string to append
         recurring - use interval, not timeout? def true
      returns:
         identifier for interval or timeout
   */
   var setAutoRefreshCellInterval=function(cellId,interval,extraQryString,recurring)
   {
      if(!enUtils.isInteger(cellId) || !enUtils.isNum(interval))return;
      if(!enUtils.isSet(recurring))recurring=true;
      var exe="enApplication.reloadCell("+cellId+",true";
      if(!enUtils.isEmpty(extraQryString))exe+=",null,'"+extraQryString+"'";
      exe+=");";   
      if(recurring)
         return window.setInterval(exe,1000*interval);
      else
         return window.setTimeout(exe,1000*interval);
   }
   this.setAutoRefreshCellInterval=setAutoRefreshCellInterval;
      
   /*
      set list of buttons to disable on execution
   */
   var setDisableButtonList=function(list)
   {
      global.disableButtonList=list;
   }
   this.setDisableButtonList=setDisableButtonList;
   
   /*
      enable / disable buttons list on execution
   */
   var toggleDisableButtonList=function(disable)
   {
      var list=global.disableButtonList;
      var el=null;
      if(enUtils.isEmpty(list))return;
      //turn into arrays
      if(!enUtils.isArray(list))
      {
         if(enUtils.isObject(list))list=new Array(list);
         else list=enUtils.separatedListToArray(list);
      }

      //loop
      for(var i=0;i<list.length;i++)
      {
         el=enUtils.objectOrGetId(list[i]);
         if(!enUtils.isEmpty(el))
         {
            el.disabled=disable;
         }
      }
      //clear
      if(!disable)global.disableButtonList=null;
   }
   this.toggleDisableButtonList=toggleDisableButtonList;
   
   //get base url (application root with trailing slash)
   var getBaseUrl=function()
   {
      //make sure has trailing slash
      if(!enUtils.isEmpty(global.baseUrl))
      {
         var pos=1+global.baseUrl.lastIndexOf("/");
         if(pos>0 && pos<global.baseUrl.length)global.baseUrl+="/";
      }
      return global.baseUrl;
   }
   this.getBaseUrl=getBaseUrl;
      
   /*-------------------------------------------------------------
      online help
   -------------------------------------------------------------*/
   
   /*
      open help on F1
      how to use:
         enUtils.evtAddEvent(document,"keydown",enApplication.getHelpOnF1);
   */
   var getHelpOnF1=function(e)
   {
      var evnt=enUtils.evtGetCBEvent(e);
      //F1 is 112
      if(evnt.keyCode==112)
      {
         evnt.cancelEvent();
         openPopUpHelp();
      }
   }
   this.getHelpOnF1=getHelpOnF1;
   
   /*
      cancel IE help event
      how to use:
         document.onhelp=enApplication.cancelIEHelp;
   */
   var cancelIEHelp=function()
   {
      event.returnValue=false;
   }
   this.cancelIEHelp=cancelIEHelp;

   /*
      open help window
      params:
         path - path to open
            expects: http://server:port/site/Static/Help...   OR Static/Help...
   */
   var openPopUpHelp=function(path)
   {
      //cascade path
      if(enUtils.isEmpty(path))
      {
         path=enUtils.ntz(enUtils.ntz(global.specificHelpFile),global.defaultHelpFile);
      }
      if(enUtils.isEmpty(path))return;
      /*
      if(path.substr(0,getBaseUrl().length)!=getBaseUrl())
      {
         //getBaseUrl returns with the last "/" so take it off from the path
         if(path.substr(0,1)=="/")path=path.substr(1);
         path=getBaseUrl()+path;
      }
      */
      enUtils.openPopupWindow(path,"enHelpWin",null,780,580);
      //window.open(path,"enHelpWin","width=780,height=580,directories=0,menubar=0,resizable=1,scrollbars=1,toolbar=0")
   }
   this.openPopUpHelp=openPopUpHelp;
      
   /*-------------------------------------------------------------
      floating Ifreame functions
    ---------------------------------------------------------------*/
   /*
      close window or floating frame
      called from a popup window - document.keyup
      how to use: 
         enUtils.evtAddEvent(document,"keyup",enApplication.closeWindowOrFloatingIfrOnEsc);
   */
   var closeWindowOrFloatingIfrOnEsc=function(e)
   {   
      var e=enUtils.evtGetCBEvent(e);
      if(e.keyCode==27)
      {
         if(countAllFloatingIfrs()) 
         {   
            closeAllFloatingIfrs();
         }   
         else if(window.opener)
         {
            window.close();
         }   
      }
   }
   this.closeWindowOrFloatingIfrOnEsc=closeWindowOrFloatingIfrOnEsc;   
   /*
      close all iframes (called from document click)
      how to use: 
         enUtils.evtAddEvent(document,"click",enApplication.closeAllFloatingIfrs);
   */
   var closeAllFloatingIfrs=function()
   {
      var check=false;
      try
      {   
         hideColorPicker();
      }
      catch(e){}
      try
      {
         hideCalendar();
      }
      catch(e){}
      try
      {
         hideSysEntitiesPicker();
      }
      catch(e){}
   }
   this.closeAllFloatingIfrs=closeAllFloatingIfrs;         
   
   /*
      count all open iframes
      returns number of open iframes
   */
   var countAllFloatingIfrs=function()
   {
      var ifrCounter=0;
      try
      {   
         if(document.getElementById("fraColorPicker").style.visibility=='visible') 
         {
            ifrCounter++;
         }   
      }
      catch(e){}
      try
      {
         if(document.getElementById("fraCalendar").style.visibility=='visible')
           {
            ifrCounter++;
         }   
      }
      catch(e){}
      return ifrCounter;
   }
   this.countAllFloatingIfrs=countAllFloatingIfrs;         
   
   /*
      close all the iframes when press Esc (called from docuemnt.keyup)
      how to use: 
         enUtils.evtAddEvent(document,"keyup",enApplication.closeAllFloatingIfrsOnEsc);
   */
   var closeAllFloatingIfrsOnEsc=function(e)
   {
      var e=enUtils.evtGetCBEvent(e);
      if(e.keyCode==27) closeAllFloatingIfrs();
   }
   this.closeAllFloatingIfrsOnEsc=closeAllFloatingIfrsOnEsc;      

   
   /*
      sign the cell onmouseover or onmouseout
      params:
            sign - sign or unsign the cell
            el - the element that we want to sign
   */
   var sortTableMarkCell=function(sign,el)
   {
      el=enUtils.objectOrGetId(el);
      //if already sorted - do not change
      var sorted=el.getAttribute("enSortedAsc");
      if(!enUtils.isEmpty(sorted))return;
      //else - switch class
      if(sign==0)
      {
         el.className = "sortTableOverCell" ;
      }
      else
      {
         el.className = "" ;
      }
   }
   this.sortTableMarkCell=sortTableMarkCell;
      
      
   /*
   show Color picker:
   */
   var showColorPicker=function (e)
   {
      var cpCbfn,cpSize,cpCallerId,cpOpenMode,elmnt,cpSign;
      var evnt=enUtils.evtGetCBEvent(e)
      elmnt=evnt.target;
      cpCallerId = elmnt.getAttribute("enCpCallerId");
      if(enUtils.isEmpty(cpCallerId)) return;
      cpSize = elmnt.getAttribute("enCpSize");
      cpOpenMode = elmnt.getAttribute("enCpOpenMode");
      cpCbfn = elmnt.getAttribute("enCpCbfn");
      if(enUtils.isEmpty(cpCbfn)) cpCbfn='enApplication.showColorPickerCbfn';
      if(enUtils.isEmpty(cpSize)) cpSize=4;
      if(enUtils.isEmpty(cpOpenMode)) cpOpenMode='iframe';
      var newWinPath = enUtils.getBaseUrl() + "Static/Common/ColorPicker/colorPicker.jsp?sizeOfArray="+enUtils.enEscape(cpSize)+
         "&funName="+enUtils.enEscape(cpCbfn)+"&callID=" + enUtils.enEscape(cpCallerId)+"&openElement=" + enUtils.enEscape(cpOpenMode);
      var ifrParams=new Object();
      var docAlign = global.isRTL?"right":"left" ;
      ifrParams.position="bottom";
      ifrParams.shiftDir=docAlign;
      ifrParams.shiftByPercent="0";
      ifrParams.ifrSrc=newWinPath;
      ifrParams.ifrWidth="160";
      ifrParams.ifrHeight="160";
      ifrParams.isSrcFile=true;
      enUtils.ifrShowFloatingIfr('fraColorPicker',elmnt,ifrParams);
      evnt.setCancelBubble(true);
   }
   //expose
   this.showColorPicker=showColorPicker;

   /*
   hidding the color picker
   */
   var hideColorPicker=function (){
      
      enUtils.ifrShowFloatingIfr('fraColorPicker');
   }
   //expose
   this.hideColorPicker=hideColorPicker;
   /*
      close color picker on escape press
      how to use: 
         enUtils.evtAddEvent(document,"keyup",enApplication.hideColorPickerOnEsc);
   */
   var hideColorPickerOnEsc=function(e)
   {
      //get event
      var e=enUtils.evtGetCBEvent(e);
      //get ascii code
      if(e.keyCode==27) hideColorPicker();
   }
   this.hideColorPickerOnEsc=hideColorPickerOnEsc;
   
   /*
      showColorPickerCbfn call back function to be called from the color picker
      how to use:
         pass 'enApplication.showColorPickerCbfn' a sthe call back function to the color picker
         <input type="button" name="cmdTest" id="cmdTest" value="..."
            enCpCallerId="cmdTest" enCpCbfn="enApplication.showColorPickerCbfn" 
            enCpSize="4" enCpOpenMode="iframe">
         the color picker will call the function back with the selected color
      params:
         inputId - the id of the related input
         color - selected color
   */
   var showColorPickerCbfn=function(inputId,color)
   {
      var el = document.getElementById(inputId) ;
      if(!enUtils.isEmpty(el))
      {
         enUtils.setValueOf(el,color);
      }
   }
   //expose
   this.showColorPickerCbfn=showColorPickerCbfn;
   
   /*
      show tooltip frame
      params:
         elmnt - element or id to hook tooltip on
         textTitle - tooltip title
         textBody - tooltip body text
         minWidth - min width for frame (def 140)
         minHeight - min height for frame (def 100)
   */
   var showToolTip=function(elmnt,textTitle,textBody,minWidth,minHeight)
   {
      //validation
      if ( enUtils.isEmpty(elmnt) || 
         enUtils.isEmpty(textTitle) && enUtils.isEmpty(textBody) ) return;
      
      //get size
      var width=enUtils.enParseInt(enUtils.ntz(minWidth,"140"));
      var height=0;
      minHeight=enUtils.enParseInt(enUtils.ntz(minHeight,"100"));
      //get divToolTipSizeChecker
      var sizeChecker=enUtils.objectOrGetId("divToolTipSizeChecker");
      if(!enUtils.isEmpty(sizeChecker))
      {
         //set width to divToolTipSizeChecker
         sizeChecker.style.width=width;
         //title first
         //enUtils.elmntSetInnerText(sizeChecker,textTitle); - THIS DOES NOT TAKE <BR>... into concideration
         sizeChecker.innerHTML=textTitle;
         height+=enUtils.enParseInt(enUtils.elmntAbsPos(sizeChecker).height);
         //body
         //enUtils.elmntSetInnerText(sizeChecker,textBody); 
         sizeChecker.innerHTML="";
         sizeChecker.innerHTML=textBody;
         height+=enUtils.enParseInt(enUtils.elmntAbsPos(sizeChecker).height);
      }
      //html
      var isDocRtl = global.isRTL?'dir=\"rtl\"':'';
      var src = "<html "+isDocRtl+"><head>\n";
      if(!enUtils.isEmpty(global.charset))
      {
         src+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset="+global.charset+"\">\n";
      }
      src += "<link rel='stylesheet' type='text/css' href='"
         +enUtils.getBaseUrl()+"Static/Include/common.css'>";
      src += "<link rel='stylesheet' type='text/css' href='"
         +enUtils.getBaseUrl()+"Static/Include/enformia.css'>";
      if(!enUtils.isEmpty(global.currentSkinName))
      {
         src += "<link rel='stylesheet' type='text/css' href='"
            +enUtils.getBaseUrl()+"Static/Include/"+global.currentSkinName+".css'>";
      }
      src += "</head><body style='margin:0;padding:0;'>";
      src += "<div class='tltpHeader'>"+textTitle+"</div>";
      src += "<div class='tltpBody'>"+textBody+"</div>";
      src += "</body></html>";
      
      //show iframe
      elmnt = enUtils.objectOrGetId(elmnt);
      var ifrParams=new Object();
      var docAlign = global.isRTL?"right":"left" ;
      ifrParams.position="bottom";
      ifrParams.shiftDir=docAlign;
      ifrParams.shiftByPercent="50";
      ifrParams.isSrcFile=false;
      ifrParams.ifrSrc=src;
      ifrParams.ifrWidth=width;
      ifrParams.ifrHeight=(minHeight>height ? minHeight : height);
      enUtils.ifrShowFloatingIfr('fraToolTip',elmnt,ifrParams);
   }
   this.showToolTip=showToolTip;         

   var hideToolTip=function()
   {
      enUtils.ifrShowFloatingIfr('fraToolTip');
   }
   this.hideToolTip=hideToolTip;         

   /*-------------------------------------------------------------
      Home page components
      --------------------------------------------------------------*/
   /*
   show Move Cells board:
   */
   var showMoveCellsPopup=function (elmnt)
   {      
      //backupScrollPos(); not needed anymore...
      elmnt=enUtils.objectOrGetId(elmnt);
      if(enUtils.isEmpty(elmnt))return;
      global.pagePrefrencesUrl = elmnt.getAttribute("enPopupUrl");
      global.enSrcElmntToMove = elmnt;
      var srcCode = moveCellsCreateHtml();
      var ifrParams=new Object();
      var docAlign = global.isRTL?"right":"left" ;
      ifrParams.skipKeepInWin=true;
      ifrParams.position="bottom";
      ifrParams.shiftDir=docAlign;
      ifrParams.shiftByPercent="0";
      ifrParams.ifrSrc=srcCode;
      ifrParams.ifrWidth="126";
      if(enUtils.isEmpty(global.moveCellsMenuHeight)) global.moveCellsMenuHeight="158";
      ifrParams.ifrHeight=""+global.moveCellsMenuHeight+"";
      ifrParams.isSrcFile=false;
      ifrParams.showHide='show';
      enUtils.ifrShowFloatingIfr('fraMoveCells',elmnt,ifrParams);
      //window.setTimeout("enApplication.restoreScrollPos();",1); not needed anymore...
   }
   //expose
   this.showMoveCellsPopup=showMoveCellsPopup;
            
   /*
   hide Move Cells board
   */
   var hideMoveCellsPopup=function()
   {
      var el=new Object();
      el.showHide = "hide";
      enUtils.ifrShowFloatingIfr("fraMoveCells",null,el);
   }
   //expose
   this.hideMoveCellsPopup=hideMoveCellsPopup;
   
/*
   Move the cells
   td are coded by: td_tbl#_row#(top-down)_cell#(left-right) 
   td's have an attribute called: enChangeablTd, set to "true".
*/   
   var moveTd = function(srcClickElmnt, moveDir)
   {
      var success, errMsg=enMsg.get("enApplication.noCell"),tmpId=null;
      //get details about the sourse td
      var srcTd=srcClickElmnt.parentNode;
      while(srcTd.getAttribute("enMoveableTd")!="true")
      {
         srcTd=srcTd.parentNode
      }
      //one cell jump
      if (moveDir=="R" || moveDir=="L" || moveDir=="U" || moveDir=="D")
      {
         success=switchTd(srcTd,moveDir);
         if(success==null) 
         {   
            alert(errMsg);
            //success=tmpId;
         }
         else
         {   
            tmpId=success;
         }   
      }
      else if (moveDir=="RR" || moveDir=="LL" || moveDir=="UU" || moveDir=="DD")
      {
         //get basic direction
         var basicdir=moveDir.substr(0,1);
         //first time we want to give the message
         success=switchTd(srcTd,basicdir);
         if(success==null) 
         {   
            alert(errMsg);
         }   
         else 
         {
            tmpId=success;
         }   
         while(success!=null)
         {
            success=switchTd(srcTd,basicdir);
            if(success!=null)tmpId=success;
         }
         success=tmpId;
      }
      return success ;
   }
   //expose
   this.moveTd=moveTd;

   /*
      this function gets the td to move and the basic movement: R,L,U,D.
      the function does all the work for getting the destination td (also if it is in another table)
      return value: true: the cell has been moved. false: no destination cell;
      srcTbl=0: means we move cells in the same table.
      srcTbl=else: means for R/L we move cells between tables.
   */
   var switchTd = function(srcTd,moveDir)
   {
      //get srcTd details
      var srcTdId=srcTd.id;
      var srcTr=srcTd.parentNode;
      //parse cell id
      var idArray=srcTdId.split('@');
      var preFix=idArray[0];
      var srcTbl=enUtils.enParseInt(idArray[1]);
      var srcRow=enUtils.enParseInt(idArray[2]);
      var srcCell=enUtils.enParseInt(idArray[3]);
      if(moveDir=='R')
      {
         //get details about the destination td
         var dstTbl= srcTbl==0?srcTbl:srcTbl+1;
         var dstRow=srcRow;
         var dstCell=srcTbl==0?srcCell+1:srcCell;
         var dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         var dstTd=document.getElementById(dstTdId);
         //go out if no destination
         if(!dstTd) return null;
         //switch
         var dstTr=dstTd.parentNode;
         dstTr.replaceChild(srcTd,dstTd);
         if(srcTbl==0)srcTr.insertBefore(dstTd,srcTd);
         else srcTr.appendChild(dstTd);
         //change the id
         srcTd.id=dstTdId;
         dstTd.id=srcTdId;
      }
      else if(moveDir=='L')
      {
         //get details about the destination td
         var dstTbl= srcTbl==0?srcTbl:srcTbl-1;
         if(srcTbl!=0 && dstTbl==0) dstTbl=-1;
         var dstRow=srcRow;
         var dstCell=srcTbl==0?srcCell-1:srcCell;
         var dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         var dstTd=document.getElementById(dstTdId);
         //go out if no destination
         if(!dstTd) return null;
         //switch
         var dstTr=dstTd.parentNode;
         srcTr.replaceChild(dstTd,srcTd);
         if(srcTbl==0)dstTr.insertBefore(srcTd,dstTd);
         else dstTr.appendChild(srcTd);
         //change the id
         srcTd.id=dstTdId;
         dstTd.id=srcTdId;
      }
      else if(moveDir=='D')
      {
         //get details about the destination td
         var dstTbl= srcTbl;
         var dstRow=srcRow+1;
         var dstCell=srcCell;
         var dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         var dstTd=document.getElementById(dstTdId);
         //go out if no destination
         if(!dstTd) return null;
         //check for the next right td in the source tr
         var nxtSrcTdId=preFix +"@" +srcTbl + "@" + srcRow + "@" + (srcCell+1);
         var nxtSrcTd=document.getElementById(nxtSrcTdId);
         //switch
         var dstTr=dstTd.parentNode;
         dstTr.replaceChild(srcTd,dstTd);
         if(nxtSrcTd) srcTr.insertBefore(dstTd,nxtSrcTd);
         else srcTr.appendChild(dstTd);
         //change the id
         srcTd.id=dstTdId;
         dstTd.id=srcTdId;
      }
      else if(moveDir=='U')
      {
         //get details about the destination td
         var dstTbl= srcTbl;
         var dstRow=srcRow-1;
         var dstCell=srcCell;
         var dstTdId=preFix +"@" +dstTbl + "@"  + dstRow + "@" + dstCell;
         //get the destination td
         var dstTd=document.getElementById(dstTdId);
         //go out if no destination
         if(!dstTd) return null;
         //check for the next right td in the dstination tr
         var nxtDstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + (dstCell+1);
         var nxtDstTd=document.getElementById(nxtDstTdId);
         //switch
         var dstTr=dstTd.parentNode;
         srcTr.replaceChild(dstTd,srcTd);
         if(nxtDstTd) dstTr.insertBefore(srcTd,nxtDstTd);
         else dstTr.appendChild(srcTd);
         //change the id
         srcTd.id=dstTdId;
         dstTd.id=srcTdId;
      }
      //return success
      //return true;
      return dstTd.id ;      
   }
   //expose
   this.switchTd=switchTd;
   
   /*
    * shows the main div 'divMainFocus' according to a base elmnt (embeded in HomePage)
    *   (embeded in HomePage) - USES: enUtils.ifrShowFloatingIfr
    *    if already in main focus - open in that window
    * Params:
    *      srcPath: source(URL) to open in the floating iframe.      
    *      height: the height of the iframe in absolute numbers or relative to screen size (def global.mainFocusHeight).
    *      isRelativeHeight: if true will set the iframe height as height*screen height (def global.mainFocusIsRelative)
    */
    var showMainFocus=function(srcPath,height,isRelativeHeight)
    {
       //check functoin paramters
      if(!enUtils.isSet(srcPath))return;
      if(!enUtils.isSet(height))height=global.mainFocusHeight;
      if(!enUtils.isSet(isRelativeHeight))isRelativeHeight=global.mainFocusIsRelative;

      //add random parameter to path
      srcPath=enUtils.addQueryStringParam(srcPath,"enaRand",Math.random());
      
      // Hide selects and objects
      enUtils.elmntShowHideAdvanced(false);
      
      //if already in main focus, or page does not support - open in current window
      if(global.isMainFocus || !global.supportsMainFocus 
         || enUtils.isEmpty(document.getElementById("maxZoneBaseEl")))
      {
         enUtils.setWinLocation(window,srcPath);
         return;
      }

      //add page name, and floating parameter to path
      srcPath=enUtils.addQueryStringParam(srcPath,"enPage","MainFocus");
      srcPath=enUtils.addQueryStringParam(srcPath,"enaFloating","1");
      
      if (isRelativeHeight)
      {
         //convert %
         if((new String(height)).indexOf("%")!=-1)height=parseFloat(height)/100;
         //set relative height
         height=enUtils.enParseInt(parseFloat(height)*parseFloat(enUtils.getWindowPos().height));
      }
      //set internal iframe element size
      setMainFocusIntIfrSize(true);
      //default id of the div container for that purpose
      var ifr="divMainFocus";
      //defautl id of the elmnt
      var elmnt="maxZoneBaseEl";
      //get base elemnt width for default
      var oElmnt=enUtils.objectOrGetId(elmnt);
      var calcWidth=oElmnt.width;
      //ifr parameters
      var ifrParams=new Object();
      var docAlign = global.isRTL?"right":"left" ;
      ifrParams.position="bottom";
      ifrParams.shiftDir=docAlign;
      ifrParams.shiftByPercent="0";
      ifrParams.ifrSrc=srcPath;
      ifrParams.ifrWidth=calcWidth;
      ifrParams.skipKeepInWin=true;
      ifrParams.ifrHeight=height;
      ifrParams.isSrcFile=true;
      ifrParams.showHide='show';

      enUtils.ifrShowFloatingIfr(ifr,elmnt,ifrParams);
      //make sure it is dragable
      var oIfr=enUtils.objectOrGetId(ifr);
      if(!enUtils.isEmpty(oIfr))
      {   
         oIfr.setAttribute("enaDragable","1");
         if(enBS.ns6up || enBS.ie55 || enBS.ie6up)
            oIfr.style.cursor="move";   
      }
      //if there is a last position move there
      if(enApplication.global.drag.focusLastLeft && enApplication.global.drag.focusLastTop)
      {
         enUtils.elmntMove(ifr,enApplication.global.drag.focusLastLeft,
                        enApplication.global.drag.focusLastTop);
      }
      //set flags
      global.mainFocusInUse=true;
      global.mainFocusVisible=true;
      global.mainFocusResState=null;
      global.mainFocusResPos=null;
      try
      {
         window.scrollTo(0,0);
      }
      catch(e){}
    }
    this.showMainFocus=showMainFocus;

   /*
    * hides the main div 'divMainFocus'
    * this function is to be called from the main page. if called from the iframe,
    * use window.parent.enUtils.hideMainFocus();
    * Params:
    *      reload: if false hides the iframe without reloading the main page(def=true)
     *      clear: clear iframe source and global flag ?(def=true)
    */
    var hideMainFocus=function(reload,clear)
    {
       //reload?
      if(!enUtils.isSet(reload))reload=true;
      //clear?
      if(!enUtils.isSet(clear))clear=true;
      if(reload) 
      {
         window.location.reload(true);
         return;
      }
      //set internal iframe element size
      setMainFocusIntIfrSize(false);
      //default id of the iv container for that purpose
      var ifr="divMainFocus";
      var ifrParams=new Object();
      ifrParams.showHide='hide';
      //hide
      enUtils.ifrShowFloatingIfr(ifr,null,ifrParams);
      
      //Show the selects and objects again
      enUtils.elmntShowHideAdvanced(true);

      //set flags
      global.mainFocusInUse=false;
      global.mainFocusVisible=false;
      global.mainFocusResState=null;
      global.mainFocusResPos=null;
      //clear source
      if(clear)
      {
         var oIfr=enUtils.getIfrFromDiv(document.getElementById(ifr))
         oIfr.src=getBaseUrl()+"Static/none.htm";
      }
    }
    this.hideMainFocus=hideMainFocus;
   
   //set internal iframe element size
   var setMainFocusIntIfrSize=function(show)
   {
      if(!enUtils.isSet(show))show=true;
      var intIframe=enUtils.objectOrGetId("ifrMainFocus");
      if(!enUtils.isEmpty(intIframe))
      {
         var size=show ? "100%" : "0";
         intIframe.style.width=size;
         intIframe.style.height=size;
      }
   }
   this.setMainFocusIntIfrSize=setMainFocusIntIfrSize;
      
   //show or hide main focus
   var toggleMainFocusVisibility=function(flg)
   {
      if(global.mainFocusInUse)
      {
         flg=enUtils.isSet(flg)?flg:!global.mainFocusVisible;
         enUtils.objectOrGetId("divMainFocus").style.visibility=flg?"visible":"hidden";
         global.mainFocusVisible=flg;
      }
      else
      {
         //reset flag
         if(global.mainFocusVisible)global.mainFocusVisible=false;
      }
   }
   this.toggleMainFocusVisibility=toggleMainFocusVisibility;
   
   //set the title of the main focus floating frame
   var setMainFocusTitle=function(title)
   {
      if(!global.isMainFocus)return;
      enUtils.elmntSetInnerText("spnMainFocusTitle",title);
   }
   //expose
   this.setMainFocusTitle=setMainFocusTitle;
   
   /*
      toggle main focus max / restore
      params:
         img - the img for the action
         integrity - perform integrity only = img src and title (def false)
   */
   var toggleMainFocusMaxRes=function(img,integrity)
   {
      //validate
      img=enUtils.objectOrGetId(img);
      if(enUtils.isEmpty(img))return;
      if(!enUtils.isSet(integrity))integrity=false;
      //check state
      var newState=global.mainFocusResState=="m" ? "m" : "r";
      if(!integrity)newState=global.mainFocusResState=="m" ? "r" : "m";
      //action
      if(!integrity)
      {
         if(newState=="m")
         {
            maxMainFocus();
            //scroll to top
            //only when not RTL
            if(!global.isRTL)
               window.scrollTo(0,0);
         }
         else restoreMainFocus();
      }
      //change src
      var currSrcFolder=enUtils.getFolderFromUrl(img.src);
      img.setAttribute("src",
         newState=="r" ? currSrcFolder+"/maximize.gif" : currSrcFolder+"/restore.gif");
      //change title
      img.setAttribute("title",newState=="m" ? enMsg.get("enApplication.restore") : enMsg.get("enApplication.maximize"));
      //set state      
      if(!integrity)global.mainFocusResState=newState;
   }
   this.toggleMainFocusMaxRes=toggleMainFocusMaxRes;

   
   //maximize main focus
   var maxMainFocus=function()
   {
      var ifr=document.getElementById("divMainFocus");
      //save last position
      var lastPos=new Object();
      lastPos.width=ifr.style.width;
      lastPos.height=ifr.style.height;
      lastPos.left=ifr.style.left;
      lastPos.top=ifr.style.top;
      global.mainFocusResPos=lastPos;
      //set max pos
      var winPos=enUtils.getWindowPos();
      ifr.style.width=winPos.width*0.96;
      ifr.style.height=winPos.height*0.96;      
      ifr.style.left=4;
      ifr.style.top=4;
      //make it undragable
      ifr.setAttribute("enaDragable","0");
      ifr.style.cursor="";   
   }
   this.maxMainFocus=maxMainFocus;

   //restore main focus
   var restoreMainFocus=function()
   {
      var ifr=document.getElementById("divMainFocus");
      var lastPos=global.mainFocusResPos;
      if(lastPos)
      {
         ifr.style.width=lastPos.width;
         ifr.style.height=lastPos.height;
         ifr.style.left=lastPos.left;
         ifr.style.top=lastPos.top;
      }
      else
      {
         var winPos=enUtils.getWindowPos();
         ifr.style.width=3*parseFloat(winPos.width)/4;
         ifr.style.height=3*parseFloat(winPos.height)/4;
         ifr.style.left=(parseFloat(winPos.width)/8);
         ifr.style.top=(parseFloat(winPos.height)/8);   
      }
      //make it dragable
      ifr.setAttribute("enaDragable","1");
      if(enBS.ns6up || enBS.ie55 || enBS.ie6up)
         ifr.style.cursor="move";   
   }
   this.restoreMainFocus=restoreMainFocus;

   /*
      toggle cell min / restore
      state is stored in the img
      params:
         img - the img for the action
   */
   
   var toggleCellMinRes=function(img)
   {
      //validate
      img=enUtils.objectOrGetId(img);
      if(enUtils.isEmpty(img))return;
      //check state
      var state=img.getAttribute("enState")=="r" ? "r" : "m";
      var newState=state=="r" ? "m" : "r";
      //get cell id
      var cellId=img.getAttribute("componentIndex");
      if(!enUtils.isInteger(cellId))return;
      
      //point to main content td
      cellId="tdComponentBody"+cellId;   
      var contentTd=enUtils.objectOrGetId(cellId);
      if(enUtils.isEmpty(contentTd))return;
      //action
      enUtils.elmntShowHide(contentTd);

      //change src. the img may have suffix extention,
      //so we would just replace the restore/minimize part
      var currSrcFolder=enUtils.getFolderFromUrl(img.src);
      var fileName=enUtils.getFileFromUrl(img.src);
      var newFileName= newState=="m" ? fileName.replace("restore","minimize") 
         : fileName.replace("minimize","restore");
      img.setAttribute("src",currSrcFolder+"/"+newFileName);
         
      //change title
      img.setAttribute("title",newState=="m" ? enMsg.get("enApplication.minimize") 
         : enMsg.get("enApplication.restore"));
      //set state      
      img.setAttribute("enState",newState);
   }
   this.toggleCellMinRes=toggleCellMinRes;
      
   
   /*
      print an individual cell
      params:
         cellId - id of cell in page
   */
   var printCell=function(cellId)
   {
      //get cell id
      if(enUtils.isEmpty(cellId))
      {
         var srcClickElmnt=global.enSrcElmntToMove;
         if(enUtils.isEmpty(srcClickElmnt))return;
         cellId=srcClickElmnt.getAttribute("componentIndex");
      }
      if(!enUtils.isInteger(cellId))return;
      //what's the cell size?
      var minWidth=280;
      var minHeight=200;
      var absPos=enUtils.elmntAbsPos("tdComponentBody"+cellId);
      var cellWidth=Math.max(minWidth,absPos.width);
      var cellHeight=Math.max(minHeight,absPos.height);
      
      //build url      
      var path=enUtils.getBaseUrl()+"bin/en.jsp?enPage="+global.currentPageName;
         path+="&enaMode=print&enaCellId="+cellId+"&enaCellWidth="+cellWidth;
      
      /*
      var path=enUtils.getBaseUrl()+"bin/en.jsp?enPage=NOPAGE&enInfolet=Misc/printCell.jsp";
         path+="&enaCellId="+cellId+"&enaCellWidth="+cellWidth;
      */
      
      //print - use hidden frame 
      //(do not run on IE 5.5 and 6.0. IE 5.0 prints the floating frame..)
      if(enBS.ie)
      {
         //use popup
         enUtils.openPopupWindow(path,"_blank",null,1.2 * cellWidth,1.2 * cellHeight);
      }
      else
      {
         path=enUtils.addQueryStringParam(path,"enaHidden","1");
         enUtils.execAsync("fraExec",path,"fraExec");
      }
   }
   this.printCell=printCell;

   /*
      return a comma separated list of cell ids for a given zone name
      params:
         zoneName - zone name (or @ delimited list) to filter by
         firstOnly - return only first (def false)
      returns:
         a comma separated list of cell ids
   */
   var getCellsByZone=function(zoneName,firstOnly)
   {
      //validation and defaults
      if(enUtils.isEmpty(zoneName))return null;
      if(!enUtils.isSet(firstOnly))firstOnly=false;
      if(enUtils.isEmpty(global.mapZonesToCells))return null;
      var out="";
      //for each zone in zoneName - loop on global.mapZonesToCells
      var zoneNames=zoneName.split("@");
      for (var z=0;z<zoneNames.length;z++)
      {
         for(var i=0;i<global.mapZonesToCells.length;i++)
         {
            if(global.mapZonesToCells[i][0]==zoneNames[z])
            {
               if(!enUtils.isEmpty(out))out+=",";
               out+=global.mapZonesToCells[i][1];
               if(firstOnly)break;
            }
         }
      }
      return out;
   }
   this.getCellsByZone=getCellsByZone;
   
   /*
      return a comma separated list of cell ids for a given component name
      params:
         componentName - component name (or @ delimited list) to filter by
         firstOnly - return only first (def false)
      returns:
         a comma separated list of cell ids
   */
   var getCellsByComponent=function(componentName,firstOnly)
   {
      //validation and defaults
      if(enUtils.isEmpty(componentName))return null;
      if(!enUtils.isSet(firstOnly))firstOnly=false;
      if(enUtils.isEmpty(global.mapComponentsToCells))return null;
      var out="";
      //for each component in zoneName - loop on global.mapComponentsToCells
      var compNames=componentName.split("@");
      for (var c=0;c<compNames.length;c++)
      {
         for(var i=0;i<global.mapComponentsToCells.length;i++)
         {
            if(global.mapComponentsToCells[i][0]==compNames[c])
            {
               if(!enUtils.isEmpty(out))out+=",";
               out+=global.mapComponentsToCells[i][1];
               if(firstOnly)break;
            }
         }
      }
      return out;
   }
   this.getCellsByComponent=getCellsByComponent;
                  
   /*
      reload an individual cell

      params:
         cellId - id of cell (or a comma separated list of cell ids) in page
         retryIfBusy - when !isExecAsync - retry again (def false) in that mode no alerts are used
         win - window to run in (default current window)
         extraQryString - axtra params to append to cell link - query string or 2D array
      how to use:
         1. to reload a given cell - enApplication.reloadCell(12); / enApplication.reloadCell("12,54,2");
         2. to reload all cells with a give zone - enApplication.reloadCell(getCellsByZone('zoneName'));
         2. to reload all cells with a give component - enApplication.reloadCell(enApplication.getCellsByComponent('compName'));
   */
   var reloadCell=function(cellId,retryIfBusy,win,extraQryString)
   {
      //default
      if(enUtils.isEmpty(win))win=window;
      if(!enUtils.isSet(retryIfBusy))retryIfBusy=false;
      //get cell id
      if(enUtils.isEmpty(cellId))
      {
         var srcClickElmnt=win.enApplication.global.enSrcElmntToMove;
         if(enUtils.isEmpty(srcClickElmnt))return;
         cellId=srcClickElmnt.getAttribute("componentIndex");
      }
      if(enUtils.isEmpty(cellId))return;
      //build url
      var path="en.jsp?enPage="+global.currentPageName;
         path+="&enaMode=reload&enaCellId="+cellId;
      if(!enUtils.isEmpty(extraQryString))
      {
         if(enUtils.isArray(extraQryString))
            extraQryString=enUtils.qryStringFromArray(extraQryString);
         path+="&"+extraQryString;
      }
      //run - use hidden frame
      if(!win.enUtils.isExecAsync("fraExec",retryIfBusy))
      {
         win.enUtils.execAsync("fraExec",path);
      }
      else
      {
         //resqedule
         var timeoutFn="enApplication.reloadCell("+cellId+",true";
         if(!enUtils.isEmpty(extraQryString))timeoutFn+=",null,'"+extraQryString+"'";
         timeoutFn+=");";
         win.setTimeout(timeoutFn,enUtils.enParseInt(Math.random()*100));
      }
   }
   this.reloadCell=reloadCell;
   
   /*
      reload cell call back function
      params:
         newEl - new element to use
         elId - id of element to refresh
         clone - clone the new element? (def false)
   */
   var reloadCellCallBack=function(newEl,elId,clone)
   {
      var el=enUtils.objectOrGetId(elId);
      if(enUtils.isEmpty(el) || enUtils.isEmpty(newEl))return;
      //the following runs on ns only when dealing with different frames
      if(enBS.ns6up)
      {
         if(clone) el.parentNode.replaceChild(newEl.cloneNode(true),el);
         else el.parentNode.replaceChild(newEl,el);
      }
      else el.innerHTML=newEl.innerHTML;
   }
   this.reloadCellCallBack=reloadCellCallBack;

   /*
      reload home page component by zone name
      if called from Main Focus or popup - find Home Page - the main window
      params:
         zoneName - zone to reload cells for
   */
   var reloadHomePageCompByZone=function(zoneName)
   {
      if(enUtils.isEmpty(zoneName))return;
      //locate main window
      var win=window.top;
      if(!enUtils.isEmpty(window.top.opener))
         win=window.top.opener.top;
      //reload
      if(win.enApplication)
         win.enApplication.reloadCell(win.enApplication.getCellsByZone(zoneName));
   }
   this.reloadHomePageCompByZone=reloadHomePageCompByZone;
   
   /*
      send page tp a friend
      params:
         win - window to send
         cell - send cell and not page (def false)
   */
   var openSendToFriend=function(win,cell)
   {
      //check biz rule
      if(!cell && !global.sendToFriend || cell && !global.sendToFriendComp)return;
      
      if(enUtils.isEmpty(win))win=window;
      //path to popup
      var path="en.jsp?enPage=PopupPage&enInfolet=Send/sendPage.jsp";
      var url="";
      var title="";
      var cellId="";
      if(cell)
      {   
         //cell mode
         path=enUtils.addQueryStringParam(path,"enaMode","cell");
         //get clicked cell id and title
         var srcClickElmnt=global.enSrcElmntToMove;
         if(enUtils.isEmpty(srcClickElmnt))return;
         cellId=srcClickElmnt.getAttribute("componentIndex");
         title=srcClickElmnt.getAttribute("enComponentTitle");
         var clsSuffix=srcClickElmnt.getAttribute("enComponentClassSuffix");
         if(!enUtils.isInteger(cellId))return;
         //get mesures
         var absPos=enUtils.elmntAbsPos("tdComponentBody"+cellId);
         var cellWidth=Math.max(280,absPos.width);
         //get current page
         var page=global.currentPageName;
         //build url
         url=enUtils.addQueryStringParam(enUtils.getBaseUrl()+"bin/en.jsp","enPage",page);
         url=enUtils.addQueryStringParam(url,"enaMode","sent");
         url=enUtils.addQueryStringParam(url,"enaCellId",cellId);
         url=enUtils.addQueryStringParam(url,"enaCellWidth",cellWidth);
         url=enUtils.addQueryStringParam(url,"enaCellClassSuffix",clsSuffix);
      }
      else
      {
         url=win.location.href;
         title=win.document.title;
      }
      
      path=enUtils.addQueryStringParam(path,"enaSendUrl",enUtils.enEscape(url));
      path=enUtils.addQueryStringParam(path,"enaSendTitle",enUtils.enEscape(title));

      enUtils.openPopupWindow(path,"enSendWin");
   }
   this.openSendToFriend=openSendToFriend;
            
   /*---------------------------------------------------------------------------------------
      Hirarchic tree
   ---------------------------------------------------------------------------------------*/   
   /*
   treeNodeClick   change look for picked and put its system name & title in a window variable 
               (should be kept in enNodeSysName att)
   for use with a collapsing tree (each node should be in a span element)
   parameters:   
      elmnt : the clicked span
      divContainer : the top div that holds the tree
      classSuffix : css classes suffix
      multi : if true will not clear all others select (def: false)
   */
   var treeNodeClick=function(elmnt,divContainer,classSuffix,multi)
   {
      if(!enUtils.isSet(multi))multi=false;
      elmnt=enUtils.objectOrGetId(elmnt);
      divContainer=enUtils.objectOrGetId(divContainer);
      var nodeSysName=elmnt.getAttribute("enNodeSysName");
      var nodeTitle="";
      //get the span text node
      for(i=0;i<elmnt.childNodes.length;i++)
      {
         if(elmnt.childNodes[i].nodeType==3)nodeTitle=elmnt.childNodes[i].nodeValue
      }
      var nodeTitle=enUtils.trim(nodeTitle);
      var selectedClassName='treeNodeSelected'+enUtils.ntz(classSuffix);
      if(elmnt.className==selectedClassName)
      {
         if(!multi)return;
         else//unselect it and remove it from pickedNodeSysName
         {
            var usSelectedClassName='treeNode'+enUtils.ntz(classSuffix);
            elmnt.className=usSelectedClassName;
            //remove sysname
            var selected=divContainer.getAttribute('pickedNodeSysName');
            var idx=selected.indexOf(","+nodeSysName+",");
            if(idx==-1)//in the end/or begining
            {
               if(enUtils.endsWith(selected,","+nodeSysName))
               {
                  selected=selected.substr(0,selected.length-(nodeSysName.length+1));
               }
               else if(enUtils.startsWith(selected,nodeSysName))//begining
               {
                  if(selected==nodeSysName)
                     selected="";
                  else
                     selected=selected.substr(nodeSysName.length+1);
               }
            }
            else//in the middle
            {
               selected=selected.substr(0,idx)+selected.substr(idx+1+nodeSysName.length);
            }
            divContainer.setAttribute('pickedNodeSysName',selected);
            //remove title
            var selectedTitles=divContainer.getAttribute('pickedNodeTitle');
            idx=selectedTitles.indexOf(","+nodeTitle+",");
            if(idx==-1)//in the end/or begining
            {
               if(enUtils.endsWith(selectedTitles,","+nodeTitle))
               {
                  selectedTitles=selectedTitles.substr(0,selectedTitles.length-(nodeTitle.length+1));
               }
               else if(enUtils.startsWith(selectedTitles,nodeTitle))//begining
               {
                  if(selectedTitles==nodeTitle)
                     selectedTitles="";
                  else
                     selectedTitles=selectedTitles.substr(nodeTitle.length+1);
               }
            }
            else//in the middle
            {
               selectedTitles=selectedTitles.substr(0,idx)+selectedTitles.substr(idx+1+nodeTitle.length);
            }
            divContainer.setAttribute('pickedNodeTitle',selectedTitles);
            return;
         }
      }
      //unselect all
      if(!multi)
         treeNodeClearSelect(divContainer,classSuffix);
      //select elmnt + set picked element in divContainer
      elmnt.className=selectedClassName;   
      if(multi)
      {
         if(nodeSysName!="$ROOT$" && nodeSysName!="-1" && !enUtils.isEmpty(nodeSysName))
         {
            var selected=enUtils.ntz(divContainer.getAttribute('pickedNodeSysName'));
            if(!enUtils.isEmpty(selected))selected+=",";
            selected+=nodeSysName;
            divContainer.setAttribute('pickedNodeSysName',selected);
            var selectedTitles=enUtils.ntz(divContainer.getAttribute('pickedNodeTitle'));
            if(!enUtils.isEmpty(selectedTitles))selectedTitles+=",";
            selectedTitles+=nodeTitle;
            divContainer.setAttribute('pickedNodeTitle',selectedTitles); 
         }
      }
      else
      {
         divContainer.setAttribute('pickedNodeSysName',nodeSysName);
         divContainer.setAttribute('pickedNodeTitle',nodeTitle); 
      }
   }
   this.treeNodeClick=treeNodeClick;
   /*
   treeNodeClearSelect   unslect all nods in a tree.
   for use with a collapsing tree (each node should be in a span element)
   parameters:   
      divContainer : the top div that holds the tree
      classSuffix : css classes suffix
   */
   var treeNodeClearSelect=function(divContainer,classSuffix)
   {
      var selectedClassName='treeNodeSelected'+enUtils.ntz(classSuffix);
      var usSelectedClassName='treeNode'+enUtils.ntz(classSuffix);
      divContainer=enUtils.objectOrGetId(divContainer);
      var spansCol=divContainer.getElementsByTagName("SPAN");
      //unselect all
      for(var i=0;i<spansCol.length;i++)
      {
         if(spansCol[i].className==selectedClassName)spansCol[i].className=usSelectedClassName;
      }
      divContainer.setAttribute('pickedNodeSysName',"");
      divContainer.setAttribute('pickedNodeTitle',"");
   }
   this.treeNodeClearSelect=treeNodeClearSelect;
   
   /*
      switch the icon form '+' to '-' OR from '-' to '+'
      params:
         img - the image Element
         showOrHide - optional show or hide flag (true (def) / false)
   */

   var elmntToggleShowHide=function (img,showOrHide)
   {
      if(!enUtils.isSet(img))return;
      img=enUtils.objectOrGetId(img);
      if(enUtils.isEmpty(img))return;
      var altPlus=enMsg.get("enApplication.expand");
      var altMinus=enMsg.get("enApplication.collapse");
      
      var imgUrl,imgPath,imgSplit,imgName,imgAlt;
      imgUrl = img.src;
      imgPath=enUtils.getFolderFromUrl(imgUrl);
      imgName=enUtils.getFileFromUrl(imgUrl);

      imgAlt = img.alt ;
      if(enUtils.isSet(showOrHide))
      {
         if(showOrHide)
         {   
            imgName="collapse.gif"
            img.alt = altMinus ;
         }
         else
         {
            imgName="expand.gif"
            img.alt = altPlus ;
         }
      }   
      else
      {
         if(imgName=="expand.gif")
         {
            imgName="collapse.gif";
            img.alt = altMinus ;
            showOrHide=true;
         }   
         else
         {
            imgName="expand.gif";
            img.alt = altPlus ;   
            showOrHide=false;
         }   
      }   
      img.src = imgPath+"/"+imgName ;
      
      //show / hide related gif
      var showHideDiv=img.getAttribute("enRelItemID");
      showHideDiv=enUtils.objectOrGetId(showHideDiv);
      if(!enUtils.isEmpty(showHideDiv))
         enUtils.elmntShowHide(showHideDiv,showOrHide);   
   }
   //expose
   this.elmntToggleShowHide=elmntToggleShowHide;

   /*
      Open or Close all the tree in one click
      params:
         flag - if "0" the tree should be close , else the tree should be open
            default:True
         containerElement - the element that contain the tag names (div,table etc.)
            default:document
         refTagName - the tag that is in container (img,td,tr etc.)
            default:img
         relAttributeName - the Attribute of the tag
            default:enRelItem
            
         sample: onclick="elmntExpandOrCollapseTree(true,divID)"   
   */
   var elmntExpandOrCollapseTree=function (flag,containerElement,refTagName,relAttributeName)
   //var elmntCollapseTree=function (oElement)
   {
         //set default values 
         if(!enUtils.isSet(flag)) flag=true; 
         if(enUtils.isEmpty(containerElement)) containerElement="document"; 
         if(enUtils.isEmpty(refTagName)) refTagName="img";
         if(enUtils.isEmpty(relAttributeName)) relAttributeName="enRelItemID";
         //end of "set default values"
         containerElement = enUtils.objectOrGetId(containerElement);
         var imagesArray=containerElement.getElementsByTagName(refTagName);
         for(var i=0;i<imagesArray.length;i++)
         {
            if(!enUtils.isEmpty(imagesArray[i].getAttribute(relAttributeName)))
            {
               elmntToggleShowHide(imagesArray[i],flag);
            }   
         }
   }
   //expose
   this.elmntExpandOrCollapseTree=elmntExpandOrCollapseTree;
   /*
      reloadChildrenNodes: insert next level nodes
      params:
         newEl - new element to use
         elId - id of element to refresh
         clone - clone the new element? (def false)
   */
   var reloadChildrenNodes=function(newEl,elId,clone)
   {
      var el=enUtils.objectOrGetId(elId);
      if(enUtils.isEmpty(el) || enUtils.isEmpty(newEl))return;
      //the following runs on ns only when dealing with different frames
      /*if(enBS.ns6up)
      {
         if(clone) el.parentNode.replaceChild(newEl.cloneNode(true),el);
         //else el.parentNode.replaceChild(newEl,el);
         else
         {   
            var parent=el.parentNode;
            parent.appendChild(newEl);
            //alert("stop");
            var x;
            for(i=0;i<10000;i++){x=i;}
            parent.removeChild(el);
         }
         
      }*/
      else el.innerHTML=newEl.innerHTML;
   }
   this.reloadChildrenNodes=reloadChildrenNodes;
   //------------------------
   //ENUITree methods
   //------------------------
   /*
   * retrievs an object representing a node that exposes the foillowing methods:
   *   getAttribute: get an attribute from the div container element
   *   setAttribute: get an attribute to the div container element
   *   getCascadeAttribute: get an attribute cascading value when searched in the container div, image el, span el.
   *   getNodeName: get the node name
   *   getNodeTitle: get the node title
   *   getChidrenNo: get the node number of children nodes
   *   isChildLoaded: is the children nodes have been losaded to the page
   *   setChildLoaded: mark the node that its child container was loaded to the page
   *   getTreeName: get the tree name
   *   getTreePrefix: get the tree elements pre fix
   *   isOpen:   is the child container is visible
   *   setIsOpen: sets the node isOpen attribute
   *   getConDivEl: get the container DIV element.
   *   getSpanEl: get the SPAN element.
   *   getIconEl: get the icon elemenet (IMG type)
   *   getImageEl: get the IMG element.
   *   getChildDivEl: get the childs container div element.
   *   getRootNode: get the tree root node ENUITreeNode object 
   *   getTreeNode: get any other tree node by its name
   *   getSelectedNames: gets the selected names list
   *   getSelectedName: get the first selected item's name
   *   getSelectedTitles: gets the selected titles list
   *   getSelectedTitle: get the first selected item's title
   * Params: 
   *   el - one of the following: div container, image or span elements.
   * Return: 
   *   a treeNode object
   */
   var getENUITreeNode   = function (el)
   {
      el=enUtils.objectOrGetId(el);
      if(!el)return null;
      var enTreeNode=new Object();
      enTreeNode.type="enUITreeNode";
      var img,spn,childDiv,tmp;
      //get reference to container div element
      var div=el;
      while(div.nodeName!="DIV")
      {
         div=div.parentNode;
         if(div.nodeName=="BODY")return null
      }
      //get reference to all other elements
      for(var i=0;i<div.childNodes.length;i++)
      {
         tmp=div.childNodes[i];
         if(tmp.nodeName=="IMG")   img=tmp;
         else if(tmp.nodeName=="SPAN")spn=tmp;
         else if(tmp.nodeName=="DIV")childDiv=tmp;
      }
      /** Private ENTreeNode methods **/
      var _getAttribute=function(attr){return div.getAttribute(attr);}
      var _setAttribute=function(name,value){return div.setAttribute(name,value);}
      var _getCascadeAttribute=function(attr)
      {
         var attrVal="";
         if(!enUtils.isEmpty(div))
         {
            attrVal=div.getAttribute(attr);
         }
         if(enUtils.isEmpty(attrVal) && !enUtils.isEmpty(img))
         {
            img.getAttribute(attr)
         }
         if(enUtils.isEmpty(attrVal) && !enUtils.isEmpty(spn))
         {
            spn.getAttribute(attr)
         }
         return attrVal;
      }
      var _getNodeName=function(){return _getCascadeAttribute("entNodeName");}
      var _getNodeTitle=function()
      {
         for(var i=0;i<spn.childNodes.length;i++)
         {
            if(spn.childNodes[i].nodeType==3)return enUtils.trim(spn.childNodes[i].nodeValue);
         }
         return "";
      }
      var _getChidrenNo=function(){return enUtils.enParseInt(_getCascadeAttribute("entChildren"));}
      var _getTreeName=function(){return _getAttribute("entTreeName");}
      var _getTreePrefix=function(){return _getAttribute("entTreePreFix");}
      var _isOpen=function(){return enUtils.toBoolean(_getAttribute("entIsOpen"));}
      var _setIsOpen=function(status){return _setAttribute("entIsOpen",status);}
      var _isChildLoaded=function(){return enUtils.toBoolean(_getAttribute("entChildLoaded"));}
      var _setChildLoaded=function(){return _setAttribute("entChildLoaded",true);}
      var _getConDivEl=function(){return div;}
      var _getSpanEl=function(){return spn;}
      var _getIconEl=function()
      {
         for(var i=0;i<spn.childNodes.length;i++)
         {
            if(spn.childNodes[i].nodeName=="IMG")return spn.childNodes[i];
         }
         return null;
      }
      var _getImageEl=function(){return img;}
      var _getChildDivEl=function(){return childDiv;}
      var _getRootNode=function(){return _getTreeNode(_getTreeName());}
      var _getTreeNode=function(name){return getENUITreeNode(_getTreePrefix()+name+"Div");}
      var _getSelectedNodes=function()
      {
         var selected=_getSelectedNames();
         var selArr=selected.split(",");
         for(var i=0;i<selArr.length;i++)
            selArr[i]=_getTreeNode(selArr[i]);
         return selArr;
      }
      var _getSelectedNode=function(){return _getTreeNode(_getSelectedName());}
      var _getSelectedNames=function()
      {
         var selected="";
         var rootNode= _getRootNode();
         if(!enUtils.isEmpty(rootNode))selected=rootNode.getAttribute("pickedNodeSysName");
         return selected;
      }
      var _getSelectedName=function()
      {
         var selected=_getSelectedNames();
         if(enUtils.isEmpty(selected))return selected
         var selArr=selected.split(",");
         return selArr[0]
      }
      var _getSelectedTitles=function()
      {
         var selected="";
         var rootNode= _getRootNode();
         if(!enUtils.isEmpty(rootNode))selected=rootNode.getAttribute("pickedNodeTitle");
         return selected;
      }
      var _getSelectedTitle=function()
      {
         var selected=_getSelectedTitles();
         if(enUtils.isEmpty(selected))return selected
         var selArr=selected.split(",");
         return selArr[0]
      }
      //expose methods
      enTreeNode.getAttribute=_getAttribute;
      enTreeNode.setAttribute=_setAttribute
      enTreeNode.getCascadeAttribute=_getCascadeAttribute;
      enTreeNode.getNodeName=_getNodeName;
      enTreeNode.getNodeTitle=_getNodeTitle;
      enTreeNode.getChidrenNo=_getChidrenNo;
      enTreeNode.isChildLoaded=_isChildLoaded;
      enTreeNode.setChildLoaded=_setChildLoaded;
      enTreeNode.getTreeName=_getTreeName;
      enTreeNode.getTreePrefix=_getTreePrefix;
      enTreeNode.isOpen=_isOpen;
      enTreeNode.setIsOpen=_setIsOpen;
      enTreeNode.getConDivEl=_getConDivEl;
      enTreeNode.getSpanEl=_getSpanEl;
      enTreeNode.getIconEl=_getIconEl;
      enTreeNode.getImageEl=_getImageEl;
      enTreeNode.getChildDivEl=_getChildDivEl;
      enTreeNode.getRootNode=_getRootNode;
      enTreeNode.getTreeNode=_getTreeNode;
      enTreeNode.getSelectedNodes=_getSelectedNodes;
      enTreeNode.getSelectedNode=_getSelectedNode;
      enTreeNode.getSelectedNames=_getSelectedNames;
      enTreeNode.getSelectedName=_getSelectedName;
      enTreeNode.getSelectedTitles=_getSelectedTitles;
      enTreeNode.getSelectedTitle=_getSelectedTitle;
      return enTreeNode;
   }
   this.getENUITreeNode=getENUITreeNode;
   /*
   * get the tree root node treNode object
   * params:
   *   prefix: tree pre fix
   *   nodeName: any of the tree nodes name
   *   if none specified, the first div with attribute 'entUITreeNode' or 'entUITreeRoot' is searched for
   * Return: 
   *   a treeNode object
   */
   var getENUITreeRootNode=function(prefix,nodeName)
   {
      var enTreeNode=null;
      if(enUtils.isEmpty(prefix) && enUtils.isEmpty(nodeName))
      {
         var divs=document.getElementsByTagName("DIV");
         if(!enUtils.isEmpty(divs))
         {
            for(var i=0;i<divs.length;i++)
            {
               if(enUtils.toBoolean(divs[i].getAttribute("entUITreeNode")) || enUtils.toBoolean(divs[i].getAttribute("entUITreeRoot")))
               {
                  enTreeNode=getENUITreeNode(divs[i]);
                  break;
               }
            }
         }
      }
      else
         enTreeNode=getENUITreeNode(prefix+nodeName+"Div");
         
      if(enUtils.isEmpty(enTreeNode))return null;
      enTreeNode=enTreeNode.getRootNode();
      return enTreeNode;
   }
   this.getENUITreeRootNode=getENUITreeRootNode;
   /*
   * default ENUITree pick function.
   * mark the picked node as selected
   * and put its name & title in the tree root node attributes 'pickedNodeSysName', 'pickedNodeTitle'
   * !! collect params from the tree root node: cssSuffix, multi select)
   * (for multi toggles select/unselect)
   * params:
   *         el: pick event's firing element
   *         treeNode: the node treeNode object
   */
   var pickENUITreeNode=function(el,treeNode)
   {
      var spn=treeNode.getSpanEl();
      var enRootNode=treeNode.getRootNode();
      var divContainer=enRootNode.getConDivEl();
      var classSuffix=enRootNode.getAttribute("entCssSuffix");
      var multi=enUtils.toBoolean(enRootNode.getAttribute("entMultiSlct"),false);
      var nodeSysName=enUtils.ntz(treeNode.getNodeName());
      var nodeTitle=enUtils.ntz(treeNode.getNodeTitle());
      var usSelectedClassName='treeNode'+enUtils.ntz(classSuffix);
      var selectedClassName='treeNodeSelected'+enUtils.ntz(classSuffix);
      //Click on a selected node
      if(spn.className==selectedClassName)
      {
         //not- mutli: ignore
         //if multi: unselect it and remove it from enRootNode
         if(multi)
         {
            spn.className=usSelectedClassName;
            //REMOVE NAME
            var selectedNames=enRootNode.getAttribute('pickedNodeSysName');
            var namesArr=selectedNames.split(",");
            selectedNames="";
            for(i=0;i<namesArr.length;i++)
            {
               if(enUtils.trim(namesArr[i])!=nodeSysName)selectedNames+=namesArr[i]+",";
            }
            selectedNames=selectedNames.substr(0,selectedNames.length-1);
            enRootNode.setAttribute('pickedNodeSysName',selectedNames);
            //REMOVE TITLE
            var selectedTitles=enRootNode.getAttribute('pickedNodeTitle');
            var titlesArr=selectedTitles.split(",");
            selectedTitles="";
            for(i=0;i<titlesArr.length;i++)
            {
               if(enUtils.trim(titlesArr[i])!=nodeTitle)selectedTitles+=titlesArr[i]+",";
            }
            selectedTitles=selectedTitles.substr(0,selectedTitles.length-1);
            enRootNode.setAttribute('pickedNodeTitle',selectedTitles);
         }
      }
      //Click on an unselected node
      else
      {
         if(!multi)enApplication.treeNodeClearSelect(divContainer,classSuffix);
         //select node + set picked node in enRootNode
         spn.className=selectedClassName;   
         if(multi)
         {
            var selectedNames=enUtils.ntz(enRootNode.getAttribute('pickedNodeSysName'));
            if(!enUtils.isEmpty(selectedNames))selectedNames+=",";
            selectedNames+=nodeSysName;
            enRootNode.setAttribute('pickedNodeSysName',selectedNames);
            var selectedTitles=enUtils.ntz(enRootNode.getAttribute('pickedNodeTitle'));
            if(!enUtils.isEmpty(selectedTitles))selectedTitles+=",";
            selectedTitles+=nodeTitle;
            enRootNode.setAttribute('pickedNodeTitle',selectedTitles); 
         }
         else
         {
            enRootNode.setAttribute('pickedNodeSysName',nodeSysName);
            enRootNode.setAttribute('pickedNodeTitle',nodeTitle); 
         }
      }
   }
   this.pickENUITreeNode=pickENUITreeNode;
   /*
   * default ENUITree expand function
   * expands/collapses the node's children nodes & mark it as opened/close
   * if this is expand and the children were not loaded to the page calls incUITreeExec.jsp
   * params:
   *         el: expand event's firing element
   *         treeNode: the node treeNode object
   *         ignoreExec: ignore execution
   */
   var expandENUITreeNode=function (el,treeNode,ignoreExec)
   {
      if(enUtils.isEmpty(ignoreExec))ignoreExec=false;
      //if proccessing return (try because text frame may be empty)
      try{
         if(!ignoreExec && enUtils.isExecAsync("fraExec",true,null,null,true,false))return;
      }catch(e){return;}
      if(treeNode.getChidrenNo()<=0)return;
      var nodeSysName=enUtils.ntz(treeNode.getNodeName());
      var imgEl=treeNode.getImageEl();
      var spnEl=treeNode.getSpanEl();
      var iconEl=treeNode.getIconEl();
      var childDivEl=treeNode.getChildDivEl();
      var closeAction=enUtils.toBoolean(treeNode.getAttribute("entIsOpen"))
      var childLoaded=enUtils.toBoolean(treeNode.getAttribute("entChildLoaded"))
      var iconClose=treeNode.getAttribute("entIconClose");
      var iconOpen=treeNode.getAttribute("entIconOpen");
      var enRootNode=treeNode.getRootNode();
      var imgClose=enRootNode.getAttribute("entImgClose");
      var altClose=enMsg.get("enApplication.expand");
      var imgOpen=enRootNode.getAttribute("entImgOpen");
      var altOpen=enMsg.get("enApplication.collapse");
      //change current open ststus
      treeNode.setIsOpen(!closeAction);
      //replace close/open images
      if(imgEl)
      {
         if(!enUtils.isEmpty(imgClose) && !enUtils.isEmpty(imgOpen))
            imgEl.src=closeAction?imgClose:imgOpen;
         imgEl.alt=closeAction?altClose:altOpen;
      }
      //replace open close icon
      if(iconEl && !enUtils.isEmpty(iconClose) && !enUtils.isEmpty(iconOpen))
      {
         iconEl.src=closeAction?iconClose:iconOpen;
      }
      //show hide childs div
      //THIS HAS A BUG: EREZ H
      //enUtils.elmntShowHide(childDivEl);
      childDivEl.className=closeAction?"hiddenEl":"";      
      //reload child nodes if necessary
      if(!closeAction && !childLoaded)
      {
         var treePreFix=treeNode.getAttribute("entTreePreFix");
         var frm=document.forms[treePreFix+"frmEnUITreeUtils"];
         if(!frm)return;
         var actionCtrl=frm.elements["enaUITreeAction"];
         var expandNodeCtrl=frm.elements["enaUITreeExpandedNode"];
         var cbfnCtrl=frm.elements["cbfn"];
         var subEntityTypeCtrl=frm.elements["entSubEntityType"];
         enUtils.setValueOf(actionCtrl,"enaExpandNode");
         enUtils.setValueOf(expandNodeCtrl,nodeSysName);
         enUtils.setValueOf(cbfnCtrl,"enApplication.genENUITreeNodeCbfn");
         //put sub entity type (empty if root, for colision of cat & class name)
         if(enUtils.toBoolean(treeNode.getAttribute("entUITreeRoot")))
            enUtils.setValueOf(subEntityTypeCtrl,"");
         else
            enUtils.setValueOf(subEntityTypeCtrl,enUtils.ntz(treeNode.getAttribute("entSubEntityType")));
         var useProgress=global.useProgressBar && enUtils.toBoolean(enRootNode.getAttribute("entUseProgExpand"));
         if(!enUtils.isExecAsync("fraExec",false,null,null,false,useProgress))frm.submit();
      }
   }
   this.expandENUITreeNode=expandENUITreeNode;
   /*
   * default ENUITree user filter function
   * params:
   *         frm: search form element
   *         act: filter type (search,segment)
   */
   var filterENUITree=function(frm,act)
   {
      if(!frm)return;
      var actionCtrl=frm.elements["enaUITreeAction"];//frm.elements[treePreFix+"enaUITreeAction"];
      var cbfnCtrl=frm.elements["cbfn"];
      enUtils.setValueOf(actionCtrl,act);
      enUtils.setValueOf(cbfnCtrl,"enApplication.genENUITreeNodeCbfn");
      var treePrefix=frm.getAttribute("entFrmTreePrefix");
      var treeName=frm.getAttribute("entFrmTreeName");
      var enRootNode=getENUITreeNode(treePrefix+treeName+"Div");
      var useProgress=global.useProgressBar
      if(enRootNode!=null)useProgress=useProgress && enUtils.toBoolean(enRootNode.getAttribute("entUseProgFilter"));
      if(!enUtils.isExecAsync("fraExec",false,null,null,false,useProgress))frm.submit();
   }
   this.filterENUITree=filterENUITree;
   /*
   * full expand function (serevr/client side opening)
   * params:
   *         frm: search form element
   *         preSlctCtrlName: the name of the preselected control (to change the tree state to the last selected)
   */
   var fullexpandENUITree=function(frm,preSlctCtrlName)
   {
      if(!frm)return;
      var actionCtrl=frm.elements["enaUITreeAction"];//frm.elements[treePreFix+"enaUITreeAction"];
      var cbfnCtrl=frm.elements["cbfn"];
      enUtils.setValueOf(actionCtrl,"enaFullExpand");
      enUtils.setValueOf(cbfnCtrl,"enApplication.genENUITreeNodeCbfn");
      var treePrefix=frm.getAttribute("entFrmTreePrefix");
      var treeName=frm.getAttribute("entFrmTreeName");
      var enRootNode=getENUITreeNode(treePrefix+treeName+"Div");
      var useProgress=global.useProgressBar
      if(enRootNode!=null)useProgress=useProgress && enUtils.toBoolean(enRootNode.getAttribute("entUseProgFullExpand"));
      //check if allready full expanded
      if(enUtils.toBoolean(enRootNode.getAttribute("entFullExpanded")))
      {
         if(useProgress){showProgressaBar();}
         fullExpndCollpse(enRootNode,true);
         if(useProgress){hideProgressaBar();}
      }
      else if(!enUtils.isExecAsync("fraExec",false,null,null,false,useProgress))
      {
         enRootNode.setAttribute("entFullExpanded",true);
         //handle preselected & search that might change
         var preSlctVtrl=frm.elements[preSlctCtrlName];
         if(preSlctVtrl)enUtils.setValueOf(preSlctVtrl,enRootNode.getSelectedNames());
         frm.submit();
      }
   }
   this.fullexpandENUITree=fullexpandENUITree;
   /*
   * full collpase function (client side closing)
   * params:
   *         frm: search form element
   *         isExpand: true->expand, false->collapse
   */
   var collpaseENUITree=function(frm)
   {
      if(!frm)return;
      var treePrefix=frm.getAttribute("entFrmTreePrefix");
      var treeName=frm.getAttribute("entFrmTreeName");
      var enRootNode=getENUITreeNode(treePrefix+treeName+"Div");
      var useProgress=global.useProgressBar
      if(enRootNode!=null)useProgress=useProgress && enUtils.toBoolean(enRootNode.getAttribute("entUseProgExpand"));
      //start progeress bar
      var useProgress=global.useProgressBar
      if(enRootNode!=null)useProgress=useProgress && enUtils.toBoolean(enRootNode.getAttribute("entUseProgFullExpand"));
      if(useProgress){showProgressaBar();}
      fullExpndCollpse(enRootNode,false);
      //stop progress bar
      if( useProgress){hideProgressaBar()};
   }
   this.collpaseENUITree=collpaseENUITree;
   /*
   * PRIVATE !!!
   * full expand/collapse client side
   */
   var fullExpndCollpse=function(enRootNode,expand)
   {
      //go over all nodes and expand//collapse them...
      if(enRootNode==null)return;
      var rootChildsContainer=enRootNode.getChildDivEl();
      var childs = rootChildsContainer.getElementsByTagName("div");
      var div,treeNode;
      for(i=0;i<childs.length;i++)
      {
         div=childs[i];
         nodeName=div.getAttribute("entNodeName");
         if(enUtils.isEmpty(nodeName))continue;
         treeNode=getENUITreeNode(div);
         if(!treeNode)continue;
         if(enUtils.toBoolean(treeNode.getAttribute("entIsOpen"))^expand)
         {
            expandENUITreeNode(null,treeNode,true);
         }
      }
      if(enUtils.toBoolean(enRootNode.getAttribute("entIsOpen"))^expand)
      {   
         expandENUITreeNode(null,enRootNode,true);
      }
   }
   
   /*
   * default ENUITree callback function replaces 2 nodes' childs
   * loads the children nodes from the fraExec to the page, marks the node childLoaded as true.
   * and activates enUtils.defaultCallBack.
   * params:
   *      prm: the returned object from the doAction page
   */
   var genENUITreeNodeCbfn=function (prm)
   {
      //get treeNode objects for the nodes
      var closedNode=prm.closedNode;
      var openedNode=prm.openedNode;
      if(!enUtils.isEmpty(closedNode) && !enUtils.isEmpty(openedNode))
      {
         var enRootNode=closedNode.getRootNode();
         var treePreFix=enRootNode.getAttribute("entTreePreFix");
         var frm=document.forms[treePreFix+"frmEnUITreeUtils"];
         if(prm.status)
         {
            var closedDiv=closedNode.getChildDivEl();
            var openedDiv=openedNode.getChildDivEl();
            if(closedDiv && openedDiv)
            {
               closedDiv.innerHTML=openedDiv.innerHTML;
               closedNode.setChildLoaded();
               if(!enUtils.toBoolean(closedNode.getAttribute("entIsOpen")))
               {
                  expandENUITreeNode(null,closedNode,true);
               }
            }
            if(frm)
            {
               //---   search actions   ---
               //update the search hidden input to the last search
               var searchCtrl=frm.elements[prm.ctrlSearch];
               if(searchCtrl)
               {
                  searchCtrl.value=prm.searchStr;
               }
               //---   segments action   ---
               //handle current segment
               var segIdCtrl=frm.elements[prm.ctrlSegId];
               if(segIdCtrl)
               {
                  if(!prm.segAct)segIdCtrl.value=0;
                  else if(prm.segAct=='prev' && segIdCtrl.value>0)segIdCtrl.value--;
                  else if(prm.segAct=='next')segIdCtrl.value++;
               }
               //handle total segments (if was cganged)
               var totSegsCtrl=frm.elements[prm.ctrlTotSegs];
               if(totSegsCtrl)
               {
                  if(!enUtils.isEmpty(prm.totSegs))
                     totSegsCtrl.value=enUtils.enParseInt(prm.totSegs);
               }
               //handle prev & next images
               handleSegmentsENUITree(frm,prm);
            }
         }
         else
         {
            //if could not open the children, mark as unclosed!!
            openedNode.setIsOpen(false);
         }
         //clear only when filtering
         if(prm.clearSelect)
         {
            var divContainer=enRootNode.getConDivEl(); 
            var classSuffix=enRootNode.getAttribute("entCssSuffix");
            treeNodeClearSelect(divContainer,classSuffix);
         }
      }
      enUtils.defaultCallBack(prm);
   }
   this.genENUITreeNodeCbfn=genENUITreeNodeCbfn;
   /*
   * chenges the tree multi select behavior
   * when changed from multi to single it will clear current selection!
   * params:
   *      chk: checkbox that indicates the multi mode (check=multi)
   *          has attributes treePrefix & treeName in order to fetch the tree reet node.
   */
   var handleMultiENUITree=function(chk)
   {
      var frm = chk.form;
      if(!frm)return;
      var multi=chk.checked;
      var treePrefix=frm.getAttribute("entFrmTreePrefix");
      var treeName=frm.getAttribute("entFrmTreeName");
      var enRootNode=getENUITreeNode(treePrefix+treeName+"Div");
      var divContainer=enRootNode.getConDivEl();
      var classSuffix=enRootNode.getAttribute("entCssSuffix");
      //clear only when moving from multi to not
      if(!multi)treeNodeClearSelect(divContainer,classSuffix);
      enRootNode.setAttribute("entMultiSlct",multi);
   }
   this.handleMultiENUITree=handleMultiENUITree;
   /**
   * Enables/disables prev & next images according to the current segment & total segments
   * params:
   *   frm: the segments form
   */
   var handleSegmentsENUITree=function(frm,prm)
   {
      if(!frm)return;
      var treePrefix=enUtils.ntz(frm.getAttribute("entTreePrefix"));
      var imgPrev=document.getElementById(treePrefix+prm.ctrlImgPrev);
      var imgNext=document.getElementById(treePrefix+prm.ctrlImgNext);
      var currSegIdCtrl=frm.elements[prm.ctrlSegId];
      var totSegsCtrl=frm.elements[prm.ctrlTotSegs];
      if(!enUtils.isEmpty(imgPrev) && !enUtils.isEmpty(imgNext) 
         && !enUtils.isEmpty(currSegIdCtrl) && !enUtils.isEmpty(totSegsCtrl))
      {
         var currSegId=enUtils.enParseInt(currSegIdCtrl.value);
         var totSegs=enUtils.enParseInt(totSegsCtrl.value);
         //prev image
         var allowPrev=currSegId>0;
         imgPrev.src=allowPrev?imgPrev.getAttribute("srcReg"):imgPrev.getAttribute("srcDis");
         imgPrev.className=allowPrev?"clickMe":"";
         imgPrev.disabled=!allowPrev;
         //next image
         var allowNext=currSegId+1<totSegs;
         imgNext.src=allowNext?imgNext.getAttribute("srcReg"):imgNext.getAttribute("srcDis");
         imgNext.className=allowNext?"clickMe":"";
         imgNext.disabled=!allowNext;
      }
   }
   this.handleSegmentsENUITree=handleSegmentsENUITree;
   /*
   * Converts FS pathe to HTML compatible name and backwards
   * params:
   *   path:    path to convert
   *   toHTML:   to HTML or back to path
   */
   var convertFSPath=function(path,toHTML)
   {
      var HTML_REPLACER="*";
      var FORSLASH="/";
      var BACKSLASH="\\";
      if(enUtils.isEmpty(path))return path;
      if(!enUtils.isSet(toHTML))toHTML=(path.indexOf(HTML_REPLACER)==-1);
      //convert to forward slash
      path = path.replace(new RegExp("\\"+BACKSLASH,"g"),FORSLASH);
      if(toHTML)
      {
         path = path.replace(new RegExp(FORSLASH,"g"),HTML_REPLACER);
      }
      else
      {
         path = path.replace(new RegExp("\\"+HTML_REPLACER,"g"),FORSLASH);
      }
      return path;
   }
   this.convertFSPath=convertFSPath;

   /**
   /*---------------------------------------------------------------------------------------
      form functions
   ---------------------------------------------------------------------------------------*/
   /*
      rowsBrwsrDuplicate: 
            desc:duplicate a form row.
      page structure:
            Build a div with all the form row elemnts (with id,name events will work only in IE)
            If you want a delete element(button,image...) add it as well with out the delete event!
            The id/name encoding uses a default seperator "@" ,
               in order to change it give the delete button attribute: enSeparator
               if you don;t have delete button (central deletion) give the div this attribute.
            The delete button should gave attribute: enRowsElmnts with all the elements id's seperated by 
               the right seperator.
      parameters:
         frm: object with the following properties:
                  frmId: name/id of form to add the elements
                  insertBeforeEl: before this button the element will be inserted (def= end of form)
         baseDiv: div containing the form elements
         delBtn: object with the following properties:
                  delBtnId: the id of the delete element
                  delBtnEvent: event of the delBtnId to delete on (def="click")
                  delBtnFunction: delete function to attach (def=rowsBrwsrDelete)
         codeName:   Do we code the name true/false(def)
   */
   var rowsBrwsrDuplicate=function (frm,baseDiv,delBtn,codeName){
      if(!enUtils.isObject(frm) && !enUtils.isArray(frm))return false;
      //get form ref
      var frmElmnt=enUtils.objectOrGetId(frm.frmId);
      //try by name
      if(!frmElmnt)frmElmnt=enUtils.objectOrGetId(frm.frmId,"form");
      if(!frmElmnt)return false;
      
      var baseDivElmnt=enUtils.objectOrGetId(baseDiv);
      //increment counter, if not exist initial it
      if(!enUtils.isSet(baseDivElmnt.lastTrId)) {
         baseDivElmnt.lastTrId=0;
      }
      else baseDivElmnt.lastTrId++;
      //look for seperator in: delBtn/div (att: enSeparator) else def="@"
      var seperator="";
      //get delete button info
      var delId="";var delEvnt="";var delFn="";
      if(enUtils.isSet(delBtn))
      {
         delId=delBtn.delBtnId;
         delEvnt=enUtils.isEmpty(delBtn.delBtnEvent)?"click":delBtn.delBtnEvent;
         delFn=enUtils.isEmpty(delBtn.delBtnFunction)?rowsBrwsrDelete:delBtn.delBtnFunction;
         //find seperator
         var delBtn=enUtils.objectOrGetId(delId);
         seperator=(!delBtn)?"":delBtn.getAttribute("enSeparator");
      }
      //if we don't have seperator goto div
      if(enUtils.isEmpty(seperator)){
         seperator=(!baseDivElmnt)?"":baseDivElmnt.getAttribute("enSeparator");
      }
      if(enUtils.isEmpty(seperator)) seperator="@";
      //add base div elements (check if it the delBtn, and add event if so)
      var lastBtn="";
      if(enUtils.isSet(frm.insertBeforeEl)) lastBtn=enUtils.objectOrGetId(frm.insertBeforeEl);
      //run over all div elements and add them to the form   
      var objElmnt=null;
      for(var i=0;i<baseDivElmnt.childNodes.length;i++)
      {
         if(baseDivElmnt.childNodes[i].nodeType==1)
         {
            objElmnt=baseDivElmnt.childNodes[i].cloneNode(true);
            if(enUtils.isEmpty(lastBtn))
               frmElmnt.appendChild(objElmnt);
            else
               frmElmnt.insertBefore(objElmnt,lastBtn);
            //if delete button add event
            if(objElmnt.id==delId){
               enUtils.evtAddEvent(objElmnt,delEvnt,delFn);
            }
            objElmnt.id=objElmnt.id+seperator+baseDivElmnt.lastTrId;
            if(codeName) objElmnt.name=objElmnt.name+seperator+baseDivElmnt.lastTrId;
         }
      }
   }
   this.rowsBrwsrDuplicate=rowsBrwsrDuplicate;
   
   /*
      rowsBrwsrDelete:
         desc: will erase all form elemnts in the buttonDelete's "row"
      parameters: has no parameters (should be attached),
         but the event.target(source) should have attribute:enRowsElmnts with all the 
         form elemnents (seperated by the seperator, see  rowsBrwsrDuplicate())
   */
   var rowsBrwsrDelete=function (e){
      var evt=enUtils.evtGetCBEvent(e);
      delElmnt=evt.target;
      //find the seperator
      var seperator="";
      seperator=delElmnt.getAttribute("enSeparator");
      if(enUtils.isEmpty(seperator)) seperator="@";
      //get the row number to delete
      var deleteId=delElmnt.id.substr(delElmnt.id.indexOf(seperator)+1);
      //get from the delete button the id of the elmnts in the rows
      var elmntsArray=delElmnt.getAttribute("enRowsElmnts")
      if(enUtils.isEmpty(elmntsArray))return;
      elmntsArray=elmntsArray.split(seperator);
      //delete all the objects from the form
      var frmElmnt=delElmnt.parentNode;
      var objElmnt=null;
      for(var i=0;i<elmntsArray.length;i++)
      {
         objElmnt=enUtils.objectOrGetId(elmntsArray[i]+seperator+deleteId);
         if(typeof objElmnt=='object')frmElmnt.removeChild(objElmnt);
      }
      //remove delete button
      frmElmnt.removeChild(delElmnt);
   }
   this.rowsBrwsrDelete=rowsBrwsrDelete;

   /*---------------------------------------------------------------------------------------
      arrays functions
   ---------------------------------------------------------------------------------------*/
   
   /*
      remove an existing (database) row of elements
      if the row includes a file element - create a delete file input
      
      params:
         frm - form / name of form
         trId - tr id/reference
   */
   var arrayRemoveExistingRow=function(frm,tr)
   {
      frm=enUtils.objectOrGetId(frm,"form");
      if(enUtils.isEmpty(frm))return;
      tr=enUtils.objectOrGetId(tr);
      if(enUtils.isEmpty(tr))return;

      //get removed file element
      var ins=tr.getElementsByTagName("INPUT");
      var el,newEl;
      for(var i=0;i<ins.length;i++)
      {
         el=ins[i];
         //for each file input create a delete file input('DELETE_FILE_ATTRNAME_IX')
         if(el.type=="file")
         {
            newEl=document.createElement("INPUT");
            newEl.type="hidden";
            newEl.name="DELETE_FILE_"+el.name;
            newEl.value="1";
            frm.appendChild(newEl);
         }
      }
      //remove the row
      tr.parentNode.removeChild(tr);
   }
   this.arrayRemoveExistingRow=arrayRemoveExistingRow;
   
   /*
      handle array gaps
      go over the elements and hide empty ones (by nullifing their names)
      when items are related, check that all are not empty
      this function should be called before calling arrayHandleNames, after validation
      params:
         frm - form / name of form to handle
         attrName - attribute name (or an array of names) to handle
         alertUser - when false (default):fix mode - removes inconsistant elements
            else: alert mode - alerts the user
         msg - a message to use when alerting the user
   */
   var arrayHandleGaps=function(frm,attrName,alertUser,msg)
   {
      if(enUtils.isEmpty(frm) || enUtils.isEmpty(attrName))return false;
      //check if an array. if not - convert into an array   
      if(!enUtils.isArray(attrName))attrName=[attrName];
      var attrsLen=attrName.length;
      var elementsLen=0;
      var ok,emptyEl,el;
      
      //get form ref
      frm=enUtils.objectOrGetId(frm,"form");
      if(enUtils.isEmpty(frm))return false;
      
      //internal function to remove an element from all attributes
      var removeAttrsElement=function(ix)
      {
         //loop on attributes and remove
         for(var j=0;j<attrsLen;j++)
         {
            relEls[attrName[j]][ix].name=null;
         }
      }
      //internal function to alert the user
      var alertUserOnElement=function(el)
      {
         alert(msg);
         enUtils.elmntSelect(el);      
      }
      
      //build arrays to hold related elements and their indexes
      var relIxs=new Array();
      var relEls=new Array();
      for(var j=0;j<attrsLen;j++)
      {
         relIxs[attrName[j]]=0;
         relEls[attrName[j]]=new Array();
      }
      
      //fix inconsistant elements or alert user
      alertUser=(alertUser && attrsLen>1);
      if(alertUser)
      {
         if(enUtils.isEmpty(msg))msg=enMsg.get("enApplication.requiredValue");         
         /*
            here we need to check the gaps in existing elements as well
            we do not remove eleemnts, only alert the user
         */
         //find max index
         var maxIx=arrayGetAttrMaxIx(frm,attrName[0]);
         //if any
         for(var i=0;i<=maxIx;i++)
         {
            ok=false;
            emptyEl=null;
            //loop on attributes
            for(var j=0;j<attrsLen;j++)
            {
               el=frm.elements[attrName[j]+"_"+i];               
               if(enUtils.isEmpty(el))
               {
                  //assume all are missing
                  ok=false;
                  break;
               }
         
               //if any element is empty - remove it
               //an empty element has an empty value, or an attributr 'enNotEmpty' for type file
               if(el.type=='file' && el.getAttribute("enNotEmpty")!="true" || 
                  el.type!='file' && enUtils.isEmpty(enUtils.getValueOf(el)))
               {
                  if(emptyEl==null)emptyEl=el;
               }
               else
               {
                  ok=true;
               }
            }
            if(ok && emptyEl!=null)
            {
               alertUserOnElement(emptyEl);
               return false;
            }            
         }
      }   
            
      //handle dynamically created elements
      //loop on form elements and build related items array         
      for(var i=0;i<frm.elements.length;i++)
      {
         el=frm.elements[i];
         //check if element name is one we are looking for
         for(var j=0;j<attrsLen;j++)
         {
            if(el.name==attrName[j])
            {
               relEls[attrName[j]][relIxs[attrName[j]]++]=el;
               break;
            }
         }
      }
      elementsLen=relEls[attrName[0]].length;
         
      //loop on relEls and check elements consistency. remove empty gaps      
      for(var k=0;k<elementsLen;k++)
      {
         ok=false;
         emptyEl=null;
         //loop on attributes
         for(var i=0;i<attrsLen;i++)
         {
            el=relEls[attrName[i]][k];
            //if any element is empty - remove it
            if(enUtils.isEmpty(enUtils.getValueOf(el)))
            {
               if(alertUser)
               {
                  if(emptyEl==null)emptyEl=el;
               }
               else
               {
                  removeAttrsElement(k);
                  break;
               }
            }
            else
            {
               ok=true;
            }
         }      
         if(alertUser && ok && emptyEl!=null)
         {
            alertUserOnElement(emptyEl);
            return false;
         }
      }
      return true;
   }
   this.arrayHandleGaps=arrayHandleGaps;

   /*
      get max index of an array attribute control
      params:
         frm - form / name of form to handle
         attrName - attribute name to handle
      return:
         max ix in use
   */
   var arrayGetAttrMaxIx=function(frm,attrName)
   {
      frm=enUtils.objectOrGetId(frm,"form");
      if(enUtils.isEmpty(frm))return 0;
      var el,pos,ix,maxIx=-1;
      for(var i=0;i<frm.elements.length;i++)
      {
         el=frm.elements[i];
         if(!enUtils.isEmpty(el.name))
         {
            pos=el.name.indexOf(attrName+"_");
            if(pos==0)
            {
               ix=el.name.substring(pos+(attrName+"_").length);
               if(enUtils.isNum(ix)) if(maxIx<=ix)maxIx=ix;
            }
         }
      }
      return maxIx;
   }
   this.arrayGetAttrMaxIx=arrayGetAttrMaxIx;

   /*
      syncronize names in array of elements 
      finds gaps in name indexes and closes gaps.
      sets id to name (has to, otherwise the form.elements
         collection does not recognize the new name in ie)
         should be run after handling gaps
      params:
         frm - form / name of form to handle
         attrName - attribute names (one or an array) to sync   
   */
   /*
   var arraySyncNames=function(frm,attrName)
   {
      frm=enUtils.objectOrGetId(frm,"form");
      if(enUtils.isEmpty(frm))return;
      
      if(enUtils.isArray(attrName))
      {
         for(var i=0;i<attrName.length;i++) arraySyncNames(frm,attrName[i]);
         return;
      }
         
      //get max ix
      var maxIx=arrayGetAttrMaxIx(frm,attrName);
      var ix,notLast,newName;
      while(true)
      {
         notLast=false;
         //find first missing element with non empty ones after
         ix=null;
         for(var i=0;i<maxIx;i++)
         {
            if(enUtils.isEmpty(frm.elements[attrName+"_"+i]))
            {
               if(ix==null)ix=i;
            }
            //if empty element was already found and current element is non empty - break
            else if(ix!=null)notLast=true;
            if(notLast)break;
         }
         //if the empty element is the last one - break
         if(!notLast)break;
      
         //find elements with next ix and 
         var nextIx=ix+1;
         var el=frm.elements[attrName+"_"+nextIx++];
   
         while(!enUtils.isEmpty(el))
         {
            newName=attrName+"_"+(ix++);
            el.name=newName;
            el.id=newName;
            el=frm.elements[attrName+"_"+(nextIx++)];
         }
      }
   }
   this.arraySyncNames=arraySyncNames;
   */
   
   /*
      handle array names - assign new names to conform with arrays naming convention (ATT_NAME_i)
      make sure each array has at least one element,
      so when removing all elements the array is deleted by the engine
      this function should be the last to be called, after arrayHandleGaps and before submit
      params:
         frm - form / name of form to handle
         attrName - attribute name (or an array of names) to handle
   */
   var arrayHandleNames=function(frm,attrName)
   {
      frm=enUtils.objectOrGetId(frm,"form");
      if(enUtils.isEmpty(frm))return;
      if(enUtils.isArray(attrName))
      {
         for(var i=0;i<attrName.length;i++) arrayHandleNames(frm,attrName[i]);
         return;
      }
      
      //flag - any element found or created?
      var any=false;
      var el,maxIx=-1;
      //get index to start with
      maxIx=arrayGetAttrMaxIx(frm,attrName);
      //any found?
      any=(maxIx>-1);
      //inc
      maxIx++;
      
      //change elements names
      for(var i=0;i<frm.elements.length;i++)
      {
         el=frm.elements[i];
         if(el.name==attrName)
         {
            any=true;
            el.name=attrName+"_"+maxIx++;
         }
      }      
      //make sure each array has at least one element
      if(!any)
      {
         var newEl=document.createElement("INPUT");
         newEl.type="hidden";
         newEl.name=attrName+"_0";
         newEl.value="";
         frm.appendChild(newEl);
      }
   }
   this.arrayHandleNames=arrayHandleNames;
   
   /*
      converts elements arrays (name and value) to a querystring
      
      params:
         frm - form / name of form to handle
         attrName - attribute name of the element holding the name
         attrVal - attribute name of the element holding the value
         txt - input or id to place query string in
      returns:
         the query string
   */
   var arrayBuildQueryString=function(frm,attrName,attrVal,txt)
   {
      frm=enUtils.objectOrGetId(frm,"form");
      var o=new Array();
      var inames=0,ivals=0,el;
      //tmp arrays
      var names=new Array();
      var vals=new Array();
      for(var i=0;i<frm.elements.length;i++)
      {
         el=frm.elements[i];
         if(el.name==attrName)
         {            
            names[inames++]=enUtils.getValueOf(el);
         }
         else if(el.name==attrVal)
         {
            vals[ivals++]=enUtils.getValueOf(el);
         }
      }
      //check sync
      if(inames!=ivals)return "";
      //load into final array
      for(var i=0;i<names.length;i++)
      {
         o[i]=[names[i],vals[i]];
      }
      if(enUtils.isEmpty(o))return "";
      o=enUtils.qryStringFromArray(o);
      //add trailing &
      o+="&";
      if(!enUtils.isEmpty(txt))enUtils.setValueOf(enUtils.objectOrGetId(txt),o);
      return o;
   }
   this.arrayBuildQueryString=arrayBuildQueryString;
   
   /*
      build array that contain data about the new order of cells
   */
   
   var setUserCellsOrder=function()
   {
      var cellOrderArray = new Array() ;
      var ind=0;
      var numOfCols=0;
      var cellIdAttr=0;
      for(var i=0;i<global.zfMainArray.length;i++)
      {
         numOfCols = global.zfMainArray[i][4];
         //is dirty
         if(global.zfMainArray[i][1])
         {
            if(global.zfMainArray[i][3]==1) //structure policy - REGULAR
            {
               var trIndex=1,tdIndex=0,tblIndex=0 ,prefixId=global.zfMainArray[i][0];
               var fullObjId=prefixId+"@"+"0@"+trIndex+"@"+tdIndex ;
               var elTd = document.getElementById(fullObjId) ;
               for(var x=0;x<numOfCols;x++)
               {
                  tdIndex++;
                  trIndex=1;
                  fullObjId = prefixId+"@"+"0@"+trIndex+"@"+tdIndex;
                  tblIndex++;
                  elTd = document.getElementById(fullObjId) ;
                  while(!enUtils.isEmpty(elTd))
                  {
                     cellIdAttr=elTd.getAttribute("enPageCellId");
                     if(!enUtils.isEmpty(cellIdAttr))
                     {
                        if(!enUtils.isInArray(cellIdAttr,cellOrderArray))
                        {
                           cellOrderArray[ind] = cellIdAttr;
                        }
                     }   
                     fullObjId = prefixId+"@"+tblIndex+"@"+trIndex+"@"+"1";
                     trIndex++;
                     elTd = document.getElementById(fullObjId) ;
                     ind++;
                  }
               }   
            }
            if(global.zfMainArray[i][3]==2) //structure policy - GRID
            {
               var trIndex=1,tdIndex=1,tblIndex=0 ,prefixId=global.zfMainArray[i][0];
               var fullObjId=prefixId+"@"+"0@"+trIndex+"@"+tdIndex ;
               var elTd = document.getElementById(fullObjId) ;
               var fullObjId = prefixId+"@"+tblIndex+"@"+trIndex+"@"+tdIndex;
               var counter=0;
               while(!enUtils.isEmpty(elTd))
               {
                  cellIdAttr = elTd.getAttribute("enPageCellId");
                  if(!enUtils.isInArray(cellIdAttr,cellOrderArray))
                  {
                     cellOrderArray[ind] = cellIdAttr;
                  }   
                  tdIndex++;
                  counter++;
                  if(counter%numOfCols==0)
                  {
                     trIndex++;
                     tdIndex=1;
                  }   
                  fullObjId=prefixId+"@"+"0@"+trIndex+"@"+tdIndex ;
                  elTd = document.getElementById(fullObjId) ;
                  ind++;
               }
            }
         }
         global.zfMainArray[i][2] = cellOrderArray.join(",") ;
         cellOrderArray = new Array() ;
         ind=0;
      }//end for
         return global.zfMainArray ;   
   }//end function
   this.setUserCellsOrder=setUserCellsOrder;
   

   /*
      save the new order of the components
      params:
            dataArray - the data about the items that should be deleted
   */
   var saveUserCellsOrder=function(dataArray)
   {
      var doUpdate=0;
      var cellsOrderStr="";
      for(var i=0;i<dataArray.length;i++)
      {
         if(dataArray[i][1])
         {
            cellsOrderStr+=dataArray[i][2]+",";
            doUpdate=1;
         }   
      }
      //if cells were moves or cells should be deleted
      doUpdate=(doUpdate||!enUtils.isEmpty(global.zfHideCells)); 
      if(doUpdate)
      {
         var pageName = global.currentPageName;
         var execPath = "en.jsp?enAction=custom&enActionInfolet=Personalize/moveCellsExec.jsp";
         execPath+="&enaHidden=1";
         execPath=enUtils.addQueryStringParam(execPath,"enaCellsOrder",cellsOrderStr);
         execPath=enUtils.addQueryStringParam(execPath,"cbfn","enApplication.moveCellsCbfn");
         execPath=enUtils.addQueryStringParam(execPath,"cbflag","fraExec");         
         execPath=enUtils.addQueryStringParam(execPath,"enaPage",pageName);
         execPath=enUtils.addQueryStringParam(execPath,"enaDelCells",global.zfHideCells);         
         if(enUtils.isExecAsync('fraExec'))return false;
         enUtils.execAsync('fraExec',execPath);
      }
      var el = new Object();
      el.showHide = "hide" ;
      enUtils.ifrShowFloatingIfr("fraMoveCells",null,el);
   }
   this.saveUserCellsOrder=saveUserCellsOrder;
   /*
   move the components 
   
   params:
      moveDir - the direction that we want to move the components to
              sample:
                    L = left
                  R = right
                  U = up
                  D=down
   */
   var imgMoveClick=function(moveDir)
   {
      var resultId="";
      var prefixResult= new Array();
      resultId=moveTd(global.enSrcElmntToMove,moveDir);
      //if null then was no movement
      if(enUtils.isEmpty(resultId)) return;
      prefixResult = resultId.split("@");
      resultId = prefixResult[0];
      //make zone frame dirty
      for(var i=0;i<global.zfMainArray.length;i++)
      {
         if(global.zfMainArray[i][0]==resultId)
         {
            global.zfMainArray[i][1]=true ;
         }
      }
      //move iframe to new location
      var ifrElmnt=document.getElementById('fraMoveCells');
      showMoveCellsPopup(global.enSrcElmntToMove);
      
   }
   this.imgMoveClick=imgMoveClick;
   
   
   /*
      check if the update id Done
      params:
            prm - the flag that sign if the update is done or not
   */
   var moveCellsCbfn=function(prm)
   {
      if(prm.status)
      {
         //clean all variebles
         for(var i=0;i<global.zfMainArray.length;i++)
         {
            global.zfMainArray[i][1]=false;
            global.zfMainArray[i][2]=null;
         }
         var el = new Object();
         el.showHide = "hide" ;
         enUtils.ifrShowFloatingIfr("fraMoveCells",null,el);
      }
      enUtils.defaultCallBack(prm) ;
   }
   this.moveCellsCbfn=moveCellsCbfn;


   /*
      show or hide components 
      params:
            elmnt - the component id 
            showOrHide - the action that need to do (show or Hide)
   */
   var showOrHideCell=function(elmnt,showOrHide)
   {
      elmnt=enUtils.objectOrGetId(elmnt);
      var cellId = elmnt.getAttribute("componentIndex");
      var hidTr = document.getElementById("hiddenTr"+cellId);
      var contTr = document.getElementById("contentTr"+cellId);
      
      if(showOrHide=="hide")
      {
         global.zfHideCells+="@"+cellId+"@";
      }   
      else
      {
         var re = new RegExp("@"+cellId+"@","ig");
         global.zfHideCells=global.zfHideCells.replace(re,"");
      }   
   
      if(showOrHide=="hide")
      {
         contTr.style.display="none";
         hidTr.style.display="";
         showMoveCellsPopup(elmnt);
      }
      else
      {
         hidTr.style.display="none";
         contTr.style.display="";
         showMoveCellsPopup(elmnt);
      }
   }
   this.showOrHideCell=showOrHideCell;

   /*
      checks to what directions the td can be moved
      params:
         srcTdId   the id of the td to check
      retruns:
         an arrayof true/false in the order of R,RR,L,LL,U,UU,D,DD
   */
   var canMoveTd=function(srcTdId)
   {
      //if no id
      if(enUtils.isEmpty(srcTdId))
      {
         return [false,false,false,false,false,false,false];
      }
      //array to return
      var canMoveArr=new Array();
      //parse the source id
      var idArray=srcTdId.split('@');
      var preFix=idArray[0];
      var srcTbl=enUtils.enParseInt(idArray[1]);
      var srcRow=enUtils.enParseInt(idArray[2]);
      var srcCell=enUtils.enParseInt(idArray[3]);
      //variables for the destination td
      var dstTbl,dstRow,dstCell,dstTdId,dstTd;
      //check for "R"
         dstTbl= srcTbl==0?srcTbl:srcTbl+1;
         dstRow=srcRow;
         dstCell=srcTbl==0?srcCell+1:srcCell;
         dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         dstTd=document.getElementById(dstTdId);
         canMoveArr[0]=!enUtils.isEmpty(dstTd);
      //check for "RR"
         dstTbl= srcTbl==0?srcTbl:srcTbl+2;
         dstRow=srcRow;
         dstCell=srcTbl==0?srcCell+2:srcCell;
         dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         dstTd=document.getElementById(dstTdId);
         canMoveArr[1]=!enUtils.isEmpty(dstTd);
      //check for "L"
         dstTbl= srcTbl==0?srcTbl:srcTbl-1;
         //
         if(srcTbl!=0 && dstTbl==0) dstTbl=-1;
         dstRow=srcRow;
         dstCell=srcTbl==0?srcCell-1:srcCell;
         dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         dstTd=document.getElementById(dstTdId);
         canMoveArr[2]=!enUtils.isEmpty(dstTd);
      //check for "LL"
         dstTbl= srcTbl==0?srcTbl:srcTbl-2;
         if(srcTbl!=0 && dstTbl==0) dstTbl=-1;
         dstRow=srcRow;
         dstCell=srcTbl==0?srcCell-2:srcCell;
         dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         dstTd=document.getElementById(dstTdId);
         canMoveArr[3]=!enUtils.isEmpty(dstTd);
      //check for "U"
         dstTbl= srcTbl;
         dstRow=srcRow-1;
         dstCell=srcCell;
         dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         dstTd=document.getElementById(dstTdId);
         canMoveArr[4]=!enUtils.isEmpty(dstTd);
      //check for "UU"
         dstTbl= srcTbl;
         dstRow=srcRow-2;
         dstCell=srcCell;
         dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         dstTd=document.getElementById(dstTdId);
         canMoveArr[5]=!enUtils.isEmpty(dstTd);
      //check for "D"
         var dstTbl= srcTbl;
         var dstRow=srcRow+1;
         var dstCell=srcCell;
         dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         dstTd=document.getElementById(dstTdId);
         canMoveArr[6]=!enUtils.isEmpty(dstTd);
      //check for "DD"
         var dstTbl= srcTbl;
         var dstRow=srcRow+2;
         var dstCell=srcCell;
         dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
         //get the destination td
         dstTd=document.getElementById(dstTdId);
         canMoveArr[7]=!enUtils.isEmpty(dstTd);
      
      return canMoveArr;
   }
   this.canMoveTd=canMoveTd;
   /*
      create the Menu HTML source
   */
   var moveCellsCreateHtml=function()
   {   
      //srcClickElmnt is the clicked image....
      var srcClickElmnt=global.enSrcElmntToMove ;
      var srcTd=srcClickElmnt.parentNode;
      while(srcTd.getAttribute("enMoveableTd")!="true")
      {
         srcTd=srcTd.parentNode;
         if(enUtils.isEmpty(srcTd))break;
      }
      var imgSuffix="";
      var isMoveable=global.enSrcElmntToMove.getAttribute("enMoveCellsMoveable");
      var isPersonalizable=global.enSrcElmntToMove.getAttribute("enMoveCellsPersonalizable");
      var hideComponent = global.enSrcElmntToMove.getAttribute("enHideComponent");
      var moveableArray = canMoveTd(enUtils.isEmpty(srcTd) ? null : srcTd.id);
      var isDocRtl = global.isRTL?'dir=\"rtl\"':'';
      var arrowsDirection="";
      var arrayIndex=0;
      var src="";
      src+="<html "+isDocRtl+">";
      src+="<head>\n";
      if(!enUtils.isEmpty(global.charset))
      {
         src+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset="+global.charset+"\">\n";
      }
      src+="<link rel=\"stylesheet\" type=\"text/css\" href=\""+enUtils.getBaseUrl()+"Static/Include/enformia.css\">\n" ;
      src+="<link rel=\"stylesheet\" type=\"text/css\" href=\""+enUtils.getBaseUrl()+"Static/Include/Skins/"+global.currentSkinName+".css\">\n" ;
      src+="<scr"+"ipt language=\"JavaScript\">\n";
      src+="<!--\n";
      src+="var callingWin=window.parent;\n";
      
      src+="function imgMoveClickCaller(param)\n";
      src+="{\n";
      src+=   "callingWin.enApplication.global.moveCellsFlag=1;\n";
      src+=   "callingWin.enApplication.imgMoveClick(param);\n";
      src+="}\n";
      
      src+="function cancelUserChoose()\n";
      src+="{\n";
      src+=   "callingWin.enApplication.global.moveCellsFlag=0;\n";
      src+=   "callingWin.enApplication.hideMoveCellsPopup();\n";
      if(!enUtils.isEmpty(global.zfHideCells) || global.moveCellsFlag==1)
      {
         src+="callingWin.location.reload();\n" ;
      }
      src+="}\n";
      
      src+="function confirmUserCellsOrder()\n";
      src+="{\n";
      src+=   "callingWin.enApplication.global.moveCellsFlag=0\n";      
      src+=   "var dataArray = callingWin.enApplication.setUserCellsOrder();     //get the new cells order\n";
      src+=   "callingWin.enApplication.saveUserCellsOrder(dataArray);    //   update the cells order\n";
      src+="}\n"
      
      src+="function markRow(row,sign)\n";
      src+="{\n";
      src+=   "if(sign==1)\n";
      src+=   "{\n";
      src+=      "row.className = \"moveCellsRowOver\" ;\n";
      src+=   "}\n";
      src+=   "else\n";
      src+=   "{\n";
      src+=      "row.className = \"moveCellsRow\" ;\n";
      src+=   "}\n";
      src+="}\n";
      
      src+="function checkMoveCellsFlag()\n";
      src+="{\n";
      src+=   "var el=document.getElementById(\"moveCellsNavigation\");\n";
      src+=   "if(!el)return;\n";      
      src+=   "if(callingWin.enApplication.global.moveCellsFlag==1)\n";
      src+=   "{\n";
      src+=      "el.className=\"hiddenEl\";\n";
      src+=   "}\n";
      src+=   "else\n";
      src+=   "{\n";
      src+=   "el.className=\"moveCellsNav\";\n";
      src+=   "}\n";
      src+="}\n";
      
      src+="//-->\n";
      src+="</sc"+"ript>\n";
      src+="</head>";
      src+="<body class=\"moveCellsMenuBody\" onload=\"checkMoveCellsFlag()\">" ;
      src+="<img src=\"../Static/Images/blank.gif\" width=\"1\" height=\"10\">"
      if(isMoveable=="1")
      {
      src+=   "<table width=\"69\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">";
      src+=      "<tr>";
      src+=         "<td colspan=\"2\" rowspan=\"2\">";
      if(global.isRTL)
      {
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverRightLeft.gif")+"\" width=\"25\" height=\"25\">";//ff
      }
      else
      {   
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverTopLeft.gif")+"\" width=\"25\" height=\"25\">";//ff0
      }   
      src+=         "</td>" ;
      if(moveableArray[5])
      {
      src+=         "<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('UU');\" >";
      imgSuffix="";
      }
      else
      {
      src+=         "<td>";      
      imgSuffix="Dis";
      }
      src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverUp2"+imgSuffix+".gif")+"\" width=\"19\" height=\"12\">";
      src+=         "</td>";
      src+=         "<td colspan=\"2\" rowspan=\"2\">" ;
      if(global.isRTL)
      {
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverTopLeft.gif")+"\" width=\"25\" height=\"25\">";//ff
      }
      else
      {
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverRightLeft.gif")+"\" width=\"25\" height=\"25\">";//ff1         
      }
      src+=         "</td>" ;
      src+=      "</tr>" ;
      src+=      "<tr>" ;      
      if(moveableArray[4])
      {
      src+=         "<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('U');\">";
      imgSuffix="";
      }
      else
      {
      src+=         "<td>";      
      imgSuffix="Dis";
      }
      src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverUp1"+imgSuffix+".gif")+"\" width=\"19\" height=\"13\">";
      src+=         "</td>";
      src+=      "</tr>" ;
      src+=      "<tr>" ;   
      //RR / LL
      arrayIndex=3;//global.isRTL?3:1;   
      if(moveableArray[arrayIndex])
      {
      arrowsDirection = 'LL';//global.isRTL?'LL':'RR';
      src+=         "<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('"+arrowsDirection+"');\">";
      imgSuffix="";
      }
      else
      {
      src+=         "<td>";
      imgSuffix="Dis";      
      }
      if(global.isRTL)
      {
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverRight2"+imgSuffix+".gif")+"\" width=\"12\" height=\"19\">";//ff
      }
      else
      {   
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverLeft2"+imgSuffix+".gif")+"\" width=\"12\" height=\"19\">";//ff2
      }   
      src+=         "</td>";
      //R / L
      arrayIndex=2;//global.isRTL?2:0;   
      if(moveableArray[arrayIndex])
      {
      arrowsDirection = 'L';//global.isRTL?'L':'R';
      src+=         "<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('"+arrowsDirection+"');\">" ;
      imgSuffix="";
      }
      else
      {
      src+=         "<td>" ;
      imgSuffix="Dis";      
      }
      if(global.isRTL)
      {
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverRight1"+imgSuffix+".gif")+"\" width=\"13\" height=\"19\">";//ff
      }
      else
      {   
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverLeft1"+imgSuffix+".gif")+"\" width=\"13\" height=\"19\">";//ff3
      }   
      src+=         "</td>";
      src+=         "<td>";
      src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverCenter.gif")+"\" width=\"19\" height=\"19\">";
      src+=         "</td>";
      //R / L
      arrayIndex=0;//global.isRTL?0:2;   
      if(moveableArray[arrayIndex])
      {
      arrowsDirection = 'R';//global.isRTL?'R':'L';
      src+=         "<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('"+arrowsDirection+"');\">";
      imgSuffix="";
      }
      else
      {
      src+=         "<td>";      
      imgSuffix="Dis";
      }
      if(global.isRTL)
      {
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverLeft1"+imgSuffix+".gif")+"\" width=\"13\" height=\"19\">";//ff
      }
      else
      {   
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverRight1"+imgSuffix+".gif")+"\" width=\"13\" height=\"19\">";//ff4
      }   
      src+=         "</td>";
      //RR / LL
      arrayIndex=1;//global.isRTL?1:3;   
      if(moveableArray[arrayIndex])
      {
      arrowsDirection = 'RR';//global.isRTL?'RR':'LL';
      src+=         "<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('"+arrowsDirection+"');\">";
      imgSuffix="";
      }
      else
      {
      src+=         "<td>";      
      imgSuffix="Dis";
      }
      if(global.isRTL)
      {
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverLeft2"+imgSuffix+".gif")+"\" width=\"12\" height=\"19\">";//ff
      }
      else
      {   
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverRight2"+imgSuffix+".gif")+"\" width=\"12\" height=\"19\">";//ff5
      }   
      src+=         "</td>";
      src+=      "</tr>" ;
      src+=      "<tr>" ;      
      src+=         "<td colspan=\"2\" rowspan=\"2\">";
      if(global.isRTL)
      {
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverBottomRight.gif")+"\" width=\"25\" height=\"25\">";//ff
      }
      else
      {   
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverBottomLeft.gif")+"\" width=\"25\" height=\"25\">";//ff6
      }   
      src+=         "</td>";
      if(moveableArray[6])
      {
      src+=         "<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('D');\">";
      imgSuffix="";
      }
      else
      {
      src+=         "<td>";      
      imgSuffix="Dis";
      }
      src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverDown1"+imgSuffix+".gif")+"\" width=\"19\" height=\"13\">";
      src+=         "</td>";
      src+=         "<td colspan=\"2\" rowspan=\"2\">";
      if(global.isRTL)
      {
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverBottomLeft.gif")+"\" width=\"25\" height=\"25\">";//ff
      }
      else
      {   
         src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverBottomRight.gif")+"\" width=\"25\" height=\"25\">";//ff7
      }   
      src+=         "</td>";
      src+=      "</tr>" ;
      src+=      "<tr>" ;      
      if(moveableArray[7])
      {
      src+=         "<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('DD');\">";
      imgSuffix="";
      }
      else
      {
      src+=         "<td>";      
      imgSuffix="Dis";
      }
      src+=            "<img src=\""+getSkinImgPath("MoveCellMenu/moverDown2"+imgSuffix+".gif")+"\" width=\"19\" height=\"12\">";
      src+=         "</td>";
      src+=      "</tr>" ;
      src+=   "</table>";
      src+=   "<table align=\"center\">";
      src+=      "<tr>";
      src+=         "<td colspan=\"2\">";
      src+=         "</td>";
      src+=      "</tr>";
      src+=      "<tr>";
      src+=         "<td>";
      src+=            "<input type=\"button\" value=\""+enMsg.get("enApplication.cell.save")+"\" class=\"button\" ";
      src+=            "onclick=\"confirmUserCellsOrder();\" class=\"moveCellsMenuButton\">";
      src+=         "</td>";
      src+=         "<td>";
      src+=            "<input type=\"button\" value=\""+enMsg.get("enApplication.cell.cancel")+"\" class=\"cancelForm\" ";
      src+=            "onclick=\"cancelUserChoose();\" class=\"moveCellsMenuButton\">";
      src+=         "</td>";
      src+=      "</tr>";
      src+=      "<tr>";
      src+=         "<td colspan=\"2\">";
      src+=         "</td>";
      src+=      "</tr>";
      src+=   "</table>";
      }
      //when moving - no options
      if(!(global.moveCellsFlag=="1" || hideComponent==1))
      {
      src+=   "<table align=\"center\" id=\"moveCellsNavigation\" class=\"moveCellsNav\" cellpadding=\"0\" cellspacing=\"0\">";
      src+=      "<tr onmouseover=\"markRow(this,1)\" onmouseout=\"markRow(this,0)\" class=\"moveCellsRow\">";
      src+=         "<td colspan=\"2\" class=\"moveCellsTopRow\" onclick=\"javascript:void callingWin.enApplication.printCell();callingWin.enApplication.hideMoveCellsPopup();\">"+enMsg.get("enApplication.cell.print")+"</td>";
      src+=      "</tr>";
      //send
      if(global.sendToFriendComp)
      {
      src+=      "<tr onmouseover=\"markRow(this,1)\" onmouseout=\"markRow(this,0)\" class=\"moveCellsRow\">";
      src+=         "<td colspan=\"2\" class=\"moveCellsSecondRow\" onclick=\"javascript:void callingWin.enApplication.openSendToFriend(null,true);callingWin.enApplication.hideMoveCellsPopup();\">"+enMsg.get("enApplication.cell.send")+"</td>";
      src+=      "</tr>";
      }
      src+=      "<tr onmouseover=\"markRow(this,1)\" onmouseout=\"markRow(this,0)\" class=\"moveCellsRow\">";
      src+=         "<td colspan=\"2\" class=\"moveCellsMidRow\" onclick=\"javascript:void callingWin.enApplication.reloadCell();callingWin.enApplication.hideMoveCellsPopup();\">"+enMsg.get("enApplication.cell.reload")+"</td>";
      src+=      "</tr>";
      if(isPersonalizable=="1")
      {
      src+=      "<tr onmouseover=\"markRow(this,1)\" onmouseout=\"markRow(this,0)\" class=\"moveCellsRow\">";
      src+=         "<td colspan=\"2\" class=\"moveCellsBottomRow\" onclick=\"javascript:void callingWin.enUtils.openPopupWindow('"+global.pagePrefrencesUrl+"',null,null,780,500); callingWin.enApplication.hideMoveCellsPopup();\">"+enMsg.get("enApplication.cell.preferences")+"</td>";
      src+=      "</tr>";
      }
      src+=   "</table>";
      if(isMoveable=="0")         
      {
         src+="<img src=\"../Static/Images/blank.gif\" width=\"1\" height=\"5\">"      
         src+="<span class=\"moveCellsMenuSpan\">" ;
         src+="<input type=\"button\" value=\"Cancel\" class=\"cancelForm\" ";
         src+="onclick=\"cancelUserChoose();\" class=\"moveCellsMenuButton\">";
         src+="</span>" ;
      }
      }
      src+="</body>";
      src+="</html>";
      var menuMoveHeight=110;
      var menuItemHeight=16;
      var menuCancelHeight=35;
      var menuHeight=0;
      
      //show only move (after move start / hide)
      if(!(global.moveCellsFlag=="1" || hideComponent==1))
      {
         //add print and reload
         menuHeight+= 2*menuItemHeight;
         //send
         if(global.sendToFriendComp)menuHeight+=menuItemHeight;
         //personalizable - personaliza
         if(isPersonalizable=="1")menuHeight+=menuItemHeight;
      }
      //movable
      if(isMoveable=="1")menuHeight+=menuMoveHeight;
      //cancel button
      else menuHeight+=menuCancelHeight;
      //assign
      global.moveCellsMenuHeight=menuHeight;
      //ret source
      return src;
   }
   this.moveCellsCreateHtml=moveCellsCreateHtml;
   
   
   /*-------------------------
   Progress bar
   --------------------------*/
   /*
      initialize and display the progress dialog.
      params:
         title - title of the bar ($NONE$ -> no title, def - >In Progress)
         progressInterval - interval in miliseconds to update the bar (def -> 50)
         progressLength - times to increase bar before clean it.
   */
   var showProgressaBar=function(title,progressInterval,progressLength)
   {
      //fix title span
      var el=document.getElementById("spnProgressTitle");
      if(!enUtils.isEmpty(el))
      {
         //remove all span content
         var len=el.childNodes.length;
         for(var i=len-1;i>-1;i--)
         {
            el.removeChild(el.childNodes[i]);
         }
         //create new title
         if(enUtils.isEmpty(title)) title=enMsg.get("enApplication.progressBarDefTitle")+"\n";
         else if (title=="$NONE$")title="";
         var txt=document.createTextNode(title);
         el.appendChild(txt);
      }
      //if no interval use default
      if(enUtils.isEmpty(progressInterval))progressInterval=50;
      //if there is new end override default
      if(!enUtils.isEmpty(progressLength))enApplication.global.progressBarVars.progressLength=progressLength;
      enApplication.global.progressBarVars.progressAt = 0;
      var pDiv=document.getElementById("enaProgressDiv");
      if(enUtils.isEmpty(pDiv))return;
      winPos=enUtils.getWindowPos();
      pDiv.className="";
      var pDivWidth=enUtils.enParseInt(enUtils.isEmpty(pDiv.width)?pDiv.style.width:pDiv.width);
      var pDivHeight=enUtils.enParseInt(enUtils.isEmpty(pDiv.height)?pDiv.style.height:pDiv.height);
      pDiv.style.left=winPos.width/2-pDivWidth;
      pDiv.style.top=winPos.height/2-pDivHeight;
      enApplication.global.progressBarVars.progressId=window.setInterval(updateProgressaBar,progressInterval);
   }
   this.showProgressaBar=showProgressaBar;
   
   // Update the progress dialog with the current state
   var updateProgressaBar=function() {
      var bar=document.getElementById("enaProgressBar");
      if(enUtils.isEmpty(bar))return;
      bar.value+="||";
      enApplication.global.progressBarVars.progressAt++;
      if(enApplication.global.progressBarVars.progressAt>enApplication.global.progressBarVars.progressLength)
      {
         bar.value="";
         enApplication.global.progressBarVars.progressAt=0;
      }
   }
   this.updateProgressaBar=updateProgressaBar;
   
   // Hide the progress bar
   var hideProgressaBar=function () {
      var pDiv=document.getElementById("enaProgressDiv");
      if(!enUtils.isEmpty(pDiv))
         pDiv.className="hiddenEl";
      //stop the interval
      window.clearInterval(enApplication.global.progressBarVars.progressId);
      //clear the bar
      var bar=document.getElementById("enaProgressBar");
      if(!enUtils.isEmpty(bar))
         bar.value="";
   }
   this.hideProgressaBar=hideProgressaBar;

   /*
   open's the file system browser and set's it's focus
   params:
      enaRetElement:   the eleemnt to hold the value (if ommited browser will not open).
      enaMode:   directory or file browser //1- dirs only(def), 2- files only)
      enaRoot:   [optional]    root folder to start with (reserved words: $site$, $binaries$, $usbinaries$, 
                        $components$, $classes$, $pagelets$, $tmpbinaries$, $tmpstatic$,$appicons$,
                        $infolets$, $scripts$,$help$,$WEBINF$, $web-inf$, $enformiaroot$, $machineroot$))
      enaRootFullPath:[optional] Returns the full path or start from the sent root (1/0(def)).
      enaRetAbs:   [optional] returns absolute path(starts with a slash) relevant when enaRootFullPath=0 (1/0(def)).
      enaFilter:   [optional] Filter for files (pattern: *.*|*.*).
      enaRootFixed:[optional] May the user change the root (values: 1/0(def))
      enaUseTrailingSlash: [optional] enclose the returned folder path with a slash (relevant in dir mode).(values: 1/0(def))
      enaCbfnFn:      [optional] name of fucntion to activate on return 
                     (this function should get the enaRetElement + the value)
      enaPreSelected: [optional] path of directory or file to be pre selected. full path required. if ommited, tries to use the value in enaRetElement 
      enaExcludeDrives: [optional] comma delimited list of drive names to exclude. use $empty$ to ignore system defaults
   */
   var openFsBrowser=function(enaRetElement,enaMode,enaRoot,enaRootFullPath,enaRetAbs,enaFilter,
                        enaRootFixed, enaUseTrailingSlash,enaCbfnFn,enaPreSelected,enaExcludeDrives)
   {
      //return if no element
      if(enUtils.isEmpty(enaRetElement))return;
      //handle defaults
      enaMode=enUtils.ntz(enaMode,"1");
      enaRootFullPath=enUtils.ntz(enaRootFullPath,"0");
      enaRetAbs=enUtils.ntz(enaRetAbs,"0");
      enaRootFixed=enUtils.ntz(enaRootFixed,"0");
      enaUseTrailingSlash=enUtils.ntz(enaUseTrailingSlash,"0");
      if(enUtils.isEmpty(enaPreSelected))
         enaPreSelected=enUtils.getValueOf(enaRetElement);
      var enaWinName="fsBrowserWin";
      //variables
      var fsBrowserSource=enUtils.getBaseUrl()+"bin/en.jsp?enScript=FSBrowser/fsBrowser.jsp";
      fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRetElement",enaRetElement);
      fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaMode",enaMode);
      if(!enUtils.isEmpty(enaRoot))
         fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRoot",enaRoot);
      fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRootFullPath",enaRootFullPath);
      fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRetAbs",enaRetAbs);
      if(!enUtils.isEmpty(enaFilter))
         fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaFilter",enaFilter);
      fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRootFixed",enaRootFixed);
      fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaUseTrailingSlash",enaUseTrailingSlash);
      if(!enUtils.isEmpty(enaCbfnFn))
         fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaCbfnFn",enaCbfnFn);
      if(!enUtils.isEmpty(enaPreSelected))
         fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaPreSelected",enaPreSelected);      
      if(!enUtils.isEmpty(enaExcludeDrives))
         fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaExcludeDrives",enaExcludeDrives);
         
      enUtils.openPopupWindow(fsBrowserSource, enaWinName,null,780,580);
   }
   this.openFsBrowser=openFsBrowser;
   /*
      fsBrowserCbfn call back function to be called from the file system browser
      how to use:
         call the function on the "ok" method,
         the fs browser will call the function back with the selected path
      params:
         enaRetWindow - reference to the calling window (window.opener, window.parent...)
         retElement - the id of the related input
         path - selected path to directort/file
   */
   var fsBrowserCbfn=function(enaRetWindow,enaRetElement,path)
   {
      if(enUtils.isEmpty(enaRetWindow))return;
      var el = enaRetWindow.enUtils.objectOrGetId(enaRetElement) ;
      if(!enUtils.isEmpty(el))
      {
         enUtils.setValueOf(el,path);
      }
   }
   this.fsBrowserCbfn=fsBrowserCbfn;
   /*
      openExprBuilder   opens the expression builder and set's it's focus
      params:
         enaRetElement:   the eleemnt to hold the value.
         enaCbfnFn:      [optional] name of fucntion to activate on return 
                     (this function should get the enaRetElement + the value)
         enaOpenMode:      [optional] open the builder in that mode(simple/advanced)
         enaForceMode:   [optional] if 1 user cannot change the mode (1/0 def)
         ** if last 2 params are ommited the builder will select the openning mode auto'
   */
   var openExprBuilder=function(enaRetElement,enaCbfnFn,enaOpenMode,enaForceMode)
   {
      //return if no retElement or get its current value.
      var retElement=enUtils.objectOrGetId(enaRetElement);
      if(!retElement && enUtils.isEmpty(enaCbfnFn))return;
      var expr=enUtils.ntz(enUtils.getValueOf(retElement));
      //variables
      var exprBldrSource=enUtils.getBaseUrl()+"bin/en.jsp?enScript=ExprBuilder/exprBuilder.jsp";
      exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaRetElement",enaRetElement);
      //endoce expr
      exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaExpr",enUtils.enEscape(expr));
      if(!enUtils.isEmpty(enaCbfnFn))
         exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaCbfnFn",enaCbfnFn);
      if(!enUtils.isEmpty(enaOpenMode))
         exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaOpenMode",enaOpenMode);
      if(!enUtils.isEmpty(enaForceMode))
         exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaForceMode",enaForceMode);
      enUtils.openPopupWindow(exprBldrSource,"enaExprBuilderWin",null,780,580);
   }
   this.openExprBuilder=openExprBuilder;
   /*
      exprBuilderCbfn   
      
   */
   var exprBuilderCbfn=function(enaRetWindow,enaRetElement,expr)
   {
      
      if(enUtils.isEmpty(enaRetWindow))return;
      var el = enaRetWindow.enUtils.objectOrGetId(enaRetElement) ;
      if(!enUtils.isEmpty(el))
      {
         enUtils.setValueOf(el,expr);
      }
   }
   this.exprBuilderCbfn=exprBuilderCbfn;
   
   /*
      showSysEntitiesPicker   opens a window for the system objects picker for the right object type.
      params:
         retElement:            an element with 3 attributes: enaEntitiesPickerRetElName with element id to get the picked name,
                                                    enaEntitiesPickerRetElTitle with element id to get the picked title.
                                                  enaEntitiesPickerOnChange with js function/statements.
                           For the Iframe will serve as the anchor.
         params:               2D array with params to pass
         [openMethod]:         whether to open in window or iframe {iframe | window (def)}
         [width]:            open width (def 280)
         [height]:            open height (def 280)
   */
   var showSysEntitiesPicker=function(retElement,params,openMethod,width,height)
   {
      //return if no retElement or get its current value.
      var retElement=enUtils.objectOrGetId(retElement);
      if(enUtils.isEmpty(retElement) || enUtils.isEmpty(params))return;
      openMethod=enUtils.ntz(openMethod,"window").toLowerCase();
      var isWin=openMethod!="iframe";
      if(!enUtils.isEmpty(width))width=enUtils.enParseInt(width);
      if(enUtils.isEmpty(width) || width<=0)width=280;
      if(!enUtils.isEmpty(height))height=enUtils.enParseInt(height);
      if(enUtils.isEmpty(height) || height<=0)height=280;
      //get current selected value
      var selectedVal=enUtils.getValueOf(retElement.getAttribute("enaEntitiesPickerRetElName"));
      //variables
      var sysObjPickerSource=enUtils.getBaseUrl()+"bin/en.jsp?enScript=EntityPicker/entityPicker.jsp";
      //ret element
      sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaRetElement",retElement.id);
      //width and height
      sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaWidth",width);
      sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaHeight",height);
      //all other
      for(var i=0;i<params.length;i++)
      {
         //handle current selected value - will be handled separately
         if(params[i][0]=="entPreSelected")continue;
         //add to query string
         sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,params[i][0],params[i][1]);
      }
      //handle the case when there is no entPreSelected parameter, but there is a selected value
      if(!enUtils.isEmpty(selectedVal))
      {
         sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"entPreSelected",enUtils.enEscape(selectedVal));
      }
      //win attributes
      if(isWin)
      {
         var winAtts = ",resizable=1,status=0,menubar=0,scrollbars=0,fullscreen=0";
         enUtils.openPopupWindow(sysObjPickerSource,"enaEntityPickerWin",winAtts,width,height);
      }
      else
      {
         var ifrParams=new Object();
         var docAlign = global.isRTL?"right":"left" ;
         ifrParams.position="bottom";
         ifrParams.shiftDir=docAlign;
         ifrParams.shiftByPercent="0";
         ifrParams.ifrSrc=sysObjPickerSource;
         ifrParams.ifrWidth=width;
         ifrParams.ifrHeight=height;
         ifrParams.isSrcFile=true;
         enUtils.ifrShowFloatingIfr("fraObjPicker",retElement,ifrParams);
      }
   }
   this.showSysEntitiesPicker=showSysEntitiesPicker;
   
   /*
      hideSysEntitiesPicker:   close the object picker (window or iframe)
   */
   var hideSysEntitiesPicker=function(win)
   {
      //close object picker
      if(win)
      {
         window.close();
      }
      else
      {
         var ifrParams=new Object();
         ifrParams.showHide="hide";
         window.parent.enUtils.ifrShowFloatingIfr("fraObjPicker",null,ifrParams);
         //clear iframe src
         window.parent.enUtils.clearIFrameSrc("fraObjPicker");
      }
   }
   this.hideSysEntitiesPicker=hideSysEntitiesPicker;
   
   /*
      close object picker on escape press
      how to use: 
         enUtils.evtAddEvent(document,"keyup",enApplication.hideSysEntitiesPickerOnEsc);
   */
   var hideSysEntitiesPickerOnEsc=function(e)
   {
      //get event
      var e=enUtils.evtGetCBEvent(e);
      //get ascii code
      if(e.keyCode==27) hideSysEntitiesPicker();
   }
   this.hideSysEntitiesPickerOnEsc=hideSysEntitiesPickerOnEsc;
   
   /*
      sysEntitiesPickerCbfn   call back function to be called from the objects picker.
   */
   var sysEntitiesPickerCbfn=function(enaRetWindow,enaRetElement,pickedName,pickedTitle,pickedNode)
   {
      if(enUtils.isEmpty(enaRetWindow))return;
      var el = enaRetWindow.enUtils.objectOrGetId(enaRetElement);
      if(!enUtils.isEmpty(el))
      {
         //get the name target & title taregt
         var nameEl=enaRetWindow.enUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElName"));
         if(!enUtils.isEmpty(nameEl) && pickedName!=-1)
         {   
            if(nameEl.value!=pickedName)
            {
               enUtils.setValueOf(nameEl,pickedName);
               var titleEl=enaRetWindow.enUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElTitle"));
               if(!enUtils.isEmpty(titleEl))
                  enUtils.setValueOf(titleEl,pickedTitle);
               var onChange=el.getAttribute("enaEntitiesPickerOnChange");
               if(!enUtils.isEmpty(onChange))
               {
                  //fix onchange - replace $title$ with titles and $name$ with names
                  onChange=onChange.replace("$title$",enUtils.escapeJs(pickedTitle));
                  onChange=onChange.replace("$name$",enUtils.escapeJs(pickedName));
                  onChange=onChange.replace("$node$","pickedNode");
                  eval("enaRetWindow."+onChange);
               }
            }
         }
      }
   }
   this.sysEntitiesPickerCbfn=sysEntitiesPickerCbfn;
   
   /*
      sysEntitiesPickerClear: clear the hidden name input & the title.
   */
   var sysEntitiesPickerClear=function(enaRetElement)
   {
      var el = enUtils.objectOrGetId(enaRetElement) ;
      if(!enUtils.isEmpty(el))
      {
         //get the name target & title taregt
         var nameEl=enUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElName"));
         if(!enUtils.isEmpty(nameEl))
         {   
            if(!enUtils.isEmpty(nameEl.value))
            {
               enUtils.setValueOf(nameEl,"");
               var titleEl=enUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElTitle"));
               if(!enUtils.isEmpty(titleEl))
                  enUtils.setValueOf(titleEl,"");
               var onChange=el.getAttribute("enaEntitiesPickerOnChange");
               if(!enUtils.isEmpty(onChange))
               {
                  //fix onchange - replace $title$ with titles and $name$ with names
                  onChange=onChange.replace("$title$","");
                  onChange=onChange.replace("$name$","");
                  onChange=onChange.replace("$node$","null");
                  eval(onChange);
               }
            }
         }
      }
      //hide
      var ifrParams=new Object();
      ifrParams.showHide="hide";
      enUtils.ifrShowFloatingIfr("fraObjPicker",null,ifrParams);
      //clear iframe src
      enUtils.clearIFrameSrc("fraObjPicker");
   }
   this.sysEntitiesPickerClear=sysEntitiesPickerClear;
   
   /*
   opens the calendar near the element
   params:
      el:            the element to position the calendar near to.
      trgt:         the input element that holds the date (should have attribute enLongDateInputName with 
                  the name of the control that represents the date as long (initialize & return)).
      [cbfn]:         the call back function (should recieve parameters like the default function)- default enApplication.showCalendarCbfn
      [calendarType]: allowed values 11(date)/12(time)/6(datetime)- defualt=6. (The numbers are corresponding to ENTypes class)
      [dateFrom]:      (js date object) date range start - default from enCalendar.show()
      [dateTo]:      (js date object) date range end - default from enCalendar.show()
      [dateFormat]:   the format of the date for returning value (for supprted formats see enUtils.formatAsDateTime())
      [timeFormat]    the format to present the time (for supprted formats see enUtils.formatAsDateTime())
      [startDay]:      first day of week (0=sunday, 1=monday)  default from enCalendar.show()
      [startYear]:   first year in the select list  default from enCalendar.show()
      [endYear]:      lsst year in the select list  default from enCalendar.show()
      [addButtons]:   add prev/next month & year buttons -  default from enCalendar.show()
   */
   var showCalendar=function(el,trgt,cbfn,calendarType,dateFrom,dateTo,dateFormat,timeFormat,startDay,startYear,endYear,addButtons)
   {
      //handle parameters
      if(!enUtils.isSet(el))return;
      if(!enUtils.isSet(trgt))return;
      cbfn=enUtils.ntz(cbfn,"enApplication.showCalendarCbfn");
      calendarType=enUtils.ntz(calendarType,"null");
      if(enUtils.isSet(dateFrom) && dateFrom.constructor==Date)
         dateFrom="new Date("+dateFrom.getFullYear()+","+dateFrom.getMonth()+","+dateFrom.getDate()+")";
      else
         dateFrom="null"
      if(enUtils.isSet(dateTo) && dateTo.constructor==Date)
         dateTo="new Date("+dateTo.getFullYear()+","+dateTo.getMonth()+","+dateTo.getDate()+")";
      else
         dateTo="null"
      dateFormat=(enUtils.isEmpty(dateFormat))?"null":"'"+dateFormat+"'";
      timeFormat=(enUtils.isEmpty(timeFormat))?"null":"'"+timeFormat+"'";
      startDay=enUtils.ntz(startDay,"null");
      startYear=enUtils.ntz(startYear,"null");
      endYear=enUtils.ntz(endYear,"null");
      addButtons=enUtils.ntz(addButtons,"null");
      //create the calendar base HTML source
      //window.alert(enUtils.getBaseUrl());
      var tmpStr="<html "+(global.isRTL?"dir=\"rtl\"":"")+">\n";
      tmpStr += "<head>\n<link rel=\"STYLESHEET\" href=\""+enUtils.getBaseUrl()+"Static/Common/CalendarDOM/calendar.css\" type=\"text/css\">\n";
      tmpStr += "<sc"+"ript language=\"JavaScript\" src=\""+enUtils.getBaseUrl()+"Static/Common/CalendarDOM/enformiaCalendar.js\" type=\"text/javascript\"></scr"+"ipt>\n";
      tmpStr += "<sc"+"ript language=\"JavaScript\" type=\"text/javascript\">\n";
      tmpStr += "function start(){\n";
      tmpStr += "enCalendar.show('divCalendar','"+trgt+"','";
      tmpStr += cbfn+"',"+calendarType+","+dateFrom+","+dateTo+","+dateFormat+","+timeFormat+",";
      tmpStr += startDay+","+startYear+","+endYear+","+addButtons+");\n";
      tmpStr += "}\n";
      tmpStr += "</sc"+"ript>\n";
      tmpStr += "</head>\n<body style=\"margin:0\" onload=\"start();\">\n";
      tmpStr += "<div id=\"divCalendar\" style=\"width:100%;\"></div>";
      tmpStr += "</body>\n</html>";
          
      //open the calendar iframe.
      var ifr="fraCalendar";
      var ifrParams=new Object();
      ifrParams.position="bottom";
      ifrParams.shiftDir=global.isRTL?"right":"left"
      ifrParams.shiftByPercent="0"
      ifrParams.ifrSrc=tmpStr;
      ifrParams.ifrWidth="230";
      ifrParams.ifrHeight="61";//this changed in the control (except for time only control)
      enUtils.ifrShowFloatingIfr(ifr,el,ifrParams);
   }
   this.showCalendar=showCalendar;
   /*
   close the calendar iframe
   */
   var hideCalendar=function()
   {
      //close calendar
      var ifrParams=new Object();
      ifrParams.showHide="hide";
      enUtils.ifrShowFloatingIfr("fraCalendar",null,ifrParams);
   }
   this.hideCalendar=hideCalendar;
   /*
   The function to get back the date and handle it.
   parameters:
      pickedDate: the Date object that was picked un the calendar.
      trgt:      the input to get back the formatted date 
               (the value would be kept in the corresponding hidden inputs with id's with that name + ext:
               "_YY" - year; "_MM" - month; "_DD" - day; "_HO" - hour; "_MI" - minutes, "_SE" - seconds).
      calType:   values 11(date)/12(time)/6(datetime)- defualt=6. 
               (The numbers are corresponding to ENTypes class)
      [format]:      the format to present the returned date (for supprted formats see enUtils.formatAsDateTime())
      [timeFormat]    the format to present the returned time (for supprted formats see enUtils.formatAsDateTime())
      
   */
   var showCalendarCbfn=function(pickedDate,target,calType,format,timeFormat)
   {
      //extensions of the hidden inputs
      var DATE_HIDDEN_EXTS=["_YY","_MM","_DD","_HO","_MI","_SE"];
      var padZero=function(num)
      {
         return ((num <= 9) ? ("0" + num) : num);
      }
      //handle default represantation
      if(calType!=6 && calType!=11 && calType!=12)calType=6;
      //get date time parameters
      var year = pickedDate.getFullYear();
      var month =  padZero(pickedDate.getMonth()+1);
      var day  = padZero(pickedDate.getDate());
      var hour=padZero(pickedDate.getHours());
      var minute=padZero(pickedDate.getMinutes());
      var second=padZero(pickedDate.getSeconds());
      //put value in hidden fields
      var tmpEl;
      var tmpDateArry=[year,month,day,hour,minute,second];
      var prefix=target.id;
      for(var i=0;i<DATE_HIDDEN_EXTS.length;i++)
      {
         tmpEl=document.getElementById(prefix+DATE_HIDDEN_EXTS[i])
         if(tmpEl!=null)
         {
            tmpEl.value=tmpDateArry[i];
         }
      }
      /*
      //put long value in hidden field
      var longDateEl=document.getElementById(target.getAttribute("enLongDateInputName"));
      if(!enUtils.isEmpty(longDateEl))
      {
         longDateEl.value=pickedDate.getTime();
      }
      */
      //handle presentation
      if(target.nodeName.toUpperCase()=="INPUT")
      {
         target.value=enUtils.formatAsDateTime(pickedDate,calType,format,timeFormat);;
      }//end is INPUT
      //close calendar
      hideCalendar();
   }
   this.showCalendarCbfn=showCalendarCbfn;
   
   var clearCalendarVal=function(name)
   {
      var DATE_HIDDEN_EXTS=["","_YY","_MM","_DD","_HO","_MI","_SE"];
      var tmpEl=null;
      for(var i=0;i<DATE_HIDDEN_EXTS.length;i++)
      {
         tmpEl=document.getElementById(name+DATE_HIDDEN_EXTS[i])
         if(tmpEl!=null)
            tmpEl.value="";
      }
      hideCalendar();
   }
   this.clearCalendarVal=clearCalendarVal;



   /*
      openClassQbe   opens the Class QBE window and set its focus
      params:
         enaClass:      class name (REQUIRED).
         qbeExParams:   Object with the Extra parameters:
            enaCbfnFn:      name of fucntion to activate on return (def: enApplication.classQbeCbfn).
            enaCbSlctEl:   id of element to get the SELECT clause.
            enaCbWhrEl:      id of element to get the WHERE clause.
            enaCbOrdrEl:   id of element to get the ORDER BY clause.
            enaActTypes:   Comma seperated list of actions to allow def-all(values: select,where,order)
            enaSelect:      init SELECT cluase.
            enaWhere:      init WHERE clause.
            enaOrder:      init ORDER BY clause.
            enaTitle:      Main title (window title def- "common.classQBE.title" in dev.properties
            enaQbeTitle:   QBE fieldset legend (def set in incClassQbe.jsp).
            enaSlctSize:   size of select list (def set in incClassQbe.jsp).
            enaExcAttrs:   comma separated list of attributes to exclude.
            enaIncAttrs:   comma separated list of attributes to include (ignored if exclude is set).
            enaUnSlctAttrs:   comma separated list of attributes that could appear in SELECT clause.
            enaFromSig:      fromSignificance to filter by.
            enaToSig:      toSignificance to filter by.
         enaSilent:      don't alert if no class (def false)
         
   */
   var openClassQbe=function(enaClass, qbeExParams,enaSilent)
   {
      //return if no Class.
      if(enUtils.isEmpty(enaClass) || enaClass=="NO_CLASS")
      {
         if(!enUtils.ntz(enaSilent,false))alert(enMsg.get("enApplication.qbe.noclass"));
         return;
      }
      //variables
      var qbeSource=enUtils.getBaseUrl()+"bin/en.jsp?enScript=ClassQbe/classQbe.jsp";
      qbeSource=enUtils.addQueryStringParam(qbeSource,"enaClass",enaClass);
      //Add extra parameters
      if(qbeExParams)
      {
         if(!enUtils.isEmpty(qbeExParams.enaCbfnFn))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaCbfnFn",qbeExParams.enaCbfnFn);
         if(!enUtils.isEmpty(qbeExParams.enaCbSlctEl))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaCbSlctEl",qbeExParams.enaCbSlctEl);
         if(!enUtils.isEmpty(qbeExParams.enaCbWhrEl))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaCbWhrEl",qbeExParams.enaCbWhrEl);
         if(!enUtils.isEmpty(qbeExParams.enaCbOrdrEl))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaCbOrdrEl",qbeExParams.enaCbOrdrEl);
         if(!enUtils.isEmpty(qbeExParams.enaActTypes))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaActTypes",qbeExParams.enaActTypes);
         if(!enUtils.isEmpty(qbeExParams.enaSelect))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaSelect",enUtils.enEscape(qbeExParams.enaSelect));
         if(!enUtils.isEmpty(qbeExParams.enaWhere))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaWhere",enUtils.enEscape(qbeExParams.enaWhere));
         if(!enUtils.isEmpty(qbeExParams.enaOrder))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaOrder",enUtils.enEscape(qbeExParams.enaOrder));
         if(!enUtils.isEmpty(qbeExParams.enaTitle))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaTitle",qbeExParams.enaTitle);
         if(!enUtils.isEmpty(qbeExParams.enaQbeTitle))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaQbeTitle",qbeExParams.enaQbeTitle);
         if(!enUtils.isEmpty(qbeExParams.enaSlctSize))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaSlctSize",qbeExParams.enaSlctSize);
         if(!enUtils.isEmpty(qbeExParams.enaExcAttrs))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaExcAttrs",qbeExParams.enaExcAttrs);
         if(!enUtils.isEmpty(qbeExParams.enaIncAttrs))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaIncAttrs",qbeExParams.enaIncAttrs);
         if(!enUtils.isEmpty(qbeExParams.enaUnSlctAttrs))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaUnSlctAttrs",qbeExParams.enaUnSlctAttrs);
         if(!enUtils.isEmpty(qbeExParams.enaFromSig))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaFromSig",qbeExParams.enaFromSig);
         if(!enUtils.isEmpty(qbeExParams.enaToSig))
            qbeSource=enUtils.addQueryStringParam(qbeSource,"enaToSig",qbeExParams.enaToSig);
      }
      enUtils.openPopupWindow(qbeSource,"enaClassQbeWin",null,780,580);
   }
   this.openClassQbe=openClassQbe;
   /*
      classQbeCbfn   : call back function to be called from the Class QBE.
      params:
         retWindow: calling window
         qbeParamsObj: the returnning object from the incClassQbe
            select:      returning SELECT clause.
            where:      returning WHERE clause.
            orderBy:   returning ORDER BY clause.
         retElsObj: object with elemnts to put the values in:
            enaCbSlctEl:   id of element to get the SELECT clause.
            enaCbWhrEl:      id of element to get the WHERE clause.
            enaCbOrdrEl:   id of element to get the ORDER BY clause.
   */
   var classQbeCbfn=function(retWindow,qbeParamsObj,retElsObj)
   {
      if(enUtils.isEmpty(retWindow) || enUtils.isEmpty(retElsObj) || enUtils.isEmpty(qbeParamsObj))return;
      var slctEl=retWindow.enUtils.objectOrGetId(retElsObj.enaCbSlctEl) ;
      var whereEl=retWindow.enUtils.objectOrGetId(retElsObj.enaCbWhrEl) ;
      var orderEl=retWindow.enUtils.objectOrGetId(retElsObj.enaCbOrdrEl) ;
      if(!enUtils.isEmpty(slctEl))
      {
         if(enUtils.ntz(qbeParamsObj.select)=="*")
            enUtils.setValueOf(slctEl,"");
         else
            enUtils.setValueOf(slctEl,enUtils.ntz(qbeParamsObj.select));
      }
      if(!enUtils.isEmpty(whereEl))enUtils.setValueOf(whereEl,enUtils.ntz(qbeParamsObj.where));
      if(!enUtils.isEmpty(orderEl))enUtils.setValueOf(orderEl,enUtils.ntz(qbeParamsObj.orderBy));
   }
   this.classQbeCbfn=classQbeCbfn;
   
}//end of construstor function

//instanciate object
if(!window.enApplication)window.enApplication=new enApplicationConstrustor();   
