//  Interested in looking at our code?  Maybe you should work for us !!!

//  If you understand most of what is going on below this message and you have a real passion 
//  for working somewhere which breaks into new opportunites and CAN'T STAND red tape you may 
//  be right for the job.  Drop us an email: info@puntersparadise.com.au

  var iph = new IndexHandler();

  function IndexHandler()
  {
    this.currentFeed = 'News';
    this.lastRan = 0;
    this.feedLength = 0;
  }

  IndexHandler.prototype.updateCurrentFeed = function()
  {
    var now = new Date();
    if ((now-iph.lastRan) > 24000) //greater than 4 minutes?
    {
      iph.switchFeed(iph.currentFeed,false);
    }
  }

  IndexHandler.prototype.switchFeed = function(page,moreResults)
  {
    if (typeof(moreResults) == 'undefined')
    {
      iph.feedLength = 0;
    }
    else if (moreResults == true)
    {
      iph.feedLength += 15;
    }
    $(".feedLoading").removeClass("noShow");
    $(".moreResultsLink").addClass("noShow");
    setCookieNoExp("HomeFeed",page);
    $(".subtabs li.active").removeClass("active");  //deselect this item
    $(".subtabs li." + page).addClass("active");  //select the new item
    //Load the feed
    var now = new Date()
    iph.lastRan = now;
    var randomnumber=Math.floor(Math.random()*10000)
    $("#feedContent").load("/index_FetchFeed" + page + ".php?rnd="+randomnumber+"&l="+iph.feedLength,null,function () { $(".feedLoading").addClass("noShow"); $(".moreResultsLink").removeClass("noShow"); } );
    iph.currentFeed = page;
    //Run the timer for 5 minutes
    iph.runTimer();
  }

  IndexHandler.prototype.runTimer = function()
  {
    window.setTimeout(function() { iph.updateCurrentFeed(); }, 60000*5);
  }

  $(document).ready(function() 
  {
    $('.ladderUserMenu').hover(
			function() { $('ul', this).css('display', 'inline'); },
			function() { $('ul', this).css('display', 'none'); });
  });