//popup voor modules binnen admin
try {
	top.window.popupPhotomodule = function () {
		popupModules('photomodule');
	}
} catch(e) {}

function popupModules(modulenaam) {
	var filename="/admin/modules/"+modulenaam+"/index.php";
	var fileid= modulenaam;
	var width="650";
	var height="580";
	var scrollbars= "no";
	var resizable="no";
	var menubar="no";
	var toolbar="no";
	var status="no";
	var location="no";
	var popupscherm=0;
	var args = "height=" + height + ", width=" + width + ", scrollbars=" + scrollbars + ", resizable=" + resizable +  ", menubar=" + menubar + ", toolbar=" +toolbar + ", status=" + status + " ,location=" + location;
	popupscherm = top.window.open(filename, fileid, args);
}

function toggleMailaFriend() {
	var div = document.getElementById('mailafriend');
	var thankyou = document.getElementById('mailafriend_thankyou');
	
	if (div) {
		if (div.style.display !== 'block')
			div.style.display = 'block';
		else
			div.style.display = 'none';
		
		if (thankyou)
			thankyou.style.display = 'none';
	}
}

function confirmDelete(rubid,id,title) {
	ant = confirm('Wilt u de foto \'' + title + '\' echt verwijderen?');
	if (ant && id && rubid) {
		location.href='/?rubriekid='+rubid+'&action=delete&photo='+id;
	}
}

function ValidateSubscribeForm(form) {
	var pwd1 = form.DBF_password.value;
	var pwd2 = form.password2.value;
	
	if (pwd1 == pwd2)
		return PPFormValidator(form);
	else {
		alert('De ingevulde wachtwoorden dienen exact overeen te komen!');
		return false;
	}
}

function setMaxLength() {
	var textareas = document.getElementsByTagName('textarea');
	for (var i=0;i<textareas.length;i++) {
		if (textareas[i].getAttribute('maxlength')) {
			textareas[i].onkeyup = textareas[i].onchange = checkMaxLength;
			textareas[i].onkeyup();
		}
	}
}

function checkMaxLength() {
	var maxLength = this.getAttribute('maxlength');
	var currentLength = this.value.length;
	if (currentLength > maxLength)
		this.value = this.value.substring(0,maxLength);
}

//haal hoogte window binnen
var isNav4, isNav6
var isBrand = navigator.appName
var navVer = parseInt(navigator.appVersion)

//browser check
var isNav4 = (isBrand == "Netscape" && navVer < 5) ? true : false
var isNav6 = (isBrand == "Netscape" && navVer >= 5) ? true : false

//give back the computed style
function getStyle(obj,Attribute) {
	if (obj) {
		if (obj.currentStyle)
			var value = eval('obj.currentStyle.'+Attribute)
		else
			var value = eval('document.defaultView.getComputedStyle(obj, null).'+Attribute)
		return parseInt(value);
	}
}

//haal hoogte browser binnen
function getInsideWindowHeight() {
	if (isNav4 || isNav6)
		return window.innerHeight
 	else 
	    return document.body.clientHeight
}

function setHeight() {
	setMaxLength();
	
	var main 			= document.getElementById('main');
	var sidebar 		= document.getElementById('sidebar');
	var content 		= document.getElementById('content');
	var margin 			= getStyle(main,'top');
	var schermhoogte 	= getInsideWindowHeight();
	
	if (!sidebar || !content)
		return false;
	
	if ((content.offsetHeight + margin) < schermhoogte) {
		sidebar.style.height = (schermhoogte - margin) + 'px';
		content.style.height = (schermhoogte - margin) + 'px';
	} else
		sidebar.style.height = content.offsetHeight + 'px';
}