var backCounter  =new Array();
var backCounterTime = 1000;
var addBackCounter = function($el, start){
	backCounter.push({element:$el, indul:start});
};

var doBackCounter = function (){
	var sec = 0;
	var min = 0;
	var hour = 0;
	jQuery.each(backCounter, function(){
		this.indul = this.indul - backCounterTime/1000;
		if (this.indul < 0){return;}
		var ido = this.indul;
		var idoleft = ido;
		sec = ido % 60;
		ido = (ido-sec)/60;
		min = ido % 60;
		ido = (ido-min)/60;
		hour = ido % 24;
		ido = (ido-hour)/24;
	
		var title = '';
		if (ido>0){
			title = title+ido+" nap, ";
		}

		if (hour>0){
			if (hour < 10){
				hour = "0"+hour;
			}
			title = title+hour+":";
		}

		if (min>0){
			if (min < 10){
				min = "0"+min;
			}
			title = title+min+":";
		}

		if (sec < 10){
			sec = "0"+sec;
		}	
		title = title+sec

		if (idoleft==300){
			$("#kosaralert").show();
			$(".place").hide();
		}
		if (idoleft==0){
			document.location.href='/';
		}		
		this.element.html(title);
	});
	setTimeout("doBackCounter()", backCounterTime);
};

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