<!--<script LANGUAGE="javascript">-->
var msTable = '';
var mbDocsEnabled = true;
var bMenuAlive = true;
var miitem_id = 0;
var miitem_version_id = 0;
var miparent_id = 0;

function confirmDelete(iitem_id,iParentID, sReferer) {
   var bConfirm;
   if ( iitem_id != null ) {
     bConfirm = window.confirm("Are you sure you want to delete this object?");
     if (bConfirm == true) {
        if (iitem_id == '(obj)') iitem_id = miitem_id;
        var sPath = "aspDeleteObject.asp?item_id=" + iitem_id + "&ParentID=" + iParentID;
        if (sReferer != undefined)
          if (sReferer.length > 1)
            sPath += "&referer=" + escape(sReferer);
        window.navigate(sPath);
     }
   }
}

function getDateTime(sInput) {
// Return the current data time into the input box specified
  try {
    var eDate = new Date();
    var eInput = document.all[sInput];
    var sDate = "";
    var sMinutes = '00' + eDate.getMinutes();

    sMinutes = sMinutes.substring(sMinutes.length-2);

    sDate+= eDate.getDate() + " ";
    switch (eDate.getMonth()+1) {
      case 1 : sDate += "Jan "; break;
      case 2 : sDate += "Feb "; break;
      case 3 : sDate += "Mar "; break;
      case 4 : sDate += "Apr "; break;
      case 5 : sDate += "May "; break;
      case 6 : sDate += "Jun "; break;
      case 7 : sDate += "Jul "; break;
      case 8 : sDate += "Aug "; break;
      case 9 : sDate += "Sep "; break;
      case 10 : sDate += "Oct "; break;
      case 11 : sDate += "Nov "; break;
      case 12 : sDate += "Dec "; break;
      default : ;
    }
    sDate+= eDate.getYear() + " ";
    sDate+= eDate.getHours() + ":" + sMinutes;
    eInput.value = sDate;
  } catch (e) { alert(e.description) }
}

function getDate(sDate) {
  // parse dates in the format dd-mmm-yyyy
  var iIndex = 0;
  var iIndex = sDate.indexOf("-",iIndex);
  var sDay = sDate.substr(0,iIndex);
  iIndex++;
  var iIndex2 = sDate.indexOf("-",iIndex);
  var sMonth = sDate.substr(iIndex,(iIndex2-iIndex));
  iIndex2++;
  var iIndex = sDate.indexOf(" ",iIndex2);
  if ( iIndex < 0 ) iIndex = sDate.length;
  var sYear = sDate.substr(iIndex2,(iIndex - iIndex2));
  var iMonth = 0;
  switch (sMonth.toLowerCase()) {
    case "jan" : iMonth = 0; break;
    case "feb" : iMonth = 1; break;
    case "mar" : iMonth = 2; break;
    case "apr" : iMonth = 3; break;
    case "may" : iMonth = 4; break;
    case "jun" : iMonth = 5; break;
    case "jul" : iMonth = 6; break;
    case "aug" : iMonth = 7; break;
    case "sep" : iMonth = 8; break;
    case "oct" : iMonth = 9; break;
    case "nov" : iMonth = 10; break;
    case "dec" : iMonth = 11; break;
  }
  var eDate = new Date(sYear,iMonth,sDay);
  return eDate;
}

function fDate(eDate, bTime) {
// Return a string with the formatted date
  try {
    var sDate = "";
    sDate+= eDate.getDate() + "-";
    switch (eDate.getMonth()+1) {
      case 1 : sDate += "Jan"; break;
      case 2 : sDate += "Feb"; break;
      case 3 : sDate += "Mar"; break;
      case 4 : sDate += "Apr"; break;
      case 5 : sDate += "May"; break;
      case 6 : sDate += "Jun"; break;
      case 7 : sDate += "Jul"; break;
      case 8 : sDate += "Aug"; break;
      case 9 : sDate += "Sep"; break;
      case 10 : sDate += "Oct"; break;
      case 11 : sDate += "Nov"; break;
      case 12 : sDate += "Dec"; break;
      default : ;
    }
    sDate+= "-" + eDate.getYear();
    if (bTime)
      sDate += " " + eDate.getHours() + ":" + eDate.getMinutes();
  } catch (e) { sDate = e.description }
  return sDate;
}

function addObject(sTable,iObjectTypeID) {
  var sURL = '';
  var sFeatures = '';
  var iX = 0;
  var iY = 0;
  var iWidth = 600;
  var iHeight = 500;

  iX = window.screenLeft + ((document.body.clientWidth) / 2) - (iWidth / 2);
  iY = window.screenTop + ((document.body.clientHeight) / 2) - (iHeight / 2);
  sFeatures = "left=" + iX + ",top=" + iY + ",";
  sFeatures = sFeatures + "width=" + iWidth + ",height=" + iHeight + ",status=no,scrollbars=yes,resizeable=no";

  if (iObjectTypeID != 0)
     sURL = 'aspShowObject.asp?item_id=0&ParentID=0&action=edit&ObjectTypeID=' + iObjectTypeID + '&Border=false';
  else
     sURL = 'aspNewObject.asp?item_id=0&ParentID=0&Border=false';

  msTable = sTable;
  newWindow = open(sURL,"",sFeatures);
  newWindow.focus();
  // controll passes to callBack at this point
}

