   function CInt(vVariant)
    {
            var num = 0;
            if (CStr(vVariant) != "" && !isNaN(vVariant))
                num = parseInt(vVariant);

        return num;
    }
    
    
    function CStr(vVariant)
    {
        var str = new String(vVariant).toString();
        if (str == "null" || str == "undefined")
            return "";
        else
            return str;
    }
    
       
	function FormatDate(sDate, bReturnYearOnly)
	{
      if(CStr(sDate) != "")      
      {
         var d = new Date(sDate);
         if (bReturnYearOnly)
            return (d.getFullYear());
         else
            return ((d.getMonth() + 1) + "/" + d.getDate() + "/" + d.getFullYear());
      }
      else
         return "";
	}
	
	function checkAll(checkboxes, checked)
	{
	  if (!checkboxes)
	    return;
	  if (!checkboxes)
	  {
	    checkboxes.checked = checked
	    return;
	  }
	  for (var i = 0; i < checkboxes.length; i++)
	    checkboxes[i].checked = checked
	}
	
	function setFormAction()
	{
    for (var i = 0; i < document.forms.length; i++)
      if (document.forms[i].action == "")
        document.forms[i].action = document.location.pathname;
	}
	
  function deleteCurrentItem(displayText, form)
  {
    if (confirm(displayText))
    {
      if (form == null)
        form = event.srcElement.form;
      form._Action.value = "Delete";
      form.submit();
    }
  }
  
  function deleteItem(displayText, IDName, ID, _Status)
  {
    if (displayText == null)
      displayText = "Are you sure you want to delete this " + IDName.substr(0, IDName.length - 2) + "?"
    if (confirm(displayText))
    {
      var frm = document.DeleteForm;
      if (!frm)
      {
        frm = document.FilterForm;
        frm._Action.value = "Delete"
      }
      frm.PK.value = ID;
      frm.PK.name = IDName;
      if (_Status)
        frm._Status.value = _Status
      frm.submit();
    }
  }
	
	
  function dialogFrameset(page, params, width, height)
  {
    if (width == null)
      width = 535
    if (height == null)
      height = 400
    if (1 == window.showModalDialog("DialogFrameset.asp?Page=" + page + "&" + params,
                                      "", 
                                      "dialogWidth: " + width + "px;dialogHeight: " + height + "px; status: no")
        )
    {
      var frm = document.FilterForm
      if (frm == null)
        document.location = document.location
      else
        frm.submit();
    }
  }
  
  function filterValueChanged(e)
  {
    var frm = document.FilterForm
    frm.elements(e.name).value = e.value;
    frm.submit();
  }
	
	
	function setLogoutTimer(timeout)
	{
	  var topPage = findTopRow();
	  if (null != topPage && null != topPage.register)
	  {
	    var myDocID = topPage.register();
      window.setTimeout('checkLogout(' + myDocID + ')', timeout);
    }
	}
	function checkLogout(myDocID)
	{
	  var topPage = findTopRow();
	  if (null != topPage && topPage.getLastDocID() == myDocID)
	  {
	    var DPSWebTop = findDPSWebTop();
	    if (DPSWebTop != null)
	    DPSWebTop.navigate("");
	  }
	}
	/**
	  This function looks for topmost frameset of DPSWeb. If DPSWeb is open in a separate
	  window, function returns window.top. If it is open in a frame of bigger frameset, that 
	  frame is returned.
	*/
	function findDPSWebTop()
	{
    var p = window.self
    var i = 0;
    while (p != null && i++ < 5)
    {
      if (p.document.body != null)
      {
        if (p.document.body.name == "MiamiTop")
          return p;
      }
      p = p.parent;
    }
    return null;
  }
  
  function findTopRow()
  {
	  var DPSWebTop = findDPSWebTop();
    if (DPSWebTop == null)
      return null;
    return DPSWebTop.TopPage;
  }
	
	function disableMenu()
	{
	  var topPage = findTopRow();
	  if (topPage != null && topPage != window && null != topPage.doDisableMenu)
	  {
	    topPage.doDisableMenu()
	  }
	}
	
	function enableMenu()
	{
	  var topPage = findTopRow();
	  if (topPage != null && topPage != window && null != topPage.doDisableMenu)
	    topPage.doEnableMenu()
	}
	
	disableMenu();
	window.onload = new Function("enableMenu()");
