var simapotty = new Image();
simapotty.src = '/kepek/dot2.jpg';
var aktivpotty = new Image();
aktivpotty.src = '/kepek/dot1.jpg';
var index = 0;
var timeout;
function kepfeltolt () {
	var kepvalto = document.getElementById('kepvalto');
	var pottydiv = document.createElement('div');
	pottydiv.id = 'pottyok';
	var table = document.createElement('table');
	table.cellPadding = 0;
	table.cellSpacing = 0;
	table.border = 0;
	var tbody = document.createElement('tbody');
	var tr = document.createElement('tr');
	var sz = 0;
	for (var i = 0; i < kepek.length; i++) {
		var td = document.createElement('td');
		var kep = document.createElement('img');
		var potty = document.createElement('img');
		kep.src = kepek[i].src;
		kep.alt = '';
		potty.id = 'potty'+i;
		potty.setAttribute ('class', 'potty');
		$(potty).bind ('click', function () { kepvalto_f (parseInt(this.id.substr(5))); });
		if (i == index) potty.src = aktivpotty.src;
		else potty.src = simapotty.src;
		pottydiv.appendChild (potty);
		if (i > 0) {
			sz += kepek[i-1].width;
		}
		kepek[i].eddig = sz;
		td.appendChild (kep);
		tr.appendChild (td);
	}
	tbody.appendChild (tr);
	table.appendChild (tbody);
	kepvalto.appendChild (pottydiv);
	kepvalto.appendChild (table);
	timeout = setTimeout ('kepvalto_f()', 7000);
}

var vege = 1;
function kepvalto_f (id) {
	id = parseInt (id);
	if (!isNaN (id) && id == index) return false;
	if (vege == 0) return false;
	vege = 0;
	clearTimeout (timeout);
	var sebesseg = 'slow';
	$('#potty'+index).attr ('src', simapotty.src);
	if (!isNaN (id)) index = id;
	else if (index < kepek.length-1) index++;
	else index = 0;
	$('#potty'+index).animate ({opacity: 0.99}, 'fast');
	$('#potty'+index).attr ('src', aktivpotty.src);
	$('#potty'+index).animate ({opacity: 1.00}, 'fast');
	$('#kepvalto').animate ({scrollLeft: kepek[index].eddig}, sebesseg, function () {
		timeout = setTimeout ('kepvalto_f()', 7000);
		vege = 1;
	});
}
