/*************************************************************************************************************
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 ibpApp-->
        &lt;script language="JavaScript" type="text/javascript"
            src="../Static/Include/application.js"&gt;&lt;/script&gt;

the script will create an object named ibpApp (or window.ibpApp)
    all functions are the object's methods result=ibpApp.fnName();

ibpApp 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

ibpApp functions
=========================
(name)                    (description)
-------------------------------------------------------------
general
-------------------------------------------------------------
favsPromptTitle            prompt user for favs title
runAppFile                run client side application using ENLauncher(ActivX)
filterZoneObjectsVersions	filter zone objects view by versions
filterZoneObjectsStatus		filter zone objects view by status
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)
absoluteRedirectPage    redirect to a given page

-------------------------------------------------------------
    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 - @deprecated as of v. 5.0 use 
	hidePageCell			hide page cell
    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
setPageCellMinimized 		set page cell minimized flag
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
reloadIfValidForm 			reload cell if form is valid
openSendToFriend            send page tp a friend
setPortletMode 				set portlet mode (when portlets are enabled)
setPortletWindowState 		set portlet window state (when portlets are enabled)

-------------------------------------------------------------
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.
*************************************************************************************************************/

//ibpApp construstor function
function ibpAppConstrustor()
{
    /*---------------------------------------------------------------------------------------
        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(ibpUtils.isExecAsync('fraExec',null,null,null,true))return;
        if(!ibpUtils.isSet(path))return;
        title=!ibpUtils.isEmpty(title)?title:"";
        //allow user to change title
        var usrTitle=window.prompt(ibpMsg.get("ibpApp.promptFavsTitle"),title);
        //if user canceled - exit
        if(usrTitle==null)return;

        //check hidden execution with flaging
        if(ibpUtils.isExecAsync('fraExec'))return;
        //if emrty, use original title
        usrTitle=!ibpUtils.isEmpty(usrTitle)?usrTitle:title;
        //change path - add title parameter
        path=ibpUtils.addQueryStringParam(path,"zoneLinkTITLE",usrTitle);
        //mark as javascript unicode string
        path=ibpUtils.addQueryStringParam(path,"ibpUTF8ParamNames","zoneLinkTITLE");
		
        if(ibpUtils.isEmpty(target))
        {
            ibpUtils.setWinLocation(window,path);
        }
        else
        {
            window.open(path,target);
        }
    }
    this.favsPromptTitle=favsPromptTitle;

    var runAppFile=function(path)
    {
        if(ibpUtils.isEmpty(path))return;
        var launcher=window.objENLauncher;
        //if we have launcher
        if(!ibpUtils.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 by versions
    var filterZoneObjectsVersions=function(status)
    {
        //def status
        if(ibpUtils.isEmpty(status))status=null;
        //build path
        var path=window.location.href;
        path=ibpUtils.addQueryStringParam(path,"enaFilterViewVersions",status);
        //redirect
        ibpUtils.setWinLocation(null,path);
    }
    this.filterZoneObjectsVersions=filterZoneObjectsVersions;
	
    //filter zone objects view by status
    var filterZoneObjectsStatus=function(status)
    {
        //def status
        if(ibpUtils.isEmpty(status))status=null;
        //build path
        var path=window.location.href;
        path=ibpUtils.addQueryStringParam(path,"enaFilterViewStatus",status);
        //redirect
        ibpUtils.setWinLocation(null,path);
    }
    this.filterZoneObjectsStatus=filterZoneObjectsStatus;

    //filter zone objects view by notifications
    var filterZoneNotifObjects=function(action)
    {
        //def action
        if(ibpUtils.isEmpty(action))action=null;
        //build path
        var path=window.location.href;
        path=ibpUtils.addQueryStringParam(path,"enaFilterNotif",action);
        //redirect
        ibpUtils.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="ibp.jsp?ibpPage="+global.linkManagePageMethod
            +"&ibpInfolet=Administration/administratePageProp.jsp";
        path=ibpUtils.addQueryStringParam(path,"editPropOfPageName",global.currentPageName);
        path=ibpUtils.addQueryStringParam(path,"ibpPageTitle","Pages Management");
        switch(global.linkManagePageMethod)
        {
            case "PopupPage":
                ibpUtils.openPopupWindow(path,"enAdminPage",null,750,600);
                break;
            case "MainFocus":
                showMainFocus(path);
                break;
            default:
                path=ibpUtils.addQueryStringParam(path,"ibpPage",global.defaultPageName);
                ibpUtils.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(ibpUtils.isEmpty(cbo))return;
        if(cbo.options.selectedIndex==-1)return;
        var paramValue=ibpUtils.getValueOf(cbo);
        //if cell id is passed - reload cell
        if(ibpUtils.isInteger(cellId))
        {
            var extraQryStr=paramName+"="+paramValue;
            reloadCell(cellId,null,null,extraQryStr);
        }
        //else - reload page
        else
        {
            var path=window.location.href;
            path=ibpUtils.addQueryStringParam(path,paramName,paramValue);
            ibpUtils.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=ibpUtils.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(ibpUtils.isEmpty(win))win=window;
        if(ibpUtils.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(ibpUtils.isEmpty(imgName))return "";
        //get base url
        var path=ibpUtils.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(ibpUtils.isEmpty(msg)) msg=ibpMsg.get("ibpApp.alertNotLoginAndClose") ;
        alert(msg);
        ibpUtils.absoluteRedirect(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(!ibpUtils.isEmpty(msg) && msg.toLowerCase().equals("$none$"))
        {
            confirmFirst=false;
        }
        if(confirmFirst)
        {
            //get msg
            if(ibpUtils.isEmpty(msg)) msg=ibpMsg.get("ibpApp.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("ibpApp.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(!ibpUtils.isInteger(cellId) || !ibpUtils.isNum(interval))return;
        if(!ibpUtils.isSet(recurring))recurring=true;
        var exe="ibpApp.reloadCell("+cellId+",true";
        if(!ibpUtils.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(ibpUtils.isEmpty(list))return;
        //turn into arrays
        if(!ibpUtils.isArray(list))
        {
            if(ibpUtils.isObject(list))list=new Array(list);
            else list=ibpUtils.separatedListToArray(list);
        }

        //loop
        for(var i=0;i<list.length;i++)
        {
            el=ibpUtils.objectOrGetId(list[i]);
            if(!ibpUtils.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(!ibpUtils.isEmpty(global.baseUrl))
        {
            var pos=1+global.baseUrl.lastIndexOf("/");
            if(pos>0 && pos<global.baseUrl.length)global.baseUrl+="/";
        }
        return global.baseUrl;
    }
    this.getBaseUrl=getBaseUrl;

	//absolutr redirect to a given page
	var absoluteRedirectPage=function(pageName)
	{
		var url=getBaseUrl()+'bin/ibp.jsp?ibpPage='+pageName;
		ibpUtils.absoluteRedirect(url);
	}   
	this.absoluteRedirectPage=absoluteRedirectPage;
	
    /*-------------------------------------------------------------
        online help
    -------------------------------------------------------------*/

    /*
        open help on F1
        how to use:
            ibpUtils.evtAddEvent(document,"keydown",ibpApp.getHelpOnF1);
    */
    var getHelpOnF1=function(e)
    {
        var evnt=ibpUtils.evtGetCBEvent(e);
        //F1 is 112
        if(evnt.keyCode==112)
        {
            evnt.cancelEvent();
            openPopUpHelp();
        }
    }
    this.getHelpOnF1=getHelpOnF1;

    /*
        cancel IE help event
        how to use:
            document.onhelp=ibpApp.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(ibpUtils.isEmpty(path))
        {
            path=ibpUtils.ntz(ibpUtils.ntz(global.specificHelpFile),global.defaultHelpFile);
        }
        if(ibpUtils.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;
        }
        */
        ibpUtils.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:
            ibpUtils.evtAddEvent(document,"keyup",ibpApp.closeWindowOrFloatingIfrOnEsc);
    */
    var closeWindowOrFloatingIfrOnEsc=function(e)
    {
        var e=ibpUtils.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:
            ibpUtils.evtAddEvent(document,"click",ibpApp.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:
            ibpUtils.evtAddEvent(document,"keyup",ibpApp.closeAllFloatingIfrsOnEsc);
    */
    var closeAllFloatingIfrsOnEsc=function(e)
    {
        var e=ibpUtils.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=ibpUtils.objectOrGetId(el);
        //if already sorted - do not change
        var sorted=el.getAttribute("enSortedAsc");
        if(!ibpUtils.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=ibpUtils.evtGetCBEvent(e)
        elmnt=evnt.target;
        cpCallerId = elmnt.getAttribute("enCpCallerId");
        if(ibpUtils.isEmpty(cpCallerId)) return;
        cpSize = elmnt.getAttribute("enCpSize");
        cpOpenMode = elmnt.getAttribute("enCpOpenMode");
        cpCbfn = elmnt.getAttribute("enCpCbfn");
        if(ibpUtils.isEmpty(cpCbfn)) cpCbfn='ibpApp.showColorPickerCbfn';
        if(ibpUtils.isEmpty(cpSize)) cpSize=4;
        if(ibpUtils.isEmpty(cpOpenMode)) cpOpenMode='iframe';
        var newWinPath = ibpUtils.getBaseUrl() + "Static/Common/ColorPicker/colorPicker.jsp?sizeOfArray="+ibpUtils.encodeURL(cpSize)+
            "&funName="+ibpUtils.encodeURL(cpCbfn)+"&callID=" + ibpUtils.encodeURL(cpCallerId)+"&openElement=" + ibpUtils.encodeURL(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;
        ibpUtils.ifrShowFloatingIfr('fraColorPicker',elmnt,ifrParams);
        evnt.setCancelBubble(true);
    }
    //expose
    this.showColorPicker=showColorPicker;

    /*
    hidding the color picker
    */
    var hideColorPicker=function (){

        ibpUtils.ifrShowFloatingIfr('fraColorPicker');
    }
    //expose
    this.hideColorPicker=hideColorPicker;
    /*
        close color picker on escape press
        how to use:
            ibpUtils.evtAddEvent(document,"keyup",ibpApp.hideColorPickerOnEsc);
    */
    var hideColorPickerOnEsc=function(e)
    {
        //get event
        var e=ibpUtils.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 'ibpApp.showColorPickerCbfn' a sthe call back function to the color picker
            <input type="button" name="cmdTest" id="cmdTest" value="..."
                enCpCallerId="cmdTest" enCpCbfn="ibpApp.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(!ibpUtils.isEmpty(el))
        {
            ibpUtils.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 ( ibpUtils.isEmpty(elmnt) ||
            ibpUtils.isEmpty(textTitle) && ibpUtils.isEmpty(textBody) ) return;

        //get size
        var width=ibpUtils.enParseInt(ibpUtils.ntz(minWidth,"140"));
        var height=0;
        minHeight=ibpUtils.enParseInt(ibpUtils.ntz(minHeight,"100"));
        //get divToolTipSizeChecker
        var sizeChecker=ibpUtils.objectOrGetId("divToolTipSizeChecker");
        if(!ibpUtils.isEmpty(sizeChecker))
        {
            //set width to divToolTipSizeChecker
            sizeChecker.style.width=width;
            //title first
            //ibpUtils.elmntSetInnerText(sizeChecker,textTitle); - THIS DOES NOT TAKE <BR>... into concideration
            sizeChecker.innerHTML=textTitle;
            height+=ibpUtils.enParseInt(ibpUtils.elmntAbsPos(sizeChecker).height);
            //body
            //ibpUtils.elmntSetInnerText(sizeChecker,textBody);
            sizeChecker.innerHTML="";
            sizeChecker.innerHTML=textBody;
            height+=ibpUtils.enParseInt(ibpUtils.elmntAbsPos(sizeChecker).height);
        }
        //html
        var isDocRtl = global.isRTL?'dir=\"rtl\"':'';
        var src = "<html "+isDocRtl+"><head>\n";
        if(!ibpUtils.isEmpty(global.charset))
        {
            src+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset="+global.charset+"\">\n";
        }
        src += "<link rel='stylesheet' type='text/css' href='"
            +ibpUtils.getBaseUrl()+"Static/Include/common.css'>";
        src += "<link rel='stylesheet' type='text/css' href='"
            +ibpUtils.getBaseUrl()+"Static/Include/basic.css'>";
        if(!ibpUtils.isEmpty(global.currentSkinName))
        {
            src += "<link rel='stylesheet' type='text/css' href='"
                +ibpUtils.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 = ibpUtils.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);
        ibpUtils.ifrShowFloatingIfr('fraToolTip',elmnt,ifrParams);
    }
    this.showToolTip=showToolTip;

    var hideToolTip=function()
    {
        ibpUtils.ifrShowFloatingIfr('fraToolTip');
    }
    this.hideToolTip=hideToolTip;

    /*-------------------------------------------------------------
        Home page components
       --------------------------------------------------------------*/
    /*
    show Move Cells board:
    */
    var showMoveCellsPopup=function (elmnt)
    {
        //backupScrollPos(); not needed anymore...
        elmnt=ibpUtils.objectOrGetId(elmnt);
        if(ibpUtils.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(ibpUtils.isEmpty(global.moveCellsMenuHeight)) global.moveCellsMenuHeight="158";
        ifrParams.ifrHeight=""+global.moveCellsMenuHeight+"";
        ifrParams.isSrcFile=false;
        ifrParams.showHide='show';
        ibpUtils.ifrShowFloatingIfr('fraMoveCells',elmnt,ifrParams);
        //window.setTimeout("ibpApp.restoreScrollPos();",1); not needed anymore...
    }
    //expose
    this.showMoveCellsPopup=showMoveCellsPopup;

    /*
    hide Move Cells board
    */
    var hideMoveCellsPopup=function()
    {
        var el=new Object();
        el.showHide = "hide";
        ibpUtils.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=ibpMsg.get("ibpApp.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=ibpUtils.enParseInt(idArray[1]);
        var srcRow=ibpUtils.enParseInt(idArray[2]);
        var srcCell=ibpUtils.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: ibpUtils.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(!ibpUtils.isSet(srcPath))return;
        if(!ibpUtils.isSet(height))height=global.mainFocusHeight;
        if(!ibpUtils.isSet(isRelativeHeight))isRelativeHeight=global.mainFocusIsRelative;

        //add random parameter to path
        srcPath=ibpUtils.addQueryStringParam(srcPath,"ibpRand",Math.random());

        // Hide selects and objects
        ibpUtils.elmntShowHideAdvanced(false);

        //if already in main focus, or page does not support - open in current window
        if(global.isMainFocus || !global.supportsMainFocus
            || ibpUtils.isEmpty(document.getElementById("maxZoneBaseEl")))
        {
            ibpUtils.setWinLocation(window,srcPath);
            return;
        }

        //add page name, and floating parameter to path
        srcPath=ibpUtils.addQueryStringParam(srcPath,"ibpPage","MainFocus");
        srcPath=ibpUtils.addQueryStringParam(srcPath,"ibpFloating","1");

        if (isRelativeHeight)
        {
            //convert %
            if((new String(height)).indexOf("%")!=-1)height=parseFloat(height)/100;
            //set relative height
            height=ibpUtils.enParseInt(parseFloat(height)*parseFloat(ibpUtils.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=ibpUtils.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';

        ibpUtils.ifrShowFloatingIfr(ifr,elmnt,ifrParams);
        //make sure it is dragable
        var oIfr=ibpUtils.objectOrGetId(ifr);
        if(!ibpUtils.isEmpty(oIfr))
        {
            oIfr.setAttribute("enaDragable","1");
            if(ibpSpy.ns6up || ibpSpy.ie55 || ibpSpy.ie6up)
                oIfr.style.cursor="move";
        }
        //if there is a last position move there
        if(global.drag.focusLastLeft && global.drag.focusLastTop)
        {
            ibpUtils.elmntMove(ifr,global.drag.focusLastLeft,
                                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.ibpUtils.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(!ibpUtils.isSet(reload))reload=true;
        //clear?
        if(!ibpUtils.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
        ibpUtils.ifrShowFloatingIfr(ifr,null,ifrParams);

        //Show the selects and objects again
        ibpUtils.elmntShowHideAdvanced(true);

        //set flags
        global.mainFocusInUse=false;
        global.mainFocusVisible=false;
        global.mainFocusResState=null;
        global.mainFocusResPos=null;
        //clear source
        if(clear)
        {
            var oIfr=ibpUtils.getIfrFromDiv(document.getElementById(ifr))
            oIfr.src=getBaseUrl()+"Static/none.htm";
        }
     }
     this.hideMainFocus=hideMainFocus;

    //set internal iframe element size
    var setMainFocusIntIfrSize=function(show)
    {
        if(!ibpUtils.isSet(show))show=true;
        var intIframe=ibpUtils.objectOrGetId("ifrMainFocus");
        if(!ibpUtils.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=ibpUtils.isSet(flg)?flg:!global.mainFocusVisible;
            ibpUtils.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;
        ibpUtils.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=ibpUtils.objectOrGetId(img);
        if(ibpUtils.isEmpty(img))return;
        if(!ibpUtils.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=ibpUtils.getFolderFromUrl(img.src);
        img.setAttribute("src",
            newState=="r" ? currSrcFolder+"/maximize.gif" : currSrcFolder+"/restore.gif");
        //change title
        img.setAttribute("title",newState=="m" ? ibpMsg.get("ibpApp.restore") : ibpMsg.get("ibpApp.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=ibpUtils.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=ibpUtils.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(ibpSpy.ns6up || ibpSpy.ie55 || ibpSpy.ie6up)
            ifr.style.cursor="move";
    }
    this.restoreMainFocus=restoreMainFocus;

	/*
        set page cell minimized flag
        params:
          	elmnt - the cell element or id
			minimized - minimized flag
    */
	var setPageCellMinimized=function(elmnt,minimized)
	{
        elmnt=ibpUtils.objectOrGetId(elmnt);
        if(ibpUtils.isEmpty(elmnt))return;
		minimized=ibpUtils.ntz(minimized,"1");
        var cellId = elmnt.getAttribute("componentIndex");
		var args=[
			["ibpAction","setMinimized"]
			,["ibpActOnWhat","pagecell"]
			,["ibpActOnWho",global.currentPageName+"#"+cellId]
			,["IS_MINIMIZED",minimized]
			,["cbReload","1"]
		];
		var url="ibp.jsp?"+ibpUtils.qryStringFromArray(args);
		ibpUtils.execAsync('fraExec',url,'fraExec',true);
	}
	this.setPageCellMinimized=setPageCellMinimized;
	
    /*
        toggle cell min / restore client side impl
        state is stored in the img
        params:
            img - the img for the action
    */

    var toggleCellMinRes=function(img)
    {
        //validate
        img=ibpUtils.objectOrGetId(img);
        if(ibpUtils.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(!ibpUtils.isInteger(cellId))return;

        //point to main content td
        cellId="tdComponentBody"+cellId;
        var contentTd=ibpUtils.objectOrGetId(cellId);
        if(ibpUtils.isEmpty(contentTd))return;
        //action
        ibpUtils.elmntShowHide(contentTd);

        //change src. the img may have suffix extention,
        //so we would just replace the restore/minimize part
        var currSrcFolder=ibpUtils.getFolderFromUrl(img.src);
        var fileName=ibpUtils.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" ? ibpMsg.get("ibpApp.minimize")
            : ibpMsg.get("ibpApp.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(ibpUtils.isEmpty(cellId))
        {
            var srcClickElmnt=global.enSrcElmntToMove;
            if(ibpUtils.isEmpty(srcClickElmnt))return;
            cellId=srcClickElmnt.getAttribute("componentIndex");
        }
        if(!ibpUtils.isInteger(cellId))return;
        //what's the cell size?
        var minWidth=280;
        var minHeight=200;
        var absPos=ibpUtils.elmntAbsPos("tdComponentBody"+cellId);
        var cellWidth=Math.max(minWidth,absPos.width);
        var cellHeight=Math.max(minHeight,absPos.height);

        //build url
        var path=ibpUtils.getBaseUrl()+"bin/ibp.jsp?ibpPage="+global.currentPageName;
            path+="&enaMode=print&enaCellId="+cellId+"&enaCellWidth="+cellWidth;

        /*
        var path=ibpUtils.getBaseUrl()+"bin/ibp.jsp?ibpPage=NOPAGE&ibpInfolet=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(ibpSpy.ie)
        {
            //use popup
            ibpUtils.openPopupWindow(path,"_blank",null,1.2 * cellWidth,1.2 * cellHeight);
        }
        else
        {
            path=ibpUtils.addQueryStringParam(path,"ibpHidden","1");
            ibpUtils.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(ibpUtils.isEmpty(zoneName))return null;
        if(!ibpUtils.isSet(firstOnly))firstOnly=false;
        if(ibpUtils.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(!ibpUtils.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(ibpUtils.isEmpty(componentName))return null;
        if(!ibpUtils.isSet(firstOnly))firstOnly=false;
        if(ibpUtils.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(!ibpUtils.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 - ibpApp.reloadCell(12); / ibpApp.reloadCell("12,54,2");
            2. to reload all cells with a give zone - ibpApp.reloadCell(getCellsByZone('zoneName'));
            2. to reload all cells with a give component - ibpApp.reloadCell(ibpApp.getCellsByComponent('compName'));
    */
    var reloadCell=function(cellId,retryIfBusy,win,extraQryString)
    {
        //default
        if(ibpUtils.isEmpty(win))win=window;
        if(!ibpUtils.isSet(retryIfBusy))retryIfBusy=false;
        //get cell id
        if(ibpUtils.isEmpty(cellId))
        {
            var srcClickElmnt=win.ibpApp.global.enSrcElmntToMove;
            if(ibpUtils.isEmpty(srcClickElmnt))return;
            cellId=srcClickElmnt.getAttribute("componentIndex");
        }
        if(ibpUtils.isEmpty(cellId))return;
        //build url
        var path="ibp.jsp?ibpPage="+global.currentPageName;
            path+="&enaMode=reload&enaCellId="+cellId;
        if(!ibpUtils.isEmpty(extraQryString))
        {
            if(ibpUtils.isArray(extraQryString))
                extraQryString=ibpUtils.qryStringFromArray(extraQryString);
            path+="&"+extraQryString;
        }
        //run - use hidden frame

        if(!win.ibpUtils.isExecAsync("fraExec",retryIfBusy))
        {
            win.ibpUtils.execAsync("fraExec",path);
        }
        else
        {
            //resqedule
            var timeoutFn="ibpApp.reloadCell("+cellId+",true";
            if(!ibpUtils.isEmpty(extraQryString))timeoutFn+=",null,'"+extraQryString+"'";
            timeoutFn+=");";
            win.setTimeout(timeoutFn,ibpUtils.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=ibpUtils.objectOrGetId(elId);
        if(ibpUtils.isEmpty(el) || ibpUtils.isEmpty(newEl))return;
        //the following runs on ns only when dealing with different frames
        if(ibpSpy.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
			extraQryString - axtra params to append to cell link - query string or 2D array
    */
    var reloadHomePageCompByZone=function(zoneName,extraQryString)
    {
        if(ibpUtils.isEmpty(zoneName))return;
        //locate main window
        var win=window.top;
        if(!ibpUtils.isEmpty(window.top.opener))
            win=window.top.opener.top;
        //reload
        if(win.ibpApp)
            win.ibpApp.reloadCell(win.ibpApp.getCellsByZone(zoneName),null,null,extraQryString);
    }
    this.reloadHomePageCompByZone=reloadHomePageCompByZone;

	/*
        reload cell if form is valid
		usefull to validate forms that are reloaded and their javascript not functional
        params:
			frm form id or reference
			validation array of validation attributes [[id, attribute, value], [id, attribute, value]]
				value should be passed as string to eval()
            params - parameters array to append [[name, id, def], [name, id, def]]
				where name is the parameter name, id is element id to get value from and def is the default value
			extraQryString - additional query string (appended last)
            cellId - cell id to reload. if ommited, the page is reloaded
    */
    var reloadIfValidForm=function (frm,validation,params,extraQryString,cellId)
    {
        if(ibpUtils.isEmpty(frm))return;
		//reference the form
		frm=ibpUtils.objectOrGetId(frm, 'form');
		if(ibpUtils.isEmpty(frm))return;
		//handle validation
		if(!ibpUtils.isEmpty(validation) && ibpUtils.isArray(validation))
		{
            for (var i=0;i<validation.length;i++)
            {
				try{eval("ibpUtils.objectOrGetId(validation[i][0])."+validation[i][1]+"="+validation[i][2]);}catch(e){}
            }
		}
		//validate
		if(!ibpValidation.validateForm(frm))
			return false;
		//build query string
		var qs="";
		if(!ibpUtils.isEmpty(params) && ibpUtils.isArray(params))
		{
			var qsArr=[];
            for (var i=0;i<params.length;i++)
            {
				qsArr[i]=[params[i][0], ibpUtils.ntz(ibpUtils.getValueOf(params[i][1]),params[i][2])];
            }
			qs=ibpUtils.qryStringFromArray(qsArr);
		}
		//append extraQryString
		qs+="&"+extraQryString;
        //if cell id is passed - reload cell
        if(ibpUtils.isInteger(cellId))
        {
            reloadCell(cellId,null,null,qs);
        }
        //else - reload page
        else
        {
            var path=window.location.href;
            path=ibpUtils.addQueryStringParamToEnd(path,qs);
            ibpUtils.setWinLocation(null,path);
        }
    }
    this.reloadIfValidForm=reloadIfValidForm;
	
    /*
        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(ibpUtils.isEmpty(win))win=window;
        //path to popup
        var path="ibp.jsp?ibpPage=PopupPage&ibpInfolet=Send/sendPage.jsp";
        var url="";
        var title="";
        var cellId="";
        if(cell)
        {
            //cell mode
            path=ibpUtils.addQueryStringParam(path,"enaMode","cell");
            //get clicked cell id and title
            var srcClickElmnt=global.enSrcElmntToMove;
            if(ibpUtils.isEmpty(srcClickElmnt))return;
            cellId=srcClickElmnt.getAttribute("componentIndex");
            title=srcClickElmnt.getAttribute("enComponentTitle");
            var clsSuffix=srcClickElmnt.getAttribute("enComponentClassSuffix");
            if(!ibpUtils.isInteger(cellId))return;
            //get mesures
            var absPos=ibpUtils.elmntAbsPos("tdComponentBody"+cellId);
            var cellWidth=Math.max(280,absPos.width);
            //get current page
            var page=global.currentPageName;
            //build url
            url=ibpUtils.addQueryStringParam(ibpUtils.getBaseUrl()+"bin/ibp.jsp","ibpPage",page);
            url=ibpUtils.addQueryStringParam(url,"enaMode","sent");
            url=ibpUtils.addQueryStringParam(url,"enaCellId",cellId);
            url=ibpUtils.addQueryStringParam(url,"enaCellWidth",cellWidth);
            url=ibpUtils.addQueryStringParam(url,"enaCellClassSuffix",clsSuffix);
        }
        else
        {
            url=win.location.href;
            title=win.document.title;
        }

        path=ibpUtils.addQueryStringParam(path,"enaSendUrl",url);
        path=ibpUtils.addQueryStringParam(path,"enaSendTitle",title);
		//mark as javascript unicode string
		path=ibpUtils.addQueryStringParam(path,"ibpUTF8ParamNames","enaSendTitle");

        ibpUtils.openPopupWindow(path,"enSendWin");
    }
    this.openSendToFriend=openSendToFriend;

	/*
        set portlet mode (when portlets are enabled)
        params:
          	uid - portlet uid
			mode - portlet mode
    */
	var setPortletMode=function(uid,mode)
	{
        if(ibpUtils.isEmpty(uid))return;
		mode=ibpUtils.ntz(mode,"view");
		//start with current possition
		var url=window.location.href;
		url=ibpUtils.addQueryStringParam(url,"ibpAction","portletState");
		url=ibpUtils.addQueryStringParam(url,"ibpActOnWhat","portletWin");
		url=ibpUtils.addQueryStringParam(url,"ibpActOnWho",uid);
		url=ibpUtils.addQueryStringParam(url,"ibpPortletMode",mode);
		url=ibpUtils.addQueryStringParam(url,"cbReload","1");
		url=ibpUtils.addQueryStringParam(url,"ibpRand",Math.random());
		ibpUtils.execAsync('fraExec',url,'fraExec',true);
	}
	this.setPortletMode=setPortletMode;
	
	/*
        set portlet window state (when portlets are enabled)
        params:
          	uid - portlet uid
			state - portlet window state
    */
	var setPortletWindowState=function(uid,state)
	{
        if(ibpUtils.isEmpty(uid))return;
		state=ibpUtils.ntz(state,"normal");
		//start with current possition
		var url=window.location.href;
		url=ibpUtils.addQueryStringParam(url,"ibpAction","portletState");
		url=ibpUtils.addQueryStringParam(url,"ibpActOnWhat","portletWin");
		url=ibpUtils.addQueryStringParam(url,"ibpActOnWho",uid);
		url=ibpUtils.addQueryStringParam(url,"ibpPortletState",state);
		url=ibpUtils.addQueryStringParam(url,"cbReload","1");
		url=ibpUtils.addQueryStringParam(url,"ibpRand",Math.random());
		ibpUtils.execAsync('fraExec',url,'fraExec',true);
	}
	this.setPortletWindowState=setPortletWindowState;
	
	
    /*---------------------------------------------------------------------------------------
        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(!ibpUtils.isSet(multi))multi=false;
        elmnt=ibpUtils.objectOrGetId(elmnt);
        divContainer=ibpUtils.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=ibpUtils.trim(nodeTitle);
        var selectedClassName='treeNodeSelected'+ibpUtils.ntz(classSuffix);
        if(elmnt.className==selectedClassName)
        {
            if(!multi)return;
            else//unselect it and remove it from pickedNodeSysName
            {
                var usSelectedClassName='treeNode'+ibpUtils.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(ibpUtils.endsWith(selected,","+nodeSysName))
                    {
                        selected=selected.substr(0,selected.length-(nodeSysName.length+1));
                    }
                    else if(ibpUtils.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(ibpUtils.endsWith(selectedTitles,","+nodeTitle))
                    {
                        selectedTitles=selectedTitles.substr(0,selectedTitles.length-(nodeTitle.length+1));
                    }
                    else if(ibpUtils.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" && !ibpUtils.isEmpty(nodeSysName))
            {
                var selected=ibpUtils.ntz(divContainer.getAttribute('pickedNodeSysName'));
                if(!ibpUtils.isEmpty(selected))selected+=",";
                selected+=nodeSysName;
                divContainer.setAttribute('pickedNodeSysName',selected);
                var selectedTitles=ibpUtils.ntz(divContainer.getAttribute('pickedNodeTitle'));
                if(!ibpUtils.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'+ibpUtils.ntz(classSuffix);
        var usSelectedClassName='treeNode'+ibpUtils.ntz(classSuffix);
        divContainer=ibpUtils.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(!ibpUtils.isSet(img))return;
        img=ibpUtils.objectOrGetId(img);
        if(ibpUtils.isEmpty(img))return;
        var altPlus=ibpMsg.get("ibpApp.expand");
        var altMinus=ibpMsg.get("ibpApp.collapse");

        var imgUrl,imgPath,imgSplit,imgName,imgAlt;
        imgUrl = img.src;
        imgPath=ibpUtils.getFolderFromUrl(imgUrl);
        imgName=ibpUtils.getFileFromUrl(imgUrl);

        imgAlt = img.alt ;
        if(ibpUtils.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=ibpUtils.objectOrGetId(showHideDiv);
        if(!ibpUtils.isEmpty(showHideDiv))
            ibpUtils.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(!ibpUtils.isSet(flag)) flag=true;
            if(ibpUtils.isEmpty(containerElement)) containerElement="document";
            if(ibpUtils.isEmpty(refTagName)) refTagName="img";
            if(ibpUtils.isEmpty(relAttributeName)) relAttributeName="enRelItemID";
            //end of "set default values"
            containerElement = ibpUtils.objectOrGetId(containerElement);
            var imagesArray=containerElement.getElementsByTagName(refTagName);
            for(var i=0;i<imagesArray.length;i++)
            {
                if(!ibpUtils.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=ibpUtils.objectOrGetId(elId);
        if(ibpUtils.isEmpty(el) || ibpUtils.isEmpty(newEl))return;
        //the following runs on ns only when dealing with different frames
        /*if(ibpSpy.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=ibpUtils.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(!ibpUtils.isEmpty(div))
            {
                attrVal=div.getAttribute(attr);
            }
            if(ibpUtils.isEmpty(attrVal) && !ibpUtils.isEmpty(img))
            {
                img.getAttribute(attr)
            }
            if(ibpUtils.isEmpty(attrVal) && !ibpUtils.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 ibpUtils.trim(spn.childNodes[i].nodeValue);
            }
            return "";
        }
        var _getChidrenNo=function(){return ibpUtils.enParseInt(_getCascadeAttribute("entChildren"));}
        var _getTreeName=function(){return _getAttribute("entTreeName");}
        var _getTreePrefix=function(){return _getAttribute("entTreePreFix");}
        var _isOpen=function(){return ibpUtils.toBoolean(_getAttribute("entIsOpen"));}
        var _setIsOpen=function(status){return _setAttribute("entIsOpen",status);}
        var _isChildLoaded=function(){return ibpUtils.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(!ibpUtils.isEmpty(rootNode))selected=rootNode.getAttribute("pickedNodeSysName");
            return selected;
        }
        var _getSelectedName=function()
        {
            var selected=_getSelectedNames();
            if(ibpUtils.isEmpty(selected))return selected
            var selArr=selected.split(",");
            return selArr[0]
        }
        var _getSelectedTitles=function()
        {
            var selected="";
            var rootNode= _getRootNode();
            if(!ibpUtils.isEmpty(rootNode))selected=rootNode.getAttribute("pickedNodeTitle");
            return selected;
        }
        var _getSelectedTitle=function()
        {
            var selected=_getSelectedTitles();
            if(ibpUtils.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(ibpUtils.isEmpty(prefix) && ibpUtils.isEmpty(nodeName))
        {
            var divs=document.getElementsByTagName("DIV");
            if(!ibpUtils.isEmpty(divs))
            {
                for(var i=0;i<divs.length;i++)
                {
                    if(ibpUtils.toBoolean(divs[i].getAttribute("entUITreeNode")) || ibpUtils.toBoolean(divs[i].getAttribute("entUITreeRoot")))
                    {
                        enTreeNode=getENUITreeNode(divs[i]);
                        break;
                    }
                }
            }
        }
        else
            enTreeNode=getENUITreeNode(prefix+nodeName+"Div");

        if(ibpUtils.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=ibpUtils.toBoolean(enRootNode.getAttribute("entMultiSlct"),false);
        var nodeSysName=ibpUtils.ntz(treeNode.getNodeName());
        var nodeTitle=ibpUtils.ntz(treeNode.getNodeTitle());
        var usSelectedClassName='treeNode'+ibpUtils.ntz(classSuffix);
        var selectedClassName='treeNodeSelected'+ibpUtils.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(ibpUtils.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(ibpUtils.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)treeNodeClearSelect(divContainer,classSuffix);
            //select node + set picked node in enRootNode
            spn.className=selectedClassName;
            if(multi)
            {
                var selectedNames=ibpUtils.ntz(enRootNode.getAttribute('pickedNodeSysName'));
                if(!ibpUtils.isEmpty(selectedNames))selectedNames+=",";
                selectedNames+=nodeSysName;
                enRootNode.setAttribute('pickedNodeSysName',selectedNames);
                var selectedTitles=ibpUtils.ntz(enRootNode.getAttribute('pickedNodeTitle'));
                if(!ibpUtils.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(ibpUtils.isEmpty(ignoreExec))ignoreExec=false;
        //if proccessing return (try because text frame may be empty)
        try{
            if(!ignoreExec && ibpUtils.isExecAsync("fraExec",true,null,null,true,false))return;
        }catch(e){return;}
        if(treeNode.getChidrenNo()<=0)return;
        var nodeSysName=ibpUtils.ntz(treeNode.getNodeName());
        var imgEl=treeNode.getImageEl();
        var spnEl=treeNode.getSpanEl();
        var iconEl=treeNode.getIconEl();
        var childDivEl=treeNode.getChildDivEl();
        var closeAction=ibpUtils.toBoolean(treeNode.getAttribute("entIsOpen"))
        var childLoaded=ibpUtils.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=ibpMsg.get("ibpApp.expand");
        var imgOpen=enRootNode.getAttribute("entImgOpen");
        var altOpen=ibpMsg.get("ibpApp.collapse");
        //change current open ststus
        treeNode.setIsOpen(!closeAction);
        //replace close/open images
        if(imgEl)
        {
            if(!ibpUtils.isEmpty(imgClose) && !ibpUtils.isEmpty(imgOpen))
                imgEl.src=closeAction?imgClose:imgOpen;
            imgEl.alt=closeAction?altClose:altOpen;
        }
        //replace open close icon
        if(iconEl && !ibpUtils.isEmpty(iconClose) && !ibpUtils.isEmpty(iconOpen))
        {
            iconEl.src=closeAction?iconClose:iconOpen;
        }
        //show hide childs div
        //THIS HAS A BUG: EREZ H
        //ibpUtils.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"];
            ibpUtils.setValueOf(actionCtrl,"enaExpandNode");
            ibpUtils.setValueOf(expandNodeCtrl,nodeSysName);
            ibpUtils.setValueOf(cbfnCtrl,"ibpApp.genENUITreeNodeCbfn");
            //put sub entity type (empty if root, for colision of cat & class name)
            if(ibpUtils.toBoolean(treeNode.getAttribute("entUITreeRoot")))
                ibpUtils.setValueOf(subEntityTypeCtrl,"");
            else
                ibpUtils.setValueOf(subEntityTypeCtrl,ibpUtils.ntz(treeNode.getAttribute("entSubEntityType")));
            var useProgress=global.useProgressBar && ibpUtils.toBoolean(enRootNode.getAttribute("entUseProgExpand"));
            if(!ibpUtils.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"];
        ibpUtils.setValueOf(actionCtrl,act);
        ibpUtils.setValueOf(cbfnCtrl,"ibpApp.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 && ibpUtils.toBoolean(enRootNode.getAttribute("entUseProgFilter"));
        if(!ibpUtils.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"];
        ibpUtils.setValueOf(actionCtrl,"enaFullExpand");
        ibpUtils.setValueOf(cbfnCtrl,"ibpApp.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 && ibpUtils.toBoolean(enRootNode.getAttribute("entUseProgFullExpand"));
        //check if allready full expanded
        if(ibpUtils.toBoolean(enRootNode.getAttribute("entFullExpanded")))
        {
            if(useProgress){showProgressaBar();}
            fullExpndCollpse(enRootNode,true);
            if(useProgress){hideProgressaBar();}
        }
        else if(!ibpUtils.isExecAsync("fraExec",false,null,null,false,useProgress))
        {
            enRootNode.setAttribute("entFullExpanded",true);
            //handle preselected & search that might change
            var preSlctVtrl=frm.elements[preSlctCtrlName];
            if(preSlctVtrl)ibpUtils.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 && ibpUtils.toBoolean(enRootNode.getAttribute("entUseProgExpand"));
        //start progeress bar
        var useProgress=global.useProgressBar
        if(enRootNode!=null)useProgress=useProgress && ibpUtils.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(ibpUtils.isEmpty(nodeName))continue;
            treeNode=getENUITreeNode(div);
            if(!treeNode)continue;
            if(ibpUtils.toBoolean(treeNode.getAttribute("entIsOpen"))^expand)
            {
                expandENUITreeNode(null,treeNode,true);
            }
        }
        if(ibpUtils.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 ibpUtils.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(!ibpUtils.isEmpty(closedNode) && !ibpUtils.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(!ibpUtils.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(!ibpUtils.isEmpty(prm.totSegs))
                            totSegsCtrl.value=ibpUtils.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);
            }
        }
        ibpUtils.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=ibpUtils.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(!ibpUtils.isEmpty(imgPrev) && !ibpUtils.isEmpty(imgNext)
            && !ibpUtils.isEmpty(currSegIdCtrl) && !ibpUtils.isEmpty(totSegsCtrl))
        {
            var currSegId=ibpUtils.enParseInt(currSegIdCtrl.value);
            var totSegs=ibpUtils.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(ibpUtils.isEmpty(path))return path;
        if(!ibpUtils.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(!ibpUtils.isObject(frm) && !ibpUtils.isArray(frm))return false;
        //get form ref
        var frmElmnt=ibpUtils.objectOrGetId(frm.frmId);
        //try by name
        if(!frmElmnt)frmElmnt=ibpUtils.objectOrGetId(frm.frmId,"form");
        if(!frmElmnt)return false;

        var baseDivElmnt=ibpUtils.objectOrGetId(baseDiv);
        //increment counter, if not exist initial it
        if(!ibpUtils.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(ibpUtils.isSet(delBtn))
        {
            delId=delBtn.delBtnId;
            delEvnt=ibpUtils.isEmpty(delBtn.delBtnEvent)?"click":delBtn.delBtnEvent;
            delFn=ibpUtils.isEmpty(delBtn.delBtnFunction)?rowsBrwsrDelete:delBtn.delBtnFunction;
            //find seperator
            var delBtn=ibpUtils.objectOrGetId(delId);
            seperator=(!delBtn)?"":delBtn.getAttribute("enSeparator");
        }
        //if we don't have seperator goto div
        if(ibpUtils.isEmpty(seperator)){
            seperator=(!baseDivElmnt)?"":baseDivElmnt.getAttribute("enSeparator");
        }
        if(ibpUtils.isEmpty(seperator)) seperator="@";
        //add base div elements (check if it the delBtn, and add event if so)
        var lastBtn="";
        if(ibpUtils.isSet(frm.insertBeforeEl)) lastBtn=ibpUtils.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(ibpUtils.isEmpty(lastBtn))
                    frmElmnt.appendChild(objElmnt);
                else
                    frmElmnt.insertBefore(objElmnt,lastBtn);
                //if delete button add event
                if(objElmnt.id==delId){
                    ibpUtils.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=ibpUtils.evtGetCBEvent(e);
        delElmnt=evt.target;
        //find the seperator
        var seperator="";
        seperator=delElmnt.getAttribute("enSeparator");
        if(ibpUtils.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(ibpUtils.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=ibpUtils.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=ibpUtils.objectOrGetId(frm,"form");
        if(ibpUtils.isEmpty(frm))return;
        tr=ibpUtils.objectOrGetId(tr);
        if(ibpUtils.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(ibpUtils.isEmpty(frm) || ibpUtils.isEmpty(attrName))return false;
        //check if an array. if not - convert into an array
        if(!ibpUtils.isArray(attrName))attrName=[attrName];
        var attrsLen=attrName.length;
        var elementsLen=0;
        var ok,emptyEl,el;

        //get form ref
        frm=ibpUtils.objectOrGetId(frm,"form");
        if(ibpUtils.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);
            ibpUtils.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(ibpUtils.isEmpty(msg))msg=ibpMsg.get("ibpApp.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(ibpUtils.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' && ibpUtils.isEmpty(ibpUtils.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(ibpUtils.isEmpty(ibpUtils.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=ibpUtils.objectOrGetId(frm,"form");
        if(ibpUtils.isEmpty(frm))return 0;
        var el,pos,ix,maxIx=-1;
        for(var i=0;i<frm.elements.length;i++)
        {
            el=frm.elements[i];
            if(!ibpUtils.isEmpty(el.name))
            {
                pos=el.name.indexOf(attrName+"_");
                if(pos==0)
                {
                    ix=el.name.substring(pos+(attrName+"_").length);
                    if(ibpUtils.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=ibpUtils.objectOrGetId(frm,"form");
        if(ibpUtils.isEmpty(frm))return;

        if(ibpUtils.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(ibpUtils.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(!ibpUtils.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=ibpUtils.objectOrGetId(frm,"form");
        if(ibpUtils.isEmpty(frm))return;
        if(ibpUtils.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=ibpUtils.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++]=ibpUtils.getValueOf(el);
            }
            else if(el.name==attrVal)
            {
                vals[ivals++]=ibpUtils.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(ibpUtils.isEmpty(o))return "";
        o=ibpUtils.qryStringFromArray(o);
        //add trailing &
        o+="&";
        if(!ibpUtils.isEmpty(txt))ibpUtils.setValueOf(ibpUtils.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(!ibpUtils.isEmpty(elTd))
                        {
                            cellIdAttr=elTd.getAttribute("enPageCellId");
                            if(!ibpUtils.isEmpty(cellIdAttr))
                            {
                                if(!ibpUtils.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(!ibpUtils.isEmpty(elTd))
                    {
                        cellIdAttr = elTd.getAttribute("enPageCellId");
                        if(!ibpUtils.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/moved
    */
    var saveUserCellsOrder=function(dataArray)
    {
        var doUpdate=0;
        var cellsOrderStr="";
		//loop on all zone frame items
        for(var i=0;i<dataArray.length;i++)
        {
			//check the 'changed' flag
            if(dataArray[i][1])
            {
				//append the cells order (all groups are appended together)
                cellsOrderStr+=dataArray[i][2]+",";
                doUpdate=1;
            }
        }
        //if cells were moves or cells should be deleted
        doUpdate=(doUpdate||!ibpUtils.isEmpty(global.zfHideCells));
        if(doUpdate)
        {
            var pageName = global.currentPageName;
            var execPath = "ibp.jsp?ibpAction=custom&ibpActionInfolet=Personalize/cellsExec.jsp";
            execPath+="&ibpHidden=1";
            execPath=ibpUtils.addQueryStringParam(execPath,"enaCellsOrder",cellsOrderStr);
            execPath=ibpUtils.addQueryStringParam(execPath,"cbfn","ibpApp.moveCellsCbfn");
            execPath=ibpUtils.addQueryStringParam(execPath,"cbflag","fraExec");
            execPath=ibpUtils.addQueryStringParam(execPath,"enaPage",pageName);
            execPath=ibpUtils.addQueryStringParam(execPath,"enaDelCells",global.zfHideCells);
            if(ibpUtils.isExecAsync('fraExec'))return false;
            ibpUtils.execAsync('fraExec',execPath);
        }
        var el = new Object();
        el.showHide = "hide" ;
        ibpUtils.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(ibpUtils.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" ;
            ibpUtils.ifrShowFloatingIfr("fraMoveCells",null,el);
        }
        ibpUtils.defaultCallBack(prm) ;
    }
    this.moveCellsCbfn=moveCellsCbfn;


    /*
        hide page cell
        params:
                elmnt - the cell element
    */
	var hidePageCell=function(elmnt)
	{
        elmnt=ibpUtils.objectOrGetId(elmnt);
        var cellId = elmnt.getAttribute("componentIndex");
		var args=[
			["ibpAction","setVisible"]
			,["ibpActOnWhat","pagecell"]
			,["ibpActOnWho",global.currentPageName+"#"+cellId]
			,["IS_VISIBLE","0"]
			,["cbReload","1"]
		];
		var url="ibp.jsp?"+ibpUtils.qryStringFromArray(args);
  		ibpUtils.confirmActionHidden(url,'fraExec',null,null,ibpMsg.get("ibpApp.confirmHideCell"));
	}
	this.hidePageCell=hidePageCell;
	
    /*
        show or hide components
		@deprecated as of version 5.0
        params:
                elmnt - the component id
                showOrHide - the action that need to do (show or Hide)
    */
    var showOrHideCell=function(elmnt,showOrHide)
    {
        elmnt=ibpUtils.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(ibpUtils.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=ibpUtils.enParseInt(idArray[1]);
        var srcRow=ibpUtils.enParseInt(idArray[2]);
        var srcCell=ibpUtils.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]=!ibpUtils.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]=!ibpUtils.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]=!ibpUtils.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]=!ibpUtils.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]=!ibpUtils.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]=!ibpUtils.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]=!ibpUtils.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]=!ibpUtils.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(ibpUtils.isEmpty(srcTd) || srcTd.nodeName=="BODY")break;
        }
		
        var imgSuffix="";
        var isMoveable=global.enSrcElmntToMove.getAttribute("enMoveCellsMoveable");
        var isPersonalizable=global.enSrcElmntToMove.getAttribute("enMoveCellsPersonalizable");
        var hideComponent = global.enSrcElmntToMove.getAttribute("enHideComponent");
        var moveableArray = canMoveTd(ibpUtils.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(!ibpUtils.isEmpty(global.charset))
        {
            src+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset="+global.charset+"\">\n";
        }
        src+="<link rel=\"stylesheet\" type=\"text/css\" href=\""+ibpUtils.getBaseUrl()+"Static/Include/basic.css\">\n" ;
        src+="<link rel=\"stylesheet\" type=\"text/css\" href=\""+ibpUtils.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.ibpApp.global.moveCellsFlag=1;\n";
        src+=    "callingWin.ibpApp.imgMoveClick(param);\n";
        src+="}\n";

        src+="function cancelUserChoose()\n";
        src+="{\n";
        src+=    "callingWin.ibpApp.global.moveCellsFlag=0;\n";
        src+=    "callingWin.ibpApp.hideMoveCellsPopup();\n";
        if(!ibpUtils.isEmpty(global.zfHideCells) || global.moveCellsFlag==1)
        {
            src+="callingWin.location.reload();\n" ;
        }
        src+="}\n";

        src+="function confirmUserCellsOrder()\n";
        src+="{\n";
        src+=    "callingWin.ibpApp.global.moveCellsFlag=0\n";
        src+=    "var dataArray = callingWin.ibpApp.setUserCellsOrder();     //get the new cells order\n";
        src+=    "callingWin.ibpApp.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.ibpApp.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=\""+ibpMsg.get("ibpApp.cell.save")+"\" class=\"submitForm\" ";
        src+=                "onclick=\"confirmUserCellsOrder();\" class=\"moveCellsMenuButton\">";
        src+=            "</td>";
        src+=            "<td>";
        src+=                "<input type=\"button\" value=\""+ibpMsg.get("ibpApp.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.ibpApp.printCell();callingWin.ibpApp.hideMoveCellsPopup();\">"+ibpMsg.get("ibpApp.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.ibpApp.openSendToFriend(null,true);callingWin.ibpApp.hideMoveCellsPopup();\">"+ibpMsg.get("ibpApp.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.ibpApp.reloadCell();callingWin.ibpApp.hideMoveCellsPopup();\">"+ibpMsg.get("ibpApp.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.ibpUtils.openPopupWindow('"+global.pagePrefrencesUrl+"',null,null,780,500); callingWin.ibpApp.hideMoveCellsPopup();\">"+ibpMsg.get("ibpApp.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(!ibpUtils.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(ibpUtils.isEmpty(title)) title=ibpMsg.get("ibpApp.progressBarDefTitle")+"\n";
            else if (title=="$NONE$")title="";
            var txt=document.createTextNode(title);
            el.appendChild(txt);
        }
        //if no interval use default
        if(ibpUtils.isEmpty(progressInterval))progressInterval=50;
        //if there is new end override default
        if(!ibpUtils.isEmpty(progressLength))global.progressBarVars.progressLength=progressLength;
        global.progressBarVars.progressAt = 0;
        var pDiv=document.getElementById("enaProgressDiv");
        if(ibpUtils.isEmpty(pDiv))return;
        winPos=ibpUtils.getWindowPos();
        pDiv.className="";
        var pDivWidth=ibpUtils.enParseInt(ibpUtils.isEmpty(pDiv.width)?pDiv.style.width:pDiv.width);
        var pDivHeight=ibpUtils.enParseInt(ibpUtils.isEmpty(pDiv.height)?pDiv.style.height:pDiv.height);
        pDiv.style.left=winPos.width/2-pDivWidth;
        pDiv.style.top=winPos.height/2-pDivHeight;
        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(ibpUtils.isEmpty(bar))return;
        bar.value+="||";
        global.progressBarVars.progressAt++;
        if(global.progressBarVars.progressAt>global.progressBarVars.progressLength)
        {
            bar.value="";
            global.progressBarVars.progressAt=0;
        }
    }
    this.updateProgressaBar=updateProgressaBar;

    // Hide the progress bar
    var hideProgressaBar=function () {
        var pDiv=document.getElementById("enaProgressDiv");
        if(!ibpUtils.isEmpty(pDiv))
            pDiv.className="hiddenEl";
        //stop the interval
        window.clearInterval(global.progressBarVars.progressId);
        //clear the bar
        var bar=document.getElementById("enaProgressBar");
        if(!ibpUtils.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$,$WEB-INF$, $web-inf$, $ibproot$, $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(ibpUtils.isEmpty(enaRetElement))return;
        //handle defaults
        enaMode=ibpUtils.ntz(enaMode,"1");
        enaRootFullPath=ibpUtils.ntz(enaRootFullPath,"0");
        enaRetAbs=ibpUtils.ntz(enaRetAbs,"0");
        enaRootFixed=ibpUtils.ntz(enaRootFixed,"0");
        enaUseTrailingSlash=ibpUtils.ntz(enaUseTrailingSlash,"0");
        if(ibpUtils.isEmpty(enaPreSelected))
            enaPreSelected=ibpUtils.getValueOf(enaRetElement);
        var enaWinName="fsBrowserWin";
        //variables
        var fsBrowserSource=ibpUtils.getBaseUrl()+"bin/ibp.jsp?ibpScript=FSBrowser/fsBrowser.jsp";
        fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaRetElement",enaRetElement);
        fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaMode",enaMode);
        if(!ibpUtils.isEmpty(enaRoot))
            fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaRoot",enaRoot);
        fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaRootFullPath",enaRootFullPath);
        fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaRetAbs",enaRetAbs);
        if(!ibpUtils.isEmpty(enaFilter))
			fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaFilter",enaFilter);
        fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaRootFixed",enaRootFixed);
        fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaUseTrailingSlash",enaUseTrailingSlash);
        if(!ibpUtils.isEmpty(enaCbfnFn))
            fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaCbfnFn",enaCbfnFn);
        if(!ibpUtils.isEmpty(enaPreSelected))
			fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaPreSelected",enaPreSelected);
		//mark as javascript unicode string
   		fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"ibpUTF8ParamNames","enaPreSelected,enaFilter");
		
        if(!ibpUtils.isEmpty(enaExcludeDrives))
            fsBrowserSource=ibpUtils.addQueryStringParam(fsBrowserSource,"enaExcludeDrives",enaExcludeDrives);

        ibpUtils.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(ibpUtils.isEmpty(enaRetWindow))return;
        var el = enaRetWindow.ibpUtils.objectOrGetId(enaRetElement) ;
        if(!ibpUtils.isEmpty(el))
        {
            ibpUtils.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=ibpUtils.objectOrGetId(enaRetElement);
        if(!retElement && ibpUtils.isEmpty(enaCbfnFn))return;
        var expr=ibpUtils.ntz(ibpUtils.getValueOf(retElement));
        //variables
        var exprBldrSource=ibpUtils.getBaseUrl()+"bin/ibp.jsp?ibpScript=ExprBuilder/exprBuilder.jsp";
        exprBldrSource=ibpUtils.addQueryStringParam(exprBldrSource,"enaRetElement",enaRetElement);
        //endoce expr
        exprBldrSource=ibpUtils.addQueryStringParam(exprBldrSource,"enaExpr",expr);
        //mark as javascript unicode string
        exprBldrSource=ibpUtils.addQueryStringParam(exprBldrSource,"ibpUTF8ParamNames","enaExpr");
        if(!ibpUtils.isEmpty(enaCbfnFn))
            exprBldrSource=ibpUtils.addQueryStringParam(exprBldrSource,"enaCbfnFn",enaCbfnFn);
        if(!ibpUtils.isEmpty(enaOpenMode))
            exprBldrSource=ibpUtils.addQueryStringParam(exprBldrSource,"enaOpenMode",enaOpenMode);
        if(!ibpUtils.isEmpty(enaForceMode))
            exprBldrSource=ibpUtils.addQueryStringParam(exprBldrSource,"enaForceMode",enaForceMode);
        ibpUtils.openPopupWindow(exprBldrSource,"enaExprBuilderWin",null,780,580);
    }
    this.openExprBuilder=openExprBuilder;
    /*
        exprBuilderCbfn

    */
    var exprBuilderCbfn=function(enaRetWindow,enaRetElement,expr)
    {

        if(ibpUtils.isEmpty(enaRetWindow))return;
        var el = enaRetWindow.ibpUtils.objectOrGetId(enaRetElement) ;
        if(!ibpUtils.isEmpty(el))
        {
            ibpUtils.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.
                                   	naEntitiesPickerOnChange 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=ibpUtils.objectOrGetId(retElement);
        if(ibpUtils.isEmpty(retElement) || ibpUtils.isEmpty(params))return;
        openMethod=ibpUtils.ntz(openMethod,"window").toLowerCase();
        var isWin=openMethod!="iframe";
        if(!ibpUtils.isEmpty(width))width=ibpUtils.enParseInt(width);
        if(ibpUtils.isEmpty(width) || width<=0)width=280;
        if(!ibpUtils.isEmpty(height))height=ibpUtils.enParseInt(height);
        if(ibpUtils.isEmpty(height) || height<=0)height=280;
        //get current selected value
        var selectedVal=ibpUtils.getValueOf(retElement.getAttribute("enaEntitiesPickerRetElName"));
        //variables
        var sysObjPickerSource=ibpUtils.getBaseUrl()+"bin/ibp.jsp?ibpScript=EntityPicker/entityPicker.jsp";
        //ret element
        sysObjPickerSource=ibpUtils.addQueryStringParam(sysObjPickerSource,"enaRetElement",retElement.id);
        //width and height
        sysObjPickerSource=ibpUtils.addQueryStringParam(sysObjPickerSource,"enaWidth",width);
        sysObjPickerSource=ibpUtils.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=ibpUtils.addQueryStringParam(sysObjPickerSource,params[i][0],params[i][1]);
        }
        //handle the case when there is no entPreSelected parameter, but there is a selected value
        if(!ibpUtils.isEmpty(selectedVal))
        {
            sysObjPickerSource=ibpUtils.addQueryStringParam(sysObjPickerSource,"entPreSelected",selectedVal);
        }
        //win attributes
        if(isWin)
        {
            var winAtts = ",resizable=1,status=0,menubar=0,scrollbars=0,fullscreen=0";
            ibpUtils.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;
            ibpUtils.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.ibpUtils.ifrShowFloatingIfr("fraObjPicker",null,ifrParams);
            //clear iframe src
            window.parent.ibpUtils.clearIFrameSrc("fraObjPicker");
        }
    }
    this.hideSysEntitiesPicker=hideSysEntitiesPicker;

    /*
        close object picker on escape press
        how to use:
            ibpUtils.evtAddEvent(document,"keyup",ibpApp.hideSysEntitiesPickerOnEsc);
    */
    var hideSysEntitiesPickerOnEsc=function(e)
    {
        //get event
        var e=ibpUtils.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(ibpUtils.isEmpty(enaRetWindow))return;
        var el = enaRetWindow.ibpUtils.objectOrGetId(enaRetElement);
        if(!ibpUtils.isEmpty(el))
        {
            //get the name target & title taregt
            var nameEl=enaRetWindow.ibpUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElName"));
            if(!ibpUtils.isEmpty(nameEl) && pickedName!=-1)
            {
                if(nameEl.value!=pickedName)
                {
                    ibpUtils.setValueOf(nameEl,pickedName);
                    var titleEl=enaRetWindow.ibpUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElTitle"));
                    if(!ibpUtils.isEmpty(titleEl))
                        ibpUtils.setValueOf(titleEl,pickedTitle);
                    var onChange=el.getAttribute("enaEntitiesPickerOnChange");
                    if(!ibpUtils.isEmpty(onChange))
                    {
                        //fix onchange - replace $title$ with titles and $name$ with names
                        onChange=onChange.replace("$title$",ibpUtils.escapeJs(pickedTitle));
                        onChange=onChange.replace("$name$",ibpUtils.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 = ibpUtils.objectOrGetId(enaRetElement) ;
        if(!ibpUtils.isEmpty(el))
        {
            //get the name target & title taregt
            var nameEl=ibpUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElName"));
            if(!ibpUtils.isEmpty(nameEl))
            {
                if(!ibpUtils.isEmpty(nameEl.value))
                {
                    ibpUtils.setValueOf(nameEl,"");
                    var titleEl=ibpUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElTitle"));
                    if(!ibpUtils.isEmpty(titleEl))
                        ibpUtils.setValueOf(titleEl,"");
                    var onChange=el.getAttribute("enaEntitiesPickerOnChange");
                    if(!ibpUtils.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";
        ibpUtils.ifrShowFloatingIfr("fraObjPicker",null,ifrParams);
        //clear iframe src
        ibpUtils.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 ibpApp.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 ibpUtils.formatAsDateTime())
        [timeFormat]     the format to present the time (for supprted formats see ibpUtils.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(!ibpUtils.isSet(el))return;
        if(!ibpUtils.isSet(trgt))return;
        cbfn=ibpUtils.ntz(cbfn,"ibpApp.showCalendarCbfn");
        calendarType=ibpUtils.ntz(calendarType,"null");
        if(ibpUtils.isSet(dateFrom) && dateFrom.constructor==Date)
            dateFrom="new Date("+dateFrom.getFullYear()+","+dateFrom.getMonth()+","+dateFrom.getDate()+")";
        else
            dateFrom="null"
        if(ibpUtils.isSet(dateTo) && dateTo.constructor==Date)
            dateTo="new Date("+dateTo.getFullYear()+","+dateTo.getMonth()+","+dateTo.getDate()+")";
        else
            dateTo="null"
        dateFormat=(ibpUtils.isEmpty(dateFormat))?"null":"'"+dateFormat+"'";
        timeFormat=(ibpUtils.isEmpty(timeFormat))?"null":"'"+timeFormat+"'";
        startDay=ibpUtils.ntz(startDay,"null");
        startYear=ibpUtils.ntz(startYear,"null");
        endYear=ibpUtils.ntz(endYear,"null");
        addButtons=ibpUtils.ntz(addButtons,"null");
        //create the calendar base HTML source
        var tmpStr="<html "+(global.isRTL?"dir=\"rtl\"":"")+">\n";
        tmpStr += "<head>\n<link rel=\"STYLESHEET\" href=\""+ibpUtils.getBaseUrl()+"Static/Common/CalendarDOM/calendar.css\" type=\"text/css\">\n";
        tmpStr += "<sc"+"ript language=\"JavaScript\" src=\""+ibpUtils.getBaseUrl()+"Static/Common/CalendarDOM/calendar.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="200";
        ifrParams.ifrHeight="51";//this changed in the control (except for time only control)
        ibpUtils.ifrShowFloatingIfr(ifr,el,ifrParams);
    }
    this.showCalendar=showCalendar;
    /*
    close the calendar iframe
    */
    var hideCalendar=function()
    {
        //close calendar
        var ifrParams=new Object();
        ifrParams.showHide="hide";
        ibpUtils.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 ibpUtils.formatAsDateTime())
        [timeFormat]     the format to present the returned time (for supprted formats see ibpUtils.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(!ibpUtils.isEmpty(longDateEl))
        {
            longDateEl.value=pickedDate.getTime();
        }
        */
        //handle presentation
        if(target.nodeName.toUpperCase()=="INPUT")
        {
            target.value=ibpUtils.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: ibpApp.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(ibpUtils.isEmpty(enaClass) || enaClass=="NO_CLASS")
        {
            if(!ibpUtils.ntz(enaSilent,false))alert(ibpMsg.get("ibpApp.qbe.noclass"));
            return;
        }
        //variables
        var qbeSource=ibpUtils.getBaseUrl()+"bin/ibp.jsp?ibpScript=ClassQbe/classQbe.jsp";
        qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaClass",enaClass);
        //Add extra parameters
        if(qbeExParams)
        {
            if(!ibpUtils.isEmpty(qbeExParams.enaCbfnFn))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaCbfnFn",qbeExParams.enaCbfnFn);
            if(!ibpUtils.isEmpty(qbeExParams.enaCbSlctEl))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaCbSlctEl",qbeExParams.enaCbSlctEl);
            if(!ibpUtils.isEmpty(qbeExParams.enaCbWhrEl))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaCbWhrEl",qbeExParams.enaCbWhrEl);
            if(!ibpUtils.isEmpty(qbeExParams.enaCbOrdrEl))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaCbOrdrEl",qbeExParams.enaCbOrdrEl);
            if(!ibpUtils.isEmpty(qbeExParams.enaActTypes))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaActTypes",qbeExParams.enaActTypes);
            if(!ibpUtils.isEmpty(qbeExParams.enaSelect))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaSelect",qbeExParams.enaSelect);
            if(!ibpUtils.isEmpty(qbeExParams.enaWhere))
			{
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaWhere",qbeExParams.enaWhere);
				//mark as javascript unicode string
        		qbeSource=ibpUtils.addQueryStringParam(qbeSource,"ibpUTF8ParamNames","enaWhere");
			}
            if(!ibpUtils.isEmpty(qbeExParams.enaOrder))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaOrder",qbeExParams.enaOrder);			
            if(!ibpUtils.isEmpty(qbeExParams.enaTitle))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaTitle",qbeExParams.enaTitle);
            if(!ibpUtils.isEmpty(qbeExParams.enaQbeTitle))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaQbeTitle",qbeExParams.enaQbeTitle);
            if(!ibpUtils.isEmpty(qbeExParams.enaSlctSize))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaSlctSize",qbeExParams.enaSlctSize);
            if(!ibpUtils.isEmpty(qbeExParams.enaExcAttrs))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaExcAttrs",qbeExParams.enaExcAttrs);
            if(!ibpUtils.isEmpty(qbeExParams.enaIncAttrs))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaIncAttrs",qbeExParams.enaIncAttrs);
            if(!ibpUtils.isEmpty(qbeExParams.enaUnSlctAttrs))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaUnSlctAttrs",qbeExParams.enaUnSlctAttrs);
            if(!ibpUtils.isEmpty(qbeExParams.enaFromSig))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaFromSig",qbeExParams.enaFromSig);
            if(!ibpUtils.isEmpty(qbeExParams.enaToSig))
                qbeSource=ibpUtils.addQueryStringParam(qbeSource,"enaToSig",qbeExParams.enaToSig);
        }
        ibpUtils.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(ibpUtils.isEmpty(retWindow) || ibpUtils.isEmpty(retElsObj) || ibpUtils.isEmpty(qbeParamsObj))return;
        var slctEl=retWindow.ibpUtils.objectOrGetId(retElsObj.enaCbSlctEl) ;
        var whereEl=retWindow.ibpUtils.objectOrGetId(retElsObj.enaCbWhrEl) ;
        var orderEl=retWindow.ibpUtils.objectOrGetId(retElsObj.enaCbOrdrEl) ;
        if(!ibpUtils.isEmpty(slctEl))
        {
            if(ibpUtils.ntz(qbeParamsObj.select)=="*")
                ibpUtils.setValueOf(slctEl,"");
            else
                ibpUtils.setValueOf(slctEl,ibpUtils.ntz(qbeParamsObj.select));
        }
        if(!ibpUtils.isEmpty(whereEl))ibpUtils.setValueOf(whereEl,ibpUtils.ntz(qbeParamsObj.where));
        if(!ibpUtils.isEmpty(orderEl))ibpUtils.setValueOf(orderEl,ibpUtils.ntz(qbeParamsObj.orderBy));
    }
    this.classQbeCbfn=classQbeCbfn;

}//end of construstor function

//instanciate object
if(!window.ibpApp)window.ibpApp=new ibpAppConstrustor();






function confirmDelete(delUrl) {
	if(confirm("האם אתה בטוח שברצונך למחוק?")) {
		document.location = delUrl;
	}
}

