// popup window names
var cs_RMResource = "RMResource"
var cs_RMOptions = "RMOptions"
var cs_RMColourPicker = "RMColourPicker"

// form state array element values
var cs_iResourceID = 0;
var cs_iMetaCategoryID = 1;
var cs_iCategoryID = 2;
var cs_iThisOrderID = 3;
var cs_iOrderFieldName = 4;
var cs_iThisOrderTypeID = 5;
var cs_iSystemFormViewID = 6;
var cs_iDataViewID = 7;
var cs_iFormViewID = 8;
var cs_iTypeID = 9;
var cs_iFirstRowID = 10;
var cs_iLastRowID = 11;
var cs_iSelectedRowID = 12
var cs_iUserDefinedRowID = 13;
var cs_iIncrement = 14;
var cs_iOverallTotal = 15;
var cs_iSubCategoryTotal = 16;
var cs_bTrigger = 17;
var cs_bCreate = 18;
var cs_iSearchType = 19;
var cs_iSearchString = 20;
var cs_iPreviousResourceID = 21;
var cs_iAccountTypeID = 22
var cs_iResourceMetaGroupID = 23
var cs_iSiteID = 24
var cs_iSiteLocked = 25

// Log state array element values
var cs_iTimeStamp = 5

// miscellaneous defaults
var oThisTupple = null;
var iCategoryView = 0;
var iResourceView = 1;
var iInsert = 0;
var iUpdate = 1;
var iDelete = 99;
var iAscend = 0;
var iDescend = 1;
var iMinute = 60000
var iMinutesTimeout = 15
var cs_iUserDefined = 5
var cs_iStatic = 6
var cs_BOF = 1
var cs_iColumnOrder = 0
var cs_iSearchOrder = 1
var cs_Empty = ''

cs_SessionTimeout();

function cs_OnChange() {putRMState(document.content.nvCurrentState,1,cs_bTrigger)}
function cs_setRowChange(ob) {putRMState(document.content.nvCurrentState,ob.value,cs_iUserDefinedRowID)}
function cs_SessionTimeoutReset() {cs_SetCookie('RMLog',putRMState(cs_GetCookie('RMLog'),cs_TimeStamp(),cs_iTimeStamp),null,'/')}
function cs_DeleteCookie(name,path,domain) {if (cs_GetCookie(name)) document.cookie = name + "=" + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ";expires=Thu, 01-Jan-70 00:00:01 GMT"}
function cs_SetCookie(name,value,expires,path,domain,secure) {document.cookie = name + "=" + escape(value) + ((expires) ? ";expires=" + expires.toGMTString() : "") + ((path) ? ";path=" + path : "") + ((domain) ? ";domain=" + domain : "") + ((secure) ? ";secure" : "")}
function cs_scrollWindow() {window.scrollTo(1,1)}
function isUndefined(a) {return typeof a == 'undefined';} 

function cs_SessionTimeout() {
 if ((cs_TimeStamp() - getRMState(cs_GetCookie('RMLog'),cs_iTimeStamp)) >= iMinutesTimeout) cs_Logout();  
 setTimeout('cs_SessionTimeout()',iMinute)   
}

function cs_TimeStamp() {
  var d = new Date();
  return Math.round(d.getTime()/iMinute)
}

function cs_Logout() {
  cs_SetCookie('RMLog','',null,'/');
  cs_DeleteCookie('RMLog',null,'/');
  location.href = '/admin/RMLogon/tp_RMLogoutForm.asp'
}

function cs_CheckLogStatus() {
  if (!opener.parent.RMAnchor) window.close();
  setTimeout('cs_CheckLogStatus()',1000)   
}

function cs_OnKeyPress() {
  var iKeyCode = window.event.keyCode;
  if (cs_IsValidCharacter(iKeyCode)) {
    document.content.bTrigger.value="1";
    cs_SessionTimeoutReset()  
  }  
}

