// JavaScript Document
window.onerror = stopError
function stopError() {
	return true;
}

function Show_afbeelding(photo_id,gallery_id){
	var leftPos = (screen.availWidth-640) / 2;
	var topPos = (screen.availHeight-480) / 2;
	popupWin = window.open('','','width=640,height=480, status=no,scrollbars=auto,resizable=yes,titlebar=0,top=' + topPos + ',left=' + leftPos);
	popupWin.location='photo_popup.php?photo_id='+photo_id+'&gallery_id='+gallery_id;
}

function Show_nieuwsphoto(afbeelding){
	var leftPos = (screen.availWidth-640) / 2;
	var topPos = (screen.availHeight-480) / 2;
	popupWin = window.open('','','width=640,height=480, status=no,scrollbars=auto,resizable=yes,titlebar=0,top=' + topPos + ',left=' + leftPos);
	popupWin.location='photo_popup.php?afbeelding='+afbeelding;
}

function isValidEmail(str) {
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)){
		return true;
	} else {
		return false;
	}
}

function doMail(which) {
	//Init 
	var valid = "yes";

	//Check  
	if (document.all.naam.value=='') var valid = 'no';
	if (document.all.email.value=='') var valid = 'no';
	if (document.all.opmerkingen.value=='') var valid = 'no';
	document.home_form.action="index.php?pagina_id=<?=$pagina_id?>&show_mail=yes&do_mail=yes&which="+which;

	//If ok, then submit
	if (valid == "yes") {
		document.home_form.submit(document.home_form);
	} else {
		alert("U dient alle vereiste velden in te voeren.");
	}
}

function isDefined(obj){
	varToStr=eval("'"+obj+"'");
	if(varToStr=="undefined") return false;
	else return true;
}

function doPrint(page)
{
	text = "<HTML><HEAD><title>Print deze pagina</title></HEAD><BODY><style type='text/css' title='v3'>@import 'includes/template_1.css.php';</style><style>html, body {padding: 12px}</style>\n";
	text += eval('document.all.'+page+'.innerHTML');
	text = text.replace("doPrint('"+page+"')","print()");
	text = text.replace("popupMail()","");
	text += "<br><center><a href='javascript: window.close()'>Venster sluiten</a></center>";
	text += "</BODY></HTML>";
	printWin = window.open('','','width=600,height=420,scrollbars=yes,resizable=yes,titlebar=0');

	printWin.document.write(text)
	printWin.document.close()
	printWin.print()
}
