//	$Id: CatDialog.js,v 1.32 2007-09-21 05:52:37 thchuong Exp $
function cgDialog_BindBringOnTop(dlg)
{
   $(document).bind("click", dlg, function(evnt)
   {
      if (!parent.hasModal())
         evnt.data.bringToTop();
   });
}

self.getActiveDialog = function(innerControl)
{
   if (!innerControl)
   {
      var active = top.document.activeElement;
      while (active && (active.tagName == 'FRAME' || active.tagName == 'IFRAME'))
      {
         try
         {
            active = active.contentWindow.document.activeElement;
         }
         catch (e)
         {
            break;
         }
      }
      innerControl = active;
   }
   if (typeof (innerControl.tagName) == 'undefined')
      return null;
   var fr = innerControl;
   while (fr && (fr.tagName != 'IFRAME' || fr.id != 'CatDialogContentIframe'))
   {
      try
      {
         //fr = fr.document.frames.frameElement;
         var doc = fr.document;
         if (fr.tagName == "FRAME" || doc == null)
            doc = fr.ownerDocument;
         fr = cg_shared.getWindow(doc).frameElement;
      }
      catch (e)
      {
         fr = null;
         break;
      }
     }
   if (!fr && this && typeof (this.frameElement) != 'undefined')
    fr = this.frameElement;
   if (!fr)
      return null;
   var dlg = fr;
   while (dlg && (dlg.tagName != 'DIV' || dlg.id != 'CatDialogOuterDiv'))
   {
      dlg = dlg.parentNode;
   }
   if (dlg)
   {
      if (typeof (dlg.instance) != 'undefined' && dlg.instance != null)
         return dlg.instance;
      else
         return null;
   }
   return null;
}

self.getActiveDialogEx = function()
{
   var intIndex = 0;
   var dlgResult = null;
   var dlgs = getDialogList();
   if (dlgs != null)
   {
      for (var i = 0; i < dlgs.length; i++)
      {
         var dlg = dlgs[i];
         if (dlg.getMaxzIndex() > intIndex)
         {
            intIndex = dlg.getMaxzIndex();
            dlgResult = dlg;
         }
      }
   }
   return dlgResult;
}

self.findDialog = function(dialogid)
{
   var dlgs = getDialogList();
   if (dlgs != null)
   {
      for (var i = 0; i < dlgs.length; i++)
      {
         var dlg = dlgs[i];
         if (dlg.getId() == dialogid)
            return dlg;
      }
   }
   return null;
}

self.getDialogList = function()
{
   var ifrs = self.document.getElementsByTagName('IFRAME');
   for (var i = 0; i < ifrs.length; i++)
   {
      var ifr = ifrs[i];
      if (ifr.id == 'CatDialogContentIframe')
      {
         var dlg = ifr;
         while (dlg && (dlg.tagName != 'DIV' || dlg.id != 'CatDialogOuterDiv'))
         {
            dlg = dlg.parentNode;
         }
         if (dlg && dlg.instance)
         {
            if (dlg.instance instanceof CatDialog && typeof (dlg.instance.getDialogList) != 'undefined')
            {
               return dlg.instance.getDialogList();
            }
            return null;
         }
      }
   }
   return null;
}

self.hasModal = function()
{
   var dlgs = $("div[cgdialog=modal]");
   for (var idx = 0; idx < dlgs.length; idx++)
   {
      if ($(dlgs.get(idx)).css("visibility") == "visible")
         return true;
   }
   return false;
}

self.getMaxzIndex = function()
{
   var dlgs = getDialogList();
   if (dlgs && dlgs.length > 0)
      return dlgs[0].getMaxzIndex();
   return -1;
}
self.destroy = function(dlg)
{
   try
   {
      dlg.show(false);
      dlg.destroy();
   }
   catch (e)
	{ }
}

