  var gXtraParam = '';
  var gCurrPageType = 'INBOX';
  var gCurrMboxId   = 0;


  var gCurrSortColumn   = 5;
  var gCurrSortOrder    = 'D';
  var gCurrStart        = 1;
  var gContentXtraParam = '';
  function emlRefreshContent()
  {
    if ( $('searchParam') != null )
    {
      var searchParam = $('searchParam').value;
      if ( searchParam != '' )
      {
        var selObj = $('searchType');
        var selValue = selObj.options[selObj.selectedIndex].value;
        gContentXtraParam = gContentXtraParam + '&searchType='+selValue+'&searchParam='+escape(searchParam);
      }
    }
    SimpleAJAXCall ( 'xhpEmlRefresh.jsp'+genappend_submiturl+'&refresh=BOX&pt='+gCurrPageType+'&acctid='+gCurrMboxId+'&sortcol='+gCurrSortColumn+'&sortad='+gCurrSortOrder+'&start='+gCurrStart+gContentXtraParam, emlRefreshContentRefresh, 'POST', '' );
  }

  function emlRefreshContentRefresh( in_responseText, in_param )
  {
    $('divEmailInbox').innerHTML = in_responseText;
    gContentXtraParam = '';
//    if ( browser.isIE )  $('divEmailInbox').style.width = "" + (getBrowserSizeX()-250) + "px";
//    else                 $('divEmailInbox').style.width = "" + (getBrowserSizeX()-260) + "px";
    if ( gCurrPageType=='INBOX' )
    {
      if ( $('emlAcctGetting').value == 'Y' ) 
      {
        setTimeout( emlRefreshContent, 2000 );
      }
    }
  }

  function ToggleReadFlag( emlObjId )
  {
    gContentXtraParam = '&ACT=TOGGLEREAD&togglereadid='+emlObjId;
    emlRefreshContent();
  }

  function ToggleSortHeader( col )
  {
    if ( col == gCurrSortColumn )
    {
      if ( gCurrSortOrder == 'D' ) gCurrSortOrder = 'A';
      else                         gCurrSortOrder = 'D';
    }
    else
    {
      gCurrSortColumn = col;
    }
    emlRefreshContent();
  }

  var gLastEmailId = '-1';
  function showEmail( emlObjId )
  {
    gLastEmailId = emlObjId;  // remember the last viewed email. We will need this for reply, reply-all, fwd.

    gContentXtraParam = '&ACT=MARKREAD&markreadid='+emlObjId;
    emlRefreshContent();
    
    var popWin=window.open('ozEmpInbox.jsp?emailDetailId='+emlObjId,'EmailPopupUI','left=10,top=10,width=980,height=700,resizable=yes,scrollbars=no');
    popWin.opener=self;
    popWin.focus();
  }

  function callGet()
  {
        gContentXtraParam = '&ACT=GET';
        emlRefreshContent();
  }