function callBack(iItemID,sTitle) {
  var sRows = '';

  if (iItemID != 0) {
    sRows = '<xml><row><id>' + iItemID + '</id><title>' + sTitle + '</title></row></xml>';
    addRows(sRows, msTable, false);
  }
}
function openWindow(sAddress) {
//  window.scrollTo(0,100);
//  open(sAddress,'_blank','fullscreen=no,resizable=yes,toolbar=no,scrollbars=yes,width=450,height=500','');
  document.location = sAddress;
}

function openNewWindow(sAddress) {
  open(sAddress,'_blank','fullscreen=no,resizable=yes,menubar=yes,toolbar=yes,scrollbars=yes,width=600,height=500','');
}
function openWizard(sAddress) {
  open(sAddress,'_blank','fullscreen=no,resizable=yes,toolbar=no,scrollbars=yes,width=550,height=375','');
}

function toggleDesc() {
  var i;
  try {
    for (i = 0; i < desc.length; i++)
      if (desc(i).style.display == 'none')
        desc(i).style.display = ''
      else
        desc(i).style.display = 'none';
  } catch (e) {}
}

function setSelectedView() {
  var eSelect = new Object;
  var iX = 0;

  eSelect = document.all["selView"];
  if (eSelect != null) {
  for (iX = 0; iX < eSelect.options.length; iX++) {
    if (eSelect.options[iX].value == "12") {
      eSelect.options(iX).selected = true;
    }
  }
  }
}

function doSearch() {
  var sURL = "aspShowSearch.asp?includeHeader=2";

  //searchResults.document.all["divResults"].outerHTML = sSrchMessage;
  sURL = sURL + "&attribute[-1]=" + escape(document.all["short_search_string"].value);
  sURL = sURL + "&criteria[-1]=4";
  sURL = sURL + "&execute=1";
  sURL = sURL + "&include_header=true";
  sURL = sURL + "&style_sheet=sys_searchResults.xslt";
  document.location = sURL;
}

function goTo(eObj) {
  var sURL = "";
  var re = /\(obj\)/g;
  var re2 = /\(objVersion\)/g;
  var re4 = /\(parent\)/g;
  var doc = document.location.href;
  var host = document.location.host;
  var re3 = new RegExp("http://" + host,"ig");
  doc = doc.replace(re3,"");
  // remove any references to referer in the URL
  var re3 = /referer/gi;
  var i = doc.search(re3);
  if ( i > 0 ) doc = doc.substr(0,i-1);
  bMenuAlive = false;
  try {
    sURL = eObj;
    sURL = sURL.replace(re,miitem_id);
    sURL = sURL.replace(re2,miitem_version_id);
    sURL = sURL.replace(re4,miparent_id);
    sURL += "&referer=" +  escape(doc);
    //alert(sURL);
    window.navigate(sURL);
  } catch (e) {}

}

function showMenu(eTD,sMenu) {
// Show the selected pop-up menu
  var ePopup = document.all[sMenu];
  if ( bMenuAlive ) {
    try {
      eTD.style.textDecoration = "underline";
      ePopup.style.display = "";
      ePopup.style.position = "absolute";
    } catch (e) {}
  }
}

function hideMenu(eTD, sMenu) {
// Hide the selected pop-up menu
  var ePopup = document.all[sMenu];
  if ( bMenuAlive ) {
    try {
      eTD.style.textDecoration = "";
      ePopup.style.display = "none";
    } catch (e) {}
  }
}

function showPopupMenu(eTD,sMenu, iitem_id, iitem_version_id, iparent_id ) {
// Show the selected pop-up menu
  var ePopup = document.all[sMenu];
  var iY = 0;
  var iX = 0;
  var eObj;

  if ( bMenuAlive ) {
    try {
//      alert(eTD.offsetParent.offsetParent.offsetTop);
      eObj = eTD.offsetParent;
      iY = -10;
      iX = -10;
      while (eObj.id != 'tblMain') {
        iY = iY + eObj.offsetTop;
        iX = iX + eObj.offsetLeft;
        eObj = eObj.offsetParent;
      }
      ePopup.style.position = "absolute";
      ePopup.style.display = "";
      ePopup.style.left = iX; //eTD.offsetParent.offsetParent.offsetLeft;
      ePopup.style.top = iY; //eTD.offsetParent.offsetTop + ePopup.offsetHeight + 10;
      ePopup.style.zIndex = 400;
      miitem_id = iitem_id;
      miitem_version_id = iitem_version_id;
      miparent_id = iparent_id;
    } catch (e) {alert(e.description);}
  }
}

