function rot13(input) {
	var coding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMabcdefghijklmnopqrstuvwxyzabcdefghijklm';

	for (var text = '',i=0;i<input.length;i++) {
	character = input.charAt(i);
	position = coding.indexOf(character);
	if (position > -1) {
	character = coding.charAt(position + 13);
	}
	text += character;
	}

	return text;
}

function ontRot(linkje) {
	linkje.href='mailto:' + rot13(linkje.href.substring(7));
}

function showPopup(src,width,height,feature){
	if(!width) width=800;
	if(!height) height=600;
	if(!feature || feature.length<=0) feature=',status=no,toolbar=no,scrollbars=no,menubar=no,location=no';
	var lnk=window.open(src,null,'width='+width+',height='+height+','+feature);
	lnk.focus();
}

function scrollToTop() {
	var anchor = document.anchors[0];
	var y = 0;
    while (anchor) {
      y += anchor.offsetTop;
      anchor = anchor.offsetParent;
    }
    window.scrollTo(0,y);
}

function toonPagina(num,bs) {
	for(i = 1; (ele = document.getElementById('pagina'+i+'-'+bs)) != null; i++) {
		ele.style.display = (i==num ? '' : 'none');
	}
	scrollToTop();
}

function toonOverzicht(bs) {
	for(i = 1; (ele = document.getElementById('button'+i+'-'+bs)) != null; i++) {
		ele.style.display = 'none';
	}
	for(i = 1; (ele = document.getElementById('header'+i+'-'+bs)) != null; i++) {
		ele.style.display = 'none';
	}
	for(i = 1; (ele = document.getElementById('pagina'+i+'-'+bs)) != null; i++) {
		ele.style.display = '';
	}
	scrollToTop();
}

function checkBestelForm() {
	var f = document.getElementById('bestelform');
	if(checkform(f)==false) {
		return false;
	}
	f.submit();
}

function checkTicket(num) {
	if(document.getElementById('codeticket'+num).style.display==''){
		var correct=document.getElementById('checkticket'+num).contentWindow.document.getElementById('correct');
		if(correct!=null){
			correct = (correct.getAttribute('correct')!='true' ? false : true);
		}else{
			correct = false;
		}
		if(correct==false){
			alert('U heeft geen correcte fruitticketcode gechecked.');
			return false;
		}
	}
	toonPagina(2,num);
}