$(function() {
    $('#slideshow').cycle();
    
	$('#slider').cycle();
});

var tmr = null;

function start() {
	attachEvents();
}

function attachEvents() {
	//var searchbox = document.getElementById("search_box");
	//searchbox.onfocus = searchboxFocus;
	//searchbox.onblur  = searchboxBlur;
}

function searchboxFocus() {
	if (this.value == "Zoeken...") {
		this.value = "";
	}
}

function searchboxBlur() {
	if (this.value == "") {
		this.value = "Zoeken...";
	}
}

function getHTTPObject() {
	if (window.XMLHttpRequest) {
		return new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) {
		return new ActiveXObject('Microsoft.XMLHTTP');
	}
}
var http = getHTTPObject();

function getContent(url) {
	http.open("GET", url, true);
	http.onreadystatechange = function() {
		if( http.readyState == 4 ) {
			var content_element = document.getElementById('foto_top').innerHTML = http.responseText;
		}
	}
	http.send(null);
}

function slideShow(currentid,maxid) {
	stopShow();
	getContent("zetfoto.php?c="+currentid);
	tmr = setTimeout("slideShow("+ (parseInt(currentid)+1) +","+ maxid +")", 1500);
	if (currentid >= parseInt(maxid)-1) {
		stopShow();
	}
}

function stopShow() {
	if (tmr != null) {
		clearTimeout(tmr);
	}
}

function toggleVisible(targetId) {
	if (document.getElementById) {
		target = document.getElementById( targetId );
		if (target.style.display == "none") {
			target.style.display = "";
		}
		else {
			target.style.display = "none";
		}
	}
}

function slideShowtr(currentid,maxid) {
	stopShow();
	getContent("zetfototr.php?c="+currentid);
	tmr = setTimeout("slideShowtr("+ (parseInt(currentid)+1) +","+ maxid +")", 3000);
	if (currentid >= parseInt(maxid)-1) {
		stopShow();
	}
}

function stopShowtr() {
	if (tmr != null) {
		clearTimeout(tmr);
	}
}