function cs_GetCookie(param) {
  var c = unescape(document.cookie), i=0;
  param += "=";
  while (i < c.length) {
    var j = i + param.length;
    if (c.substring(i,j) == param) {
      var k = c.indexOf(";", j);
      if (k == -1) k = c.length;
      return c.substring(j,k);
    }
    i = c.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

function cs_OnMousedown(param) {
  param.style.border='1px inset white';
}

function cs_OnROMousedown(param) {
  var oState = document.content.nvCurrentState;
  cs_OnMousedown(param);
  cs_Descend(param)
}

function cs_OnCBMousedown(param) {
  cs_OnChange();
  var oImg = param.name.replace('btn','img');
  var nvImg = document[oImg].src;
  var onStr = 'On.gif';
  var offStr = 'Off.gif';
  if (nvImg.lastIndexOf(offStr) != -1) {
    nvImg = nvImg.replace(offStr,onStr);
  } else {
    nvImg = nvImg.replace(onStr,offStr);
  }
  document[oImg].src = nvImg;
}

function getSelectedCategories() {
  var nvImg = cs_Empty, nvCategoryState = cs_Empty;
  var ob = document.content;
  var ar = ob.nvImageArray.value.split('|');
  var k = ar.length;
  for (var i=0; i<k; ++i) {
    nvImg = document['img_' + ar[i]].src;
    if (nvImg.lastIndexOf('On.gif') != -1) nvCategoryState += ar[i] + '|'
  }
  ob.nvCategoryState.value = nvCategoryState.substr(0,nvCategoryState.length-1);
}

function cs_OnMenuMouseover(param) {
  var ar = param.name.split('_');
  var oImg = 'img_' + ar[1];
  switch(parseInt(ar[1])) {
    case 1 : document[oImg].src = '/images/cs_RMNewOn.gif'; break;
    case 2 : document[oImg].src = '/images/cs_RMDeleteOn.gif'; break;
    case 3 : document[oImg].src = '/images/cs_RMFindOn.gif'; break;
    case 4 : document[oImg].src = '/images/cs_RMOptionsOn.gif'; break;
    case 5 : document[oImg].src = '/images/cs_RMLogoutOn.gif'; break;
    case 21 : document[oImg].src = '/images/cs_RMSaveOn.gif'; break;
    case 22 : document[oImg].src = '/images/cs_RMNewOn.gif'; break;
    case 23 : document[oImg].src = '/images/cs_RMDeleteOn.gif'; break;
    case 24 : document[oImg].src = '/images/cs_RMCancelOn.gif'; break;
  }
}

function cs_OnMenuMouseout(param) {
  param.style.border='1px solid #D4D0C8';
  var ar = param.name.split('_');
  var oImg = 'img_' + ar[1];
  switch(parseInt(ar[1])) {
    case 1 : document[oImg].src = '/images/cs_RMNewOff.gif'; break;
    case 2 : document[oImg].src = '/images/cs_RMDeleteOff.gif'; break;
    case 3 : document[oImg].src = '/images/cs_RMFindOff.gif'; break;
    case 4 : document[oImg].src = '/images/cs_RMOptionsOff.gif'; break;
    case 5 : document[oImg].src = '/images/cs_RMLogoutOff.gif'; break;
    case 21 : document[oImg].src = '/images/cs_RMSaveOff.gif'; break;
    case 22 : document[oImg].src = '/images/cs_RMNewOff.gif'; break;
    case 23 : document[oImg].src = '/images/cs_RMDeleteOff.gif'; break;
    case 24 : document[oImg].src = '/images/cs_RMcancelOff.gif'; break;
  }
}

function cs_OnReturnKey() {
  if (window.event.keyCode == 13) {
    window.event.returnValue = false; 
    window.close()
  }  
}  

function cs_IsValidCharacter(param) {
  var iKeyCode = parseInt(param);
  if ((iKeyCode > 31) && (iKeyCode < 127)) return true;
  return false;
}  

function cs_Descend(param) {
  var oState = document.content.nvCurrentState;
  var ar0 = oState.value.split('|');
  var nvCurrentOrderFieldName = ar0[cs_iOrderFieldName];
  var ar1 = param.name.split('|');
  var oImg = 'imgMenu_' + ar1[1];
  var nvOrderFieldName = ar1[2];
  var nvImage = '/images/cs_CategoryDescending.gif';
  if (nvCurrentOrderFieldName == nvOrderFieldName) nvImage = (getRMState(oState,cs_iThisOrderTypeID) == iDescend) ? '/images/cs_CategoryDescending.gif' : '/images/cs_CategoryAscending.gif';
  document[oImg].src = nvImage
}

function cs_DeselectRow() {
  if (oThisTupple) {
    oThisTupple.style.background='white';
    oThisTupple.style.color='black'
  }  
}

function cs_SelectRow(ob) {
  ob.style.background='#003366';
  ob.style.color='white';
  oThisTupple = ob
}

function initialiseRMState(iMetaCategoryID,iCategoryID) {
  var oState = document.content.nvCurrentState;
  putRMState(oState,0,cs_iFirstRowID);
  putRMState(oState,0,cs_iLastRowID);
  putRMState(oState,0,cs_iIncrement);
  putRMState(oState,cs_BOF,cs_iTypeID);
  putRMState(oState,iMetaCategoryID,cs_iMetaCategoryID);
  location.href = 'tp_RMCategories.asp?q=' + putRMState(oState,iCategoryID,cs_iCategoryID)
}

function getRMState(ob,i) {
  if (!ob) return;
  var ar = (typeof(ob) == 'string') ? ob.split('|') : ob.value.split('|');
  return parseInt(unescape(ar[i]));
}

function putRMState(ob,param,j) {
  var ar = (typeof(ob) == 'string') ? ob.split('|') : ob.value.split('|');
  var str = cs_Empty;
  var k = ar.length-1;
  for (var i=0; i<=k; ++i) {
    if (i==j) {
      str += escape(param);
    } else {  
      str += ar[i];
    }
    if (i<k) str += '|'  
  }
  ob.value = str;
  return str
}

function cs_IsDelete() {
  if (confirm('This action will permanently remove this resource\r\nand all references to this resource from the\rsystem\r\n\r\nAre you sure you wish to continue...')) return true;
  return false
}

function cs_IsSave() {
  var oState = document.content.nvCurrentState;
  if (getRMState(oState,cs_bTrigger) == 0) return false;
  if (confirm('Do you wish to save your changes?')) return true;
  document.forms.content[0].focus();
  return false
}

function cs_NewTupple() {
  var oState = parent.RMCategories.document.content.nvCurrentState;
  var iMetaCategoryID = getRMState(oState,cs_iMetaCategoryID);
  if (iMetaCategoryID == -1) {
    alert('Please select a category you wish the resource to belong to...')
  } else {  
    parent.RMCategories.cs_CreateTupple()
  }  
}  

function cs_CreateTupple() {
  cs_ConfirmUpdate();
  var oState = document.content.nvCurrentState;
  var iPreviousResourceID = getRMState(oState,cs_iResourceID);
  var iHeight = 480;
  var iWidth = 640;
  putRMState(oState,iPreviousResourceID,cs_iPreviousResourceID);
  putRMState(oState,-1,cs_iResourceID);
  putRMState(oState,1,cs_bCreate);
  var nvURL = 'tp_RMResource.asp?q=' + oState.value;
  popWindow(cs_RMResource,nvURL,iHeight,iWidth)
}

function cs_CancelCreateTupple() {
  var ob = document.content;
  var oState = ob.nvCurrentState;
//  putRMState(oState,getRMState(oState,cs_iFirstRowID)+1,cs_iUserDefinedRowID); 
  cs_GetThisTupple(getRMState(oState,cs_iPreviousResourceID))
}  

function cs_SaveTupple(param) {
  var ob = document.content;
  var oState = ob.nvCurrentState;
  if (!cs_IsValidTupple()) return false;
  if (!param) param = -1;
  var iSaveType = (parseInt(param) < 1) ? iInsert : iUpdate;
  putRMState(oState,0,cs_bTrigger);
  putRMState(oState,cs_iStatic,cs_iTypeID);
  if (typeof(ob.nvFileAs)) cs_ResetFileAs();
  if (ob.nvImageArray.value) getSelectedCategories();
//  if (getRMState(oState,cs_iDataViewID) == iFormView_Resource) cs_ResetFileAs();
//  if (getRMState(oState,cs_iDataViewID) == iFormView_Categories) getSelectedCategories();
//  submitForm('tp_RMForm.asp?q1=' + iSaveType + '&q2=' + iResourceView + '&q3=' + oState.value);
  setTimeout('cs_RefreshThisList()',100);
  return true;
}  

function cs_DropTupple() {
  var oState = parent.RMCategories.document.content.nvCurrentState;
  var iResourceID = (parent.RMCategories.oThisTupple) ? parent.RMCategories.oThisTupple.id : null;
  if (!iResourceID) {
    alert('Please select the resource you wish to delete...')
  } else {  
    parent.RMCategories.cs_DeleteTupple(iResourceID,iCategoryView)
  }  
}  

function cs_DeleteTupple(iResourceID,iView) {
  var bRefresh = false;
  var bDelete = true;
  var oState = document.content.nvCurrentState;
  if (!iResourceID) {
    alert('Please select the resource you wish to delete...');
  } else {  
    if (cs_IsDelete()) {
      bCancelled = false;
      if (iView == iResourceView) bRefresh = true;
      putRMState(oState,cs_iStatic,cs_iTypeID);
      putRMState(oState,iResourceID,cs_iResourceID)
      submitForm('tp_RMForm.asp?q1=' + iDelete + '&q2=' + iView + '&q3=' + oState.value);
    } else {
      bCancelled = true;
    }
  }
  setTimeout('cs_RefreshThisList(' + bDelete + ')',100);
}  

function cs_ConfirmUpdate() {
  var ob = document.content;
  var oState = ob.nvCurrentState;
  if (ob.iDocumentID.value != 1) return true;
  if (cs_IsSave()) {
    if (cs_SaveTupple(getRMState(oState,cs_iResourceID))) return true;
  } else {
    if (typeof(ob.nvFileAs)) ob.nvFileNameAs.value = ob.nvInitialFileAs.value
  }  
  return false;
}  

function cs_SetFocus(tabIndex) {
  var ob = document.content[tabIndex];
  if (!ob.disabled) ob.focus();
}

function cs_IsValidOb(ob,nvAlert,obFocus,bPermitNull) {
  var param = ob.value;
  var oFocus = (obFocus) ? obFocus : ob;
  if (bPermitNull && !param) return true;
  if (!param) {
    alert(nvAlert);
    oFocus.focus();
    return false;
  }
  return true;
}

function cs_RefreshThisList(bDelete) {
  var bForceRefresh = (bDelete) ? true : false;
  var ob = document.content;
  var oState = ob.nvCurrentState;
  var iDataViewID = getRMState(oState,cs_iDataViewID);

  var bDataViewID_Resource = (typeof(ob.nvFileAs)) ? true : false;
  var bDataViewID_Categories = (ob.nvImageArray.value) ? true : false;
//  if ((bForceRefresh) || (bDataViewID_Resource) || (bDataViewID_Categories)) {

alert(bDataViewID_Resource);
alert(bDataViewID_Categories);


//  if ((bForceRefresh) || (iDataViewID == iDataViewID_Resource) || (iDataViewID == iDataViewID_Categories)) {
    var oState = document.content.nvCurrentState;
    if (ob.iDocumentID.value == 0) {
      location.href = 'tp_RMCategories.asp?q=' + oState.value
    } else {  
      window.opener.location.href = 'tp_RMCategories.asp?q=' + oState.value
    }  
//  }  
}

function cs_RowSelect(ob) {
  cs_DeselectRow();
  cs_SelectRow(ob)
}

function cs_DefaultOptions() {
  var iHeight = 480;
  var iWidth = 640;
  var nvURL = 'tp_RMDefaults.asp';
  popWindow(cs_RMOptions,nvURL,iHeight,iWidth)
}

function cs_getColorPicker(param) {
  var iHeight = 480;
  var iWidth = 640;
  var nvURL = 'tp_ColorPicker.asp?q=' + escape(param);
  popWindow(cs_RMColourPicker,nvURL,iHeight,iWidth)
}

function cs_PopTab(oState,iFormViewSystemID,iFormViewID) {
  putRMState(oState,iFormViewSystemID,cs_iSystemFormViewID);
  putRMState(oState,iFormViewID,cs_iFormViewID);
  var iHeight = 480;
  var iWidth = 640;
  var nvURL = 'tp_RMResource.asp?q=' + oState.value;
  popWindow(cs_RMResource,nvURL,iHeight,iWidth)
}

function cs_GetTab(iFormViewSystemID,iFormViewID) {
  var ob = document.content;
  var oState = ob.nvCurrentState;
  var bCreate = (getRMState(oState,cs_bCreate)) ? true : false;
  var bConfirm = false;
  if ((getRMState(oState,cs_bTrigger) == 1) || (bCreate)) {
    bConfirm = true;
    if (typeof(ob.nvFileAs)) if (!cs_IsValidTupple()) bConfirm = false;
  }  
  if (bConfirm) if (cs_ConfirmUpdate()) setTimeout('cs_RefreshThisList()',100);
  if (bCreate) {
     if (bConfirm) cs_PopTab(oState,iFormViewSystemID,iFormViewID);  
  } else {
    cs_PopTab(oState,iFormViewSystemID,iFormViewID);
  }   
}

function cs_GetTupple(iResourceID,bReset) {
  var oState = document.content.nvCurrentState;
  if (getRMState(oState,cs_bTrigger) == 1) {
    var nvURL = 'cs_GetThisTupple(' + iResourceID + ',' + bReset + ')';
    if (cs_ConfirmUpdate()) setTimeout(nvURL,1000)
  }  
  cs_GetThisTupple(iResourceID,bReset)
}

function cs_GetThisTupple(iResourceID,bReset) {
  var ob = document.content;
  var oState = ob.nvCurrentState;
  var bScrollable = true
  var bResizable = true
  var iPreviousResourceID = getRMState(oState,cs_iResourceID);
  if (bReset) cs_ResetForm();
  if (getRMState(oState,cs_bCreate)) putRMState(oState,0,cs_iUserDefinedRowID);
  putRMState(oState,iPreviousResourceID,cs_iPreviousResourceID);
  putRMState(oState,iResourceID,cs_iResourceID);
  putRMState(oState,0,cs_bCreate);
  var nvURL = 'tp_RMResource.asp?q=' + oState.value;
  var iHeight = 480;
  var iWidth = 640;
  popWindow(cs_RMResource,nvURL,iHeight,iWidth,bScrollable,bResizable)
}

function cs_ResetForm() {
  var ob = document.content;
  var oState = ob.nvCurrentState;
  putRMState(oState,null,cs_iSystemFormViewID);
  putRMState(oState,null,cs_iDataViewID);
  putRMState(oState,null,cs_iFormViewID);
}  

function cs_GetThisList(iType) {
  var ob = document.content;
  var oState = document.content.nvCurrentState;
  var iFirstRow = ob.iDisplayFirstRow.value-1;
  var iLastRow = ob.iDisplayLastRow.value;
  if (iFirstRow < 0) iFirstRow = getRMState(oState,cs_iFirstRowID);
  if (!iLastRow) iLastRow = getRMState(oState,cs_iLastRowID);
  if (iLastRow > getRMState(oState,cs_iSubCategoryTotal)) iLastRow = getRMState(oState,cs_iSubCategoryTotal);
  putRMState(oState,iType,cs_iTypeID);
  if (getRMState(oState,cs_iUserDefinedRowID)) {
    putRMState(oState,cs_iUserDefined,cs_iTypeID);
    putRMState(oState,cs_Empty,cs_iUserDefinedRowID)
    putRMState(oState,iLastRow - iFirstRow,cs_iIncrement);
  } 
  putRMState(oState,iFirstRow,cs_iFirstRowID);
  location.href = 'tp_RMCategories.asp?q=' + putRMState(oState,iLastRow,cs_iLastRowID)
}

function cs_GetThisCategory(iMetaCategoryID,iCategoryID) {
  var oState = document.content.nvCurrentState;
  putRMState(oState,cs_iColumnOrder,cs_iSearchType);
  putRMState(oState,cs_Empty,cs_iSearchString);
//  bResetList = (iCategoryID == getRMState(oState,cs_iCategoryID)) ? true : false;
  bResetList = ((iMetaCategoryID == getCRMState(oState,cs_iMetaCategoryID)) && (iCategoryID == getCRMState(oState,cs_iCategoryID))) ? true : false;
  if (bResetList) {
    location.href = 'tp_RMCategories.asp'
  } else {
    initialiseRMState(iMetaCategoryID,iCategoryID);
  }  
}

function cs_GetThisCategoryOrder(param) {
  var oState = document.content.nvCurrentState;
  var ar0 = oState.value.split('|');
  var nvCurrentOrderFieldName = ar0[cs_iOrderFieldName];
  var ar1 = param.name.split('|');
  var iThisOrderID = ar1[1];
  var nvOrderFieldName = ar1[2];
  var iThisOrderTypeID = iAscend;
  if (nvCurrentOrderFieldName == nvOrderFieldName) iThisOrderTypeID = (getRMState(oState,cs_iThisOrderTypeID) == iAscend) ? iDescend : iAscend;
  putRMState(oState,cs_iColumnOrder,cs_iSearchType);
  putRMState(oState,iThisOrderID,cs_iThisOrderID);
  putRMState(oState,nvOrderFieldName,cs_iOrderFieldName);
  putRMState(oState,cs_iStatic,cs_iTypeID);
  location.href = 'tp_RMCategories.asp?q=' + putRMState(oState,iThisOrderTypeID,cs_iThisOrderTypeID)
}

function cs_SearchResource() {
  var oState = parent.RMCategories.document.content.nvCurrentState;
  var iHeight = 125;
  var iWidth = 335;
  var nvURL = 'tp_RMSearch.asp';
  var dFtrs = 'dialogWidth:'+iWidth+'px;dialogHeight:'+iHeight+'px;'+'help:0';
  var ar = new Array(parent.RMAnchor.document.content.nvLastSearch.value);
  var param = window.showModalDialog(nvURL,ar,dFtrs);
  if (param) {
    parent.RMAnchor.document.content.nvLastSearch.value = param;
    putRMState(oState,param,cs_iSearchString);
    putRMState(oState,cs_iSearchOrder,cs_iSearchType);
    putRMState(oState,0,cs_iFirstRowID);
    putRMState(oState,0,cs_iLastRowID);
    putRMState(oState,0,cs_iIncrement);
    putRMState(oState,cs_BOF,cs_iTypeID);
    parent.RMCategories.location.href = 'tp_RMCategories.asp?q=' + oState.value;
  }  
}

function cs_ResetFileAs() {
  var ob = document.content;
  var nvThisName = cs_Empty, nvTitle, nvFirstname, nvMiddleNames, nvSuffix;
  if (ob.nvLastName.value || ob.nvFirstName.value || ob.nvMiddleNames.value) {
    if (ob.nvTitle.value) nvThisName += ob.nvTitle.value.trim();
    if (ob.nvLastName.value) {
      if (ob.nvTitle.value) nvThisName += ' ';
      nvThisName += ob.nvLastName.value.trim();
      if ((ob.nvLastName.value) && (ob.nvFirstName.value || ob.nvMiddleNames.value)) nvThisName += ', ';
    }  
    if (ob.nvFirstName.value) {
      if ((!ob.nvLastName.value) && (ob.nvFirstName.value)) nvThisName += ' ';
      nvThisName += ob.nvFirstName.value.trim();
    }   
    if (ob.nvMiddleNames.value) {
      if (ob.nvTitle.value || ob.nvLastName.value || ob.nvFirstName.value) nvThisName += ' ';
      nvThisName += ob.nvMiddleNames.value.trim()
    }  
    if (ob.nvSuffix.value) {
      if (ob.nvTitle.value || ob.nvLastName.value || ob.nvFirstName.value || ob.nvMiddleNames.value) nvThisName += ' ';
      nvThisName += ob.nvSuffix.value.trim();
    }  
  } else {
    nvThisName = ob.nvCompanyName.value.trim();
  }
  ob.nvFileAs.value = nvThisName.trim();
  ob.nvFileNameAs.value = ob.nvFileAs.value
}

function cs_BrowserType() {	
  var nvType, nvUserAgent = navigator.userAgent.toLowerCase();
  if (nvUserAgent.indexOf("msie") != -1) {
    nvType = "ie";
    if (nvUserAgent.indexOf("mac") != -1) nvType = "iemac";
  } else if (nvUserAgent.indexOf("mozilla") != -1) {
    nvType = "nn";
    if (nvUserAgent.indexOf("gecko") != -1) nvType = "nn6";
    if (nvUserAgent.indexOf("linux") != -1) nvType = "nnlinux";
    if (nvUserAgent.indexOf("mac") != -1) nvType = "nnmac"; 
  } else {
    nvType = "other";
  }
  return nvType;
}  

function cs_GetScreenHeight() {
  var n;
  switch (cs_BrowserType()) {
    case "ie": n = screen.height; break;
    case "iemac": n = screen.height; break;
    case "nn": n = screen.height + 19; break;
    case "nn6": n = screen.height + 19; break;
    case "nnlinux": n = screen.height + 19; break;
    case "nnmac": n = screen.height + 19; break;
    default: n = 460
  }
  switch(n) {
    case 480 : return 182;
    case 600 : return 308;
    case 768 : return 487;
    case 864 : return 583;
    case 960 : return 602;
    case 1024 : return 602;
    case 1200 : return 602;
    case 1280 : return 615;
    default: return 308;
  }
}

function submitForm(param,ignoreLock) {
  if ((!ignoreLock) && dbLocked()) return;  
  document.content.action = param;
  document.content.submit();
}

//function popWindow(nvWindowName,nvURL,iHeight,iWidth,bNoScroll,bNoResize) {
// if (!iHeight) iHeight = 640;
// if (!iWidth) iWidth = 500;
//  var nvScroll = (bNoScroll) ? 'yes' : 'no';
//  var nvResize = (bNoResize) ? 'yes' : 'no';
//  remote = window.open(cs_Empty,nvWindowName,'height='+iHeight+',width='+iWidth+',status=no,toolbar=no,menubar=no,location=no,scrollbars='+nvScroll+',resizable='+nvResize);
//  if (remote != null) {
//    if (remote.opener == null) remote.opener == self;
//    remote.location.href = nvURL;
//  }  
//}

function dbLocked() {
  var oState = document.content.nvCurrentState;
  var bSiteLocked = (getRMState(oState,cs_iSiteLocked) == 1) ? true : false;
  var bException = (getRMState(oState,cs_iAccountTypeID) == 1) ? true : false;
  if (bSiteLocked && (!bException)) {
    alert('The site is currently undergoing essential maintenance. Access is restricted.\r\n\r\nPlease logon at a later time...');
    return true;
  }
  return false;
}

document.write("<SCR" + "IPT LANGUAGE='JavaScript1.2' SRC='/_ScriptLibrary/Encryption/rijndael.js' TYPE='text/javascript'><\/SCR" + "IPT>");

