/*************************************************************************************************************
application.js

application specific javascript functions

		
how to use:
===========
include this script in the page (after the enformisUtils):
		<!-- application specific script. instanciate a window level object enApplication-->
		&lt;script language="JavaScript" type="text/javascript"
			src="../Static/Include/application.js"&gt;&lt;/script&gt;

the script will create an object named enApplication (or window.enApplication)
	all functions are the object's methods result=enApplication.fnName();

enApplication Properties
=========================
global				an object to hold custom data for the application usage
	.URLs				an object with url names to be used in js.
						values should be set in the page header
		.home			home url
		.login			login page
	.mainFocusInUse		weather main focus iframe is being used
	.mainFocusVisible	weather main focus iframe is currently visible
	.mainFocusResPos	restore position of main focus
	.mainFocusResState	restore state (max / res)
	.zfMainArray		array that contain the new order of the components
	.zfHideCells		string that contain the items that should be hide
	.currentPageName	page name, set in header
	.defaultPageName	default page name
	.isHomePage			is this page a home page?
	.currentSkinName	skin name, set in header
	.linkManagePageMethod 	method to open page management screen (page name - popup, mainfocus, or empty)
	.baseUrl			base url to use in getBaseUrl
	.enSrcElmntToMove	the element that the moveCells menu will open from
	.moveCellsFlag		flag that check if was movement
	.moveCellsMenuHeight contain the move cells menu height 
	.pagePrefrencesUrl	contain the url that the prefrebces popup will be open	
	.currentScrollPos   current scroling position
	.useProgressBar		use progress bar with hidden execution
	.disableButtonOnExecute - disable buttons on execution
	.disableButtonList	- list of buttons to disable
	.progressBarVars	object to hold: 
						progressLength (no of dbl lines); progressAt (lines counter); progressId (window interval id)
	.dirtyFlag 			flag that sign if we should save personalization to DB.
	.confirmAutoRefresh confirm with user before auto reloading the window
	.autoRefreshRate	no of miliseconds for refresh
	.mapZonesToCells	an array to map zone names to cell ids on the page
	.mapComponentsToCells	an array to map component names to cell ids on the page
	.isRTL				is page direction RTL 
	.charset			client charset in use
	
	.defaultHelpFile 	default help file for the current page
	.specificHelpFile 	specific help file for the current page (comes from zone..)
	.isMainFocus		is the window in main focus?
	.supportsMainFocus	does the current page supports main focus?
	.mainFocusHeight	height of
	.mainFocusIsRelative use relative height (true/false)
	
	.sendToFriend		allow send to friend
	.sendToFriendComp 	allow send component to friend
	
enApplication functions
=========================
(name)					(description)
-------------------------------------------------------------
general
-------------------------------------------------------------
favsPromptTitle			prompt user for favs title
runAppFile				run client side application using ENLauncher(ActivX)
filterZoneObjects		filter zone objects view
filterZoneNotifObjects 	filter zone objects view by notifications
linkManageCurrPage 		link to current page management
reloadNotifsCell		reload notifd component cell
reloadOnComboChange 	reload on combo change
backupScrollPos  		save current scrolling position in global.currentScrollPos
restoreScrollPos 		sets current scrolling position
getSkinImgPath			builds the path to an image based on the current skin
alertNotLoginAndClose	give alert and closing the window
confirmAndRefresh 		confirm user and refresh window
setAutoRefreshTimeout	set window timeout to refresh page
setDisableButtonList	set list of buttons to disable on execution
getBaseUrl 				get base url (application root)

-------------------------------------------------------------
	online help
-------------------------------------------------------------
openPopUpHelp			open a window with online help
cancelIEHelp 			cancel IE help event
getHelpOnF1				open help on F1

-------------------------------------------------------------
floating Ifreame functions
-------------------------------------------------------------

general
-----------
	closeWindowOrFloatingIfrOnEsc 	close window or floating frame
	closeAllFloatingIfrs			close all iframes (called from document click)
	countAllFloatingIfrs			count all open iframes
	closeAllFloatingIfrsOnEsc		close all the iframes when press Esc (called from docuemnt.keyup)
	

sort Table
------------	
	sortTableMarkCell				sign or unsign the cell onmouseover or onmouseout
	
color picker
-------------
	showColorPicker			Build a color Picker
	hideColorPicker			Hiding the color picker
	hideColorPickerOnEsc 	hide color picker on escape press
	showColorPickerCbfn 	call back function to be called from the color picker

Tool tip
------------
	showToolTip				show tool tip onMouseOver
	hideToolTip				hide tool tip onMoseOut	

Move Cells
------------
	setUserCellsOrder		build a array that contain all the data about the new order
							of the cells.
	saveUserCellsOrder		save the new order of the components
	imgMoveClick			move the components
	moveCellsCbfn			check if the update is Done.
	showOrHideCell			show or hide cells
	moveCellsCreateHtml		create the HTML that will build the move cells menu
	canMoveTd				checks to what directions the td can be moved
-------------------------------------------------------------
Home page components
-------------------------------------------------------------
showMoveCellsPopup			show Move Cells board
hideMoveCellsPopup			hide Move Cells board
moveTd						Move the cells
switchTd					this function gets the td to move and the basic movement: R,L,U,D.
showMainFocus				shows the main div 'divMainFocus' according to a base elmnt (embeded in HomePage)
hideMainFocus				hides the main div 'divMainFocus'
setMainFocusIntIfrSize 		set internal iframe element size
toggleMainFocusVisibility	show or hide main focus
setMainFocusTitle			set the title of the main focus floating frame
toggleMainFocusMaxRes 		toggle main focus max / restore
maxMainFocus 				maximize main focus
restoreMainFocus 			restore main focus
toggleCellMinRes			toggle cell min / restore
printCell					print an individual cell
getCellsByZone				return a comma separated list of cell ids for a given zone name
getCellsByComponent				return a comma separated list of cell ids for a given component name
reloadCell					reload a cell
reloadCellCallBack			reload call back
reloadHomePageCompByZone	reload home page component by zone name
openSendToFriend			send page tp a friend

-------------------------------------------------------------
Hirarchic tree
-------------------------------------------------------------
treeNodeClick
elmntExpandOrCollapseTree open or close all the levels on tree
reloadChildrenNodes		insert next level nodes
elmntToggleShowHide		show or hide next level of tree and change icon fron '+' to '-'
						or from '-' to '+'


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 and set's it's focus
fsBrowserCbfn		call back function to be called from the file system browser

expression builder
------------------------
openExprBuilder		opens the expression builder and set's it's 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

Calendar
------------
showCalendar		opens the calendar in iframe.
hideCalendar		close the calendar.
showCalendarCbfn	The function to get back the date and handle it.
*************************************************************************************************************/

