function Init()
{
  InitEscape();
  HelpdeskWindow();
  setInterval('Ping()', 10000);
  
  if($('#forecast'))
  {
    $('#forecast').mouseout(function() { ForecastToggle(true); }).mouseover(function() { ForecastToggle(false); });
    //$('#forecast .button').click(function() { ForecastToggle(); });
  }
  
  var oScroller = $('#scroller');
  oScroller.html('<marquee>' + oScroller.html() + '</marquee>');
  
  InitAjaxGet('sort');
  //InitAjaxPost('submit');
}

function Ping()
{
  $.get(sBaseUrl + 'Ping/');
}

function InitEscape()
{
  if(self != top)
    top.location.href = self.location.href;
}

function HelpdeskWindow()
{
  oHelpdeskWindow = null;
  
  $('#mainmenu .helpdesk').click(function() {
    if(!oHelpdeskWindow || oHelpdeskWindow.closed)
      oHelpdeskWindow = window.open(this, 'Helpdesk', 'width=735,height=600');
    else
      oHelpdeskWindow.focus();
    
    return false;
  });
}

function SelectCheckboxes(oObject)
{
  $('.checkbox').attr('checked', oObject.checked);
}

function ForecastToggle(bMode)
{
  /*if(typeof bForecast != 'undefined' && LockbForecastLock === true) return false;
  if(typeof oForecast == 'undefined') oForecast = $('#forecast');
  if(typeof iForecast == 'undefined') iForecast = parseInt(oForecast.css('left')) * -1;
  if(typeof bMode == 'undefined') { ForecastToggle((iForecast <= 0) ? false : true); return true; }
  
  bForecastLock = true;
  
  if(bMode)
  {
    if(iForecast <= 0) bForecastLock = false;
    else iForecast -= 5;
  }
  else
  {
    if(iForecast >= 120) bForecastLock = false;
    else iForecast += 5;
  }
  
  oForecast.css('left', '-' + iForecast + 'px');
  
  if(bForecastLock)
    setTimeout('ForecastToggle(' + bMode + ')', 1);
  */
  var oForecast = $('#forecast'); var iForecast = 0;
  
  if(typeof bMode == 'undefined')
    bMode = (parseInt(oForecast.css('left')) == 0);
  
  oForecast.css('left', ((bMode) ? -120 : 0) + 'px');
}

$(document).ready(function() {
  Init();
});

