//Tiny lib, events wrapper (c)Alexander Melanchenko, http://alexnd.com

$EVP={
_onresizes:new Array(),
_onloads:new Array(),
_time_threads:new Array(),

add_onresize:function(f){
	$EVP._onresizes[$EVP._onresizes.length]=f;
},
onresize:function(){
	for(var i=0; i<$EVP._onresizes.length; i++){
		var f=$EVP._onresizes[i];
		if('function'==typeof f)f();
	}
},

add_onload:function(f){
	$EVP._onloads[$EVP._onloads.length]=f;
},
onload:function(){
	for(var i=0; i<$EVP._onloads.length; i++){
		var f=$EVP._onloads[i];
		if('function'==typeof f)f();
	}
},

add_time_thread:function(c, o, p){
	if( !('function' == typeof c && 'function' == typeof o && p>0) )return null;
	var i=$EVP._time_threads.length,d=new Date(),t=d.getTime(),m=d.getMilliseconds();
	$EVP._time_threads[i]={
		_:null,
		_i:i,
		_c:c,
		_o:o,
		_p:p,
		_ts:t,
		_t:t,
		_m:m,
		_f:function(){
			var fd=new Date();
			$EVP._time_threads[i]._t=fd.getTime();
			$EVP._time_threads[i]._m=fd.getMilliseconds();
			if( 'function' == typeof $EVP._time_threads[i]._c && $EVP._time_threads[i]._c() ){
				clearInterval($EVP._time_threads[i]._);
				$EVP._time_threads[i]._o();
				$EVP._time_threads[i]=null;
			}
		}
	};
	$EVP._time_threads[i]._=setInterval($EVP._time_threads[i]._f, p);
	return i;
},
delete_time_thread:function(i){
	if('object' != typeof $EVP._time_threads[i])
	{
		$EVP._time_threads[i]=null;
	}
},
fire_time_thread:function(i){
	if('object' != typeof $EVP._time_threads[i])
	{
		$EVP._time_threads[i]._o();
	}
},

init:function(){
	window.onresize=$EVP.onresize;
	window.onload=$EVP.onload;
}
}
