function timeAgo(t){
	if(t==0){return 'Never';}
	t=parseInt(t);
  periods = new Array("second", "minute", "hour", "day", "week", "month", "year", "decade");
  lengths = new Array("60","60","24","7","4.35","12","10");
   now = Math.round((new Date()).getTime() / 1000);
       difference     = now - t;
       tense         = "ago";
   for(j = 0; difference >= lengths[j] && j < lengths.length-1; j++) {
       difference = difference/lengths[j];
	}
   difference = Math.round(difference);

   if(difference != 1) {
       periods[j]+= "s";
   }
   
	return difference+" "+periods[j]+ " ago ";
}
function updateTimeAgo(){
$(".timeAgo").each(function(){
									$(this).html(timeAgo($(this).attr("title")));
});	
}
function emailCheck(t){
	$.ajax({
							  type: "GET",
							  url: "ajax.php?a=emailCheck&email="+t.value,
							}).done(function( msg ) {
								if(msg=='success'){
									t.style.border='1px solid #0C0';
								}else{
									t.style.border='1px solid #C00';
								}
							});
}
function usernameCheck(t){
						$.ajax({
							  type: "GET",
							  url: "ajax.php?a=usernameCheck&username="+t.value,
							}).done(function( msg ) {
								if(msg=='success'){
									t.style.border='1px solid #0C0';
								}else{
									t.style.border='1px solid #C00';
								}
							});
					}
function rate(i,r) {
	    var returnF = false;
	    $.ajax({
	        url: siteUrl+"/ajax.php?a=rate&id="+i,
	        global: false,
	        type: "POST",
	        data: "rate=" + r,
	        async: false,
	        success: function (msg) {
	            returnF = msg;
	        }
	    });
	    return returnF;
	}	
	$(document).ready(function () {
						   updateTimeAgo();
						   setInterval('updateTimeAgo();',1000);
						   var i=0;
					$(".ajaxMessage").each(function(){
									$(this).slideDown(1000);	
									setTimeout('$(".ajaxMessage").stop().slideUp(1000);',5000);
});
						
	    $('#cancelX').click(function () {

	        $("#loginform").fadeOut(600);
	        $("#loginlinks").fadeIn(600);
	        return false;

	    });
	    $('#loginX').click(function () {
	        $("#loginlinks").fadeOut(600);
	        $("#loginform").fadeIn(600);
	        return false;
	    });
	    var dataContent;
	    $(".hovereffect img").mouseover(function () {
	        $(this).animate({
	            height: '-=25'
	        }, 1000);
	        $(".hovereffect .gamename").stop().animate({
	            backgroundColor: '#5d7c15'
	        }, 1000);

	    });
	    $(".hovereffect img").mouseout(function () {
	        $(this).animate({
	            height: '+=25'
	        }, 1000);
	        $(".hovereffect .gamename").stop().animate({
	            backgroundColor: '#000'
	        }, 1000);
	    });


	});