function hidePopupMenu(eTD, sMenu) {
// Hide the selected pop-up menu - if the mouse is outside of the table
  var ePopup = document.all[sMenu];
  if ( bMenuAlive ) {
    try {
      //if ( document.body.scrollTop != 0 ) alert(document.body.scrollTop);
      if (event.clientY >= (ePopup.offsetTop + ePopup.clientHeight - document.body.scrollTop) |
          event.clientY <= ( ePopup.offsetTop - document.body.scrollTop ) |
          event.clientX <= ePopup.offsetLeft |
          event.clientX >= (ePopup.offsetLeft + ePopup.clientWidth) )
         ePopup.style.display = "none";
    } catch (e) {alert(e.description)}
  }
}
function highlight(eTD) {
  if ( bMenuAlive ) {
//    eTD.style.backgroundColor = "navy";
//    eTD.style.color = "white";
      eTD.className = "mnMainHighlight";
  }
}
function unhighlight(eTD) {
  if ( bMenuAlive ) {
//    eTD.style.backgroundColor = "";
//  eTD.style.color = "";
    eTD.className = "mnMainUnHighlight";
  }
}

function expand(sID) {
 // Grow the size of a textbox object
   var eTextBox = new Object;

   try {
     eTextBox = document.all[sID];
     eTextBox.rows = eTextBox.rows + 10;
   } catch (e) {}
 }
 function collapse(sID) {
 // Grow the size of a textbox object
   var eTextBox = new Object;

   try {
     eTextBox = document.all[sID];
     if (eTextBox.rows > 10) eTextBox.rows = eTextBox.rows - 10;
   } catch (e) {}
 }


// ================================================================
// Pops up the search window using sSearchString as the default
// criteria.  Adds the selected objects to the supplied table.
// ================================================================
function getLinksToObjects(sTable, sAttributeID, bAllowMulti, bExecute ) {
  var eMessage = document.all["searchPopup"];
  var sSearchString = "";
  var retVal = "";
  var iX = 0;
  var iX2 = 0;

  // Pop-up the search window in the centre of the screen
  eMessage.style.position = "absolute";
  eMessage.style.left = ( document.body.offsetWidth / 2 ) - ( eMessage.style.posWidth / 2);
  eMessage.style.top =  ( document.body.scrollTop ) + ( document.body.offsetHeight / 2 ) - ( eMessage.style.posHeight / 2);
//  sFeatures = sFeatures + "dialogWidth:510px;dialogHeight:390px;center=yes;status:no;scroll:yes;resizeable:no";
  sFeatures = "dialogHeight:450px;center=yes;status:no;scroll:no;resizeable:no";
  eMessage.style.display = "";
  sSearchString = "attribute_id=" + sAttributeID + "&style_sheet=sys_searchPopup.xslt&include_header=false&execute=" + bExecute;
  try {
    while (true) {
      // show search message
      retVal = window.showModalDialog("aspShowSearch.asp?" + sSearchString + "&" + Math.random() ,"",sFeatures);
//      retVal = window.showModalDialog("aspShowSearch.asp?" + sSearchString ,"",sFeatures);
      //retVal = window.open("aspShowSearch.asp?" + sSearchString,"",sFeatures);
      if (retVal == 'undefined')
         break;
      if (retVal.substr(0,1) != "?") {
         break;
      } else {
         sSearchString = retVal.substr(1);
    sSearchString = sSearchString + "&style_sheet=sys_searchPopup.xslt&include_header=false";
      }
    }
    eMessage.style.display = "none";
    if ( (retVal != 'undefined') & (retVal != null) )
       addRows(retVal, sTable, bAllowMulti);
  } catch (e) {
    eMessage.style.display = "none";
  }

}
// Retreive the value of the specified XML tag
function getXMLField(sXML , sField, iStart) {
  var i1 = sXML.indexOf("<" + sField + ">", iStart);
  var i2 = sXML.indexOf("</" + sField + ">",i1);
  var i3 = sField.length;
  var sRetVal = sXML.substr(i1 + i3 + 2, (i2 - i1 - (i3 + 2)));
  return sRetVal;
}

function addRows(sRows, sTable, bAllowMulti) {
//  Add the link rows to the specified table
  var eTable = new Object;
  var eRow = new Object;
  var eCell = new Object;
  var i = 0;
  var iCells = 0;
  var sID = "";
  var sTitle = "";
  var bFound = false;

  // Add results to the supplied table
  eTable = document.all[sTable];
  iCells = eTable.rows[0].cells.length;
  iX = sRows.indexOf("<row>",0);
  while (iX != -1) {
    // get <id>
    iX = sRows.indexOf("<id>", iX);
    iX2 = sRows.indexOf("</id>", iX);
    sID = sRows.substr(iX + 4, (iX2 - iX - 4));

    // get <title>
    iX = sRows.indexOf("<title>", iX2);
    iX2 = sRows.indexOf("</title>", iX);
    sTitle = sRows.substr(iX + 7, (iX2 - iX - 7));

    if (bAllowMulti == false) {
       // replace the last row
       eRow = eTable.rows[eTable.rows.length-1];
       // eRow.all["link_description"].innerHTML = sTitle;
       eRow.all["link_description"].value = sTitle;
       eRow.all["id"].children[0].value = sID;
       iX = -1;
    } else {

       // check whether the record is already in the table
       bFound = false;
       for (i=0; i < eTable.rows.length; i++) {
         if (eTable.rows[i].all["id"].children[0].value == sID) {
            eRow = eTable.rows[i];
            bFound = true;
            break;
         }
       }

       // create a new row in the table, by copying the above row
       if (bFound == false) {
           eRow = eTable.rows[0];
           if ( eRow.all["id"].children[0].value != 0 ) {
             eRow = eTable.insertRow();
             // copy first row to new row
             for (i=0; i < iCells; i++) {
               eCell = eRow.insertCell();
               eCell.innerHTML = eTable.rows[0].cells[i].innerHTML;
               eCell.className = eTable.rows[0].cells[i].className;
               eCell.style.cssText = eTable.rows[0].cells[i].style.cssText;
               eCell.width = eTable.rows[0].cells[i].width;
             }
           }
       }
       //eRow.all["link_description"].innerHTML = sTitle;
       eRow.all["link_description"].value = sTitle;
       eRow.all["id"].children[0].value = sID;
       iX = sRows.indexOf("<row>",iX2);
    }
  }
}

