function openImage(pic, theCaption, theWidth, theHeight) {
 	if(!theCaption) var theCaption = '';
	if(!theWidth) var theWidth = window.screen.availWidth*0.5;
	if(!theHeight) var theHeight = window.screen.availHeight*0.5;
	
	theWidth = theWidth + 40;
	theHeight = theHeight + 30;
	if (theCaption != '') theHeight = theHeight + 20;
		
	if( theWidth > window.screen.availWidth ) {
		theWidth = window.screen.availWidth;
		if ( theHeight < (window.screen.availHeight-20) ) theHeight = theHeight + 20;
		else if ( theHeight < (window.screen.availHeight) ) theHeight = window.screen.availHeight;
	}
	if( theHeight > window.screen.availHeight ) {
		theHeight = window.screen.availHeight;
		if ( theWidth < (window.screen.availWidth-20) ) theWidth = theWidth + 20;
		else if ( theWidth < window.screen.availWidth ) theWidth = window.screen.availWidth;
	}
	
	// alert(theWidth+' '+theHeight);
	
	var theX = (window.screen.availWidth - theWidth)/2;
	var theY = (window.screen.availHeight - theHeight)/2;

	strProperties = "width=" + theWidth + ", height=" + theHeight + ", top=" + theY + ", left=" + theX + ", directories=no, location=no, menubar=yes, scrollbars=yes, status=no, toolbar=no, resizable=yes";

	pop=window.open('static/displayImage.php?image=' + pic + '&theCaption=' + theCaption, 'imagePopup', strProperties);
}

function openGallery(key, pic, theBreadcrumbsTitle) {
	theWidth = 750;
	theHeight = 540;
	
	if(!theBreadcrumbsTitle) var theBreadcrumbsTitle = '';
	else theBreadcrumbsTitle = escape(theBreadcrumbsTitle);
	
	// alert(theBreadcrumbsTitle);
	
	if( theWidth > window.screen.availWidth ) {
		theWidth = window.screen.availWidth;
		if ( theHeight < (window.screen.availHeight-20) ) theHeight = theHeight + 20;
		else if ( theHeight < (window.screen.availHeight) ) theHeight = window.screen.availHeight;
	}
	if( theHeight > window.screen.availHeight ) {
		theHeight = window.screen.availHeight;
		if ( theWidth < (window.screen.availWidth-20) ) theWidth = theWidth + 20;
		else if ( theWidth < window.screen.availWidth ) theWidth = window.screen.availWidth;
	}
	
	var theX = (window.screen.availWidth - theWidth)/2;
	var theY = (window.screen.availHeight - theHeight)/2;

	strProperties = "width=" + theWidth + ", height=" + theHeight + ", top=" + theY + ", left=" + theX + ", directories=no, location=no, menubar=yes, scrollbars=yes, status=no, toolbar=no, resizable=yes";

	pop=window.open('static/displayGallery.php?key=' + key + '&image=' + pic + '&theBreadcrumbsTitle=' + theBreadcrumbsTitle, 'galleryPopup', strProperties);
}
