function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

// popup window code
var IE = navigator.appVersion.indexOf("MSIE")>0;
var msieIndex = navigator.appVersion.indexOf("MSIE") + 5;
var version = parseFloat(navigator.appVersion.substr(msieIndex,3))
var IE4 = IE && version>=4 && version<5;
var IE5 = IE && version>=5;
var Macintosh = navigator.userAgent.indexOf('Mac')>0;

function spawnWithScrollbars(URL,windowName,width,height) {
				// default amounts in case they are running an old browser
				var w = 800;
				var h = 600;
				if (document.all || document.layers) {
				   w = screen.availWidth;
				   h = screen.availHeight;
				}
				var leftPos = (w-width)/2, topPos = (h-height)/2;
 				if (Macintosh) {
 					if (IE4) { newheight = 17 + height; }
 					else { newheight = height; }
 				}
 				else { newheight = height; }
 				var msgWindow = window.open(URL, windowName, "scrollbars=yes,toolbar=no,location=no,status=yes,menubar=no,top=0,left=0,width="+width+",height="+newheight+",resizable=yes,top="+topPos+",left="+leftPos );
}

function spawn(URL,windowName,width,height) {
				// default amounts in case they are running an old browser
				var w = 800;
				var h = 600;
				if (document.all || document.layers) {
				   w = screen.availWidth;
				   h = screen.availHeight;
				}
				var leftPos = (w-width)/2, topPos = (h-height)/2;
 				if (Macintosh) {
 					if (IE4) { newheight = 17 + height; }
 					else { newheight = height; }
 				}
 				else { newheight = height; }
 				var msgWindow = window.open(URL, windowName, "scrollbars=auto,toolbar=no,location=no,status=yes,menubar=no,top=0,left=0,width="+width+",height="+newheight+",resizable=yes,top="+topPos+",left="+leftPos );
}

function spawnPhoto(URL,windowName,width,height) {
				// default amounts in case they are running an old browser
				var w = 800;
				var h = 600;
				if (document.all || document.layers || document.getElementById) {
				   w = screen.availWidth;
				   h = screen.availHeight;
				}
				var leftPos = (w-width)/2, topPos = (h-height)/2;
 				if (Macintosh) {
 					if (IE4) { newheight = 17 + height; }
 					else { newheight = height; }
 				}
 				else { newheight = height; }	
 				var msgWindow = window.open('', windowName, "toolbar=no,location=no,status=yes,menubar=no,top=0,left=0,scrollbars=no,width="+width+",height="+newheight+",resizable=no,top="+topPos+",left="+leftPos );
				var body1 = '<html><head><title>Enlarged View</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head><body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">';
				var body2 = '</body></html>';
				var page='<a href="javascript:window.close();" title="Click to close this window"><img src="' + URL + '" width="' + width + '" height="' + height + '" border="0" galleryimg="no"></a>';
				var totalPage = body1 + page + body2;
				msgWindow.document.open();
				msgWindow.document.write(totalPage);
				msgWindow.document.close();
}

function selectDate ( day, month, year, current ) {
  url = "event_datesel.php?form=editentryform&day=" + day +
    "&month=" + month + "&year=" + year;
  if ( current > 0 )
    url += '&date=' + current;
  //window.open( url, "DateSelection",
  //  "width=250,height=225,resizable=yes,scrollbars=no" );
  spawn(url,"DateSelection",250,225);
}

function checkSearchForm(form) {
	var errors = '';
	var numErrors = 0;

	if (form.keyword.value == "") {
		errors += '- You must enter a keyword before performing a search.\n';
		numErrors++;
	}
	
	if (numErrors) {
		errors = 'The form can not be completed due to the following problem' + ((numErrors > 1) ? 's' : '') + ':\n\n' + errors + '\nPlease fix ' + ((numErrors > 1) ? 'these' : 'this') + ' problem' + ((numErrors > 1) ? 's' : '') + ' and resubmit the form.';
		alert(errors);
		return false;
	}
	return true;
}