// ================================================================
// Deletes the selected row
// ================================================================
function delRow(eObj) {
  var eRow = new Object;
  var eTable = new Object;
  var iCount = 0;

  // Get row
  eRow = eObj;
  while ((eRow.tagName != "TR") & (iCount < 10)) {
    eRow = eRow.parentElement;
    iCount++;
  }
  // Get table
  iCount = 0;
  eTable = eRow;
  while ((eTable.tagName != "TABLE") & (iCount < 10)) {
    eTable = eTable.parentElement;
    iCount++;
  }
  // Delete row
  if ((eRow.tagName == "TR") & (eTable.tagName == "TABLE")) {
    if ( eTable.rows.length > 1 )
      eTable.deleteRow(eRow.rowIndex)
    else {
      //eRow.all["link_description"].innerHTML = ".";
      eRow.all["link_description"].value = "";
      eRow.all["id"].children[0].value = 0;
    }
  }
}

function showNotifications() {
  try {
    var eTable = document.all["tblSubscription"];
    eTable.style.position = "absolute";
    eTable.style.display = "";
    eTable.style.left = event.clientX;//iX;// + 50;
    eTable.style.top = event.clientY;//iY + 90;
  } catch (e) {
    alert("This function is only availble from the property page");
  }
}
function saveNotifications( iItemID ) {
  if ( iItemID > 0 ) {
    var eTable = document.all["tblSubscription"];
    var sURL = "aspUpdateNotifications.asp?";
    sURL += "item_id=" + iItemID;
    sURL += "&this_change=" + document.all["chkThisChange"].checked;
    sURL += "&child_change=" + document.all["chkChildChange"].checked;
    sURL += "&child_add=" + document.all["chkChildAdd"].checked;
    sURL += "&referer=" + cx_referer;
    window.navigate(sURL);
  }
}
function cancelNotifications() {
  var eTable = document.all["tblSubscription"];
  eTable.style.display = "none";
}
function copyEditedContent(eObj) {
// ---- Copy content from 'span' fields to hidden input fields ----
  var i = 0;
  var eCollection = document.forms(0,0); // get all elements for the form
  for (i = 0; i < eCollection.length; i++) {
    if (eCollection[i].name.substring(0,8) == 'EXTENDED') {
       var sID = eCollection[i].name.substr(9);
       var eInput = document.all['EXEDIT:' + sID];
       if (eInput != null ) {
         if ( eInput.style.display == '' ) eCollection[i].value = stripURL(eInput.innerHTML);
       }
    }
  }
}
function stripURL(sContent) {
  // Strip out hard wired URLS if the URL is the current page
  var path = document.location.href;
  // get rid of the search part of the path
  var sSearch = document.location.search;
  path = path.substr(0,path.length - sSearch.length);
  // clear references to self
  var pattern = new RegExp(path,"g");
  sContent = sContent.replace(pattern,"");
  // clear references to search path
  // first change ? to \? for RegExp to work
  for (var i = 0; i < sSearch.length; i++)
    if (sSearch.substr(i,1) == "?") {
       if ( i == 0 )
          sSearch = "\\" + sSearch.substr(i)
       else
          sSearch = sSearch.substr(0,i-1) + "\\" + sSearch.substr(i);
    }
  // next change & to &amp; to adjust for HTML converting & to &amp;
  sSearch = sSearch.replace(/&/g,"&amp;");
  pattern = new RegExp(sSearch,"g");
  sContent = sContent.replace(pattern,"");
  // clear relative references
  var re = new RegExp("/","g");
  var r = path.match(re);
  path = path.substr(0,r.lastIndex);
  var pattern = new RegExp(path,"g");
  sContent = sContent.replace(pattern,"");
  return sContent;
}
function processKey() {
// ---- Process key board events --
  if (window.event.ctrlKey == true ) {
     var sKey = String.fromCharCode(window.event.keyCode);
     switch (sKey) {
       case 'L' : //Bullet
                 document.execCommand("InsertUnorderedList");
                 window.event.returnValue = false;
                 break;
       case '1' : //Heading Level 1
/*
       case 73 : //ctrl-i Image
                 document.execCommand("InsertImage",false,"phil.img");
                 window.event.returnValue = false;
                 break;
*/
     }
  }
}

