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";
}

function legen(srt,wat){
	if(document.getElementById(srt).value == wat){
		document.getElementById(srt).value = "";
	}
	else if(document.getElementById(srt).value == ""){
		document.getElementById(srt).value = wat;
	}
}

function gaZoeken(){

	var term = document.getElementById('zoekterm').value;
	var mom = document.getElementById('mom').value;
	
	if(term.length >= 3){

		http = createRequestObject();
		http.onreadystatechange = getTerm;
	
		http.open(meth,mom+"manip/gazoeken.php?term="+encodeURIComponent(term),true);
		http.setRequestHeader('Content-Type','text/plain');
		http.send(null);	
	}
	else{
		document.getElementById('gevonden').style.visibility = "hidden";			
	}

}

function getTerm(){
	 if(http.readyState == 4) { 
		if(http.status  == 200) {
			if(http.responseText != "0"){
				
				document.getElementById("gevonden").innerHTML = http.responseText;
				document.getElementById('gevonden').style.visibility = "visible";
				
			}
			else{
				
				document.getElementById("gevonden").innerHTML = "";
				document.getElementById('gevonden').style.visibility = "hidden";
				
			}
		}
	}
}


function formulier(){

	var con1 = document.getElementById('con1');
	var con2 = document.getElementById('con2');
	var con3 = document.getElementById('con3');
	var con4 = document.getElementById('con4');
	var con5 = document.getElementById('con5');
	var con6 = document.getElementById('con6');
	var con7 = document.getElementById('con7');
	var con8 = document.getElementById('con8');
	var con9 = document.getElementById('con9');
	var con10 = document.getElementById('con10');
	var con11 = document.getElementById('con11');

	if(con1.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel een bedrijfsnaam in te voeren";
		con1.style.border = "1px solid #EC3839";
		con1.style.background = "#ef8a84";
		con1.focus();
		return false;	
	}
	else{
		con1.style.border = "1px solid #0404A1";
		con1.style.background = "#E6E6E6";	
	}

	if(con2.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel een afdeling in te voeren";
		con2.style.border = "1px solid #EC3839";
		con2.style.background = "#ef8a84";
		con2.focus();
		return false;	
	}
	else{
		con2.style.border = "1px solid #0404A1";
		con2.style.background = "#E6E6E6";	
	}
	
	if(con3.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel een naam in te voeren";
		con3.style.border = "1px solid #EC3839";
		con3.style.background = "#ef8a84";
		con3.focus();
		return false;	
	}
	else{
		con3.style.border = "1px solid #0404A1";
		con3.style.background = "#E6E6E6";	
	}

	if(con4.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel uw initialen in te voeren";
		con4.style.border = "1px solid #EC3839";
		con4.style.background = "#ef8a84";
		con4.focus();
		return false;	
	}
	else{
		con4.style.border = "1px solid #0404A1";
		con4.style.background = "#E6E6E6";	
	}

	if(con5.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel uw functie in te voeren";
		con5.style.border = "1px solid #EC3839";
		con5.style.background = "#ef8a84";
		con5.focus();
		return false;	
	}
	else{
		con5.style.border = "1px solid #0404A1";
		con5.style.background = "#E6E6E6";	
	}

	if(con6.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel een adres in te voeren";
		con6.style.border = "1px solid #EC3839";
		con6.style.background = "#ef8a84";
		con6.focus();
		return false;	
	}
	else{
		con6.style.border = "1px solid #0404A1";
		con6.style.background = "#E6E6E6";	
	}
	
	if(con7.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel een postcode in te voeren";
		con7.style.border = "1px solid #EC3839";
		con7.style.background = "#ef8a84";
		con7.focus();
		return false;	
	}
	else{
		con7.style.border = "1px solid #0404A1";
		con7.style.background = "#E6E6E6";	
	}
	
	if(con8.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel een plaats in te voeren";
		con8.style.border = "1px solid #EC3839";
		con8.style.background = "#ef8a84";
		con8.focus();
		return false;	
	}
	else{
		con8.style.border = "1px solid #0404A1";
		con8.style.background = "#E6E6E6";	
	}

	if(con9.value == "" && con10.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel een telefoonnummer in te voeren";
		con9.style.border = "1px solid #EC3839";
		con9.style.background = "#ef8a84";
		con10.style.border = "1px solid #EC3839";
		con10.style.background = "#ef8a84";
		return false;	
	}
	else{
		con9.style.border = "1px solid #0404A1";
		con9.style.background = "#E6E6E6";
		con10.style.border = "1px solid #0404A1";
		con10.style.background = "#E6E6E6";	
	}
	
	if(con11.value == ""){
		document.getElementById('formfout').innerHTML = "U dient wel een e-mailadres in te voeren";
		con11.style.border = "1px solid #EC3839";
		con11.style.background = "#ef8a84";
		con11.focus();
		return false;	
	}
	else{
		if(/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/.test(con11.value)){	
			con11.style.border = "1px solid #0404A1";
			con11.style.background = "#E6E6E6";
		}
		else{
			document.getElementById('formfout').innerHTML = "Dit e-mail adres is niet geldig";
			con11.style.border = "1px solid #EC3839";
			con11.style.background = "#ef8a84";
			con11.focus();
			return false;		
		}
	}
}

function vergrootFoto(foto){
	setTimeout("sm('box',220,19)",10);
	var mom = document.getElementById('mom').value;
	document.getElementById("box").innerHTML = "<div class=\"laden\"><img src=\""+mom+"img/laden.gif\" alt=\"een moment geduld aub\" /></div>";
	
	http = createRequestObject();
	http.onreadystatechange = getFoto;

	http.open(meth,mom+"manip/modalfoto.php?foto="+foto,true);
	http.setRequestHeader('Content-Type','text/plain');
	http.send(null);	
}

function getFoto(){
	 if(http.readyState == 4) { 
		if(http.status  == 200) {
			setTimeout("sm('box',810,681)",100);
			document.getElementById('box').innerHTML = http.responseText;

		}
	}
}

function sluiten(){
	setTimeout("hm('box')",10);
}

function slideSwitch() {
    var $active = $('#slideshow IMG.active');

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

    var $next =  $active.next().length ? $active.next()
        : $('#slideshow 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( "slideSwitch()", 5000 );
});


$(function(){
  //Get our elements for faster access and set overlay width
  var div = $('div.sc_menu'),
               ul = $('ul.sc_menu'),
               // unordered list's left margin
               ulPadding = 15;

  //Get menu width
  var divWidth = div.width();

  //Remove scrollbars
  div.css({overflow: 'hidden'});

  //Find last image container
  var lastLi = ul.find('li:last-child');

  //When user move mouse over menu
  div.mousemove(function(e){

    //As images are loaded ul width increases,
    //so we recalculate it each time
    var ulWidth = lastLi[0].offsetLeft + lastLi.outerWidth() + ulPadding;

    var left = (e.pageX - div.offset().left) * (ulWidth-divWidth) / divWidth;
    div.scrollLeft(left);
  });
});