//enApplication construstor function
function enApplicationConstrustor()
{
	/*---------------------------------------------------------------------------------------
		Properties
	---------------------------------------------------------------------------------------*/
	//an object to hold custom data for the application usage
	var global=new Object();
	//an object with url names to be used in js.
	global.URLs=new Object();
	global.URLs.home=null;
	global.URLs.login=null;
	global.baseUrl="../";
	
	global.mainFocusInUse=false;
	global.mainFocusVisible=false;
	global.zfMainArray=new Array();
	global.zfHideCells="";
	//progress bar variables
	global.useProgressBar=false;
	global.disableButtonOnExecute=true;
	global.progressBarVars=new Object();
	global.progressBarVars.progressLength=40;
	global.progressBarVars.progressAt=0;
	global.progressBarVars.progressId=null;
	
	global.confirmAutoRefresh=true;
	global.isRTL=false;
	global.isMainFocus=false;
	global.supportsMainFocus=true;
	
	global.sendToFriend=true;
	global.sendToFriendComp=true;
	
	this.global = global ;

	/*---------------------------------------------------------------------------------------
		general
	---------------------------------------------------------------------------------------*/

	/*
		prompt user for favs title
		params:
			path - path to open
			title - initial title
			target - to open the window in
	*/
	var favsPromptTitle=function(path,title,target)
	{
		//before u start - check hidden execution with no flaging
		if(enUtils.isExecAsync('fraExec',null,null,null,true))return;
		if(!enUtils.isSet(path))return;
		title=!enUtils.isEmpty(title)?title:"";
		//allow user to change title
		var usrTitle=window.prompt(enMsg.get("enApplication.promptFavsTitle"),title);
		//if user canceled - exit
		if(usrTitle==null)return;
		
		//check hidden execution with flaging
		if(enUtils.isExecAsync('fraExec'))return;
		//if emrty, use original title
		usrTitle=!enUtils.isEmpty(usrTitle)?usrTitle:title;
		//change path - add title parameter
		path=enUtils.addQueryStringParam(path,"zoneLinkTITLE",usrTitle);
		//mark as javascript unicode string
		path=enUtils.addQueryStringParam(path,"enaJSU","1");
		if(enUtils.isEmpty(target))
		{
			enUtils.setWinLocation(window,path);
		}
		else
		{
			window.open(path,target);
		}
	}
	this.favsPromptTitle=favsPromptTitle;

	var runAppFile=function(path)
	{
		if(enUtils.isEmpty(path))return;
		var launcher=window.objENLauncher;
		//if we have launcher
		if(!enUtils.isEmpty(launcher))
		{
			try
			{
				window.objENLauncher.runFile(path);
			}
			catch(e){}
		}
		//if not - open in new window
		else
		{
			window.open(path,"_blank");
		}
	}
	this.runAppFile=runAppFile;
	
	//filter zone objects view
	var filterZoneObjects=function(status)
	{
		//def status
		if(enUtils.isEmpty(status))status=null;
		//build path
		var path=window.location.href;
		path=enUtils.addQueryStringParam(path,"enaFilterView",status);		
		//redirect
		enUtils.setWinLocation(null,path);
	}
	this.filterZoneObjects=filterZoneObjects;		
	
	//filter zone objects view by notifications
	var filterZoneNotifObjects=function(action)
	{
		//def action
		if(enUtils.isEmpty(action))action=null;
		//build path
		var path=window.location.href;
		path=enUtils.addQueryStringParam(path,"enaFilterNotif",action);		
		//redirect
		enUtils.setWinLocation(null,path);
	}
	this.filterZoneNotifObjects=filterZoneNotifObjects;		
	
	/*
		link to current page management
		assignes current page as a parameter and opens in a popup
	*/
	var linkManageCurrPage=function()
	{
		var path="en.jsp?enPage="+enApplication.global.linkManagePageMethod
			+"&enInfolet=Administration/administratePageProp.jsp";
		path=enUtils.addQueryStringParam(path,"editPropOfPageName",enApplication.global.currentPageName);
		path=enUtils.addQueryStringParam(path,"enPageTitle","Pages Management");	
		switch(enApplication.global.linkManagePageMethod)
		{
			case "PopupPage":
				enUtils.openPopupWindow(path,"enAdminPage",null,750,600);		
				break;
			case "MainFocus":
				showMainFocus(path);
				break;
			default:
				path=enUtils.addQueryStringParam(path,"enPage",enApplication.global.defaultPageName);
				enUtils.setWinLocation(null,path);
		}
	}
	this.linkManageCurrPage=linkManageCurrPage;
	
	/*
		reload notifd component cell
		params:
			cbo - selected filter type (combo box)
			cellId - cell id to reload
			
	*/
	var reloadNotifsCell=function (cbo,cellId)
	{
		reloadOnComboChange(cbo,"enaActionType",cellId);
	}
	this.reloadNotifsCell=reloadNotifsCell;
	
	/*
		reload on combo change
		params:
			cbo - selected filter type (combo box)
			paramName - request param to append
			cellId - cell id to reload. if ommited, the page is reloaded
	*/
	var reloadOnComboChange=function (cbo,paramName,cellId)
	{
		if(enUtils.isEmpty(cbo))return;
		if(cbo.options.selectedIndex==-1)return;
		var paramValue=enUtils.getValueOf(cbo);
		//if cell id is passed - reload cell
		if(enUtils.isInteger(cellId))
		{
			var extraQryStr=paramName+"="+paramValue;
			reloadCell(cellId,null,null,extraQryStr);
		}
		//else - reload page
		else
		{
			var path=window.location.href;
			path=enUtils.addQueryStringParam(path,paramName,paramValue);
			enUtils.setWinLocation(null,path);
		}
	}
	this.reloadOnComboChange=reloadOnComboChange;
	
	/*
		save current scrolling position in global.currentScrollPos
		params:
			win - window to handle (optional)
		returns:
			the object assigned to global.currentScrollPos:
				obj.left
				obj.top
	*/
	var backupScrollPos=function (win)
	{
		var currScroll=new Object();
		var winPos=enUtils.getWindowPos(win);
		currScroll.top=winPos.top;
		currScroll.left=winPos.left;
		//set in application global
		global.currentScrollPos=currScroll;
		return currScroll;
	}
	//expose
	this.backupScrollPos=backupScrollPos;
	

	/*
		sets current scrolling position
		params:
			toScrollPos - new sctoling position (optional)
			win - window to handle (optional)
	*/
	var restoreScrollPos=function (toScrollPos,win)
	{
		if(enUtils.isEmpty(win))win=window;
		if(enUtils.isEmpty(toScrollPos))toScrollPos=global.currentScrollPos;
		win.scrollTo(toScrollPos.left,toScrollPos.top);
	}
	//expose
	this.restoreScrollPos=restoreScrollPos;
	
	/*
		builds the path to an image based on the current skin
		params:
			imgName - image to find - start bellow the skin folder
		returns - the full img path
	*/
	var getSkinImgPath=function(imgName)
	{
		if(enUtils.isEmpty(imgName))return "";
		//get base url
		var path=enUtils.getBaseUrl();
		path+="Static/Images/Skins/";
		path+=global.currentSkinName+"/";
		path+=imgName;
		return path;
	}
	this.getSkinImgPath=getSkinImgPath;

	/*
		give alert and close the current window
		optional param:
			msg - the alert messege. 
	*/
	var alertNotLoginAndClose=function(msg)
	{
		if(enUtils.isEmpty(msg)) msg=enMsg.get("enApplication.alertNotLoginAndClose") ;
		alert(msg);
		enUtils.absoluteRedirect(enApplication.global.URLs.login);
	}
	this.alertNotLoginAndClose=alertNotLoginAndClose;
	
	/*
		confirm user and refresh window
		checks global.promptAutoRefresh as a silent default param
		optional param:
			msg - the alert messege. to avoid use '$none$' 
	*/
	var confirmAndRefresh=function(msg)
	{
		var confirmFirst=global.confirmAutoRefresh;
		if(!enUtils.isEmpty(msg) && msg.toLowerCase().equals("$none$"))
		{
			confirmFirst=false;
		}
		if(confirmFirst)
		{
			//get msg
			if(enUtils.isEmpty(msg)) msg=enMsg.get("enApplication.confirmRefresh");
			//confirm with user
			if(!confirm(msg))return;
		}
		//reload
		window.location.reload(true);
	}
	this.confirmAndRefresh=confirmAndRefresh;
	
	/*
		set window timeout to refresh page
	*/
	var setAutoRefreshTimeout=function()
	{
		window.setTimeout("enApplication.confirmAndRefresh();",global.autoRefreshRate);
	}
	this.setAutoRefreshTimeout=setAutoRefreshTimeout;
	
	/*
		set list of buttons to disable on execution
	*/
	var setDisableButtonList=function(list)
	{
		global.disableButtonList=list;
	}
	this.setDisableButtonList=setDisableButtonList;
	
	/*
		enable / disable buttons list on execution
	*/
	var toggleDisableButtonList=function(disable)
	{
		var list=global.disableButtonList;
		var el=null;
		if(enUtils.isEmpty(list))return;
		//turn into arrays
		if(!enUtils.isArray(list))
		{
			if(enUtils.isObject(list))list=new Array(list);
			else list=enUtils.separatedListToArray(list);
		}

		//loop
		for(var i=0;i<list.length;i++)
		{
			el=enUtils.objectOrGetId(list[i]);
			if(!enUtils.isEmpty(el))
			{
				el.disabled=disable;
			}
		}
		//clear
		if(!disable)global.disableButtonList=null;
	}
	this.toggleDisableButtonList=toggleDisableButtonList;
	
	//get base url (application root with trailing slash)
	var getBaseUrl=function()
	{
		//make sure has trailing slash
		if(!enUtils.isEmpty(global.baseUrl))
		{
			var pos=1+global.baseUrl.lastIndexOf("/");
			if(pos>0 && pos<global.baseUrl.length)global.baseUrl+="/";
		}
		return global.baseUrl;
	}
	this.getBaseUrl=getBaseUrl;
		
	/*-------------------------------------------------------------
		online help
	-------------------------------------------------------------*/
	
	/*
		open help on F1
		how to use:
			enUtils.evtAddEvent(document,"keydown",enApplication.getHelpOnF1);
	*/
	var getHelpOnF1=function(e)
	{
		var evnt=enUtils.evtGetCBEvent(e);
		//F1 is 112
		if(evnt.keyCode==112)
		{
			evnt.cancelEvent();
			openPopUpHelp();
		}
	}
	this.getHelpOnF1=getHelpOnF1;
	
	/*
		cancel IE help event
		how to use:
			document.onhelp=enApplication.cancelIEHelp;
	*/
	var cancelIEHelp=function()
	{
		event.returnValue=false;
	}
	this.cancelIEHelp=cancelIEHelp;

	/*
		open help window
		params:
			path - path to open
				expects: http://server:port/site/Static/Help...	OR Static/Help...
	*/
	var openPopUpHelp=function(path)
	{
		//cascade path
		if(enUtils.isEmpty(path))
		{
			path=enUtils.ntz(enUtils.ntz(global.specificHelpFile),global.defaultHelpFile);
		}
		if(enUtils.isEmpty(path))return;
		/*
		if(path.substr(0,getBaseUrl().length)!=getBaseUrl())
		{
			//getBaseUrl returns with the last "/" so take it off from the path
			if(path.substr(0,1)=="/")path=path.substr(1);
			path=getBaseUrl()+path;
		}
		*/
		enUtils.openPopupWindow(path,"enHelpWin",null,780,580);
	}
	this.openPopUpHelp=openPopUpHelp;
		
	/*-------------------------------------------------------------
		floating Ifreame functions
	 ---------------------------------------------------------------*/
	/*
		close window or floating frame
		called from a popup window - document.keyup
		how to use: 
			enUtils.evtAddEvent(document,"keyup",enApplication.closeWindowOrFloatingIfrOnEsc);
	*/
	var closeWindowOrFloatingIfrOnEsc=function(e)
	{	
		var e=enUtils.evtGetCBEvent(e);
		if(e.keyCode==27)
		{
			if(countAllFloatingIfrs()) 
			{	
				closeAllFloatingIfrs();
			}	
			else if(window.opener)
			{
				window.close();
			}	
		}
	}
	this.closeWindowOrFloatingIfrOnEsc=closeWindowOrFloatingIfrOnEsc;	
	/*
		close all iframes (called from document click)
		how to use: 
			enUtils.evtAddEvent(document,"click",enApplication.closeAllFloatingIfrs);
	*/
	var closeAllFloatingIfrs=function()
	{
		var check=false;
		try
		{	
			hideColorPicker();
		}
		catch(e){}
		try
		{
			hideCalendar();
		}
		catch(e){}
		try
		{
			hideSysEntitiesPicker();
		}
		catch(e){}
	}
	this.closeAllFloatingIfrs=closeAllFloatingIfrs;			
	
	/*
		count all open iframes
		returns number of open iframes
	*/
	var countAllFloatingIfrs=function()
	{
		var ifrCounter=0;
		try
		{	
			if(document.getElementById("fraColorPicker").style.visibility=='visible') 
			{
				ifrCounter++;
			}	
		}
		catch(e){}
		try
		{
			if(document.getElementById("fraCalendar").style.visibility=='visible')
	  		{
				ifrCounter++;
			}	
		}
		catch(e){}
		return ifrCounter;
	}
	this.countAllFloatingIfrs=countAllFloatingIfrs;			
	
	/*
		close all the iframes when press Esc (called from docuemnt.keyup)
		how to use: 
			enUtils.evtAddEvent(document,"keyup",enApplication.closeAllFloatingIfrsOnEsc);
	*/
	var closeAllFloatingIfrsOnEsc=function(e)
	{
		var e=enUtils.evtGetCBEvent(e);
		if(e.keyCode==27) closeAllFloatingIfrs();
	}
	this.closeAllFloatingIfrsOnEsc=closeAllFloatingIfrsOnEsc;		

	
	/*
		sign the cell onmouseover or onmouseout
		params:
				sign - sign or unsign the cell
				el - the element that we want to sign
	*/
	var sortTableMarkCell=function(sign,el)
	{
		el=enUtils.objectOrGetId(el);
		//if already sorted - do not change
		var sorted=el.getAttribute("enSortedAsc");
		if(!enUtils.isEmpty(sorted))return;
		//else - switch class
		if(sign==0)
		{
			el.className = "sortTableOverCell" ;
		}
		else
		{
			el.className = "" ;
		}
	}
	this.sortTableMarkCell=sortTableMarkCell;
		
		
	/*
	show Color picker:
	*/
	var showColorPicker=function (e)
	{
		var cpCbfn,cpSize,cpCallerId,cpOpenMode,elmnt,cpSign;
		var evnt=enUtils.evtGetCBEvent(e)
		elmnt=evnt.target;
		cpCallerId = elmnt.getAttribute("enCpCallerId");
		if(enUtils.isEmpty(cpCallerId)) return;
		cpSize = elmnt.getAttribute("enCpSize");
		cpOpenMode = elmnt.getAttribute("enCpOpenMode");
		cpCbfn = elmnt.getAttribute("enCpCbfn");
		if(enUtils.isEmpty(cpCbfn)) cpCbfn='enApplication.showColorPickerCbfn';
		if(enUtils.isEmpty(cpSize)) cpSize=4;
		if(enUtils.isEmpty(cpOpenMode)) cpOpenMode='iframe';
		var newWinPath = enUtils.getBaseUrl() + "Static/Common/ColorPicker/colorPicker.jsp?sizeOfArray="+escape(cpSize)+
			"&funName="+escape(cpCbfn)+"&callID=" + escape(cpCallerId)+"&openElement=" + escape(cpOpenMode);
		var ifrParams=new Object();
		var docAlign = global.isRTL?"right":"left" ;
		ifrParams.position="bottom";
		ifrParams.shiftDir=docAlign;
		ifrParams.shiftByPercent="0";
		ifrParams.ifrSrc=newWinPath;
		ifrParams.ifrWidth="160";
		ifrParams.ifrHeight="160";
		ifrParams.isSrcFile=true;
		enUtils.ifrShowFloatingIfr('fraColorPicker',elmnt,ifrParams);
		evnt.setCancelBubble(true);
	}
	//expose
	this.showColorPicker=showColorPicker;

	/*
	hidding the color picker
	*/
	var hideColorPicker=function (){
		
		enUtils.ifrShowFloatingIfr('fraColorPicker');
	}
	//expose
	this.hideColorPicker=hideColorPicker;
	/*
		close color picker on escape press
		how to use: 
			enUtils.evtAddEvent(document,"keyup",enApplication.hideColorPickerOnEsc);
	*/
	var hideColorPickerOnEsc=function(e)
	{
		//get event
		var e=enUtils.evtGetCBEvent(e);
		//get ascii code
		if(e.keyCode==27) hideColorPicker();
	}
	this.hideColorPickerOnEsc=hideColorPickerOnEsc;
	
	/*
		showColorPickerCbfn call back function to be called from the color picker
		how to use:
			pass 'enApplication.showColorPickerCbfn' a sthe call back function to the color picker
			<input type="button" name="cmdTest" id="cmdTest" value="..."
				enCpCallerId="cmdTest" enCpCbfn="enApplication.showColorPickerCbfn" 
				enCpSize="4" enCpOpenMode="iframe">
			the color picker will call the function back with the selected color
		params:
			inputId - the id of the related input
			color - selected color
	*/
	var showColorPickerCbfn=function(inputId,color)
	{
		var el = document.getElementById(inputId) ;
		if(!enUtils.isEmpty(el))
		{
			enUtils.setValueOf(el,color);
		}
	}
	//expose
	this.showColorPickerCbfn=showColorPickerCbfn;
	
	/*
		show tooltip frame
		params:
			elmnt - element or id to hook tooltip on
			textTitle - tooltip title
			textBody - tooltip body text
			minWidth - min width for frame (def 140)
			minHeight - min height for frame (def 100)
	*/
	var showToolTip=function(elmnt,textTitle,textBody,minWidth,minHeight)
	{
		//validation
		if ( enUtils.isEmpty(elmnt) || 
			enUtils.isEmpty(textTitle) && enUtils.isEmpty(textBody) ) return;
		
		//get size
		var width=parseInt(enUtils.ntz(minWidth,"140"));
		var height=0;
		minHeight=parseInt(enUtils.ntz(minHeight,"100"));
		//get divToolTipSizeChecker
		var sizeChecker=enUtils.objectOrGetId("divToolTipSizeChecker");
		if(!enUtils.isEmpty(sizeChecker))
		{
			//set width to divToolTipSizeChecker
			sizeChecker.style.width=width;
			//title first
			//enUtils.elmntSetInnerText(sizeChecker,textTitle); - THIS DOES NOT TAKE <BR>... into concideration
			sizeChecker.innerHTML=textTitle;
			height+=parseInt(enUtils.elmntAbsPos(sizeChecker).height);
			//body
			//enUtils.elmntSetInnerText(sizeChecker,textBody); 
			sizeChecker.innerHTML="";
			sizeChecker.innerHTML=textBody;
			height+=parseInt(enUtils.elmntAbsPos(sizeChecker).height);
		}
		//html
		var isDocRtl = global.isRTL?'dir=\"rtl\"':'';
		var src = "<html "+isDocRtl+"><head>\n";
		if(!enUtils.isEmpty(global.charset))
		{
			src+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset="+global.charset+"\">\n";
		}
		src += "<link rel='stylesheet' type='text/css' href='"
			+enUtils.getBaseUrl()+"Static/Include/enformia.css'>";
		if(!enUtils.isEmpty(global.currentSkinName))
		{
			src += "<link rel='stylesheet' type='text/css' href='"
				+enUtils.getBaseUrl()+"Static/Include/"+global.currentSkinName+".css'>";
		}
		src += "</head><body style='margin:0;padding:0;'>";
		src += "<div class='tltpHeader'>"+textTitle+"</div>";
		src += "<div class='tltpBody'>"+textBody+"</div>";
		src += "</body></html>";
		
		//show iframe
		elmnt = enUtils.objectOrGetId(elmnt);
		var ifrParams=new Object();
		var docAlign = global.isRTL?"right":"left" ;
		ifrParams.position="bottom";
		ifrParams.shiftDir=docAlign;
		ifrParams.shiftByPercent="50";
		ifrParams.isSrcFile=false;
		ifrParams.ifrSrc=src;
		ifrParams.ifrWidth=width;
		ifrParams.ifrHeight=(minHeight>height ? minHeight : height);
		enUtils.ifrShowFloatingIfr('fraToolTip',elmnt,ifrParams);
	}
	this.showToolTip=showToolTip;			

	var hideToolTip=function()
	{
		enUtils.ifrShowFloatingIfr('fraToolTip');
	}
	this.hideToolTip=hideToolTip;			

	/*-------------------------------------------------------------
		Home page components
  	 --------------------------------------------------------------*/
	/*
	show Move Cells board:
	*/
	var showMoveCellsPopup=function (elmnt)
	{		
		//backupScrollPos(); not needed anymore...
		elmnt=enUtils.objectOrGetId(elmnt);
		if(enUtils.isEmpty(elmnt))return;
		global.pagePrefrencesUrl = elmnt.getAttribute("enPopupUrl");
		global.enSrcElmntToMove = elmnt;
		var srcCode = moveCellsCreateHtml();
		var ifrParams=new Object();
		var docAlign = global.isRTL?"right":"left" ;
		ifrParams.skipKeepInWin=true;
		ifrParams.position="bottom";
		ifrParams.shiftDir=docAlign;
		ifrParams.shiftByPercent="0";
		ifrParams.ifrSrc=srcCode;
		ifrParams.ifrWidth="126";
		if(enUtils.isEmpty(global.moveCellsMenuHeight)) global.moveCellsMenuHeight="158";
		ifrParams.ifrHeight=""+global.moveCellsMenuHeight+"";
		ifrParams.isSrcFile=false;
		ifrParams.showHide='show';
		enUtils.ifrShowFloatingIfr('fraMoveCells',elmnt,ifrParams);
		//window.setTimeout("enApplication.restoreScrollPos();",1); not needed anymore...
	}
	//expose
	this.showMoveCellsPopup=showMoveCellsPopup;
				
	/*
	hide Move Cells board
	*/
	var hideMoveCellsPopup=function()
	{
		var el=new Object();
		el.showHide = "hide";
		enUtils.ifrShowFloatingIfr("fraMoveCells",null,el);
	}
	//expose
	this.hideMoveCellsPopup=hideMoveCellsPopup;
	
/*
	Move the cells
	td are coded by: td_tbl#_row#(top-down)_cell#(left-right) 
	td's have an attribute called: enChangeablTd, set to "true".
*/	
	var moveTd = function(srcClickElmnt, moveDir)
	{
		var success, errMsg=enMsg.get("enApplication.noCell"),tmpId=null;
		//get details about the sourse td
		var srcTd=srcClickElmnt.parentNode;
		while(srcTd.getAttribute("enMoveableTd")!="true")
		{
			srcTd=srcTd.parentNode
		}
		//one cell jump
		if (moveDir=="R" || moveDir=="L" || moveDir=="U" || moveDir=="D")
		{
			success=switchTd(srcTd,moveDir);
			if(success==null) 
			{	
				alert(errMsg);
				//success=tmpId;
			}
			else
			{	
				tmpId=success;
			}	
		}
		else if (moveDir=="RR" || moveDir=="LL" || moveDir=="UU" || moveDir=="DD")
		{
			//get basic direction
			var basicdir=moveDir.substr(0,1);
			//first time we want to give the message
			success=switchTd(srcTd,basicdir);
			if(success==null) 
			{	
				alert(errMsg);
			}	
			else 
			{
				tmpId=success;
			}	
			while(success!=null)
			{
				success=switchTd(srcTd,basicdir);
				if(success!=null)tmpId=success;
			}
			success=tmpId;
		}
		return success ;
	}
	//expose
	this.moveTd=moveTd;

	/*
		this function gets the td to move and the basic movement: R,L,U,D.
		the function does all the work for getting the destination td (also if it is in another table)
		return value: true: the cell has been moved. false: no destination cell;
		srcTbl=0: means we move cells in the same table.
		srcTbl=else: means for R/L we move cells between tables.
	*/
	var switchTd = function(srcTd,moveDir)
	{
		//get srcTd details
		var srcTdId=srcTd.id;
		var srcTr=srcTd.parentNode;
		//parse cell id
		var idArray=srcTdId.split('@');
		var preFix=idArray[0];
		var srcTbl=parseInt(idArray[1]);
		var srcRow=parseInt(idArray[2]);
		var srcCell=parseInt(idArray[3]);
		if(moveDir=='R')
		{
			//get details about the destination td
			var dstTbl= srcTbl==0?srcTbl:srcTbl+1;
			var dstRow=srcRow;
			var dstCell=srcTbl==0?srcCell+1:srcCell;
			var dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			var dstTd=document.getElementById(dstTdId);
			//go out if no destination
			if(!dstTd) return null;
			//switch
			var dstTr=dstTd.parentNode;
			dstTr.replaceChild(srcTd,dstTd);
			if(srcTbl==0)srcTr.insertBefore(dstTd,srcTd);
			else srcTr.appendChild(dstTd);
			//change the id
			srcTd.id=dstTdId;
			dstTd.id=srcTdId;
		}
		else if(moveDir=='L')
		{
			//get details about the destination td
			var dstTbl= srcTbl==0?srcTbl:srcTbl-1;
			if(srcTbl!=0 && dstTbl==0) dstTbl=-1;
			var dstRow=srcRow;
			var dstCell=srcTbl==0?srcCell-1:srcCell;
			var dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			var dstTd=document.getElementById(dstTdId);
			//go out if no destination
			if(!dstTd) return null;
			//switch
			var dstTr=dstTd.parentNode;
			srcTr.replaceChild(dstTd,srcTd);
			if(srcTbl==0)dstTr.insertBefore(srcTd,dstTd);
			else dstTr.appendChild(srcTd);
			//change the id
			srcTd.id=dstTdId;
			dstTd.id=srcTdId;
		}
		else if(moveDir=='D')
		{
			//get details about the destination td
			var dstTbl= srcTbl;
			var dstRow=srcRow+1;
			var dstCell=srcCell;
			var dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			var dstTd=document.getElementById(dstTdId);
			//go out if no destination
			if(!dstTd) return null;
			//check for the next right td in the source tr
			var nxtSrcTdId=preFix +"@" +srcTbl + "@" + srcRow + "@" + (srcCell+1);
			var nxtSrcTd=document.getElementById(nxtSrcTdId);
			//switch
			var dstTr=dstTd.parentNode;
			dstTr.replaceChild(srcTd,dstTd);
			if(nxtSrcTd) srcTr.insertBefore(dstTd,nxtSrcTd);
			else srcTr.appendChild(dstTd);
			//change the id
			srcTd.id=dstTdId;
			dstTd.id=srcTdId;
		}
		else if(moveDir=='U')
		{
			//get details about the destination td
			var dstTbl= srcTbl;
			var dstRow=srcRow-1;
			var dstCell=srcCell;
			var dstTdId=preFix +"@" +dstTbl + "@"  + dstRow + "@" + dstCell;
			//get the destination td
			var dstTd=document.getElementById(dstTdId);
			//go out if no destination
			if(!dstTd) return null;
			//check for the next right td in the dstination tr
			var nxtDstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + (dstCell+1);
			var nxtDstTd=document.getElementById(nxtDstTdId);
			//switch
			var dstTr=dstTd.parentNode;
			srcTr.replaceChild(dstTd,srcTd);
			if(nxtDstTd) dstTr.insertBefore(srcTd,nxtDstTd);
			else dstTr.appendChild(srcTd);
			//change the id
			srcTd.id=dstTdId;
			dstTd.id=srcTdId;
		}
		//return success
		//return true;
		return dstTd.id ;		
	}
	//expose
	this.switchTd=switchTd;
	
	/*
	 * shows the main div 'divMainFocus' according to a base elmnt (embeded in HomePage)
	 *	(embeded in HomePage) - USES: enUtils.ifrShowFloatingIfr
	 * 	if already in main focus - open in that window
	 * Params:
	 *		srcPath: source(URL) to open in the floating iframe.		
	 *		height: the height of the iframe in absolute numbers or relative to screen size (def global.mainFocusHeight).
	 *		isRelativeHeight: if true will set the iframe height as height*screen height (def global.mainFocusIsRelative)
	 */
	 var showMainFocus=function(srcPath,height,isRelativeHeight)
	 {
	 	//check functoin paramters
		if(!enUtils.isSet(srcPath))return;
		if(!enUtils.isSet(height))height=global.mainFocusHeight;
		if(!enUtils.isSet(isRelativeHeight))isRelativeHeight=global.mainFocusIsRelative;

		//add random parameter to path
		srcPath=enUtils.addQueryStringParam(srcPath,"enaRand",Math.random());
		
		//if already in main focus, or page does not support - open in current window
		if(global.isMainFocus || !global.supportsMainFocus 
			|| enUtils.isEmpty(document.getElementById("maxZoneBaseEl")))
		{
			enUtils.setWinLocation(window,srcPath);
			return;
		}

		//add page name, and floating parameter to path
		srcPath=enUtils.addQueryStringParam(srcPath,"enPage","MainFocus");
		srcPath=enUtils.addQueryStringParam(srcPath,"enaFloating","1");
		
		if (isRelativeHeight)
		{
			//convert %
			if((new String(height)).indexOf("%")!=-1)height=parseFloat(height)/100;
			//set relative height
			height=parseInt(parseFloat(height)*parseFloat(enUtils.getWindowPos().height));
		}
		//set internal iframe element size
		setMainFocusIntIfrSize(true);
		//default id of the div container for that purpose
		var ifr="divMainFocus";
		//defautl id of the elmnt
		var elmnt="maxZoneBaseEl";
		//get base elemnt width for default
		var oElmnt=enUtils.objectOrGetId(elmnt);
		var calcWidth=oElmnt.width;
		//ifr parameters
		var ifrParams=new Object();
		var docAlign = global.isRTL?"right":"left" ;
		ifrParams.position="bottom";
		ifrParams.shiftDir=docAlign;
		ifrParams.shiftByPercent="0";
		ifrParams.ifrSrc=srcPath;
		ifrParams.ifrWidth=calcWidth;
		ifrParams.skipKeepInWin=true;
		ifrParams.ifrHeight=height;
		ifrParams.isSrcFile=true;
		ifrParams.showHide='show';

		enUtils.ifrShowFloatingIfr(ifr,elmnt,ifrParams);
		//make sure it is dragable
		var oIfr=enUtils.objectOrGetId(ifr);
		if(!enUtils.isEmpty(oIfr))
		{	
			oIfr.setAttribute("enaDragable","1");
			if(enBS.ns6up || enBS.ie55 || enBS.ie6up)
				oIfr.style.cursor="move";	
		}
		//if there is a last position move there
		if(enApplication.global.drag.focusLastLeft && enApplication.global.drag.focusLastTop)
		{
			enUtils.elmntMove(ifr,enApplication.global.drag.focusLastLeft,
								enApplication.global.drag.focusLastTop);
		}
		//set flags
		global.mainFocusInUse=true;
		global.mainFocusVisible=true;
		global.mainFocusResState=null;
		global.mainFocusResPos=null;
		try
		{
			window.scrollTo(0,0);
		}
		catch(e){}
	 }
	 this.showMainFocus=showMainFocus;

	/*
	 * hides the main div 'divMainFocus'
	 * this function is to be called from the main page. if called from the iframe,
	 * use window.parent.enUtils.hideMainFocus();
	 * Params:
	 *		reload: if false hides the iframe without reloading the main page(def=true)
	  *		clear: clear iframe source and global flag ?(def=true)
	 */
	 var hideMainFocus=function(reload,clear)
	 {
	 	//reload?
		if(!enUtils.isSet(reload))reload=true;
		//clear?
		if(!enUtils.isSet(clear))clear=true;
		if(reload) 
		{
			window.location.reload(true);
			return;
		}
		//set internal iframe element size
		setMainFocusIntIfrSize(false);
		//default id of the iv container for that purpose
		var ifr="divMainFocus";
		var ifrParams=new Object();
		ifrParams.showHide='hide';
		//hide
		enUtils.ifrShowFloatingIfr(ifr,null,ifrParams);
		//set flags
		global.mainFocusInUse=false;
		global.mainFocusVisible=false;
		global.mainFocusResState=null;
		global.mainFocusResPos=null;
		//clear source
		if(clear)
		{
			var oIfr=enUtils.getIfrFromDiv(document.getElementById(ifr))
			oIfr.src="";
		}
	 }
	 this.hideMainFocus=hideMainFocus;
	
	//set internal iframe element size
	var setMainFocusIntIfrSize=function(show)
	{
		if(!enUtils.isSet(show))show=true;
		var intIframe=enUtils.objectOrGetId("ifrMainFocus");
		if(!enUtils.isEmpty(intIframe))
		{
			var size=show ? "100%" : "0";
			intIframe.style.width=size;
			intIframe.style.height=size;
		}
	}
	this.setMainFocusIntIfrSize=setMainFocusIntIfrSize;
		
	//show or hide main focus
	var toggleMainFocusVisibility=function(flg)
	{
		if(global.mainFocusInUse)
		{
			flg=enUtils.isSet(flg)?flg:!global.mainFocusVisible;
			enUtils.objectOrGetId("divMainFocus").style.visibility=flg?"visible":"hidden";
			global.mainFocusVisible=flg;
		}
		else
		{
			//reset flag
			if(global.mainFocusVisible)global.mainFocusVisible=false;
		}
	}
	this.toggleMainFocusVisibility=toggleMainFocusVisibility;
	
	//set the title of the main focus floating frame
	var setMainFocusTitle=function(title)
	{
		if(!global.isMainFocus)return;
		enUtils.elmntSetInnerText("spnMainFocusTitle",title);
	}
	//expose
	this.setMainFocusTitle=setMainFocusTitle;
	
	/*
		toggle main focus max / restore
		params:
			img - the img for the action
			integrity - perform integrity only = img src and title (def false)
	*/
	var toggleMainFocusMaxRes=function(img,integrity)
	{
		//validate
		img=enUtils.objectOrGetId(img);
		if(enUtils.isEmpty(img))return;
		if(!enUtils.isSet(integrity))integrity=false;
		//check state
		var newState=global.mainFocusResState=="m" ? "m" : "r";
		if(!integrity)newState=global.mainFocusResState=="m" ? "r" : "m";
		//action
		if(!integrity)
		{
			if(newState=="m")
			{
				maxMainFocus();
				//scroll to top
				//only when not RTL
				if(!global.isRTL)
					window.scrollTo(0,0);
			}
			else restoreMainFocus();
		}
		//change src
		var currSrcFolder=enUtils.getFolderFromUrl(img.src);
		img.setAttribute("src",
			newState=="r" ? currSrcFolder+"/maximize.gif" : currSrcFolder+"/restore.gif");
		//change title
		img.setAttribute("title",newState=="m" ? enMsg.get("enApplication.restore") : enMsg.get("enApplication.maximize"));
		//set state		
		if(!integrity)global.mainFocusResState=newState;
	}
	this.toggleMainFocusMaxRes=toggleMainFocusMaxRes;

	
	//maximize main focus
	var maxMainFocus=function()
	{
		var ifr=document.getElementById("divMainFocus");
		//save last position
		var lastPos=new Object();
		lastPos.width=ifr.style.width;
		lastPos.height=ifr.style.height;
		lastPos.left=ifr.style.left;
		lastPos.top=ifr.style.top;
		global.mainFocusResPos=lastPos;
		//set max pos
		var winPos=enUtils.getWindowPos();
		ifr.style.width=winPos.width*0.96;
		ifr.style.height=winPos.height*0.96;		
		ifr.style.left=4;
		ifr.style.top=4;
		//make it undragable
		ifr.setAttribute("enaDragable","0");
		ifr.style.cursor="";	
	}
	this.maxMainFocus=maxMainFocus;

	//restore main focus
	var restoreMainFocus=function()
	{
		var ifr=document.getElementById("divMainFocus");
		var lastPos=global.mainFocusResPos;
		if(lastPos)
		{
			ifr.style.width=lastPos.width;
			ifr.style.height=lastPos.height;
			ifr.style.left=lastPos.left;
			ifr.style.top=lastPos.top;
		}
		else
		{
			var winPos=enUtils.getWindowPos();
			ifr.style.width=3*parseFloat(winPos.width)/4;
			ifr.style.height=3*parseFloat(winPos.height)/4;
			ifr.style.left=(parseFloat(winPos.width)/8);
			ifr.style.top=(parseFloat(winPos.height)/8);	
		}
		//make it dragable
		ifr.setAttribute("enaDragable","1");
		if(enBS.ns6up || enBS.ie55 || enBS.ie6up)
			ifr.style.cursor="move";	
	}
	this.restoreMainFocus=restoreMainFocus;

	/*
		toggle cell min / restore
		state is stored in the img
		params:
			img - the img for the action
	*/
	
	var toggleCellMinRes=function(img)
	{
		//validate
		img=enUtils.objectOrGetId(img);
		if(enUtils.isEmpty(img))return;
		//check state
		var state=img.getAttribute("enState")=="r" ? "r" : "m";
		var newState=state=="r" ? "m" : "r";
		//get cell id
		var cellId=img.getAttribute("componentIndex");
		if(!enUtils.isInteger(cellId))return;
		
		//point to main content td
		cellId="tdComponentBody"+cellId;	
		var contentTd=enUtils.objectOrGetId(cellId);
		if(enUtils.isEmpty(contentTd))return;
		//action
		enUtils.elmntShowHide(contentTd);

		//change src. the img may have suffix extention,
		//so we would just replace the restore/minimize part
		var currSrcFolder=enUtils.getFolderFromUrl(img.src);
		var fileName=enUtils.getFileFromUrl(img.src);
		var newFileName= newState=="m" ? fileName.replace("restore","minimize") 
			: fileName.replace("minimize","restore");
		img.setAttribute("src",currSrcFolder+"/"+newFileName);
			
		//change title
		img.setAttribute("title",newState=="m" ? enMsg.get("enApplication.minimize") 
			: enMsg.get("enApplication.restore"));
		//set state		
		img.setAttribute("enState",newState);
	}
	this.toggleCellMinRes=toggleCellMinRes;
		
	
	/*
		print an individual cell
		params:
			cellId - id of cell in page
	*/
	var printCell=function(cellId)
	{
		//get cell id
		if(enUtils.isEmpty(cellId))
		{
			var srcClickElmnt=global.enSrcElmntToMove;
			if(enUtils.isEmpty(srcClickElmnt))return;
			cellId=srcClickElmnt.getAttribute("componentIndex");
		}
		if(!enUtils.isInteger(cellId))return;
		//what's the cell size?
		var minWidth=280;
		var minHeight=200;
		var absPos=enUtils.elmntAbsPos("tdComponentBody"+cellId);
		var cellWidth=Math.max(minWidth,absPos.width);
		var cellHeight=Math.max(minHeight,absPos.height);
		
		//build url		
		var path=enUtils.getBaseUrl()+"bin/en.jsp?enPage="+global.currentPageName;
			path+="&enaMode=print&enaCellId="+cellId+"&enaCellWidth="+cellWidth;
		
		/*
		var path=enUtils.getBaseUrl()+"bin/en.jsp?enPage=NOPAGE&enInfolet=Misc/printCell.jsp";
			path+="&enaCellId="+cellId+"&enaCellWidth="+cellWidth;
		*/
		
		//print - use hidden frame 
		//(do not run on IE 5.5 and 6.0. IE 5.0 prints the floating frame..)
		if(enBS.ie)
		{
			//use popup
			enUtils.openPopupWindow(path,"_blank",null,1.2 * cellWidth,1.2 * cellHeight);
		}
		else
		{
			path=enUtils.addQueryStringParam(path,"enaHidden","1");
			enUtils.execAsync("fraExec",path,"fraExec");
		}
	}
	this.printCell=printCell;

	/*
		return a comma separated list of cell ids for a given zone name
		params:
			zoneName - zone name (or @ delimited list) to filter by
			firstOnly - return only first (def false)
		returns:
			a comma separated list of cell ids
	*/
	var getCellsByZone=function(zoneName,firstOnly)
	{
		//validation and defaults
		if(enUtils.isEmpty(zoneName))return null;
		if(!enUtils.isSet(firstOnly))firstOnly=false;
		if(enUtils.isEmpty(global.mapZonesToCells))return null;
		var out="";
		//for each zone in zoneName - loop on global.mapZonesToCells
		var zoneNames=zoneName.split("@");
		for (var z=0;z<zoneNames.length;z++)
		{
			for(var i=0;i<global.mapZonesToCells.length;i++)
			{
				if(global.mapZonesToCells[i][0]==zoneNames[z])
				{
					if(!enUtils.isEmpty(out))out+=",";
					out+=global.mapZonesToCells[i][1];
					if(firstOnly)break;
				}
			}
		}
		return out;
	}
	this.getCellsByZone=getCellsByZone;
	
	/*
		return a comma separated list of cell ids for a given component name
		params:
			componentName - component name (or @ delimited list) to filter by
			firstOnly - return only first (def false)
		returns:
			a comma separated list of cell ids
	*/
	var getCellsByComponent=function(componentName,firstOnly)
	{
		//validation and defaults
		if(enUtils.isEmpty(componentName))return null;
		if(!enUtils.isSet(firstOnly))firstOnly=false;
		if(enUtils.isEmpty(global.mapComponentsToCells))return null;
		var out="";
		//for each component in zoneName - loop on global.mapComponentsToCells
		var compNames=componentName.split("@");
		for (var c=0;c<compNames.length;c++)
		{
			for(var i=0;i<global.mapComponentsToCells.length;i++)
			{
				if(global.mapComponentsToCells[i][0]==compNames[c])
				{
					if(!enUtils.isEmpty(out))out+=",";
					out+=global.mapComponentsToCells[i][1];
					if(firstOnly)break;
				}
			}
		}
		return out;
	}
	this.getCellsByComponent=getCellsByComponent;
						
	/*
		reload an individual cell

		params:
			cellId - id of cell (or a comma separated list of cell ids) in page
			retryIfBusy - when !isExecAsync - retry again (def false) in that mode no alerts are used
			win - window to run in (default current window)
			extraQryString - aetra params to append to cell link
		how to use:
			1. to reload a given cell - enApplication.reloadCell(12); / enApplication.reloadCell("12,54,2");
			2. to reload all cells with a give zone - enApplication.reloadCell(getCellsByZone('zoneName'));
			2. to reload all cells with a give component - enApplication.reloadCell(enApplication.getCellsByComponent('compName'));
	*/
	var reloadCell=function(cellId,retryIfBusy,win,extraQryString)
	{
		//default
		if(enUtils.isEmpty(win))win=window;
		if(!enUtils.isSet(retryIfBusy))retryIfBusy=false;
		//get cell id
		if(enUtils.isEmpty(cellId))
		{
			var srcClickElmnt=win.enApplication.global.enSrcElmntToMove;
			if(enUtils.isEmpty(srcClickElmnt))return;
			cellId=srcClickElmnt.getAttribute("componentIndex");
		}
		if(enUtils.isEmpty(cellId))return;
		//build url
		var path="en.jsp?enPage="+global.currentPageName;
			path+="&enaMode=reload&enaCellId="+cellId;
		if(!enUtils.isEmpty(extraQryString))
			path+="&"+extraQryString;
		//run - use hidden frame
		if(!win.enUtils.isExecAsync("fraExec",retryIfBusy))
		{
			win.enUtils.execAsync("fraExec",path);
		}
		else
		{
			//resqedule
			win.setTimeout("enApplication.reloadCell("+cellId+",true);",parseInt(Math.random()*100));
		}
	}
	this.reloadCell=reloadCell;
	
	/*
		reload cell call back function
		params:
			newEl - new element to use
			elId - id of element to refresh
			clone - clone the new element? (def false)
	*/
	var reloadCellCallBack=function(newEl,elId,clone)
	{
		var el=enUtils.objectOrGetId(elId);
		if(enUtils.isEmpty(el) || enUtils.isEmpty(newEl))return;
		//the following runs on ns only when dealing with different frames
		if(enBS.ns6up)
		{
			if(clone) el.parentNode.replaceChild(newEl.cloneNode(true),el);
			else el.parentNode.replaceChild(newEl,el);
		}
		else el.innerHTML=newEl.innerHTML;
	}
	this.reloadCellCallBack=reloadCellCallBack;

	/*
		reload home page component by zone name
		if called from Main Focus or popup - find Home Page - the main window
		params:
			zoneName - zone to reload cells for
	*/
	var reloadHomePageCompByZone=function(zoneName)
	{
		if(enUtils.isEmpty(zoneName))return;
		//locate main window
		var win=window.top;
		if(!enUtils.isEmpty(window.top.opener))
			win=window.top.opener.top;
		//reload
		if(win.enApplication)
			win.enApplication.reloadCell(win.enApplication.getCellsByZone(zoneName));
	}
	this.reloadHomePageCompByZone=reloadHomePageCompByZone;
	
	/*
		send page tp a friend
		params:
			win - window to send
			cell - send cell and not page (def false)
	*/
	var openSendToFriend=function(win,cell)
	{
		//check biz rule
		if(!cell && !global.sendToFriend || cell && !global.sendToFriendComp)return;
		
		if(enUtils.isEmpty(win))win=window;
		//path to popup
		var path="en.jsp?enPage=PopupPage&enInfolet=Send/sendPage.jsp";
		var url="";
		var title="";
		var cellId="";
		if(cell)
		{	
			//cell mode
			path=enUtils.addQueryStringParam(path,"enaMode","cell");
			//get clicked cell id and title
			var srcClickElmnt=global.enSrcElmntToMove;
			if(enUtils.isEmpty(srcClickElmnt))return;
			cellId=srcClickElmnt.getAttribute("componentIndex");
			title=srcClickElmnt.getAttribute("enComponentTitle");
			var clsSuffix=srcClickElmnt.getAttribute("enComponentClassSuffix");
			if(!enUtils.isInteger(cellId))return;
			//get mesures
			var absPos=enUtils.elmntAbsPos("tdComponentBody"+cellId);
			var cellWidth=Math.max(280,absPos.width);
			//get current page
			var page=enUtils.getQueryStringParam("enPage");
			//build url
			url=enUtils.addQueryStringParam(enUtils.getBaseUrl()+"bin/en.jsp","enPage",page);
			url=enUtils.addQueryStringParam(url,"enaMode","sent");
			url=enUtils.addQueryStringParam(url,"enaCellId",cellId);
			url=enUtils.addQueryStringParam(url,"enaCellWidth",cellWidth);
			url=enUtils.addQueryStringParam(url,"enaCellClassSuffix",clsSuffix);
		}
		else
		{
			url=win.location.href;
			title=win.document.title;
		}
		
		path=enUtils.addQueryStringParam(path,"enaSendUrl",enUtils.enEscape(url));
		path=enUtils.addQueryStringParam(path,"enaSendTitle",enUtils.enEscape(title));

		enUtils.openPopupWindow(path,"enSendWin");
	}
	this.openSendToFriend=openSendToFriend;
				
	/*---------------------------------------------------------------------------------------
		Hirarchic tree
	---------------------------------------------------------------------------------------*/	
	/*
	treeNodeClick	change look for picked and put its system name 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
	*/
	var treeNodeClick=function(elmnt,divContainer,classSuffix)
	{
		elmnt=enUtils.objectOrGetId(elmnt);
		var selectedClassName='treeNodeSelected'+enUtils.ntz(classSuffix);
		if(elmnt.className==selectedClassName)return;
		divContainer=enUtils.objectOrGetId(divContainer);
		//unselect all
		treeNodeClearSelect(divContainer,classSuffix);
		//select elmnt + set picked element in divContainer
		elmnt.className=selectedClassName;
		var nodeSysName=elmnt.getAttribute("enNodeSysName");
		divContainer.setAttribute('pickedNodeSysName',nodeSysName);
	}
	this.treeNodeClick=treeNodeClick;
	/*
	treeNodeClearSelect	unslect all nods in a tree.
	for use with a collapsing tree (each node should be in a span element)
	parameters:	
		divContainer : the top div that holds the tree
		classSuffix : css classes suffix
	*/
	var treeNodeClearSelect=function(divContainer,classSuffix)
	{
		var selectedClassName='treeNodeSelected'+enUtils.ntz(classSuffix);
		var usSelectedClassName='treeNode'+enUtils.ntz(classSuffix);
		divContainer=enUtils.objectOrGetId(divContainer);
		var spansCol=divContainer.getElementsByTagName("SPAN");
		//unselect all
		for(var i=0;i<spansCol.length;i++)
		{
			if(spansCol[i].className==selectedClassName)spansCol[i].className=usSelectedClassName;
		}
		divContainer.setAttribute('pickedNodeSysName',"");
	}
	this.treeNodeClearSelect=treeNodeClearSelect;
	
	/*
		switch the icon form '+' to '-' OR from '-' to '+'
		params:
			img - the image Element
			showOrHide - optional show or hide flag (true (def) / false)
	*/

	var elmntToggleShowHide=function (img,showOrHide)
	{
		if(!enUtils.isSet(img))return;
		img=enUtils.objectOrGetId(img);
		if(enUtils.isEmpty(img))return;
		var altPlus=enMsg.get("enApplication.expand");
		var altMinus=enMsg.get("enApplication.collapse");
		
		var imgUrl,imgPath,imgSplit,imgName,imgAlt;
		imgUrl = img.src;
		var pos=imgUrl.lastIndexOf("/");
		if (pos!=-1)
		{
			imgPath=imgUrl.substring(0,pos+1);
			imgName=imgUrl.substring(pos+1);
		}
		imgAlt = img.alt ;
		if(enUtils.isSet(showOrHide))
		{
			if(showOrHide)
			{	
				imgName="collapse.gif"
				img.alt = altMinus ;
			}
			else if(!showOrHide)
			{
				imgName="expand.gif"
				img.alt = altPlus ;
			}
		}	
		else
		{
			if(imgName=="expand.gif")
			{
				imgName="collapse.gif";
				img.alt = altMinus ;
			}	
			else
			{
				imgName="expand.gif";
				img.alt = altPlus ;	
			}	
		}	
		img.src = imgPath+imgName ;
		
		//show / hide related gif
		var showHideDiv=img.getAttribute("enRelItemID");
		showHideDiv=enUtils.objectOrGetId(showHideDiv);
		if(!enUtils.isEmpty(showHideDiv))enUtils.elmntShowHide(showHideDiv,showOrHide);	
	}
	//expose
	this.elmntToggleShowHide=elmntToggleShowHide;

	/*
		Open or Close all the tree in one click
		params:
			flag - if "0" the tree should be close , else the tree should be open
				default:True
			containerElement - the element that contain the tag names (div,table etc.)
				default:document
			refTagName - the tag that is in container (img,td,tr etc.)
				default:img
			relAttributeName - the Attribute of the tag
				default:enRelItem
				
			sample: onclick="elmntExpandOrCollapseTree(true,divID)"	
	*/
	var elmntExpandOrCollapseTree=function (flag,containerElement,refTagName,relAttributeName)
	//var elmntCollapseTree=function (oElement)
	{
			//set default values 
			if(!enUtils.isSet(flag)) flag=true; 
			if(enUtils.isEmpty(containerElement)) containerElement="document"; 
			if(enUtils.isEmpty(refTagName)) refTagName="img";
			if(enUtils.isEmpty(relAttributeName)) relAttributeName="enRelItemID";
			//end of "set default values"
			containerElement = enUtils.objectOrGetId(containerElement);
			var imagesArray=containerElement.getElementsByTagName(refTagName);
			for(var i=0;i<imagesArray.length;i++)
			{
				if(!enUtils.isEmpty(imagesArray[i].getAttribute(relAttributeName)))
				{
					elmntToggleShowHide(imagesArray[i],flag);
				}	
			}
	}
	//expose
	this.elmntExpandOrCollapseTree=elmntExpandOrCollapseTree;
	/*
		reloadChildrenNodes: insert next level nodes
		params:
			newEl - new element to use
			elId - id of element to refresh
			clone - clone the new element? (def false)
	*/
	var reloadChildrenNodes=function(newEl,elId,clone)
	{
		var el=enUtils.objectOrGetId(elId);
		if(enUtils.isEmpty(el) || enUtils.isEmpty(newEl))return;
		//the following runs on ns only when dealing with different frames
		/*if(enBS.ns6up)
		{
			if(clone) el.parentNode.replaceChild(newEl.cloneNode(true),el);
			//else el.parentNode.replaceChild(newEl,el);
			else
			{	
				var parent=el.parentNode;
				parent.appendChild(newEl);
				//alert("stop");
				var x;
				for(i=0;i<10000;i++){x=i;}
				parent.removeChild(el);
			}
			
		}*/
		else el.innerHTML=newEl.innerHTML;
	}
	this.reloadChildrenNodes=reloadChildrenNodes;
	
	
	/*---------------------------------------------------------------------------------------
		form functions
	---------------------------------------------------------------------------------------*/
	/*
		rowsBrwsrDuplicate: 
				desc:duplicate a form row.
		page structure:
				Build a div with all the form row elemnts (with id,name events will work only in IE)
				If you want a delete element(button,image...) add it as well with out the delete event!
				The id/name encoding uses a default seperator "@" ,
					in order to change it give the delete button attribute: enSeparator
					if you don;t have delete button (central deletion) give the div this attribute.
				The delete button should gave attribute: enRowsElmnts with all the elements id's seperated by 
					the right seperator.
		parameters:
			frm: object with the following properties:
						frmId: name/id of form to add the elements
						insertBeforeEl: before this button the element will be inserted (def= end of form)
			baseDiv: div containing the form elements
			delBtn: object with the following properties:
						delBtnId: the id of the delete element
						delBtnEvent: event of the delBtnId to delete on (def="click")
						delBtnFunction: delete function to attach (def=rowsBrwsrDelete)
			codeName:	Do we code the name true/false(def)
	*/
	var rowsBrwsrDuplicate=function (frm,baseDiv,delBtn,codeName){
		if(!enUtils.isObject(frm) && !enUtils.isArray(frm))return false;
		//get form ref
		var frmElmnt=enUtils.objectOrGetId(frm.frmId);
		//try by name
		if(!frmElmnt)frmElmnt=enUtils.objectOrGetId(frm.frmId,"form");
		if(!frmElmnt)return false;
		
		var baseDivElmnt=enUtils.objectOrGetId(baseDiv);
		//increment counter, if not exist initial it
		if(!enUtils.isSet(baseDivElmnt.lastTrId)) {
			baseDivElmnt.lastTrId=0;
		}
		else baseDivElmnt.lastTrId++;
		//look for seperator in: delBtn/div (att: enSeparator) else def="@"
		var seperator="";
		//get delete button info
		var delId="";var delEvnt="";var delFn="";
		if(enUtils.isSet(delBtn))
		{
			delId=delBtn.delBtnId;
			delEvnt=enUtils.isEmpty(delBtn.delBtnEvent)?"click":delBtn.delBtnEvent;
			delFn=enUtils.isEmpty(delBtn.delBtnFunction)?rowsBrwsrDelete:delBtn.delBtnFunction;
			//find seperator
			var delBtn=enUtils.objectOrGetId(delId);
			seperator=(!delBtn)?"":delBtn.getAttribute("enSeparator");
		}
		//if we don't have seperator goto div
		if(enUtils.isEmpty(seperator)){
			seperator=(!baseDivElmnt)?"":baseDivElmnt.getAttribute("enSeparator");
		}
		if(enUtils.isEmpty(seperator)) seperator="@";
		//add base div elements (check if it the delBtn, and add event if so)
		var lastBtn="";
		if(enUtils.isSet(frm.insertBeforeEl)) lastBtn=enUtils.objectOrGetId(frm.insertBeforeEl);
		//run over all div elements and add them to the form	
		var objElmnt=null;
		for(var i=0;i<baseDivElmnt.childNodes.length;i++)
		{
			if(baseDivElmnt.childNodes[i].nodeType==1)
			{
				objElmnt=baseDivElmnt.childNodes[i].cloneNode(true);
				if(enUtils.isEmpty(lastBtn))
					frmElmnt.appendChild(objElmnt);
				else
					frmElmnt.insertBefore(objElmnt,lastBtn);
				//if delete button add event
				if(objElmnt.id==delId){
					enUtils.evtAddEvent(objElmnt,delEvnt,delFn);
				}
				objElmnt.id=objElmnt.id+seperator+baseDivElmnt.lastTrId;
				if(codeName) objElmnt.name=objElmnt.name+seperator+baseDivElmnt.lastTrId;
			}
		}
	}
	this.rowsBrwsrDuplicate=rowsBrwsrDuplicate;
	
	/*
		rowsBrwsrDelete:
			desc: will erase all form elemnts in the buttonDelete's "row"
		parameters: has no parameters (should be attached),
			but the event.target(source) should have attribute:enRowsElmnts with all the 
			form elemnents (seperated by the seperator, see  rowsBrwsrDuplicate())
	*/
	var rowsBrwsrDelete=function (e){
		var evt=enUtils.evtGetCBEvent(e);
		delElmnt=evt.target;
		//find the seperator
		var seperator="";
		seperator=delElmnt.getAttribute("enSeparator");
		if(enUtils.isEmpty(seperator)) seperator="@";
		//get the row number to delete
		var deleteId=delElmnt.id.substr(delElmnt.id.indexOf(seperator)+1);
		//get from the delete button the id of the elmnts in the rows
		var elmntsArray=delElmnt.getAttribute("enRowsElmnts")
		if(enUtils.isEmpty(elmntsArray))return;
		elmntsArray=elmntsArray.split(seperator);
		//delete all the objects from the form
		var frmElmnt=delElmnt.parentNode;
		var objElmnt=null;
		for(var i=0;i<elmntsArray.length;i++)
		{
			objElmnt=enUtils.objectOrGetId(elmntsArray[i]+seperator+deleteId);
			if(typeof objElmnt=='object')frmElmnt.removeChild(objElmnt);
		}
		//remove delete button
		frmElmnt.removeChild(delElmnt);
	}
	this.rowsBrwsrDelete=rowsBrwsrDelete;

	/*---------------------------------------------------------------------------------------
		arrays functions
	---------------------------------------------------------------------------------------*/
	
	/*
		remove an existing (database) row of elements
		if the row includes a file element - create a delete file input
		
		params:
			frm - form / name of form
			trId - tr id/reference
	*/
	var arrayRemoveExistingRow=function(frm,tr)
	{
		frm=enUtils.objectOrGetId(frm,"form");
		if(enUtils.isEmpty(frm))return;
		tr=enUtils.objectOrGetId(tr);
		if(enUtils.isEmpty(tr))return;

		//get removed file element
		var ins=tr.getElementsByTagName("INPUT");
		var el,newEl;
		for(var i=0;i<ins.length;i++)
		{
			el=ins[i];
			//for each file input create a delete file input('DELETE_FILE_ATTRNAME_IX')
			if(el.type=="file")
			{
				newEl=document.createElement("INPUT");
				newEl.type="hidden";
				newEl.name="DELETE_FILE_"+el.name;
				newEl.value="1";
				frm.appendChild(newEl);
			}
		}
		//remove the row
		tr.parentNode.removeChild(tr);
	}
	this.arrayRemoveExistingRow=arrayRemoveExistingRow;
	
	/*
		handle array gaps
		go over the elements and hide empty ones (by nullifing their names)
		when items are related, check that all are not empty
		this function should be called before calling arrayHandleNames, after validation
		params:
			frm - form / name of form to handle
			attrName - attribute name (or an array of names) to handle
			alertUser - when false (default):fix mode - removes inconsistant elements
				else: alert mode - alerts the user
			msg - a message to use when alerting the user
	*/
	var arrayHandleGaps=function(frm,attrName,alertUser,msg)
	{
		if(enUtils.isEmpty(frm) || enUtils.isEmpty(attrName))return false;
		//check if an array. if not - convert into an array	
		if(!enUtils.isArray(attrName))attrName=[attrName];
		var attrsLen=attrName.length;
		var elementsLen=0;
		var ok,emptyEl,el;
		
		//get form ref
		frm=enUtils.objectOrGetId(frm,"form");
		if(enUtils.isEmpty(frm))return false;
		
		//internal function to remove an element from all attributes
		var removeAttrsElement=function(ix)
		{
			//loop on attributes and remove
			for(var j=0;j<attrsLen;j++)
			{
				relEls[attrName[j]][ix].name=null;
			}
		}
		//internal function to alert the user
		var alertUserOnElement=function(el)
		{
			alert(msg);
			enUtils.elmntSelect(el);		
		}
		
		//build arrays to hold related elements and their indexes
		var relIxs=new Array();
		var relEls=new Array();
		for(var j=0;j<attrsLen;j++)
		{
			relIxs[attrName[j]]=0;
			relEls[attrName[j]]=new Array();
		}
		
		//fix inconsistant elements or alert user
		alertUser=(alertUser && attrsLen>1);
		if(alertUser)
		{
			if(enUtils.isEmpty(msg))msg=enMsg.get("enApplication.requiredValue");			
			/*
				here we need to check the gaps in existing elements as well
				we do not remove eleemnts, only alert the user
			*/
			//find max index
			var maxIx=arrayGetAttrMaxIx(frm,attrName[0]);
			//if any
			for(var i=0;i<=maxIx;i++)
			{
				ok=false;
				emptyEl=null;
				//loop on attributes
				for(var j=0;j<attrsLen;j++)
				{
					el=frm.elements[attrName[j]+"_"+i];					
					if(enUtils.isEmpty(el))
					{
						//assume all are missing
						ok=false;
						break;
					}
			
					//if any element is empty - remove it
					//an empty element has an empty value, or an attributr 'enNotEmpty' for type file
					if(el.type=='file' && el.getAttribute("enNotEmpty")!="true" || 
						el.type!='file' && enUtils.isEmpty(enUtils.getValueOf(el)))
					{
						if(emptyEl==null)emptyEl=el;
					}
					else
					{
						ok=true;
					}
				}
				if(ok && emptyEl!=null)
				{
					alertUserOnElement(emptyEl);
					return false;
				}				
			}
		}	
				
		//handle dynamically created elements
		//loop on form elements and build related items array			
		for(var i=0;i<frm.elements.length;i++)
		{
			el=frm.elements[i];
			//check if element name is one we are looking for
			for(var j=0;j<attrsLen;j++)
			{
				if(el.name==attrName[j])
				{
					relEls[attrName[j]][relIxs[attrName[j]]++]=el;
					break;
				}
			}
		}
		elementsLen=relEls[attrName[0]].length;
			
		//loop on relEls and check elements consistency. remove empty gaps		
		for(var k=0;k<elementsLen;k++)
		{
			ok=false;
			emptyEl=null;
			//loop on attributes
			for(var i=0;i<attrsLen;i++)
			{
				el=relEls[attrName[i]][k];
				//if any element is empty - remove it
				if(enUtils.isEmpty(enUtils.getValueOf(el)))
				{
					if(alertUser)
					{
						if(emptyEl==null)emptyEl=el;
					}
					else
					{
						removeAttrsElement(k);
						break;
					}
				}
				else
				{
					ok=true;
				}
			}		
			if(alertUser && ok && emptyEl!=null)
			{
				alertUserOnElement(emptyEl);
				return false;
			}
		}
		return true;
	}
	this.arrayHandleGaps=arrayHandleGaps;

	/*
		get max index of an array attribute control
		params:
			frm - form / name of form to handle
			attrName - attribute name to handle
		return:
			max ix in use
	*/
	var arrayGetAttrMaxIx=function(frm,attrName)
	{
		frm=enUtils.objectOrGetId(frm,"form");
		if(enUtils.isEmpty(frm))return 0;
		var el,pos,ix,maxIx=-1;
		for(var i=0;i<frm.elements.length;i++)
		{
			el=frm.elements[i];
			if(!enUtils.isEmpty(el.name))
			{
				pos=el.name.indexOf(attrName+"_");
				if(pos==0)
				{
					ix=el.name.substring(pos+(attrName+"_").length);
					if(enUtils.isNum(ix)) if(maxIx<=ix)maxIx=ix;
				}
			}
		}
		return maxIx;
	}
	this.arrayGetAttrMaxIx=arrayGetAttrMaxIx;

	/*
		syncronize names in array of elements 
		finds gaps in name indexes and closes gaps.
		sets id to name (has to, otherwise the form.elements
			collection does not recognize the new name in ie)
			should be run after handling gaps
		params:
			frm - form / name of form to handle
			attrName - attribute names (one or an array) to sync	
	*/
	/*
	var arraySyncNames=function(frm,attrName)
	{
		frm=enUtils.objectOrGetId(frm,"form");
		if(enUtils.isEmpty(frm))return;
		
		if(enUtils.isArray(attrName))
		{
			for(var i=0;i<attrName.length;i++) arraySyncNames(frm,attrName[i]);
			return;
		}
			
		//get max ix
		var maxIx=arrayGetAttrMaxIx(frm,attrName);
		var ix,notLast,newName;
		while(true)
		{
			notLast=false;
			//find first missing element with non empty ones after
			ix=null;
			for(var i=0;i<maxIx;i++)
			{
				if(enUtils.isEmpty(frm.elements[attrName+"_"+i]))
				{
					if(ix==null)ix=i;
				}
				//if empty element was already found and current element is non empty - break
				else if(ix!=null)notLast=true;
				if(notLast)break;
			}
			//if the empty element is the last one - break
			if(!notLast)break;
		
			//find elements with next ix and 
			var nextIx=ix+1;
			var el=frm.elements[attrName+"_"+nextIx++];
	
			while(!enUtils.isEmpty(el))
			{
				newName=attrName+"_"+(ix++);
				el.name=newName;
				el.id=newName;
				el=frm.elements[attrName+"_"+(nextIx++)];
			}
		}
	}
	this.arraySyncNames=arraySyncNames;
	*/
	
	/*
		handle array names - assign new names to conform with arrays naming convention (ATT_NAME_i)
		make sure each array has at least one element,
		so when removing all elements the array is deleted by the engine
		this function should be the last to be called, after arrayHandleGaps and before submit
		params:
			frm - form / name of form to handle
			attrName - attribute name (or an array of names) to handle
	*/
	var arrayHandleNames=function(frm,attrName)
	{
		frm=enUtils.objectOrGetId(frm,"form");
		if(enUtils.isEmpty(frm))return;
		if(enUtils.isArray(attrName))
		{
			for(var i=0;i<attrName.length;i++) arrayHandleNames(frm,attrName[i]);
			return;
		}
		
		//flag - any element found or created?
		var any=false;
		var el,maxIx=-1;
		//get index to start with
		maxIx=arrayGetAttrMaxIx(frm,attrName);
		//any found?
		any=(maxIx>-1);
		//inc
		maxIx++;
		
		//change elements names
		for(var i=0;i<frm.elements.length;i++)
		{
			el=frm.elements[i];
			if(el.name==attrName)
			{
				any=true;
				el.name=attrName+"_"+maxIx++;
			}
		}		
		//make sure each array has at least one element
		if(!any)
		{
			var newEl=document.createElement("INPUT");
			newEl.type="hidden";
			newEl.name=attrName+"_0";
			newEl.value="";
			frm.appendChild(newEl);
		}
	}
	this.arrayHandleNames=arrayHandleNames;
	
	/*
		converts elements arrays (name and value) to a querystring
		
		params:
			frm - form / name of form to handle
			attrName - attribute name of the element holding the name
			attrVal - attribute name of the element holding the value
			txt - input or id to place query string in
		returns:
			the query string
	*/
	var arrayBuildQueryString=function(frm,attrName,attrVal,txt)
	{
		frm=enUtils.objectOrGetId(frm,"form");
		var o=new Array();
		var inames=0,ivals=0,el;
		//tmp arrays
		var names=new Array();
		var vals=new Array();
		for(var i=0;i<frm.elements.length;i++)
		{
			el=frm.elements[i];
			if(el.name==attrName)
			{				
				names[inames++]=enUtils.getValueOf(el);
			}
			else if(el.name==attrVal)
			{
				vals[ivals++]=enUtils.getValueOf(el);
			}
		}
		//check sync
		if(inames!=ivals)return "";
		//load into final array
		for(var i=0;i<names.length;i++)
		{
			o[i]=[names[i],vals[i]];
		}
		if(enUtils.isEmpty(o))return "";
		o=enUtils.qryStringFromArray(o);
		//add trailing &
		o+="&";
		if(!enUtils.isEmpty(txt))enUtils.setValueOf(enUtils.objectOrGetId(txt),o);
		return o;
	}
	this.arrayBuildQueryString=arrayBuildQueryString;
	
	/*
		build array that contain data about the new order of cells
	*/
	
	var setUserCellsOrder=function()
	{
		var cellOrderArray = new Array() ;
		var ind=0;
		var numOfCols=0;
		var cellIdAttr=0;
		for(var i=0;i<global.zfMainArray.length;i++)
		{
			numOfCols = global.zfMainArray[i][4];
			//is dirty
			if(global.zfMainArray[i][1])
			{
				if(global.zfMainArray[i][3]==1) //structure policy - REGULAR
				{
					var trIndex=1,tdIndex=0,tblIndex=0 ,prefixId=global.zfMainArray[i][0];
					var fullObjId=prefixId+"@"+"0@"+trIndex+"@"+tdIndex ;
					var elTd = document.getElementById(fullObjId) ;
					for(var x=0;x<numOfCols;x++)
					{
						tdIndex++;
						trIndex=1;
						fullObjId = prefixId+"@"+"0@"+trIndex+"@"+tdIndex;
						tblIndex++;
						elTd = document.getElementById(fullObjId) ;
						while(!enUtils.isEmpty(elTd))
						{
							cellIdAttr=elTd.getAttribute("enPageCellId");
							if(!enUtils.isEmpty(cellIdAttr))
							{
								if(!enUtils.isInArray(cellIdAttr,cellOrderArray))
								{
									cellOrderArray[ind] = cellIdAttr;
								}
							}	
							fullObjId = prefixId+"@"+tblIndex+"@"+trIndex+"@"+"1";
							trIndex++;
							elTd = document.getElementById(fullObjId) ;
							ind++;
						}
					}	
				}
				if(global.zfMainArray[i][3]==2) //structure policy - GRID
				{
					var trIndex=1,tdIndex=1,tblIndex=0 ,prefixId=global.zfMainArray[i][0];
					var fullObjId=prefixId+"@"+"0@"+trIndex+"@"+tdIndex ;
					var elTd = document.getElementById(fullObjId) ;
					var fullObjId = prefixId+"@"+tblIndex+"@"+trIndex+"@"+tdIndex;
					var counter=0;
					while(!enUtils.isEmpty(elTd))
					{
						cellIdAttr = elTd.getAttribute("enPageCellId");
						if(!enUtils.isInArray(cellIdAttr,cellOrderArray))
						{
							cellOrderArray[ind] = cellIdAttr;
						}	
						tdIndex++;
						counter++;
						if(counter%numOfCols==0)
						{
							trIndex++;
							tdIndex=1;
						}	
						fullObjId=prefixId+"@"+"0@"+trIndex+"@"+tdIndex ;
						elTd = document.getElementById(fullObjId) ;
						ind++;
					}
				}
			}
			global.zfMainArray[i][2] = cellOrderArray.join(",") ;
			cellOrderArray = new Array() ;
			ind=0;
		}//end for
			return global.zfMainArray ;	
	}//end function
	this.setUserCellsOrder=setUserCellsOrder;
	

	/*
		save the new order of the components
		params:
				dataArray - the data about the items that should be deleted
	*/
	var saveUserCellsOrder=function(dataArray)
	{
		var doUpdate=0;
		var cellsOrderStr="";
		for(var i=0;i<dataArray.length;i++)
		{
			if(dataArray[i][1])
			{
				cellsOrderStr+=dataArray[i][2]+",";
				doUpdate=1;
			}	
		}
		//if cells were moves or cells should be deleted
		doUpdate=(doUpdate||!enUtils.isEmpty(global.zfHideCells)); 
		if(doUpdate)
		{
			var pageName = global.currentPageName;
			var execPath = "en.jsp?enAction=custom&enActionInfolet=Personalize/moveCellsExec.jsp";
			execPath+="&enaHidden=1";
			execPath=enUtils.addQueryStringParam(execPath,"enaCellsOrder",cellsOrderStr);
			execPath=enUtils.addQueryStringParam(execPath,"cbfn","enApplication.moveCellsCbfn");
			execPath=enUtils.addQueryStringParam(execPath,"cbflag","fraExec");			
			execPath=enUtils.addQueryStringParam(execPath,"enaPage",pageName);
			execPath=enUtils.addQueryStringParam(execPath,"enaDelCells",global.zfHideCells);			
			if(enUtils.isExecAsync('fraExec'))return false;
			enUtils.execAsync('fraExec',execPath);
		}
		var el = new Object();
		el.showHide = "hide" ;
		enUtils.ifrShowFloatingIfr("fraMoveCells",null,el);
	}
	this.saveUserCellsOrder=saveUserCellsOrder;
	/*
	move the components 
	
	params:
		moveDir - the direction that we want to move the components to
				  sample:
				  		L = left
						R = right
						U = up
						D=down
	*/
	var imgMoveClick=function(moveDir)
	{
		var resultId="";
		var prefixResult= new Array();
		resultId=moveTd(global.enSrcElmntToMove,moveDir);
		//if null then was no movement
		if(enUtils.isEmpty(resultId)) return;
		prefixResult = resultId.split("@");
		resultId = prefixResult[0];
		//make zone frame dirty
		for(var i=0;i<global.zfMainArray.length;i++)
		{
			if(global.zfMainArray[i][0]==resultId)
			{
				global.zfMainArray[i][1]=true ;
			}
		}
		//move iframe to new location
		var ifrElmnt=document.getElementById('fraMoveCells');
		showMoveCellsPopup(global.enSrcElmntToMove);
		
	}
	this.imgMoveClick=imgMoveClick;
	
	
	/*
		check if the update id Done
		params:
				prm - the flag that sign if the update is done or not
	*/
	var moveCellsCbfn=function(prm)
	{
		if(prm.status)
		{
			//clean all variebles
			for(var i=0;i<global.zfMainArray.length;i++)
			{
				global.zfMainArray[i][1]=false;
				global.zfMainArray[i][2]=null;
			}
			var el = new Object();
			el.showHide = "hide" ;
			enUtils.ifrShowFloatingIfr("fraMoveCells",null,el);
		}
		enUtils.defaultCallBack(prm) ;
	}
	this.moveCellsCbfn=moveCellsCbfn;


	/*
		show or hide components 
		params:
				elmnt - the component id 
				showOrHide - the action that need to do (show or Hide)
	*/
	var showOrHideCell=function(elmnt,showOrHide)
	{
		elmnt=enUtils.objectOrGetId(elmnt);
		var cellId = elmnt.getAttribute("componentIndex");
		var hidTr = document.getElementById("hiddenTr"+cellId);
		var contTr = document.getElementById("contentTr"+cellId);
		
		if(showOrHide=="hide")
		{
			global.zfHideCells+="@"+cellId+"@";
		}	
		else
		{
			var re = new RegExp("@"+cellId+"@","ig");
			global.zfHideCells=global.zfHideCells.replace(re,"");
		}	
	
		if(showOrHide=="hide")
		{
			contTr.style.display="none";
			hidTr.style.display="";
			showMoveCellsPopup(elmnt);
		}
		else
		{
			hidTr.style.display="none";
			contTr.style.display="";
			showMoveCellsPopup(elmnt);
		}
	}
	this.showOrHideCell=showOrHideCell;

	/*
		checks to what directions the td can be moved
		params:
			srcTdId	the id of the td to check
		retruns:
			an arrayof true/false in the order of R,RR,L,LL,U,UU,D,DD
	*/
	var canMoveTd=function(srcTdId)
	{
		//if no id
		if(enUtils.isEmpty(srcTdId))
		{
			return [false,false,false,false,false,false,false];
		}
		//array to return
		var canMoveArr=new Array();
		//parse the source id
		var idArray=srcTdId.split('@');
		var preFix=idArray[0];
		var srcTbl=parseInt(idArray[1]);
		var srcRow=parseInt(idArray[2]);
		var srcCell=parseInt(idArray[3]);
		//variables for the destination td
		var dstTbl,dstRow,dstCell,dstTdId,dstTd;
		//check for "R"
			dstTbl= srcTbl==0?srcTbl:srcTbl+1;
			dstRow=srcRow;
			dstCell=srcTbl==0?srcCell+1:srcCell;
			dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			dstTd=document.getElementById(dstTdId);
			canMoveArr[0]=!enUtils.isEmpty(dstTd);
		//check for "RR"
			dstTbl= srcTbl==0?srcTbl:srcTbl+2;
			dstRow=srcRow;
			dstCell=srcTbl==0?srcCell+2:srcCell;
			dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			dstTd=document.getElementById(dstTdId);
			canMoveArr[1]=!enUtils.isEmpty(dstTd);
		//check for "L"
			dstTbl= srcTbl==0?srcTbl:srcTbl-1;
			//
			if(srcTbl!=0 && dstTbl==0) dstTbl=-1;
			dstRow=srcRow;
			dstCell=srcTbl==0?srcCell-1:srcCell;
			dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			dstTd=document.getElementById(dstTdId);
			canMoveArr[2]=!enUtils.isEmpty(dstTd);
		//check for "LL"
			dstTbl= srcTbl==0?srcTbl:srcTbl-2;
			if(srcTbl!=0 && dstTbl==0) dstTbl=-1;
			dstRow=srcRow;
			dstCell=srcTbl==0?srcCell-2:srcCell;
			dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			dstTd=document.getElementById(dstTdId);
			canMoveArr[3]=!enUtils.isEmpty(dstTd);
		//check for "U"
			dstTbl= srcTbl;
			dstRow=srcRow-1;
			dstCell=srcCell;
			dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			dstTd=document.getElementById(dstTdId);
			canMoveArr[4]=!enUtils.isEmpty(dstTd);
		//check for "UU"
			dstTbl= srcTbl;
			dstRow=srcRow-2;
			dstCell=srcCell;
			dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			dstTd=document.getElementById(dstTdId);
			canMoveArr[5]=!enUtils.isEmpty(dstTd);
		//check for "D"
			var dstTbl= srcTbl;
			var dstRow=srcRow+1;
			var dstCell=srcCell;
			dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			dstTd=document.getElementById(dstTdId);
			canMoveArr[6]=!enUtils.isEmpty(dstTd);
		//check for "DD"
			var dstTbl= srcTbl;
			var dstRow=srcRow+2;
			var dstCell=srcCell;
			dstTdId=preFix +"@" +dstTbl + "@" + dstRow + "@" + dstCell;
			//get the destination td
			dstTd=document.getElementById(dstTdId);
			canMoveArr[7]=!enUtils.isEmpty(dstTd);
		
		return canMoveArr;
	}
	this.canMoveTd=canMoveTd;
	/*
		create the Menu HTML source
	*/
	var moveCellsCreateHtml=function()
	{	
		//srcClickElmnt is the clicked image....
		var srcClickElmnt=global.enSrcElmntToMove ;
		var srcTd=srcClickElmnt.parentNode;
		while(srcTd.getAttribute("enMoveableTd")!="true")
		{
			srcTd=srcTd.parentNode;
			if(enUtils.isEmpty(srcTd))break;
		}
		var imgSuffix="";
		var isMoveable=global.enSrcElmntToMove.getAttribute("enMoveCellsMoveable");
		var isPersonalizable=global.enSrcElmntToMove.getAttribute("enMoveCellsPersonalizable");
		var hideComponent = global.enSrcElmntToMove.getAttribute("enHideComponent");
		var moveableArray = canMoveTd(enUtils.isEmpty(srcTd) ? null : srcTd.id);
		var isDocRtl = global.isRTL?'dir=\"rtl\"':'';
		var arrowsDirection="";
		var arrayIndex=0;
		var src="";
		src+="<html "+isDocRtl+">";
		src+="<head>\n";
		if(!enUtils.isEmpty(global.charset))
		{
			src+="<meta http-equiv=\"Content-Type\" content=\"text/html; charset="+global.charset+"\">\n";
		}
		src+="<link rel=\"stylesheet\" type=\"text/css\" href=\""+enUtils.getBaseUrl()+"Static/Include/enformia.css\">\n" ;
		src+="<link rel=\"stylesheet\" type=\"text/css\" href=\""+enUtils.getBaseUrl()+"Static/Include/Skins/"+global.currentSkinName+".css\">\n" ;
		src+="<scr"+"ipt language=\"JavaScript\">\n";
		src+="<!--\n";
		src+="var callingWin=window.parent;\n";
		
		src+="function imgMoveClickCaller(param)\n";
		src+="{\n";
		src+=	"callingWin.enApplication.global.moveCellsFlag=1;\n";
		src+=	"callingWin.enApplication.imgMoveClick(param);\n";
		src+="}\n";
		
		src+="function cancelUserChoose()\n";
		src+="{\n";
		src+=	"callingWin.enApplication.global.moveCellsFlag=0;\n";
		src+=	"callingWin.enApplication.hideMoveCellsPopup();\n";
		if(!enUtils.isEmpty(global.zfHideCells) || global.moveCellsFlag==1)
		{
			src+="callingWin.location.reload();\n" ;
		}
		src+="}\n";
		
		src+="function confirmUserCellsOrder()\n";
		src+="{\n";
		src+=	"callingWin.enApplication.global.moveCellsFlag=0\n";		
		src+=	"var dataArray = callingWin.enApplication.setUserCellsOrder();     //get the new cells order\n";
		src+=	"callingWin.enApplication.saveUserCellsOrder(dataArray);	 //	update the cells order\n";
		src+="}\n"
		
		src+="function markRow(row,sign)\n";
		src+="{\n";
		src+=	"if(sign==1)\n";
		src+=	"{\n";
		src+=		"row.className = \"moveCellsRowOver\" ;\n";
		src+=	"}\n";
		src+=	"else\n";
		src+=	"{\n";
		src+=		"row.className = \"moveCellsRow\" ;\n";
		src+=	"}\n";
		src+="}\n";
		
		src+="function checkMoveCellsFlag()\n";
		src+="{\n";
		src+=	"var el=document.getElementById(\"moveCellsNavigation\");\n";
		src+=	"if(!el)return;\n";		
		src+=	"if(callingWin.enApplication.global.moveCellsFlag==1)\n";
		src+=	"{\n";
		src+=		"el.className=\"hiddenEl\";\n";
		src+=	"}\n";
		src+=	"else\n";
		src+=	"{\n";
		src+=	"el.className=\"moveCellsNav\";\n";
		src+=	"}\n";
		src+="}\n";
		
		src+="//-->\n";
		src+="</sc"+"ript>\n";
		src+="</head>";
		src+="<body class=\"moveCellsMenuBody\" onload=\"checkMoveCellsFlag()\">" ;
		src+="<img src=\"../Static/Images/blank.gif\" width=\"1\" height=\"10\">"
		if(isMoveable=="1")
		{
		src+=	"<table width=\"69\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\" align=\"center\">";
		src+=		"<tr>";
		src+=			"<td colspan=\"2\" rowspan=\"2\">";
		if(global.isRTL)
		{
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverRightLeft.gif")+"\" width=\"25\" height=\"25\">";//ff
		}
		else
		{	
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverTopLeft.gif")+"\" width=\"25\" height=\"25\">";//ff0
		}	
		src+=			"</td>" ;
		if(moveableArray[5])
		{
		src+=			"<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('UU');\" >";
		imgSuffix="";
		}
		else
		{
		src+=			"<td>";		
		imgSuffix="Dis";
		}
		src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverUp2"+imgSuffix+".gif")+"\" width=\"19\" height=\"12\">";
		src+=			"</td>";
		src+=			"<td colspan=\"2\" rowspan=\"2\">" ;
		if(global.isRTL)
		{
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverTopLeft.gif")+"\" width=\"25\" height=\"25\">";//ff
		}
		else
		{
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverRightLeft.gif")+"\" width=\"25\" height=\"25\">";//ff1			
		}
		src+=			"</td>" ;
		src+=		"</tr>" ;
		src+=		"<tr>" ;		
		if(moveableArray[4])
		{
		src+=			"<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('U');\">";
		imgSuffix="";
		}
		else
		{
		src+=			"<td>";		
		imgSuffix="Dis";
		}
		src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverUp1"+imgSuffix+".gif")+"\" width=\"19\" height=\"13\">";
		src+=			"</td>";
		src+=		"</tr>" ;
		src+=		"<tr>" ;	
		//RR / LL
		arrayIndex=3;//global.isRTL?3:1;	
		if(moveableArray[arrayIndex])
		{
		arrowsDirection = 'LL';//global.isRTL?'LL':'RR';
		src+=			"<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('"+arrowsDirection+"');\">";
		imgSuffix="";
		}
		else
		{
		src+=			"<td>";
		imgSuffix="Dis";		
		}
		if(global.isRTL)
		{
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverRight2"+imgSuffix+".gif")+"\" width=\"12\" height=\"19\">";//ff
		}
		else
		{	
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverLeft2"+imgSuffix+".gif")+"\" width=\"12\" height=\"19\">";//ff2
		}	
		src+=			"</td>";
		//R / L
		arrayIndex=2;//global.isRTL?2:0;	
		if(moveableArray[arrayIndex])
		{
		arrowsDirection = 'L';//global.isRTL?'L':'R';
		src+=			"<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('"+arrowsDirection+"');\">" ;
		imgSuffix="";
		}
		else
		{
		src+=			"<td>" ;
		imgSuffix="Dis";		
		}
		if(global.isRTL)
		{
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverRight1"+imgSuffix+".gif")+"\" width=\"13\" height=\"19\">";//ff
		}
		else
		{	
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverLeft1"+imgSuffix+".gif")+"\" width=\"13\" height=\"19\">";//ff3
		}	
		src+=			"</td>";
		src+=			"<td>";
		src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverCenter.gif")+"\" width=\"19\" height=\"19\">";
		src+=			"</td>";
		//R / L
		arrayIndex=0;//global.isRTL?0:2;	
		if(moveableArray[arrayIndex])
		{
		arrowsDirection = 'R';//global.isRTL?'R':'L';
		src+=			"<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('"+arrowsDirection+"');\">";
		imgSuffix="";
		}
		else
		{
		src+=			"<td>";		
		imgSuffix="Dis";
		}
		if(global.isRTL)
		{
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverLeft1"+imgSuffix+".gif")+"\" width=\"13\" height=\"19\">";//ff
		}
		else
		{	
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverRight1"+imgSuffix+".gif")+"\" width=\"13\" height=\"19\">";//ff4
		}	
		src+=			"</td>";
		//RR / LL
		arrayIndex=1;//global.isRTL?1:3;	
		if(moveableArray[arrayIndex])
		{
		arrowsDirection = 'RR';//global.isRTL?'RR':'LL';
		src+=			"<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('"+arrowsDirection+"');\">";
		imgSuffix="";
		}
		else
		{
		src+=			"<td>";		
		imgSuffix="Dis";
		}
		if(global.isRTL)
		{
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverLeft2"+imgSuffix+".gif")+"\" width=\"12\" height=\"19\">";//ff
		}
		else
		{	
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverRight2"+imgSuffix+".gif")+"\" width=\"12\" height=\"19\">";//ff5
		}	
		src+=			"</td>";
		src+=		"</tr>" ;
		src+=		"<tr>" ;		
		src+=			"<td colspan=\"2\" rowspan=\"2\">";
		if(global.isRTL)
		{
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverBottomRight.gif")+"\" width=\"25\" height=\"25\">";//ff
		}
		else
		{	
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverBottomLeft.gif")+"\" width=\"25\" height=\"25\">";//ff6
		}	
		src+=			"</td>";
		if(moveableArray[6])
		{
		src+=			"<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('D');\">";
		imgSuffix="";
		}
		else
		{
		src+=			"<td>";		
		imgSuffix="Dis";
		}
		src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverDown1"+imgSuffix+".gif")+"\" width=\"19\" height=\"13\">";
		src+=			"</td>";
		src+=			"<td colspan=\"2\" rowspan=\"2\">";
		if(global.isRTL)
		{
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverBottomLeft.gif")+"\" width=\"25\" height=\"25\">";//ff
		}
		else
		{	
			src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverBottomRight.gif")+"\" width=\"25\" height=\"25\">";//ff7
		}	
		src+=			"</td>";
		src+=		"</tr>" ;
		src+=		"<tr>" ;		
		if(moveableArray[7])
		{
		src+=			"<td class=\"moveCellsCursor\" onclick=\"imgMoveClickCaller('DD');\">";
		imgSuffix="";
		}
		else
		{
		src+=			"<td>";		
		imgSuffix="Dis";
		}
		src+=				"<img src=\""+getSkinImgPath("MoveCellMenu/moverDown2"+imgSuffix+".gif")+"\" width=\"19\" height=\"12\">";
		src+=			"</td>";
		src+=		"</tr>" ;
		src+=	"</table>";
		src+=	"<table align=\"center\">";
		src+=		"<tr>";
		src+=			"<td colspan=\"2\">";
		src+=			"</td>";
		src+=		"</tr>";
		src+=		"<tr>";
		src+=			"<td>";
		src+=				"<input type=\"button\" value=\""+enMsg.get("enApplication.cell.save")+"\" class=\"submitForm\" ";
		src+=				"onclick=\"confirmUserCellsOrder();\" class=\"moveCellsMenuButton\">";
		src+=			"</td>";
		src+=			"<td>";
		src+=				"<input type=\"button\" value=\""+enMsg.get("enApplication.cell.cancel")+"\" class=\"cancelForm\" ";
		src+=				"onclick=\"cancelUserChoose();\" class=\"moveCellsMenuButton\">";
		src+=			"</td>";
		src+=		"</tr>";
		src+=		"<tr>";
		src+=			"<td colspan=\"2\">";
		src+=			"</td>";
		src+=		"</tr>";
		src+=	"</table>";
		}
		//when moving - no options
		if(!(global.moveCellsFlag=="1" || hideComponent==1))
		{
		src+=	"<table align=\"center\" id=\"moveCellsNavigation\" class=\"moveCellsNav\" cellpadding=\"0\" cellspacing=\"0\">";
		src+=		"<tr onmouseover=\"markRow(this,1)\" onmouseout=\"markRow(this,0)\" class=\"moveCellsRow\">";
		src+=			"<td colspan=\"2\" class=\"moveCellsTopRow\" onclick=\"javascript:void callingWin.enApplication.printCell();callingWin.enApplication.hideMoveCellsPopup();\">"+enMsg.get("enApplication.cell.print")+"</td>";
		src+=		"</tr>";
		//send
		if(global.sendToFriendComp)
		{
		src+=		"<tr onmouseover=\"markRow(this,1)\" onmouseout=\"markRow(this,0)\" class=\"moveCellsRow\">";
		src+=			"<td colspan=\"2\" class=\"moveCellsSecondRow\" onclick=\"javascript:void callingWin.enApplication.openSendToFriend(null,true);callingWin.enApplication.hideMoveCellsPopup();\">"+enMsg.get("enApplication.cell.send")+"</td>";
		src+=		"</tr>";
		}
		src+=		"<tr onmouseover=\"markRow(this,1)\" onmouseout=\"markRow(this,0)\" class=\"moveCellsRow\">";
		src+=			"<td colspan=\"2\" class=\"moveCellsMidRow\" onclick=\"javascript:void callingWin.enApplication.reloadCell();callingWin.enApplication.hideMoveCellsPopup();\">"+enMsg.get("enApplication.cell.reload")+"</td>";
		src+=		"</tr>";
		if(isPersonalizable=="1")
		{
		src+=		"<tr onmouseover=\"markRow(this,1)\" onmouseout=\"markRow(this,0)\" class=\"moveCellsRow\">";
		src+=			"<td colspan=\"2\" class=\"moveCellsBottomRow\" onclick=\"javascript:void callingWin.enUtils.openPopupWindow('"+global.pagePrefrencesUrl+"',null,null,780,500); callingWin.enApplication.hideMoveCellsPopup();\">"+enMsg.get("enApplication.cell.preferences")+"</td>";
		src+=		"</tr>";
		}
		src+=	"</table>";
		if(isMoveable=="0")			
		{
			src+="<img src=\"../Static/Images/blank.gif\" width=\"1\" height=\"5\">"		
			src+="<span class=\"moveCellsMenuSpan\">" ;
			src+="<input type=\"button\" value=\"Cancel\" class=\"cancelForm\" ";
			src+="onclick=\"cancelUserChoose();\" class=\"moveCellsMenuButton\">";
			src+="</span>" ;
		}
		}
		src+="</body>";
		src+="</html>";
		var menuMoveHeight=110;
		var menuItemHeight=16;
		var menuCancelHeight=35;
		var menuHeight=0;
		
		//show only move (after move start / hide)
		if(!(global.moveCellsFlag=="1" || hideComponent==1))
		{
			//add print and reload
			menuHeight+= 2*menuItemHeight;
			//send
			if(global.sendToFriendComp)menuHeight+=menuItemHeight;
			//personalizable - personaliza
			if(isPersonalizable=="1")menuHeight+=menuItemHeight;
		}
		//movable
		if(isMoveable=="1")menuHeight+=menuMoveHeight;
		//cancel button
		else menuHeight+=menuCancelHeight;
		//assign
		global.moveCellsMenuHeight=menuHeight;
		//ret source
		return src;
	}
	this.moveCellsCreateHtml=moveCellsCreateHtml;
	
	
	/*-------------------------
	Progress bar
	--------------------------*/
	/*
		initialize and display the progress dialog.
		params:
			title - title of the bar ($NONE$ -> no title, def - >In Progress)
			progressInterval - interval in miliseconds to update the bar (def -> 50)
			progressLength - times to increase bar before clean it.
	*/
	var showProgressaBar=function(title,progressInterval,progressLength)
	{
		//fix title span
		var el=document.getElementById("spnProgressTitle");
		if(!enUtils.isEmpty(el))
		{
			//remove all span content
			var len=el.childNodes.length;
			for(var i=len-1;i>-1;i--)
			{
				el.removeChild(el.childNodes[i]);
			}
			//create new title
			if(enUtils.isEmpty(title)) title=enMsg.get("enApplication.progressBarDefTitle")+"\n";
			else if (title=="$NONE$")title="";
			var txt=document.createTextNode(title);
			el.appendChild(txt);
		}
		//if no interval use default
		if(enUtils.isEmpty(progressInterval))progressInterval=50;
		//if there is new end override default
		if(!enUtils.isEmpty(progressLength))enApplication.global.progressBarVars.progressLength=progressLength;
		enApplication.global.progressBarVars.progressAt = 0;
		var pDiv=document.getElementById("enaProgressDiv");
		if(enUtils.isEmpty(pDiv))return;
		winPos=enUtils.getWindowPos();
		pDiv.className="";
		var pDivWidth=parseInt(enUtils.isEmpty(pDiv.width)?pDiv.style.width:pDiv.width);
		var pDivHeight=parseInt(enUtils.isEmpty(pDiv.height)?pDiv.style.height:pDiv.height);
		pDiv.style.left=winPos.width/2-pDivWidth;
		pDiv.style.top=winPos.height/2-pDivHeight;
		enApplication.global.progressBarVars.progressId=window.setInterval(updateProgressaBar,progressInterval);
	}
	this.showProgressaBar=showProgressaBar;
	
	// Update the progress dialog with the current state
	var updateProgressaBar=function() {
		var bar=document.getElementById("enaProgressBar");
		if(enUtils.isEmpty(bar))return;
		bar.value+="||";
		enApplication.global.progressBarVars.progressAt++;
		if(enApplication.global.progressBarVars.progressAt>enApplication.global.progressBarVars.progressLength)
		{
			bar.value="";
			enApplication.global.progressBarVars.progressAt=0;
		}
	}
	this.updateProgressaBar=updateProgressaBar;
	
	// Hide the progress bar
	var hideProgressaBar=function () {
		var pDiv=document.getElementById("enaProgressDiv");
		if(!enUtils.isEmpty(pDiv))
			pDiv.className="hiddenEl";
		//stop the interval
		window.clearInterval(enApplication.global.progressBarVars.progressId);
		//clear the bar
		var bar=document.getElementById("enaProgressBar");
		if(!enUtils.isEmpty(bar))
			bar.value="";
	}
	this.hideProgressaBar=hideProgressaBar;

	/*
	open's the file system browser and set's it's focus
	params:
		enaRetElement:	the eleemnt to hold the value (if ommited browser will not open).
		enaMode:	directory or file browser //1- dirs only(def), 2- files only)
		enaRoot:	[optional] 	root folder to start with (reserved words: $site$, $binaries$, $usbinaries$, 
								$components$, $classes$, $pagelets$, $tmpbinaries$, $tmpstatic$,$appicons$,
								$infolets$, $scripts$,$help$,$WEBINF$)
		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)
	*/
	var openFsBrowser=function(enaRetElement,enaMode,enaRoot,enaRootFullPath,enaRetAbs,enaFilter,
								enaRootFixed, enaUseTrailingSlash,enaCbfnFn)
	{
		//return if no element
		if(enUtils.isEmpty(enaRetElement))return;
		//handle defaults
		enaMode=enUtils.ntz(enaMode,"1");
		enaRootFullPath=enUtils.ntz(enaRootFullPath,"0");
		enaRetAbs=enUtils.ntz(enaRetAbs,"0");
		enaRootFixed=enUtils.ntz(enaRootFixed,"0");
		enaUseTrailingSlash=enUtils.ntz(enaUseTrailingSlash,"0");
		//enaWinName=enUtils.ntz(enaWinName,"fsBrowserWin");
		enaWinName="fsBrowserWin";
		//variables
		var fsBrowserSource=enUtils.getBaseUrl()+"bin/en.jsp?enScript=FSBrowser/fsBrowser.jsp";
		fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRetElement",enaRetElement);
		fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaMode",enaMode);
		if(!enUtils.isEmpty(enaRoot))
			fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRoot",enaRoot);
		fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRootFullPath",enaRootFullPath);
		fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRetAbs",enaRetAbs);
		if(!enUtils.isEmpty(enaFilter))
			fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaFilter",enaFilter);
		fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaRootFixed",enaRootFixed);
		fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaUseTrailingSlash",enaUseTrailingSlash);
		if(!enUtils.isEmpty(enaCbfnFn))
			fsBrowserSource=enUtils.addQueryStringParam(fsBrowserSource,"enaCbfnFn",enaCbfnFn);
		enUtils.openPopupWindow(fsBrowserSource, enaWinName,null,780,580);
	}
	this.openFsBrowser=openFsBrowser;
	/*
		fsBrowserCbfn call back function to be called from the file system browser
		how to use:
			call the function on the "ok" method,
			the fs browser will call the function back with the selected path
		params:
			enaRetWindow - reference to the calling window (window.opener, window.parent...)
			retElement - the id of the related input
			path - selected path to directort/file
	*/
	var fsBrowserCbfn=function(enaRetWindow,enaRetElement,path)
	{
		if(enUtils.isEmpty(enaRetWindow))return;
		var el = enaRetWindow.enUtils.objectOrGetId(enaRetElement) ;
		if(!enUtils.isEmpty(el))
		{
			enUtils.setValueOf(el,path);
		}
	}
	this.fsBrowserCbfn=fsBrowserCbfn;
	/*
		openExprBuilder	open's the expression builder and set's it's focus
		params:
			enaRetElement:	the eleemnt to hold the value.
			enaCbfnFn:		[optional] name of fucntion to activate on return 
							(this function should get the enaRetElement + the value)
			enaOpenMode:   	[optional] open the builder in that mode(simple/advanced)
			enaForceMode:	[optional] if 1 user cannot change the mode (1/0 def)
			** if last 2 params are ommited the builder will select the openning mode auto'
	*/
	var openExprBuilder=function(enaRetElement,enaCbfnFn,enaOpenMode,enaForceMode)
	{
		//return if no retElement or get its current value.
		var retElement=enUtils.objectOrGetId(enaRetElement);
		if(!retElement && enUtils.isEmpty(enaCbfnFn))return;
		var expr=enUtils.ntz(enUtils.getValueOf(retElement));
		//variables
		var exprBldrSource=enUtils.getBaseUrl()+"bin/en.jsp?enScript=ExprBuilder/exprBuilder.jsp";
		exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaRetElement",enaRetElement);
		//endoce expr
		exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaExpr",enUtils.enEscape(expr));
		if(!enUtils.isEmpty(enaCbfnFn))
			exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaCbfnFn",enaCbfnFn);
		if(!enUtils.isEmpty(enaOpenMode))
			exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaOpenMode",enaOpenMode);
		if(!enUtils.isEmpty(enaForceMode))
			exprBldrSource=enUtils.addQueryStringParam(exprBldrSource,"enaForceMode",enaForceMode);
		enUtils.openPopupWindow(exprBldrSource,"enaExprBuilderWin",null,780,580);
	}
	this.openExprBuilder=openExprBuilder;
	/*
		exprBuilderCbfn	
		
	*/
	var exprBuilderCbfn=function(enaRetWindow,enaRetElement,expr)
	{
		
		if(enUtils.isEmpty(enaRetWindow))return;
		var el = enaRetWindow.enUtils.objectOrGetId(enaRetElement) ;
		if(!enUtils.isEmpty(el))
		{
			enUtils.setValueOf(el,expr);
		}
	}
	this.exprBuilderCbfn=exprBuilderCbfn;
	
	/*
		showSysEntitiesPickerWin	opens a window for the system objects picker for the right object type.
		params:
			enaRetElement:			an element with 3 attributes: enaEntitiesPickerRetElName with element id to get the picked name,
														  		  enaEntitiesPickerRetElTitle with element id to get the picked title.
																  enaEntitiesPickerOnChange with js function/statements.
									For the Iframe will serve as the anchor.
			enaSysObj: 				the object type to open (default: class)
									values: class, jclass, fsclass, zone, component, infolet, page, user, 
										role, security_scheme, permission, application, bizrule, config, 
										datasource, device, distribution, driver, locale, Schedular_Action, 
										task
			[enaCheckEntityLevelPerm] Whether to check for each entity its read permission (only those who support entity level permission like zones) 
			[enaOpenMethod]:		whether to open in window or iframe (iframe/window-def)
			[enaLoadRoot]:			whether to open loaded (def=1)
			[enaShowSearch]:		whether to show search (def=1) only to object that supports search
			[enaSupportSegments]: 	wether to show list in segments (def=0) only to object that supports search
			[enaSegLength]:			segment size (only when enaSupportSegments=1)
			[enaRootEntity]:		For hierarchic entities: start from this parent, for users: pass role name for filtering.
			[enaCbfnFn]:			name of fucntion to activate on return 
									(this function should get the enaRetElement + the name & title)
	*/
	var showSysEntitiesPicker=function(enaRetElement,enaSysObj,enaCheckEntityLevelPerm,enaOpenMethod,enaLoadRoot,
						enaShowSearch,enaSupportSegments,enaSegLength,enaRootEntity,enaCbfnFn)
	{
		//return if no retElement or get its current value.
		var retElement=enUtils.objectOrGetId(enaRetElement);
		if(!retElement && enUtils.isEmpty(enaCbfnFn))return;
		
		var isWin=enaOpenMethod!="iframe";
		var width=250;
		var height=250
		//variables
		var sysObjPickerSource=enUtils.getBaseUrl()+"bin/en.jsp?enScript=SysObjPicker/sysObjPicker.jsp";
		sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaSpecRetElement",enaRetElement);
		if(!enUtils.isEmpty(enaSysObj))
			sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaSysObj",enaSysObj);
		if(!enUtils.isEmpty(enaCbfnFn))
			sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaSpecCbfnFn",enaCbfnFn);
		if(!enUtils.isEmpty(enaCheckEntityLevelPerm))
			sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaCheckEntityLevelPerm",enaCheckEntityLevelPerm);
		if(!enUtils.isEmpty(enaLoadRoot))
			sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaSpecLoadRoot",enaLoadRoot);
		if(!enUtils.isEmpty(enaShowSearch))
			sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaSpecShowSearch",enaShowSearch);
		if(!enUtils.isEmpty(enaSupportSegments))
			sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaSpecSupportSegments",enaSupportSegments);
		if(!enUtils.isEmpty(enaSegLength))
			sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaSpecSegLength",enaSegLength);
		if(!enUtils.isEmpty(enaRootEntity))
			sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaRootEntity",enaRootEntity);
		
		if(isWin)
		{
			sysObjPickerSource=enUtils.addQueryStringParam(sysObjPickerSource,"enaSpecPopUp","1");
			var winAtts = ",resizable=0,status=0,menubar=0,scrollbars=0,fullscreen=0";
			enUtils.openPopupWindow(sysObjPickerSource,"enaSysObjPickerWin",winAtts,width,height);
		}
		else
		{
			var ifrParams=new Object();
			var docAlign = global.isRTL?"right":"left" ;
			ifrParams.position="bottom";
			ifrParams.shiftDir=docAlign;
			ifrParams.shiftByPercent="0";
			ifrParams.ifrSrc=sysObjPickerSource;
			ifrParams.ifrWidth=width;
			ifrParams.ifrHeight=height;
			ifrParams.isSrcFile=true;
			enUtils.ifrShowFloatingIfr("fraObjPicker",retElement,ifrParams);
		}
	}
	this.showSysEntitiesPicker=showSysEntitiesPicker;
	/*
		hideSysEntitiesPicker:	close the object picker (window or iframe)
	*/
	var hideSysEntitiesPicker=function(openMode)
	{
		//close object picker
		if(openMode=="win")
		{
			window.close();
		}
		else
		{
			var ifrParams=new Object();
			ifrParams.showHide="hide";
			window.parent.enUtils.ifrShowFloatingIfr("fraObjPicker",null,ifrParams);
			//clear iframe src
			window.parent.enUtils.clearIFrameSrc("fraObjPicker");
		}
	}
	this.hideSysEntitiesPicker=hideSysEntitiesPicker;
	/*
		close object picker on escape press
		how to use: 
			enUtils.evtAddEvent(document,"keyup",enApplication.hideSysEntitiesPickerOnEsc);
	*/
	var hideSysEntitiesPickerOnEsc=function(e)
	{
		//get event
		var e=enUtils.evtGetCBEvent(e);
		//get ascii code
		if(e.keyCode==27) hideSysEntitiesPicker();
	}
	this.hideSysEntitiesPickerOnEsc=hideSysEntitiesPickerOnEsc;
	/*
		sysEntitiesPickerCbfn	call back function to be called from the objects picker.
	*/
	var sysEntitiesPickerCbfn=function(enaRetWindow,enaRetElement,pickedName, pickedTitle)
	{
		if(enUtils.isEmpty(enaRetWindow))return;
		var el = enaRetWindow.enUtils.objectOrGetId(enaRetElement) ;
		if(!enUtils.isEmpty(el))
		{
			//get the name target & title taregt
			var changed=false;
			var nameEl=enaRetWindow.enUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElName"));
			if(!enUtils.isEmpty(nameEl) && pickedName!=-1)
			{	
				if(nameEl.value!=pickedName)
				{
					enUtils.setValueOf(nameEl,pickedName);
					changed=true;
				}
			}
			var titleEl=enaRetWindow.enUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElTitle"));
			if(!enUtils.isEmpty(titleEl) && changed)enUtils.setValueOf(titleEl,pickedTitle);
			var onChange=el.getAttribute("enaEntitiesPickerOnChange");
			if(!enUtils.isEmpty(onChange) && changed)eval("enaRetWindow."+onChange);
		}
	}
	this.sysEntitiesPickerCbfn=sysEntitiesPickerCbfn;
	
	/*
		sysEntitiesPickerClear: clear the hidden name input & the title.
	*/
	var sysEntitiesPickerClear=function(enaRetElement)
	{
		var el = enUtils.objectOrGetId(enaRetElement) ;
		if(!enUtils.isEmpty(el))
		{
			//get the name target & title taregt
			var changed=false;
			var nameEl=enUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElName"));
			if(!enUtils.isEmpty(nameEl))
			{	
				if(!enUtils.isEmpty(nameEl.value))
				{
					enUtils.setValueOf(nameEl,"");
					changed=true;
				}
			}
			var titleEl=enUtils.objectOrGetId(el.getAttribute("enaEntitiesPickerRetElTitle"));
			if(!enUtils.isEmpty(titleEl) && changed)enUtils.setValueOf(titleEl,"");
			var onChange=el.getAttribute("enaEntitiesPickerOnChange");
			if(!enUtils.isEmpty(onChange) && changed)eval(onChange);
		}
	}
	this.sysEntitiesPickerClear=sysEntitiesPickerClear;
	/*
	opens the calendar near the element
	params:
		el:				the element to position the calendar near to.
		trgt:			the input element that holds the date (should have attribute enLongDateInputName with 
						the name of the control that represents the date as long (initialize & return)).
		[cbfn]:			the call back function (should recieve parameters like the default function)- default enApplication.showCalendarCbfn
		[calendarType]: allowed values 11(date)/12(time)/6(datetime)- defualt=6. (The numbers are corresponding to ENTypes class)
		[dateFrom]:		(js date object) date range start - default from enCalendar.show()
		[dateTo]:		(js date object) date range end - default from enCalendar.show()
		[dateFormat]:	the format of the date for returning value (for supprted formats see enUtils.formatAsDateTime())
		[timeFormat] 	the format to present the time (for supprted formats see enUtils.formatAsDateTime())
		[startDay]:		first day of week (0=sunday, 1=monday)  default from enCalendar.show()
		[startYear]:	first year in the select list  default from enCalendar.show()
		[endYear]:		lsst year in the select list  default from enCalendar.show()
		[addButtons]:	add prev/next month & year buttons -  default from enCalendar.show()
	*/
	var showCalendar=function(el,trgt,cbfn,calendarType,dateFrom,dateTo,dateFormat,timeFormat,startDay,startYear,endYear,addButtons)
	{
		//handle parameters
		if(!enUtils.isSet(el))return;
		if(!enUtils.isSet(trgt))return;
		cbfn=enUtils.ntz(cbfn,"enApplication.showCalendarCbfn");
		calendarType=enUtils.ntz(calendarType,"null");
		if(enUtils.isSet(dateFrom) && dateFrom.constructor==Date)
			dateFrom="new Date("+dateFrom.getFullYear()+","+dateFrom.getMonth()+","+dateFrom.getDate()+")";
		else
			dateFrom="null"
		if(enUtils.isSet(dateTo) && dateTo.constructor==Date)
			dateTo="new Date("+dateTo.getFullYear()+","+dateTo.getMonth()+","+dateTo.getDate()+")";
		else
			dateTo="null"
		dateFormat=(enUtils.isEmpty(dateFormat))?"null":"'"+dateFormat+"'";
		timeFormat=(enUtils.isEmpty(timeFormat))?"null":"'"+timeFormat+"'";
		startDay=enUtils.ntz(startDay,"null");
		startYear=enUtils.ntz(startYear,"null");
		endYear=enUtils.ntz(endYear,"null");
		addButtons=enUtils.ntz(addButtons,"null");
		//create the calendar base HTML source
		var tmpStr="<html "+(global.isRTL?"dir=\"rtl\"":"")+">\n";
		tmpStr += "<head>\n<link rel=\"STYLESHEET\" href=\""+enUtils.getBaseUrl()+"Static/Common/CalendarDOM/calendar.css\" type=\"text/css\">\n";
		tmpStr += "<script language=\"JavaScript\" src=\""+enUtils.getBaseUrl()+"Static/Common/CalendarDOM/enformiaCalendar.js\" type=\"text/javascript\"></script>\n";
		tmpStr += "<script 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 += "</script>\n";
		tmpStr += "</head>\n<body style=\"margin:0\" onload=\"start();\">\n";
		tmpStr += "<div id=\"divCalendar\" style=\"width:200px;height:220;\"></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=(calendarType==6)?"185":(calendarType==11)?"137":"51";
		enUtils.ifrShowFloatingIfr(ifr,el,ifrParams);
	}
	this.showCalendar=showCalendar;
	/*
	close the calendar iframe
	*/
	var hideCalendar=function()
	{
		//close calendar
		var ifrParams=new Object();
		ifrParams.showHide="hide";
		enUtils.ifrShowFloatingIfr("fraCalendar",null,ifrParams);
	}
	this.hideCalendar=hideCalendar;
	/*
	The function to get back the date and handle it.
	parameters:
		pickedDate: the Date object that was picked un the calendar.
		trgt:		the input to get back the formatted date 
					(the value would be kept in the corresponding hidden inputs with id's with that name + ext:
					"_YY" - year; "_MM" - month; "_DD" - day; "_HO" - hour; "_MI" - minutes, "_SE" - seconds).
		calType:	values 11(date)/12(time)/6(datetime)- defualt=6. 
					(The numbers are corresponding to ENTypes class)
		[format]:		the format to present the returned date (for supprted formats see enUtils.formatAsDateTime())
		[timeFormat] 	the format to present the returned time (for supprted formats see enUtils.formatAsDateTime())
		
	*/
	var showCalendarCbfn=function(pickedDate,target,calType,format,timeFormat)
	{
		//extensions of the hidden inputs
		var DATE_HIDDEN_EXTS=["_YY","_MM","_DD","_HO","_MI","_SE"];
		var padZero=function(num)
		{
			return ((num <= 9) ? ("0" + num) : num);
		}
		//handle default represantation
		if(calType!=6 && calType!=11 && calType!=12)calType=6;
		//get date time parameters
		var year = pickedDate.getFullYear();
		var month =  padZero(pickedDate.getMonth()+1);
		var day  = padZero(pickedDate.getDate());
		var hour=padZero(pickedDate.getHours());
		var minute=padZero(pickedDate.getMinutes());
		var second=padZero(pickedDate.getSeconds());
		//put value in hidden fields
		var tmpEl;
		var tmpDateArry=[year,month,day,hour,minute,second];
		var prefix=target.id;
		for(var i=0;i<DATE_HIDDEN_EXTS.length;i++)
		{
			tmpEl=document.getElementById(prefix+DATE_HIDDEN_EXTS[i])
			if(tmpEl!=null)
			{
				tmpEl.value=tmpDateArry[i];
			}
		}
		/*
		//put long value in hidden field
		var longDateEl=document.getElementById(target.getAttribute("enLongDateInputName"));
		if(!enUtils.isEmpty(longDateEl))
		{
			longDateEl.value=pickedDate.getTime();
		}
		*/
		//handle presentation
		if(target.nodeName.toUpperCase()=="INPUT")
		{
			target.value=enUtils.formatAsDateTime(pickedDate,calType,format,timeFormat);;
		}//end is INPUT
		//close calendar
		hideCalendar();
	}
	this.showCalendarCbfn=showCalendarCbfn;
	
	var clearCalendarVal=function(name)
	{
		var DATE_HIDDEN_EXTS=["","_YY","_MM","_DD","_HO","_MI","_SE"];
		var tmpEl=null;
		for(var i=0;i<DATE_HIDDEN_EXTS.length;i++)
		{
			tmpEl=document.getElementById(name+DATE_HIDDEN_EXTS[i])
			if(tmpEl!=null)
				tmpEl.value="";
		}
	}
	this.clearCalendarVal=clearCalendarVal;
	
}//end of construstor function

//instanciate object
if(!window.enApplication)window.enApplication=new enApplicationConstrustor();	