// Show popup list of items
function mdShowPopup(eButton, sName) {
  var eTable = document.all[sName];
  var iY = 0;
  var iX = 0;
  try {
    // Calculate position for popup window
    while (eButton != null) {
      iY = iY + eButton.offsetTop;
      iX = iX + eButton.offsetLeft;
      eButton = eButton.offsetParent;
    }
    eTable.style.position = "absolute";
    eTable.style.display = ''
    eTable.style.left = iX + 50;
    eTable.style.top = iY;
    // Give the select list focus
    eTable.all['[xxx_list]'].focus();
  } catch (e) {}
}
function mdHidePopup(sName) {
  var eTable = document.all[sName];
  try {
    eTable.style.display = 'none';
  } catch (e) {}
}
// Add item from popup list to link list
function mdAddItem(eList, sTable, bAllowMulti) {
//  Add the link rows to the specified table
  var eTable = document.all[sTable];
  var eItem = new Object;
  var eRow = new Object;
  var eCell = new Object;
  var i = 0;
  var iCells = 0;
  var sID = "";
  var sTitle = "";
  var bFound = false;

  // Get the selected item
  eItem = eList.options(eList.selectedIndex);
  sID = eItem.value;
  sTitle = eItem.text;

  // Add results to the supplied table
  iCells = eTable.rows[0].cells.length;
  if (bAllowMulti == false) {
     // replace the last row
     eRow = eTable.rows[eTable.rows.length-1];
     eRow.all["link_description"].innerHTML = sTitle;
     eRow.all["id"].children[0].value = sID;
  } else {

    // check whether the record is already in the table
    bFound = false;
    for (i=0; i < eTable.rows.length; i++) {
      if (eTable.rows[i].all["id"].children[0].value == sID) {
         bFound = true;
         eRow = eTable.rows[i];
         break;
      }
    }

    // create a new row in the table, by copying the above row
    if (bFound == false) {
       eRow = eTable.rows[0];
       if ( eRow.all["id"].children[0].value != 0 ) {
          eRow = eTable.insertRow();
          // copy first row to new row
          for (i=0; i < iCells; i++) {
            eCell = eRow.insertCell();
            eCell.innerHTML = eTable.rows[0].cells[i].innerHTML;
            eCell.className = eTable.rows[0].cells[i].className;
            eCell.width = eTable.rows[0].cells[i].width;
          }
       }
    }
    eRow.all["link_description"].innerHTML = sTitle;
    eRow.all["id"].children[0].value = sID;
  }
}
// Dynamically resize an image
function imageResize ( eImg, iWidth ) {
  try {
    if ( eImg.width > iWidth )
       eImg.width = iWidth;
  } catch (e) { }
}
function toggleHide(sObjName) {
  var eObj = document.all[sObjName];

  if (eObj.style.display == '')
         eObj.style.display = 'none'
  else
     eObj.style.display = '';
}

function filter(iItemID) {
   var sColumn = 0;
   var sValue = "";
   var eFilter = document.all["filter_field"];
   var sURL = "";

   sValue = document.all["filter_value"].value;
   sColumn = eFilter.options(eFilter.selectedIndex).value;
   sURL = "aspShowFile2.asp?item_id=" + iItemID + "&RestrictByColumn=" + sColumn + "&RestrictByValue=" + sValue;
   window.navigate(sURL);
}

function cx_ShowMessage(sMessage) {
  var width = 350;
  var height = 200;
  var xPos = ( document.body.offsetWidth / 2 ) - ( width / 2);
  var yPos = ( document.body.scrollTop ) + ( document.body.offsetHeight / 2 ) - ( height / 2);

  if (!document.all["cxMessageBox"]) {
    var sBox = "<div id='cxMessageBox' class='cxMessageBox' style='display:none'></div>";
    document.body.insertAdjacentHTML("afterbegin",sBox);
  }
  var eDiv = document.all["cxMessageBox"];
  eDiv.style.left = xPos;
  eDiv.style.top =  yPos;
  eDiv.style.width = width;
  eDiv.innerHTML = sMessage;
  eDiv.style.display = "";
}
function cx_HideMessage() {
  if (document.all["cxMessageBox"]) {
    var eDiv = document.all["cxMessageBox"];
    eDiv.style.display = "none";
  }
}

// Display a popup calendar
var cx_mDate = new Date();
var cx_mCalField;
var cx_mAlignTo;
var cx_mColor;

