function showinfo(info, event)
{
document.getElementById('info').innerHTML = info
document.getElementById('info').style.top = (event.clientY+20) + "px"
document.getElementById('info').style.left = (event.clientX+10) + "px"
document.getElementById('info').style.visibility = "visible"
}

function hideinfo()
{
document.getElementById('info').style.visibility = "hidden"
}

// AJAX
function getHTTPObject() {
  var xmlhttp = null;
  var success = false;
  
  // List of MS XMLHTTP versions - newest first
  var MSXML_XMLHTTP_PROGIDS = new Array(
	  'MSXML2.XMLHTTP.5.0',
	  'MSXML2.XMLHTTP.4.0',
	  'MSXML2.XMLHTTP.3.0',
	  'MSXML2.XMLHTTP',
	  'Microsoft.XMLHTTP'
  );

  // test for IE implementations first
  for (var i = 0; i < MSXML_XMLHTTP_PROGIDS.length &&
	   !success; i++)
  {
	 try
	 {
		xmlhttp = new ActiveXObject( 
		   MSXML_XMLHTTP_PROGIDS[i]);
		success = true;
		return xmlhttp;
	 }
	 catch (e)
	 {
		xmlhttp = false;
	 }
  }

  // Now test for non-IE implementations
  if (!xmlhttp &&
	  typeof XMLHttpRequest != 'undefined')
  {
	 try
	 {
		xmlhttp = new XMLHttpRequest();
	 }
	 catch (e)
	 {
		xmlhttp = false;
	 }
  }

  return xmlhttp;
}

function changeItem(action) {
	if (action == "next" && document.getElementById("photo").src.lastIndexOf(lastItem) != -1) {
		alert("Dit is de laatste foto!");
	} else {
		if (action == "previous" && document.getElementById("photo").src.lastIndexOf(firstItem) != -1) {
			alert("Dit is de eerste foto");
		} else {
			handler.open('get', 'get_media.php?action='+action+'&album_id='+albumId+'&current='+document.getElementById("photo").src, true);
			handler.onreadystatechange = loadMedia;
			handler.send(null);
			if (action == "next") {
				document.getElementById("count").innerHTML++;
			} else if (action == "previous") {
				document.getElementById("count").innerHTML--;			
			}
		}
	}
}

function loadMedia() {
	if (handler.readyState==4 || handler.readyState=="complete") {
		filename = handler.responseText;
		if (filename.substr(-3) == "flv") {
			switchMedia("video");
			var FO = { movie:"flvplayer.swf",width:"550",height:"400",majorversion:"7",build:"0",bgcolor:"#FFFFFF",
			flashvars:"file="+filename+"&showdigits=true&autostart=false&overstretch=none" };
			UFO.create(FO,"video");
		} else {
			switchMedia("photo");
		}
		document.getElementById('photo').src = handler.responseText;
		
	}
}

function startSlideshow() {
	delay = prompt("Hoeveel seconden wilt u elke foto zien?", 2)
	if (delay == null) {
		return;
	}
	delay = delay*1000;
	document.getElementById("slideshow").className = "stop";
	document.getElementById("slideshow").href = "javascript: stopSlideshow();"
	continueSlideshow();
}

function stopSlideshow() {
	document.getElementById("slideshow").className = "play";
	document.getElementById("slideshow").href = "javascript: startSlideshow();"
	clearTimeout(slideshow);
	slideshow = false;
}

function continueSlideshow() {
	if (document.getElementById("photo").src.lastIndexOf(lastItem) != -1) {
		if (firstItem.substr(-3) == "flv") {
			switchMedia("video");
			var FO = { movie:"flvplayer.swf",width:"550",height:"400",majorversion:"7",build:"0",bgcolor:"#FFFFFF",
			flashvars:"file="+firstItem+"&showdigits=true&autostart=false&overstretch=none" };
			UFO.create(FO,"video");
			document.getElementById('photo').src = firstItem;
		} else {
			switchMedia("photo");
			document.getElementById('photo').src = firstItem;
		}
	} else {
		changeItem('next');
	}
	slideshow = setTimeout("continueSlideshow()", delay);
}

function switchMedia(switchTo) {
	if (switchTo == "video") {
		document.getElementById('video').style.visibility = "visible";
		document.getElementById('video').style.position = "static";
		document.getElementById('photo').style.visibility = "hidden";
		document.getElementById('photo').style.position = "absolute";
	} else {
		document.getElementById('video').style.visibility = "hidden";
		document.getElementById('video').style.position = "absolute";
		document.getElementById('photo').style.visibility = "visible";
		document.getElementById('photo').style.position = "static";
	}

}

handler = getHTTPObject();
slideshow = false;
delay = 2000;