var currentCount = 0;
var timer;

$(document).ready(function()
{
	$('#eventBox').hide();
	counter();
});

function counter()
{

	if(currentCount == 0)
	{
		checkEvents();
		currentCount = currentCount + 1;
	}
	else if(currentCount == 15)
	{
		currentCount = 0;
	}
	else
	{
		currentCount = currentCount + 1;
	}

	timer = setTimeout("counter()", 1000)
}

function checkEvents()
{
	$.get("checkevents.php", 
		{ 	 
		},
	  function(data){
	  	if(data != '<!-- llama -->')
	  	{
	  		$('#eventBox').html(data);
	  		$('#eventBox').show();
	  	}
	  	else $('#eventBox').hide();
	  	
	  });
}

function hideEvent(eid)
{
	$.get("checkevents.php",
	{
		eid: eid
	},
  function(data){
  	if(data != '<!-- llama -->')
  	{
  		$('#eventBox').html(data);
  		$('#eventBox').show();
  	}
	  else $('#eventBox').hide();
  	
  });
}


jQuery.fn.center = function()
{
    this.css("position","absolute");
    this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
    this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
    return this;
}