function cx_ShowCalendar(eField,eAlignTo) {
  try {
  if (eField) cx_mCalField = eField;
  if (eAlignTo) cx_mAlignTo = eAlignTo;
  var sCal = "";
  var eStartDate = new Date(cx_mDate.getFullYear(),cx_mDate.getMonth(),1);
  var eEndDate = new Date(2003,eStartDate.getMonth()+1,1);
  eEndDate.setDate(-1);
  // Create calendar header
  var sTitle = "<b>" + cx_GetMonth(eStartDate,false) + " " + eStartDate.getFullYear() + "</b>";
  sCal += "<table border=0 width=150 class='cxCalTop'>";
  sCal += "<tr><td class='cxWebDing' width=10 style='cursor:hand' onclick='cx_CalLeft()'>3</td><td class='cxCalTop' align=center>" + sTitle + "</td><td class='cxWebDing' width=10 style='cursor:hand' onclick='cx_CalRight()'>4</td></tr>";
  sCal += "</table>";
  sCal += "<table border=0 width=150 class='cxCalTop' cellspacing=0 style='border-top:none'>";
  sCal += "<tr><td class='cxCalDay'>S</td><td class='cxCalDay'>M</td><td class='cxCalDay'>T</td><td class='cxCalDay'>W</td><td class='cxCalDay'>T</td><td class='cxCalDay'>F</td><td class='cxCalDay'>S</td></tr>";
  // Output days
  var iStartDay = eStartDate.getDay();
  var iEndDay = eEndDate.getDate();
  var eToday = new Date();
  for (var y=0; y < 6; y++) {
    sCal += "<tr>";
    for (var x=0; x < 7; x++) {
      sCal += "<td class='cxCalDate'";
      if ((((y*7)+x)>= iStartDay) & ((y*7)+x-eStartDate.getDay())<=iEndDay) {
        var iDay = (y*7)+x - eStartDate.getDay() + 1;
        if ((eStartDate.getFullYear() == eToday.getFullYear()) & (eStartDate.getMonth() == eToday.getMonth()) & (iDay == eToday.getDate()) )
           sCal += " style='background-color : gold'";
        sCal += " onmouseover='cx_calHighlight(this)' onmouseout='cx_calUnHighlight(this)'onclick='cx_CalSelect(" + eStartDate.getFullYear() + "," + eStartDate.getMonth() + "," + iDay + ")'>" + iDay;
      }
      sCal += "</td>";
    }
    sCal += "</tr>";
  }
  sCal += "</table>";
  // Footer
  sCal += "<table border=0 width=150 class='cxCalTop' style='border-top:none'>";
  sCal += "<tr><td class='cxCalTop' style='cursor:hand' align='center' onclick='cx_CalToday()'>Today</td><td class='cxCalTop' style='cursor:hand' align='center' onclick='cx_CalClose()'>Close</td></tr>";
  sCal += "</table>";

  if (!document.all["cxCalendar"])
    document.body.insertAdjacentHTML("afterbegin","<div style='position:absolute;z-index:200;' id='cxCalendar'></div>");
  var eCal = document.all["cxCalendar"];
  eCal.innerHTML = sCal;
  eCal.style.display = "";
  var pos = cx_getAbsolutePos(cx_mAlignTo);
  eCal.style.left = pos[0] + cx_mAlignTo.offsetWidth - eCal.offsetWidth;
  eCal.style.top = pos[1] + cx_mAlignTo.offsetHeight;
//  alert(pos[0] + ':' + pos[1]);
  // Hide "select" elements under the calendar
//  cx_HideSelectObjects(eCal);
  } catch (e) {
    alert(e.description);
  }
  return false;
}
// move back one month
function cx_CalLeft() {
  cx_mDate.setMonth(cx_mDate.getMonth()-1);
  cx_ShowCalendar();
}
// move forward one month
function cx_CalRight() {
  cx_mDate.setMonth(cx_mDate.getMonth()+1);
  cx_ShowCalendar();
}
// return the name of the month
function cx_GetMonth(eDate, bShort) {
  var months = new Array(["Jan","January"],["Feb","February"],["Mar","March"],["Apr","April"],["May","May"],["Jun","June"],["Jul","July"],["Aug","August"],["Sep","September"],["Oct","October"],["Nov","November"],["Dec","December"]);
  if (bShort)
    return months[eDate.getMonth()][0]
  else
    return months[eDate.getMonth()][1];
}
// close the calendar
function cx_CalClose() {
  if (document.all["cxCalendar"]) {
    var eCal = document.all["cxCalendar"];
    cx_UnHideSelectObjects(eCal);
    eCal.style.display = "none";
  }
}
// set the calendar date to today
function cx_CalToday() {
  cx_mDate = new Date();
  cx_ShowCalendar();
}
function cx_CalSelect(iYear,iMonth,iDay) {
  try {
    var eDate = new Date(iYear,iMonth,iDay)
    cx_mCalField.value = iDay + " " + cx_GetMonth(eDate,true) + " " + iYear;
    try {
      cx_mCalField.onchange();
    } catch (e) {}
    cx_CalClose();
  } catch (e) {
    alert(e.description);
  }
}
function cx_calHighlight(eThis) {
  cx_mColor = eThis.style.backgroundColor;
  eThis.style.backgroundColor = 'moccasin';
}
function cx_calUnHighlight(eThis) {
  eThis.style.backgroundColor = cx_mColor;
}
function cx_HideSelectObjects( eShow ) {
  var iTop = parseInt(eShow.style.top);
  var iLeft = parseInt(eShow.style.left);
  var iRight = iLeft + eShow.offsetWidth;
  var iBottom = iTop + eShow.offsetHeight;
  var eSelects = document.getElementsByTagName("select");
  for (var i = 0; i < eSelects.length; i++ ) {
    var pos = cx_getAbsolutePos(eSelects[i]);
    var iThisTop = pos[1]; //eSelects[i].offsetTop;
    var iThisLeft = pos[0]; //eSelects[i].offsetLeft;
    var iThisRight = iThisLeft + eSelects[i].offsetWidth;
    var iThisBottom  = iThisTop + eSelects[i].offsetHeight;
    if ((iThisTop >= iTop ) & (iThisTop <= iBottom) &
     (((iThisLeft <= iLeft) & (iThisRight >= iLeft)) |
      ((iThisLeft <= iRight) & (iThisRight >= iRight)) |
      ((iThisLeft >= iLeft) & (iThisRight <= iRight))
     ))
      eSelects[i].style.visibility = "hidden";
  }
}
function cx_UnHideSelectObjects( eShow ) {
  var iTop = parseInt(eShow.style.top);
  var iLeft = parseInt(eShow.style.left);
  var iRight = iLeft + eShow.offsetWidth;
  var iBottom = iTop + eShow.offsetHeight;
  var eSelects = document.getElementsByTagName("select");
  for (var i = 0; i < eSelects.length; i++ ) {
    var pos = cx_getAbsolutePos(eSelects[i]);
    var iThisTop = pos[1]; //eSelects[i].offsetTop;
    var iThisLeft = pos[0]; //eSelects[i].offsetLeft;
    var iThisRight = iThisLeft + eSelects[i].offsetWidth;
    var iThisBottom  = iThisTop + eSelects[i].offsetHeight;
    if ((iThisTop >= iTop ) & (iThisTop <= iBottom) &
     (((iThisLeft <= iLeft) & (iThisRight >= iLeft)) |
      ((iThisLeft <= iRight) & (iThisRight >= iRight)) |
      ((iThisLeft >= iLeft) & (iThisRight <= iRight))
     ))
      eSelects[i].style.visibility = "visible";
  }
}
// Calculate the absolute position of the object on the page
function cx_getAbsolutePos(eThis) {
  var pos = new Array(0,0);
  while ( eThis.tagName != 'BODY' ) {
    pos[0] += eThis.offsetLeft;
    pos[1] += eThis.offsetTop;
    eThis = eThis.offsetParent;
  }
  return pos;
}
function fGetValue(eForm, sFieldName) {
  try {
    var eField = eForm[sFieldName];
    if ("length" in eField) {
      var sType = eField[0].type;
      var sValue = "";
    } else {
      var sType = eField.type;
      var sValue = eField.value; // getAttribute('value',0);
    }
    if (sType == 'radio') {
       // find the selected item
       var i = 0;
       for (i=0; i<eField.length; i++) {
         if (eField[i].checked == true)
            sValue = eField[i].value;
       }
    }
    return fFixXML(sValue);
  } catch (e) {
    return "";
  }
}
// parse the XML for protected elements
function fFixXML(sValue) {
  sValue = sValue.replace(/\&/gi,"&amp;");
  sValue = sValue.replace(/\"/gi,"&quot;");
  sValue = sValue.replace(/\</gi,"&lt;");
  sValue = sValue.replace(/\>/gi,"&gt;");
  sValue = sValue.replace(/\'/gi,"&apos;");
  return sValue;
}
function fTransfer(bVersion, sReferer) {
  var sLastError = '';
  var lItemID = 0;
  var iParentID = 0;
  var lResult = 0;
  var sXML = '';
  var eForm = document.forms["menu"];
  // tidy-up any richtext
  tinyMCE.triggerSave();

  // Generate XML from form details
  document.forms["menu"]["xml_data"].value = "";
  sXML = '<xml version="2">';
  sXML = sXML + '<items>';
  sXML = sXML + '<row ';
  sXML = sXML + '  new_version="' + bVersion + '" ';
  sXML = sXML + '  check_in="true" ';
  sXML = sXML + '  item_id="' + fGetValue(eForm,'item_id') + '" ';
  sXML = sXML + '  item_version_id="' + fGetValue(eForm,'item_version_id') + '" ';
  sXML = sXML + '  parent_id="' + fGetValue(eForm,'parent_id') + '" ';
  sXML = sXML + '  type_id="' + fGetValue(eForm,'object_type_id') + '" ';
  sXML = sXML + '  type_name="' + fGetValue(eForm,'object_type_name') + '" ';
  sXML = sXML + '  is_folder="' + fGetValue(eForm,'is_folder') + '" ';
  sXML = sXML + '  title="' + fGetValue(eForm,'title') + '" ';
  sXML = sXML + '  description="' + fGetValue(eForm,'description') + '" ';
  sXML = sXML + '>';
  // Get EXTENDED and LINK values
  sXML = sXML + fGenerateXML();
  // Get FILES
  var sFileXML = fGenerateFileXML();
  sXML = sXML + sFileXML;
  sXML = sXML + '</row>';
  sXML = sXML + '</items>';
  sXML = sXML + '</xml>';
  // Transfer data to server
  iParentID = fGetValue(eForm,'parent_id');
  document.forms["menu"]["xml_data"].value = sXML;
  if (iParentID == 0) {
    lResult = confirm("Are you sure you want to save this object in the root folder?");
    if (lResult == 0)
      return "";
  }
      if (sFileXML.length > 0) {
        // Send via multipart document post
        document.forms["menu"].encoding = 'multipart/form-data';
        if ( sReferer == undefined  )
          document.forms["menu"].action = 'cXWebServer.dll/saveDocument?session_id=' + cx_session_id + '&referer=' + cx_referer
        else
          document.forms["menu"].action = 'cXWebServer.dll/saveDocument?session_id=' + cx_session_id + '&referer=' + escape(sReferer);
        document.forms["menu"].submit();
      } else {
        if ( sReferer == undefined  )
          document.forms["menu"].action = 'update_item.asp?session_id=' + cx_session_id + '&referer=' + cx_referer
        else
          document.forms["menu"].action = 'update_item.asp?session_id=' + cx_session_id + '&referer=' + escape(sReferer);
        document.forms["menu"].submit();
      }
}

// Generate XML from the form to send to server
function fGenerateXML() {
  var eForm = document.forms["menu"];
  var sXML = "<extended_attributes>";
  // iterate through the collection and update the XML
  for (i = 0; i < eForm.length; i++) {
    var sTag = eForm[i].tagName;
    var sName = eForm[i].name; //getAttribute('name',0);
    var sType = eForm[i].type; //getAttribute('type',0);
    var sValue = eForm[i].value; //getAttribute('value',0);

    // Get the value for select or radio objects
/*
    if (sType == 'select-one') {
       if (eForm[i].selectedIndex > 0)
          sValue = eForm[i].options(eForm[i].selectedIndex).value;
    }
*/

    if (sType == 'checkbox')
       if ( eForm[i].checked == true )
          sValue = 1
       else
          sValue = 0;

    if (sType == 'radio')
       if ( eForm[i].checked != true )
          sType = '';  // ignore unchecked radio buttons

    // force ignore of [button] objects
    if (sType == 'button') sType ='';

    // force ignore of [file] objects
    if (sName.indexOf('file',0) == 0) sType = '';

    // force ignore of [system] objects
    if (sName.substr(0,1) == '[') sType = '';

    // build appropriate XML structure
    sName = sName.toLowerCase();
    if ((sName.length > 0) & (sType.length > 0)) {
       // Add extended attributes
       if (sName.indexOf('extended',0) >= 0) {
          var sAttributeName = sName.substr(9,sName.length - 8);
          var sID = new Number(sAttributeName);
          if (isNaN(sID)) sID = 0;
          sXML = sXML + '<attribute ';
          sXML = sXML + '  id="' + sID + '" ';
          sXML = sXML + '  name="' + sAttributeName + '">';
          sXML = sXML + '  <value><![CDATA' + '[' + sValue + ']' + ']></value>';
          sXML = sXML + '</attribute>';
       } else {
          // Add link attributes
          if (sName.indexOf('linked',0) >= 0) {
             var sAttributeName = sName.substr(7,sName.length - 6);
             var sID = new Number(sAttributeName);
             if (isNaN(sID)) sID = 0;
             sXML = sXML + '<attribute ';
             sXML = sXML + '  id="' + sID + '" ';
             sXML = sXML + '  name="' + sAttributeName + '">';
             sXML = sXML + '  <link item_id="' +  sValue + '" />';
             sXML = sXML + '</attribute>';
          }
       }
    }
  }
  sXML = sXML + "</extended_attributes>";
  return sXML;
}

// Generate XML for the attached files
function fGenerateFileXML() {
  var eForm = document.forms.item(0,0);
  var sXML = '';

  // iterate through the collection and update the XML
  for (i = 0; i < eForm.length; i++) {
    var sTag = eForm[i].tagName;
    var sName = eForm[i].name; //getAttribute('name',0);
    var sType = eForm[i].type; //getAttribute('type',0);
    var sValue = eForm[i].value; //getAttribute('value',0);

    // Get the value for select or radio objects
    if ((sName.substr(0,4) == 'file') & (sValue.length > 0)) {
       var sID = sName.substr(5);
       sID = sID.substr(0,sID.length-1);
       sXML = sXML + '<file ';
       sXML = sXML + ' original_file_name="' + fFixXML(sValue) + '" ';
       sXML = sXML + ' item_version_data_id="' + sID + '" ';
       if (sType == 'hidden')
          sXML = sXML + ' file_size="0" '
       else
          sXML = sXML + ' file_size="10" ';
       sXML = sXML + '/>';
    }
  }
  return sXML;
}

// Add a new file object to the file table
function fAddFileRow(sTable) {
  var eTable = document.all[sTable];
  var eRow = eTable.insertRow();

  // Create the column
  var eCell = eRow.insertCell();
  eCell.innerHTML = "<input type='file' name='file[0]' size='50' />";
//  return true;
}

function fCheckOut() {

  try {
    ucFileList1.getAllFiles(true);
    window.navigate("aspShowObject.asp?item_id=" + ucFileList1.itemID + "&action=edit");
  } catch (e) {
    alert("Requires the document handling component to be installed...");
  }

}

function popWindow(sURL) {
  var winOptions = "location=yes,toolbar=yes,menubar=yes,resizable=yes,scrollbars=yes,height=500,width=500";
  if (navigator.appName == "Netscape")
    winOptions += ",screenX=0,screenY=0"
  else
    winOptions += ",left=0,top=0";
  window.open(sURL, "", winOptions);
}
function popPicture(sURL) {
  var winOptions = "location=no,toolbar=no,menubar=no,resizable=no,scrollbars=no,width=850";
  if (navigator.appName == "Netscape")
    winOptions += ",screenX=0,screenY=0"
  else
    winOptions += ",left=0,top=0";
  window.open(sURL, "", winOptions);
}

<!--</script>-->