// ------------------------------------------------ //
//  CostSavingSystems, LLC | common.js              //
//  Author: Kevin Scholl   | kscholl@comcast.net    //
//  Created: 23 Dec 2005   | Updated: 03 Jan 2006   //
// ------------------------------------------------ //

// ------------------------------------------------//
// 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 screenW = 640; 
		else var screenW = x + 20;
	if (!(y)) var screenH = 480; 
		else var screenH = y + 20;
	var params  = "width=" + screenW + ",height=" + screenH + ",status=yes,toolbar=no,directories=no,scrollbars=yes,resizable=yes,menubar=no,location=no,top=50,left=50,screeny=50,screenx=50"

	POPWIN = window.open(loc,"CostSavingSystems",params);
	POPWIN.focus;
	}
	
// ------------------------------------------------//
// DISPLAY LARGE PHOTO
// ------------------------------------------------//

function popPhoto(whichPhoto) {

  closePopWin(); 	// closes an existing popup window if user opens 
        					// new window before closing existing window
	
	var params  = "width=402,height=312,status=no,toolbar=no,directories=no,scrollbars=no,resizable=yes,menubar=no,location=no,top=50,left=50,screeny=50,screenx=50"

	POPWIN = window.open("","CostSavingSystems",params);

  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>CostSavingSystems</title></head>');
  POPWIN.document.writeln('<body style="margin: 0; background-color: #EEE; padding: 0;">');
  POPWIN.document.writeln('  <div style="margin: 10px; border: 1px solid #CCC; padding: 10px; background-color: #FFF; text-align: center;">');
  POPWIN.document.writeln('    <a href="javascript:window.close();"><img src="' + whichPhoto + '" style="border: 0; width: 360px; height: 270px;" 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() {
				viewPhoto(this);
				return false;
				}
			}
		}
	}
	
window.onload = setupGallery;