function openclose(p, who) {
	t = document.getElementById("pl" + p);
	im = document.getElementById("im_" + p);
	if(t.style.display == "block") {
		t.style.display = "none";
		im.src = im.src.replace("open", "closed");
	} else {
		t.style.display = "block";
		im.src = im.src.replace("closed", "open");
	}
	setCookie("show" + p, t.style.display, 31, "/");
}
function doCheckLightbox(id) {
	t = document.getElementById(id);
	if(t.value =='') {
		alert('Selecteer eerst een afbeelding');	
	} else {
		itm = document.createElement("a");
		itm.href= t.value ;
		itm.rel = 'image';
		doLightbox(itm);
	}
	
	
}

function setCookie( name, value, expires, path, domain, secure ) {
	var today = new Date();
	today.setTime( today.getTime() );

	if ( expires ) {
		expires = expires * 1000 * 60 * 60 * 24;
	}
	var expires_date = new Date( today.getTime() + (expires) );

document.cookie = name + "=" +escape( value ) +
( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
( ( path ) ? ";path=" + path : "" ) +
( ( domain ) ? ";domain=" + domain : "" ) +
( ( secure ) ? ";secure" : "" );
}


function checkAll(f, what) {
	c = what.checked;
	// dit werkt niet
	obj = document.getElementById(f);
	f = obj.getElementsByTagName("input");
	l = f.length;

	for(i = 0 ; i <= l ; i++) {
		
	if(f[i].name.indexOf("[OWN]") > -1){
	} else {
			if(f[i].type == "hidden") {
				f[i].value = c ? "Y" : "N";
			}
			if(f[i].type == "checkbox") {
				f[i].checked = c;
			}
		}
	}
}


function displayTable(i){
	cTable = document.getElementById('currentTable').innerHTML;
	document.getElementById("table_" + cTable).style.display ="none";
	document.getElementById("tabactions_" + cTable).style.display ="none";
	document.getElementById("tab_" + cTable).className ="tab";
	
	document.getElementById("table_" + i).style.display ="block";
	document.getElementById("tabactions_" + i).style.display ="block";
	document.getElementById('currentTable').innerHTML = i;
	document.getElementById("tab_" + i).className ="tabactive";
}


function PopUp(page,name,w,h,scroll,pos){
	if(pos=="random"){
		LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;
		TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	} else if(pos=="center"){
		LeftPosition=(screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	} else if(pos=="right"){
		LeftPosition=(screen.width)?(screen.width-w):1024-w;
		TopPosition=0; h=Math.min(screen.height,600);
	} else {
		LeftPosition=0;
		TopPosition=20;
	}
	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=no,menubar=no,toolbar=no,resizable=yes';
	return window.open(page,name,settings);
}

function advCheck(who, val1, val2) {
	who.form.elements[who.name.replace(/adv\_\_/, "")].value = who.checked ? val2 : val1;
}

 

var banners, bnum, bmax, bprev, tmpbnum;
$(document).ready(function() {
	banners = Array();
	bmax = Array();
	bnum = Array();
	bprev = Array()
	tmpbnum = Array()
	
	checkBanner(1);
	checkBanner(2);
	
	$(".fkalender").datepicker({dateFormat: 'dd-mm-yy',numberOfMonths: 1,showButtonPanel: true,changeMonth: true,changeYear: true});

});
function checkBanner(num) {
	banners[num] = Array();
	nn = "#imagelist" + num + " div";
	bmax[num] = $(nn).length;
	if(bmax[num] > 1) {
		$(nn).each(function(i) {
			banners[num][i] = this;
			$(this).fadeTo(1, 0);
			if(i == 0) {
				$(this).fadeTo(1, 1);
			}
		});
		bnum[num] = 0;
		t = setTimeout("dobBanner(" + num + ");", num*2500);
	}
}
function dobBanner(num) {
	tmpbnum[num] = bnum[num];
	nn = "#imagelist" + num + " div";
	
	$(nn).eq(tmpbnum[num]).fadeTo(1000, 0);
	bprev[num] = bnum[num];
	bnum[num]++;
	if(bnum[num] >= bmax[num]) {
		bnum[num] = 0;
	}
	$(nn).eq(bnum[num]).fadeTo(1000, 1, function() {	
		setTimeout("dobBanner(" + num + ");", 5000);
	});
}

function hover(what, onOrOut) {
	
	$("#im_" + what).css("opacity", (onOrOut ? ".5" : "1"));
	$("#im_" + what).css("filter", ("alpha(opacity=" + (onOrOut ? 50 : 100) + ")"));
	$("#li_" + what + " a").css("color", (onOrOut ? "#FFF" : "#EE9C76"));
}
function setActive(what){
	
	f = document.body.getElementsByTagName("li");
	l = f.length;

	for(i = 0 ; i < l ; i++) {
		
		if(f[i].className =='subactive'){
			f[i].className = '';
		}
	}
	
	document.getElementById("li_" + what).className = "subactive";
}
function showDiv(what) {
        with(document.getElementById(what).style) {
                display = "block";
                overflow = "hidden";
                width = "500px";
                minHeight = "500px"

        }
}
function hideDiv(what) {
        with(document.getElementById(what).style) {
                display = "none"
                overflow = "hidden";
                width = "100px";
                minHeight = "20px";

        }
}
function unPopUp(what) {
	if(what == "#") {
		return false;
	}
	window.opener.document.location.href = what;
	window.opener.focus();
	window.close();
}
var activewho;
function setElm(elm, val, w) {
	if(activewho) {
		$(activewho).addClass("active");
		$(activewho).removeClass("active");
	}
	activewho = w;
	$(activewho).addClass("active");
	document.forms["mainform"].elements[elm].value = val;
}
var getimageelm;
function getFile(trg) {
	
	getimageelm = document.forms["form"].elements[trg];
	PopUp("/test", "getfile", 900, 500, "y", "center");
}