//methode om video's aan het DOM toe te voegen
function setVideo(divId,videoPath) {
	var myObject = document.createElement('object'); 
	obj = document.getElementById(divId);
	obj.appendChild(myObject); 
	myObject.width = "205"; 
	myObject.classid= "clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6";  
	myObject.URL = videoPath;
	myObject.uiMode = "mini";
}

var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var popupscherm=0;

//benodigde functie voor foto overzichts bouwsteen
function popup_afbeelding(filename, fileid, width, height, scrollbars, resizable, menubar, toolbar, status, location) {
	if (popupscherm && ! popupscherm.closed)	popupscherm.close();
	if (!filename || filename=="")				filename="http://www.grundel.nl";
	if (!fileid || fileid=="")					fileid="Grundel";
	if (!width || width=="")					width="50";
	if (!height || height=="")					height="50";
	if (!scrollbars || scrollbars=="")			scrollbars="no";
	if (!resizable || resizable=="")			resizable="no";
	if (!menubar || menubar=="")				menubar="no";
	if (!toolbar || toolbar=="")				toolbar="no";
	if (!status || status=="")					status="no";
	if (!location || location=="")				location="no";
	popupscherm=0;
	var args = "height=" + height + ", width=" + width + ", scrollbars=" + scrollbars + ", resizable=" + resizable +  ", menubar=" + menubar + ", toolbar=" +toolbar + ", status=" + status + " ,location=" + location;
	popupscherm = open(filename, fileid, args);
	if (!InternetExplorer) 						popupscherm.focus();
}

function popup (filename, fileid, width, height, scrollbars, resizable, menubar, toolbar, status, location) {
	if (popupscherm && ! popupscherm.closed)	popupscherm.close();
	if (!filename || filename=="")				filename="http://www.nijhuis.nl";
	if (!fileid || fileid=="")					fileid="nijhuis";
	if (!width || width=="")					width="600";
	if (!height || height=="")					height="500";
	if (!scrollbars || scrollbars=="")			scrollbars="no";
	if (!resizable || resizable=="")			resizable="no";
	if (!menubar || menubar=="")				menubar="no";
	if (!toolbar || toolbar=="")				toolbar="no";
	if (!status || status=="")					status="no";
	if (!location || location=="")				location="no";
	popupscherm=0;
	var args = "height=" + height + ", width=" + width + ", scrollbars=" + scrollbars + ", resizable=" + resizable +  ", menubar=" + menubar + ", toolbar=" +toolbar + ", status=" + status + " ,location=" + location;
	popupscherm = open(filename, fileid, args);
	if (!InternetExplorer) 						popupscherm.focus();
}

function toon_afbeelding_wit(afbeelding){
	afbeelding.src='/images/geen_afbeelding.gif'
}
function toon_afbeelding_153(afbeelding){
	afbeelding.src='/images/not_available_153.gif'
}
function toon_afbeelding_308(afbeelding){
	afbeelding.src='/images/not_available_308.gif'
}
function toon_afbeelding_dot_clear(afbeelding){
	afbeelding.src='/images/not_available_dot_clear.gif'
}
function OpslaanBericht() {
	document.formulier.action.value = "opslaan";
	CheckFormulier(); 
}

function wijzig_status(id, status) {
	document.formulier.id.value = id;
	document.formulier.status.value = status;
	document.formulier.submit();
}

function CheckFormulier () {

	result = true;
	if (document.formulier.naam) {
		if (document.formulier.naam.value == "") {
			alert ('U moet het veld Voornaam & achternaam invullen');
			document.formulier.naam.focus();
			result = false;
		}
	}

	if (result && document.formulier.email) {
		if (document.formulier.email.value != "") {
			if (!CheckEmail(document.formulier.email.value)) {
				alert("Ongeldig e-mail adres")
				document.formulier.email.focus();
				result = false;
			}
		}
	}

	if (result && document.formulier.afdeling_1 && !CheckAfdeling()) {
		alert ('U moet minimaal 1 afdelingen invullen (max. 4)');
		document.formulier.afdeling_1.focus();
		result = false;
	}
	
	
	if (result == true) {
		document.formulier.submit();
	}
	
	return result;
	
}

function CheckEmail(str) {

	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1)
		return false

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
		return false;

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
		return false;

	if (str.indexOf(at,(lat+1))!=-1)
		return false;

	if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
		return false;

	if (str.indexOf(dot,(lat+2))==-1)
		return false;
	
	if (str.indexOf(" ")!=-1)
		return false;

	return true
}

function CheckAfdeling() {
	objForm=document.forms.formulier;
	var countCats=0;
	var found = false;
	var result;
		
	for (i=0; i<objForm.elements.length;i++) {
		if (objForm.elements[i].name.indexOf('afdeling') >= 0) {
			found = true;
			if (objForm.elements[i].checked==true) {
				countCats++;
			}
		}
	}
	
	if (found) {
		result = (countCats >0) && (countCats<4);
	} else {
		result = true;
	}

	return (result)
}

function myPrint(){
if (document.layers || document.all){
	var agt=navigator.userAgent.toLowerCase(); 
	var isNav4 = (navigator.appName == "Netscape") ? true : false;
	var isIE4 = (navigator.appName.indexOf("Microsoft") != -1) ? true : false;
	if (isIE4){
		if (agt.indexOf("mac")!=-1){
			alert("Gebruik de 'apple' + P toetsen om te printen")
		}
		else{
			window.print()
		}
	}
	else{
		window.print()
	}
}
else alert("Deze functie is alleen vanaf versie 4 browsers actief")
}

function redirect() {
	popup ('/admin/redirect/index.php', 'nhredirect')
}


//popup voor presentatiebouwsteen
var InternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var popupscherm=0;
function popupPresentatie(imgnodes,descriptions,displaytime,width, height) {
	if (popupscherm && ! popupscherm.closed)	popupscherm.close();
	var filename = "/popup_presentatie.php?do=x&imgnodes="+imgnodes+"&descs="+descriptions+"&displaytime="+displaytime;
	var fileid = "Nijhuis";
	if (!width || width=="") width="700";
	if (!height || height=="") height="550";
	var scrollbars="no";
	var resizable="no";
	var menubar="no";
	var toolbar="no";
	var status="no";
	var location="no";
	popupscherm=0;
	var args = "height=" + height + ", width=" + width + ", scrollbars=" + scrollbars + ", resizable=" + resizable +  ", menubar=" + menubar + ", toolbar=" +toolbar + ", status=" + status + " ,location=" + location;
	popupscherm = open(filename, fileid, args);
	if (!InternetExplorer) 						popupscherm.focus();
}

