function byId(id){
	var el = document.getElementById(id);
	return el;
}
function rand_f(el,max){	
	var r = Math.round(Math.random()*max)+1;
	el.getElementsByTagName('img')[0].src=path+r+'.gif';
}

function build_grrl(){
	byId('grrl').innerHTML = '<div id="t1"><img src="'+path+'1.gif" alt="" /></div>'+
							'<div id="t2"><img src="'+path+'2.gif" alt="" /></div>'+
							'<div id="t3"><img src="'+path+'3.gif" alt="" /></div>';
}

function preload(){
	var images = new Array();	
	for(var i=0; i<max; i++){
		images[i+1] = new Image();
		images[i+1].src = path+(i+1)+".gif";
	}		
}

function chng_grrl(){
	rand_f(byId('t1'),max);
	rand_f(byId('t2'),max);
	rand_f(byId('t3'),max);	
}

var max = 8;
//var path = '/svobodna/images/tig_';
var path = '/wp/wp-content/themes/svobodna/images/tig_';

function keep_rolling(){
	chng_grrl();
	setTimeout("keep_rolling()", 16000);
}

function start_grrl(){	
	build_grrl();	
	preload();
	
	addEvent( byId('grrl'), 'click', chng_grrl);
	keep_rolling();
}	

addLoadEvent(start_grrl);