﻿function pastpost (seconds) {
	d = new Date();
	d = new Date(d-seconds*1000);
	hour = d.getHours();
	min = d.getMinutes();
	sec = d.getSeconds();
	if (min <= 9) {
      min = "0" + min;
    }
    if (sec <= 9) {
      sec = "0" + sec;
    }
	if (hour <= 9) {
      hour = "0" + hour;
    }
	return hour + ":" + min + ":" + sec;
};

function pastdate (dates) {
	da = new Date();
	da = new Date(da-dates*24*60*60*1000);
	day = da.getDate();
	month = da.getMonth();
	month = month + 1;
	year = da.getFullYear();
	return day + "." + month + "." + year;
};

function getRandomInt(min, max) {
  return Math.floor(Math.random() * (max - min + 1)) + min;
}


$(document).ready(function(){
	//Онлайн
	$(".online span").text(getRandomInt(87,201));
	//Даты комментов
	$("#com1").text(pastdate(0));
	$("#com2").text(pastdate(1));
	$("#com3").text(pastdate(1));
	$("#com4").text(pastdate(1));
	$("#com5").text(pastdate(2));
	//Выводим чат
	$("#mes1 .time").text(pastpost(67));
	$("#mes2 .time").text(pastpost(53));
	$("#mes3 .time").text(pastpost(40));
	$("#mes4 .time").text(pastpost(0-13));
	$("#mes5 .time").text(pastpost(0-17));
	$("#mes6 .time").text(pastpost(0-23));
	$("#mes7 .time").text(pastpost(0-31));
	$("#mes1").fadeIn();
	$("#mes2").fadeIn();
	$("#mes3").fadeIn();
	$("#mes4").delay(13000).fadeIn();
	$("#mes5").delay(17000).fadeIn();
	$("#mes6").delay(23000).fadeIn();
	$("#mes7").delay(31000).fadeIn();
	
	$("#chatbtn").click(function(){
		$(".chatform").fadeOut();
		$("#afterform").delay(500).fadeIn();
	});
	
	$("#addlbl").click(function(){
		$("#commentform").slideDown();
		$("#addlbl").fadeOut();		
	});	
	
	$("#commbtn").click(function(){
		$("#commentform").fadeOut();	
		$("#commbtn").fadeOut();
		$("#aftercomment").fadeIn();
		$("#downround").fadeIn();
	});	
});
