function updatePhotos(direction) {
  var actual_photo = document.getElementById('actual_photo').value;

  if (window.ActiveXObject) {
    httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
  }
  else {
    httpRequest = new XMLHttpRequest();
  }
  httpRequest.open("GET", "actions/getPhotos.php?actual="+actual_photo+"&direction="+direction, true);
  httpRequest.onreadystatechange= function () {set(); } ;
  httpRequest.send(null);
}

function set () {
  if (httpRequest.readyState == 4) {
    if(httpRequest.status == 200) {
      var data = httpRequest.responseText;
      data = data.split(";");
      document.getElementById("previous_photo").innerHTML = data[0];
      document.getElementById("show_photo").innerHTML = data[1];
      document.getElementById("current_photo").innerHTML = data[1];
      document.getElementById("next_photo").innerHTML = data[2];
      document.getElementById("actual_photo").value = data[3];
    }
    else { alert("Chyba pri nacitani stanky"+ httpRequest.status +":"+ httpRequest.statusText); }
  }
}

function selectPhoto (index, src) {
	var current = document.getElementById('actual_photo');
	
	document.getElementById(current.value+"_photo").className = "thumb";
	document.getElementById(index+"_photo").className = "thumb_selected";
	current.value = index;
	
	var photoFrame = document.getElementById("show_photo_img").src = src; 
}

