/* JavaScript voor Harmonie St. Caecilia */$(document).ready(function() {	$("ul.mainMenu a").click(function(event) {		var subMenu = $(this).parent().children("ul");				if (subMenu.length > 0) {			event.preventDefault();			$("ul.mainMenu ul").hide();					subMenu.show(200);		}	});});function showGalleryImage(id, width, height) {
  var pWidth = (width < screen.availWidth ? width : screen.availWidth);
  var pHeight = (height < screen.availHeight ? height : screen.availHeight) + 26;
  newWindow('/assets/modules/imagegallery/show_image.php?image_id=' + escape(id), pWidth, pHeight);
}
function newWindow(URL, width, height) {
  var CurrDate = new Date();
  var wleft = (screen.availWidth ? (screen.availWidth - width) / 2 : 0);
  var wtop = (screen.availHeight ? (screen.availHeight - height) / 2 : 0);
  window.open(URL, CurrDate.getTime(), 'toolbar=no,location=no,resizable=yes,status=no,scrollbars=yes,menubar=no,width='+width+',height='+height+',left='+wleft+',top='+wtop+',screenX='+wleft+',screenY='+wtop);
}
function regenGuestbookCaptcha() {
  if (document.images) {
    var now = new Date();
    document.images['guestbCaptcha'].src = '/manager/includes/veriword.php?rand=' + now.getTime();  }
}
/* Form check functions */
function emptystr(string) {
  var x = 0;
  var chr;
  var empty = true;
  if (string.length) {
    do {
      chr = string.substring(x, x + 1);
      x++;
      empty = (chr == ' ' || chr == '\t' || chr == '\n' || chr == '\r');
    } while (empty && x < string.length);  }
  return empty;
}
function checkEmpty(frm, elem, str) {
  if (emptystr(frm.elements[elem].value)) {
    alert('Je bent ' + str + ' vergeten in te vullen!');
    frm.elements[elem].focus();
    return false;
  }
  return true;
}
function checkEmail(frm, elem) {
  var pattern = /(^[\-_\.a-zA-Z0-9]+)@((([0-9]{1,3}\.){3}([0-9]{1,3})((:[0-9])*))|(([a-zA-Z0-9\-]+)(\.[a-zA-Z]{2,})+(\.[a-zA-Z]{2})?((:[0-9])*)))/;
  if (frm.elements[elem].value.search(pattern) == -1) {
    alert('Het e-mailadres is onjuist!');
    frm.elements[elem].focus();    return false;
  }
  return true;}
function checkGuestbookEntryForm(frm) {
  return (checkEmpty(frm, 'name', 'de naam') && checkEmpty(frm, 'email', 'het e-mailadres') && checkEmail(frm, 'email') && checkEmpty(frm, 'code', 'de code') && checkEmpty(frm, 'body', 'het bericht'));}