//CatDialog Object
function CatDialog(win, dlgId, divId, shieldId, frameSrc, height, width, resourcePath, skin, classSuffix, borderColor, titleText, altTitleText, statusText, moveStatusBar, isModal, visibleAtStartup, hasStatusBar, hasTitleBar, hasLogo, hasRefreshButton, hasBackForwardButton, hasPinButton, hasAutoFitButton, hasMinButton, hasMaxButton, hasCloseButton, hasStatusIcon, contentPadding)
{
   var me = this;
   this.ForMessage = false; //alert/confirm message
   this.ClientSideEvents = new Array();
   if (typeof (catdlg_oninit) != 'undefined')
      eGo(catdlg_oninit);
   var serverId = dlgId;
   if (!dlgId || !dlgId.length)
   {
      dlgId = 'CatDlg_' + (new Date()).getTime() + '_' + parseInt(Math.random() * 10000) % 100;
   }
   var minWWid = 150;
   var minWHi = 0;
   var minWid = 180;

   var winX = 0;
   var winY = 0;
   var winWidth = 1;
   var winHeight = 1;
   var i, j, dlg, rs, arr; // dlg: dialog, rs: rows, arr: array
   var dialogContainer = null;
   if (typeof (win) == 'string')
   {
      dialogContainer = document.getElementById(win);
      win = self;
   }
   if (!win)
      win = self;
   me.manager = '' // Name	of	object manages	this dialog	on	the server,	supportted to be used with	server-side	script

   if (typeof (modalDlg) == 'undefined')
      modalDlg = null; //	the current	modal	dialog of all dialogs

   //	Interface variables:
   var line1 = true;
   var line2 = true;
   var line4 = true;
   if (!skin || !skin.length)
      skin = 'Default';
   if (skin.charAt(skin.length - 1) == '_' && skin.length > 1)
   {
      var noLines = parseInt(skin.charAt(skin.length - 2));
      skin = skin.substr(0, skin.length - 2);
      line1 = !(noLines & 1);
      line2 = !(noLines & 2);
      line4 = !(noLines & 4);
   }
   if (height == null || parseInt(height) <= 0)
      height = 400;
   if (width == null || parseInt(width) <= 0)
      width = 600;
   winWidth = width;
   winHeight = height;
   //	This is part of the init proccess:
   if (typeof (MaxzIndex) == 'undefined')
      MaxzIndex = 2000;

   if (typeof (fireServerEvent) == 'undefined')
      fireServerEvent = function(eventCode, stepIndex, url, userData)
      {
         if (eventCode == null || parseInt(eventCode) < 0)
            return;
         if (typeof (__doPostBack) != 'undefined' && me.manager.length)
         {
            if (stepIndex == null)
               stepIndex = wizardCurrStep;
            if (url == null)
               url = me.getUrl();
            if (userData == null)
               userData = '';
            //	Data posted	back is in the	following form	and fields:
            //	eventCode,x,y,w,h,stepIndex,idLen,id(serverId),urlLen,url,dataLen,data
            var args = eventCode + ',' + me.getX() + ',' + me.getY() + ',' + me.getW() + ',' + me.getH() + ',';
            args += stepIndex + ',';
            args += serverId.length + ',' + serverId + ',';
            args += url.length + ',' + url + ',';
            args += userData.length + ',' + userData;
            setzIndex(div, 0);
            __doPostBack(me.manager, args);
         }
      }
   me.postBack = function(userData)
   {
      fireServerEvent(0, null, null, win.unescape(userData));
   }
   function rC(rs, i, j)  // rC:	rowCell
   {
      return rs[i].cells[j];
   }
   if (typeof (DialogList) == 'undefined')
   {
      DialogList = new Array();
   }
   //	Interface functions:
   if (typeof (createObj) == 'undefined')
      createObj = function(win, tagName)
      {
         var obj = win.document.createElement(tagName);
         obj.tabIndex = -1;
         return obj;
      }
   if (typeof (createLabel) == 'undefined')
      createLabel = function(win, lbl)
      {
         lbl = createObj(win, 'DIV');
         lbl.style.border = '0 none';
         setStyleWidth(lbl, '100%');
         return lbl;
      }
   createContentWindow = function()
   {
      var obj = createObj(win, 'DIV');
      obj.style.border = '0	none';
      obj.style.overflow = 'auto';
      obj.style.position = 'absolute';
      obj.style.padding = 0;
      obj.tabIndex = -1;
      setStyleSize(obj, '100%', '100%');
      setVisible(obj, false);
      return obj;
   }
   createWizardFrame = function(wizardFrame)
   {
      wizardFrame = createTable(win, '', 3, 1);
      wizardFrame.border = 0;
      rs = wizardFrame.rows;
      rC(rs, 0, 0).colSpan = 3;
      rs[1].insertCell(rs[1].cells.length);
      rs[1].insertCell(rs[1].cells.length);
      rC(rs, 2, 0).colSpan = 3;
      rC(rs, 1, 1).style.height = '100%';
      rC(rs, 1, 1).style.width = '100%';
      return wizardFrame;
   }
   createTable = function(win, id_, nRows, nCells, table)	//	Global function for all	object of this	type
   {
      table = createObj(win, 'TABLE');
      table.id = id_;
      table.style.height = '100%';
      table.style.width = '100%';
      table.cellPadding = 0;
      table.cellSpacing = 0;
      for (i = 0; i < nRows; i++)
      {
         if (cg_shared.IsIE)
            row = table.insertRow();
         else
            row = table.insertRow(table.rows.length);
         for (j = 0; j < nCells; j++)
         {
            if (cg_shared.IsIE)
               row.insertCell();
            else
               row.insertCell(row.cells.length);
         }
      }
      return table;
   }
   setOuterDivStyle = function(div)
   {
    div.id = 'CatDialogOuterDiv';
    div.tabIndex = -1;
    div.onselectstart = function() {
     if (iVis(frame))
      return false;
    }
    div.style.position = 'absolute';
    div.style.overflow = 'visible';
    div.style.border = '0	none';
    div.style.left = 0;
    div.style.top = 0;
    setzIndex(div, MaxzIndex);
    MaxzIndex += 2;
    setStyleSize(div, width, height);  // default height and	width
    setVisible(div, false);
   }
   DialogList[DialogList.length] = me;
   //	Control variables:
   dropDownHideMode = 'disable';
   shieldColor = 'ff0000';
   var frameHistory = new Array();
   var titleArray = new Array();

   var wizardTitleArray = new Array();
   var wizardStepControls = new Array();
   var wizardPanes = new Array();
   var wizardCurrStep = 0;

   var svrEvents = new Object();
   var currIndex = -1;
   var isResizing = false;
   var isMoving = false;
   var isFitted = false;
   var isFrameCentered = true;
   var resizePadW = 0;
   var resizePadH = 0;
   me.destroyOnHide = false;
   me.forceCenter = false;
   me.pageLoadText = 'Loading...';
   me.readyState = 'uninitialized';
   me.isMaximized = false;
   me.isMinimized = false;
   me.isMovable = true;
   me.isResizable = true;

   if (!classSuffix)
      classSuffix = skin;
   var imgSrcArray = new Array('close.gif', 'close.gif', 'close.gif', 'close.gif', 'close.gif', 'close.gif', 'pin.gif', 'autofit.gif', 'maximize.gif', 'restore.gif', 'minimize.gif', 'close.gif', 'close.gif', 'resize.gif');
   var over_ImgSrcArray = new Array('logo-over.gif', 'refresh-over.gif', 'back-over.gif', 'forward-over.gif', 'back-off-over.gif', 'forward-off-over.gif', 'pin-over.gif', 'autofit-over.gif', 'maximize-over.gif', 'restore-over.gif', 'minimize-over.gif', 'close-over.gif', 'status-info-over.gif', 'resize-over.gif');
   me.allowServerEvents = function(objs)	//	allow	or	not 21 events for [UserEvent,AutoFit,Minimize,Maximize,Restore,Close,toNextStep,toPrevStep,ChangeStep,BeginResizing,EndResizing,BeginMoving,EndMoving,AddToHistory,GoToVisitedPage,GoBack,GoForward,Refresh,Destroy,CancelWizard,FinishWizard]
   {
      var tmp = svrEvents;
      tmp.userEvent = objs[0];
      tmp.autoFit = objs[1];
      tmp.minimize = objs[2];
      tmp.maximize = objs[3];
      tmp.restore = objs[4];
      tmp.close = objs[5];
      tmp.toNextStep = objs[6];
      tmp.toPrevStep = objs[7];
      tmp.changeStep = objs[8];
      tmp.beginResizing = objs[9];
      tmp.endResizing = objs[10];
      tmp.beginMoving = objs[11];
      tmp.endMoving = objs[12];
      tmp.addToHistory = objs[13];
      tmp.goToPage = objs[14];
      tmp.goBack = objs[15];
      tmp.goForward = objs[16];
      tmp.refresh = objs[17];
      tmp.destroy = objs[18];
      tmp.cancelWizard = objs[19];
      tmp.finishWizard = objs[20];
      tmp = null;
   }
   me.imgTitleArray = new Array('', '', '', '', '', '', 'Keep on top', 'Resize to fit contents', 'Maximize', 'Restore', 'Minimize', 'Close', '', 'Resize');
   var imgArray = new Array();
   for (i = 0; i < imgSrcArray.length; i++)
   {
      imgArray[i] = createObj(win, 'IMG');
   }

   //	Create modalShield:
   function getById(id)
   {
      return win.document.getElementById(id);
   }
   if (typeof (modalShield) == 'undefined')
   {
      modalShield = null;
      addShield = false;
      if (shieldId != null)
      {
         modalShield = getById(shieldId);
      }
      if (modalShield == null)
      {
         addShield = true;
         modalShield = createTable(win, '', 1, 1);
         
         $(modalShield).height(document.body.scrollHeight);
         $(modalShield).width(document.body.scrollWidth);
      }

      $(modalShield).bind("click", null, function(evnt)
      {
         if (iVis(modalShield))
         {
            cg_shared.stopEventFlow(evnt);

            if (modalDlg)
               modalDlg.applyFilter(800, true, null, [filterSetColor, filterUnsetColor]);

         }
      });

      setModalShieldStyle(modalShield);
   }
   function filterSetColor(o)
   {
      if (typeof (o.preservedColor) == 'undefined')
      {
         o.preservedColor = o.bgColor;
         if (o.preservedColor == '')
            o.preservedColor = o.style.backgroundColor;
      }
      o.style.backgroundColor = '#3F678A';
   }
   function filterUnsetColor(o)
   {
      if (typeof (o.preservedColor) != 'undefined')
         o.style.backgroundColor = o.preservedColor;
   }
   //	Create OuterDiv:
   var div = null;
   if (divId != null)
   {
      div = getById(divId);
   }
   var addDiv = false;
   if (div == null)
   {
      div = createObj(win, 'DIV');
      addDiv = true;
   }
   setOuterDivStyle(div);
   div.instance = me;
   me.HTMLElement = div;
   $(div).attr("cgdialog", isModal ? "modal" : "modalless");

   //	Create shield iframe:
   var shieldIframe = createIframe(win, 'ShieldIframe');
   shieldIframe.style.position = 'absolute';
   shieldIframe.style.left = 0;
   shieldIframe.style.top = 0;
   setzIndex(shieldIframe, -1);

   $(shieldIframe).bind("beforeactivate", null, function(evnt)
   {
      //TODO:consider
      //var eWin = gEWin();
      //eWin.event.returnValue = false;

      cg_shared.preventEventDefault(evnt);

   });

   aC(div, shieldIframe);

   function handleEx(e)
   {
      status = e.message;
   }
   function setClass(o, name)
   {
      if (o)
         o.className = name + classSuffix;
   }
   //	Create outer table:
   var boundTable = createTable(win, 'BoundTable', 18, 9);
   boundTable.style.height = "100%";
   setClass(boundTable, 'CD_Win_');
   aC(div, boundTable);
   //	Lay out the	cells:
   rs = boundTable.rows;
   rs[7].style.height = '100%';
   for (i = 0; i < 18; i++)
      rC(rs, i, 4).style.width = '100%';

   var titlePaneContainer = rC(rs, 4, 4);
   var centerPaneContainer = rC(rs, 7, 4);
   var statusPaneContainer = rC(rs, 12, 4);

   //	Decorate	container:
   decorateContainer(titlePaneContainer, centerPaneContainer, statusPaneContainer);

   //	Create title pane:
   var titlePane = createTable(win, '', 1, 13);
   titlePane.border = 0;
   titlePane.frame = 'void';

   rs = titlePane.rows;
   var logoCell = rC(rs, 0, 0);
   var logoPadCell = rC(rs, 0, 1);
   var refreshCell = rC(rs, 0, 2);
   var refreshPadCell = rC(rs, 0, 3);
   var backForwardCell = rC(rs, 0, 4);
   var backForwardPadCell = rC(rs, 0, 5);
   var titleCell = rC(rs, 0, 6);
   titleCell.style.width = '100%';
   titleCell.style.cursor = 'move';
   titleCell.noWrap = true;
   titleCell.setAttribute("UNSELECTABLE", "on");
   var titleLabel = createLabel(win);
   var shortenTitle = false;
   var originalTitle = '';
   $(titleLabel).bind("mousedown", null, function(evnt)
   {
      evnt.preventDefault();
   });

   aC(titleCell, titleLabel);
   var pinCell = rC(rs, 0, 8);
   var pinPadCell = rC(rs, 0, 7);
   setVisible(pinCell, false, pinPadCell);
   var fitMinMaxCell = rC(rs, 0, 10);
   var fitMinMaxPadCell = rC(rs, 0, 9);
   var closeCell = rC(rs, 0, 12);
   var closePadCell = rC(rs, 0, 11);
   aC(titlePaneContainer, titlePane);
   //	Add images to titlePane:
   var logoImg = decorateImage(0);
   var refreshImg = decorateImage(1);
   var backImg = decorateImage(2);
   var forwardImg = decorateImage(3);
   var disabledBackImg = decorateImage(4);
   var disabledForwardImg = decorateImage(5);
   //var	pinImg =	decorateImage(6);
   var autoFitImg = decorateImage(7);
   var maxImg = decorateImage(8);
   var restoreImg = decorateImage(9);
   var minImg = decorateImage(10);
   var closeImg = decorateImage(11);

   closeImg.DialogId = dlgId;

   aC(logoCell, logoImg);
   aC(refreshCell, refreshImg);
   aC(backForwardCell, backImg, disabledBackImg, forwardImg, disabledForwardImg);
   //aC(pinCell, pinImg);
   aC(fitMinMaxCell, autoFitImg, minImg, maxImg, restoreImg);
   aC(closeCell, closeImg);

   //	Create center pane:
   var centerPane = createTable(win, '', 4, 3);
   centerPane.border = 0;
   centerPane.frame = 'void';
   rs = centerPane.rows;
   insertCells(rs[1], 2);
   insertCells(rs[2], 2);
   rC(rs, 0, 1).colSpan = 3;
   rC(rs, 3, 1).colSpan = 3;
   aC(centerPaneContainer, centerPane);
   //	Create and add	content iframe:
   var maxPadding = 100;
   var contentContainer = rC(rs, 2, 2);
   decorateContainer(contentContainer);
   if (!contentPadding || isNaN(contentPadding))
      contentPadding = 0;
   else
      if (contentPadding > maxPadding)
      contentPadding = maxPadding; //	limit to 20 pixels max
   if (contentPadding < 0)
      contentPadding = 0;
   me.setContentPadding = function(padding)
   {
      if (!isNaN(padding) && padding >= 0)
      {
         if (padding > maxPadding)
            padding = maxPadding;
         contentPadding = padding;
         contentContainer.style.padding = contentPadding;
      }
   }
   me.getContentPadding = function()
   {
      return contentPadding;
   }
   contentContainer.style.width = '100%';
   contentContainer.style.height = '100%';
   contentContainer.style.padding = contentPadding;

   var controlWindow = createContentWindow();
   var wizardWindow = createContentWindow();
   var frame = createIframe(win, 'CatDialogContentIframe');
   frame.style.backgroundColor = "#FFFFFF";
   me.frame = frame;
   me.innerFrame = frame;

   me.getInnerWindow = function()
   {
      var wd = null;
      try
      {
         wd = frame.contentWindow;
      }
      catch (e)
      {
         wd = null;
      }
      return wd;
   }

   aC(contentContainer, controlWindow, wizardWindow, frame);

   //	Create wizard panes:
   var wizardOuterMostFrame = createWizardFrame();
   var wizardOuterFrame = createWizardFrame();
   var wizardCenterFrame = createTable(win, '', 1, 1);
   wizardCenterFrame.style.height = '100%';
   wizardCenterFrame.style.width = '100%';
   wizardCenterFrame.border = 0;
   aC(wizardWindow, wizardOuterMostFrame);
   aC(rC(wizardOuterMostFrame.rows, 1, 1), wizardOuterFrame);
   aC(rC(wizardOuterFrame.rows, 1, 1), wizardCenterFrame);
   var wizardIframe = createIframe(win, '');
   setVisible(wizardIframe, false);

   aC(rC(wizardCenterFrame.rows, 0, 0), wizardIframe);
   //	0	0	0
   //	3		1
   //	2	2	2
   arr = wizardPanes;
   rs = wizardOuterMostFrame.rows;
   arr[0] = rC(rs, 0, 0);
   arr[1] = rC(rs, 1, 2);
   arr[2] = rC(rs, 2, 0);
   arr[3] = rC(rs, 1, 0);

   //	4	4	4
   //	7		5
   //	6	6	6
   rs = wizardOuterFrame.rows;
   arr[4] = rC(rs, 0, 0);
   arr[5] = rC(rs, 1, 2);
   arr[6] = rC(rs, 2, 0);
   arr[7] = rC(rs, 1, 0);

   //	8
   arr[8] = wizardCenterFrame.rows[0].cells[0];
   arr[8].style.height = '100%';
   arr[8].style.width = '100%';

   //	Create Status pane:
   var statusPane = createTable(win, '', 1, 5);
   statusPane.border = 0;
   statusPane.frame = 'void';
   rs = statusPane.rows;
   var statusIconCell = rC(rs, 0, 1);
   var statusIconPadCell = rC(rs, 0, 1);
   var statusTextCell = rC(rs, 0, 2);
   var statusLabel = createLabel(win);
   var resizeCell = rC(rs, 0, 3);
   resizeCell.style.padding = '0 0 0 0';
   var resizePadCell = rC(rs, 0, 3);
   var statusIcon = decorateImage(12);
   var resizeImg = decorateImage(13);
   statusTextCell.style.width = '100%';
   statusTextCell.noWrap = true;
   aC(statusTextCell, statusLabel);
   resizeCell.style.cursor = 'SE-resize';
   aC(statusPaneContainer, statusPane);
   //	Add images to status	pane:
   resizeImg.style.cursor = 'SE-resize';
   aC(statusIconCell, statusIcon);
   aC(resizeCell, resizeImg);

   //	Format borders	if	using	color	border:
   //borderColor

   //	Assign other CSS classes:
   var cN = 'CD_Corner_'; //	cN: class name
   //	4 corners:
   rs = boundTable.rows;
   setClass(rC(rs, 0, 0), cN + 'NW_'); //	N:	north, W: west, E: east, S: south
   setClass(rC(rs, 0, 8), cN + 'NE_');
   setClass(rC(rs, 17, 8), cN + 'SE_');
   setClass(rC(rs, 17, 0), cN + 'SW_');

   //	Left border:
   for (i = 1; i <= 16; i++)
      setClass(rC(rs, i, 0), 'CD_LeftBorder_');
   //	Right	border:
   for (i = 1; i <= 16; i++)
      setClass(rC(rs, i, 8), 'CD_RightBorder_');
   //	Top border:
   for (i = 1; i <= 7; i++)
      setClass(rC(rs, 0, i), 'CD_TopBorder_');
   //	Bottom border:
   for (i = 1; i <= 7; i++)
      setClass(rC(rs, 17, i), 'CD_BotBorder_');

   //	Secondary borders:
   //	Horizontal:
   cN = 'CD_H_Border';
   for (i = 1; i <= 6; i++)
      setClass(rC(rs, 1, i), cN + '0_');
   for (i = 2; i <= 6; i++)
      setClass(rC(rs, 2, i), cN + '30_');
   for (i = 2; i <= 6; i++)
      setClass(rC(rs, 3, i), cN + '30_');

   setClass(rC(rs, 5, 4), cN + '30_');
   setClass(rC(rs, 6, 4), cN + '30_');
   setClass(rC(rs, 8, 4), cN + '0_');
   setClass(rC(rs, 9, 4), cN + '30_');
   setClass(rC(rs, 10, 4), cN + '30_');

   setClass(rC(rs, 11, 4), cN + '60_');
   setClass(rC(rs, 13, 4), cN + '0_');
   setClass(rC(rs, 14, 4), cN + '30_');
   setClass(rC(rs, 15, 4), cN + '30_');
   for (i = 1; i <= 7; i++)
      setClass(rC(rs, 16, i), cN + '60_');

   rs = centerPane.rows;
   //	Central pane bottom:
   setClass(rC(rs, 3, 1), cN + '30_');
   //	Central pane top:
   setClass(rC(rs, 0, 1), cN + '60_');
   setClass(rC(rs, 1, 2), cN + '100_');
   //	Central pane right:
   cN = 'CD_V_Border';
   setClass(rC(rs, 0, 2), cN + '0_');
   setClass(rC(rs, 1, 4), cN + '0_');
   setClass(rC(rs, 2, 4), cN + '0_');
   setClass(rC(rs, 3, 2), cN + '0_');
   for (i = 1; i <= 2; i++)
      setClass(rC(rs, i, 3), cN + '30_');
   //	Central pane left:
   for (i = 0; i < 4; i++)
      setClass(rC(rs, i, 0), cN + '60_');
   for (i = 1; i <= 2; i++)
      setClass(rC(rs, i, 1), cN + '100_');
   //	Secondary left:
   rs = boundTable.rows;
   for (i = 2; i <= 15; i++)
      setClass(rC(rs, i, 1), cN + '0_');
   for (i = 3; i <= 15; i++)
      setClass(rC(rs, i, 2), cN + '30_');
   for (i = 3; i <= 15; i++)
      setClass(rC(rs, i, 3), cN + '30_');
   //	Secondary right:
   for (i = 1; i <= 15; i++)
      setClass(rC(rs, i, 7), cN + '60_');
   for (i = 3; i <= 15; i++)
      setClass(rC(rs, i, 6), cN + '30_');
   for (i = 3; i <= 15; i++)
      setClass(rC(rs, i, 5), cN + '30_');

   //	Title:
   cN = 'CD_Title';
   setClass(titleCell, cN + 'Cell_');
   setClass(titleLabel, cN + 'Label_');
   setClass(titlePaneContainer, cN + 'BG_');
   //	Status:
   cN = 'CD_Status';
   setClass(statusTextCell, cN + 'Cell_');
   setClass(statusLabel, cN + 'Label_');
   setClass(statusPaneContainer, cN + 'BG_');
   setClass(rC(statusPane.rows, 0, 0), 'CD_V_Border60_');
   setClass(rC(statusPane.rows, 0, 4), 'CD_V_Border0_');

   //	Pads:
   for (i = 1; i < 13; i += 2)
      setClass(rC(titlePane.rows, 0, i), 'CD_ImgPadCell_');
   //	Image	cell left:
   cN = 'CD_ImgCellLeft_';
   setClass(logoCell, cN);
   setClass(refreshCell, cN);
   setClass(backForwardCell, cN);
   setClass(statusIconCell, cN);
   //	Image	cell right:
   cN = 'CD_ImgCellRight_';
   setClass(pinCell, cN);
   setClass(fitMinMaxCell, cN);
   setClass(closeCell, cN);
   setClass(resizeCell, cN);

   function setModalShieldStyle(modalShield) {
    modalShield.border = 0;
    modalShield.frame = 'void';
    modalShield.width = 1;
    modalShield.height = 1;
    modalShield.tabIndex = -1;
    modalShield.style.position = 'absolute';
    modalShield.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(Opacity=0)';
    //chuong			backgroundColor =	shieldColor;
    modalShield.style.left = 0;
    modalShield.style.top = 0;
    setzIndex(modalShield, -1);
   }
   function createIframe(win, id_, iFrame)
   {
      iFrame = win.document.createElement('IFRAME');
      iFrame.id = id_;
      iFrame.border = 0;
      iFrame.width = '100%';
      iFrame.height = '100%';
      iFrame.style.margin = '0	0 0 0';
      iFrame.style.height = '100%';
      iFrame.frameBorder = 0;
      iFrame.tabIndex = -1;
      return iFrame;
   }
   function insertCells(row, n)
   {
      for (var i = 0; i < n; i++)
      {
         cell = row.insertCell(row.cells.length);
         cell.style.border = '0';
      }
   }
   function setVisible(obj, iVis)
   {
      if (iVis != false)
         iVis = true;
      var vis = (!iVis) ? 'hidden' : 'visible';
      var dis = (!iVis) ? 'none' : '';
      obj.style.visibility = vis;
      obj.style.display = dis;
      for (var i = 2; i < arguments.length; i++)
      {
         arguments[i].style.visibility = vis;
         arguments[i].style.display = dis;
      }
   }
   function setzIndex(obj, zIndex)
   {
      if (isNaN(zIndex))
         return;
      obj.style.zIndex = zIndex;
   }
   function gzIdx(obj)
   {
      return parseInt(obj.style.zIndex);
   }
   function getCWid(obj)
   {
      return obj.document.body.clientWidth;
   }
   function gSLef(win)
   {
      return win.document.body.scrollLeft;
   }
   function gSTop(win)
   {
      return win.document.body.scrollTop;
   }
   function gCHi(win)
   {
      return win.document.body.clientHeight;
   }
   function gSclHi(obj)
   {
      try
      {
         if (typeof (obj.scrollHeight) != 'undefined')
            return parseInt(obj.scrollHeight);
         if (obj && obj.document && obj.document.body)
            return parseInt(obj.document.body.scrollHeight);
      }
      catch (e) { }

      return 0;
   }
   function gSclWid(obj)
   {
      try
      {
         if (typeof (obj.scrollWidth) != 'undefined')
            return parseInt(obj.scrollWidth);
         if (obj && obj.document && obj.document.body)
            return parseInt(obj.document.body.scrollWidth);
      }
      catch (e) { }
      return 0;
   }
   function gSWid(obj)
   {
      return parseInt(obj.style.width);
   }
   function gSHi(obj)
   {
      return parseInt(obj.style.height);
   }
   function setStyleWidth(obj, w)
   {
      obj.style.width = w;
   }
   function setStyleHeight(obj, h)
   {
      obj.style.height = h;
   }
   function setStyleSize(obj, w, h)
   {
      setStyleWidth(obj, w);
      setStyleHeight(obj, h);
   }
   function decorateContainer(container)
   {
      for (i = 0; i < arguments.length; i++)
      {
         var o = arguments[i];
         if (o)
         {
            o.style.padding = '0 0 0 0';
         }
      }
   }
   function decorateImage(idx)
   {
      var img = imgArray[idx];
      var path = resourcePath;
      img.index = idx;


      img.src = path + '/' + skin + '/' + imgSrcArray[idx];
      img.title = me.imgTitleArray[idx];
      img.className = 'CD_Img_' + classSuffix;
      img.onmouseover = function()
      {
         img.src = path + '/' + skin + '/' + over_ImgSrcArray[idx];
      }

      img.onmouseout = function()
      {
         img.src = path + '/' + skin + '/' + imgSrcArray[idx];
      }

      img.onfocus = function(evnt)
      {
         if (cg_shared.IsIE)
            return false;
         else
         {
            evnt.preventDefault();
            evnt.stopPropagation();
         }
      }

      img.onmousedown = function(evnt)
      {
         if (cg_shared.IsIE)
            return false;
         else
         {
            evnt.preventDefault();
            //evnt.stopPropagation();
         }
      }

      img.ondragstart = function(evnt)
      {
         if (cg_shared.IsIE)
            return false;
         else
         {
            evnt.preventDefault();
            evnt.stopPropagation();
         }
      }

      return img;
   }
   function aC(container)	//	ac: add control
   {
      for (var i = 1; i < arguments.length; i++)
         container.appendChild(arguments[i]);
   }
   //	Control functions:
   //	Global:
   function beginResizing(evnt)
   {
      if (typeof (catdlg_onbeginresizing) != 'undefined')
         if (!eGo(catdlg_onbeginresizing, evnt.originalEvent))
         return false;

      if (true == svrEvents.beginResizing)
      {
         fireServerEvent(svrEvents.beginResizing);
      }

      if (me.isResizable == true && !me.isMaximized && isResizing == false)
      {
         isResizing = true;

         if (jQuery.browser.msie)
            resizeCell.setCapture();
         $(document).bind("mousemove", null, onResizing);
         $(document).bind("mouseup", null, onEndResizing);
      }
   }

   function onEndResizing(evnt)
   {
      $(document).unbind("mouseup", onEndResizing);
      $(document).unbind("mousemove", onResizing);

      if (jQuery.browser.msie)
         resizeCell.releaseCapture();
      
      if (isResizing == true)
      {
         me.showAutoFitButton(true);
         if (me.forceCenter && !me.isMinimized)
            me.moveCenter();
         isResizing = false;
      }
      if (typeof (catdlg_onendresizing) != 'undefined')
         eGo(catdlg_onendresizing, evnt.originalEvent);
      if (typeof (svrEvents.endResizing) != 'undefined')
         fireServerEvent(svrEvents.endResizing);
   }

   function onResizing(evnt)
   {
      var w = evnt.clientX - div.offsetLeft;
      var h = evnt.clientY - div.offsetTop;
      if (w >= 0 && h >= 0)
      {
         w += resizePadW;
         h += resizePadH;
         if (w < minWWid && minWWid > 0)
            w = minWWid;
         if (h < minWHi && minWHi > 0)
            h = minWHi;
         me.setSize(w+10, h+10);
      }
   }
   
   function beginMoving(evnt)
   {
      if (typeof (catdlg_onbeginmoving) != 'undefined')
         if (!eGo(catdlg_onbeginmoving, evnt.originalEvent))
         return false;

      if (typeof (svrEvents.beginMoving) != 'undefined')
         fireServerEvent(svrEvents.beginMoving);

      me.bringToTop();

      if (me.isMovable == true && !me.isMaximized)
      {
         if (jQuery.browser.msie)
            titleCell.setCapture();
      
         $(document).bind("mousemove", null, onMoving);
         $(document).bind("mouseup", null, onEndMoving);
         isMoving = true;

         movePadW = evnt.clientX - div.offsetLeft;
         movePadH = evnt.clientY - div.offsetTop;

         if (jQuery.browser.mozilla)
         {
            evnt.preventDefault();
            evnt.stopPropagation();
         }
      }
   }
   function onEndMoving(evnt)
   {
      if (isMoving == false)
         return;
      $(document).unbind("mousemove", onMoving);
      $(document).unbind("mouseup", onEndMoving);
      isMoving = false;
      if (me.isMinimized == true)
       me.alignMinWins();
      if (me.forceCenter && !me.isMinimized)
       me.moveCenter();
      if (jQuery.browser.msie)
         titleCell.releaseCapture();
      
      if (!isInView(div))
         me.moveCenter();

      if (typeof (catdlg_onendmoving) != 'undefined')
         eGo(catdlg_onendmoving, evnt.originalEvent);
      if (typeof (svrEvents.endMoving) != 'undefined')
         fireServerEvent(svrEvents.endMoving);
   }

   function isInView(o)
   {
      try
      {
         if (o.offsetLeft - gSLef(win) + 10 >= getCWid(win) || o.offsetTop - gSTop(win) + 10 >= gCHi(win)
				|| o.offsetLeft + o.offsetWidth <= 0 || o.offsetTop + o.offsetHeight <= 0)
            return false;
         return true;
      }
      catch (e)
      {
      }
   }
   function setFocus(o)
   {
      try
      {
         if (o == div && !isInView(o))
            me.moveCenter();
         else
            o.focus();
      }
      catch (e)
		{ }
   }
   
   function onMoving(e)
   {
      me.move(e.clientX - movePadW, e.clientY - movePadH);

      if (e.clientX < 0 || e.clientY < 0)
         win.scrollTo(gSLef(win), gSTop(win));

      isFrameCentered = false;
      if (jQuery.browser.mozilla)
         e.stopPropagation();
   }
   
   function checkAutoFittable()
   {
      try
      {
         var tmp = frame.contentWindow.document;
         isFitted = false;
         me.showAutoFitButton(true);
      }
      catch (e)
		{ }
   }
   var shakingCurrCount = -1;
   var shakingCount = 0;
   //	Shake	
   var offsetW = 2;
   var offsetH = 2;
   var shakeDelayTime = 10;
   var offsetX = [offsetW, -(offsetW << 1), (offsetW << 1), -offsetW, 0, 0, 0, 0];
   var offsetY = [0, 0, 0, 0, -offsetH, (offsetH << 1), -(offsetH << 1), offsetH];
   function shake()
   {
      if (shakingCurrCount < shakingCount)
      {
         var idx = shakingCurrCount % offsetX.length;
         me.move(me.getX() + offsetX[idx], me.getY() + offsetY[idx]);
         shakingCurrCount++;
         win.setTimeout(shake, shakeDelayTime, 'javascript');
      }
      else
      {
         shakingCurrCount = -1;
      }
   }
   me.shake = function(mseconds)
   {
      if (!iVis(div) && shakingCurrCount == 0)
         return;
      if (shakingCurrCount >= 0)
         return;
      if (!mseconds)
         mseconds = 1000; //	shake	1 second	by	default
      if (isNaN(mseconds))
         return;
      shakingCurrCount = 0;
      shakingCount = parseInt(mseconds) / shakeDelayTime;
      shakingCount -= shakingCount % offsetX.length;
      shake();
   }
   var filterCurrCount = -1;
   var filterCount = 0;
   var filterDelayTime = 200;
   var filterArray = null;
   var filterObj = null;
   var filterScriptArray = null;
   function applyFilter()
   {
      if (filterCurrCount < filterCount)
      {
         try
         {
            if (filterArray)
               filterObj.style.filter = filterArray[filterCurrCount % filterArray.length];
            if (filterScriptArray)
               filterScriptArray[filterCurrCount % filterScriptArray.length](filterObj);
         }
         catch (e)
			{ }
         filterCurrCount++;
         win.setTimeout(applyFilter, filterDelayTime, 'javascript');
      }
      else
      {
         filterCurrCount = -1;
      }
   }
   me.applyFilter = function(mseconds, titleBar, filters, scripts)
   {
      if (!iVis(div) && filterCount == 0)
         return;
      if (titleBar == true)
         filterObj = titlePaneContainer;
      else
         filterObj = div;
      if (filters && filters.length)
         filterArray = filters;
      else
         filterArray = null;
      if (scripts && scripts.length)
         filterScriptArray = scripts;
      else
         filterScriptArray = null;

      if (filterArray && filterScriptArray && filterArray.length % filterScriptArray.length != 0
			&& filterScriptArray.length % filterArray.length != 0)
         filterScriptArray = null;
      if (!filterArray && !filterScriptArray)
         filterArray = ['progid:DXImageTransform.Microsoft.BasicImage(invert=1)', filterObj.style.filter];

      if (filterCurrCount >= 0)
         return;
      if (!mseconds)
         mseconds = 1000; //	apply filter for 1 second by default
      if (isNaN(mseconds))
         return;
      filterCurrCount = 0;
      filterCount = parseInt(mseconds) / filterDelayTime;
      if (filterArray)
         filterCount -= filterCount % filterArray.length;
      else
         if (filterScriptArray)
         filterCount -= filterCount % filterScriptArray.length;
      applyFilter();
   }
   me.allowMovingStatusBar = function(allow)
   {
      if (allow == true)
         moveStatusBar = true;
      else
         moveStatusBar = false;
      if (moveStatusBar == true)
      {
       statusTextCell.onmousedown = titleCell.onmousedown;
       statusTextCell.onmouseup = titleCell.onmouseup;
       statusTextCell.onmousemove = titleCell.onmousemove;
      }
      else
      {
       statusTextCell.onmousedown = null;
       statusTextCell.onmouseup = null;
       statusTextCell.onmousemove = null;
      }
   }
   me.allowLogo = function(allow)
   {
      hasLogo = allow;
      me.showLogo();
   }
   me.allowRefreshButton = function(allow)
   {
      hasRefreshButton = allow;
      me.showRefreshButton();
   }
   me.allowBackForwardButtons = function(allow)
   {
      hasBackForwardButton = allow;
      me.showBackForwardButtons();
   }
   /*
   me.allowPinButton	= function(allow)
   {
   hasPinButton =	allow;
   me.showPinButton();
   }
   */
   me.allowAutoFitButton = function(allow)
   {
      hasAutoFitButton = allow;
      me.showAutoFitButton();
   }
   me.allowMinButton = function(allow)
   {
      hasMinButton = allow;
      me.showMinButton();
   }
   me.allowMaxButton = function(allow)
   {
      hasMaxButton = allow;
      me.showMaxButton();
   }
   me.allowCloseButton = function(allow)
   {
      hasCloseButton = allow;
      me.showCloseButton();
   }
   me.allowStatusIcon = function(allow)
   {
      hasStatusIcon = allow;
      me.showStatusIcon();
   }
   me.allowStatusBar = function(allow)
   {
      hasStatusBar = allow;
      me.showStatusBar();
   }
   me.allowTitleBar = function(allow)
   {
      hasTitleBar = allow;
      me.showTitleBar();
   }
   me.showLogo = function(show)
   {
      if (!(hasLogo != false))
         show = false;
      setVisible(logoCell, show, logoPadCell);
   }
   me.showRefreshButton = function(show)
   {
      if (!(hasRefreshButton != false))
         show = false;
      setVisible(refreshCell, show, refreshPadCell);
   }
   me.showBackForwardButtons = function(show)
   {
      if (!(hasBackForwardButton != false))
         show = false;
      setVisible(backForwardCell, show, backForwardPadCell);
   }
   me.showBackButton = function(show)
   {
      if (!(hasBackForwardButton != false))
         show = false;
      setVisible(backImg, show);
   }
   me.showDisabledBackButton = function(show)
   {
      if (!(hasBackForwardButton != false))
         show = false;
      setVisible(disabledBackImg, show);
   }
   me.showForwardButton = function(show)
   {
      if (!(hasBackForwardButton != false))
         show = false;
      setVisible(forwardImg, show);
   }
   me.showDisabledForwardButton = function(show)
   {
      if (!(hasBackForwardButton != false))
         show = false;
      setVisible(disabledForwardImg, show);
   }
   /*
   me.showPinButton = function (show)
   {
   if(!(hasPinButton	!=	false))
   show = false;
   setVisible(pinCell, show, pinPadCell);
   }
   */
   me.showFitMinMaxButtons = function(show)
   {
      if (!(hasMinButton != false) && !(hasMaxButton != false) && !(hasAutoFitButton != false))
         show = false;
      setVisible(fitMinMaxCell, show, fitMinMaxPadCell);
   }
   me.showMinButton = function(show)
   {
      if (!(hasMinButton != false))
         show = false;
      setVisible(minImg, show);
   }
   me.showMaxButton = function(show)
   {
      if (!(hasMaxButton != false))
         show = false;
      setVisible(maxImg, show);
   }
   me.showRestoreButton = function(show)
   {
      if (!(hasMaxButton != false) && !(hasMinButton != false))
         show = false;
      setVisible(restoreImg, show);
   }
   me.showAutoFitButton = function(show)
   {
      if (!(hasAutoFitButton != false))
         show = false;
      setVisible(autoFitImg, show);
   }
   me.showCloseButton = function(show)
   {
      if (!(hasCloseButton != false))
         show = false;
      setVisible(closeCell, show, closePadCell);
   }
   me.showStatusIcon = function(show)
   {
      if (!(hasStatusIcon != false))
         show = false;
      setVisible(statusIconCell, show, statusIconPadCell);
   }
   me.showResizeIcon = function(show)
   {
      if (!(me.isResizable != false))
         show = false;
      setVisible(resizeCell, show, resizePadCell);
      var showStatus = hasStatusBar;
      if (!(show != false) && $(statusLabel).text().length <= 0)
         showStatus = false;
      me.showStatusBar(showStatus);
   }
   me.showStatusBar = function(show)
   {
      rs = boundTable.rows;
      if (!(hasStatusBar != false))
         show = false;
      if (line1 && line2 && line4)	//	all lines
         for (i = 10; i <= 14; i++)
         setVisible(rs[i], show);
      else	//	not all lines
      {
         if (!line2)
            setVisible(rs[12], show);
         if (!line1) // no line, delete	more
            setVisible(rs[0], show);
         if (!line4)
            setVisible(rs[17], show);
      }
   }
   me.showTitleBar = function(show)
   {
      if (!(hasTitleBar != false))
         show = false;
      for (i = 4; i <= 6; i++)
         setVisible(boundTable.rows[i], show);
   }
   if (typeof (outerOnresizeHandler) == 'undefined')
      outerOnresizeHandler = null;
   if (typeof (outerOnscrollHandler) == 'undefined')
      outerOnscrollHandler = null;
   if (typeof (onresizeHandler) == 'undefined')
   {
      onresizeHandler = function()
      {
      }
      onscrollHandler = function()
      {
         me.alignWins();
         me.alignMinWins();
         refreshModalShield();
         if (typeof (outerOnscrollHandler) == 'function')
         {
            outerOnscrollHandler();
         }
         if (typeof (_onscroll) == 'function' && _onscroll != outerOnscrollHandler)
         {
            _onscroll();
         }
      }
   }
   function eGo(fn, param)
   {
      var go = true;
      if (typeof (fn) == 'function')
         try
      {
         go = fn(me, wizardCurrStep, param);
      }
      catch (e)
		{ handleEx(e); }
      if (false == go)
         return false;
      return true;
   }

   function bringFrameToTop()
   {
      var dlgs = getDialogList();
      if (dlgs == null) return;
      for (var idx = 0; idx < dlgs.length; idx++)
      {
         var dlg = dlgs[idx];
         if (dlg.getModal() == true)
            return;
      }
      tmpList = new Array();
      for (var idx = 0; idx < dlgs.length; idx++)
         if (dlgs[idx] != me)
         tmpList.push(dlgs[idx]);
      tmpList.push(me);
      DialogList = tmpList;

      me.bringToTop();
   }

   function frameOnReadyStateChange()
   {
      if (!cg_shared.IsIE && typeof (frame.readyState) == 'undefined')
         frame.readyState = 'complete'

      me.readyState = frame.readyState;
      if (iVis(controlWindow) || iVis(wizardWindow))
         return;
      if (frame.readyState == 'interactive' || frame.readyState == 'complete')
      {
         setVisible(frame, true);
         contentContainer.style.cursor = 'auto';
         if (frame.src && frame.src.length)
            frameSrc = frame.src;
         //	Set the title:
         try //	Try to get the	title
			{
            if (titleText == null)
            {
               var titles = frame.contentWindow.document.getElementsByTagName('TITLE');
               var _title = cg_shared.IsIE ? titles[0].innerText : titles[0].textContent; //the statement $(titles[0]).text() does not work properly.
               if (_title.length > 0)
                  me.setTitle(_title, true);

            }
            else
               me.setTitle(titleText, true);
         }
         catch (e)
         {
            me.setTitle(altTitleText, true);
         }

         try
         {
            if (frameHistory != null)
               a2Hry(frame.contentWindow.location.href);
         }
         catch (e)
         {
            me.setTitle('', true);
            a2Hry(frame.src);
         }

      }
      var timerId;
      var bindbringontop = function()
      {
         window.clearInterval(timerId);
         if (typeof (me.getInnerWindow().cgDialog_BindBringOnTop) == 'function')
         {
            me.getInnerWindow().cgDialog_BindBringOnTop(me);
            bindbringontop = null;
         }
      };

      timerId = window.setInterval(bindbringontop, 1000);

   }


   function init()
   {
      if (cg_shared.IsIE)
         $(frame).bind('readystatechange', null, frameOnReadyStateChange);
      else
         $(frame).bind('load', null, frameOnReadyStateChange);

      $(titleCell).bind("mousedown", null, beginMoving);

      titleCell.ondblclick = me.toggleSize;

      me.allowMovingStatusBar(moveStatusBar);

      $(autoFitImg).click(function(evnt)
      {
         if (typeof (catdlg_onautofit) != 'undefined')
            if (!eGo(catdlg_onautofit, evnt.originalEvent))
            return false;
         if (typeof (svrEvents.autoFit) != 'undefined')
            fireServerEvent(svrEvents.autoFit);
         me.autoFitSize();
      });

      $(maxImg).click(function(evnt)
      {
         if (typeof (catdlg_onmaximize) != 'undefined')
            if (!eGo(catdlg_onmaximize, evnt.originalEvent))
            return false;

         if (typeof (svrEvents.maximize) != 'undefined')
            fireServerEvent(svrEvents.maximize);

         me.maximize();
      });

      $(restoreImg).click(function(evnt)
      {
         if (typeof (catdlg_onrestore) != 'undefined')
            if (!eGo(catdlg_onrestore, evnt.originalEvent))
            return false;
         if (typeof (svrEvents.restore) != 'undefined')
            fireServerEvent(svrEvents.restore);

         me.restore();
      });

      $(minImg).click(function(evnt)
      {
         if (typeof (catdlg_onminimize) != 'undefined')
            if (!eGo(catdlg_onminimize, evnt.originalEvent))
            return false;
         if (typeof (svrEvents.minimize) != 'undefined')
            fireServerEvent(svrEvents.minimize);

         me.minimize();
      });

      $(resizeCell).bind("mousedown", null, beginResizing);

      closeImg.onclick = function()
      {
         var dlg = findDialog(closeImg.DialogId);
         if (dlg != null && typeof (dlg.ClientSideEvents.onclose) == 'string')
         {
            try
            {
               var result = dlg.getInnerWindow().eval(dlg.ClientSideEvents.onclose + "()");
               if (result == false)
                  return result;
            }
            catch (e) { }
         }

         if (typeof (catdlg_onclose) != 'undefined')
            if (!eGo(catdlg_onclose))
            return false;
         if (svrEvents && typeof (svrEvents.close) != 'undefined')
            fireServerEvent(svrEvents.close);
         me.show(false);
         if (me.destroyOnHide == true)
            me.destroy();
      }

      statusIcon.ondblclick = function()
      {
         if ($(statusLabel).text().length > 0)
            alert($(statusLabel).text());
      }

      logoImg.ondblclick = closeImg.onclick;
      refreshImg.onclick = function()
      {
         if (currIndex >= 0 && currIndex < frameHistory.length)
         {
            if (typeof (catdlg_onrefresh) != 'undefined')
               if (!eGo(catdlg_onrefresh, frameHistory[currIndex]))
               return false;
            if (typeof (svrEvents.refresh) != 'undefined')
               fireServerEvent(svrEvents.refresh, null, frameHistory[currIndex]);
            try
            {
               frame.contentWindow.location.reload(true);
            }
            catch (e)
            {
               frame.src = frameHistory[currIndex];
            }
         }
         return false;
      }
      backImg.onclick = function()
      {
         try
         {
            if (currIndex - 1 >= 0)
            {
               if (currIndex <= 0)
                  return;
               if (typeof (catdlg_ongoback) != 'undefined')
                  if (!eGo(catdlg_ongoback, frameHistory[currIndex - 1]))
                  return false;
               if (typeof (svrEvents.goBack) != 'undefined')
                  fireServerEvent(svrEvents.goBack, null, frameHistory[currIndex - 1]);
               gotoPage(currIndex - 1);
            }
         }
         catch (e)
			{ handleEx(e); }
      }
      forwardImg.onclick = function()
      {
         try
         {
            if (currIndex + 1 < frameHistory.length)
            {
               if (currIndex + 1 >= frameHistory.length)
                  return;
               if (typeof (catdlg_ongoforward) != 'undefined')
                  if (!eGo(catdlg_ongoforward, frameHistory[currIndex + 1]))
                  return false;
               if (typeof (svrEvents.goForward) != 'undefined')
                  fireServerEvent(svrEvents.goForward, null, frameHistory[currIndex + 1]);
               gotoPage(currIndex + 1);
            }
         }
         catch (e)
			{ }
      }

      //	This is part of the init proccess:
      //	Capture the	document	onresize	and onscroll event:

      me.setTitle(titleText, true);
      me.setStatus(statusText);
      me.refreshVisualFace();
      //	Initial status
      me.show(visibleAtStartup == true);
      me.setModal(isModal);
      me.setUrl(frameSrc);

      if (!isModal)
      {
         parent.setTimeout(me.bringToTop, 100);
      }
   }
   function saveWinPos()
   {
      winX = div.style.left;
      winY = div.style.top;
      winWidth = me.getW();
      winHeight = me.getH();
   }
   me.showDDLs = function(show, curWin)
   {
      return;
      //no need to disable
      if (curWin && curWin.tagName == 'IFRAME')
         try
      {
         curWin = curWin.contentWindow;
      }
      catch (e)
      {
         return;
      }
      if (!curWin)
      {
         curWin = win;
      }
      try
      {
         var selectObjs;
         var isWin = false;
         try
         {
            selectObjs = curWin.getElementsByTagName('SELECT');
         }
         catch (e)
         {
            selectObjs = curWin.document.body.getElementsByTagName('SELECT');
            isWin = true;
         }
         for (i = 0; i < selectObjs.length; i++)
         {
            if (contentContainer.contains(selectObjs[i]))
            {
             selectObjs[i].disabled = false;
             selectObjs[i].isDisabledByMD = false;
             continue;
            }

            if (typeof (selectObjs[i].isDisabledByCD) == 'undefined')
               selectObjs[i].isDisabledByCD = false;
            if (!selectObjs[i].isDisabled && selectObjs[i].show == false) {
             selectObjs[i].disabled = true;
             selectObjs[i].isDisabledByCD = true;
            }
            else if (selectObjs[i].show == true && selectObjs[i].isDisabledByCD == true) {
             selectObjs[i].disabled = false;
             selectObjs[i].isDisabledByMD = false;
            }
         }
         var frameObjs;
         if (isWin)
            frameObjs = curWin.document.body.getElementsByTagName('FRAME');
         else
            frameObjs = curWin.getElementsByTagName('FRAME');
         for (var i = 0; i < frameObjs.length; i++)
         {
            me.showDDLs(show, frameObjs[i].contentWindow);
         }
         var iFrameObjs;
         if (isWin)
            iFrameObjs = curWin.document.body.getElementsByTagName('IFRAME');
         else
            iFrameObjs = curWin.getElementsByTagName('IFRAME');
         for (var i = 0; i < iFrameObjs.length; i++)
         {
            if (iFrameObjs[i] != me.frame || show == true)
               me.showDDLs(show, iFrameObjs[i].contentWindow);
            else
               me.showDDLs(true, iFrameObjs[i].contentWindow);
         }
      }
      catch (e)
		{ }
   }
   me.focus = function()
   {
      div.click();
   }
   function sameUrls(url1, url2)
   {
      if (!url1 || !url2)
         return false;
      url1 = url1.toLowerCase();
      url2 = url2.toLowerCase();
      if (url1 == url2)
         return true;
      return false;
   }
   function addTitleToHistory(replaceLast)
   {
      var ttText = $(titleLabel).text();
      if (ttText == me.pageLoadText)
         ttText = '';
      if (replaceLast == true)
      {
         if (titleArray.length - 1 >= 0)
            titleArray[titleArray.length - 1] = ttText;
      }
      else
         titleArray[titleArray.length] = ttText;
   }
   function gotoPage(idx, oldPage)
   {
      if (idx < 0 || idx >= frameHistory.length)
         return;

      if (typeof (catdlg_ongotovisitedpage) != 'undefined')
         if (!eGo(catdlg_ongotovisitedpage, frameHistory[idx]))
         return false;
      if (typeof (svrEvents.gotoPage) != 'undefined')
         fireServerEvent(svrEvents.gotoPage, null, frameHistory[idx]);

      currIndex = idx;
      if (!(oldPage == true))
      {
         me.setUrl(frameHistory[idx]);
      }
      refreshImg.title = titleArray[idx] + (titleArray[idx] ? '\n' : '') + frameHistory[idx];
      if (idx > 0)
      {
         me.showBackButton(true);
         me.showDisabledBackButton(false);
         backImg.title = titleArray[idx - 1] + (titleArray[idx - 1] ? '\n' : '') + frameHistory[idx - 1];
      }
      else
      {
         me.showBackButton(false);
         me.showDisabledBackButton(true);
         backImg.title = '';
      }

      if (idx < frameHistory.length - 1)
      {
         me.showForwardButton(true);
         me.showDisabledForwardButton(false);
         forwardImg.title = titleArray[idx + 1] + (titleArray[idx + 1] ? '\n' : '') + frameHistory[idx + 1];
      }
      else
      {
         me.showForwardButton(false);
         me.showDisabledForwardButton(true);
         forwardImg.title = '';
      }

      if (frameHistory.length > 1)
      {
         me.showBackForwardButtons(true);
      }
      else
         me.showBackForwardButtons(false);
   }
   function a2Hry(url)	//	add to history
   {
      if (url == null || url.length == 0 || url == 'about:blank')
         return;
      //	Check	if	two addresses same:
      if (sameUrls(url, frameHistory[currIndex]))
      {
         //	Get title text	if	any:
         if (!titleArray[titleArray.length - 1].length)
         {
            addTitleToHistory(true);
         }
         return;
      }

      if (typeof (catdlg_onaddtohistory) != 'undefined')
         if (!eGo(catdlg_onaddtohistory, url))
         return false;
      if (typeof (svrEvents.addToHistory) != 'undefined')
         fireServerEvent(svrEvents.addToHistory, null, url);

      frameHistory = frameHistory.slice(0, currIndex + 1);
      titleArray = titleArray.slice(0, currIndex + 1);
      frameHistory[frameHistory.length] = url;
      addTitleToHistory(false);
      currIndex = frameHistory.length - 1;
      gotoPage(currIndex, true);
   }
   function iVis(obj)
   {
      if (obj)
         return (obj.style.visibility != 'hidden');
      return true;
   }
   function dtPerm(idx)	//	destroy permanent
   {
      closeWaitingPage();
      if (typeof (catdlg_ondestroy) != 'undefined')
         if (!eGo(catdlg_ondestroy, idx))
         return false;
      if (typeof (svrEvents.destroy) != 'undefined')
         fireServerEvent(svrEvents.destroy);

      var dlg = DialogList[idx];
      if (dlg instanceof CatDialog)
      {
         dlg.setModal(false);

         if (cg_shared.IsIE)
         {
            dlg.setUrl("about:blank");

            try
            {
               $(dlg.HTMLElement).replaceWith("<SPAN></SAPN>");
            }
            catch (e)
			   { }
         }
         //dialogContainer.removeChild(dlg.HTMLElement);
         //	Delete dlg object:
         dlg.ClientSideEvents = null;
         dlg.HTMLElement.instance = null;
         dlg.HTMLElement = null;
         dlg = null;
         var list = new Array();
         for (i = 0; i < idx; i++)
            list[list.length] = DialogList[i];
         for (i = idx + 1; i < DialogList.length; i++)
            list[list.length] = DialogList[i];
         for (i = 0; i < DialogList.length; i++)
            DialogList[i] = null;
         DialogList = null;
         DialogList = list;
      }
   }
   //	Public
   me.show = function(toShow, refresh, destroy)
   {
      if (toShow != false)
         toShow = true;
      if (toShow == true)
         fu();
      setVisible(div, toShow);
      setVisible(frame, toShow);
      if (modalDlg == null)	//	is OFF
      {
         if (isModal == true && toShow == true)	//	switch it ON
         {
            modalDlg = me;
            me.refreshModalShield();
         }
      }
      else	//	is ON
      {
         if (modalDlg == me && toShow == false)	//	switch it OFF
         {
            if (me.lastModalDlg && me.lastModalDlg != null)
            {
               modalDlg = me.lastModalDlg;
               modalDlg.refreshModalShield();
            }
            else
            {
               modalDlg = null;
               me.lastModalDlg = null;
               disableShield();
            }
         }
         if (toShow == true && modalDlg != me)	//	pass it to me
         {
            me.lastModalDlg = modalDlg;
            modalDlg = me;
            me.refreshModalShield();
         }
      }
      if (!toShow && refresh == true)
      {
         if (win.document.forms.length)
            win.document.forms[0].submit();
      }
      me.alignMinWins();

      if (typeof (destroy) != 'undefined')
      {
         if (destroy == true)
            me.destroy();
      }
      else
      {
         if (me.destroyOnHide == true && !toShow)
            me.destroy();
      }
   }
   me.refreshVisualFace = function() {
    me.showLogo();
    me.showRefreshButton();
    if (frameHistory.length > 1)
     me.showBackForwardButtons(true);
    else
     me.showBackForwardButtons(false);
    //showPinButton();
    me.showAutoFitButton();
    me.showMinButton();
    me.showMaxButton();
    me.showFitMinMaxButtons();
    if (me.isMaximized == true || me.isMinimized == true)
     me.showRestoreButton(true);
    else
     me.showRestoreButton(false);
    me.showCloseButton();
    me.showStatusIcon();
    me.showResizeIcon();
    me.showStatusBar();
    me.showTitleBar();
    me.setShieldColor(shieldColor);
    me.updateSizeAndPos();
   }
   //	Set frame inner content
   //	if	"content" is a	tring, add "content"
   //	if	"content" is an object,	add "content.outerHTML"
   //	if	"content" is null	and "objId"	is	a string, set content to be "object.outerHTML"
   //		where	object.id == objId
   me.setFrameContent = function(content, objId)
   {
      var contentOuterHTML = content ? $($('<div></div>').html($(content).clone())).html() : null;
      if (content != null && typeof (content) == 'string')
      {
         frame.src = 'javascript:new String(\'' + escape(content) + '\');';
      }
      else
         if (content && typeof (content) == 'object' && contentOuterHTML)
      {
         frame.src = 'javascript:new String(\'' + escape(contentOuterHTML) + '\');';
      }
      else
         if (content && typeof (content) == 'function')
      {
         try
         {
            content = content();
            content = content.toString();
         }
         catch (e)
					{ content = ''; }
         frame.src = 'javascript:new String(\'' + escape(content) + '\');';
      }
      if (typeof (objId) == 'string')
      {
         var obj = getById(objId);
         var objOuterHTML = $($('<div></div>').html($(obj).clone())).html();
         if (obj && typeof (objOuterHTML) != 'undefined')
         {
            frame.src = 'javascript:new String(\'' + escape(objOuterHTML) + '\');';
         }
      }
   }
   //	On	setting url, three possible value canbe posted back to url server	in	a query string:
   //	params: value of request "params", must be a	string
   //	dataObj:	get value for request "data",	must be an object	with property "innerText" or "value"
   //		or a function, or an id of the data object
   //	evalExp:	evaluate	value	for request	"options", must be evaluatable to return the	desired value
   me.setUrl = function(url, params, dataObj, evalExp, frameName, addToList)
   {
      if (typeof (url) != 'string')
         return;
      var request = '';
      if (typeof (params) == 'string' && params.length)
      {
         request = request + '&params=' + escape(params);
      }
      if (typeof (dataObj) == 'string')
      {
         dataObj = getById(dataObj);
      }
      if (typeof (dataObj) == 'object' && dataObj != null)
      {
         var data = '';
         if (typeof (dataObj.value) == 'string' && dataObj.value.length)
         {
            data = dataObj.value;
         }
         else
         {
            var txt = $(dataObj).text();
            if (typeof (txt) == 'string' && txt.length > 0)
               data = txt;
         }
         request = request + '&data=' + escape(data);
      }
      else
         if (typeof (dataObj) == 'function')
      {
         var data;
         try
         {
            data = dataObj();
         }
         catch (e)
         {
            data = '';
         }
         request = request + '&data=' + escape(data);
      }
      if (typeof (evalExp) == 'string' && evalExp.length)
      {
         var options = '';
         try
         {
            options = eval(evalExp);
         }
         catch (e)
         {
            options = '';
         }
         if (options.length)
            request = request + '&options=' + escape(options);
      }
      if (request != '')
      {
         if (url.indexOf('?') < 0)
            url = url + '?';
         url = url + request;
      }

      if (typeof (frameName) == 'string')
      {
         frame.name = frameName;
      }
      me.readyState = 'uninitialized';
      me.setTitle(me.pageLoadText, true);
      frameSrc = url;
      frame.src = url;

      //      try{frame.contentWindow.location.assign(url);}catch(e){}

      isFitted = false;
      me.setViewTo('iframe');

      if (cg_shared.IsIE && url.length)
      {
         setVisible(frame, false);
         contentContainer.style.cursor = 'wait';
      }
   }
   me.refreshIframe = function()
   {
      try
      {
         frame.contentWindow.location.reload(true);
      }
      catch (e)
		{ }
   }
   me.getUrl = function()
   {
      var url = '';
      try
      {
         url = frame.contentWindow.location.href;
      }
      catch (e)
      {
         url = frameSrc;
      }
      return url;
   }
   setViewTo = function(obj)
   {
      if (obj.toLowerCase() == 'controls')
      {
         setVisible(frame, false, wizardWindow);
         setVisible(controlWindow, true);
         me.setTitle(titleText, true);
      }
      else
         if (obj.toLowerCase() == 'wizard')
      {
         setVisible(controlWindow, false, frame);
         setVisible(wizardWindow, true);
         showStepCtrl(wizardCurrStep, true);
         //	Don't add toStep here
      }
      else	//	set view	to	'iframe'
      {
         showStepCtrl(wizardCurrStep, false);
         setVisible(controlWindow, false, wizardWindow);
         setVisible(frame, true);
         me.setTitle(titleText, true);
      }
      if (!iVis(frame))
         contentContainer.style.cursor = 'auto';
   }
   me.setViewTo = setViewTo;
   me.getView = function()
   {
      if (iVis(controlWindow) == true)
      {
         return "controls";
      }
      else
         if (iVis(wizardWindow) == true)
      {
         return "wizard";
      }
      else
         return "iframe";
   }
   me.setStepUrl = function(stepIndex, url)
   {
      if (stepIndex < 0 || stepIndex >= wizardStepControls.length)
         return;
      if (typeof (url) != 'string')
         return;
      currStep = wizardStepControls[stepIndex];
      currStep.url = url;
   }
   me.toStep = function(stepIndex, setViewToStep)
   {
      if (stepIndex < 0 || stepIndex >= wizardStepControls.length)
         return false;

      if (typeof (catdlg_onchangestep) != 'undefined')
         if (!eGo(catdlg_onchangestep))
         return false;
      if (typeof (svrEvents.changeStep) != 'undefined')
         fireServerEvent(svrEvents.changeStep, stepIndex);

      //	Hide old	step:
      var currStep = null;
      if (wizardCurrStep != stepIndex)
         showStepCtrl(wizardCurrStep, false);
      //	Show new	Step:
      showStepCtrl(stepIndex, true);
      //	Set the title:
      var ttText = wizardTitleArray[stepIndex];
      if (typeof (ttText) == 'function')
         ttText = ttText();
      if (!ttText)
         ttText = '';
      me.setTitle(ttText, true);
      wizardCurrStep = stepIndex;
      rfsNavBts();
      if (setViewToStep != false)
         me.setViewTo('wizard');
   }
   function showStepCtrl(stepIndex, toShow)
   {
      if (wizardStepControls == null)
         return;
      if (stepIndex < 0 || stepIndex >= wizardStepControls.length)
         return false;
      if (toShow != false)
         toShow = true;
      //	Show or hide step:
      var currStep = wizardStepControls[stepIndex]
      if (toShow)
         wizardIframe.src = currStep.url;
      else
         wizardIframe.src = '';
      setVisible(wizardIframe, (wizardIframe.src != ''));
      try
      {
         for (var i = 0; i < currStep.length; i++)
            setVisible(currStep[i], toShow);
      }
      catch (e)
		{ }
   }
   me.rollStepBack = function(count)
   {
      var stepIndex = wizardCurrStep - count;
      if (stepIndex < 0)
         stepIndex = 0;
      return me.toStep(stepIndex);
   }
   me.rollStepForward = function(count)
   {
      var stepIndex = wizardCurrStep + count;
      if (stepIndex >= wizardStepControls.length)
         stepIndex = wizardStepControls.length - 1;
      if (stepIndex < 0)
         stepIndex = 0;
      return me.toStep(stepIndex, count);
   }
   me.toNextStep = function()
   {
      if (wizardCurrStep < 0 || wizardCurrStep + 1 >= wizardStepControls.length)
         return;
      if (typeof (catdlg_onnextstep) != 'undefined')
         if (!eGo(catdlg_onnextstep))
         return false;
      if (typeof (svrEvents.toNextStep) != 'undefined')
         fireServerEvent(svrEvents.toNextStep, (wizardCurrStep + 1));

      return me.rollStepForward(1);
   }
   me.toPrevStep = function()
   {
      if (wizardCurrStep <= 0 || wizardCurrStep - 1 >= wizardStepControls.length)
         return;

      if (typeof (catdlg_onprevstep) != 'undefined')
         if (!eGo(catdlg_onprevstep))
         return false;
      if (typeof (svrEvents.toPrevStep) != 'undefined')
         fireServerEvent(svrEvents.toPrevStep, (wizardCurrStep - 1));

      return me.rollStepBack(1);
   }
   me.getCurrentStepIndex = function()
   {
      return wizardCurrStep;
   }
   me.getStepCount = function()
   {
      return wizardStepControls.length;
   }
   cancelWizard = function()
   {
      if (typeof (catdlg_oncancelwizard) != 'undefined')
         if (!eGo(catdlg_oncancelwizard))
         return false;
      if (typeof (svrEvents.cancelWizard) != 'undefined')
         fireServerEvent(svrEvents.cancelWizard, wizardCurrStep);

      me.show(false);
   }
   finishWizard = function()
   {
      if (typeof (catdlg_onfinishwizard) != 'undefined')
         if (!eGo(catdlg_onfinishwizard))
         return false;
      if (typeof (svrEvents.finishWizard) != 'undefined')
         fireServerEvent(svrEvents.finishWizard, wizardCurrStep);

      me.show(false);
   }
   me.wizardNextButton = null;
   me.wizardBackButton = null;
   me.wizardCancelButton = null;
   me.wizardFinishButton = null;
   me.setWizardActivationButtons = function(back, next, finish, cancel)
   {
      if (next)
      {
         me.wizardNextButton = next;
         if (typeof (next) == 'string')
         {
            me.wizardNextButton = getById(next);
         }
         if (me.wizardNextButton && typeof (me.wizardNextButton) == 'object')
            me.wizardNextButton.onclick = function()
            {
               me.toNextStep();
               return false;
            }
         else
            me.wizardNextButton = null;
      }
      if (back)
      {
         me.wizardBackButton = back;
         if (typeof (back) == 'string')
         {
            me.wizardBackButton = getById(back);
         }
         if (me.wizardBackButton && typeof (me.wizardBackButton) == 'object')
            me.wizardBackButton.onclick = function()
            {
               me.toPrevStep();
               return false;
            }
         else
            me.wizardBackButton = null;
      }
      if (cancel)
      {
         me.wizardCancelButton = cancel;
         if (typeof (cancel) == 'string')
         {
            me.wizardCancelButton = getById(cancel);
         }
         if (me.wizardCancelButton && typeof (me.wizardCancelButton) == 'object')
            me.wizardCancelButton.onclick = function()
            {
               cancelWizard();
               return false;
            }
         else
            me.wizardCancelButton = null;
      }
      if (finish)
      {
         me.wizardFinishButton = finish;
         if (typeof (finish) == 'string')
         {
            me.wizardFinishButton = getById(finish);
         }
         if (me.wizardFinishButton && typeof (me.wizardFinishButton) == 'object')
            me.wizardFinishButton.onclick = function()
            {
               finishWizard();
               return false;
            }
         else
            me.wizardFinishButton = null;
      }
      rfsNavBts();
   }
   function rfsNavBts()	//	refresh naigation buttons
   {
      if (me.wizardBackButton != null)
         if (wizardCurrStep == 0)
         setVisible(me.wizardBackButton, false);
      else
         setVisible(me.wizardBackButton, true);
      if (me.wizardNextButton != null && me.wizardFinishButton != null)
         if (wizardCurrStep == wizardStepControls.length - 1)
      {
         setVisible(me.wizardNextButton, false);
         setVisible(me.wizardFinishButton, true);
      }
      else
      {
         setVisible(me.wizardNextButton, true);
         setVisible(me.wizardFinishButton, false);
      }
   }
   //	Add one step, return	index	of	the newly-added step
   me.addStep = function(title, url)
   {
      var step = new Array();
      if (typeof (url) == 'string' && url.length)
         step.url = url;
      else
         step.url = '';
      var idx = wizardStepControls.length;
      wizardStepControls[idx] = step;
      wizardTitleArray[idx] = title;
      return idx;
   }
   //	Add more	steps	to	the wizard
   //	stepInfo: an array of steps[step	title, url]
   //	If	pane index is not	in	the range [0, 7],	control is added to center	pane
   //	if	leaveDiv	is	true,	it	is	assumed that controls in a	table	cell is wrapped with	a div,
   //		when moving	child	controls	from the	cell,	leave	out the DIV
   //		The div has	the 'Step' property,	indicating stepIndex
   me.addMultipleSteps = function(stepInfo, tableId, leaveDiv)
   {
      //	Add steps:
      if (typeof (stepInfo) == 'object')
         try
      {
         for (i = 0; i < stepInfo.length; i++)
         {
            var step = stepInfo[i];
            me.addStep(step[0], step[1]);
         }
      }
      catch (e)
			{ handleEx(e); }
      //	Add controls and copy cell	properties:
      var t = getById(tableId);
      if (!t || !t.rows)
         return;
      var row = t.rows[0];
      if (!row)
         return;
      var paneCount = parseInt(row.cells.length);
      if (paneCount > 9)
         paneCount = 9;

      var nodes;
      //	Iterate through the cells (panes):
      for (i = 0; i < paneCount; i++)
      {
         cell = row.cells[i];
         me.getWizardPane(i).mergeAttributes(cell, true);
         if (cell && cell.childNodes && cell.childNodes.length)
         {
            var nodes = cell.childNodes;
            var ct;
            for (var j = 0; j < nodes.length; j++)
            {
               //	Transfer	each control to wizard pane:
               ct = nodes[j];
               if (ct.tagName == 'DIV' && leaveDiv == true)
               {
                  try
                  {
                     var step = parseInt(ct.getAttribute('Step'));
                  }
                  catch (e)
                  {
                     step = -1;
                  }
                  for (var k = 0; k < ct.childNodes.length; k++)
                  {
                     var ct2 = ct.childNodes[k];
                     me.moveControlToWizardPane(i, ct2, step);
                  }
               }
               else
               {
                  aC(wizardPanes[j], ct);
               }
            }
         }
      }
      if (typeof (catdlg_onwizardactive) != 'undefined')
         eGo(catdlg_onwizardactive);
      me.toStep(0); //	step 0
   }
   me.setStepTitle = function(stepIndex, t)
   {
      if (stepIndex >= 0 && stepIndex < wizardTitleArray.length)
      {
         wizardTitleArray[stepIndex] = t;
      }
   }
   //	Add controls to the center	pane of a wizard step
   me.letStepManageControl = function(stepIndex, o)
   {
      try
      {
         step = wizardStepControls[stepIndex];
         if (step && o)
         {
            setVisible(o, false);
            step[step.length] = o;
         }
      }
      catch (e)
		{ handleEx(e); }
   }
   //	Get wizard pane at index paneIndex
   //	pane is a table cell, indexes	and positions are	as	follows:
   //	0	0	0	0	0
   //	3	4	4	4	1
   //	3	7	8	5	1
   //	3	6	6	6	1
   //	2	2	2	2	2
   me.getWizardPane = function(paneIndex)
   {
      try
      {
         if (paneIndex >= 0 && paneIndex < wizardPanes.length)
            return wizardPanes[paneIndex];
      }
      catch (e)
		{ handleEx(e); }
      return wizardPanes[8];
   }
   me.moveControlToWizardPane = function(paneIndex, o, stepIndex, pane)
   {
      try
      {
         pane = me.getWizardPane(paneIndex);
         if (o)
         {
            fu();
            aC(pane, o);
            me.letStepManageControl(parseInt(stepIndex), o);
         }
      }
      catch (e)
		{ handleEx(e); }
   }
   //	Add object o to pane	with index paneIndex	in	step with index stepIndex:
   //	If	pane index is not	in	the range [0, 7],	control is added to center	pane
   me.moveControlToWizardPaneBefore = function(paneIndex, o, anchorObj, stepIndexdx, pane)
   {
      try
      {
         pane = me.getWizardPane(paneIndex);
         if (o)
         {
            var tmp = pane.insertBefore(o, anchorObj);
            me.letStepManageControl(parseInt(stepIndex), o);
         }
      }
      catch (e)
		{ handleEx(e); }
   }
   me.add = function(obj, objId, removeOldObj, makeVisible)
   {
      if (obj == null)
         obj = getById(objId);
      if (obj && typeof (obj) == 'object')
      {
         try
         {
            var obj2 = null;
            if (!removeOldObj)
               obj2 = obj.cloneNode(true);
            else
               obj2 = obj;
            fu();
            aC(controlWindow, obj2);
            if (obj2)
               me.showDDLs(true, obj2);
            if (makeVisible == true)
               setVisible(obj2, true);
         }
         catch (e)
			{ handleEx(e); }
      }
   }
   me.move = function(x, y)
   {
      if (isNaN(x) || isNaN(y))
         return;
      var minPad = (titleCell.offsetHeight >> 1);
      var len = titleCell.offsetLeft + titlePaneContainer.offsetLeft + boundTable.offsetLeft + titleCell.offsetWidth - minPad;
      if (x < -len)
         x = -len;
      if (y < -minPad)
         y = -minPad;

      div.style.left = x;
      div.style.top = y;
   }

   me.getCloseImage = function()
   {
      return decorateImage(11);
   }

   me.moveCenter = function()
   {
      h = div.offsetHeight;
      if (h == 0)
         h = gSHi(div);
      w = div.offsetWidth;
      if (w == 0)
         w = gSWid(div);
      me.move(((getCWid(win) - w) >> 1) + gSLef(win), ((gCHi(win) - h) >> 1) + gSTop(win));
   }
   me.setSize = function(w, h)
   {
      checkAutoFittable();
      if (w >= 0 && h >= 0)
      {
         if (cg_shared.IsIE && (h > document.body.offsetHeight))
            h = document.body.offsetHeight - 5;
         else if (h > document.body.clientHeight)//FireFox
            h = document.body.clientHeight - 5;
         if (w > document.body.offsetWidth)
            w = document.body.offsetWidth - 5;

         setStyleSize(div, w, h);
         if (div.offsetHeight > h)
            setStyleHeight(div, div.offsetHeight);
         if (div.offsetWidth > w)
            setStyleWidth(div, div.offsetWidth);
         me.move(me.getX(), me.getY());
         if (me.isMaximized || me.isMinimized)
         {
            me.showMaxButton(true);
            me.showMinButton(true);
            me.showRestoreButton(false);
         }
         me.isMaximized = false;
         me.isMinimized = false;
      }
   }
   me.setMinSize = function(minW, minH)
   {
      if (minW >= 0 && minH >= 0)
      {
         minWWid = minW;
         minWHi = minH;
      }
   }
   me.restore = function()
   {
      if (me.isMaximized == true || me.isMinimized == true)
      {
       div.style.left = winX;
       div.style.top = winY;
       div.style.overflow = 'visible';
       setStyleSize(div, winWidth, winHeight);
       me.showResizeIcon(true);
       me.showMaxButton(true);
       me.showMinButton(true);
       me.showAutoFitButton(true);
       me.showRestoreButton(false);
       me.isMaximized = false;
       me.isMinimized = false;
       //restore the tilte if it was shorten
       if (me.getTitleShortened()) {
        me.setTitle(me.getOriginalTitle(), true);
        me.setTitleShortened(false);
       }
       me.alignMinWins();
       //setFocus(div);

         if (!isFitted)
         {
            me.showAutoFitButton(true);
         }
         if (isFrameCentered == true || me.forceCenter == true)
            me.moveCenter();
      }
      if (me.getInnerWindow() != null)
         me.getInnerWindow().focus();
   }
   me.maximize = function()
   {
      if (!me.isMaximized)
      {
          if (me.isMinimized == false)
           saveWinPos();
          me.showMinButton(false);
          me.showMaxButton(false);
          me.showAutoFitButton(false);
          me.showRestoreButton(true);
          me.isMaximized = true;
          me.isMinimized = false;
      }
      div.style.overflow = 'visible';
      x = gSLef(win);
      y = gSTop(win);
       me.showResizeIcon(false);
       me.move(x, y);
       setStyleSize(div, getCWid(win), gCHi(win)); //	Dont use the setsize method
       me.move(gSLef(win), gSTop(win));
      if (me.getInnerWindow() != null)
         me.getInnerWindow().focus();
   }
   me.minimize = function()
   {
    if (!me.isMinimized) {
     saveWinPos();
     me.showMinButton(false);
     me.showMaxButton(false);
     me.showAutoFitButton(false);
     me.showRestoreButton(true);
     me.isMinimized = true;
     me.isMaximized = false;
    }
    me.showResizeIcon(false);
      div.style.overflow = 'hidden';
      var h = 0;
      for (i = 0; i <= 5; i++)
         h += parseInt(boundTable.rows[i].offsetHeight);

      if (me.getCurrentTitle() != null && me.getCurrentTitle().length > 15)
      {
         me.setTitleShortened(true);
         me.setTitle(me.getCurrentTitle(), true);
      }

      setStyleSize(div, minWid, h); //	Don't use the setsize method
      me.alignMinWins();
      if (me.getInnerWindow() != null)
         me.getInnerWindow().focus();
   }
   me.toggleSize = function()
   {
      if (!hasMaxButton)
         return;
       if (me.isMinimized == true) {
        me.restore();
        return;
       }
       if (!me.isResizable)
        return;

       if (me.isMaximized == true)
        me.restore();
       else
        me.maximize();
   }
   //	Align	all minimized windows
   me.isVisible = function()
   {
      return iVis(div);
   }
   if (typeof (alignMinWins) == 'undefined')
      alignMinWins = function()
      {
         var iRow = 0;
         var iCol = 0;
         var countPerRow = parseInt(getCWid(win) / minWid);
         if (countPerRow == 0)
            countPerRow = 1;
         var rowHeight = 0;
         for (i = 0; i < DialogList.length; i++)
         {
            dlg = DialogList[i];
            if (dlg.isMinimized == true && dlg.isVisible())
            {
               if (rowHeight == 0)
                  rowHeight = dlg.getH();
               dlg.move(iCol * minWid + gSLef(win), gCHi(win) - (iRow + 1) * rowHeight + gSTop(win));
               iCol++;
               if (iCol == countPerRow)
               {
                  iRow++;
               }
               iCol %= countPerRow;
            }
         }
      }
   me.alignMinWins = alignMinWins;
   if (typeof (alignWins) == 'undefined')
      alignWins = function()
      {
         var dlg = null;
         for (i = 0; i < DialogList.length; i++)
         {
            dlg = DialogList[i];
            dlg.updateSizeAndPos();
         }
         //if(modalDlg != null)
         //modalDlg.occupyTopModal();
      }
   me.alignWins = alignWins;
   me.updateSizeAndPos = function() {
    if (me.isMaximized == true) {
     me.maximize();
    }
    else
     if (!me.isMinimized) {
     me.restore();
     if (me.isFrameCentered == true || me.forceCenter == true)
      me.moveCenter();
    }
   }
   var fitRoundW = -1, fitRoundH = -1;
   var autoFitCount = 0;
   autoFitSize = function(roundW, roundH)
   {
      if (me.isMaximized == true)
      {
         fitRoundW = fitRoundH = -1;
         return;
      }
      if (fitRoundW < 0)
      {
         try
         {
            fitRoundW = parseInt(roundW);
            if (fitRoundW < 0 || fitRoundW == 'NaN')
               fitRoundW = 0;
         }
         catch (e)
         {
            fitRoundW = 0;
         }
      }
      if (fitRoundH < 0)
      {
         try
         {
            fitRoundH = parseInt(roundH);
            if (fitRoundH < 0 || fitRoundH == 'NaN')
               fitRoundH = 0;
         }
         catch (e)
         {
            fitRoundH = 0;
         }
      }
      var client = contentContainer;
      var iW = controlWindow;
      if (iVis(wizardWindow))
      {
         iW = wizardWindow;
      }
      else
         if (!iVis(controlWindow))
      {
         try
         {
            iW = frame.contentWindow;
            //				var recall = iW.document.readyState != 'complete' & autoFitCount < 300;
            //				if(me.ForMessage)
            //				   recall &= (iW.document.readyState != 'interactive');
            if (cg_shared.IsIE & iW.document.readyState != 'complete' & autoFitCount < 300)
            {
               autoFitCount++;
               win.setTimeout(autoFitSize, iW.document.URL == 'about:blank' ? 1 : 500, 'javascript');
               return;
            }
         }
         catch (e)
			{ }
      }
      try
      {
         var w = gSWid(div) + gSclWid(iW) - client.offsetWidth;
         var h = gSHi(div) + gSclHi(iW) - client.offsetHeight;
         if (h > gCHi(win) || w > getCWid(win) || (h >> 1) + (h >> 2) > w)
         {
            var area = w * h;
            var newW = 2 * Math.sqrt(area / 3);
            var newH = area / newW;
            me.setSize(newW + 10, newH);
            me.moveCenter();
            w = gSWid(div) + gSclWid(iW) - client.offsetWidth;
            h = gSHi(div) + gSclHi(iW) - client.offsetHeight;
         }
         if (fitRoundW > 0)	//	ignore 0
         {
            w += fitRoundW - 1;
            w -= (w % fitRoundW);
         }
         if (fitRoundH > 0)
         {
            h += fitRoundH - 1;
            h -= (h % fitRoundH);
         }
         w += (contentPadding << 1);
         h += (contentPadding << 1);
         if (w > getCWid(win))
            w = getCWid(win);
         //if(h > gCHi(win))
         //h = gCHi(win);
         if (w < minWWid)
            w = minWWid;
         if (h < minWHi)
            h = minWHi;
         me.setSize(w, h);
         isFrameCentered = true;
         me.moveCenter();
      }
      catch (e)
		{ handleEx(e); }
      autoFitCount = 0;
      isFitted = true;
      fitRoundW = fitRoundH = -1;
      me.showAutoFitButton(false);
   }
   me.autoFitSize = autoFitSize;
   me.setModal = function(modal)
   {
      if (typeof (catdlg_onsetmodal) != 'undefined')
         if (!eGo(catdlg_onsetmodal, modal))
         return false;
      if (typeof (modal) == '')
         modal = true;

      isModal = modal;
      if (modalDlg == null)	//	is OFF
      {
         if (modal == true && me.isVisible())
         {
            modalDlg = me;
            me.refreshModalShield();
         }
      }
      else	//	is ON
      {
         if (modalDlg == me && modal == false)	//	turn OFF
         {
            if (me.lastModalDlg != null && me.lastModalDlg.isVisible() && me.lastModalDlg.getModal() == true)
            {
               modalDlg = me.lastModalDlg;
               me.lastModalDlg.refreshModalShield();
            }
            else
            {
               modalDlg = null;
               disableShield();
            }
         }
         else
         {
            if (modalDlg != me && modal == true && me.isVisible())
            {
               me.lastModalDlg = modalDlg;
               modalDlg = me;
               me.refreshModalShield();
            }
         }
      }
      me.refreshModalShield();
   }
   me.getModal = function()
   {
      if (isModal == true)
         return true;
      return false;
   }
   me.setAltTitle = function(val)
   {
      if (val)
         altTitleText = val;
      else
         altTitleText = '';
   }
   me.setTitle = function(text, discard)
   {
      if (typeof (catdlg_onsettitle) != 'undefined')
         if (!eGo(catdlg_onsettitle, text))
         return false;

      if (discard != true)
         titleText = text;
      if (text == null)
         text = '';

      text = text.replace(/^\s+/, '').replace(/\s+$/, '');
      titleLabel.title = win.unescape(text.toString());

      var titleLength = text.toString().length, shownTitle = text;
      if (me.isMinimized && titleLength > 15)           //if the title is over 15 characters when minimized, just show the first 15 chars with '...' at the end.
         shownTitle = text.substring(0, 15) + "...";
      else if (titleLength > 100)                              //if the title is too long, just show the first 100 chars with '...' at the end.
         shownTitle = text.substring(0, 100) + "...";

      //do NOT use $(titleLabel).text(...) because the DIV "titleLabel" does not change it's width follow the length of text.
      if (cg_shared.IsFireFox)
         titleLabel.textContent = win.unescape(shownTitle.toString());
      else
         titleLabel.innerText = win.unescape(shownTitle.toString());
   }
   me.getTitle = function()
   {
      return titleText;
   }
   me.getCurrentTitle = function()
   {
      return titleLabel.title; //the real title is stored in 'title' field.
   }
   me.setTitleShortened = function(shorten)
   {
      shortenTitle = shorten;
      if (shorten)
         originalTitle = me.getCurrentTitle();
   }
   me.getTitleShortened = function()
   {
      return shortenTitle;
   }
   me.getOriginalTitle = function()
   {
      return originalTitle;
   }
   me.getAltTitle = function()
   {
      return altTitleText;
   }
   me.getStatus = function()
   {
      return $(statusLabel).text();
   }
   me.setStatus = function(text, type, important)
   {
      if (typeof (catdlg_onsetstatus) != 'undefined')
         if (!eGo(catdlg_onsetstatus, text))
         return false;

      if (text == null)
         text = '';
      statusLabel.innerText = win.unescape(text);
      statusLabel.title = win.unescape(text);
      if (text.length)
      {
         me.showStatusIcon(true);
         statusIcon.title = text;
         rISrc(statusIcon, '-important.gif', '.gif');
         var iNW = 'status-warning.gif'; //	iN: image name, W: warning, E: error, I: info, Wo:	wondering
         var iNE = 'status-error.gif', iNI = 'status-info.gif', iNWo = 'status-wondering.gif';
         if (type)
            switch (type)
         {
            case 'warning':
               rISrc(statusIcon, iNI, iNW);
               rISrc(statusIcon, iNE, iNW);
               rISrc(statusIcon, iNWo, iNW);
               break;
            case 'error':
               rISrc(statusIcon, iNI, iNE);
               rISrc(statusIcon, iNW, iNE);
               rISrc(statusIcon, iNWo, iNE);
               break;
            case 'wondering':
               rISrc(statusIcon, iNI, iNWo);
               rISrc(statusIcon, iNW, iNWo);
               rISrc(statusIcon, iNE, iNWo);
               break;
            case 'info':
            default:
               rISrc(statusIcon, iNW, iNI);
               rISrc(statusIcon, iNE, iNI);
               rISrc(statusIcon, iNWo, iNI);
               break;
         }
         if (important == true)
            rISrc(statusIcon, '.gif', '-important.gif');
      }
      else
         me.showStatusIcon(false);
   }
   function rISrc(img, oldSrc, newSrc)	//	replace image source
   {
      if (!img)
         return;
      img.src = img.src.toLowerCase().replace(oldSrc, newSrc);
   }
   me.bringToTop = function()
   {
      if (gzIdx(div) + 2 < MaxzIndex)
      {
         setzIndex(div, MaxzIndex);
         setzIndex(modalShield, gzIdx(div) - 1);
         me.refreshModalShield();
         MaxzIndex += 2;
      }
   }
   me.getMaxzIndex = function()
   {
      return MaxzIndex;
   }

   //	Get the window having the valid event object
   //	Don't	search frames,	just current frames and	child	iframes
   //	Search windows	top down, begin from	specified win
   function gEWin(win)
   {
      var iFrameObjs = win.document.body.getElementsByTagName('IFRAME');
      for (var i = 0; i < iFrameObjs.length; i++)
      {
         w = gEWin(iFrameObjs[i].contentWindow);
         if (w)
            return w;
      }
      return null; //	No	valid	event	in	any window found
   }

   if (typeof (refreshModalShield) == 'undefined')
      refreshModalShield = function()
      {
         if (modalDlg != null && modalDlg.HTMLElement != null && iVis(modalDlg.HTMLElement))
         {
            if (gzIdx(modalDlg.HTMLElement) + 2 < MaxzIndex)
            {
               setzIndex(modalDlg.HTMLElement, MaxzIndex);
               MaxzIndex += 2;
            }
            var h = Math.max(gSclHi(win), gCHi(win));
            var w = Math.max(gSclWid(win), getCWid(win));
            modalShield.width = w;
            modalShield.height = h;
            setzIndex(modalShield, gzIdx(modalDlg.HTMLElement) - 1);
            setVisible(modalShield, true);
            if (dropDownHideMode == 'disable')
               modalDlg.showDDLs(false);
            return true;
         }
         else
         {
            disableShield();
            return false;
         }
         return false;
      }
   function disableShield()
   {
      if (typeof(parent.hasModal) == 'function' &&  parent.hasModal())
         return;
      if (modalDlg)
         modalDlg = modalDlg.lastModalDlg;
      setzIndex(modalShield, -1);
      setVisible(modalShield, false);
      if (dropDownHideMode == 'disable')
         me.showDDLs(true);
   }
   me.refreshModalShield = refreshModalShield;
   me.setShieldColor = function(color)
   {
      if (!color)
         return;
      shieldColor = color;
      //chuong		modalShield.style.backgroundColor =	shieldColor;
   }
   me.setDropDownHideMode = function(mode)
   {
      if (mode.toLowerCase() == 'preventchange')
         dropDownHideMode = 'preventchange';
      else
         dropDownHideMode = 'disable';
   }
   me.getX = function()
   {
      return div.offsetLeft;
   }
   me.getY = function()
   {
      return div.offsetTop;
   }
   me.getW = function()
   {
      if (div.offsetWidth > 0)
         return div.offsetWidth;
      else
         return parseInt(div.style.width);
   }
   me.getH = function()
   {
      if (div.offsetHeight > 0)
         return div.offsetHeight;
      else
         return parseInt(div.style.height);
   }
   me.getId = function()
   {
      return dlgId;
   }
   me.setIdEx = function(newId)
   {
      dlgId = newId;
   }
   me.setId = function(newId, url)
   {
      dlgId = newId;
      serverId = dlgId;
      if (url == null || url.length == 0)
         url = frameSrc;
      try
      {
         url = frame.contentWindow.location.href;
      }
      catch (e)
		{ handleEx(e); }
      me.setUrl(url, null, null, null, newId);
   }
   //	Find first dialog	with specified	id
   if (typeof (findDialog) == 'undefined')
      findDialog = function(id)
      {
         for (i = 0; i < DialogList.length; i++)
         {
            dlg = DialogList[i];
            if (dlg.getId() == id)
               return dlg;
         }
         return null;
      }
   me.findDialog = findDialog;
   me.getDialogList = function()
   {
      return DialogList;
   }
   me.destroy = function(dlg)
   {
      if (!dlg)
         dlg = me;
      for (var index = 0; index < DialogList.length; index++)
      {
         if (dlg.getId() == DialogList[index].getId())
         {
            dtPerm(index);
            break;
         }
      }
   }
   me.getWin = function()
   {
      return win;
   }
   me.getOuterWin = me.getWin;
   me.papa = win;
   me.setImageTitles = function(logo, refresh, back, forward, backoff, forwardoff, pin, autofit, maximize, restore, minimize, close, statusicon, resize)
   {
      arr = me.imgTitleArray;
      var len = arr.length;
      if (len > arguments.length)
         len = arguments.length;
      for (i = 0; i < len; i++)
         arr[i] = unescape(arguments[i]);

      //	Dont'	change navigation	buttons'	title
      imgArray[0].title = arr[0];
      for (i = 6; i < imgArray.length; i++)
         imgArray[i].title = (arr[i]);
   }
   //	Init (events handlers, variables, ...)
   refreshZIndex = function() {
    var tmp = 0;
    var inc = MaxzIndex;
    var maxZ = Math.max.apply(null, $.map($('body > *'), function(e, n) {
     if ($(e).css('position') == 'absolute')
      return parseInt($(e).css('z-index')) || 1;
    }));
    if (MaxzIndex < maxZ)
     MaxzIndex = maxZ;
    if (MaxzIndex < 100000)
     MaxzIndex <<= 1;
    MaxzIndex += 2;
    inc = MaxzIndex - inc;
    for (i = 0; i < DialogList.length; i++) {
     var dlg = DialogList[i];
     if (dlg)
      setzIndex(dlg.HTMLElement, gzIdx(dlg.HTMLElement) + inc);
    }
   }
   
   if (typeof (checkHandlers) == 'undefined')
   {
      var handlerCheckCount = 0;
      checkHandlers = function()
      {
            if (win.document.body.onresize != onresizeHandler)
            {
               var onresizeFunc = win.document.body.onresize;
               outerOnresizeHandler = onresizeFunc;
               win.document.body.onresize = onresizeHandler;
            }
            if (win.document.body.onscroll != onscrollHandler)
            {
               var onscrollFunc = win.document.body.onscroll;
               outerOnscrollHandler = onscrollFunc;
               win.document.body.onscroll = onscrollHandler;
            }
         if (win.document.readyState != 'complete' && handlerCheckCount < 300)
         {
            handlerCheckCount++;
            win.setTimeout(checkHandlers, 600, 'javascript');
         }
         else
         {
            refreshZIndex();
            refreshModalShield();
            if (typeof (catdlg_onstatesteady) != 'undefined')
               eGo(catdlg_onstatesteady);
         }
      }
      checkHandlers();
   }
   function fu()
   {
      if (addDiv == true)
         if (dialogContainer)
      {
         aC(dialogContainer, div);
         setVisible(dialogContainer, true);
      }
      else
      {
         aC(win.document.body, div);
      }
      if (addShield == true)
         if (dialogContainer)
         aC(dialogContainer, modalShield);
      else
         aC(win.document.body, modalShield);
   }
   wizardIframe.onreadyStateChange = function()
   {
      if (wizardIframe.readyState == 'interactive' || wizardIframe.readyState == 'complete')
      {
         if (typeof (catdlg_onpostedback) == 'function')
         {
            try
            {
               catdlg_onpostedback(me, wizardCurrStep, wizardIframe.contentWindow);
            }
            catch (e)
				{ handleEx(e); }
         }
      }
   }
   
   init();
   if (!line1)	 // delete line 1
   {
      rs = boundTable.rows;
      setVisible(rs[0], false, rs[1], rs[2], rs[3]);
   }
   if (!line2)	//	delete line	2
   {
      rs = boundTable.rows;
      setVisible(rs[5], false, rs[6], rs[8], rs[9], rs[10], rs[11]);

      rs = centerPane.rows;
      setVisible(rs[0], false, rs[1], rs[3], rC(rs, 2, 0), rC(rs, 2, 1), rC(rs, 2, 3), rC(rs, 2, 4));

      rs = statusPane.rows;
      setVisible(rC(rs, 0, 0), false, rC(rs, 0, 4));
   }
   if (!line4)	//	delete line	3
   {
      rs = boundTable.rows;
      setVisible(rs[13], false, rs[14], rs[15], rs[16], rs[17]);
   }
   me.getWin = function()
   {
      return win;
   }
   if (typeof (catdlg_onstart) != 'undefined')
      eGo(catdlg_onstart);
}

