var DivInnerHtml = "";
var DivList = new Array();
var SubDivList = new Array();
var lastDiv;
var ToolbarStartLeft = 2;
var MenuBoxStartTop = 107;
var SubStartTop = 31;
var SubBoxStartTop = 90;
var SubSubStartTop = 0;
var HelpStartTop = 0;
var ToolbarArgs = "";
var SubSubOffset = 0;
var HideOption = ""
var PickField = ' ';
var PickRow = 0;
var PriorClickedRow = 1;
var MessageboxIcon = "";
var MessageboxButton = "";
var ini_UndefinedMenuButtonVisible = true;
var chooseRow = -1;

var MONTH_NAMES=new Array('January','February','March','April','May','June','July','August','September','October','November','December','Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var DAY_NAMES=new Array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday','Sun','Mon','Tue','Wed','Thu','Fri','Sat');



//Since you can only have one popup per window, we use the popup's window as the second window.
var oPopup = window.createPopup();
var window2 = oPopup.document.parentWindow;
var ooPopup  = window2.createPopup();

var posX = 0;
var posY = 0;

//window.onload = init();

function init() {
  if (window.Event) {
    document.captureEvents(Event.MOUSEMOVE);
  }
  //document.getElementById("CenterContent").onmousedown = getXY;
  document.onmousemove = getXY;
}


function f_ini(argParm1) {
 //alert('f_ini: ' + argParm1);
 ini_UndefinedMenuButtonVisible = argParm1;
}

function f_OnLoad(argHideOption) {
// window.resizeTo(window.screen.width, window.screen.height);
// window.moveTo(0,0);

// if (document.layers) document.captureEvents(Event.MOUSEMOVE);
// document.onmousemove=mtrack;

 HideOption = argHideOption;

 f_BuildMenuStyle();
 if (argHideOption == 0) { //Show menu - eg menu screen
  f_BuildMenuTop(argHideOption);
  f_BuildMenuLeft(argHideOption);
 }
 if (argHideOption == 1) { //Hide menu - eg add wizards
  f_BuildMenuTop(argHideOption);
  f_BuildMenuLeft(argHideOption);
  f_MenuLeftHide();
 }
 if (argHideOption == 2) { //Menu in Tab Frames in List screen
  SubSubOffset = -37;
  f_BuildMenuTop(argHideOption);
  f_BuildMenuLeft(argHideOption);
  f_MenuLeftHide();
  f_MenuTopHide();
 }
 if (argHideOption == 3) { //TopOnly in Tab Frames
  f_BuildMenuTop(argHideOption);
  var xWidth = window.screen.width - 20; //Rajesh changed from 29
  MenuTopAreaId.style.left="0px";
  MenuTopAreaId.style.width= xWidth + "px";
  MenuTopAMANDAiId.style.left="0px";
  MenuToolbarId.style.left="0px";
  MenuToolbarId.style.width= xWidth + "px";
  //workspace.style.left="8px"; //Rajesh Set off  
  var elementCreateMenuLeft = document.createElement("<DIV id=MenuLeft>");
  document.body.insertBefore(elementCreateMenuLeft);
 }
 if (argHideOption == 4) { //Toolbars only in Tab Frame's Detail window
  f_BuildMenuTop(argHideOption);
  f_MenuLeftHide2();
  f_MenuTopHide2();
  var xWidth = window.screen.width - 280;
  MenuTopAreaId.style.width= xWidth + 280 + "px";
 }
 if (argHideOption == 5) { //Toolbars and wipe in Tab Frame's List window 
  f_BuildMenuTop(argHideOption);
  var elementCreateWipe = document.createElement('<IMG id=wipe src="images\\wipe.gif" OnMouseOver="f_MenuFrameShow();">'); //Rajesh Set off
  document.body.insertBefore(elementCreateWipe);
  var xWidth = window.screen.width -  20; //Rajesh changed from 29
  MenuTopAreaId.style.visibility='hidden';
  MenuTopAMANDAiId.style.left="0px";
  MenuToolbarId.style.top="0px";
  MenuToolbarId.style.left="0px";
  MenuToolbarId.style.width= xWidth + "px";
  wipe.style.visibility='visible';
 }
 
 //used by CallCenter
  if (argHideOption == 6) {
   f_BuildMenuTop(argHideOption);
   var elementCreateWipe = document.createElement('<IMG id=wipe src="images\\wipe.gif" OnMouseOver="f_MenuFrameShow();">'); //Rajesh Set off
   document.body.insertBefore(elementCreateWipe);
   var xWidth = window.screen.width - 20;
   MenuTopAreaId.style.visibility='hidden';
   MenuTopAMANDAiId.style.visibility='hidden';
   MenuToolbarId.style.top="0px";
   MenuToolbarId.style.left="0px";
   MenuToolbarId.style.width= xWidth + "px";
   MenuToolbarId.style.width= "0px";
   wipe.style.visibility='visible';
 }
 
 f_BuildMenuHelp();

}

function f_BuildMenuHelp() {
 var elementCreateHelpSub = document.createElement('<DIV id=MenuHelpSub style="POSITION: ABSOLUTE; VISIBILITY: hidden;">');
 document.body.insertBefore(elementCreateHelpSub );
 var elementHelpSub =  document.all.item("MenuHelpSub");
 DivList.push(elementHelpSub);
 DivInnerHtml = "";
 f_BuildHelpText("User Guide","f_open('http:/help/user/Output/wwhelp.htm');", true);
 f_BuildHelpText("Administrator's Guide","f_open('http:/help/admin/Output/wwhelp.htm');", true);
 f_BuildHelpText("Telephone Directory","f_open('NotImplemented.htm');", false);
 f_BuildHelpText("Frequently Asked Questions","f_open('NotImplemented.htm');", false);
 f_BuildHelpText("Glossary","f_open('NotImplemented.htm');", false);
 f_BuildHelpText("Site Map","f_open('NotImplemented.htm');", false);
 f_BuildHelpText("Website Terms &amp; Conditions","f_open('NotImplemented.htm');", false);
 f_BuildHelpText("Website Privacy Policy","f_open('NotImplemented.htm');", false);
 f_BuildHelpText("Most Up To Date Documentation","f_open('http://www.csdcsystems.com');", false);
 f_BuildHelpText("About AMANDAi","f_open('about_AMANDAi.htm');", true);
 elementHelpSub.style.height = HelpStartTop;
 elementHelpSub.innerHTML = DivInnerHtml;

}

function f_BuildHelpText(argText, argClick, argDefined) {
 if (argDefined || ini_UndefinedMenuButtonVisible) {
  DivInnerHtml += '<span class=MenuHelpBox style="TOP: ' + HelpStartTop + 'px;" onMouseOver="this.style.background=\'#6697C4\';" onMouseOut="this.style.background=\'#F0F8FF\';" onClick="parent.' + argClick + '">';
  DivInnerHtml += ' <span class=MenuHelpText>' + argText + '</span>';
  DivInnerHtml += '</span>';
  HelpStartTop = HelpStartTop + 23;
 }
}

function f_BuildMenuTop(argHideOption) {
 var elementCreateMenuTop = document.createElement('<DIV id=MenuTop>');
 document.body.insertBefore(elementCreateMenuTop );
 var elementMenuTop =  document.all.item("MenuTop");

 DivInnerHtml  = '<span id=MenuTopAreaId class=MenuTopArea></span>';
 DivInnerHtml += '<img  id=MenuTopAMANDAiId class=MenuTopAMANDAi src="images/menuAMANDAi.gif" border="0" >';
 f_BuildMenuTopText(280,'LOGOFF', "f_submit('logoff.jsp');", 1);
 f_BuildMenuTopBar(220, 4);
 f_BuildMenuTopHelp(199, "HELP", "f_MenuHelpShow();", 2);
 f_BuildMenuTopBar(159, 5);
 f_BuildMenuTopText(144, "CONTACT US", "f_open('http://www.csdcsystems.com/contact.htm');", 3);
 if (argHideOption == 0) {
  DivInnerHtml += '<span id=MenuToolbarId class=MenuToolbar onMouseOver="f_SubMenuHide();"></span>';
 } else {
  if (argHideOption == 4) {
   DivInnerHtml += '<span id=MenuToolbarId class=MenuToolbar></span>';
  } else {
   if (argHideOption == 5) {
    DivInnerHtml += '<span id=MenuToolbarId class=MenuToolbar onMouseOver="f_MenuFrameHide();"></span>';
   } else {
    DivInnerHtml += '<span id=MenuToolbarId class=MenuToolbar onMouseOver="f_MenuLeftHide();"></span>';
   }
  }
 }
 elementMenuTop.innerHTML = DivInnerHtml ;
}

