// Vergelijkbaar met PHP in_array
function in_array(string, array) {   
   for (i = 0; i < array.length; i++) {   
      if(array[i] == string) {   
         return true;   
      }   
   }   
return false;   
}  

// Elementen selecteren op class
function classAction(theClass, input){
	if(document.getElementById(input).value == 'Nieuws') {
		var allTags = document.getElementsByTagName('*');
		for(i=0; i<allTags.length; i++) {
			if(allTags[i].className == theClass) allTags[i].style.display = 'block';
		}
	} else {
		var allTags = document.getElementsByTagName('*');
		for(i=0; i<allTags.length; i++) {
			if(allTags[i].className == theClass) allTags[i].style.display = 'none';
		}		
	}
}

// Gaat naar dezelfde pagina in een andere taal
function switchLanguage(language){
	var path = window.location.pathname;
	var pagina = path.substring(path.lastIndexOf('/') + 1);
	window.location = '../' + language + '/' + pagina;
}

function submenu(id) {
	document.getElementById('menu_bedrijf').style.backgroundPosition = "bottom";
	document.getElementById('menu_producten').style.backgroundPosition = "bottom";
	document.getElementById('menu_service').style.backgroundPosition = "bottom";
	document.getElementById('menu_actueel').style.backgroundPosition = "bottom";
	document.getElementById('menu_funyak').style.backgroundPosition = "bottom";
	document.getElementById('menu_contact').style.backgroundPosition = "bottom";
	
	document.getElementById('submenu_bedrijf').style.display = "none";
	document.getElementById('submenu_producten').style.display = "none";
	document.getElementById('submenu_service').style.display = "none";
	document.getElementById('submenu_actueel').style.display = "none";
	document.getElementById('submenu_funyak').style.display = "none";
	document.getElementById('submenu_contact').style.display = "none";
	
	var menu = document.getElementById('menu_'+id);
	var submenu = document.getElementById('submenu_'+id);
	menu.style.backgroundPosition = "top";
	submenu.style.display = "inline";	
}

// Get variabelen ophalen via javascript
function get(key_str) {
	if(window.location.search) {
		var query = window.location.search.substr(1);
		var pairs = query.split("&");
		for(var i = 0; i < pairs.length; i++) {
			var pair = pairs[i].split("=");
			if(unescape(pair[0]) == key_str)
				return unescape(pair[1]);
		}
	}
}

function bevestig(bevestigd, niet_bevestigd, bericht){
	var bevestiging = confirm(bericht);
	if (bevestiging == true){
		window.location = bevestigd;
	}
	else{
		window.location = niet_bevestigd;
	}
}
