
var events = [];

function addEvent(typ, funkce){

	if(!events[typ]) events[typ] = [];
   events[typ][events[typ].length] = funkce;
}

function event(typ, config){

	if(events[typ]){

		if(!config) config = {};

		for(var i = 0; i < events[typ].length; i++){
   		events[typ][i](typ, config);
		}
   }
}

var myEvent = event;

function errorEfekt(el, color1, color2, time0, prodleva){

	var krok = 50;
	var interval = null;
	
	if(el.toLowerCase) el = document.getElementById(el);

	var r1,g1,b1,r2,g2,b2,kroku,krokR,krokG,krokB,time;

	this.reStart = function(){
	
	   time = time0;

		r1 = parseInt(color1.substr(0,2), 16);
		g1 = parseInt(color1.substr(2,2), 16);
		b1 = parseInt(color1.substr(4,2), 16);

		r2 = parseInt(color2.substr(0,2), 16);
		g2 = parseInt(color2.substr(2,2), 16);
		b2 = parseInt(color2.substr(4,2), 16);

		kroku = time/krok;

		krokR = (r2 - r1)/kroku;
		krokG = (g2 - g1)/kroku;
		krokB = (b2 - b1)/kroku;

	   if(interval) clearInterval(interval);
		if(!prodleva){

			interval = setInterval(casovac, krok);
		}else{

		   setTimeout(function(){

				interval = setInterval(casovac, krok);
			},prodleva);
		}
	}

	function casovac(){

		time -= krok;
	   if(time <= 0){

	      clearInterval(interval);
	      interval = null;
	   }

	   r1 += krokR;
	   g1 += krokG;
	   b1 += krokB;

	   el.style.backgroundColor = 'rgb('+Math.round(r1)+', '+Math.round(g1)+', '+Math.round(b1)+')';
	}

	
	this.reStart();
}

function AntiTimeout()
	{
	$.get("empty.php");
	}

setInterval("AntiTimeout()",119000);