function f_BuildMenuLeft(argHideOption) {
 if (argHideOption == 4) {
  var elementCreateWipe = document.createElement('<IMG id=wipe src="images\\wipe.gif">');
 } else {
  var elementCreateWipe = document.createElement('<IMG id=wipe src="images\\wipe.gif" OnMouseOver="f_MenuLeftShow();">');
 }
 document.body.insertBefore(elementCreateWipe);
 //var elementWipe =  document.all.item("wipe");

 var elementCreateMenuLeft = document.createElement("<DIV id=MenuLeft>");
 document.body.insertBefore(elementCreateMenuLeft);
 var elementMenuLeft =  document.all.item("MenuLeft");

 DivInnerHtml  = '<span class=MenuLeftBackground></span>';
 DivInnerHtml += '<span class=MenuTopLeftBackground></span>';
 DivInnerHtml += '<img  class=MenuTopLeftImage src="images/menuCSDC.gif" border="0" onClick="f_open(\'http://www.csdcsystems.com\');" onMouseOver="f_SubMenuHide();">';
 DivInnerHtml += '<span class=MenuLeftFolderBox onMouseOver="this.style.background=\'#6697C4\';folderIcon.src=\'images/folder_mouseover.gif\';" onMouseOut="this.style.background=\'#F0F8FF\';folderIcon.src=\'images/folder.gif\';" >';
 DivInnerHtml += ' <img class=MenuLeftFolderIcon id=folderIcon src="images/folder.gif" >';
 DivInnerHtml += ' <img class=MenuLeftFolderArrow src="images/ArrowRightLight.gif" >';
 DivInnerHtml += ' <span class=MenuLeftFolderText style="TOP:  7px;" onMouseOver="this.style.color=\'#FFFFFF\';f_SubMenuShow(FolderAddSub);" onMouseOut="this.style.color=\'#000000\';">Add Folder</span>';
 DivInnerHtml += ' <span class=MenuLeftFolderText style="TOP: 24px;" onMouseOver="this.style.color=\'#FFFFFF\';f_SubMenuShow(FolderQuerySub);" onMouseOut="this.style.color=\'#000000\';">Query Folder</span>';
 DivInnerHtml += '</span>';
 //f_BuildMenuLeftPictureText('Property', 'property', "f_submit('Property.jsp');");
 //f_BuildMenuLeftPictureText('People', 'people', "f_submit('People.jsp');");
 f_BuildMenuLeftBox('property', true);
 f_BuildMenuLeftBox('people', true);
 f_BuildMenuLeftBox('todo', true);
 f_BuildMenuLeftBox('admin', true);
 f_BuildMenuLeftBox('inspection', true);
 f_BuildMenuLeftBox('report', true);
 f_BuildMenuLeftBox('myoffice', true);
 //f_BuildMenuLeftText('CallCenter', "f_submit('CallCenter.jsp');", true);
 //f_BuildMenuLeftText('CallCenter', "f_submit('Call_Frames.jsp');", true);
 //f_BuildMenuLeftText('HealthPlus', "f_submit('FolderHealthPlus.jsp');", true);
 f_BuildMenuLeftText('New Browser', "f_new_window('menu.jsp');", true);
 f_BuildMenuLeftText('Close Form', "f_submit('menu.jsp');", true);
 f_BuildMenuLeftText('Hide Menu', "f_MenuFrameHide();", true);
 

 //f_BuildMenuLeftText('Attachment Test', "f_submit('/callcentre/attachment.jsp?folderrsn=1');");
 //f_BuildMenuLeftText('Hide Menus', "f_MenuLeftHide();f_MenuTopHide();");
 //f_BuildMenuLeftText('Show Toolbar', "f_toolbar_all();");
 elementMenuLeft.innerHTML = DivInnerHtml ;
 //alert(DivInnerHtml);

 // GroupTypeCode:
 //  1 - Location License (done)
 //  2 - Lottery License (done)
 //  3 - General Folder (default - done)
 //  4 - Letter of Credit
 //  5 - CallCentre (old way)
 //  6 - People License (done)
 //  7 - Trust Account
 //  8 - Vehicle Licence
 //  9 - Health Plus
 // 10 - Open Tax
 // 11 - Utility
 // 12 - Metered
 // 13 - Time Tracking

 f_BuildSubMenu('FolderAdd', '35');
 f_BuildSubHeader('FOLDER - ADD NEW');
 f_BuildSubText('Permitting', "f_submit('Folder.jsp');", true);
 f_BuildSubText('Location License', "f_submit('Folder.jsp?GroupTypeCode=1');", true);
 f_BuildSubText('People License', "f_submit('Folder.jsp?GroupTypeCode=6');", true);
 f_BuildSubText('Lottery License', "f_submit('Folder.jsp?GroupTypeCode=2');", true);
 //f_BuildSubText('Request for Service', "f_submit('RfsAddStep1.jsp');", true);
 f_BuildSubText('Request for Service', "window.open('','CallCenter','top=1,left=1,height='+(screen.height-80)+',width='+(screen.width-10)+',status=no,toolbar=yes,menubar=no,location=no'); parent.f_submitTarget('CallCenter.jsp','CallCenter');", true);
 f_BuildSubText('Trust Account', "alert('Trust Account');", false);
 f_BuildSubText('Letter of Credit', "alert('Letter of Credit');", false);
 f_BuildSubText('Health+', "alert('Health+');", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;
 //alert(DivInnerHtml);

 f_BuildSubMenu('FolderQuery', '52');
 f_BuildSubHeader('FOLDER - QUERY');
 f_BuildSubText('Permitting', "f_submit('Folder.jsp');", true);
 f_BuildSubText('Location License', "f_submit('Folder.jsp?GroupTypeCode=1');", true);
 f_BuildSubText('People License', "f_submit('Folder.jsp?GroupTypeCode=6');", true);
 f_BuildSubText('Lottery License', "f_submit('Folder.jsp?GroupTypeCode=2');", true);
 f_BuildSubText('Request for Service', "alert('Request for Service');", false);
 f_BuildSubText('Trust Account', "alert('Trust Account');", false);
 f_BuildSubText('Letter of Credit', "alert('Letter of Credit');", false);
 f_BuildSubText('Health+', "alert('Health+');", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubMenuAuto('property');
 f_BuildSubHeader('PROPERTY');
 f_BuildSubText('Add New', "f_submit('Property.jsp');", true);
 f_BuildSubText('Query', "f_submit('Property.jsp');", true);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubMenuAuto('people');
 f_BuildSubHeader('PEOPLE');
 f_BuildSubText('Add New', "f_submit('People.jsp');", true);
 f_BuildSubText('Query', "f_submit('People.jsp');", true);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubMenuAuto('todo');
 f_BuildSubHeader('To Do');
 f_BuildSubText('Show my To Do List', "f_submit('ToDo.jsp');", true);
 f_BuildSubText('Query To Do', "f_submit('ToDoQuery.jsp');", true);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubMenuAuto('admin');
 f_BuildSubHeader('ADMIN');
 f_BuildSubText('Change Password', "alert('Change Password');", false);
 f_BuildSubText('Users', "f_submit('ValidUser.jsp');", true);
 f_BuildSubText('Who\'s On / Logons', "f_submit('CsdcLogonDetail.jsp');", true);
 f_BuildSubText('Clear Cache', "f_submit('CacheClear.jsp');", true);
 f_BuildSubText('Check Cache Status', "f_submit('CsdcDataIoDetail.jsp');", true);
 f_BuildSubText('Setup', "alert('Setup');", false);
 f_BuildSubText('Roles', "f_submit('ValidRoleDetail.jsp?command=retrieve');", true);
 f_BuildSubText('Bulletin', "f_submit('ValidBulletinDetail.jsp?command=retrieve');", true);
 f_BuildSubText('Printers', "f_submit('ValidPrinterDetail.jsp?command=retrieve');", true);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubMenuAuto('inspection');
 f_BuildSubHeader('INSPECTIONS');
 f_BuildSubText('Add Request', "f_submit('FolderInspectionRequest.jsp')", true);
 f_BuildSubText('Enter Result', "f_submit('FolderInspectionResultGenerate.jsp')", true);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubMenuAuto('report');
 f_BuildSubHeader('REPORTS');
 f_BuildSubText('Quick and Simple Report', "f_submit('SeaQueFrame.jsp');", true);
 f_BuildSubTextMenu('General', 'RepGeneral', false);
 f_BuildSubTextMenu('Permitting', 'RepPermitting', false);
 f_BuildSubTextMenu('Location License', 'RepLocation', false);
 f_BuildSubTextMenu('People License', 'RepPeople', false);
 f_BuildSubTextMenu('Lottery License', 'RepLottery', false);
 f_BuildSubTextMenu('Request for Service', 'RepRFS', false);
 f_BuildSubTextMenu('Trust Account', 'RepTrust', false);
 f_BuildSubTextMenu('Letter of Credit', 'RepLetter', false);
 f_BuildSubTextMenu('Inspections', 'RepInspection', false);
 f_BuildSubTextMenu('Revenue', 'RepRevenue', false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;
 //alert(DivInnerHtml);

 f_BuildSubMenuAuto('myoffice');
 f_BuildSubHeader('MY OFFICE');
 f_BuildMyOffice();
 f_BuildSubText('Organize Office', "f_submit('ValidUserMyOfficeDetail.jsp');", true);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 //SubSubStartTop = parseInt(reportSub.style.top.substring(0,3)) + 23;
 SubSubStartTop = 23 + 31 + SubSubOffset;

 f_BuildSubSubMenuAuto('RepGeneral', false);
 f_BuildSubSubText('Folder Master', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Folder Master Detail', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Folder Detail', "f_submit('RptFolderDetail.jsp')", false); 
 f_BuildSubSubText('Listings', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Audit', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Folder Totals by SubType', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Folders by InfoCode', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Section Township Range', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Folder Detail by Application Number', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Folder Statistics by FolderType', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Folder Statistics by Responsibility', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Milestones Overdue', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('12-Week Workload', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Workload', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Mailing Label', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Info Field Report', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Departmental Summary Statistics', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Folder Statistics', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubSubMenuAuto('RepPermitting', false);
 f_BuildSubSubText('Certificate of Occupancy Expiration', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Folder Issuance Summary', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Issuance Listing', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Issuance Summary by Building Type', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Issuance Summary by Work Proposed', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Statistics Canada', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubSubMenuAuto('RepLocation', false);
 f_BuildSubSubText('Animal License', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('New Licence', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('License Contacts', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubSubMenuAuto('RepPeople', false);
 f_BuildSubSubText('New Licence', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('License Contacts', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubSubMenuAuto('RepLottery', false);
 f_BuildSubSubText('Lottery Event Proceeds Exceeded', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Lottery License Event Totals', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Lottery License Reports Due', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Event', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Event Income', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubSubMenuAuto('RepRFS', false);
 f_BuildSubSubText('Source Analysis', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Divisional Analysis', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubSubMenuAuto('RepTrust', false);
 f_BuildSubSubText('Statement', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Revenue', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Payment Detail', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Payment Draw Detail', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubSubMenuAuto('RepLetter', false);
 f_BuildSubSubText('Letters of Credit', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('LC Account', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubSubMenu('RepInspection', 85 + SubSubOffset);
 f_BuildSubSubText('Certificate of Occupancy Inspections', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Inspection Schedule', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Fire Re/Inspection', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Inspector Workload', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Inspector Card', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Inspection Statistics - Activity', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Inspection Request Worksheet', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Dormant Folder', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Inspection Purge', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Inspector Attempts Statistic', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;

 f_BuildSubSubMenu('RepRevenue', 110 + SubSubOffset);
 f_BuildSubSubText('GL Summary', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('GL Transaction Detail', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Billing Request', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Utility Folders', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Daily Revenue (Billed Fees)', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Daily Revenue (Paid Fees)', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Daily Revenue Summary (Paid Fees)', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Daily Revenue User Summary (Paid Fees)', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Payment', "document.location='NotImplemented.htm'", false);
 f_BuildSubSubText('Payment Detail', "document.location='NotImplemented.htm'", false);
 lastDiv.style.height = SubStartTop;
 lastDiv.innerHTML = DivInnerHtml ;
}

function f_BuildMenuStyle() {
 if ( document.all('MenuStyle') ) { document.all.item('MenuStyle').removeNode(true) ; }
 var elementMenuStyle = document.createElement("<style id=MenuStyle>");
 document.body.insertBefore(elementMenuStyle);
 var styleSheetsMenuStyle =  document.styleSheets["MenuStyle"];
 var xWidth = window.screen.width - 151; //Rajesh Changed from 160
 styleSheetsMenuStyle.addRule(".MenuTopArea","           {POSITION: ABSOLUTE; LEFT: 131px; TOP:  0px; WIDTH:" + xWidth + "px; height: 32px; BACKGROUND-COLOR: #768ECA; }");
 styleSheetsMenuStyle.addRule(".MenuTopAMANDAi","        {POSITION: ABSOLUTE; LEFT: 131px; TOP:  0px; WIDTH:175px; height: 32px;}");
 styleSheetsMenuStyle.addRule(".MenuTopText","           {POSITION: ABSOLUTE;              TOP:  8px; color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:  8pt; cursor:hand;}");
 styleSheetsMenuStyle.addRule(".MenuTopBar","            {POSITION: ABSOLUTE;              TOP:  8px; color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight:bold;}");
 styleSheetsMenuStyle.addRule(".MenuToolbar","           {POSITION: ABSOLUTE; LEFT: 131px; TOP: 32px; WIDTH:" + xWidth + "px; height: 32px; BACKGROUND-COLOR: #C6C6C6; }");
 styleSheetsMenuStyle.addRule(".MenuToolbarButton","     {POSITION: RELATIVE;              TOP:  5px; WIDTH: 20px; height: 22px; BACKGROUND-COLOR: #D4D0C8; cursor:hand; BORDER:solid 1px #C6C6C6;}");
 styleSheetsMenuStyle.addRule(".MenuTopLeftBackground"," {POSITION: ABSOLUTE; LEFT:   0px; TOP:  0px; WIDTH:130px; height: 64px; BACKGROUND-COLOR: #768ECA; }");
 styleSheetsMenuStyle.addRule(".MenuTopLeftImage","      {POSITION: ABSOLUTE; LEFT:   5px; TOP: 12px; WIDTH:120px; HEIGHT: 40px; cursor:hand;}");
 styleSheetsMenuStyle.addRule(".MenuLeftBackground","    {POSITION: ABSOLUTE; LEFT:   0px; TOP:   0px; WIDTH:130px; height:100%;  BACKGROUND-COLOR: #F0F8FF; }");
 styleSheetsMenuStyle.addRule(".MenuLeftFolderBox","     {POSITION: ABSOLUTE; LEFT:   0px; TOP:  64px; WIDTH:130px; HEIGHT: 44px; border: solid 1px;}");
 styleSheetsMenuStyle.addRule(".MenuLeftFolderIcon","    {POSITION: RELATIVE; LEFT:   3px; TOP:  10px;}");
 styleSheetsMenuStyle.addRule(".MenuLeftFolderArrow","   {POSITION: RELATIVE; LEFT:   5px; TOP:   5px;}");
 styleSheetsMenuStyle.addRule(".MenuLeftFolderText","    {POSITION: ABSOLUTE; LEFT:  53px;             WIDTH: 65px; color:#000000; font-family: Arial, Helvetica, sans-serif; font-size:  7pt; font-weight:bold; cursor:hand;}");
 styleSheetsMenuStyle.addRule(".MenuLeftBox","           {POSITION: ABSOLUTE; LEFT:   0px;             WIDTH:130px; HEIGHT: 32px; border: solid 1px; BACKGROUND-COLOR: #F0F8FF;}");
 styleSheetsMenuStyle.addRule(".MenuLeftIcon","          {POSITION: RELATIVE; LEFT:   3px; TOP:   4px;}");
 styleSheetsMenuStyle.addRule(".MenuLeftArrow","         {POSITION: RELATIVE; LEFT:   5px; TOP:  -1px;}");
 styleSheetsMenuStyle.addRule(".MenuLeftText","          {POSITION: RELATIVE; LEFT:   5px; TOP:   7px; WIDTH:110px; font-weight: bold; cursor:hand;}");
 styleSheetsMenuStyle.addRule(".MenuLeftPicText","       {POSITION: RELATIVE; LEFT:   5px; TOP:  -3px; WIDTH: 50px; font-weight: bold; cursor:hand;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSub","           {POSITION: ABSOLUTE; LEFT: 100px;             WIDTH:130px; BACKGROUND-COLOR: #F0F8FF; visibility:hidden;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSubSub","        {POSITION: ABSOLUTE; LEFT: 275px;             WIDTH:130px; BACKGROUND-COLOR: #F0F8FF; visibility:hidden;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSubHeaderBox","  {POSITION: ABSOLUTE; LEFT:   0px;             WIDTH:180px; HEIGHT: 32px; border: solid 1px; BACKGROUND-COLOR: #768ECA;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSubHeaderText"," {POSITION: RELATIVE; LEFT:   5px; TOP:   7px; WIDTH:170px; TEXT-ALIGN: center; color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight:bold;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSubBox","        {POSITION: ABSOLUTE; LEFT:   0px;             WIDTH:180px; HEIGHT: 24px; border: solid 1px; BACKGROUND-COLOR: #F0F8FF; cursor:hand;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSubText","       {POSITION: RELATIVE; LEFT:  10px; TOP:   2px; WIDTH:170px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:  10pt;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSubMenuText","   {POSITION: RELATIVE; LEFT:  10px; TOP:   1px; WIDTH:140px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:  10pt;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSubMenuArrow","  {POSITION: RELATIVE; LEFT:  10px; TOP:   0px;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSubSubBox","     {POSITION: ABSOLUTE; LEFT:   0px;             WIDTH:230px; HEIGHT: 18px; border: solid 1px; BACKGROUND-COLOR: #F0F8FF; cursor:hand;}");
 styleSheetsMenuStyle.addRule(".MenuLeftSubSubText","    {POSITION: RELATIVE; LEFT:  10px; TOP:   0px; WIDTH:220px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:  10pt;}");
 styleSheetsMenuStyle.addRule(".MenuHelpBox","           {POSITION: ABSOLUTE;                          WIDTH:230px; HEIGHT: 24px; border: solid 1px; BACKGROUND-COLOR: #F0F8FF;}");
 styleSheetsMenuStyle.addRule(".MenuHelpText","          {POSITION: RELATIVE; LEFT:   5px; TOP:   4px; WIDTH:220px; font-weight: bold; cursor:hand;}");
 styleSheetsMenuStyle.addRule("#wipe","                  {POSITION: absolute; LEFT: 0px; TOP: 0px; WIDTH: 8px; HEIGHT: 100%;  VISIBILITY: hidden; border:none; CURSOR: default; Z-INDEX:-2; MARGIN: 0px;}");
 styleSheetsMenuStyle.addRule("#workspace","             {POSITION: absolute; LEFT: 131px; TOP: 64px; BACKGROUND-COLOR:#F0F8FF;}");
}

function f_BuildMenuTopText(argRight, argText, argClick, argIdKey) {
 var xPos = window.screen.width - argRight;
 DivInnerHtml += '<span class=MenuTopText Id="MenuTopTextId' + argIdKey + '" style="LEFT: ' + xPos + 'px;" onMouseOver="this.style.color=\'#000000\';f_SubMenuHide();" onMouseOut="this.style.color=\'#FFFFFF\';" onClick="' + argClick + '">' + argText + '</span>';
}

function f_BuildMenuTopHelp(argRight, argText, argMouseOver, argIdKey) {
 var xPos = window.screen.width - argRight;
 DivInnerHtml += '<span class=MenuTopText Id="MenuTopTextId' + argIdKey + '" style="LEFT: ' + xPos + 'px;" onMouseOver="this.style.color=\'#000000\';' + argMouseOver + '" onMouseOut="this.style.color=\'#FFFFFF\';" >' + argText + '</span>';
}

function f_BuildMenuTopBar(argRight, argIdKey) {
 var xPos = window.screen.width - argRight;
 DivInnerHtml += '<span class=MenuTopBar Id="MenuTopTextId' + argIdKey + '" style="LEFT: ' + xPos + 'px;">|</span>';
}

function f_BuildMenuLeftBox(argImg, argDefined) {
 if (argDefined || ini_UndefinedMenuButtonVisible) {
  DivInnerHtml += '<span class=MenuLeftBox style="TOP: ' + MenuBoxStartTop + 'px;" onMouseOver="this.style.background=\'#6697C4\';' + argImg + 'Icon.src=\'images/' + argImg + '_mouseover.gif\';f_SubMenuShow(' + argImg + 'Sub);" onMouseOut="this.style.background=\'#F0F8FF\';' + argImg + 'Icon.src=\'images/' + argImg + '.gif\';" >';
  DivInnerHtml += ' <img class=MenuLeftIcon id=' + argImg + 'Icon src="images/' + argImg + '.gif" >';
  DivInnerHtml += ' <img class=MenuLeftArrow src="images/ArrowRightLight.gif" >';
  DivInnerHtml += '</span>';
  MenuBoxStartTop = MenuBoxStartTop + 31;
 }
}

function f_BuildMenuLeftPictureText(argText, argImg, argClick) {
 DivInnerHtml += '<span class=MenuLeftBox style="TOP: ' + MenuBoxStartTop + 'px;" onMouseOver="this.style.background=\'#6697C4\';' + argImg + 'Icon.src=\'images/' + argImg + '_mouseover.gif\';f_SubMenuHide();" onMouseOut="this.style.background=\'#F0F8FF\';' + argImg + 'Icon.src=\'images/' + argImg + '.gif\';" onClick="' + argClick + '">';
 DivInnerHtml += ' <img class=MenuLeftIcon id=' + argImg + 'Icon src="images/' + argImg + '.gif" alt="' + argText + '">';
 DivInnerHtml += ' <span class=MenuLeftPicText>' + argText + '</span>';
 DivInnerHtml += '</span>';
 MenuBoxStartTop = MenuBoxStartTop + 31;
}

function f_BuildMenuLeftText(argText, argClick, argDefined) {
 if (argDefined || ini_UndefinedMenuButtonVisible) {
  DivInnerHtml += '<span class=MenuLeftBox style="TOP: ' + MenuBoxStartTop + 'px;" onMouseOver="this.style.background=\'#6697C4\'; f_SubMenuHide();" onMouseOut="this.style.background=\'#F0F8FF\';" onClick="' + argClick + '">';
  DivInnerHtml += ' <span class=MenuLeftText>' + argText + '</span>';
  DivInnerHtml += '</span>';
  MenuBoxStartTop = MenuBoxStartTop + 31;
 }
}

function f_BuildSubMenu(argID, argTop) {
 var elementCreateDiv = document.createElement('<DIV id=' + argID + 'Sub class=MenuLeftSub style="TOP:' + argTop + 'px;">');
 document.body.insertBefore(elementCreateDiv);
 lastDiv =  document.all.item(argID +'Sub');
 DivList.push(lastDiv);
 DivInnerHtml = "";
 SubStartTop = 31;
}

function f_BuildSubMenuAuto(argID) {
 var elementCreateDiv = document.createElement('<DIV id=' + argID + 'Sub class=MenuLeftSub style="TOP:' + SubBoxStartTop + 'px;">');
 document.body.insertBefore(elementCreateDiv);
 lastDiv =  document.all.item(argID +'Sub');
 DivList.push(lastDiv);
 DivInnerHtml = "";
 SubStartTop = 31;
 SubBoxStartTop = SubBoxStartTop + 31;
}

function f_BuildSubSubMenu(argID, argTop, argDefined) {
 if (argDefined || ini_UndefinedMenuButtonVisible) {
  var elementCreateDiv = document.createElement('<DIV id=' + argID + 'SubSub class=MenuLeftSubSub style="TOP:' + argTop + 'px;">');
  document.body.insertBefore(elementCreateDiv);
  lastDiv =  document.all.item(argID + 'SubSub');
  SubDivList.push(lastDiv);
  DivInnerHtml = "";
  SubStartTop = 0;
  SubBoxStartTop = SubBoxStartTop + 31;
  SubSubStartTop = SubSubStartTop + 23;
 }
}

function f_BuildSubSubMenuAuto(argID, argDefined) {
 if (argDefined || ini_UndefinedMenuButtonVisible) {
  var elementCreateDiv = document.createElement('<DIV id=' + argID + 'SubSub class=MenuLeftSubSub style="TOP:' + SubSubStartTop + 'px;">');
  document.body.insertBefore(elementCreateDiv);
  lastDiv =  document.all.item(argID + 'SubSub');
  SubDivList.push(lastDiv);
  DivInnerHtml = "";
  SubStartTop = 0;
  SubBoxStartTop = SubBoxStartTop + 31;
  SubSubStartTop = SubSubStartTop + 23;
 }
}

function f_BuildSubHeader(argText) {
 DivInnerHtml += '<span class=MenuLeftSubHeaderBox style="TOP: 0px;">';
 DivInnerHtml += ' <span class=MenuLeftSubHeaderText>' + argText + '</span>';
 DivInnerHtml += '</span>';
}

function f_BuildSubText(argText, argClick, argDefined) {
 if (argDefined || ini_UndefinedMenuButtonVisible) {
  DivInnerHtml += '<span class=MenuLeftSubBox style="TOP: ' + SubStartTop + 'px;" onMouseOver="this.style.background=\'#6697C4\';parent.f_SubSubMenuHide();" onMouseOut="this.style.background=\'#F0F8FF\';" onClick="parent.' + argClick + '">';
  DivInnerHtml += ' <span class=MenuLeftSubText>' + argText + '</span>';
  DivInnerHtml += '</span>';
  SubStartTop = SubStartTop + 23;
 }
}

function f_BuildSubSubText(argText, argClick, argDefined) {
 if (argDefined || ini_UndefinedMenuButtonVisible) {
  DivInnerHtml += '<span class=MenuLeftSubSubBox style="TOP: ' + SubStartTop + 'px;" onMouseOver="this.style.background=\'#6697C4\';" onMouseOut="this.style.background=\'#F0F8FF\';" onClick="parent.parent.parent.' + argClick + '">';
  DivInnerHtml += ' <span class=MenuLeftSubSubText>' + argText + '</span>';
  DivInnerHtml += '</span>';
  SubStartTop = SubStartTop + 17;
 }
}

function f_BuildSubTextMenu(argText, argMenu, argDefined) {
 if (argDefined || ini_UndefinedMenuButtonVisible) {
  DivInnerHtml += '<span class=MenuLeftSubBox style="TOP: ' + SubStartTop + 'px;" onMouseOver="this.style.background=\'#6697C4\';parent.f_SubSubMenuShow(parent.document.all.' + argMenu + 'SubSub);" onMouseOut="this.style.background=\'#F0F8FF\';" >';
  //DivInnerHtml += '<span class=MenuLeftSubBox style="TOP: ' + SubStartTop + 'px;" onMouseOver="this.style.background=\'#6697C4\';parent.mytest(\'hello\');" onMouseOut="this.style.background=\'#F0F8FF\';" >';

  DivInnerHtml += ' <span class=MenuLeftSubMenuText>' + argText + '</span>';
  DivInnerHtml += ' <img class=MenuLeftSubMenuArrow src="images/ArrowRightLight.gif" >';
  DivInnerHtml += '</span>';
  SubStartTop = SubStartTop + 23;
 }
}

function f_BuildMyOffice() {
 if (!theform.MyOffice) { return; }
 var myOffice = theform.MyOffice.value;
 if (myOffice.length < 1) { return; }
 
 var theLinks = myOffice.split(';');
 for (var i = 0; i < theLinks.length; i++) {
  //alert(i + ' links: ' + theLinks[i]);
  var theFields = theLinks[i].split('|');
  var theType = theFields[0];
  var theURL  = theFields[1];
  var theDesc = theFields[2];
  //alert(i + ': ' + theType + ' , ' + theURL + ' , ' + theDesc);
  if (theType == 'Folder') {
   f_BuildSubText(theDesc, "f_submit('Folder.jsp?FolderRSN=" + theURL + "');", true);
  }
  if (theType == 'People') {
   f_BuildSubText(theDesc, "f_submit('People.jsp?PeopleRSN=" + theURL + "');", true);
  }
  if (theType == 'Property') {
   f_BuildSubText(theDesc, "f_submit('Property.jsp?PropertyRSN=" + theURL + "');", true);
  }
  if (theType == 'URL') {
   //if (theURL.indexOf("?") < 0) {
   // theURL = theURL + "?";
   //} else {
   // theURL = theURL + "&";
   //}
   //f_BuildSubText(theDesc, "f_open('" + theURL + "lid=" + theform.lid.value + "');");
   f_BuildSubText(theDesc, "f_open_window('" + theURL + "','');", true);
  }
  if (theType == 'UrlNoLid') {
   f_BuildSubText(theDesc, "f_open_window_no_LID('" + theURL + "','');", true);
  }
 }
}


function f_SubMenuShow(argDiv) {
 f_SubMenuHide();
 oPopup.document.body.innerHTML =  argDiv.innerHTML;
 if ( !oPopup.document.all('MenuStyle') ) { //add style the first time
   var elementMenuStyle = oPopup.document.createElement("<style id=MenuStyle>");
   oPopup.document.body.insertBefore(elementMenuStyle);
   var styleSheetsMenuStyle =  oPopup.document.styleSheets["MenuStyle"];
   styleSheetsMenuStyle.addRule(".MenuLeftSubHeaderBox","  {POSITION: ABSOLUTE; LEFT:   0px;             WIDTH:180px; HEIGHT: 32px; border: solid 1px; BACKGROUND-COLOR: #768ECA;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubHeaderText"," {POSITION: RELATIVE; LEFT:   5px; TOP:   7px; WIDTH:170px; TEXT-ALIGN: center; color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight:bold;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubBox","        {POSITION: ABSOLUTE; LEFT:   0px;             WIDTH:180px; HEIGHT: 24px; border: solid 1px; BACKGROUND-COLOR: #F0F8FF; cursor:hand;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubText","       {POSITION: RELATIVE; LEFT:  10px; TOP:   2px; WIDTH:170px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:  10pt;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubMenuText","   {POSITION: RELATIVE; LEFT:  10px; TOP:   1px; WIDTH:140px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:  10pt;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubMenuArrow","  {POSITION: RELATIVE; LEFT:  10px; TOP:   0px;}");
   styleSheetsMenuStyle.addRule(".MenuHelpBox","           {POSITION: ABSOLUTE;                          WIDTH:230px; HEIGHT: 24px; border: solid 1px; BACKGROUND-COLOR: #F0F8FF;}");
   styleSheetsMenuStyle.addRule(".MenuHelpText","          {POSITION: RELATIVE; LEFT:   5px; TOP:   4px; WIDTH:220px; FONT-FAMILY: Verdana; FONT-SIZE: 12px; font-weight: bold; cursor:hand;}");
 }
 var dtop = argDiv.style.top;
 dtop = dtop.substring(0,dtop.length - 2); //remove the trailing 'px'
 var dheight = argDiv.style.height;
 dheight = parseInt(dheight.substring(0,dheight.length - 2)) + 2;
 oPopup.show(100, dtop, 180, dheight, MenuLeft);
 }

function f_SubSubMenuShow(argDiv) {
 f_SubSubMenuHide();
 ooPopup.document.body.innerHTML =  argDiv.innerHTML
 if ( !ooPopup.document.all('MenuStyle') ) {
   var elementMenuStyle = ooPopup.document.createElement("<style id=MenuStyle>");
   ooPopup.document.body.insertBefore(elementMenuStyle);
   var styleSheetsMenuStyle =  ooPopup.document.styleSheets["MenuStyle"];
   styleSheetsMenuStyle.addRule(".MenuLeftSubSubBox","     {POSITION: ABSOLUTE; LEFT:   0px;             WIDTH:230px; HEIGHT: 18px; border: solid 1px; BACKGROUND-COLOR: #F0F8FF; cursor:hand;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubSubText","    {POSITION: RELATIVE; LEFT:  10px; TOP:   0px; WIDTH:220px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:  10pt;}");
 }
 var dtop = argDiv.style.top;
 dtop = dtop.substring(0,dtop.length - 2); //remove the trailing 'px' in '130px'
 var dheight = argDiv.style.height;
 dheight = parseInt(dheight.substring(0,dheight.length - 2)) + 2;
 //alert(dtop + ' ' + dheight);
 //return;
 ooPopup.show(170, dtop, 230, dheight, MenuLeft);
}


function f_SubMenuHide() {
 oPopup.hide();
 //for (var i = 0; i < DivList.length; i++) {
 // var elementdiv = DivList[i];
 // elementdiv.style.visibility='hidden';
 //}
 f_SubSubMenuHide();
}

function f_SubSubMenuHide() {
 ooPopup.hide();
 //for (var i = 0; i < SubDivList.length; i++) {
 // var elementdiv = SubDivList[i];
 // elementdiv.style.visibility='hidden';
 //}
}

function mtrack(e) {
 var text = 'Coordinates: ';
 if (document.layers) text += e.pageX + ',' + e.pageY
 else text += event.x + ',' + event.y;
 window.defaultStatus = text;
}

function f_MenuLeftHide() {
 f_SubMenuHide();
 var xWidth = window.screen.width - 20; //Rajesh changed from 29
 MenuTopAreaId.style.left="0px";
 MenuTopAreaId.style.width= xWidth + "px";
 MenuTopAMANDAiId.style.left="0px";
 MenuToolbarId.style.left="0px";
 MenuToolbarId.style.width= xWidth + "px";
 xWidth = xWidth - 12;
 workspace.style.width=xWidth + "px";
 workspace.style.left="8px";
 wipe.style.visibility='visible';
 MenuLeft.style.visibility='hidden';
}

function f_MenuLeftHide2() {
 f_SubMenuHide();
 var xWidth = window.screen.width - 20; //Rajesh changed from 29
 MenuTopAreaId.style.left="0px";
 MenuTopAreaId.style.width= xWidth + "px";
 MenuTopAMANDAiId.style.left="0px";
 MenuToolbarId.style.left="0px";
 MenuToolbarId.style.width= xWidth + "px";
 xWidth = xWidth - 12;
 workspace.style.width=xWidth + "px";
 workspace.style.left="8px";
}

function f_MenuLeftShow() {
 var xWidth = window.screen.width - 151; //Rajesh changed from 160
 MenuLeft.style.visibility='visible';
 MenuTopAreaId.style.left="131px";
 MenuTopAreaId.style.width= xWidth + "px";
 MenuTopAMANDAiId.style.left="131px";
 MenuToolbarId.style.left="131px";
 MenuToolbarId.style.width=xWidth + "px";
 workspace.style.left="131px"; 
 wipe.style.visibility='hidden';
}

function f_MenuHelpShow() {
 f_SubMenuHide();
 oPopup.document.body.innerHTML =  MenuHelpSub.innerHTML
 if ( !oPopup.document.all('MenuStyle') ) { //add style the first time
   var elementMenuStyle = oPopup.document.createElement("<style id=MenuStyle>");
   oPopup.document.body.insertBefore(elementMenuStyle);
   var styleSheetsMenuStyle =  oPopup.document.styleSheets["MenuStyle"];
   styleSheetsMenuStyle.addRule(".MenuLeftSubHeaderBox","  {POSITION: ABSOLUTE; LEFT:   0px;             WIDTH:180px; HEIGHT: 32px; border: solid 1px; BACKGROUND-COLOR: #768ECA;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubHeaderText"," {POSITION: RELATIVE; LEFT:   5px; TOP:   7px; WIDTH:170px; TEXT-ALIGN: center; color: #FFFFFF; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 11px; font-weight:bold;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubBox","        {POSITION: ABSOLUTE; LEFT:   0px;             WIDTH:180px; HEIGHT: 24px; border: solid 1px; BACKGROUND-COLOR: #F0F8FF; cursor:hand;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubText","       {POSITION: RELATIVE; LEFT:  10px; TOP:   2px; WIDTH:170px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:  10pt;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubMenuText","   {POSITION: RELATIVE; LEFT:  10px; TOP:   1px; WIDTH:140px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size:  10pt;}");
   styleSheetsMenuStyle.addRule(".MenuLeftSubMenuArrow","  {POSITION: RELATIVE; LEFT:  10px; TOP:   0px;}");
   styleSheetsMenuStyle.addRule(".MenuHelpBox","           {POSITION: ABSOLUTE;                          WIDTH:230px; HEIGHT: 24px; border: solid 1px; BACKGROUND-COLOR: #F0F8FF;}");
   styleSheetsMenuStyle.addRule(".MenuHelpText","          {POSITION: RELATIVE; LEFT:   5px; TOP:   4px; WIDTH:220px; FONT-FAMILY: Verdana; FONT-SIZE: 12px; font-weight: bold; cursor:hand;}");
 }
 var xLeft = window.screen.width - 260;
 var dheight = MenuHelpSub.style.height;
 dheight = parseInt(dheight.substring(0,dheight.length - 2)) + 2;
 oPopup.show(xLeft, 30, 230, dheight, MenuLeft);
}

function f_MenuFrameShow() {
 //alert ('f_MenuFrameShow');
 //alert (parent.parent.parent.parent.WindowFrameSet.cols);
 parent.parent.parent.parent.WindowFrameSet.cols = "130,*";
 //Rajesh Addedd
 var xWidth = window.screen.width - 410; //Rajesh changed from 160
parent.parent.TitleFrame.MenuTopTextId1.style.left= xWidth + "px";
parent.parent.TitleFrame.MenuTopTextId2.style.left= (xWidth + 81) + "px";
parent.parent.TitleFrame.MenuTopTextId3.style.left= (xWidth + 81 + 55)+ "px";
parent.parent.TitleFrame.MenuTopTextId4.style.left= (xWidth + 60)+ "px";
parent.parent.TitleFrame.MenuTopTextId5.style.left= (xWidth + 121)+ "px";
parent.parent.TitleFrame.MenuTopAreaId.style.left="0px";
parent.parent.TitleFrame.MenuTopAreaId.style.width= xWidth + 280 + "px";
wipe.style.visibility='visible';
  //Rajesh Addedd
 
}

function f_MenuFrameHide() {
 //alert ('f_MenuFrameHide');
 //Rajesh Added
 if(parent.parent.parent.parent.WindowFrameSet){
  	parent.parent.parent.parent.WindowFrameSet.cols = "0,*";
 	parent.parent.parent.parent.MenuFrame.f_SubMenuHide();
 	parent.parent.TitleFrame.f_SubMenuHide();
 	var xWidth = window.screen.width - 280; 
	parent.parent.TitleFrame.MenuTopTextId1.style.left= xWidth + "px";
	parent.parent.TitleFrame.MenuTopTextId2.style.left= (xWidth + 81) + "px";
	parent.parent.TitleFrame.MenuTopTextId3.style.left= (xWidth + 81 + 55)+ "px";
	parent.parent.TitleFrame.MenuTopTextId4.style.left= (xWidth + 60)+ "px";
	parent.parent.TitleFrame.MenuTopTextId5.style.left= (xWidth + 121)+ "px";
	parent.parent.TitleFrame.MenuTopAreaId.style.left="0px";
	parent.parent.TitleFrame.MenuTopAreaId.style.width= xWidth + 280 + "px";
 }else{
 	f_MenuLeftHide();
 }
 //Rajesh Added
 
 	//Rajesh Set off
  	//parent.parent.parent.parent.WindowFrameSet.cols = "0,*";
 	//parent.parent.parent.parent.MenuFrame.f_SubMenuHide();
 	//parent.parent.TitleFrame.f_SubMenuHide();
 	//Rajesh Set off
 	
 	
 //alert('done');
}

function f_ShowQuery(argQueryUrl, argLid) {
 //alert('f_ShowQuery');
 f_MenuFrameHide();
 //var TabMask = "YYYNYYYYYYYNNYNNNNN";
 var urlSuffix = "";
 if (document.all.TabMask) {
  var urlSuffix = urlSuffix + '&TabMask=' + document.all.TabMask.value;
 }
 //alert('f_ShowQuery TabMask:' + TabMask);
 
 var where = "";
 if (document.all.where) {
  var where = document.all.where.value;
 }
 if (document.all.FolderRSN) {
  if (where > ' ') { where = where + ' and '; }
  where = where + 'FolderRSN=' + document.all.FolderRSN.value;
  urlSuffix = urlSuffix + "&FolderRSN=" + document.all.FolderRSN.value;
 } else if (document.all.argFolderRSN) {
  urlSuffix = urlSuffix + '&argFolderRSN=' + document.all.argFolderRSN.value;
 //} else if (document.all.PeopleRSN) {
 // if (where > ' ') { where = where + ' and '; }
 // where = where + 'PeopleRSN=' + document.all.PeopleRSN.value;
 } else if (document.all.argPeopleRSN) {
  urlSuffix = urlSuffix + '&argPeopleRSN=' + document.all.argPeopleRSN.value;
 //} else if (document.all.PropertyRSN) {
 // if (where > ' ') { where = where + ' and '; }
 // where = where + 'PropertyRSN=' + document.all.PropertyRSN.value;
 } else if (document.all.argPropertyRSN) {
  urlSuffix = urlSuffix + '&argPropertyRSN=' + document.all.argPropertyRSN.value;
 }
 //alert('f_ShowQuery where:' + where);
  
 if (argQueryUrl == 'FolderDocumentDetail' || argQueryUrl == 'FolderCommentDetail' || argQueryUrl == 'AttachmentDetail') {
    var pp;
    if (parent.parent.DetailFrameSet) {
     pp = parent.parent;
    } else {
     pp = parent;
    }
    pp.DetailFrameSet.cols = "*, 780";
    detailUrl = argQueryUrl + '.jsp?command=query&lid=' + argLid + '&where=' + escape(where) + urlSuffix;
    pp.DetailDetailFrame.document.location = detailUrl;
  } 
  else if(argQueryUrl == 'CallCenterDetail'){
    parent.parent.ListDetailQueryFrameSet.cols = "*, 0, 780";
    var theUrl = argQueryUrl + '.jsp?command=retrieve&lid=' + argLid;
    //alert('theUrl='+theUrl);
    parent.parent.QueryFrame.document.location = theUrl;
  }
  else if(argQueryUrl == 'FolderHealthPlusDetail'){
    parent.parent.ListDetailQueryFrameSet.cols = "*, 0, 780";
    var currentUrl = parent.parent.QueryFrame.document.location + ".";
    if (currentUrl.indexOf('Blue') > 0) {
     var theUrl = argQueryUrl + '.jsp?command=query&lid=' + argLid + urlSuffix;
     parent.parent.QueryFrame.document.location = theUrl;
    }
    //alert('f_ShowQuery theUrl:' + theUrl);
  }
  else {
    parent.parent.ListDetailQueryFrameSet.cols = "*, 0, 780";
    var currentUrl = parent.parent.QueryFrame.document.location + ".";
    if (currentUrl.indexOf('Blue') > 0) {
     var theUrl = argQueryUrl + '.jsp?command=query&lid=' + argLid + urlSuffix;
     parent.parent.QueryFrame.document.location = theUrl;
    }
    parent.parent.ListFrame.f_Init();
  }
}

//Same as ShowQuery above, except it ALWAYS does a refresh
function f_ShowInsert(argQueryUrl, argLid) {
 //alert('f_ShowQuery');
 f_MenuFrameHide();
 //var TabMask = "YYYNYYYYYYYNNYNNNNN";
 var urlSuffix = "";
 if (document.all.TabMask) {
  var urlSuffix = urlSuffix + '&TabMask=' + document.all.TabMask.value;
 }
 //alert('f_ShowQuery TabMask:' + TabMask);
 
 var where = "";
 if (document.all.where) {
  var where = document.all.where.value;
 }
 if (document.all.FolderRSN) {
  if (where > ' ') { where = where + ' and '; }
  where = where + 'FolderRSN=' + document.all.FolderRSN.value;
  urlSuffix = urlSuffix + "&FolderRSN=" + document.all.FolderRSN.value;
 } else if (document.all.argFolderRSN) {
  urlSuffix = urlSuffix + '&argFolderRSN=' + document.all.argFolderRSN.value;
 //} else if (document.all.PeopleRSN) {
 // if (where > ' ') { where = where + ' and '; }
 // where = where + 'PeopleRSN=' + document.all.PeopleRSN.value;
 } else if (document.all.argPeopleRSN) {
  urlSuffix = urlSuffix + '&argPeopleRSN=' + document.all.argPeopleRSN.value;
 //} else if (document.all.PropertyRSN) {
 // if (where > ' ') { where = where + ' and '; }
 // where = where + 'PropertyRSN=' + document.all.PropertyRSN.value;
 } else if (document.all.argPropertyRSN) {
  urlSuffix = urlSuffix + '&argPropertyRSN=' + document.all.argPropertyRSN.value;
 }
 //alert('f_ShowQuery where:' + where);
  
 if (argQueryUrl == 'FolderDocumentDetail' || argQueryUrl == 'FolderCommentDetail' || argQueryUrl == 'AttachmentDetail') {
    var pp;
    if (parent.parent.DetailFrameSet) {
     pp = parent.parent;
    } else {
     pp = parent;
    }
    pp.DetailFrameSet.cols = "*, 780";
    detailUrl = argQueryUrl + '.jsp?command=query&lid=' + argLid + '&where=' + escape(where) + urlSuffix;
    pp.DetailDetailFrame.document.location = detailUrl;
  }
  else if(argQueryUrl == 'CallCenterDetail'){
    parent.parent.ListDetailQueryFrameSet.cols = "*, 0, 780";
    var theUrl = argQueryUrl + '.jsp?command=query&lid=' + argLid;
    //alert('theUrl='+theUrl);
    parent.parent.QueryFrame.document.location = theUrl;
  } else {
    parent.parent.ListDetailQueryFrameSet.cols = "*, 0, 780";
    var currentUrl = parent.parent.QueryFrame.document.location + ".";
    //if (currentUrl.indexOf('Blue') > 0) {
     var theUrl = argQueryUrl + '.jsp?command=query&lid=' + argLid + urlSuffix;
     parent.parent.QueryFrame.document.location = theUrl;
    //}
    parent.parent.ListFrame.f_Init();
  }
}

function f_ShowList(argUrl, argLid, argWhere) {
 //alert('f_ShowList7: ' + argWhere);
 if ( f_left(argWhere,10) == "FolderRSN=" || (f_left(argWhere,12) == "PropertyRSN=" && theform.action != "FolderDetail.jsp") || f_left(argWhere,10) == "PeopleRSN=" ) {
  f_ShowDetail(argUrl, argLid, argWhere);
  return;
 }
 f_MenuFrameHide();
 parent.parent.ListDetailQueryFrameSet.cols = "*, 0, 0";
 parent.parent.DetailFrame.document.location = "Blue.htm";
 theUrl = argUrl + 'List.jsp?command=retrieve&lid=' + argLid + '&where=' + escape(argWhere);
 //alert(theUrl);
 if (document.all.pick) {
  theUrl = theUrl + '&pick=' + document.all.pick.value;
 }
 parent.parent.ListFrame.document.location = theUrl;
}

function f_ViewList() {
 //alert('f_ViewList');
 f_MenuFrameHide();
 parent.parent.ListDetailQueryFrameSet.cols = "*, 0, 0";
 parent.parent.ListFrame.f_Init(); 
}

function f_ViewListChild() {
 //alert('f_ViewListChild');
 f_MenuFrameHide();
 var pp; 
 if (parent.parent.DetailFrameSet) {
  pp = parent.parent;
 } else {
  pp = parent;
 }
 pp.DetailFrameSet.cols = "*, 0"; 
}

function f_ShowDetail(argUrl, argLid, argWhere) {
 //alert('f_ShowDetail: ' + argUrl + ', ' + argWhere);
 //var TabMask = "YYYNYYYYYYYNNYNNNNN";
 var urlSuffix="";
 if (document.all.TabMask) {
  var urlSuffix = urlSuffix + "&TabMask=" + document.all.TabMask.value;
 }
 if (document.all.AddMask) {
  var urlSuffix = urlSuffix + "&AddMask=" + document.all.AddMask.value;
 }
 
 if (document.all.FolderRSN && document.all.FolderRSN.value > ' ') {
  urlSuffix = urlSuffix + "&FolderRSN=" + document.all.FolderRSN.value;
 } else if (document.all.argFolderRSN) {
  urlSuffix = urlSuffix + '&argFolderRSN=' + document.all.argFolderRSN.value;
 } else if (document.all.argPeopleRSN) {
  urlSuffix = urlSuffix + '&argPeopleRSN=' + document.all.argPeopleRSN.value;
 } else if (document.all.argPropertyRSN) {
  urlSuffix = urlSuffix + '&argPropertyRSN=' + document.all.argPropertyRSN.value;
 }
 
 if (argUrl == 'FolderProcess') {
  var pp;
  if (parent.parent.DetailFrameSet) {
   //this parent.parent is probably a bug somewhere, 
   pp = parent.parent;
   //alert('parentparent: ' + pp.document.body.innerHTML);
  } else {
   //this is where it normally is.
   pp = parent;
   //alert('parent: ' + pp.document.body.innerHTML);
  }
  pp.DetailFrameSet.cols = "*, 780";
  processUrl = 'FolderProcessDetail.jsp?command=retrieve&lid=' + argLid + '&where=' + escape(argWhere) + urlSuffix;
  attemptUrl = 'FolderProcessAttemptDetail.jsp?command=retrieve&lid=' + argLid + '&where=' + escape(argWhere);
  pp.DetailDetailFrame.document.location = processUrl;
  pp.DetailTabFrame.document.location = attemptUrl;
 }
 else if (argUrl == 'FolderProcessDeficiency' || argUrl == 'FolderProcessAttachment') {
  var pp;
  if (parent.parent.DetailFrameSet) {
   //this parent.parent is probably a bug somewhere, 
   pp = parent.parent;
   //alert('parentparent: ' + pp.document.body.innerHTML);
  } else {
   //this is where it normally is.
   pp = parent;
   //alert('parent: ' + pp.document.body.innerHTML);
  }
  pp.DetailFrameSet.cols = "*, 780";
  theUrl = argUrl + 'Detail.jsp?command=retrieve&lid=' + argLid + '&where=' + escape(argWhere) + urlSuffix;
  pp.DetailTabFrame.document.location = theUrl;
 } else {
  if (argUrl == 'FolderDocument' || argUrl == 'FolderComment' || argUrl == 'Attachment') {
   var pp;
   if (parent.parent.DetailFrameSet) {
    pp = parent.parent;
   } else {
    pp = parent;
   }
   pp.DetailFrameSet.cols = "*, 780";
   detailUrl = argUrl + 'Detail.jsp?command=retrieve&lid=' + argLid + '&where=' + escape(argWhere) + urlSuffix;
   if (theform.FolderRSN) {
    detailUrl = detailUrl + "&FolderRSN=" + theform.FolderRSN.value;
   }
   pp.DetailDetailFrame.document.location = detailUrl;
  } else {
   f_MenuFrameHide();
   
   if (argUrl == 'FolderProcessDeficiencyAdd') {
    parent.parent.ListDetailQueryFrameSet.cols = "*, 600, 0";
    if (parent.parent.ListFrame.theform) {
      //parent.parent.ListFrame.f_Init();
    }
    theUrl = argUrl + 'Detail.jsp?command=query&lid=' + argLid  + '&where=' + escape(argWhere) + urlSuffix; 
    //alert(theUrl);
   }
   else{
    parent.parent.ListDetailQueryFrameSet.cols = "*, 780, 0";
    if (parent.parent.ListFrame.theform) {
      parent.parent.ListFrame.f_Init();
    }
    theUrl = argUrl + 'Detail.jsp?command=retrieve&lid=' + argLid + '&where=' + escape(argWhere) + urlSuffix;
   }

   //alert(theUrl);
   if (document.all.pick) {
    theUrl = theUrl + '&pick=' + document.all.pick.value;
   }
   parent.parent.DetailFrame.document.location = theUrl;
  }
 }
}

function f_ShowRelated(argColumn, argUrl) {
 //alert('f_ShowRelated');
 var theDw = dw[0];
 var colPtr = -1;
 var selectedCount = 0;
 var where = "";
 for (i=1;i<=theDw.columnCount;i++) {
  if (theDw.column[i].columnName == argColumn) {
   colPtr = i;
   i = 9999;
  }
 }
 if (colPtr < 1) {
  alert('columnname: ' + argColumn + ' does not exist.');
  return;
 }
 for (i=1;i<=theDw.rowCount;i++) {
  theRow = theDw.row[i];
  if (theRow.selected) {
   selectedCount++;
   if (where > "") { where = where + ","; }
   where = where + theRow.data[colPtr].newValue;
  }
 }
 if (selectedCount == 0) {
  alert('Before you press this button you must click on a row to select it/them.');
  return
 }
 if (selectedCount == 1) {
  where = argColumn + "=" + where;
 } else {
  where = argColumn + " in (" + where + ")";
 }
 
 //we keep the old action, so that inserts/updates/tabs can still be done.
 var oldAction = theform.action;
 var oldWhere = theform.where.value;
 var oldTarget = theform.target;
 theform.action = argUrl
 theform.where.value = where;
 theform.target = '_blank';
 theform.submit();
 theform.action = oldAction;
 theform.where.value = oldWhere;
 theform.target = oldTarget;
}

function f_MenuTopHide() {
 f_SubMenuHide();
 MenuTopAreaId.style.visibility='hidden';
 MenuToolbarId.style.top="0px";
 workspace.style.top="32px";
}

function f_MenuTopHide2() {
 f_SubMenuHide();
 MenuTopAreaId.style.visibility='hidden';
 MenuToolbarId.style.top="0px";
 workspace.style.top="55px";
}

function f_MenuTopShow() {
 MenuTopAreaId.style.visibility='visible';
 MenuToolbarId.style.top="32px";
 workspace.style.top="64px";
}

function f_BuildToolbarButton(argImg, argClick, argTitle) {
// DivInnerHtml += '<img  class=MenuToolbarButton style="LEFT: ' + ToolbarStartLeft + 'px;" src="images/' + argImg + '.gif" border="0" onMouseOver="this.src=\'images/' + argImg + '_mouseover.gif\';" onMouseOut="this.src=\'images/' + argImg + '.gif\';" onClick="' + argClick + '" title="' + argTitle + '">';
 DivInnerHtml += '<img  class=MenuToolbarButton style="LEFT: ' + ToolbarStartLeft + 'px;" src="images/' + argImg + '.gif" border="0" onMouseOver="this.style.border=\'solid 1px WHITE\';" onMouseOut="this.style.border=\'solid 1px #C6C6C6\';" onClick="' + argClick + '" title="' + argTitle + '">';
 //ToolbarStartLeft = ToolbarStartLeft + 22;
}

function f_toolbar(argToolbar, argFilter) {
 //alert('f_toolbar(' + argToolbar + ',' + argFilter + ')');
 ToolbarArgs = argToolbar; //Used incase some window wants to add a toolbar item to the end.
 DivInnerHtml = '';
// DivInnerHtml  = ' <span class=MenuToolbarText1>To show the menu move</span>';
// DivInnerHtml += ' <span class=MenuToolbarText2>mouse to the left edge</span>';
 for (i=0; i < argToolbar.length; i=i + 2) {
  var TwoChar = argToolbar.substring(i,i + 2);
  if (TwoChar == "Ac" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("accept", "f_accept();", "Accept");}
  if (ini_UndefinedMenuButtonVisible && TwoChar == "Cl" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("cleardefault", "alert('defaultclear');", "defaultclear");}
  if (TwoChar == "De" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("delete", "f_delete();", "Delete");}
  if (TwoChar == "Dl" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("delete", "f_delete();", "Logoff/Delete");}
  if (TwoChar == "Er" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("erase", "f_delete();", "Erase");}
  if (ini_UndefinedMenuButtonVisible && TwoChar == "Ex" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("export", "alert('export');", "export");}
  if (TwoChar == "Fi" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("first", "f_ScrollFirst();", "First");}
  if (ini_UndefinedMenuButtonVisible && TwoChar == "Im" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("import", "alert('import');", "import");}
  if (TwoChar == "In" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("insert", "f_insert();", "Add/Insert");}
  if (TwoChar == "Is" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("insertsave", "f_insert();", "Add/Insert");}
  if (TwoChar == "La" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("last", "f_ScrollLast();", "Last");}
  if (TwoChar == "Li" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("list", "f_ViewList();", "View List");}
  if (TwoChar == "Lp" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("list", "f_ViewListChild();", "View List");}
  if (TwoChar == "Ma" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("mark_all", "f_MarkAll();", "Mark All");}
  if (ini_UndefinedMenuButtonVisible && TwoChar == "Mo" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("modified", "alert('modified');", "modified");}
  if (TwoChar == "My" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("myofficeicon", "f_MyOffice();", "Add to My Office");}
  if (TwoChar == "Pi" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("pick", "f_pick();", "Pick");}
  if (TwoChar == "Qu" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("query", "f_query();", "Search/Query");}
  if (TwoChar == "Qt" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("query", "f_todo_query();", "Search/Query");}
  if (TwoChar == "Re" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("retrieve", "f_retrieve();", "Retrieve/Refresh");}
  if (TwoChar == "Rt" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("retrieve", "f_todo_retrieve();", "Retrieve/Refresh");}
  if (TwoChar == "se" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("search", "f_query();", "query2");}
  if (ini_UndefinedMenuButtonVisible && TwoChar == "Se" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("setdefault", "alert('defaultset');", "defaultset");}
  if (ini_UndefinedMenuButtonVisible && TwoChar == "So" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("sort", "alert('sort');", "sort");}
  if (ini_UndefinedMenuButtonVisible && TwoChar == "Su" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("sum", "alert('sum');", "sum");}
  if (TwoChar == "Up" && argFilter.indexOf(TwoChar) == -1) {f_BuildToolbarButton("update", "f_update();", "Save/Update");}
 }
 MenuToolbarId.innerHTML = DivInnerHtml;
 //alert(DivInnerHtml);
}

function f_toolbar_all() {
 f_toolbar("AcClDeErExFiImInLaLiMaMoPiQuReseSeSoSuUp","");
}

function f_toolbar_query(argFilter) {
 f_toolbar("ReInPi",argFilter);
}

function f_toolbar_list(argFilter) {
 f_toolbar("QuLiSoFiLa",argFilter);
}

function f_toolbar_sublist(argFilter) {
 f_toolbar("ReInSoFiLa",argFilter);
}

function f_toolbar_detail(argFilter) {
 //alert('f_toolbar_detail start');
 //var t = "UpInDeQuRePiMoSeCl";
 var t = "UpInDeQuRePi";
 if (document.all.pick) { t = t + "Ac"; }
 if (dw[0]) {
  if (dw[0].row.length > 2) { t = t + "Ma"; } //note first row 0 is wasted
 }
 if (theform.action == "FolderDetail.jsp" || theform.action == "PeopleDetail.jsp" || theform.action == "PropertyDetail.jsp") {
  t = t + "My";
 }
 f_toolbar(t,argFilter);
 //alert('f_toolbar_detail end'); 
}

function f_toolbar_UpdateableList(argFilter) {
 var t = "UpInDeQuRePiMoSeClMa";
 if (document.all.pick) { t = t + "Ac"; }
 f_toolbar(t,argFilter);
}

function f_open(argUrl) {
 //if there is no parent, then parent.parent === parent !
 //thus this doesn't really go up six levels all the time, 
 //it goes as far as it has to, then uses that.
 //parent.parent.parent.parent.parent.parent.document.location = argUrl;
 top.document.location = argUrl;
}

function f_replace_related_window(argUrl, argWhere, argPropGisId1, argFromPageName) {
 lid = theform.lid.value;
 if (argUrl.indexOf('?') > 0) {
  argUrl = argUrl + '&lid=' + lid;
 } else {
  argUrl = argUrl + '?lid=' + lid;
 }
 //alert('f_replace_related_window 1: argUrl=' + argUrl);
 if (argWhere > ' ') {
  argUrl = argUrl + '&where=' + escape(argWhere);
  //alert('f_open_related_window 2: argUrl=' + argUrl);
 }
 if (argPropGisId1 > ' ') {
  argUrl = argUrl + '&PropGisId1=' + argPropGisId1;
  //alert('f_open_related_window 3: argUrl=' + argUrl);
 }
 if (argFromPageName > ' ') {
  argUrl = argUrl + '&fromPageName=' + argFromPageName; 
  //alert('f_open_related_window 4: argUrl=' + argUrl);
 }
 //alert('f_open_related_window 5: argUrl=' + argUrl);
 top.document.location = argUrl;
}

function f_big_open(argUrl) {
 window.resizeTo(window.screen.width, window.screen.height);
 window.moveTo(0,0);
 f_open(argUrl);
}

function f_submitTarget(argUrl, argTarget) {
 theform.action = argUrl;
 theform.target = argTarget;
 theform.submit();
}

function f_submit(argUrl) {
 theform.action = argUrl;
 theform.target = '_top';
 theform.submit();
}

function f_new_window(argUrl) {
 theform.action = argUrl
 theform.target = '_blank';
 theform.submit();
}

function f_open_related_window(argUrl, argName, argWhere) {
 //alert('f_open_related_window: ' + argUrl + ', ' + argName + ', ' + argWhere);
 lid = theform.lid.value;
 //alert('f_open_related_window: lid=' + lid);
 if (argUrl.indexOf('?') > 0) {
  argUrl = argUrl + '&lid=' + lid;
 } else {
  argUrl = argUrl + '?lid=' + lid;
 }
 //alert('f_open_related_window: argUrl=' + argUrl);
 if (argWhere > ' ') {
  argUrl = argUrl + '&where=' + escape(argWhere);
  //alert('f_open_related_window: argUrl=' + argUrl);
 }
 //alert('f_open_related_window before window open: ' + argUrl + ', ' + argName);
 w = window.open(argUrl, argName, 'top=1px, left=1px, height=' + screen.height + 'px, width=' + screen.width + 'px, directories=yes, fullscreen=no, location=yes, menubar=yes, resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=yes', true);
 w.focus();
}

function f_open_window(argUrl, argName) {
 //alert('f_open_window: ' + argUrl + ', ' + argName);
 lid = theform.lid.value;
 //alert('f_open_window: lid=' + lid);
 if (argUrl.indexOf('?') > 0) {
  argUrl = argUrl + '&lid=' + lid;
 } else {
  argUrl = argUrl + '?lid=' + lid;
 }
 //alert('f_open_window: argUrl=' + argUrl);
 if (theform.where) {
  where = theform.where.value;
  if (where > ' ') {
   argUrl = argUrl + '&where=' + escape(where);
   //alert('f_open_window: argUrl=' + argUrl);
  }
 }
 //alert('f_open_window before window open: ' + argUrl + ', ' + argName);
 //w = window.open(argUrl, argName, 'top=1px, left=1px, height=' + screen.height + 'px, width=' + screen.width + 'px, directories=yes, fullscreen=no, location=yes, menubar=yes, resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=yes', true);
 if(argName.indexOf('Window') > 0)
   w = window.open(argUrl, argName, 'top=75px, left=100px, height=575px, width=775px, directories=no, fullscreen=no, location=no, menubar=no, resizable=yes, scrollbars=no, status=yes, titlebar=yes, toolbar=no', true);
 else
   w = window.open(argUrl, argName, 'top=1px, left=1px, height=' + screen.height + 'px, width=' + screen.width + 'px, directories=yes, fullscreen=no, location=yes, menubar=yes, resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=yes', true);
 w.focus();
}

function f_open_small_window(argUrl, argName, argHeight, argWidth) {
 //alert('f_open_small_window: ' + argUrl + ', ' + argName);
 lid = theform.lid.value;
 //alert('f_open_small_window: lid=' + lid);
 if (argUrl.indexOf('?') > 0) {
  argUrl = argUrl + '&lid=' + lid;
 } else {
  argUrl = argUrl + '?lid=' + lid;
 }
 //alert('f_open_small_window: argUrl=' + argUrl);
 if (theform.where) {
  where = theform.where.value;
  if (where > ' ') {
   argUrl = argUrl + '&where=' + escape(where);
   //alert('f_open_small_window: argUrl=' + argUrl);
  }
 }
 //alert('f_open_small_window before window open: ' + argUrl + ', ' + argName);
 var top = (480 - argHeight) / 2;
 var left = (640 - argWidth) / 2;
 if (top < 0) { top = (768 - argHeight) / 2; }
 if (left < 0) { left = (1024 - argWidth) / 2; }
 w = window.open(argUrl, argName, 'top=' + top + 'px, left=' + left + 'px, height=' + argHeight + 'px, width=' + argWidth + 'px, directories=no, fullscreen=no, location=no, menubar=no, resizable=yes, scrollbars=no, status=yes, titlebar=yes, toolbar=no', true);
 w.focus();
}

function f_open_small_window_where(argUrl, argName, argWhere, argHeight, argWidth) {
 //alert('f_open_small_window_where: ' + argUrl + ', ' + argName);
 lid = theform.lid.value;
 //alert('f_open_small_window_where: lid=' + lid);
 if (argUrl.indexOf('?') > 0) {
  argUrl = argUrl + '&lid=' + lid;
 } else {
  argUrl = argUrl + '?lid=' + lid;
 }
 //alert('f_open_small_window_where: argUrl=' + argUrl);
 if (argWhere > ' ') {
  argUrl = argUrl + '&where=' + escape(argWhere);
  //alert('f_open_small_window_where: argUrl=' + argUrl);
 }
 //alert('f_open_small_window_where before window open: ' + argUrl + ', ' + argName);
 var top = (480 - argHeight) / 2;
 var left = (640 - argWidth) / 2;
 if (top < 0) { top = (768 - argHeight) / 2; }
 if (left < 0) { left = (1024 - argWidth) / 2; }
 w = window.open(argUrl, argName, 'top=' + top + 'px, left=' + left + 'px, height=' + argHeight + 'px, width=' + argWidth + 'px, directories=no, fullscreen=no, location=no, menubar=no, resizable=yes, scrollbars=no, status=yes, titlebar=yes, toolbar=no', true);
 w.focus();
}

function f_open_window_no_LID(argUrl, argName) {
 //alert('f_open_window_no_LID: ' + argUrl + ', ' + argName);
 w = window.open(argUrl, argName, 'top=1px, left=1px, height=' + screen.height + 'px, width=' + screen.width + 'px, directories=yes, fullscreen=no, location=yes, menubar=yes, resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=yes', true);
 w.focus();
}

function f_open_window_HeightWidth(argUrl, argWhere, argName, argHeight, argWidth) {
 //alert('f_open_window_HeightWidth: ' + argUrl + ', ' + argName + ', ' + argHeight + ', ' + argWidth );
 
 lid = theform.lid.value;
 where = argWhere;
 if (where > ' ') {
  where = '&where=' + escape(where);
 }
 if (argUrl.indexOf('?') > 0) {
  argUrl = argUrl + '&lid=' + lid + where;
 } else {
  argUrl = argUrl + '?lid=' + lid + where;
 }

 var top  = (screen.height - argHeight) / 2;
 var left = (screen.width  - argWidth) / 2;
 w = window.open(argUrl, argName, 'top=' + top + 'px, left=' + left + 'px, height=' + argHeight + 'px, width=' + argWidth + 'px, directories=yes, fullscreen=no, location=yes, menubar=yes, resizable=yes, scrollbars=yes, status=yes, titlebar=yes, toolbar=yes', true);
 w.focus();
}

function f_MyOffice() {
 //alert('f_MyOffice');
 var theUpdate = "";
 if (theform.action == "FolderDetail.jsp") {
  theUpdate = "MyOffice}|||{Folder}|||{" + theform.FolderRSN.value + "}|||{" + theform.FolderType.value + " " + theform.FolderName.value;
 }
 if (theform.action == "PeopleDetail.jsp") {
  theUpdate = "MyOffice}|||{People}|||{" + theform.PeopleRSN.value + "}|||{" + theform.OrganizationName.value + " " + theform.NameFirst.value + " " + theform.NameLast.value;
 }
 if (theform.action == "PropertyDetail.jsp") {
  theUpdate = "MyOffice}|||{Property}|||{" + theform.PropertyRSN.value + "}|||{" + theform.PropHouse.value + " " + theform.PropStreetPrefix.value + " " + theform.PropStreet.value + " " + theform.PropStreetType.value + " " + theform.PropStreetDirection.value + " " + theform.PropUnitType.value + " " + theform.PropUnit.value;
 }
 //alert('f_MyOffice=' + theUpdate);
 theform.dw0.value = theUpdate;
 theform.command.value = 'update';
 theform.submit();
}

function f_FixPhone(argItem, argMsg) {
 var theChar, theString, theFinal;
 theFinal="";
 theString = argItem.value;
 if ( theString.length > 0 ) {
  for(var i=0; i < (theString.length); i++){
   theChar = theString.substring(i, i+1);
   if(theChar >= '0' && theChar <= '9') {
    theFinal += theChar;
   }
  }
 } else { return false; }
 if(theFinal.length < 10 ) {
  argItem.focus();
  alert(argMsg + " is invalid. Should be at least ten digits long." );
  return true;
 } else {
  argItem.value = theFinal;
  return false;
 }
}

function f_getNumber(argString) {
 var theChar, theFinal;
 theFinal="";
 if ( argString.length > 0 ) {
  for(var i=0; i < (argString.length); i++){
   theChar = argString.substring(i, i+1);
   if(theChar >= '0' && theChar <= '9') {
    theFinal += theChar;
   }
  }
 }
 return theFinal;
}

function f_isNumber(argString) {
 var theChar;
 if ( argString.length > 0 ) {
  for(var i=0; i < (argString.length); i++){
   theChar = argString.substring(i, i+1);
   if ((theChar < '0' || theChar > '9') && theChar != '.') {
    return false;
   }
  }
 }
 return true;
}

function f_LTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

function f_RTrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

function f_Trim(str)
{
   return f_RTrim(f_LTrim(str));
}

//recursively replaces multiple occurances of text with by
function f_Replace(string,text,by) {
    var strLength = string.length, txtLength = text.length;
    if ((strLength == 0) || (txtLength == 0)) return string;
    var i = string.indexOf(text);
    if ((!i) && (text != string.substring(0,txtLength))) return string;
    if (i == -1) return string;
    var newstr = string.substring(0,i) + by;
    if (i+txtLength < strLength) {
        newstr += f_Replace(string.substring(i+txtLength,strLength),text,by);
    }
    return newstr;
}

//Note, this is 1 offset, so the first character is argStart=1
//using JavaScript slice(startPositionIndex[, endPositionIndex]) might be faster.
//using JavaScript substr(startPositionIndex[, length]) might be faster.
function f_mid(argString, argStart, argLength) {
 argStart = argStart - 1;
 if (argStart > argString.length) { return ""; }
 if (!argLength) {
  return argString.substring(argStart, argString.length);
 }
 var e = argStart + argLength;
 if (e > argString.length) {e = argString.length;}
 return argString.substring(argStart, e);
}

function f_left(argString, argLength) {
 if (argLength > argString.length) {argLength = argString.length;}
 return argString.substring(0, argLength);
}

function f_BuildWhere(argColumnName, argColumnType, argWhere) {
 //argColumnType: string, date, number, RSN
 var theValue = "";
 var theValueLower = "";
 var theWhere = argWhere;
 theValue = f_Trim(document.all.item(argColumnName).value);
 if ( theValue > ' ') {
  theValueLower = theValue.toLowerCase();
  if (theWhere > ' ') { theWhere = theWhere + " and "; }

  //FolderInfo, PeopleInfo, PropertyInfo  
  if (argColumnName == "InfoValue") {
   argColumnName = "InfoValueUpper";
   theValue = theValue.toUpperCase();
  }
  if (argColumnName == "NameFirst") {
   argColumnName = "NameFirstUpper";
   theValue = theValue.toUpperCase();
  }
  if (argColumnName == "NameLast") {
   argColumnName = "NameLastUpper";
   theValue = theValue.toUpperCase();
  }
  if (argColumnName == "OrganizationName") {
   argColumnName = "OrgNameUpper";
   theValue = theValue.toUpperCase();
  }
  if (argColumnName == "AddrStreet") {
   argColumnName = "AddrStreetUpper";
   theValue = theValue.toUpperCase();
  }
  if (argColumnName == "PropStreet") {
   argColumnName = "PropStreetUpper";
   theValue = theValue.toUpperCase();
  }
  if (argColumnName == "SynStreet") {
   argColumnName = "SynStreetUpper";
   theValue = theValue.toUpperCase();
  }
  if (argColumnName == "PropHouse") {
   argColumnName = "PropHouseNumeric";
   theValue = f_getNumber(theValue);
  }
  if (argColumnName == "AddrHouse") {
   argColumnName = "AddrHouseNumeric";
   theValue = f_getNumber(theValue);
  }
  if (argColumnName == "FolderType") {
   argColumnName = "Folder.FolderType";
   theValue = theValue.toUpperCase();
  }
  if (argColumnName == "FolderType2") {
   argColumnName = "Folder.FolderType";
   theValue = theValue.toUpperCase();
  }
  
  //  var columnPtr = 9999;
  //  var theDw = dw[0];
  //  for(i=1; i <= theDw.columnCount; i++) {
  //   if (theDw.column[i].columnName == argColumnName) {
  //    columnPtr = i;
  //    i = 9999;
  //   }
  //  }
  //  if(columnPtr!=9999)
  //    argColumnName = theDw.column[columnPtr].tableName + '.' + argColumnName;
  
  theWhere = theWhere + argColumnName; 
  if (theValueLower.indexOf("like") == 0) {
   theWhere = theWhere + ' like ';
   theValue = theValue.substring(5, theValue.length);
  } else {
   if (theValueLower.indexOf('%') != -1) {
    theWhere = theWhere + ' like ';
   } else {
    if (theValueLower.indexOf('<') != 0 && theValueLower.indexOf('>') != 0) {
     theWhere = theWhere + '=';
    }
   }
  }  
  theValue = f_Replace(theValue,"'","''");
  if (argColumnType == "number" || argColumnType == "RSN") {
   theWhere = theWhere + theValue;
  } else 
    if ( argColumnType == "date" ) {
      if(theValueLower.indexOf('<') != 0 && theValueLower.indexOf('>') != 0){
        var d = parseDate(theValue);
        var v = formatDate(d, "yyyy-MM-dd") + " 00:00:00";
        theWhere += " to_date('" + v + "','YYYY-MM-DD HH24:MI:SS')";
      }
      else if(theValueLower.indexOf('<=') == 0 || theValueLower.indexOf('>=') == 0){
        var d = parseDate(f_Trim(f_mid(theValue,3)));
        var v = formatDate(d, "yyyy-MM-dd") + " 00:00:00";
        theWhere = theWhere + f_left(theValue,2) + " to_date('" + v + "','YYYY-MM-DD HH24:MI:SS')";
      }
      else{
        var d = parseDate(f_Trim(f_mid(theValue,2)));
        var v = formatDate(d, "yyyy-MM-dd") + " 00:00:00";
        theWhere = theWhere + f_left(theValue,1) + " to_date('" + v + "','YYYY-MM-DD HH24:MI:SS')";
      }
    } else {
      if (theValueLower.indexOf('<') >= 0 || theValueLower.indexOf('>') >= 0) {
        theWhere = theWhere + f_left(theValue,1) + "'" + f_Trim(f_mid(theValue,2)) + "'";
      } else {
        if (f_left(theValue,2) == "''") {
          theWhere = theWhere + f_mid(theValue,2,theValue.length - 2)
        } else {
          theWhere = theWhere + "'" + theValue + "'";
        }
      }
    }
  }
  return theWhere;
}

function f_checkNumeric(argThis) {
 var charpos = argThis.value.search("[^0-9.]"); 
 if (argThis.value.length > 0 &&  charpos >= 0) { 
  alert(argThis.name + ": Only digits allowed\n [Error character position " + eval(charpos+1)+"]"); 
  return false; 
 }
}

function f_checkDates(){
  var theDw = dw[0];
  if(theDw!=null) {
    for(i=1;i <= theDw.rowCount; i++) {
      var theRow = theDw.row[i];
      for(j=1; j <= theDw.columnCount; j++) {
        if (theRow.data[j].modified) {
          var columnType = theDw.column[j].columnType;
          var theData = theRow.data[j];
          if (columnType == 'date') {
            var NewValue = theData.newValue;
            if(NewValue.indexOf('<=') == 0 || NewValue.indexOf('>=') == 0)
              NewValue = f_Trim(f_mid(NewValue,3));
            else if(NewValue.indexOf('<') == 0 || NewValue.indexOf('>') == 0)
              NewValue = f_Trim(f_mid(NewValue,2));
            NewValue = f_Replace(NewValue," 00:00:00","");
            var d = parseDate(NewValue);
            NewValue = formatDate(d,"NNN d, yyyy");
            document.all.item(theDw.column[j].columnName).value = NewValue;
          }
        }//end if
      }//end for
    }//end for
  }//end if not null
}

// This is a function that returns a function that is used
// in the event listener
function getOnScrollFunction(oElement) {
	return function () {
		if (oElement._scrollSyncDirection == "horizontal" || oElement._scrollSyncDirection == "both")
			oElement.scrollLeft = event.srcElement.scrollLeft;
		if (oElement._scrollSyncDirection == "vertical" || oElement._scrollSyncDirection == "both")
			oElement.scrollTop = event.srcElement.scrollTop;
	};

}
// This function adds scroll syncronization for the fromElement to the toElement
// this means that the fromElement will be updated when the toElement is scrolled
function addScrollSynchronization(fromElement, toElement, direction) {
	//alert('addScrollSynchronization start');
	removeScrollSynchronization(fromElement);
	
	fromElement._syncScroll = getOnScrollFunction(fromElement);
	fromElement._scrollSyncDirection = direction;
	fromElement._syncTo = toElement;
	toElement.attachEvent("onscroll", fromElement._syncScroll);
	//alert('addScrollSynchronization end');
}

// removes the scroll synchronization for an element
function removeScrollSynchronization(fromElement) {
	if (fromElement._syncTo != null)
		fromElement._syncTo.detachEvent("onscroll", fromElement._syncScroll);

	fromElement._syncTo = null;;
	fromElement._syncScroll = null;
	fromElement._scrollSyncDirection = null;
}

function initScrollTable(oElement) {
	if (!oElement) { 
	  //This happens when there are no rows
	  return;
	}
	var head = oElement.firstChild;
	var body = oElement.lastChild;
	resizeScrollTable(oElement);
	head.syncTo = body.uniqueID;
	head.syncDirection = "horizontal";
	parent.attachEvent("onresize", function () {
		resizeScrollTable(oElement);
	});
	addScrollSynchronization(head, body, "horizontal");
}

function resizeScrollTable(oElement) {
	var head = oElement.firstChild;
	var headTable = head.firstChild;
	var body = oElement.lastChild;
	var bodyTable = body.firstChild;
	
	if (document.all.TabMask) {
	    oElement.style.top = 55;
	} else {
	    oElement.style.top = 32;
	}
	oElement.style.left = 2;

	oElement.style.width = document.body.clientWidth - 2 - 2;
	oElement.style.height = document.body.clientHeight - 100;

	body.style.width = oElement.offsetWidth;
	head.style.width = oElement.offsetWidth;
	
	var scrollBarWidth = body.offsetWidth - body.clientWidth;

	body.style.height = Math.max(0, oElement.clientHeight - head.offsetHeight);
	
	// set width of the table in the head
	headTable.style.width = Math.max(0, Math.max(bodyTable.offsetWidth + scrollBarWidth, oElement.clientWidth));

	// go through each cell in the head and resize
	var headCells = headTable.rows[0].cells;
	var bodyCells = bodyTable.rows[0].cells;
	
	for (var i = 0; i < bodyCells.length; i++)
		headCells[i].style.width = bodyCells[i].offsetWidth;
}

function initSubScrollTable(oElement) {
	//alert('initSubScrollTable start');
	var head = oElement.firstChild;
	var body = oElement.lastChild;
	resizeSubScrollTable(oElement);
	head.syncTo = body.uniqueID;
	head.syncDirection = "horizontal";
	addScrollSynchronization(head, body, "horizontal");
	//alert('initSubScrollTable end');
}

function resizeSubScrollTable(oElement) {
	var head = oElement.firstChild;
	var headTable = head.firstChild;
	var body = oElement.lastChild;
	var bodyTable = body.firstChild;
	
	body.style.width = oElement.offsetWidth;
	head.style.width = oElement.offsetWidth;

	var scrollBarWidth = body.offsetWidth - body.clientWidth;

	body.style.height = Math.max(0, oElement.clientHeight - head.offsetHeight);
	
	//alert(body.style.height + ' ' + body.style.width);
	
	// set width of the table in the head
	headTable.style.width = Math.max(0, Math.max(bodyTable.offsetWidth + scrollBarWidth, oElement.clientWidth));
	
	// go through each cell in the head and resize
	var headCells = headTable.rows[0].cells;
	
	if (!bodyTable.rows[0]) { return; }
	var bodyCells = bodyTable.rows[0].cells;
	
	for (var i = 0; i < bodyCells.length; i++) {
		headCells[i].style.width = bodyCells[i].offsetWidth;
		//alert("Offset: " + bodyCells[i].offsetWidth);
		//alert("child: " + bodyCells[i].firstChild);
		//if (bodyCells[i].firstChild) {
		// alert(bodyCells[i].firstChild.tagName);
		// alert(bodyCells[i].firstChild.offsetWidth);
		//}
	}
}

function f_messagebox(argIcon, argButton, argHeight, argWidth) {
 MessageboxIcon = argIcon;
 MessageboxButton = argButton;
 
 if (argHeight == '0') { argHeight = '500'; }
 window.showModalDialog("messagebox.htm",window,"dialogHeight: " + argHeight + "px; dialogWidth: " + argWidth + "px; dialogTop: 200px; dialogLeft: 200px; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 

 if (theform.messageboxReturn.value > ' ') {
  buttonname = theform.buttonname.value;
  theButton = document.all.item(buttonname)
  theButton.onclick();
 }
}

function f_messagebox_error() {
 MessageboxIcon = "";
 MessageboxButton = "Cancel";
 window.showModalDialog("messageboxError.htm",window,"dialogHeight: 100px; dialogWidth: 100px; dialogTop: 200px; dialogLeft: 200px; edge: Raised; center: Yes; help: No; resizable: No; status: No;"); 
}

function f_SubmitCallButton(argButtonName) {
 var temp = '';
 var temp1 = '';
 for(var i=0; i<=6; i++){
  temp = 'd00'+i+'}|||{';
  temp += eval('theform.dw'+i+'.value');
  temp1 = eval('theform.dw'+i);
  temp1.value = temp;
  //alert(temp);
 }
 theform.buttonname.value = argButtonName;
 theform.command.value = "button";
 theform.submit();
}

function f_SubmitButton(argButtonName) {
 //alert('submit button: ' + argButtonName + '(' + theform.dw0.value + ')');
 theform.buttonname.value = argButtonName;
 theform.command.value = "button";
 theform.submit();
}

function f_ClickRow(argRow) {
 var alt = window.event.altKey ;
 var ctrl = window.event.ctrlKey ;
 var shift = window.event.shiftKey ;
 
 var theRow = dw[0].row[argRow];
 if (dw[0].row[1].tr == null) { f_ClickInit(0, ''); } //use first row, not clicked row due to insert rows
 
 if ( ctrl ) {
  if ( theRow.selected ) {
   theRow.selected = false;
   theRow.tr.style.backgroundColor = theRow.backgroundColor;
  } else {
   theRow.selected = true;
   theRow.tr.style.backgroundColor = "#6633ff";
  }
 } else {
  if ( shift ) {
   if (argRow > PriorClickedRow) {
    var startRow = PriorClickedRow;
    var endRow   = argRow;
   } else {
    var startRow = argRow
    var endRow   = PriorClickedRow;
   }
   for (row = startRow; row <= endRow; row++) {
    theRow = dw[0].row[row];
    theRow.selected = true;
    theRow.tr.style.backgroundColor = "#6633ff";
   }
  } else {
   for (row = 1; row <= dw[0].row.length - 1; row++) {
    theRow = dw[0].row[row];
    if (theRow.selected) {
     theRow.selected = false;
     theRow.tr.style.backgroundColor = theRow.backgroundColor;
    }
   }
   theRow = dw[0].row[argRow];
   theRow.selected = true;
   theRow.tr.style.backgroundColor = "#6633ff";
  }
 }
 PriorClickedRow = argRow;
}

function f_child_ClickRow(argDw, argRow, argTable) {
 var alt = window.event.altKey ;
 var ctrl = window.event.ctrlKey ;
 var shift = window.event.shiftKey ;
 
 var theRow = dw[argDw].row[argRow];
 
 if (dw[argDw].row[1].tr == null) { f_ClickInit(argDw, argTable); } //use first row, not clicked row due to insert rows
 
 if ( ctrl ) {
  if ( theRow.selected ) {
   theRow.selected = false;
   theRow.tr.style.backgroundColor = theRow.backgroundColor;
  } else {
   theRow.selected = true;
   theRow.tr.style.backgroundColor = "#6633ff";
  }
 } else {
  if ( shift ) {
   if (argRow > PriorClickedRow) {
    var startRow = PriorClickedRow;
    var endRow   = argRow;
   } else {
    var startRow = argRow
    var endRow   = PriorClickedRow;
   }
   for (row = startRow; row <= endRow; row++) {
    theRow = dw[argDw].row[row];
    theRow.selected = true;
    theRow.tr.style.backgroundColor = "#6633ff";
   }
  } else {
   for (row = 1; row <= dw[argDw].row.length - 1; row++) {
    theRow = dw[argDw].row[row];
    if (theRow.selected) {
     theRow.selected = false;
     theRow.tr.style.backgroundColor = theRow.backgroundColor;
    }
   }
   theRow = dw[argDw].row[argRow];
   theRow.selected = true;
   theRow.tr.style.backgroundColor = "#6633ff";
  }
 }
 PriorClickedRow = argRow;
}

function f_SelectRow(argRow) {
 var theRow = dw[0].row[argRow];
 if (dw[0].row[1].tr == null) { f_ClickInit(0, ''); } //use first row, not clicked row due to insert rows
 
 theRow.selected = true;
 theRow.tr.style.backgroundColor = "#6633ff";
 PriorClickedRow = argRow;
}

function f_SetModified(argRow, argColumn) {
 var theDw = dw[0];
 theDw.modified = true;
 var theRow = theDw.row[argRow];
 theRow.modified = true;
 var theData = theRow.data[argColumn]
 theData.modified = true;
}

function f_SetModified(argDw, argRow, argColumn) {
 var theDw = dw[argDw];
 theDw.modified = true;
 var theRow = theDw.row[argRow];
 theRow.modified = true;
 var theData = theRow.data[argColumn]
 theData.modified = true;
}

function f_ClickInit(argDw, argTable) {
 var theTable = document.getElementById(argTable + "ListTableBody");
 var theDw = dw[argDw];
 for (i = 0; i < theTable.rows.length ; i++) {
  var theRow = theDw.row[i + 1];
  theRow.tr = theTable.rows[i];
  theRow.backgroundColor = theRow.tr.style.backgroundColor;
 }
}

function f_MarkAll() {
   if (dw[0].row[1].tr == null) { f_ClickInit(0, ''); }
   for (row = 1; row <= dw[0].row.length - 1; row++) {
    var theRow = dw[0].row[row];
    theRow.selected = true;
    theRow.tr.style.backgroundColor = "#6633ff";
   }
}

function f_child_MarkAll(argDw, argTable) {
   if (dw[argDw].row[1].tr == null) { f_ClickInit(argDw, argTable); }
   for (row = 1; row <= dw[argDw].row.length - 1; row++) {
    var theRow = dw[argDw].row[row];
    theRow.selected = true;
    theRow.tr.style.backgroundColor = "#6633ff";
   }
}

//dw[0] = new f_DW('Property', 1, 40);
function f_DW(argName, argRowCount, argColumnCount) {
 this.name = argName;
 this.rowCount = argRowCount;
 this.columnCount = argColumnCount;
 this.modified = false;
 this.row    = new Array(argRowCount + 1);
 this.column = new Array(argColumnCount + 1);
}

//dw[0].column[1] = new f_COLUMN('Property', 'PropHouse', 'string');
function f_COLUMN(argTableName, argColumnName, argColumnType, argPrimaryKey) {
 this.tableName = argTableName;
 this.columnName = argColumnName;
 this.columnType = argColumnType;
 this.primaryKey = argPrimaryKey;
}

//dw[0].row[40] = new f_ROW(40, 'W0404');
function f_ROW(argColumnCount, argPrimaryKey) {
 this.modified = false;
 this.primaryKey = argPrimaryKey;
 this.data = new Array(argColumnCount + 1);
 this.type = "U";
 this.selected = false;
 this.tr = null;
 this.backgroundColor = "#FFFFFF";
}

//dw[0].row[1].data[011] = new f_DATA("1901111110014000000");
function f_DATA(argOldValue) {
 this.modified = false;
 this.oldValue = argOldValue;
 this.newValue = argOldValue;
}

function f_threeChar(argNumber) {
 var theString = argNumber + '';
 if (argNumber < 100) {
  if (argNumber < 10) {
   theString = "00" + argNumber;
  } else {
   theString = "0" + argNumber;
  }
 }
 return theString;
}

function f_modified() {
 for(k=0; k < dw.length; k++) {
  var theDw = dw[k];
  if (theDw.modified) {
   alert('Please press update first.');
   return true;
  }
 }
 return false;
}

function f_BuildDw(argColumnName, argColumnType, argColumnNumber, argOldValue, argDw) {
 //argColumnType: string, date, number, RSN
 var theDw = argDw;
 var theValue = document.all.item(argColumnName).value;
 if (theValue > ' ' || argOldValue > ' ') {
  theDw = theDw + "}|||{C" + argColumnNumber + theValue;
  if (argOldValue > ' ') { theDw = theDw + "}|||{O"  + argColumnNumber + argOldValue;  }
 }
 return theDw;
}

function f_BuildDwKeysOnly() {
 //alert('f_BuildDwKeysOnly');
 var theReturn = "";
 for(k=0; k < dw.length; k++) {
  if (theReturn > ' ') { theReturn = theReturn + '}|||{'; }
  theReturn = theReturn + 'd' + f_threeChar(k);
  var theDw = dw[k];
  var noneSelected = true;
  for(r=1;r <= theDw.rowCount; r++) {
   if (theDw.row[r].selected) {
    noneSelected = false;
    r = 9999;
   }
  }
  var r = 0;
  for(row=1;row <= theDw.rowCount; row++) {
   var theRow = theDw.row[row];
   if ( noneSelected || theRow.selected ) {
    r = r + 1;
    theReturn = theReturn + '}|||{r' + f_threeChar(r);
    for(c=1; c <= theDw.columnCount; c++) {
     if (theDw.column[c].primaryKey) {
      var theData = theRow.data[c];
      var threeChar = f_threeChar(c);
      if (theData.oldValue > ' ') { 
       theReturn = theReturn + "}|||{C" + threeChar + theData.oldValue;
      } else {
       theReturn = theReturn + "}|||{C" + threeChar + theData.newValue;
      }
     }
    }
   }
  }
 }
 theform.dw0.value = theReturn;
}

function f_BuildDwCallAllValues() {
 var theReturn = "";
 for(k=0; k < dw.length; k++) {
  //alert('k='+k);
  if (theReturn > ' ') { theReturn = theReturn + '}|||{'; }
  theReturn = theReturn + 'd' + f_threeChar(k);
  var theDw = dw[k];
  
  if(theDw.rowCount==0){
    //alert('theDw='+k);
    theDw.row[1] = new f_ROW(theDw.columnCount,"");
    var theRow = theDw.row[1];
    //alert('theDw.columnCount='+theDw.columnCount);
    for(i=1; i <= theDw.columnCount; i++) {
     theRow.data[i] = new f_DATA("");
     f_SetModified(k, 1, i);
    }
    theDw.rowCount = 1;
    theRow.type = 'r';
  }
  else{
   for(r=1;r <= theDw.rowCount; r++) {
    var theRow = theDw.row[r];
     for(i=1; i <= theDw.columnCount; i++) {
       f_SetModified(k, r, i);
      }
    }
  }
  
  var noneSelected = true;
  for(r=1;r <= theDw.rowCount; r++) {
   if (theDw.row[r].selected) {
    noneSelected = false;
    r = 9999;
   }
  }
  for(r=1;r <= theDw.rowCount; r++) {
   //alert('r=' + r)
   //if ( noneSelected || theDw.row[r].selected ) {
    theReturn = theReturn + '}|||{r' + f_threeChar(r);
    var theRow = theDw.row[r];
    if (theRow.selected) {
     theReturn = theReturn + '}|||{s001';
    } else {
     theReturn = theReturn + '}|||{s000';
    }    
    for(c=1; c <= theDw.columnCount; c++) {
     var theData = theRow.data[c];
     var threeChar = f_threeChar(c);
     theReturn = theReturn + "}|||{C" + threeChar + theData.newValue;
     if (theData.oldValue > ' ' && theData.oldValue != theData.newValue) { theReturn = theReturn + "}|||{O" + threeChar + theData.oldValue; }
    }
   //}
  }
 }
 //alert(theReturn);
 theform.dw0.value = theReturn;
}

function f_BuildDwAllValues() {
 //alert('f_BuildDwAllValues');
 var theReturn = "";
 for(k=0; k < dw.length; k++) {
  if (theReturn > ' ') { theReturn = theReturn + '}|||{'; }
  theReturn = theReturn + 'd' + f_threeChar(k);
  var theDw = dw[k];
  var noneSelected = true;
  for(r=1;r <= theDw.rowCount; r++) {
   if (theDw.row[r].selected) {
    noneSelected = false;
    r = 9999;
   }
  }
  for(r=1;r <= theDw.rowCount; r++) {
   //alert('r=' + r)
   //if ( noneSelected || theDw.row[r].selected ) {
    theReturn = theReturn + '}|||{r' + f_threeChar(r);
    var theRow = theDw.row[r];
    if (theRow.selected) {
     theReturn = theReturn + '}|||{s001';
    } else {
     theReturn = theReturn + '}|||{s000';
    }    
    for(c=1; c <= theDw.columnCount; c++) {
     var theData = theRow.data[c];
     var threeChar = f_threeChar(c);
     theReturn = theReturn + "}|||{C" + threeChar + theData.newValue;
     if (theData.oldValue > ' ' && theData.oldValue != theData.newValue) { theReturn = theReturn + "}|||{O" + threeChar + theData.oldValue; }
    }
   //}
  }
 }
 //alert(theReturn);
 theform.dw0.value = theReturn;
}

function f_buildUpdateDw(argDw) {
 //alert('f_buildUpdateDw');
 var theReturn = "";
 var theDw = dw[argDw];
 if (theDw.modified) {
  for(i=1;i <= theDw.rowCount; i++) {
   var theRow = theDw.row[i];
   if (theRow.modified && theRow.type != ' ') { //an 'inserted' row was 'deleted'
    if (theReturn > ' ') { theReturn = theReturn + '}|||{'; }
    theReturn = theReturn + theRow.type + '001';
    updateFlag = true;
    if (theRow.type != "D") { //Update Insert
     for(j=1; j <= theDw.columnCount; j++) {
      //alert('4: ' + j + ' of ' + theDw.columnCount);
      if (theRow.data[j].modified) {
       var columnType = theDw.column[j].columnType;
       var theData = theRow.data[j];
       var threeChar = f_threeChar(j);
       theReturn = theReturn + "}|||{C" + threeChar + theData.newValue;
       if (theData.oldValue > ' ' || columnType == 'date') { theReturn = theReturn + "}|||{O" + threeChar + theData.oldValue; }
      }
     }
    } 
    if (theRow.type != "I") {
     theReturn = theReturn + "}|||{" + theRow.primaryKey;
    }
   } 
  }
 } 
 //alert(argDw + ":" + theReturn);
 return theReturn;
}

function f_buildDeleteDw(argDw) {
 var theDw = dw[argDw];
 //alert('delete');
 //alert(theDw.rowCount);
 for(i=1;i <= theDw.rowCount; i++) {
  var theRow = theDw.row[i];
  if (theRow.selected || theDw.rowCount == 1) {
   if (theRow.type == 'I') {
    theRow.type = ' '; //don't delete rows that aren't in the database
    theRow.modified = false;
   } else {
    theRow.type = 'D';
    theRow.modified = true;
    theDw.modified = true;
   }
  }
 }
}

function f_buildInsert(argTdInsert) {
 var theTable = document.getElementById("ListTableBody");
 var theTbody = theTable.firstChild; 

 var theDw = dw[0];
 var row = theTable.rows.length;
 var rowPlusOne = row + 1;
 
 var TdInsert = f_Replace(argTdInsert,"XXROWXX",rowPlusOne);
 
 var theTr = theTbody.insertRow();
 theTr.className = "dataclick";
 theTr.name = "row" + rowPlusOne;
 theTr.id = "row" + rowPlusOne
 theTr.onclick = function () { f_ClickRow(rowPlusOne,theTr); }
 theTr.style.backgroundColor = "yellow";

 //theTr.innertHTML doesn't work, so we use insertCell() instead
 j = 0;
 while ( TdInsert > "" ) {
  i = TdInsert.indexOf("</td>");
  if ( i > 0 ) {
   if (TdInsert.substring(0,4) == "<td>") {
    thisTd = TdInsert.substring(4, i );
    TdInsert = TdInsert.substring(i + 7, TdInsert.length);
   } else {
    thisTd = "&nbsp;";
    TdInsert = TdInsert.substring(i + 7, TdInsert.length);
   }
  } else {
   thisTd = TdInsert.substring(4, TdInsert.Length - 8);
   TdInsert = "";
  }
  theTd = theTr.insertCell(j);
  theTd.insertAdjacentHTML("afterBegin",thisTd);
  j++;
 }
 
 theDw.row[rowPlusOne] = new f_ROW(theDw.columnCount,"");
 var theRow = theDw.row[rowPlusOne];
 for(i=1; i <= theDw.columnCount; i++) {
  theRow.data[i] = new f_DATA("");
 }
 theDw.rowCount = rowPlusOne;
 theRow.tr = theTr;
 theRow.backgroundColor = "yellow"; 
 theRow.type = "I";
 //f_ClickInit(0, '');
 
 if (rowPlusOne > 7) { theTr.scrollIntoView(true); }
 
 //Begin parsing the where clause into values
 //just like w_z_template.dw.rbuttondown
 if (!theform.where) { return; }
 
 //requires TableName and ColumnName and no space around =
 var where = theform.where.value;
 //where = "ValidInfo.InfoDesc='ABC' and ValidInfo.InfoCode=234 and ValidInfo.Infodef=242.234";
 while (where.length > 0) {
  p = where.indexOf('.');
  if (p > 0) {
   tableName = where.substring(0,p);
   where = where.substring(p + 1);
  }
  p = where.indexOf('=');
  if (p > 0) {
   columnName = where.substring(0,p);
   where = where.substring(p + 1);
  }
  if (where.charAt(0) == "'") {
   p = where.indexOf("'",1);
   columnValue = where.substring(1,p)
   where = where.substring(p + 1);
  } else {
   //where= "FolderEventIncome.EventDate=to_date('2003-09-11 00:07:09','YYYY-MM-DD HH24:MI:SS') and FolderEventIncome.FolderRSN=38258"
   if (where.substring(0,8) == "to_date(") {
    p = where.indexOf("'",9);
    columnValue = where.substring(9,p);
    where = where.substring(p + 26);
    //alert('DATE table:' + tableName + ',  column:' + columnName + ', value:' + columnValue + ',  where:' + where);
   } else {
    columnValue = '';
    for(i=0; i < (where.length); i++){
     theChar = where.substring(i, i+1);
     if((theChar >= '0' && theChar <= '9') || theChar == '.') {
      columnValue += theChar;
     } else {
      i = where.length + 1;
     }
    }
    where = where.substring(columnValue.length);
   }
  }
  //alert('table:' + tableName + ',  column:' + columnName + ', value:' + columnValue + ',  where:' + where);
  for(i=1; i <= theDw.columnCount; i++) {
   if (theDw.column[i].columnName == columnName) {
    //alert('setting column:' + columnName + ' = ' + columnValue);
    theRow.data[i].newValue = columnValue;
    theRow.data[i].modified = true;
    i = 9999;
   }
  }
 }
}

//Similar to f_onChange() but this takes any value, especially dates with TIME.
function f_setItem(argDw, argRow, argColumnName, argNewValue) {
 //alert('f_setItem[' + argDw + ', ' + argRow + ', ' + argColumnName + ', ' + argNewValue + ']');
 var theDw = dw[argDw];
 columnPtr = -1;
 for(i=1; i <= theDw.columnCount; i++) {
  if (theDw.column[i].columnName == argColumnName) {
   columnPtr = i;
   i = 9999;
  }
 }
 if (columnPtr < 1) {
  alert("Unknown column: " + argColumnName + " in f_setItem()");
  return;
 }
 
 if (theform.item(argColumnName)) {
  theform.item(argColumnName).value = argNewValue;
 }
 
 theDw.modified = true;
 var theRow = theDw.row[argRow];
 theRow.modified = true;
 var theData = theRow.data[columnPtr]
 theData.modified = true;
 theData.newValue = argNewValue;
 if (theDw.column[columnPtr].columnType == "date") {
  if (theData.oldValue > " ") {
   var d = parseDate(theData.oldValue);
   if (d != null) {
    var v = formatDate(d, "yyyy-MM-dd") + " 00:00:00";
    theData.oldValue = v;
   }
  }
 }
 //alert('f_setItem end');
}

function f_OnChange(argDw, argRow, argColumn, argNewValue) {
 //alert('onchange[' + argDw + ', ' + argRow + ', ' + argColumn + ', ' + argNewValue + ']');
 var theDw = dw[argDw];
 theDw.modified = true;
 var theRow = theDw.row[argRow];
 theRow.modified = true;
 var theData = theRow.data[argColumn]
 theData.modified = true;
 if (theDw.column[argColumn].columnType == "date") {
  //Timestamp format must be CCYY-MM-DD HH:MM:SS
  //"ISO 8601:2000" International Date and Time Standard
  if (argNewValue > " ") {
   var sign = "";
   if(argNewValue.indexOf('<=') == 0 || argNewValue.indexOf('>=') == 0){
    sign = f_left(argNewValue,2);
    argNewValue = f_Trim(f_mid(argNewValue,3));
   }
   else if(argNewValue.indexOf('<') == 0 || argNewValue.indexOf('>') == 0){
    sign = f_left(argNewValue,1);
    argNewValue = f_Trim(f_mid(argNewValue,2));
   }
   var d = parseDate(argNewValue);
   if (d == null) {
      alert('Invalid Date. Please use Pick to select a date. (e.g. date  Dec 31, 2003)');
      return;
   }
   var v = formatDate(d, "yyyy-MM-dd") + " 00:00:00";
   theData.newValue = v;

   var v = formatDate(d, "NNN d, yyyy");
   if (v != argNewValue) {
    document.all.item(theDw.column[argColumn].columnName).value = sign + v;
   }
  } else {
   theData.newValue = "";
  }
  

  if (theData.oldValue > " ") {
   var d = parseDate(theData.oldValue);
   if (d != null) {
    var v = formatDate(d, "yyyy-MM-dd") + " 00:00:00";
    theData.oldValue = v;
   }
  }
 } else {
  theData.newValue = argNewValue;
 }
 //alert('f_OnChange end');
}

function f_OnChangeDate(argDw, argRow, argColumn, argNewValue) {
 //alert('f_OnChangeDate[' + argDw + ', ' + argRow + ', ' + argColumn + ', ' + argNewValue + ']');
 var theDw = dw[argDw];
 theDw.modified = true;
 var theRow = theDw.row[argRow];
 theRow.modified = true;
 var theData = theRow.data[argColumn]
 theData.modified = true;
 //Timestamp format must be CCYY-MM-DD HH:MM:SS
 //"ISO 8601:2000" International Date and Time Standard
 if (argNewValue > " ") {
  var d = parseDate(argNewValue);
  if (d == null) {
     alert('Invalid Date. Please use Pick to select a date. (e.g. date  Dec 31, 2003)');
     return;
  }
  var v = formatDate(d, "yyyy-MM-dd") + " 00:00:00";
  theData.newValue = v;
   var v = formatDate(d, "NNN d, yyyy");
  if (v != argNewValue) {
   document.all.item(theDw.column[argColumn].columnName + '_' + argRow).value = v;
  }

  if (theData.oldValue > " ") {
   var d = parseDate(theData.oldValue);
   if (d != null) {
    var v = formatDate(d, "yyyy-MM-dd") + " 00:00:00";
    theData.oldValue = v;
   }
  }
 } else {
  theData.newValue = argNewValue;
 }
 //alert('f_OnChangeDate end');
}

function f_OnChangeNumber(argDw, argRow, argColumn, argNewValue) {
 //alert('f_OnChangeNumber[' + argDw + ', ' + argRow + ', ' + argColumn + ', ' + argNewValue + ']');
 var theDw = dw[argDw];
 theDw.modified = true;
 var theRow = theDw.row[argRow];
 theRow.modified = true;
 var theData = theRow.data[argColumn]
 theData.modified = true;
 if (argNewValue > " ") {
  if (!f_isNumber(argNewValue)) {
      alert('Invalid number. Non numeric text is not allowed.');
      return;
  }
 }
 theData.newValue = argNewValue;
 //alert('f_OnChangeNumber end');
}


function f_ScrollFirst() {
 var theTable = document.getElementById("ListTableBody");
 var theTr = theTable.rows[0];
 theTr.scrollIntoView(true);
}

function f_ScrollLast() {
 var theTable = document.getElementById("ListTableBody");
 var theTr = theTable.rows[theTable.rows.length - 1];
 theTr.scrollIntoView(true);
}

function f_BuildPropertyTab(argPage) {
 var elementCreateTabPane = document.createElement('<div class="tab-pane" id="tabPane1" style="TOP:32;">');
 document.body.insertBefore(elementCreateTabPane);
 var elementTabPane =  document.all.item("tabPane1");
 
 var StartPage = 0;
 var i=1;
 DivInnerHtml  = '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="PropertyDetail.jsp">Property</h2></div>';       if (argPage == 'Property')    {StartPage=i - 1;} i++;
 if (ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="Property_FolderPropertyDetail.jsp">Folder Property</h2></div>'; if (argPage == 'Folder Property')       {StartPage=i - 1;} i++; }
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="PropertyParcelDetail.jsp">Parcel</h2></div>';   if (argPage == 'Parcel')       {StartPage=i - 1;}  i++;
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '""><h2 class="tab" LinkTo="PropertyInfoDetail.jsp">Info</h2></div>';      if (argPage == 'Info')         {StartPage=i - 1;}  i++;
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="PropertyCommentDetail.jsp">Comment</h2></div>'; if (argPage == 'Comment')      {StartPage=i - 1;}  i++;
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="PropertyPeopleDetail.jsp">People</h2></div>';   if (argPage == 'People')       {StartPage=i - 1;}  i++;
 if (ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '""><h2 class="tab" LinkTo="PropertySurveyDetail.jsp">Survey</h2></div>';  if (argPage == 'Survey')       {StartPage=i - 1;}  i++; }
 if (ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="PropertyRelationDetail.jsp">Relation</h2></div>';    if (argPage == 'Relation')       {StartPage=i - 1;}  i++; }
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="Attachment.jsp">Attachment</h2></div>';         if (argPage == 'Attachment')   {StartPage=i - 1;}  i++;

 elementTabPane.innerHTML = DivInnerHtml; 
 var tp1 = new f_TabPanel( document.getElementById( "tabPane1"), StartPage );
}

function f_BuildPeopleTab(argPage) {
 var elementCreateTabPane = document.createElement('<div class="tab-pane" id="tabPane1" style="TOP:32;">');
 document.body.insertBefore(elementCreateTabPane);
 var elementTabPane =  document.all.item("tabPane1");

 var StartPage = 0;
 var i=1;
 DivInnerHtml  = '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="PeopleDetail.jsp">People</h2></div>';                     if (argPage == 'People')        {StartPage=i - 1;} i++;
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="People_FolderPeopleDetail.jsp">Folder People</h2></div>'; if (argPage == 'Folder People') {StartPage=i - 1;} i++;
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="People_PropertyPeopleDetail.jsp">Property</h2></div>';          if (argPage == 'Property')      {StartPage=i - 1;} i++;
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="PeopleInfoDetail.jsp">Personal Info</h2></div>';          if (argPage == 'Personal Info') {StartPage=i - 1;} i++;
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="Attachment.jsp">Attachment</h2></div>';                   if (argPage == 'Attachment')    {StartPage=i - 1;} i++; 
 if (ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="PeopleGroupDetail.jsp">People/Group</h2></div>';          if (argPage == 'People/Group')  {StartPage=i - 1;} i++; }

 elementTabPane.innerHTML = DivInnerHtml; 
 var tp1 = new f_TabPanel( document.getElementById( "tabPane1"), StartPage );
}

function f_BuildFolderTab(argPage) {
 //alert('BuildFolderTab start: ' + argPage);
 var elementCreateTabPane = document.createElement('<div class="tab-pane" id="tabPane1" style="TOP:32;">');
 document.body.insertBefore(elementCreateTabPane);
 var elementTabPane =  document.all.item("tabPane1");
 
 //var TabMask = "YYYNYYYYYYYNNYNNNNN";
 TabMask = " ";
 if (document.all.TabMask) {
  var TabMask = document.all.TabMask.value;
 } else {
  alert('f_BuildFolderTab - TabMask was not found, default used.');
 }
 
 if (theform.AddMask) {
   for(i = 1; i <= 19; i++) {
     var AddMask = theform.AddMask.value;
     if (f_mid(AddMask,  i, 1) == 'N') {
       //alert('Before: ' + TabMask + ' ' + i + ' ' + AddMask);
       TabMask = f_left(TabMask, i - 1) + 'N' + f_mid(TabMask, i + 1, 9999);
       //alert('After: ' + TabMask + ' ' + i + ' ' + AddMask);
     }
   }
 }

 //We always have a Folder tab.
 DivInnerHtml  = '<div class="tab-page" id="tabPage1" ><h2 class="tab" LinkTo="FolderDetail.jsp">Folder</h2></div>';
  
 var StartPage = 0;
 var i=2;
 if (f_mid(TabMask,  1, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderPropertyDetail.jsp">Property</h2></div>';   if (argPage == 'Property')       {StartPage=i - 1;} i++; }
 if (f_mid(TabMask,  2, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderPeopleDetail.jsp">People</h2></div>';       if (argPage == 'People')         {StartPage=i - 1;} i++; }
 if (f_mid(TabMask,  3, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderInfoDetail.jsp">Info</h2></div>';           if (argPage == 'Info')           {StartPage=i - 1;} i++; }
 if (f_mid(TabMask,  4, 1) == 'Y' && ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDetail.jsp">Fixture</h2></div>';            if (argPage == 'Fixture')        {StartPage=i - 1;} i++; }
 if (f_mid(TabMask,  5, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="AccountBillFeeDetail.jsp">Fee/Charge</h2></div>'; if (argPage == 'Fee')            {StartPage=i - 1;} i++; }
 if (f_mid(TabMask,  6, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderProcess.jsp">Process</h2></div>';           if (argPage == 'Process')        {StartPage=i - 1;} i++; }
 if (f_mid(TabMask,  7, 1) == 'Y' && ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDetail.jsp">Select Process</h2></div>';     if (argPage == 'Select Process') {StartPage=i - 1;} i++; }
 if (f_mid(TabMask,  8, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDocument.jsp">Document</h2></div>';         if (argPage == 'Document')       {StartPage=i - 1;} i++; }
 if (f_mid(TabMask,  9, 1) == 'Y' && ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDetail.jsp">File</h2></div>';               if (argPage == 'File')           {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 10, 1) == 'Y' && ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDetail.jsp">Insp. Request</h2></div>';      if (argPage == 'Insp. Request')  {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 11, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderComment.jsp">Comment</h2></div>';           if (argPage == 'Comment')        {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 12, 1) == 'Y' && ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDetail.jsp">Clock</h2></div>';              if (argPage == 'Clock')          {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 13, 1) == 'Y' && ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDetail.jsp">Usage</h2></div>';              if (argPage == 'Usage')          {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 14, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="Attachment.jsp">Attachment</h2></div>';           if (argPage == 'Attachment')     {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 15, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderEventDetail.jsp">Event</h2></div>';         if (argPage == 'Event')          {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 16, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDonationDetail.jsp">Donation</h2></div>';   if (argPage == 'Donation')       {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 17, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDrawDetail.jsp">Draw</h2></div>';           if (argPage == 'Draw')           {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 18, 1) == 'Y') { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderWheelDetail.jsp">Wheel</h2></div>';         if (argPage == 'Wheel')          {StartPage=i - 1;} i++; }
 if (f_mid(TabMask, 19, 1) == 'Y' && ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" LinkTo="FolderDetail.jsp">Certificate</h2></div>';        if (argPage == 'Certificate')    {StartPage=i - 1;} i++; }
 if (theform.AddMask) {
 	DivInnerHtml += '<img class="tab" src="images/AutomaticAddMode.gif">'; 
 }
 elementTabPane.innerHTML = DivInnerHtml; 
 var tp1 = new f_TabPanel( document.getElementById( "tabPane1"), StartPage );
 //alert(argPage + ' ' + StartPage);
 //alert(DivInnerHtml);
}

function f_BuildProcessTab(argPage) {
 //alert('f_BuildProcessTab start: ' + argPage);
 var elementCreateTabPane = document.createElement('<div class="tab-pane" id="tabPane1" style="TOP:32;">');
 document.body.insertBefore(elementCreateTabPane);
 var elementTabPane =  document.all.item("tabPane1");
 
 DivInnerHtml  = '';
 
 var StartPage = 0;
 var i=1;
 //Attempt/Checklist/Memo/Deficiency/Attachment/Dependency/Info/Consent
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" ProcessFlag=1 LinkTo="FolderProcessAttemptDetail.jsp">Attempt</h2></div>'; if (argPage == 'Attempt')       {StartPage=i - 1;} i++; 
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" ProcessFlag=1 LinkTo="FolderProcessChecklistDetail.jsp">Checklist</h2></div>'; if (argPage == 'Checklist') {StartPage=i - 1;} i++; 
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" ProcessFlag=1 LinkTo="FolderInspectionMemoDetail.jsp">Memo</h2></div>'; if (argPage == 'Memo') {StartPage=i - 1;} i++; 
 if (ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" ProcessFlag=1 LinkTo="FolderProcessDeficiencyList.jsp">Deficiency</h2></div>'; if (argPage == 'Deficiency') {StartPage=i - 1;} i++; }
 if (ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" ProcessFlag=1 LinkTo="FolderProcessAttachmentDetail.jsp">Attachment</h2></div>'; if (argPage == 'Attachment') {StartPage=i - 1;} i++; }
 if (ini_UndefinedMenuButtonVisible) { DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" ProcessFlag=1 LinkTo="FolderProcessDependencyDetail.jsp">Dependency</h2></div>'; if (argPage == 'Dependency') {StartPage=i - 1;} i++; }
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" ProcessFlag=1 LinkTo="FolderProcessInfoDetail.jsp">Info</h2></div>'; if (argPage == 'Info') {StartPage=i - 1;} i++; 
 DivInnerHtml += '<div class="tab-page" id="tabPage' + i + '"><h2 class="tab" ProcessFlag=1 LinkTo="FolderProcessPeopleDetail.jsp">Consent</h2></div>'; if (argPage == 'People') {StartPage=i - 1;} i++; 
 
 elementTabPane.innerHTML = DivInnerHtml; 
 var tp1 = new f_TabPanel( document.getElementById( "tabPane1"), StartPage );
 //alert(argPage + ' ' + StartPage);
 //alert(DivInnerHtml);
}

function f_TabPanel( el, argSelectIndex ) {
	this.element = el;
	this.element.tabPanel = this;
	this.pages = [];
	this.selectedIndex = null;
	this.element.className = this.classNameTag + " " + this.element.className;
	this.tabRow = document.createElement( "div" );
	this.tabRow.className = "tab-row";
	el.insertBefore( this.tabRow, el.firstChild );
	this.selectedIndex = argSelectIndex;
	var cs = el.childNodes;
	var n;
	for (var i = 0; i < cs.length; i++) {
		if (cs[i].nodeType == 1 && cs[i].className == "tab-page") {
			this.addTabPage( cs[i] );
		}
	}
}

f_TabPanel.prototype = {
	classNameTag:		"tab-control",
	setSelectedIndex:	function ( n ) {
		if (this.selectedIndex != n) {
			if (this.selectedIndex != null && this.pages[ this.selectedIndex ] != null )
				this.pages[ this.selectedIndex ].hide();
			this.selectedIndex = n;
			this.pages[ this.selectedIndex ].show(true);
		}
	},
	getSelectedIndex:	function () {
		return this.selectedIndex;
	},
	addTabPage:	function ( oElement ) {
		if ( oElement.tabPage == this )	// already added
			return oElement.tabPage;
		var n = this.pages.length;
		var tp = this.pages[n] = new f_TabPage( oElement, this, n );
		tp.tabPanel = this;
		this.tabRow.appendChild( tp.tab );
		if ( n == this.selectedIndex )
			tp.show(false);
		else
			tp.hide();
		return tp;
	}	
};

function f_TabPage( el, tabPanel, nIndex ) {
	this.element = el;
	this.element.tabPage = this;
	this.index = nIndex;
	var cs = el.childNodes;
	for (var i = 0; i < cs.length; i++) {
		if (cs[i].nodeType == 1 && cs[i].className == "tab") {
			this.tab = cs[i];
			break;
		}
	}
	var a = document.createElement( "A" );
	//a.href = "javascript:void 0;";
	while ( this.tab.hasChildNodes() )
		a.appendChild( this.tab.firstChild );
	this.tab.appendChild( a );
	var oThis = this;
	this.tab.onclick = function () { oThis.select(); };
	this.tab.onmouseover = function () { f_TabPage.tabOver( oThis ); };
	this.tab.onmouseout = function () { f_TabPage.tabOut( oThis ); };
}

f_TabPage.prototype = {
	show:	function (argClick) {
		var el = this.tab;
		var s = el.className + " selected";
		s = s.replace(/ +/g, " ");
		el.className = s;
		//this.element.style.display = "block";
		this.element.style.display = "none";
		if (argClick) {
		 //alert(el.LinkTo);
		 theform.action = el.LinkTo;
		 if (el.ProcessFlag) {
		 //if (f_left(theform.action, 13) == 'FolderProcess' || theform.action == 'FolderInspectionMemoDetail.jsp') {
		  theform.target = '_self';
		  if (theform.action == 'FolderInspectionMemoDetail.jsp') {
		   //theform.where.value = "FolderRSN=" + parent.DetailDetailFrame.theform.FolderRSN.value;
		   theform.where.value = "FolderRSN=" + parent.DetailDetailFrame.theform.ProcessRSN.value;
		  } else {
		   theform.where.value = "ProcessRSN=" + parent.DetailDetailFrame.theform.ProcessRSN.value;
		  }
		 } else {
 		  theform.target = 'DetailFrame';
		  //used by pages like FolderProcessDetail.jsp
		  if (theform.argFolderRSN) {
		   theform.where.value = "FolderRSN=" + theform.argFolderRSN.value;
		  } else {
 		   if (theform.argPeopleRSN) {
		    theform.where.value = "PeopleRSN=" + theform.argPeopleRSN.value;
		   } else {
 		    if (theform.argPropertyRSN) {
		     theform.where.value = "PropertyRSN=" + theform.argPropertyRSN.value;
		    } else {
 		     if (theform.FolderRSN) {
		       theform.where.value = "FolderRSN=" + theform.FolderRSN.value;
		     }
		    }
		   }
		  }
 		 }
		 //alert(theform.where.value);
		 parent.parent.ListDetailQueryFrameSet.cols = "*, 780, 0";
		 theform.command.value = "retrieve";
		 theform.submit();
		 //f_ShowDetail(el.LinkTo, theform.lid.value, theform.where.value);
		}
		
	},
	hide:	function () {
		//alert('hide');
		var el = this.tab;
		var s = el.className;
		s = s.replace(/ selected/g, "");
		el.className = s;
		this.element.style.display = "none";
	},
	select:	function () {
		this.tabPanel.setSelectedIndex( this.index );
	}
};

f_TabPage.tabOver = function ( tabpage ) {
	var el = tabpage.tab;
	var s = el.className + " hover";
	s = s.replace(/ +/g, " ");
	el.className = s;
};

f_TabPage.tabOut = function ( tabpage ) {
	var el = tabpage.tab;
	var s = el.className;
	s = s.replace(/ hover/g, "");
	el.className = s;
};

function f_SetupAllTabs() {
	var all = document.getElementsByTagName( "*" );
	var l = all.length;
	var tabPanelRe = /tab\-pane/;
	var tabPageRe = /tab\-page/;
	var cn, el;
	var parentTabPane;
	for ( var i = 0; i < l; i++ ) {
		el = all[i]
		cn = el.className;
		if ( cn == "" ) continue;
		if ( tabPanelRe.test( cn ) && !el.tabPanel )
			new f_TabPanel( el );
		else if ( tabPageRe.test( cn ) && !el.tabPage &&
			tabPanelRe.test( el.parentNode.className ) ) {
			el.parentNode.tabPanel.addTabPage( el );			
		}
	}
}

function f_Indicator(argLabel) {
 //alert('f_indicator ' + argLabel);
 DivInnerHtml += '<td class="indicatorButton" tabIndex="1" onaction="f_Indicator' + argLabel + '();"><img src="images/' + argLabel + '.gif" align="absmiddle">&nbsp;' + argLabel + '</td>';
}

function f_IndicatorMoney(argLabel, argValue) {
 //alert('f_indicatorMoney' + argLabel + ' ' + argValue);
 DivInnerHtml += '<td class="indicatorButton" tabIndex="1" onaction="f_Indicator' + argLabel + '();"><img src="images/' + argLabel + '.gif" align="absmiddle">&nbsp;' + argValue + '&nbsp;' + argLabel + '</td>';
}

function f_IndicatorInit() {
 //alert('f_indicatorInit');
 DivInnerHtml = "";
}

function f_IndicatorShow() {
 //alert('f_indicatorShow start');
 var xWidth = document.body.clientWidth - 2 - 2;
 DivInnerHtml = '<table id="MenuToolbarIndicator" style=" position:absolute; TOP:4px;" cellspacing="1"><tr>' + DivInnerHtml + '</tr></table>';
 MenuToolbarId.innerHTML = MenuToolbarId.innerHTML + DivInnerHtml;
 var IndicatorTable = document.all.MenuToolbarIndicator;
 IndicatorTable.style.left = xWidth - IndicatorTable.offsetWidth;
 var IndicatorCells = IndicatorTable.rows[0].cells;
 for (var i = 0; i < IndicatorCells.length; i++) {
 	createButton(IndicatorCells[i]);
 	IndicatorCells[i].setAlwaysUp(true);
 }
 //alert('f_indicatorShow end');
}


function createButton(el) {

	el.attachEvent("onmouseover",	createButton.overindicatorButton);
	el.attachEvent("onmouseout",	createButton.outindicatorButton);
	el.attachEvent("onmousedown",	createButton.downindicatorButton);
	el.attachEvent("onmouseup",		createButton.upindicatorButton);
	el.attachEvent("onclick",		createButton.clickindicatorButton);
	el.attachEvent("ondblclick",	createButton.clickindicatorButton);
	el.attachEvent("onkeypress",	createButton.keypressindicatorButton);
	el.attachEvent("onkeyup",		createButton.keyupindicatorButton);
	el.attachEvent("onkeydown",		createButton.keydownindicatorButton);
	el.attachEvent("onfocus",		createButton.focusindicatorButton);
	el.attachEvent("onblur",		createButton.blurindicatorButton);
	
	el.className = "indicatorButton";
	
	el.setEnabled	= createButton.setEnabled;
	el.getEnabled	= createButton.getEnabled;
	el.setValue		= createButton.setValue;
	el.getValue		= createButton.getValue;
	el.setToggle	= createButton.setToggle;
	el.getToggle	= createButton.getToggle;
	el.setAlwaysUp	= createButton.setAlwaysUp;
	el.getAlwaysUp	= createButton.getAlwaysUp;
	
	el._enabled		= true;
	el._toggle		= false;
	el._value		= false;
	el._alwaysUp	= false;
	
	return el;
}

createButton.LEFT = window.moz ? 0 : 1;

/* event listeners */

createButton.overindicatorButton = function () {
	var toEl = createButton.getParentindicatorButton(window.event.toElement);
	var fromEl = createButton.getParentindicatorButton(window.event.fromElement);
	if (toEl == fromEl || toEl == null) return;
	
	toEl._over = true;
	
	if (!toEl._enabled) return;
	
	createButton.setClassName(toEl);
};

createButton.outindicatorButton = function () {
	var toEl = createButton.getParentindicatorButton(window.event.toElement);
	var fromEl = createButton.getParentindicatorButton(window.event.fromElement);
	if (toEl == fromEl || fromEl == null) return;
	
	fromEl._over = false;
	fromEl._down = false;
	
	if (!fromEl._enabled) return;	

	createButton.setClassName(fromEl);
};

createButton.downindicatorButton = function () {
	if (window.event.button != createButton.LEFT) return;
	
	var el = createButton.getParentindicatorButton(window.event.srcElement);
	if (el == null) return;
	
	el._down = true;
	
	if (!el._enabled) return;

	createButton.setClassName(el);
};

createButton.upindicatorButton = function () {
	if (window.event.button != createButton.LEFT) return;
	
	var el = createButton.getParentindicatorButton(window.event.srcElement);
	if (el == null) return;
	
	el._down = false;
	
	if (!el._enabled) return;
	
	if (el._toggle)
		el.setValue(!el._value);
	else
		createButton.setClassName(el);
};

createButton.clickindicatorButton = function () {
 	var el = createButton.getParentindicatorButton(window.event.srcElement);
	el.onaction = el.getAttribute("onaction");
	if (el == null || !el._enabled || el.onaction == "" || el.onaction == null) return;
	
	if (typeof el.onaction == "string")
		el.onaction = new Function ("event", el.onaction);
	
	el.onaction(window.event);
};

createButton.keypressindicatorButton = function () {
	var el = createButton.getParentindicatorButton(window.event.srcElement);
	if (el == null || !el._enabled || window.event.keyCode != 13) return;
	
	el.setValue(!el._value);
	
	if (el.onaction == null) return;
	
	if (typeof el.onaction == "string")
		el.onaction = new Function ("event", el.onaction);
	
	el.onaction(window.event);
};

createButton.keydownindicatorButton = function () {
	var el = createButton.getParentindicatorButton(window.event.srcElement);
	if (el == null || !el._enabled || window.event.keyCode != 32) return;
	createButton.downindicatorButton();
};

createButton.keyupindicatorButton = function () {
	var el = createButton.getParentindicatorButton(window.event.srcElement);
	if (el == null || !el._enabled || window.event.keyCode != 32) return;
	createButton.upindicatorButton();
	
	//el.setValue(!el._value);	// is handled in upindicatorButton()
	
	if (el.onaction == null) return;
	
	if (typeof el.onaction == "string")
		el.onaction = new Function ("event", el.onaction);
	
	el.onaction(window.event);
};

createButton.focusindicatorButton = function () {
	var el = createButton.getParentindicatorButton(window.event.srcElement);
	if (el == null || !el._enabled) return;
	createButton.setClassName(el);
};

createButton.blurindicatorButton = function () {
	var el = createButton.getParentindicatorButton(window.event.srcElement);
	if (el == null) return;
	
	createButton.setClassName(el)
};

createButton.getParentindicatorButton = function (el) {
	if (el == null) return null;
	if (/indicatorButton/.test(el.className))
		return el;
	return createButton.getParentindicatorButton(el.parentNode);
};

/* end event listeners */

createButton.setClassName = function (el) {
	var over = el._over;
	var down = el._down;
	var focused;
	try {
		focused = (el == document.activeElement && el.tabIndex > 0);
	}
	catch (exc) {
		focused = false;
	}
	
	if (!el._enabled) {
		if (el._value)
			el.className = "indicatorButtonActiveDisabled";
		else
			el.className = el._alwaysUp ? "indicatorButtonUpDisabled" : "indicatorButtonDisabled";
	}
	else {
		if (el._value) {
			if (over || down || focused)
				el.className = "indicatorButtonActiveHover";
			else
				el.className = "indicatorButtonActive";
		}
		else {
			if (down)
				el.className = "indicatorButtonActiveHover";
			else if (over || el._alwaysUp || focused)
				el.className = "indicatorButtonHover";
			else
				el.className = "indicatorButton";
		}
	}
};

createButton.setEnabled = function (b) {
	if (this._enabled != b) {
		this._enabled = b;
		createButton.setClassName(this, false, false);
		if (!window.moz) {
			if (b)
				this.innerHTML = this.firstChild.firstChild.innerHTML;
			else
				this.innerHTML = "<span class='indicatorButtonDisabledContainer'><span class='indicatorButtonDisabledContainer'>" + this.innerHTML + "</span></span>";
		}
	}
};

createButton.getEnabled = function () {
	return this._enabled;
};

createButton.setValue = function (v, bDontTriggerOnChange) {
	if (this._toggle && this._value != v) {
		this._value = v;
		createButton.setClassName(this, false, false);
		
		this.onchange = this.getAttribute("onchange");
		
		if (this.onchange == null || this.onchange == "" || bDontTriggerOnChange) return;
		
		if (typeof this.onchange == "string")
			this.onchange = new Function("", this.onchange);

		this.onchange();
	}
};

createButton.getValue = function () {
	return this._value;
};

createButton.setToggle = function (t) {
	if (this._toggle != t) {
		this._toggle = t;
		if (!t) this.setValue(false);
	}
};

createButton.getToggle = function () {
	return this._toggle;
};

createButton.setAlwaysUp = function (up) {
	if (this._alwaysUp != up) {
		this._alwaysUp = up;
		createButton.setClassName(this, false, false);
	}
};

createButton.getAlwaysUp = function () {
	return this._alwaysUp;
};

function f_accept() {
 var p = document.all.pick;
 if (!p) {
  alert('Not a pickable window');
  return;
 }
 var thePickValue = p.value;
 //alert(thePickValue);
 var thePickValue3 = thePickValue.substr(0,3);
 if (f_left(thePickValue3,1) == '0') {thePickValue3 = f_mid(thePickValue3,2);}
 if (f_left(thePickValue3,1) == '0') {thePickValue3 = f_mid(thePickValue3,2);}
 var thePickRow = parseInt(thePickValue3);
 //alert(thePickRow);
 thePickValue = thePickValue.substr(4,999);
 var thePairs = thePickValue.split('|');
 var w = 0;
 if (window.opener) {
  w = window.opener;
 } else {
  w = parent.parent.parent.parent.opener;
 }
 var a = w.document.theform;
 for (var i = 0; i < thePairs.length; i++) {
  var theFields = thePairs[i].split(',');
  //alert(i + ': ' + theFields[0] + ' , ' + theFields[1]);
  var theValue = theform.item(theFields[0]).value;
  if (thePickRow == 0) {
   temp1 = eval('a.'+theFields[1]);
   temp1.value = theValue;
   //alert(temp1.onchange);
   if ( temp1.onchange ) {
    temp1.onchange();
   }
  } else {
   temp = eval('a.'+theFields[1]+ '_' + thePickRow);
   temp.value = theValue;
   temp.onchange();
  }
 }
 if (parent.parent.parent.parent) {
  parent.parent.parent.parent.close();
 } else {
  window.close();
 }
}

function f_ClickChoose(argSpan) {
 //alert('clickchoose row = ' + chooseRow + ', ' + argSpan.innerText) ;
 var infovalue = theform.item('InfoValue_' + chooseRow);
 infovalue.value = argSpan.innerText;
 infovalue.onchange();
 
 var chooseDiv = document.all.item('choose_' + chooseRow);
 chooseDiv.style.visibility='hidden'
 
 infovalue.focus()
}

function f_PickChoose(argRow) {
 //alert("PosX: " + posX + "  PosY: " + posY);
 chooseRow = argRow;
 var chooseDiv = document.all.item('choose_' + argRow);
 //var chooseDiv = document.getElelemtById("choose_" + argRow);
 //Changing the position 

 //chooseDiv.style.left = posX - 360; 
 //chooseDiv.style.top = posY - 85;
 chooseDiv.style.visibility='visible';
 chooseDiv.focus();
 
}

function getXY(e) {
  posX = (window.Event) ? e.pageX : event.clientX;
  posY = (window.Event) ? e.pageY : event.clientY;
  
  //var coord = getPageEventCoords(e);
  //var coord = getPositionedEventCoords(e);
  //posX = coord.left;
  //posY = coord.top;
}

function getPageEventCoords(evt) {
    var coords = {left:0, top:0};
    if (evt.pageX) {
        coords.left = evt.pageX;
        coords.top = evt.pageY;
    } else if (evt.clientX) {
        coords.left = 
            evt.clientX + document.body.scrollLeft - document.body.clientLeft;
        coords.top = 
            evt.clientY + document.body.scrollTop - document.body.clientTop;
        // include html element space, if applicable
        if (document.body.parentElement && document.body.parentElement.clientLeft) {
            var bodParent = document.body.parentElement;
            coords.left += bodParent.scrollLeft - bodParent.clientLeft;
            coords.top += bodParent.scrollTop - bodParent.clientTop;
        }
    }
    return coords;
}


function getPositionedEventCoords(evt) {
    var elem = (evt.target) ? evt.target : evt.srcElement;
    var coords = {left:0, top:0};
    if (evt.layerX) {
        var borders = {left:parseInt(getElementStyle("progressBar", 
                       "borderLeftWidth", "border-left-width")),
                       top:parseInt(getElementStyle("progressBar", 
                       "borderTopWidth", "border-top-width"))};
        coords.left = evt.layerX - borders.left;
        coords.top = evt.layerY - borders.top;
    } else if (evt.offsetX) {
        coords.left = evt.offsetX;
        coords.top = evt.offsetY;
    }
    evt.cancelBubble = true;
    return coords;
}

function f_PickDate(argElement) {
 d = parseDate(argElement.value);
 if (d == null) { d = new Date(); }
 var pd = new PickDate(d, argElement);
 if ( !oPopup.document.all('DateStyle') ) { //add style the first time
    var elementDateStyle = oPopup.document.createElement("<style id=DateStyle>");
    oPopup.document.body.insertBefore(elementDateStyle);
    var styleSheetsDateStyle =  oPopup.document.styleSheets["DateStyle"];
    styleSheetsDateStyle.addRule(".PickDate"," { border:1px solid WindowText; background:Window; width:170px; padding:0px; cursor:default; -moz-user-focus:normal; position:absolute;  }");
    styleSheetsDateStyle.addRule(".PickDate td"," { font:smallcaption; font:small-caption; text-align:center; color:WindowText; cursor:default; font-weight:normal !important; -moz-user-select:none; padding:0; }");
    styleSheetsDateStyle.addRule(".PickDate td.red"," { color:red; }");
    styleSheetsDateStyle.addRule(".PickDate .header"," { background:ActiveCaption; padding:3px; border-bottom:1px solid WindowText; }");
    styleSheetsDateStyle.addRule(".PickDate .headerTable"," { width:100%; }");
    styleSheetsDateStyle.addRule(".PickDate .footer"," { padding:3px; }");
    styleSheetsDateStyle.addRule(".PickDate .footerTable"," { width:100%; }");
    styleSheetsDateStyle.addRule(".PickDate .grid"," { padding:3px; }");
    styleSheetsDateStyle.addRule(".PickDate .gridTable"," { width:100%; }");
    styleSheetsDateStyle.addRule(".PickDate .gridTable td"," { width:14.3%; }");
    styleSheetsDateStyle.addRule(".PickDate .gridTable .daysRow td"," { font-weight:bold !important; border-bottom:1px solid ThreeDDarkShadow; }");
    styleSheetsDateStyle.addRule(".PickDate .grid .gridTable .upperLine"," { width:100%; height:2px; overflow:hidden; background:transparent; }");
    styleSheetsDateStyle.addRule(".PickDate td.today"," { font-weight:bold !important; }");
    styleSheetsDateStyle.addRule(".PickDate td.selected"," { background:Highlight; color:HighlightText !important; }");
    styleSheetsDateStyle.addRule(".PickDate td.labelContainer"," { width:100%; }");
    styleSheetsDateStyle.addRule(".PickDate td .topLabel"," { color:CaptionText; display:block; font-weight:bold !important; width:100%; text-decoration:none; }");
    styleSheetsDateStyle.addRule(".PickDate td.filler"," { width:100%; }");
    styleSheetsDateStyle.addRule(".PickDate button"," { border-width:1px; font:Caption; font-weight:normal !important; }");
    styleSheetsDateStyle.addRule(".PickDate .previousButton"," { background:buttonface url(\"images/arrow.left.png\") no-repeat center center; }");
    styleSheetsDateStyle.addRule(".PickDate .nextButton"," { background:buttonface url(\"images/arrow.right.png\") no-repeat center center; }");
    styleSheetsDateStyle.addRule(".PickDate .previousButton"," { width:14px; height:14px; }");
    styleSheetsDateStyle.addRule(".PickDate .nextButton"," { width:14px; height:14px; }");
    styleSheetsDateStyle.addRule(".PickDate .todayButton"," { width:50px; }");
    styleSheetsDateStyle.addRule(".PickDate .acceptButton"," { width:50px; }");
    styleSheetsDateStyle.addRule(".PickDate .noneButton"," { width:50px; }");
    styleSheetsDateStyle.addRule(".PickDate .labelPopup"," { position:absolute; min-width:130px; background:Window; border:1px solid WindowText; padding:1px; }");
    styleSheetsDateStyle.addRule(".PickDate .labelPopup a"," { width:100%; display:block; color:WindowText; text-decoration:none; white-space:nowrap; }");
    styleSheetsDateStyle.addRule(".PickDate .labelPopup a:hover"," { background:Highlight; color:HighlightText; }");
    styleSheetsDateStyle.addRule(".PickDate .labelPopup a.selected"," { font-weight:bold; }");
  }
 oPopup.document.body.appendChild(pd.create());
 //oPopup.show(argElement.offsetLeft, argElement.offsetTop, 176, 147, document.body);
 oPopup.show(argElement.offsetLeft+250, argElement.offsetTop, 176, 147, document.body); //for WinXP
}

// The PickDate constructor
// oDate : Date Optional argument representing the date to select
function PickDate( oDate, oElement ) {
	// check arguments
	if ( arguments.length == 0 ) {
		this._selectedDate = new Date;
		this._none = false;
	}
	else {
		this._selectedDate = oDate || new Date();
		this._none = oDate == null;
	}
	
	this._matrix = [[],[],[],[],[],[],[]];
	this._showNone = true;
	this._showToday = true;
	this._firstWeekDay = 6;	// start week with monday according to standards (0..6)
	this._redWeekDay = 6;	// sunday is the default red day.
	
	this._dontChangeNone = false;
	
	this._dateElement = oElement;
}

// two static fields describing the name of the months abd days
PickDate.months = [
	"January", "February", "March", "April",
	"May", "June", "July", "August",
	"September", "October", "November", "December"];
PickDate.days = ["m", "t", "w", "t", "f", "s", "s"];


PickDate.prototype.onchange = function () {};

// create the nodes inside the date picker
PickDate.prototype.create = function ( doc ) {
	if ( doc == null ) doc = oPopup.document;

	this._document = doc;

	// create elements
	this._el = doc.createElement( "div" );
	this._el.className = "PickDate";
	this._el.id = "PickDate";
	
	//this._el.style.top = this._dateElement.offsetTop;
	//this._el.style.left = this._dateElement.offsetLeft;
	//this._el.style.zIndex = 0;
	
	// header
	var div = doc.createElement( "div" );
	div.className = "header";
	this._el.appendChild( div );
	
	var headerTable = doc.createElement( "table" );
	headerTable.className = "headerTable";
	headerTable.cellSpacing = 0;
	div.appendChild( headerTable );
	
	var tBody = doc.createElement( "tbody" );
	headerTable.appendChild( tBody );
	
	var tr = doc.createElement( "tr" );
	tBody.appendChild( tr );
	
	var td = doc.createElement( "td" );
	this._previousMonth = doc.createElement( "button" );
	this._previousMonth.className = "previousButton";
	td.appendChild( this._previousMonth );
	tr.appendChild( td );
	
	td = doc.createElement( "td" );
	td.className = "labelContainer";
	tr.appendChild( td );
	
	this._topLabel = doc.createElement( "a" );
	this._topLabel.className = "topLabel";
	this._topLabel.href = "#";
	this._topLabel.appendChild( doc.createTextNode( String.fromCharCode( 160 ) ) );
	td.appendChild( this._topLabel );
	
	this._labelPopup = doc.createElement( "div" );
	this._labelPopup.className = "labelPopup";
	// no insertion
	
	td = doc.createElement( "td" );
	this._nextMonth = doc.createElement( "button" );
	this._nextMonth.className = "nextButton";
	td.appendChild( this._nextMonth );
	tr.appendChild( td );
	
	// grid
	div = doc.createElement( "div" );
	div.className = "grid";
	this._el.appendChild( div );
	this._table = div;
	
	// footer
	div = doc.createElement( "div" );
	div.className = "footer";
	this._el.appendChild( div );
	
	var footerTable = doc.createElement( "table" );
	footerTable.className = "footerTable";
	footerTable.cellSpacing = 0;
	div.appendChild( footerTable );
	
	tBody = doc.createElement( "tbody" );
	footerTable.appendChild( tBody );
	
	tr = doc.createElement( "tr" );
	tBody.appendChild( tr );
	
	td = doc.createElement( "td" );
	this._todayButton = doc.createElement( "button" );
	this._todayButton.className = "todayButton";
	this._todayButton.appendChild( doc.createTextNode( "Today" ) );
	td.appendChild( this._todayButton );
	tr.appendChild( td );
	
	td = doc.createElement( "td" );
	td.className = "filler";
	td.appendChild( doc.createTextNode( String.fromCharCode( 160 ) ) );
	tr.appendChild( td );
	
	//td = doc.createElement( "td" );
	//this._noneButton = doc.createElement( "button" );
	//this._noneButton.className = "noneButton";
	//this._noneButton.appendChild( doc.createTextNode( "None" ) );
	//td.appendChild( this._noneButton );
	//tr.appendChild( td );
	
	td = doc.createElement( "td" );
	this._acceptButton = doc.createElement( "button" );
	this._acceptButton.className = "acceptButton";
	this._acceptButton.appendChild( doc.createTextNode( "Accept" ) );
	td.appendChild( this._acceptButton );
	tr.appendChild( td );
	
	this._createTable( doc );
	
	this._updateTable();
	this._setTopLabel();

	//if ( !this._showNone )
	//	this._noneButton.style.visibility = "hidden";
	if ( !this._showToday )
		this._todayButton.style.visibility = "hidden";

	// IE55+ extension		
	this._previousMonth.hideFocus = true;
	this._nextMonth.hideFocus = true;
	this._todayButton.hideFocus = true;
	//this._noneButton.hideFocus = true;
	this._acceptButton.hideFocus = true;
	// end IE55+ extension
	
	// hook up events
	var pd = this;
	// buttons
	this._previousMonth.onclick = function () {
		pd._dontChangeNone = true;
		pd.goToPreviousMonth();
		pd._dontChangeNone = false;
	};
	this._nextMonth.onclick = function () {
		pd._dontChangeNone = true;
		pd.goToNextMonth();
		pd._dontChangeNone = false;
	};
	this._todayButton.onclick = function () {
		pd.goToToday();
	};
	//this._noneButton.onclick = function () {
	//	pd.setDate( null );
	//};
	
	//**************************************************************
	//**************************************************************
	this._acceptButton.onclick = function () {
		var d = pd.getDate();
		var f = formatDate(d, "NNN d, y");
		pd._dateElement.value = f;
		if ( pd._dateElement.onchange ) {
		 pd._dateElement.onchange();
   		}
		pd._el.removeNode(true);
		oPopup.hide();
	};
	//**************************************************************
	//**************************************************************

	this._el.onselectstart = function () {
		return false;
	};
	
	this._table.onclick = function ( e ) {
		// find event
		if ( e == null ) e = doc.parentWindow.event;
		
		// find td
		var el = e.target != null ? e.target : e.srcElement;
		while ( el.nodeType != 1 )
			el = el.parentNode;
		while ( el != null && el.tagName && el.tagName.toLowerCase() != "td" )
			el = el.parentNode;
		
		// if no td found, return
		if ( el == null || el.tagName == null || el.tagName.toLowerCase() != "td" )
			return;
		
		var d = new Date( pd._selectedDate );
		var n = Number( el.firstChild.data );
		if ( isNaN( n ) || n <= 0 || n == null )
			return;
			
		d.setDate( n );
		pd.setDate( d );
	};
	
	// show popup
	this._topLabel.onclick = function ( e ) {
		pd._showLabelPopup();
		return false;
	};
	
	this._el.onkeydown = function ( e ) {
		if ( e == null ) e = doc.parentWindow.event;
		var kc = e.keyCode != null ? e.keyCode : e.charCode;
		
		if ( kc < 37 || kc > 40 ) return true;
		
		var d = new Date( pd._selectedDate ).valueOf();
		if ( kc == 37 ) // left
			d -= 24 * 60 * 60 * 1000;
		else if ( kc == 39 ) // right
			d += 24 * 60 * 60 * 1000;
		else if ( kc == 38 ) // up
			d -= 7 * 24 * 60 * 60 * 1000;
		else if ( kc == 40 ) // down
			d += 7 * 24 * 60 * 60 * 1000;

		pd.setDate( new Date( d ) );
		return false;
	}
	
	// ie6 extension
	this._el.onmousewheel = function ( e ) {
		if ( e == null ) e = doc.parentWindow.event;
		var n = - e.wheelDelta / 120;
		var d = new Date( pd._selectedDate );
		var m = d.getMonth() + n;
		d.setMonth( m );
		
		
		pd._dontChangeNone = true;
		pd.setDate( d );
		pd._dontChangeNone = false;
		
		return false;
	}
	
	return this._el;
};

PickDate.prototype.setDate = function ( oDate ) {

	this._hideLabelPopup();

	// if null then set None
	if ( oDate == null ) {
		if ( !this._none ) {
			this._none = true;
			this._setTopLabel();
			this._updateTable();
			
			if ( typeof this.onchange == "function" )
				this.onchange();	
		}
		return;
	}

	// if string or number create a Date object
	if ( typeof oDate == "string" || typeof oDate == "number" ) {
		oDate = new Date( oDate );
	}
	
	
	// do not update if not really changed
	if ( this._selectedDate.getDate() != oDate.getDate() ||
		this._selectedDate.getMonth() != oDate.getMonth() || 
		this._selectedDate.getFullYear() != oDate.getFullYear() ||
		this._none ) {
		
		if ( !this._dontChangeNone )
			this._none = false;
		
		this._selectedDate = new Date( oDate );
	
		this._setTopLabel();
		this._updateTable();
		
		if ( typeof this.onchange == "function" )
			this.onchange();
	}
	
	if ( !this._dontChangeNone )
		this._none = false;
}


PickDate.prototype.getDate = function () {
	if ( this._none ) return null;
	return new Date( this._selectedDate );	// create a new instance
}

// creates the table elements and inserts them into the date picker
PickDate.prototype._createTable = function ( doc ) {
	var str, i;
	var rows = 6;
	var cols = 7;
	var currentWeek = 0;

	var table = doc.createElement( "table" );
	table.className = "gridTable";
	table.cellSpacing = 0;
	
	var tBody = doc.createElement( "tbody" );
	table.appendChild( tBody );
	
	// days row
	var tr = doc.createElement( "tr" );
	tr.className = "daysRow";

	var td, tn;
	var nbsp = String.fromCharCode( 160 );
	for ( i = 0; i < cols; i++ ) {
		td = doc.createElement( "td" );
		td.appendChild( doc.createTextNode( nbsp ) );
		tr.appendChild( td );
	}
	tBody.appendChild( tr );
	
	// upper line
	tr = doc.createElement( "tr" );
	td = doc.createElement( "td" );
	td.className = "upperLine";
	td.colSpan = 7;
	tr.appendChild( td );
	tBody.appendChild( tr );

	// rest
	for ( i = 0; i < rows; i++ ) {
		tr = doc.createElement( "tr" );
		for ( var j = 0; j < cols; j++ ) {
			td = doc.createElement( "td" );
			td.appendChild( doc.createTextNode( nbsp ) );
			tr.appendChild( td );
		}
		tBody.appendChild( tr );
	}
	str += "</table>";
	
	if ( this._table != null )
		this._table.appendChild( table )
};
// this method updates all the text nodes inside the table as well
// as all the classNames on the tds
PickDate.prototype._updateTable = function () {
	// if no element no need to continue
	if ( this._table == null ) return;
	
	var i;
	var str = "";
	var rows = 6;
	var cols = 7;
	var currentWeek = 0;
		
	var cells = new Array( rows );
	this._matrix = new Array( rows )
	for ( i = 0; i < rows; i++ ) {
		cells[i] = new Array( cols );
		this._matrix[i] = new Array( cols );
	}

	// Set the tmpDate to this month
	var tmpDate = new Date( this._selectedDate.getFullYear(),
							this._selectedDate.getMonth(), 1 );
	var today = new Date();
	// go thorugh all days this month and store the text
	// and the class name in the cells matrix
	for ( i = 1; i < 32; i++ ) {
		tmpDate.setDate( i );
		// convert to ISO, Monday is 0 and 6 is Sunday
		var weekDay = ( tmpDate.getDay() + 6 ) % 7;
		var colIndex = ( weekDay - this._firstWeekDay + 7 ) % 7;
		if ( tmpDate.getMonth() == this._selectedDate.getMonth() ) {

			var isToday = tmpDate.getDate() == today.getDate() && 
						tmpDate.getMonth() == today.getMonth() &&
						tmpDate.getFullYear() == today.getFullYear();
		
			cells[currentWeek][colIndex] = { text: "", className: "" };
			
			if ( this._selectedDate.getDate() == tmpDate.getDate() && !this._none )
				cells[currentWeek][colIndex].className += "selected ";
			if ( isToday )
				cells[currentWeek][colIndex].className += "today ";
			if ( ( tmpDate.getDay() + 6 ) % 7 == this._redWeekDay ) // ISO
				cells[currentWeek][colIndex].className += "red";
			
			cells[currentWeek][colIndex].text =			
				this._matrix[currentWeek][colIndex] = tmpDate.getDate();
			
			if ( colIndex == 6 )
				currentWeek++;			
		}
	}
	
	// fix day letter order if not standard
	var weekDays = PickDate.days;												
	if (this._firstWeekDay != 0) {
		weekDays = new Array(7);
		for ( i = 0; i < 7; i++)
			weekDays[i] = PickDate.days[ (i + this._firstWeekDay) % 7];
	}

	// update text in days row
	var tds = this._table.firstChild.tBodies[0].rows[0].cells;
	for ( i = 0; i < cols; i++ )
		tds[i].firstChild.data = weekDays[i];
		
	// update the text nodes and class names
	var trs = this._table.firstChild.tBodies[0].rows;
	var tmpCell;
	var nbsp = String.fromCharCode( 160 );
	for ( var y = 0; y < rows; y++ ) {
		for (var x = 0; x < cols; x++) {
			tmpCell = trs[y + 2].cells[x];
			if ( typeof cells[y][x] != "undefined" ) {
				tmpCell.className = cells[y][x].className;
				tmpCell.firstChild.data = cells[y][x].text;
			}
			else {
				tmpCell.className = "";
				tmpCell.firstChild.data = nbsp;
			}
		}
	}
}

// sets the label showing the year and selected month
PickDate.prototype._setTopLabel = function () {
	var str = this._selectedDate.getFullYear() + " " + PickDate.months[ this._selectedDate.getMonth() ];
	if ( this._topLabel != null )
		this._topLabel.lastChild.data = str;
}

PickDate.prototype.goToNextMonth = function () {
	var d = new Date( this._selectedDate );
	d.setMonth( d.getMonth() + 1 );
	this.setDate( d );
}

PickDate.prototype.goToPreviousMonth = function () {
	var d = new Date( this._selectedDate );
	d.setMonth( d.getMonth() - 1 );
	this.setDate( d );
}

PickDate.prototype.goToToday = function () {
	if ( this._none )
		// change the selectedDate to force update if none was true
		this._selectedDate = new Date( this._selectedDate + 10000000000 );
	this._none = false;
	this.setDate( new Date() );
}

PickDate.prototype.setShowToday = function ( bShowToday ) {
	if ( typeof bShowToday == "string" )
		bShowToday = !/false|0|no/i.test( bShowToday );
		
	if ( this._todayButton != null )
		this._todayButton.style.visibility = bShowToday ? "visible" : "hidden";
	this._showToday = bShowToday;
}

PickDate.prototype.getShowToday = function () {
	return this._showToday;
}

//PickDate.prototype.setShowNone = function ( bShowNone ) {
//	if ( typeof bShowNone == "string" )
//		bShowNone = !/false|0|no/i.test( bShowNone );
//
//	if ( this._noneButton != null )
//		this._noneButton.style.visibility = bShowNone ? "visible" : "hidden";
//	this._showNone = bShowNone;
//}
//
//PickDate.prototype.getShowNone = function () {
//	return this._showNone;
//}

PickDate.prototype.setAcceptNone = function ( bAcceptNone ) {
	if ( typeof bAcceptNone == "string" )
		bAcceptNone = !/false|0|no/i.test( bAcceptNone );

	if ( this._acceptButton != null )
		this._acceptButton.style.visibility = bAcceptNone ? "visible" : "hidden";
	this._acceptNone = bAcceptNone;
}

PickDate.prototype.getAcceptNone = function () {
	return this._acceptNone;
}

// 0 is monday and 6 is sunday as in the ISO standard
PickDate.prototype.setFirstWeekDay = function ( nFirstWeekDay ) {
	if ( this._firstWeekDay != nFirstWeekDay ) {
		this._firstWeekDay = nFirstWeekDay;
		this._updateTable();
	}
}

PickDate.prototype.getFirstWeekDay = function () {
	return this._firstWeekDay;
}

// 0 is monday and 6 is sunday as in the ISO standard
PickDate.prototype.setRedWeekDay = function ( nRedWeekDay ) {
	if ( this._redWeekDay != nRedWeekDay ) {
		this._redWeekDay = nRedWeekDay;
		this._updateTable();
	}
}

PickDate.prototype.getRedWeekDay = function () {
	return this._redWeekDay;
}


PickDate.prototype._showLabelPopup = function () {
	
	/*
	this._labelPopup document.createElement( "DIV" );
	div.className = "month-popup";
	div.noWrap = true;
	el.unselectable = div.unselectable = "on";
	el.onselectstart = div.onselectstart = function () { return false; };
	*/
	
	var dateContext = function ( pd, d ) {
		return function ( e ) {
			pd._dontChangeNone = true;
			pd._hideLabelPopup();
			pd.setDate( d );
			pd._dontChangeNone = false;
			return false;
		};
	};
	
	var pd = this;
	
	// clear all old elements in the popup
	while ( this._labelPopup.hasChildNodes() )
		this._labelPopup.removeChild( this._labelPopup.firstChild );
	
	var a, tmp;
	for ( var i = -3; i < 4; i++ ) {
		tmp = new Date( this._selectedDate );
		tmp.setDate(1);	// set day to 1 to prevent overflow with shorter months
		tmp.setMonth( tmp.getMonth() + i );
		
		a = this._document.createElement( "a" );
		a.href = "javascript:void 0;";
		a.onclick = dateContext( pd, tmp );
		a.appendChild( this._document.createTextNode( tmp.getFullYear() + " " +
									PickDate.months[ tmp.getMonth() ] ) );
		if ( i == 0 )
			a.className = "selected";
		this._labelPopup.appendChild( a );
	}
	
	this._topLabel.parentNode.insertBefore( this._labelPopup, this._topLabel.parentNode.firstChild );
};

PickDate.prototype._hideLabelPopup = function () {
	if ( this._labelPopup.parentNode )
		this._labelPopup.parentNode.removeChild( this._labelPopup );
};

// ------------------------------------------------------------------
// These functions use the same 'format' strings as the 
// java.text.SimpleDateFormat class, with minor exceptions.
// The format string consists of the following abbreviations:
// 
// Field        | Full Form          | Short Form
// -------------+--------------------+-----------------------
// Year         | yyyy (4 digits)    | yy (2 digits), y (2 or 4 digits)
// Month        | MMM (name or abbr.)| MM (2 digits), M (1 or 2 digits)
//              | NNN (abbr.)        |
// Day of Month | dd (2 digits)      | d (1 or 2 digits)
// Day of Week  | EE (name)          | E (abbr)
// Hour (1-12)  | hh (2 digits)      | h (1 or 2 digits)
// Hour (0-23)  | HH (2 digits)      | H (1 or 2 digits)
// Hour (0-11)  | KK (2 digits)      | K (1 or 2 digits)
// Hour (1-24)  | kk (2 digits)      | k (1 or 2 digits)
// Minute       | mm (2 digits)      | m (1 or 2 digits)
// Second       | ss (2 digits)      | s (1 or 2 digits)
// AM/PM        | a                  |
//
// NOTE THE DIFFERENCE BETWEEN MM and mm! Month=MM, not mm!
// Examples:
//  "MMM d, y" matches: January 01, 2000
//                      Dec 1, 1900
//                      Nov 20, 00
//  "M/d/yy"   matches: 01/20/00
//                      9/2/00
//  "MMM dd, yyyy hh:mm:ssa" matches: "January 01, 2000 12:30:45AM"
// ------------------------------------------------------------------


function LZ(x) {return(x<0||x>9?"":"0")+x}


// ------------------------------------------------------------------
// isDate ( date_string, format_string )
// Returns true if date string matches format of format string and
// is a valid date. Else returns false.
// It is recommended that you trim whitespace around the value before
// passing it to this function, as whitespace is NOT ignored!
// ------------------------------------------------------------------
function isDate(val,format) {
	var date=getDateFromFormat(val,format);
	if (date==0) { return false; }
	return true;
	}

// -------------------------------------------------------------------
// compareDates(date1,date1format,date2,date2format)
//   Compare two date strings to see which is greater.
//   Returns:
//   1 if date1 is greater than date2
//   0 if date2 is greater than date1 of if they are the same
//  -1 if either of the dates is in an invalid format
// -------------------------------------------------------------------
function compareDates(date1,dateformat1,date2,dateformat2) {
	var d1=getDateFromFormat(date1,dateformat1);
	var d2=getDateFromFormat(date2,dateformat2);
	if (d1==0 || d2==0) {
		return -1;
		}
	else if (d1 > d2) {
		return 1;
		}
	return 0;
	}

// ------------------------------------------------------------------
// formatDate (date_object, format)
// Returns a date in the output format specified.
// The format string uses the same abbreviations as in getDateFromFormat()
// ------------------------------------------------------------------
function formatDate(date,format) {
	format=format+"";
	var result="";
	var i_format=0;
	var c="";
	var token="";
	var y=date.getYear()+"";
	var M=date.getMonth()+1;
	var d=date.getDate();
	var E=date.getDay();
	var H=date.getHours();
	var m=date.getMinutes();
	var s=date.getSeconds();
	var yyyy,yy,MMM,MM,dd,hh,h,mm,ss,ampm,HH,H,KK,K,kk,k;
	// Convert real date parts into formatted versions
	var value=new Object();
	if (y.length < 4) {y=""+(y-0+1900);}
	value["y"]=""+y;
	value["yyyy"]=y;
	value["yy"]=y.substring(2,4);
	value["M"]=M;
	value["MM"]=LZ(M);
	value["MMM"]=MONTH_NAMES[M-1];
	value["NNN"]=MONTH_NAMES[M+11];
	value["d"]=d;
	value["dd"]=LZ(d);
	value["E"]=DAY_NAMES[E+7];
	value["EE"]=DAY_NAMES[E];
	value["H"]=H;
	value["HH"]=LZ(H);
	if (H==0){value["h"]=12;}
	else if (H>12){value["h"]=H-12;}
	else {value["h"]=H;}
	value["hh"]=LZ(value["h"]);
	if (H>11){value["K"]=H-12;} else {value["K"]=H;}
	value["k"]=H+1;
	value["KK"]=LZ(value["K"]);
	value["kk"]=LZ(value["k"]);
	if (H > 11) { value["a"]="PM"; }
	else { value["a"]="AM"; }
	value["m"]=m;
	value["mm"]=LZ(m);
	value["s"]=s;
	value["ss"]=LZ(s);
	while (i_format < format.length) {
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		if (value[token] != null) { result=result + value[token]; }
		else { result=result + token; }
		}
	return result;
	}
	
// ------------------------------------------------------------------
// Utility functions for parsing in getDateFromFormat()
// ------------------------------------------------------------------
function _isInteger(val) {
	var digits="1234567890";
	for (var i=0; i < val.length; i++) {
		if (digits.indexOf(val.charAt(i))==-1) { return false; }
		}
	return true;
	}
function _getInt(str,i,minlength,maxlength) {
	for (var x=maxlength; x>=minlength; x--) {
		var token=str.substring(i,i+x);
		if (token.length < minlength) { return null; }
		if (_isInteger(token)) { return token; }
		}
	return null;
	}
	
// ------------------------------------------------------------------
// getDateFromFormat( date_string , format_string )
//
// This function takes a date string and a format string. It matches
// If the date string matches the format string, it returns the 
// getTime() of the date. If it does not match, it returns 0.
// ------------------------------------------------------------------
function getDateFromFormat(val,format) {
	val=val+"";
	format=format+"";
	var i_val=0;
	var i_format=0;
	var c="";
	var token="";
	var token2="";
	var x,y;
	var now=new Date();
	var year=now.getYear();
	var month=now.getMonth()+1;
	var date=1;
	var hh=now.getHours();
	var mm=now.getMinutes();
	var ss=now.getSeconds();
	var ampm="";
	
	while (i_format < format.length) {
		// Get next token from format string
		c=format.charAt(i_format);
		token="";
		while ((format.charAt(i_format)==c) && (i_format < format.length)) {
			token += format.charAt(i_format++);
			}
		// Extract contents of value based on format token
		if (token=="yyyy" || token=="yy" || token=="y") {
			if (token=="yyyy") { x=4;y=4; }
			if (token=="yy")   { x=2;y=2; }
			if (token=="y")    { x=2;y=4; }
			year=_getInt(val,i_val,x,y);
			if (year==null) { return 0; }
			i_val += year.length;
			if (year.length==2) {
				if (year > 70) { year=1900+(year-0); }
				else { year=2000+(year-0); }
				}
			}
		else if (token=="MMM"||token=="NNN"){
			month=0;
			for (var i=0; i<MONTH_NAMES.length; i++) {
				var month_name=MONTH_NAMES[i];
				if (val.substring(i_val,i_val+month_name.length).toLowerCase()==month_name.toLowerCase()) {
					if (token=="MMM"||(token=="NNN"&&i>11)) {
						month=i+1;
						if (month>12) { month -= 12; }
						i_val += month_name.length;
						break;
						}
					}
				}
			if ((month < 1)||(month>12)){return 0;}
			}
		else if (token=="EE"||token=="E"){
			for (var i=0; i<DAY_NAMES.length; i++) {
				var day_name=DAY_NAMES[i];
				if (val.substring(i_val,i_val+day_name.length).toLowerCase()==day_name.toLowerCase()) {
					i_val += day_name.length;
					break;
					}
				}
			}
		else if (token=="MM"||token=="M") {
			month=_getInt(val,i_val,token.length,2);
			if(month==null||(month<1)||(month>12)){return 0;}
			i_val+=month.length;}
		else if (token=="dd"||token=="d") {
			date=_getInt(val,i_val,token.length,2);
			if(date==null||(date<1)||(date>31)){return 0;}
			i_val+=date.length;}
		else if (token=="hh"||token=="h") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>12)){return 0;}
			i_val+=hh.length;}
		else if (token=="HH"||token=="H") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>23)){return 0;}
			i_val+=hh.length;}
		else if (token=="KK"||token=="K") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<0)||(hh>11)){return 0;}
			i_val+=hh.length;}
		else if (token=="kk"||token=="k") {
			hh=_getInt(val,i_val,token.length,2);
			if(hh==null||(hh<1)||(hh>24)){return 0;}
			i_val+=hh.length;hh--;}
		else if (token=="mm"||token=="m") {
			mm=_getInt(val,i_val,token.length,2);
			if(mm==null||(mm<0)||(mm>59)){return 0;}
			i_val+=mm.length;}
		else if (token=="ss"||token=="s") {
			ss=_getInt(val,i_val,token.length,2);
			if(ss==null||(ss<0)||(ss>59)){return 0;}
			i_val+=ss.length;}
		else if (token=="a") {
			if (val.substring(i_val,i_val+2).toLowerCase()=="am") {ampm="AM";}
			else if (val.substring(i_val,i_val+2).toLowerCase()=="pm") {ampm="PM";}
			else {return 0;}
			i_val+=2;}
		else {
			if (val.substring(i_val,i_val+token.length)!=token) {return 0;}
			else {i_val+=token.length;}
			}
		}
	// If there are any trailing characters left in the value, it doesn't match
	if (i_val != val.length) { return 0; }
	// Is date valid for month?
	if (month==2) {
		// Check for leap year
		if ( ( (year%4==0)&&(year%100 != 0) ) || (year%400==0) ) { // leap year
			if (date > 29){ return 0; }
			}
		else { if (date > 28) { return 0; } }
		}
	if ((month==4)||(month==6)||(month==9)||(month==11)) {
		if (date > 30) { return 0; }
		}
	// Correct hours value
	if (hh<12 && ampm=="PM") { hh=hh-0+12; }
	else if (hh>11 && ampm=="AM") { hh-=12; }
	var newdate=new Date(year,month-1,date,hh,mm,ss);
	return newdate.getTime();
	}

// ------------------------------------------------------------------
// parseDate( date_string [, prefer_euro_format] )
//
// This function takes a date string and tries to match it to a
// number of possible date formats to get the value. It will try to
// match against the following international formats, in this order:
// y-M-d   MMM d, y   MMM d,y   y-MMM-d   d-MMM-y  MMM d
// M/d/y   M-d-y      M.d.y     MMM-d     M/d      M-d
// d/M/y   d-M-y      d.M.y     d-MMM     d/M      d-M
// A second argument may be passed to instruct the method to search
// for formats like d/M/y (european format) before M/d/y (American).
// Returns a Date object or null if no patterns match.
// ------------------------------------------------------------------
function parseDate(val) {
	var preferEuro=(arguments.length==2)?arguments[1]:false;
	generalFormats=new Array('y/m/d','y-M-d','MMM d, y','MMM d,y','MMM d y','y-MMM-d','d-MMM-y','MMM d');
	monthFirst=new Array('M/d/y','M-d-y','M.d.y','MMM-d','M/d','M-d');
	dateFirst =new Array('d/M/y','d-M-y','d.M.y','d-MMM','d/M','d-M');
	var checkList=new Array('generalFormats',preferEuro?'dateFirst':'monthFirst',preferEuro?'monthFirst':'dateFirst');
	var d=null;
	for (var i=0; i<checkList.length; i++) {
		var l=window[checkList[i]];
		for (var j=0; j<l.length; j++) {
			d=getDateFromFormat(val,l[j]);
			if (d>0) { return new Date(d); }
			}
		}
	return null;
	}


//-------------------------------------------------------------
//This function shows a pop up window for selecting
//menu options when a button is clicked
//menuItems is a "," seperated string ending with a ","
//e.g. Show1,Show2,Show3,
//-------------------------------------------------------------
function showButtonMenu(menuItems, functionName, positionLeft, positionTop, positionWidth, positionHeight){
  var oPopup = window.createPopup();
  var oPopupBody = oPopup.document.body;
  oPopupBody.style.backgroundColor = "white";
  oPopupBody.style.border = "solid black 3px";
  var index = menuItems.indexOf(',');
  var i = 0;
  var theOptions = "";
  while(index != -1){
    theOptions += "<option value=";
    theOptions += i;
    i++;
    theOptions +=  ">" + menuItems.substring(0,index) + "</option>";
    menuItems = menuItems.substring(index+1);
    index  = menuItems.indexOf(",");
  }
  var theBodyHtml = "<span name=thetext id=thetext style='position:relative; top:10px;'><center></center></span>";
  theBodyHtml += "<center><select NAME='ButtonOptions' ID='ButtonOptions' size='"+i+"' onClick='parent."+functionName+"(document.all.ButtonOptions[document.all.ButtonOptions.selectedIndex].text);oPopup.close();'>";
  theBodyHtml += theOptions; 
  theBodyHtml += "</select></center>";
  oPopupBody.innerHTML = theBodyHtml;
  oPopup.show(positionLeft, positionTop, positionWidth, positionHeight, document.body);
}

function f_GetSelectedRow(argDw) {
  //alert('f_GetRowSelected');
  var theDw = dw[argDw];
  var theReturn = 0;
  var noneSelected = true;
  for(r=1;r <= theDw.rowCount; r++) {
   if (theDw.row[r].selected) {
    theReturn = r;
    return theReturn;
   }
  }
  if(theReturn==0 && theDw.rowCount>0)
    theReturn = 1;
  return theReturn;
}

function f_IsRowSelected(argDw,argRow) {
  //alert('f_GetRowSelected');
  var theDw = dw[argDw];
  if (theDw.row[argRow].selected)
    return true;
  else
    return false;
}

function f_GetColumnValue(argDw, argRow, argColumnName) {
  //alert('f_GetColumnValue');
  var theDw = dw[argDw];
  columnPtr = -1;
  for(i=1; i <= theDw.columnCount; i++) {
    if (theDw.column[i].columnName == argColumnName) {
     columnPtr = i;
     i = 9999;
    }
  }
  if (columnPtr < 1) {
    alert("Unknown column: " + argColumnName + " in f_GetColumnValue()");
    return "0";
  }
  
  var theRow = theDw.row[argRow];
  var theReturn = theRow.data[columnPtr].oldValue;
  //alert(theReturn);
  return theReturn;
}

function f_Modify_Icon(){
  var rowNo = f_GetSelectedRow(0);
  var PrimaryWhere = "";
  var PrimaryTable = "";
  var PrimaryColumnType = "";
  var theDw = dw[0];
  for(var i=1; i <= theDw.columnCount; i++) {
    if (theDw.column[i].primaryKey == true) {
      PrimaryColumnType = theDw.column[i].columnType;
      PrimaryTable = theDw.column[i].tableName;
      if(PrimaryWhere.length > 1)
        PrimaryWhere += " AND ";
      PrimaryWhere += theDw.column[i].columnName;
      if(PrimaryColumnType == "string"){
        PrimaryWhere += " = '";
        PrimaryWhere += f_GetColumnValue(0, rowNo, theDw.column[i].columnName);
        PrimaryWhere += "'";
      }
      else if(PrimaryColumnType == "date"){
        PrimaryWhere += " = to_date('";
        PrimaryWhere += f_GetColumnValue(0, rowNo, theDw.column[i].columnName);
        PrimaryWhere += "','YYYY-MM-DD HH24:MI:SS')";
      }
      else if(PrimaryColumnType == "number" || PrimaryColumnType == "RSN"){
        PrimaryWhere += " = ";
        PrimaryWhere += f_GetColumnValue(0, rowNo, theDw.column[i].columnName);
      }
      else{
        alert("Sorry...'"+PrimaryColumnType+"' ColumnType not yet handled.");
        return;
      }
    }//end if
  }//end for
  //alert("PrimaryWhere = " + PrimaryWhere);
  //alert("PrimaryTable = " + PrimaryTable);
  window.showModalDialog("ModifyDetail.jsp?PrimaryWhere="+PrimaryWhere+"&PrimaryTable=" + PrimaryTable + '&lid=' + theform.lid.value, window,'dialogHeight:200px; dialogWidth: 300px; dialogTop: 200px; dialogLeft: 200px; edge: Raised; center: Yes; help: No; resizable: No; status: No;scroll:no');
  //window.open('ModifyDetail.jsp?PrimaryWhere='+PrimaryWhere+'&PrimaryTable='+ PrimaryTable + '&lid=' + theform.lid.value,'','width=500,height=400,status=1');
}

