var newWindow = null;
function closeWin(){
	if (newWindow != null){
		if(!newWindow.closed)
			newWindow.close();
	}
}
function popUpWin(url, strWidth, strHeight){
	closeWin();
	var tools="resizable,menubar,location=no,scrollbars=yes,width="+strWidth+",height="+strHeight+",left=0,top=0";
	newWindow = window.open(url, 'newWin', tools);
	newWindow.focus();
}
function openSlides(CotNum, alt) {
	var url = '/gallery/slides.php?ID='+CotNum+'&alt='+URLEncode(alt);
	newWindow = window.open(url,"newWindow","width=530,height=475,scrollbars=no,left=0,top=0");
	newWindow.focus();
}
function openPictureWindow(imageName,imageWidth,imageHeight,alt) {  // v4.01
if (document.getElementById) {
	if (imageWidth < 310) {
		var winWidth = 360;
	} else {
		var winWidth = imageWidth + 30;
	}
	var winHeight = imageHeight + 100;
	newWindow = window.open("","newWindow","width="+winWidth+",height="+winHeight+",scrollbars=no,left=0,top=0");
	newWindow.document.open();
	newWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n');
	newWindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml">\n');
	newWindow.document.write('<head>\n');
	newWindow.document.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n');
	newWindow.document.write('<title>'+alt+'</title>\n');
	newWindow.document.write('<link href="/gallery.css" rel="stylesheet" type="text/css" />\n');
	newWindow.document.write('</head>\n');
	newWindow.document.write('<body>\n'); 
	newWindow.document.write('<div id="header"><img src="/graphics/g_healey.gif" alt="HEALEY LAKE LODGE" width="275" height="39" border="0" /></div>\n');
	newWindow.document.write('<div id="wrap">\n');
	newWindow.document.write('<p><img src="'+imageName+'" width="'+imageWidth+'" height="'+imageHeight+'" alt="'+alt+'" /></p>\n');
	newWindow.document.write('<p>'+alt+'</p>\n');
	newWindow.document.write('</div>\n');
	newWindow.document.write('<img src="/graphics/g_sun.png" name="sun" width="88" height="88" id="sun" />\n');
	newWindow.document.write('</body>\n');
	newWindow.document.write('</html>\n');
	newWindow.document.close();
	newWindow.focus();
  return false;
 } else {
  return true;
 }
}
function openFlashWindow(imageName,alt) {  // v4.01
if (document.getElementById) {
	newWindow = window.open("","newWindow","width=532,height=502,scrollbars=no,left=0,top=0");
	newWindow.document.open();
	newWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n');
	newWindow.document.write('<html xmlns="http://www.w3.org/1999/xhtml">\n');
	newWindow.document.write('<head>\n');
	newWindow.document.write('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />\n');
	newWindow.document.write('<title>'+alt+'</title>\n');
	newWindow.document.write('<link href="/gallery.css" rel="stylesheet" type="text/css" />\n');
	newWindow.document.write('</head>\n');
	newWindow.document.write('<body>\n'); 
	newWindow.document.write('<div id="header"><img src="/graphics/g_healey.gif" alt="HEALEY LAKE LODGE" width="275" height="39" border="0" /></div>\n');
	newWindow.document.write('<div id="wrap">\n');
	newWindow.document.write('<div class="vr">');
	newWindow.document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="502" height="402">\n');
	newWindow.document.write('<param name="movie" value="'+imageName+'" />\n');
	newWindow.document.write('<param name="wmode" value="transparent" />\n');
	newWindow.document.write('<param name="allowScriptAccess" value="sameDomain" />\n');
	newWindow.document.write('<param name="quality" value="high" />\n');
	newWindow.document.write('<embed src="'+imageName+'" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="502" height="402" allowScriptAccess="sameDomain" wmode="transparent"></embed>\n');
	newWindow.document.write('</object>\n');
	newWindow.document.write('</div>\n');
	newWindow.document.write('<p>'+alt+'</p>\n');
	newWindow.document.write('</div>\n');
	newWindow.document.write('<img src="/graphics/g_sun.png" name="sun" width="88" height="88" id="sun" />\n');
	newWindow.document.write('</body>\n');
	newWindow.document.write('</html>\n');
	newWindow.document.close();
	newWindow.focus();
  return false;
 } else {
  return true;
 }
}
function URLEncode (clearString) {
  var output = '';
  var x = 0;
  clearString = clearString.toString();
  var regex = /(^[a-zA-Z0-9_.]*)/;
  while (x < clearString.length) {
    var match = regex.exec(clearString.substr(x));
    if (match != null && match.length > 1 && match[1] != '') {
    	output += match[1];
      x += match[1].length;
    } else {
      if (clearString[x] == ' ')
        output += '+';
      else {
        var charCode = clearString.charCodeAt(x);
        var hexVal = charCode.toString(16);
        output += '%' + ( hexVal.length < 2 ? '0' : '' ) + hexVal.toUpperCase();
      }
      x++;
    }
  }
  return output;
}
function URLDecode (encodedString) {
  var output = encodedString;
  var binVal, thisString;
  var myregexp = /(%[^%]{2})/;
  while ((match = myregexp.exec(output)) != null
             && match.length > 1
             && match[1] != '') {
    binVal = parseInt(match[1].substr(1),16);
    thisString = String.fromCharCode(binVal);
    output = output.replace(match[1], thisString);
  }
  return output;
}
