$(document).ready(function() {
	//$(function(){
		$('.foto_nahodna a:gt(0)').hide();
		$('.foto_nahodna a:first').show();
		setInterval(function(){$('.foto_nahodna a:first-child').fadeOut('slow').next('a').fadeIn('slow').end().appendTo('.foto_nahodna');}, 6000);
	//});
});
/*function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
		document.getElementById(id).style.zIndex = 0;
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
		document.getElementById(id).style.zIndex = 5;
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
} 




function processRequest() {
	if (httpRequest.readyState == 4) {
		if (httpRequest.status == 200) {
			if (document.getElementById('foto_nahodna_1').innerHTML == "") {
				document.getElementById('foto_nahodna_1').innerHTML=httpRequest.responseText;
				document.getElementById('foto_nahodna_1').style.display='block';
				// javascript:opacity('foto_nahodna_2', 100, 0, 500);
				javascript:opacity('foto_nahodna_1', 0, 100, 500);
				document.getElementById('foto_nahodna_2').innerHTML='';
				document.getElementById('foto_nahodna_2').style.display='none';
			}
			else {
				document.getElementById('foto_nahodna_2').innerHTML=httpRequest.responseText;
				document.getElementById('foto_nahodna_2').style.display='block';
				// javascript:opacity('foto_nahodna_1', 100, 0, 500);
				javascript:opacity('foto_nahodna_2', 0, 100, 500);
				document.getElementById('foto_nahodna_1').innerHTML='';
				document.getElementById('foto_nahodna_1').style.display='none';
			}
		}
		else {
			alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText);
		}
	}
}

function nahodne_foto() {
	delete httpRequest;
	url = '/nahodny_obrazek.php?' + Math.floor(Math.random()*11);
	if (url != 0) {
		if (window.ActiveXObject) {
		  httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
		}
		else {
		  httpRequest = new XMLHttpRequest();
		}
		httpRequest.open("GET", url, true);
		httpRequest.onreadystatechange= function () { processRequest(); } ;
		httpRequest.send(null);
	}
	else {
		// document.getElementById(cilovePole).innerHTML = "";
		return "";
	}
}*/
