function createRequestObject() {
	var ro;
	var browser = navigator.appName;
	if(browser == "Microsoft Internet Explorer"){
		ro = new ActiveXObject("Microsoft.XMLHTTP");
	}
	else{
		ro = new XMLHttpRequest();
	}
	return ro;
}

var browser = navigator.appName;
var http = createRequestObject();

if(browser == "Microsoft Internet Explorer"){
	var meth = "POST";
}
else{
	var meth = "GET";
}

window.onload = function(){
	if(document.getElementById('tube').value != "0"){
		setTimeout("youtube('')",30);
	}
	if(document.getElementById('new').value != "0"){
		setTimeout("contrPreek('')",50);
	}
}

function setUitleg(nr,srt,sel){
	if(sel == 0){
		if(srt == 1){
			document.getElementById('uitleg_'+nr).style.color = '#f2ab00';
		}
		else{
			document.getElementById('uitleg_'+nr).style.color = '#00a2df';
		}
	}
}

function contrPreek(){
	http = createRequestObject();
	var mom = document.getElementById('mom').value;
	http.open(meth,mom+"manip/uitbreiding.php",true);
	http.setRequestHeader('Content-Type','text/plain');
	http.send(null);
}

function setKal(jaar,maand){
	http = createRequestObject();
	http.onreadystatechange = pakKalender;
	var mom = document.getElementById('mom').value;
	http.open(meth,mom+"includes/kalender.php?jaar="+jaar+"&maand="+maand,true);
	http.setRequestHeader('Content-Type','text/plain');
	http.send(null);
}

function pakKalender(){
	if(http.readyState == 4) { 
		if(http.status  == 200) {
			document.getElementById('kalender').innerHTML = http.responseText;
		}
	}
}

function youtube(){

	if(document.getElementById('tube').value != "0"){

		var so = new SWFObject("http://www.youtube.com/v/"+document.getElementById('tube').value, "", "220", "156", "8", "#000000");
		so.addParam("wmode", "transparent");
		so.write("filmpje");
	
	}
}


function openPreek(preek) {
	var mom = document.getElementById('mom').value;
	window.open(mom+"extern/preek.php?preek="+preek,"","scrollbars=0,menubar=0,resizable=0,width=540,height=250,left=350,top=250");
}

function gaNaar(naar){
	var mom = document.getElementById('mom').value;
	window.location.replace(mom+""+naar);
}

function slideSwitchHome() {
    var $active = $('#slideshow_home IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow_home IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow_home IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

function slideSwitchRest() {
    var $active = $('#slideshow_rest IMG.active');

    if ( $active.length == 0 ) $active = $('#slideshow_rest IMG:last');

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow_rest IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitchHome()", 5000 );
});

$(function() {
    setInterval( "slideSwitchRest()", 5000 );
});

