// -------------------------------------------------- //
// GLOBAL VARIABLE(S)
// -------------------------------------------------- //

var POPWIN = null;

// -------------------------------------------------- //
// CLOSE EXISTING CHILD WINDOW
// -------------------------------------------------- //

function closePopWin() {
  if ((POPWIN != null) && (POPWIN.closed != true))
  	POPWIN.close();
	}

// -------------------------------------------------- //
// DISPLAY POPUP WINDOW
// -------------------------------------------------- //

function popWindow(loc,x,y) {

  closePopWin();	// closes an existing popup window if user opens 
                	// new window before closing existing window
	
	if (!(x)) var winW = 480; 
		else var winW = x + 20;
	if (!(y)) var winH = 360; 
		else var winH = y + 20;
		
	var winPosX = (screen.width / 2) - (winW / 2);
	var winPosY = (screen.height / 2) - (winH / 2);

	var params  = "width=" + winW + ",height=" + winH + ",status=yes,toolbar=no,directories=no,scrollbars=yes,resizable=yes,menubar=no,location=no";

	POPWIN = window.open(loc,"BCC",params);
	POPWIN.moveTo(winPosX,winPosY);
	POPWIN.focus;
	}
	
// -------------------------------------------------- //
// DISPLAY LARGE PHOTO
// -------------------------------------------------- //

function popPhoto(whichPhoto) {

  closePopWin(); 	// closes an existing popup window if user opens 
        					// new window before closing existing window
	
	var winPosX = (screen.width / 2) - 250;
	var winPosY = (screen.height / 2) - 170;

	var params  = "width=500,height=380,status=no,toolbar=no,directories=no,scrollbars=no,resizable=yes,menubar=no,location=no";

	POPWIN = window.open("","BCC",params);
	POPWIN.moveTo(winPosX,winPosY);

  POPWIN.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');
  POPWIN.document.writeln('<html xmlns="http://www.w3.org/1999/xhtml">');
	POPWIN.document.writeln('<head><title>Joe Barden Engineering</title></head>');
  POPWIN.document.writeln('<body style="margin: 0; background-color: #EEE; padding: 0;">');
  POPWIN.document.writeln('  <div style="margin: 10px; border: 0; background: transparent; padding: 0; text-align: center;">');
  POPWIN.document.writeln('    <a href="javascript:window.close();"><img src="' + whichPhoto + '" style="border: 0; width: 480px; height: 360px;" alt="Click to Close" title="Click to Close"></a>');
  POPWIN.document.writeln('  </div>');
  POPWIN.document.writeln('</body>');
  POPWIN.document.writeln('</html>');

	POPWIN.document.close();
  }

// -------------------------------------------------- //
// SET UP GALLERY FOR EXPANDABLE IMAGES ON PAGE
// -------------------------------------------------- //

function setupGallery() {
  if (!document.getElementsByTagName) return false;
  var links = document.getElementsByTagName("a");
  for ( var i=0; i < links.length; i++) {
		if (links[i].className.match("popupImg")) {
			links[i].onclick = function() {
				popPhoto(this);
				return false;
				}
			}
		}
	}
	
window.onload = setupGallery;

// ------------------------------------------------------//
// INLINE JAVASCRIPT LINK SCRIPT
// ------------------------------------------------------//

function goToURL(theTarget,theURL) {
	eval(theTarget + '.location = "' + theURL + '"');
	}