function maxLen(field, maxlimit){
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
	}
	document.getElementById('charleft').innerHTML = (maxlimit - field.value.length);
}

var PicCurrentNum = 0;
var LastPicCurrentNum = 0;
var howMany = 0;
var interval;

function bgLoop(first){
	first = typeof(first) != 'undefined' ? first : false;
	var timeDelay = 3000;
	if(first){
		howMany = img.length-1;
		nextBg();
	}
	clearInterval(interval);
	interval = setInterval("nextBg()", timeDelay);
}

function nextBg(){
	PicCurrentNum++;
	if (PicCurrentNum < 1){PicCurrentNum = 1;}
	if (PicCurrentNum > howMany){PicCurrentNum = 1;}
	if(img[PicCurrentNum].complete){
		setBg(PicCurrentNum);
	}else{
		PicCurrentNum--;
	}
}

function setBgH(id){
	clearInterval(interval);
	PicCurrentNum = id;
	setBg(id);
}

function setBg(id){
	if(LastPicCurrentNum > 0){
		document.getElementById('btn'+LastPicCurrentNum).className = '';
	}
	document.getElementById('btn'+id).className = 'sel';
	document.getElementById('pagecontent').style.backgroundImage = 'url('+ img[id].src +')';
	LastPicCurrentNum = id;
}

function changeWerkn(val){
	if(val){
		document.getElementById('openwaar').style.display = 'table-row';
	}else{
		document.getElementById('openwaar').style.display = 'none';
	}
}

function changeWerkn2(val){
	if(val){
		document.getElementById('openwaar').style.display = 'inline';
	}else{
		document.getElementById('openwaar').style.display = 'none';
	}
}

function mailSend(){
	$("#newmail:hidden").show("medium");
}

function openMailWindow(movieid, moviekey){
	window.open('/pages/nieuwemail.php?m='+ movieid +'&k='+ moviekey, '', 'width=644,height=400,toolbar=false,location=false');
	$('nieuweMailWin').focus();
	$("#newmail:visible").hide("medium");
}
