//' Software by DavidRegier.com. Unauthorized use of this code is prohibited

/*

function activateLink
function checkDim
function checkImgName
function DeleteCookie
function directX
function dissolveDirectX
function DynamicIndex
function DynamicWindow
function fadeIn
function fadeInDirectX
function FileWriter
function GetCookie
function getCookieVal
function getEmailLink
function getOpacity
function getRGB
function getTransition
function getVal
function initImagesArr
function initNavLinks
function largePic
function PopUp
function PreLoader
function randompick
function reportError
function SetCookie
function showHawaiiTime
function SlideShow
function startFade
function trim

*/

IE = false, AOL = false, SF = false, MZ = false;

if( navigator.appName == "Microsoft Internet Explorer" ) {
	IE = true;
	if( navigator.userAgent.indexOf( "AOL" ) >= 0 ) AOL = true;
}
else if( navigator.userAgent.indexOf( "Safari" ) >= 0 )
	SF = true;
else if( navigator.appName == "Netscape" )
	MZ = true;

winOS = ( navigator.platform.substring( 0, 3 ) == "Win" );
winIE = ( winOS && IE );
macOS = ( navigator.platform.substring( 0, 3 ) == "Mac" );
macIE = ( macOS && IE );

theHost = document.location.hostname;
theHostLC = theHost.toLowerCase();

local = ( theHostLC.length == 0 || theHostLC == "127.0.0.1" || theHostLC == "localhost" ), live = !local;

qStr = unescape( document.location.search ).substring( 1 );

homePage = "default.aspx"
path = document.location.pathname;
delimeter = ( path.indexOf( "\\" ) >= 0 ) ? "\\" : "/";
if( path.charAt( path.length - 1 ) == delimeter ) path += homePage;
Path = path.split( delimeter );
fileName = Path[ Path.length - 1 ];

// Re-assemble e-mail addresses
if( typeof window.DB == "object" ) {

	if( typeof window.DB.Administrators == "object" ) {

		for( var key in DB.Administrators ) {

			eMailOut = "";
			eMailIn = DB.Administrators[ key ].replace( /\s{2}/g, "." );
			eMailIn = eMailIn.replace( /\s{1}/g, "@" );
			for (i = 0; i <= eMailIn.length; i++)
				eMailOut = eMailIn.charAt(i) + eMailOut;

			DB.Administrators[ key ] = eMailOut;
		}

	}

	if( typeof window.DB.Contact == "object" ) {

		eMailOut = "";
		eMailIn = DB.Contact.Email.replace( /\s{2}/g, "." );
		eMailIn = eMailIn.replace( /\s{1}/g, "@" );
		for (i = 0; i <= eMailIn.length; i++)
			eMailOut = eMailIn.charAt(i) + eMailOut;

		DB.Contact.Email = eMailOut;

	}

	eMailOut = "";
	eMailIn = DB.ReportErrorsTo.replace( /\s{2}/g, "." );
	eMailIn = eMailIn.replace( /\s{1}/g, "@" );
	for (i = 0; i <= eMailIn.length; i++)
		eMailOut = eMailIn.charAt(i) + eMailOut;

	DB.ReportErrorsTo = eMailOut;
}

//////////////////////////////// Start PreLoader: PL ////////////////////////////////

function PreLoader() {

	this.Files = [

		"images/header.jpg",

		"about.aspx",
			"images/h7272TNB.jpg",
			"images/h7086TNB.jpg",
			"images/HOLLY_1TNB.jpg",

		"ss.aspx?db=images-main.js",
			"images-main.js",
			"images/h7272.jpg",

		"rates.aspx",
			"images/HOLLY_2TNB.jpg",
			"images/h7167TNB.jpg",
			"images/IMG_5010TNB.jpg",
			"images/h7272TNB.jpg",

		"calendar.aspx",
			"cal-data.js",
			"calendar.js",
			"printer-friendly.css",

		"default.aspx",
			"images/TheHanaleiBayHouse.gif",
			"images/homeSS-h7086.jpg",
			"images/homeBkgScenic.jpg",


	null ];

	this.debug = 0;

	if( this.debug )
		DeleteCookie( "nFilesCached" );

	this.Request = null;
	this.timer = 0;
	this.nFilesCachedCookie = GetCookie( "nFilesCached" );
	this.nFilesCached = ( this.nFilesCachedCookie ) ? parseInt( this.nFilesCachedCookie ) : 0;
	this.run = run;
	if( this.debug ) self.status = "File preloader started...";

	//------------------------------------- Method PL -------------------------------------

	function run() {

		// W3C
		if( window.XMLHttpRequest ) {
			try { this.Request = new XMLHttpRequest(); }
			catch( Err ) { this.Request = null; }
		}

		// IE 6-
		else if( window.ActiveXObject ) {
			try { this.Request = new ActiveXObject( "Msxml2.XMLHTTP" ); }
			catch( Err ) {
				try { this.Request = new ActiveXObject( "Microsoft.XMLHTTP" ); }
				catch( Err ) { this.Request = null; }
			}
		}

		clearTimeout( PL.timer );

		if( this.Request ) {

			if( this.nFilesCached < this.Files.length - 1 ) {

				this.Request.onreadystatechange = function() {
					try {
						if( PL.Request.readyState == 4 ) {
							if( PL.Request.status == 200 ) {
								if( PL.debug ) self.status = PL.Files[ PL.nFilesCached ] + " preloaded; #" + ( ( PL.nFilesCached + 1 ) + " of " + ( PL.Files.length - 1 ) );
							}
							else {
								if( PL.debug )
									alert( "File preloader encountered an error retrieving: \n " + PL.Files[ PL.nFilesCached ] + "\n Status: " + PL.Request.status + "\n StatusText: " + PL.Request.statusText + "\n Number " + ( ( PL.nFilesCached + 1 ) + " of " + ( PL.Files.length - 1 ) ) );
							}

							PL.nFilesCached++;
							SetCookie( "nFilesCached", PL.nFilesCached );
							PL.timer = setTimeout( "if( window.PL ) PL.run();", 100 );

						}
					}
					catch( Err ) {
						var eMsg = "Exception at PL.run()\n\n";
						for( var i in Err ) eMsg += i + ": " + Err[ i ] + "\n";
						try{ if( PL.debug ) alert( eMsg ); } catch( Err ) { self.status = eMsg.replace( /\n/g, " " ); }
					}
				}

				this.Request.open( "GET", this.Files[ this.nFilesCached ], true );
				this.Request.send( null );

			}
		}

		// Browser cannot make http request (AOL/SF crash) so get images only
		else if( PL.debug )
			self.status = "Browser does not support the HttpRequest Request Protocol";
	}

}

PL = new PreLoader();

//////////////////////////////// End PreLoader: PL ////////////////////////////////

//----------------------------------- String Prototype -----------------------------------
// If key is found in strToSearch then returns its value, otherwise returns null
function getVal( key ) {

	var value = null;
	var strToSearch = this.toString();

	var KeyVals = strToSearch.split( "&" );

	for( member in KeyVals ) {
		var ThisPair = KeyVals[ member ].split( "=" );
		if( key == ThisPair[ 0 ] ) { value = ThisPair[ 1 ]; break; }
	}
	if( typeof value == "undefined" ) value = "";
	return value;
}
String.prototype.getVal = getVal;

//----------------------------------- String Prototype -----------------------------------
// Trims white space and/or line breaks off both ends
function trim() {
	var str = this.toString();
	str = str.replace( /^\s*|\s*$/g, "" );
	str = str.replace( /^\n*|\n*$/g, "" );
	return str;
}
String.prototype.trim = trim;

//--------------------------------------------------------------------------------------

var Msg = new Array();
Msg.about = "Learn more about the home & area";
Msg.cal = "Check our booking calendar for availability";
Msg.contact = "Contact us via phone, e-mail or mail";
Msg.home = "Back to our homepage";
Msg.links = "Links to other related web sites";
Msg.rates = "Get our Rental rates";
Msg.SS = "View photos via our automated slide-show";

///////////////////////////// START IMAGE LIBRARY FUNCTIONS /////////////////////////////
// ACCESSOR VARS: winIE, MZ, SF, local

//--------------- Image Library ---------------
function randompick() {
  return randompick.arguments[ Math.floor( Math.random()*randompick.arguments.length ) ];
}

function getTransition( transNum, duration ) {

	var trans = "";
	if( winIE ) {
		var d = duration;
		if( parseFloat( navigator.userAgent.split( "MSIE" )[ 1 ] ) >= 5.5 ) { //IE 5.5+

			var thisTrans = ( transNum == 1 ) ? Math.floor( Math.random() * 17 ) + 2 : transNum;

			switch ( thisTrans ) {
				case 2: trans="Fade(duration="+d+",overlap=1)"; break;
				case 3: trans="Blinds(duration="+d+",bands="+randompick(2,4,6,8)+",direction="+randompick('up','down','right','left')+")"; break;
				case 4: trans="CheckerBoard(duration="+d+",squaresX="+randompick(2,4,8,12)+",squaresY="+randompick(2,4,8,12)+",direction="+randompick('up','down','right','left')+")"; break;
				case 5: trans="Barn(duration="+d+",motion="+randompick('in','out')+",orientation=",randompick('horizontal','vertical')+")"; break;
				case 6: trans="GradientWipe(duration="+d+",gradientSize="+randompick(0,0.1,0.3,0.5,0.7,0.9,1)+",wipeStyle="+randompick(0,1)+",motion="+randompick('forward','reverse')+")"; break;
				case 7: trans="Inset(duration="+d+")"; break;
				case 8: trans="Iris(duration="+d+",irisStyle="+randompick('DIAMOND','CIRCLE','CROSS','PLUS','SQUARE','STAR')+",motion="+randompick('in','out')+")"; break;
				case 9: trans="RadialWipe(duration="+d+",wipeStyle="+randompick('CLOCK','WEDGE','RADIAL')+")"; break;
				case 10: trans="RandomBars(duration="+d+",orientation="+randompick('horizontal','vertical')+")"; break;
				case 11: trans="RandomBars(duration="+d+")"; break;
				case 12: trans="Slide(duration="+d+",pushStyle="+randompick('HIDE','PUSH','SWAP')+",bands="+randompick(1,2,3,4,5,6,7)+")"; break;
				case 13: trans="Spiral(duration="+d+",gridSizeX="+randompick(8,16,32,64)+",gridSizeY="+randompick(8,16,32,64)+")"; break;
				case 14: trans="Stretch(duration="+d+",stretchStyle="+randompick('HIDE','PUSH','SPIN')+")"; break;
				case 15: trans="Strips(duration="+d+",motion="+randompick('leftdown','leftup','rightdown','rightup')+")"; break;
				case 16: trans="Wheel(duration="+d+",spokes="+randompick(2,4,10,16,20)+")"; break;
				case 17: trans="Zigzag(duration="+d+",gridSizeX="+randompick(8,16,32,64)+",gridSizeY="+randompick(8,16,32,64)+")"; break;
				case 18: trans="RandomDissolve(duration="+d+")"; break;
        //case 19: trans="Pixelate(duration="+d+",maxSquare="+randompick(5,10,20,30,40,50)+")"; break;
				default: alert( "SWITCH/CASE ERROR: Case caught by default handler in \"getTransition\"" );
			}
			trans = "progid:DXImageTransform.Microsoft." + trans;
		}
		else { // Old IE 5 Browsers

			switch ( transNum ) {
				case 2: trans="blendTrans(duration="+d+")"; break;
				default: trans="revealTrans(duration="+d+",transition=" + Math.floor(Math.random()*23) + ")";
			}
		}
	}
	return trans;
}
//--------------- Image Library ---------------
function getRGB( abbrev ) {
	var rgb = abbrev;
	switch( abbrev ) {
		case "b": rgb = "0,0,0"; break;
		case "w": rgb = "255,255,255"; break;
	}
	var reRGB = /^\d{1,3},\d{1,3},\d{1,3}$/, badRGB = false;
	if( !reRGB.test( rgb ) ) badRGB = true;
	else {
		var Channels = rgb.split( "," );
		for( var i = 0; i < 3; i++ )
			if( parseInt( Channels[ i ] ) > 255 ) badRGB = true;
	}
	if( badRGB ) {
		reportError( "Errant Data", "Bad RGB value \"" + rgb + "\"" );
		rgb = "255,255,255";
	}
	return rgb;
}
//--------------- Image Library ---------------
function getOpacity( dissolveSF, dissolveMZ ) {
	var opac = "";
	if ( winIE ) opac = "visibility:hidden;";
	else if( MZ && dissolveMZ ) opac = "opacity:0;"
	else if ( SF && dissolveSF ) opac = "opacity:0;"
	return opac;
}
//--------------- Image Library ---------------
function startFade( FadeInPhoto, transNum, transDur, transDelay, dissolveSF, dissolveMZ ) {
	window.FadeInPhoto = FadeInPhoto;
	window.transNum = transNum;
	window.transDur = transDur;
	window.transDelay = transDelay;
	if( winIE ) setTimeout( "fadeInDirectX()", transDelay );
	else if( ( MZ && dissolveMZ ) || ( SF && dissolveSF ) ) {
		FadeInPhoto.onload = function() { /*cancel photo onload function*/ };
		( transDelay ) ? setTimeout( "fadeIn( FadeInPhoto )", transDelay ) : fadeIn( FadeInPhoto );
	}
	else {
		if( SF ) FadeInPhoto.style.opacity = 1.0;
		else FadeInPhoto.style.visibility = "visible";
	}
}
//--------------- Image Library ---------------
// call from startFade only, never call directly
function fadeInDirectX() {
	try {
		FadeInPhoto.style.filter = getTransition( transNum, transDur );
		FadeInPhoto.filters(0).apply();
		FadeInPhoto.style.visibility = "visible";
		FadeInPhoto.filters(0).play();
	}
	catch( Err ) {
		if( local ) {
			var eMsg = "Exception Caught in fadeInDirectX function:\n\n";
			for( var i in Err ) eMsg += i + ": " + Err[ i ] + "\n";
			alert( eMsg );
		}
		FadeInPhoto.style.visibility = "visible";
	}
}
//--------------- Image Library ---------------
// SF & MZ: Uses recursion

GuiObj = null, fadeOpacity = 0, fadeOpacityTimer = 0;
function fadeIn( GuiObj ) {

	if( MZ ) GuiObj.style.opacity = fadeOpacity;
	else GuiObj.style.opacity = fadeOpacity;

	this.fadeOpacity += .05;
	if( fadeOpacity < 1 ) {
		window.GuiObj = GuiObj;
		fadeOpacityTimer = setTimeout( "fadeIn( GuiObj )", 40 );
	}
	else {
		if( MZ ) GuiObj.style.opacity = 0.9999;
		else GuiObj.style.opacity = 0.9999;
		clearTimeout( fadeOpacityTimer );
		GuiObj = null;
		fadeOpacity = 0;
		fadeOpacityTimer = 0;
	}
}

//--------------- Image Library ---------------
function dissolveDirectX( OldPhoto, newPhotoSrc, borderWid, borderCol, transNum, transDur ) {

	try {
		OldPhoto.style.filter = getTransition( transNum, transDur );
		OldPhoto.filters(0).apply();
		OldPhoto.src = newPhotoSrc;
		if( borderWid ) OldPhoto.style.borderColor = "rgb( " + getRGB( borderCol ) + " )";
		OldPhoto.filters(0).play();
	}
	catch( Err ) {
		if( local ) {
			var eMsg = "Exception Caught in dissolveDirectX function:\n\n";
			for( var i in Err ) eMsg += i + ": " + Err[ i ] + "\n";
			alert( eMsg );
		}
		OldPhoto.src = newPhotoSrc;
		if( borderWid ) OldPhoto.style.borderColor = "rgb( " + getRGB( borderCol ) + " )";
	}
}

//--------------- Image Library ---------------
function directX( OldPhoto, newPhotoSrc, borderWid, borderCol, transNum, transDur ) {

	try {
		OldPhoto.parentNode.style.filter = getTransition( transNum, transDur );
		OldPhoto.parentNode.filters(0).apply();
		OldPhoto.src = newPhotoSrc;
		if( borderWid ) OldPhoto.style.borderColor = "rgb( " + getRGB( borderCol ) + " )";
		OldPhoto.parentNode.filters(0).play();
	}
	catch( Err ) {
		if( local ) {
			var eMsg = "Exception Caught in directX function:\n\n";
			for( var i in Err ) eMsg += i + ": " + Err[ i ] + "\n";
			alert( eMsg );
		}
		OldPhoto.src = newPhotoSrc;
		if( borderWid ) OldPhoto.style.borderColor = "rgb( " + getRGB( borderCol ) + " )";
	}
}

//--------------- Image Library ---------------
function initImagesArr() {
	try { Images.length = Images.length - 1; }
	catch( Err ) {
		reportError( "Image Data Error", "ERROR: Images array cannot be initialized because:\n 1) Data file \"" + window.dataFile + "\" is non-existent; OR\n 2) The data it contains is malformed (bad syntax)" );
	}
}

//--------------- Image Library ---------------
fileNameErr = false;
function checkImgName( fileName ) {

	var rePattern = /\s+/g;

	if( !fileNameErr && rePattern.test( fileName ) ) {
		fileNameErr = true;
		reportError( "Image File Name Error", "ERROR: An image file name \"" + fileName + "\" contains forbidden white-space characters." );
	}
}

//--------------- Image Library ---------------
ImgReal = null; checkDimTimer = 0;
function checkDim( imgRealSrc, widDB, hgtDB ) {

	// Animated gifs can erroneously report widDB & hgtDB of 0 which causes false errors
	if( widDB > 0 && hgtDB > 0 ) {

		if( ImgReal == null ) {
			ImgReal = new Image();
			ImgReal.src = imgRealSrc;
		}
		if( ImgReal.complete ) {
			clearTimeout( checkDimTimer );
			var realWid = ImgReal.width, realHgt = ImgReal.height;
			if( realWid > 1 && realHgt > 1 && ( realWid != widDB || realHgt != hgtDB ) ) {
				var FileComponents = ImgReal.src.split( "/" );
				var fileName = FileComponents[ FileComponents.length - 1 ];
				var eMsg = "\"" + fileName + "\" has incorrect dimensions: \n  1) " + widDB + " x " + hgtDB + " are the errant values \n  2) " + realWid + " x " + realHgt + " are the true values";
				reportError( "Image Dimension Error", eMsg );
			}
			ImgReal = null;
		}
		else {
			clearTimeout( checkDimTimer );
			eval( "checkDimTimer = setTimeout( 'checkDim( \"" + imgRealSrc + "\", " + widDB + ", " + hgtDB + " )', 250 );" );
		}
	}

}

/////////////////////////////// END IMAGE LIBRARY FUNCTIONS ///////////////////////////////


///////////////////////////////// BEGIN COOKIE FUNCTIONS /////////////////////////////////

function getCookieDomain() {

	var cookieDomain = null;
	if( live && theHost ) {
		var Host = theHost.split( "." ), hLen = Host.length;
		if( hLen >= 2 )
			cookieDomain = "." + Host[ hLen - 2 ] + "." + Host[ hLen - 1 ];
	}
	return cookieDomain;

}
//--------------- Cookie Library ---------------

function getCookieVal( offset ) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}

//--------------- Cookie Library ---------------
function GetCookie( name ) {
  var arg = name + "=";
  var alen = arg.length;
  var clen = document.cookie.length;
  var i = 0;
  while (i < clen) {
    var j = i + alen;
    if (document.cookie.substring(i, j) == arg)
      return getCookieVal (j);
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  }
  return null;
}

//--------------- Cookie Library ---------------
function SetCookie( name, value, expires ) {
	var path = "/", domain = getCookieDomain(), secure = null;
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}

//--------------- Cookie Library ---------------
function DeleteCookie( name ) {
	var path = "/", domain = getCookieDomain();
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}

var expDate12Mon = new Date();
expDate12Mon.setTime ( expDate12Mon.getTime() + ( 24 * 60 * 60 * 365 * 1000 ) ); // 1 year

///////////////////////////////// END COOKIE FUNCTIONS /////////////////////////////////



///////////////////////////////// BEGIN LINK ROLLOVER  /////////////////////////////////

linkAboutOff = new Image(); linkAboutOff.src = "images/linkAboutOff.gif";
linkAboutOn = new Image(); linkAboutOn.src = "images/linkAboutOn.gif";

linkRatesOff = new Image(); linkRatesOff.src = "images/linkRatesOff.gif";
linkRatesOn = new Image(); linkRatesOn.src = "images/linkRatesOn.gif";

linkAvailabilityOff = new Image(); linkAvailabilityOff.src = "images/linkAvailabilityOff.gif";
linkAvailabilityOn = new Image(); linkAvailabilityOn.src = "images/linkAvailabilityOn.gif";

linkPhotosOff = new Image(); linkPhotosOff.src = "images/linkPhotosOff.gif";
linkPhotosOn = new Image(); linkPhotosOn.src = "images/linkPhotosOn.gif";

linkContactUsOff = new Image(); linkContactUsOff.src = "images/linkContactUsOff.gif";
linkContactUsOn = new Image(); linkContactUsOn.src = "images/linkContactUsOn.gif";

linkHomepageOff = new Image(); linkHomepageOff.src = "images/linkHomepageOff.gif";
linkHomepageOn = new Image(); linkHomepageOn.src = "images/linkHomepageOn.gif";

//--------------------------------------------------------------------------------------

function activateLink( Img, on ) {
	try {
		Img.src = ( on ) ? eval( Img.id + "On.src" ) : eval( Img.id + "Off.src" );
	}
	catch( Err ) { }
}


////////////////////////////////// END LINK ROLLOVER  //////////////////////////////////


//////////////////////////// START OPEN BROWSER WIN: PopUp ////////////////////////////

/*
ACCESSOR VAR: None
ACCESSOR FUN: None
*/

function PopUp() {

	this.winName = "hbhWin";

	// Do not edit past this line -------------------------
	this.Win = null;
	this.openWin = openWin;
	this.printerFriendly = printerFriendly;
	this.closeWin = closeWin;
	this.linkToWin = linkToWin;

	//------------------------------------ METHOD: PopUp ------------------------------------

	//                req,  opt,  opt,  opt,  opt,  opt,  opt,  opt,   opt,    opt,
	function openWin( url, wWid, wHgt, wPos, tBar, lBar, sBar, mBar, scBar, reSize ) {

		this.closeWin();

		if( typeof wWid == "undefined" ) wWid = .8;
		if( typeof wHgt == "undefined" ) wHgt = .6;
		if( typeof wPos == "undefined" ) wPos = 1;
		if( typeof tBar == "undefined" ) tBar = 1;
		if( typeof lBar == "undefined" ) lBar = 1;
		if( typeof sBar == "undefined" ) sBar = 1;
		if( typeof mBar == "undefined" ) mBar = 1;
		if( typeof scBar == "undefined" ) scBar = 1;
		if( typeof reSize == "undefined" ) reSize = 1;

		var avWid = screen.availWidth - 10;
		var avHgt = screen.availHeight - 30;

		if( wWid < 1 ) wWid = wWid * avWid;
		if( wHgt < 1 ) wHgt = wHgt * avHgt;

		if( wWid > avWid * 0.90 || wWid == 1 ) wWid = avWid * 0.90;
		if( wHgt > avHgt * 0.70 || wHgt == 1 ) wHgt = avHgt * 0.70;

		var leftPos = 0;
		var topPos = 0;

		switch( wPos ) {
			case 1: // top middle
				leftPos = parseInt( ( avWid - wWid ) / 2 );
				break;

			case 2: // center middle
				leftPos = parseInt( ( avWid - wWid ) / 2 );
				topPos =  parseInt( ( avHgt - wHgt ) / 2 );
				break;
		}

		this.Win = window.open(url,PopUp.winName,"toolbar="+tBar+",location="+lBar+",directories=0,status="+sBar+",menubar="+mBar+",scrollbars="+scBar+",resizable="+reSize+",width="+wWid+",height="+wHgt+",top="+topPos+",left="+leftPos);

	}

	//------------------------------------ METHOD: PopUp ------------------------------------

	function printerFriendly() {

		var nTitle = 1;
		var pageTitle = "";
		while( document.getElementById( "pfTitle" + nTitle ) ) {
			pageTitle += document.getElementById( "pfTitle" + nTitle ).innerHTML + " ";
			// Remove hyperlinks
			pageTitle = pageTitle.replace( /<a\s.*?>/gi , "" );
			pageTitle = pageTitle.replace( /<\/a.*?>/gi , "" );
			nTitle++;
		}

		var pfPageTitle = ( pageTitle ) ? pageTitle : document.title;

		var htm =
		"<html>" +
			"<head>" +
				"<title>" + document.title + "</title>" +
				"<link rel='stylesheet' href='printer-friendly.css' type='text\/css'>" +
			"</head>" +
			"<body onLoad='if( window.print ) window.print();'>" +

			"<div class='title'>" + pfPageTitle + "</div>" +
			"<div class='metaData'>" + document.location.href + " &#149; " + new Date().toLocaleString() + "</div>";

				var nContent = 1;
				while( document.getElementById( "pfContent" + nContent ) ) {
					var content = document.getElementById( "pfContent" + nContent ).innerHTML;
					// Remove hyperlinks
					content = content.replace( /<a\s.*?>/gi , "" );
					content = content.replace( /<\/a.*?>/gi , "" );
					htm += content;
					nContent++;
				}

				if( document.getElementById( "pfFooter" ) )
					htm += "<p class='footer'>" + document.getElementById( "pfFooter" ).innerHTML + "</p>";

			htm +=
			"</body>" +
		"</html>";

		if( nContent > 1 ) {
			this.closeWin();
			this.openWin( "", 1 );
			this.Win.document.write( htm );
			this.Win.document.close();
		}
		else
			reportError( "Error at PopUp.printerFriendly", "No printer friendly sections (pfContent*) found..." );

	}
	//------------------------------------ METHOD: PopUp ------------------------------------

	function closeWin() {
		try {
			if( this.Win && this.Win.open && !this.Win.closed ) {
				this.Win.close();
				this.Win = null;
			}
		}
		catch( e ) {}
	}
	//------------------------------------ METHOD: PopUp ------------------------------------

	function linkToWin() {
		if( PopUp && PopUp.Win && PopUp.Win.registered ) PopUp.Win.MyOpener = self;
		else setTimeout( "PopUp.linkToWin()", 250 );
	}
}

PopUp = new PopUp();

////////////////////////////// END OPEN BROWSER WIN: PopUp /////////////////////////////

//////////////////////////////// START DYNAMIC INDEX DI ////////////////////////////////

/*

ACCESSOR VARIABLES: None
ACCESSOR FUNCTIONS: Cookie
ACCESSOR STYLES: di*, img.tn, img.tnOn
*/

//-------------------------------- OBJECT CONSTRUCTOR DI --------------------------------

function DynamicIndex( setEvtHandlers ) {

	// Begin User Settings -------------------------
	this.msg = new Array();
	this.msg.show = "Click to show content";
	this.msg.hide = "Click to hide content";

	// Do not edit past this line -------------------------
	this.getPlusMinus = getPlusMinus;
	this.reset = reset;
	this.switchDisplay = switchDisplay;
	this.showTip = showTip;
	this.maintainState = maintainState;
	this.setEventHandlers = setEventHandlers;
	if( setEvtHandlers ) this.setEventHandlers();

	//------------------------------------ METHOD DI ------------------------------------

	function setEventHandlers() {

		try {
			var AllLinks = document.getElementsByTagName( "a" );
			for ( var i = 0; i < AllLinks.length; i++ ) {

				// Clickable Link
				if( AllLinks[ i ].className == "diHeading" ) {
					AllLinks[ i ].onclick = function() { if( window.DI ) DI.switchDisplay( this ); }
					AllLinks[ i ].onmouseover = function() { if( window.DI ) DI.showTip( this ); return true; }
				}
				// Plus/Minus Sign
				if( AllLinks[ i ].className == "diPlusMinus" ) {
					AllLinks[ i ].onclick = function() { if( window.DI ) DI.switchDisplay( this.nextSibling ); }
					AllLinks[ i ].onmouseover = function() { if( window.DI ) DI.showTip( this.nextSibling ); return true; }
				}
			}
			self.status = "";
		}
		catch( Err ) {
			self.status = "Initializing DI.setEventHandlers() method, one moment please...";
			setTimeout( "DI.setEventHandlers();", 250 );
		}

	}

	//------------------------------------ METHOD DI ------------------------------------

	function maintainState() {

		try {
			// Use the file name as cookie name
			var path = document.location.pathname;
			var delimeter = ( path.indexOf( "\\" ) >= 0 ) ? "\\" : "/";
			var Path = path.split( delimeter );
			var fileName = Path[ Path.length - 1 ];
			this.cookieName = fileName.split( "." )[ 0 ];
			var diState = GetCookie( this.cookieName );

			if( diState ) {

				var AllLinks = document.getElementsByTagName( "a" );
				var DiState = diState.split( "_" );

				// Loop all links on page
				for ( var i = 0; i < AllLinks.length; i++ ) {
					for( var k in DiState ) {
						if( DiState[ k ] && parseInt( DiState[ k ] ) == i ) {
							try{ DI.switchDisplay( AllLinks[ i ], AllLinks[ i ].id ) } catch( e ){};
						}
					}
				}
			}
			self.status = "";
		}
		catch( Err ) {
			self.status = "Initializing DI.maintainState() method, one moment please...";
			setTimeout( "DI.maintainState();", 250 );
		}
	}

	//------------------------------------ METHOD DI ------------------------------------

	function getPlusMinus( Link ) { return Link.previousSibling; }

	//------------------------------------ METHOD DI ------------------------------------

	function reset( OtherID ) {
		for( var i = 0; i < OtherID.length; i++ ) {
			var PlusMinus = document.getElementById( "plusMinus_" + OtherID[ i ] );
			if( PlusMinus ) {
				PlusMinus.innerHTML = "-";
				this.switchDisplay( null, OtherID[ i ] );
			}
			else {
				alert( "ERROR: DI.reset unable to initialize PlusMinus as an Object.\nPROBLEM: \"plusMinus_" + OtherID[ i ] + "\" cannot be found." );
				return;
			}
		}
	}
	//------------------------------------ METHOD DI ------------------------------------

	function switchDisplay( Link, contentID, focuserID ) {

		if( !Link ) Link = document.getElementById( contentID );
		var PlusMinus = getPlusMinus( Link );
		var expanding = ( PlusMinus.innerHTML == "+" ), contracting = !expanding;

		// It there is a photo caption then activate it
		var Caption = document.getElementById( "caption_" + Link.id );
		if( Caption)
			Caption.className = ( expanding ) ? "diCaptionOn" : "diCaptionOff";

		// It there is an image then activate it
		var Img = document.getElementById( "img_" + Link.id );
		if( Img )
			Img.className = ( expanding ) ? "tnOn" : "tn";

		PlusMinus.innerHTML = ( expanding ) ? "-" : "+";

		var AllLinks = document.getElementsByTagName( "a" );

		var valOld = GetCookie( this.cookieName ), valNew = "";

		// Record State; loop all links on page
		for ( var i = 0; i < AllLinks.length; i++ ) {

			// Found link just clicked
			if( AllLinks[ i ] == Link ) {
				// Existing cookie present
				if( valOld ) {
					var key = "_" + i + "_";
					// this i value already recorded
					if( valOld.indexOf( key ) >= 0 ) {
						// Remove this entry
						if( contracting ) {
							var ValOld = valOld.split( key );
							valNew = ( ( ValOld[ 0 ] ) ? ValOld[ 0 ] : "" ) + "_" + ( ( ValOld[ 1 ] ) ? ValOld[ 1 ] : "" );
							( valNew == "_" ) ? DeleteCookie( this.cookieName ) : SetCookie( this.cookieName, valNew );
						}
						break;
					}
					if( expanding ) valNew = valOld + i + "_";
				}
				else if( expanding ) // First expansion; no cookie set
					valNew = "_" + i + "_";

				if( valNew )
					SetCookie( this.cookieName, valNew );
				break;
			}
		}

		if( contentID )
			var Content = document.getElementById( "content_" + contentID );
		else
			var Content = ( Link.parentNode.nextSibling.style ) ? Link.parentNode.nextSibling : Link.parentNode.nextSibling.nextSibling;

		try{
			Content.style.display = ( contracting ) ? "none" : "block";
		}
		catch( Err ) {
			var problem = ( contentID ) ? "\nPROBLEM: \"content_" + contentID + "\" cannot be found." : "";
			alert( "ERROR: DI.switchDisplay unable to initialize Content as an Object." + problem );
		}

		if( focuserID && expanding ) {
			var FocusCont = document.getElementById( focuserID );
			FocusCont.innerHTML = "<a href='javascript:void(0);'>.</a>";
			var FocusLink = FocusCont.firstChild;
			FocusLink.focus();
			Link.focus();
			FocusCont.innerHTML = "";
		}
		showTip( Link );

	}

	//------------------------------------ METHOD DI ------------------------------------

	function showTip( Link, msgOn, msgOff ) {

		var PlusMinus = getPlusMinus( Link );

		if( PlusMinus.innerHTML == "+" ) {
			Link.title = ( msgOn ) ? msgOn : DI.msg.show;
			PlusMinus.title = ( msgOn ) ? msgOn : DI.msg.show;
		}
		else {
			Link.title = ( msgOff ) ? msgOff : DI.msg.hide;
			PlusMinus.title = ( msgOff ) ? msgOff : DI.msg.hide;
		}

	}

}
//////////////////////////////// END DYNAMIC DI ////////////////////////////////

function getEmailLink( subject ) {

	if( subject )
		subject = "?subject=" + escape( subject );

	return "<a href='mailto:" + DB.Contact.Email + subject + "' title='Send us an e-mail' class='dwLink'>" + DB.Contact.Email + "</a>";
}

//--------------------------------------------------------------------------------------

function showHawaiiTime() {

	var gmtOffset = 10; // for Hawaii
	var now = new Date();
	var difhrs = now.getTimezoneOffset()/60;
	var lochrs = now.getHours();
	GMThours = lochrs + difhrs;
	now.setHours( GMThours - gmtOffset );

	var am_pm = "AM";
	var hours = now.getHours();

	if( hours >= 12 ) am_pm = "PM";
	if( hours >= 13 ) hours -= 12;
	if( hours == 0 ) hours = "12";

	var minutes = now.getMinutes();
	if( minutes < 10 ) minutes = "0" + minutes;

	var seconds = now.getSeconds();
	if( seconds < 10 ) seconds = "0" + seconds;
	try{
		document.getElementById( "hawaii_time" ).innerHTML = hours + ":"  + minutes + ":"  + seconds + " " + am_pm;
	}
	catch( Err ) {}
	finally{ setTimeout( "showHawaiiTime()", 1000 ); }
}


//--------------------------------------------------------------------------------------

function largePic( cap, wid, hgt, Link, evt ) {

	if( window.DW ) {
		DW.createWindow( [ cap, "imgSrc=" + Link.href ], [ 0, wid, hgt ], Link, evt );
		return false;
	}
	else
		return true;
}

///////////////////////////////// DYNAMIC WINDOW DW /////////////////////////////////

/*
	ACCESSOR VARS:  IE, MZ, SF, winIE
	ACCESSOR FUNC:  None
	ACCESSOR CLASS: dw*, off
*/

//--------------------------------- OBJECT CONSTRUCTOR DW ---------------------------------

function DynamicWindow( transNum, transDur ) {

	this.ContactUs = [ "Contact Us", "" +

	"<div>" +
		"<table align='center' border='0' cellspacing='0' cellpadding='0' class='contactUs'>" +

			"<tr>" +
				"<td valign='top' align='right'>" +
					"<div style='margin:0px 0px 0px 0px;' class='noWrap'>Name:</div>" +
				"</td>" +
				"<td valign='top'>" +
					"<div style='margin:0px 0px 0px 6px;'>" + DB.Contact.Name + "</div>" +
				"</td>" +
			"</tr>" +

			"<tr>" +
				"<td valign='top' align='right'>" +
					"<div style='margin:4px 0px 0px 0px;' class='noWrap'>Mail:</div>" +
				"</td>" +
				"<td>" +
					"<div style='margin:4px 0px 0px 6px;'>" + DB.Contact.Address1 + "<br>" + DB.Contact.Address2 + "</div>" +
				"</td>" +
			"</tr>" +

			"<tr>" +
				"<td valign='top' align='right'>" +
					"<div style='margin:4px 0px 0px 0px;' class='noWrap'>Phone:</div>" +
				"</td>" +
				"<td>" +
					"<div style='margin:4px 0px 0px 6px;'>" + DB.Contact.PhonePrimary + "</div>" +
				"</td>" +
			"</tr>" +

			"<tr>" +
				"<td valign='top' align='right'>" +
					"<div style='margin:4px 0px 0px 0px;' class='noWrap'>Cell:</div>" +
				"</td>" +
				"<td>" +
					"<div style='margin:4px 0px 0px 6px;'>" + DB.Contact.PhoneCell + "</div>" +
				"</td>" +
			"</tr>" +

			"<tr>" +
				"<td align='right'>" +
					"<div style='margin:4px 0px 0px 0px;' class='noWrap'>Hawaii Time:</div>" +
				"</td>" +
				"<td>" +
					"<div style='margin:4px 0px 0px 6px;'><span id='hawaii_time'></span></div>" +
				"</td>" +
			"</tr>" +

			"<tr>" +
				"<td align='right'>" +
					"<div style='margin:4px 0px 0px 0px;' class='noWrap'>Send E-Mail:</div>" +
				"</td>" +
				"<td>" +
					"<div style='margin:4px 0px 0px 6px;'>" + getEmailLink( "Hanalei Bay House Web Site Inquiry" ) + "</div>" +
				"</td>" +
			"</tr>" +

		"</table>" +
	"</div>" ];

	// Editable Settings
	this.dissolveMZ = 1;
	this.dissolveSF = 1;
	this.gDisableContextImgMenu = 1;

	this.Msg = new Array();
	this.Msg.fullSize = "View this image full-size";


	// Do not edit past this line -------------------------
	this.maxDissolve = 750 * 500;
	this.transNum = ( transNum ) ? transNum :   2;
	this.transDur = ( transDur ) ? transDur : 0.8;

	// Variables
	this.dWinOffsetX = 0;
	this.dWinOffsetY = 0;
	this.Window = null;
	this.overTitleBar = false;
	this.Photo = null;
	this.disableContextImgMenu = false;
	this.IeBody = null;

	// Methods
	this.createWindow = createWindow;
	this.showImg = showImg;
	this.keepInWin = keepInWin;
	this.getClickPosition = getClickPosition;
	this.getData = getData;
	this.mouseDown = mouseDown;
	this.mouseMove = mouseMove;
	this.removeWin = removeWin;
	this.mouseUp = mouseUp;

	document.onmousedown = this.mouseDown;
	document.onmousemove = this.mouseMove;
	document.onmouseup = this.mouseUp;

	//------------------------------------- METHOD DW -------------------------------------

	//                     req      req     opt      opt       opt         opt           opt
	function createWindow( dataSrc, WinDim, TheLink, theEvent, bodyMargin, RequestedPos, disableContextImgMenu ) {

		this.IeBody = ( IE && document.compatMode == "CSS1Compat" ) ? document.documentElement : document.body;

		if( TheLink ) TheLink.blur();

		if( !bodyMargin ) bodyMargin = 0;
		this.disableContextImgMenu = ( typeof disableContextImgMenu == "boolean" ) ? disableContextImgMenu : this.gDisableContextImgMenu;

		var Data = getData( dataSrc, TheLink ), title, body;

		title = Data[ 0 ].replace( /\^\^/g, "'" );
		title = title.replace( /\^/g, "\"" );
		body = Data[ 1 ].replace( /\^\^/g, "'" );
		body = body.replace( /\^/g, "\"" );

		// Read vals from 3-member WindowDimension, if image then get wid/hgt from tag
		var showImg = ( body.indexOf( "imgSrc=" ) == 0 );
		// overflow:auto creates vert scroll bars if content does not fit
		var scrollStyle = ( WinDim[ 0 ] ) ? " overflow:auto;" : "";
		var winWid = WinDim[ 1 ];
		var winHgt = WinDim[ 2 ];

		// Read vals from optional 4-member RequestedPosition
		var clickPos       = ( RequestedPos ) ? ( RequestedPos[ 0 ] == 1 ) : true;
		var aboveClkPos    = ( RequestedPos ) ? ( RequestedPos[ 0 ] == 2 ) : false;
		var topCent        = ( RequestedPos ) ? ( RequestedPos[ 0 ] == 3 ) : false;
		var center         = ( RequestedPos ) ? ( RequestedPos[ 0 ] == 4 ) : false;
		var botCent        = ( RequestedPos ) ? ( RequestedPos[ 0 ] == 5 ) : false;
		var xOffset        = ( RequestedPos ) ? RequestedPos[ 1 ] : 0;
		var yOffset        = ( RequestedPos ) ? RequestedPos[ 2 ] : 10;

		if( showImg ) {
			var mzDissolve = ( MZ && this.dissolveMZ && ( winWid * winHgt <= this.maxDissolve ) );
			var sfDissolve = ( SF && this.dissolveSF );

			// Create image tag
			var body = "<img src='" + body.split( "imgSrc=" )[ 1 ] + "' width='" + winWid + "' height='" + winHgt + "' border='0' hspace='0' vspace='0' galleryimg='no' style='" + getOpacity( sfDissolve, mzDissolve ) + "' onload='DW.showImg( this );' onAbort='this.src=this.src;'" + ">";

			this.title = title; // Store actual title

			var titleLC = title.toLowerCase(), lineBrks = "";
			var nLinesInTitle = titleLC.split( "<br>" ).length;
			for( var i = 0; i < nLinesInTitle; i++ ) lineBrks += "<br>";

			title = "Loading Image..." + lineBrks;
		}


		var Window = document.getElementById( "dWinID" );
		if( Window ) document.body.removeChild( Window );

		var NewWindow = document.createElement( "DIV" ), scrollSt, bodyHgtSt;

		bodyHgtStyle = ( winHgt ) ? " height:" + winHgt + "px;" : "";
		NewWindow.id = "dWinID";
		NewWindow.className = "dwWin";
		document.body.appendChild( NewWindow );
		NewWindow.style.visibility = "hidden"
		NewWindow.style.position = "absolute";
		NewWindow.style.width = ( IE && document.compatMode != "CSS1Compat" ) ? ( winWid + 2 * parseInt( NewWindow.currentStyle[ "borderWidth" ] ) ) + "px" : winWid + "px";
		NewWindow.style.top = ( screen.height * -1 ) + "px";
		NewWindow.style.left = ( screen.width * -1 ) + "px";
		NewWindow.style.zIndex = 10000;

		var myWindow = "" +

		"<div class='dwTitleRow' id='dwTitleRowID'>" +
			"<table align='center' border='0' cellspacing='0' cellpadding='0'>" +
				"<tr>" +
					"<td class='dwTitle' style='width:100%; text-align:center;' onmouseover='DW.overTitleBar=true;' onmouseout='DW.overTitleBar=false;' id='dwTitleTd1ID'>" +
						"<div id='dwTitleBarID'>" +
							title +
						"</div>" +
					"</td>" +
					"<td valign='top' id='dwTitleTd2ID'>" +
						"<a href='javascript:DW.removeWin();' onMouseOver='self.status=this.title; return true;' onMouseOut='self.status=\"\"; return true;' onClick='this.blur(); return true;' title='Close' class='dwX'>&times;</a>" +
					"</td>" +
				"</tr>" +
			"</table>" +
		"</div>" +

		"<div class='" + ( ( showImg ) ? "dwBodyParentImg" : "dwBodyParent" ) + "' style='width:100%;" + bodyHgtStyle + scrollStyle + "'>" +
			"<div class='dwBody' id='dwBodyID' style='margin:" + bodyMargin + "px;'>" +
				body +
			"</div>" +
		"</div>";

		NewWindow.innerHTML = myWindow;
		var xPos = 0, yPos = 0;

		if( clickPos || aboveClkPos ) {
			var ClickPos = this.getClickPosition( theEvent );
			xPos = ClickPos[ 0 ];
			var vPortWid = ( document.body.clientWidth ) ? document.body.clientWidth : window.innerWidth;
			var skew = Math.round( 100 * xPos / vPortWid ) / 100;
			xPos = xPos - ( skew * NewWindow.offsetWidth );

			// 1) Place at click position & add offset (if any)
			if( clickPos )
				yPos = ClickPos[ 1 ] + yOffset;

			// 2) Place above click position & add offset (if any)
			else
				yPos = ClickPos[ 1 ] - NewWindow.offsetHeight + yOffset;

		}

		// 3, 4 or 5) vAlign: Top center (3), Center (4) or Bot Center (5)
		else if( topCent || center || botCent ) {

			var scrollX, scrollY, bodyWid, bodyHgt;

			if( IE ) {
				scrollX = this.IeBody.scrollLeft;
				scrollY = this.IeBody.scrollTop;
				bodyWid = this.IeBody.clientWidth;
				bodyHgt = this.IeBody.clientHeight;
			}
			else {
				scrollX = window.pageXOffset;
				scrollY = window.pageYOffset;
				bodyWid = window.innerWidth;
				bodyHgt = window.innerHeight;
			}

			winHgt = NewWindow.offsetHeight;
			winWid = NewWindow.offsetWidth;

			xPos = parseInt( ( bodyWid - winWid ) / 2 + scrollX + xOffset );
			if( topCent ) yPos = parseInt( scrollY + yOffset );
			else if( center ) yPos = parseInt( ( bodyHgt - winHgt ) / 2 + scrollY + yOffset );
			else yPos = parseInt( bodyHgt - winHgt + scrollY + yOffset );

		}
		else { // RequestedPos[ 0 ] = 10 - 17: Places window around a component

			var Component = document.getElementById( RequestedPos[ 3 ] );
			var CurComponent = Component;
			var parPosAbs = false;
			while( CurComponent ) {
				if( SF ) {
					if( !parPosAbs ) parPosAbs = ( CurComponent.style.position == "absolute" );
					if( parPosAbs && CurComponent == Body ) break;
				}
				yPos += CurComponent.offsetTop;
				xPos += CurComponent.offsetLeft;
				CurComponent = CurComponent.offsetParent;
			}

			switch( RequestedPos[ 0 ] ) {


				case 10: // above left
					xPos += xOffset;
					yPos -= NewWindow.offsetHeight - yOffset;
					break;

				case 11: // above right
					xPos += Component.offsetWidth + xOffset;
					yPos -= NewWindow.offsetHeight - yOffset;
					break;

				case 12: // right top
					xPos += Component.offsetWidth + xOffset;
					yPos += yOffset;
					break;

				case 13: // right bottom
					xPos += Component.offsetWidth + xOffset;
					yPos += Component.offsetHeight + yOffset;
					break;

				case 14: // below right
					xPos += xOffset;
					yPos += Component.offsetHeight + yOffset;
					break;

				case 15: // below left
					xPos += Component.offsetWidth + xOffset - NewWindow.offsetWidth;
					yPos += Component.offsetHeight + yOffset;
					break;

				case 16: // left below
					xPos += xOffset - NewWindow.offsetWidth;
					yPos += Component.offsetHeight + yOffset;
					break;

				case 17: // left top
					xPos += xOffset - NewWindow.offsetWidth;
					yPos += yOffset;
					break;

				default:
					alert( "Switch/Case Error at DW.createWindow: RequestedPos[ 0 ] has a value of " + RequestedPos[ 0 ] + " which is invalid." );

			}
		}

		var NewWindowPos = this.keepInWin( NewWindow, xPos, yPos );
		xPos = Math.round( NewWindowPos[ 0 ] );
		yPos = Math.round( NewWindowPos[ 1 ] );

		NewWindow.style.left = xPos + "px";
		NewWindow.style.top  = yPos + "px";
		NewWindow.style.visibility = "visible";

	}

	//------------------------------------- METHOD DW -------------------------------------

	function showImg( Photo ) {

		Photo.onclick = DW.removeWin;
		Photo.oncontextmenu = function() { if( DW.disableContextImgMenu ) return false; };
		Photo.onmouseover = function() {
			Photo.title = "Click to close";
			self.status = Photo.title;
			Photo.style.cursor = ( IE ) ? "hand" : "pointer";
			return true;
		};
		Photo.onmouseout = function() { self.status = ""; return true; };

		try {
			checkDim( Photo.src, Photo.width, Photo.height );

			document.getElementById( "dwTitleBarID" ).innerHTML = this.title;

			var mzDissolve = ( MZ && this.dissolveMZ && ( Photo.width * Photo.height <= this.maxDissolve ) );
			var sfDissolve = ( SF && this.dissolveSF );

			startFade( Photo, this.transNum, this.transDur, 0, sfDissolve, mzDissolve );
		}
		catch( Err ) {
			self.status = "Exception thrown at method DW.showImg...";
		}

	}

	//------------------------------------- METHOD DW -------------------------------------

	function keepInWin( NewWindow, leftEdge, topEdge ) {

		var bodyHgt = ( IE ) ? this.IeBody.clientHeight : window.innerHeight;
		var bodyWid = ( IE ) ? this.IeBody.clientWidth : window.innerWidth;

		// Prevent window from going off bottom & top of page
		var winHgt = NewWindow.offsetHeight;
		var yOffset = ( IE ) ? this.IeBody.scrollTop : window.pageYOffset;
		var vScreenPos = topEdge - yOffset;
		var vSkew = bodyHgt - vScreenPos;
		if( vSkew < winHgt + 10 ) topEdge -= winHgt - vSkew + 10; // bottom edge
		else if( vScreenPos < 10 ) topEdge = 10 + yOffset; // top edge

		// Prevent window from going off right & left edges
		var winWid = NewWindow.offsetWidth;
		var xOffset = ( IE ) ? this.IeBody.scrollLeft : window.pageXOffset;
		var hScreenPos = leftEdge - xOffset;
		var hSkew = bodyWid - hScreenPos;
		if( hSkew < winWid + 10 ) { // right edge
			leftEdge -= winWid - hSkew + 10;
			// Vert scroll bar is present
			if( !IE && document.body.scrollHeight > bodyHgt ) leftEdge -= 15;
		}
		else if( hScreenPos < 10 ) leftEdge = 10 + xOffset; // left edge

		return[ leftEdge, topEdge ];
	}
	//------------------------------------- METHOD DW -------------------------------------

	function getClickPosition( theEvent ) {

		try {
			if( IE ) {
				var x = event.clientX + this.IeBody.scrollLeft;
				var y = event.clientY + this.IeBody.scrollTop;
			}
			else {
				var x = theEvent.pageX;
				var y = theEvent.pageY;
			}
		}
		// Catch exceptions when action does not create an event, like when
		// creating window from MZ selecting pull-down
		catch( err ) {
			var x = 0;
			var y = 0;
		}

		return[ x, y ];
	}
	//------------------------------------- METHOD DW -------------------------------------

	function getData( dataSrc, TheLink ) {

		// Get the data...
		if( dataSrc == "nextSibling" ) {

			// If we have old innerHTML then put it back where it belongs
			if( eval( "typeof this.LastSrc" ) == "object" )
				eval( "this.LastSrc.innerHTML = this.lastData" );

			try {
				var DataSource = ( TheLink.nextSibling.innerHTML ) ? TheLink.nextSibling : TheLink.nextSibling.nextSibling;
			}
			catch( err ) { alert( "EXCEPTION: Data source not found" ); return false; }

			try {
				var Title = ( DataSource.firstChild.innerHTML ) ? DataSource.firstChild : DataSource.firstChild.nextSibling;
				var title = Title.innerHTML;
			}
			catch( err ) { alert( "EXCEPTION: Title source not found" ); return false; }

			try {
				var Body = ( Title.nextSibling.innerHTML ) ? Title.nextSibling : Title.nextSibling.nextSibling;
				var body = Body.innerHTML;
			}
			catch( err ) { alert( "EXCEPTION: Body source not found" ); return false; }

			// Record this Source as Object & record innerHTML
			eval( "this.LastSrc = DataSource" );
			eval( "this.lastData = DataSource.innerHTML" );
			DataSource.innerHTML = "";

		}
		else {
			var title = dataSrc[ 0 ];
			var body  = dataSrc[ 1 ];
		}

		return[ title, body ];

	}

	//------------------------------------- METHOD DW -------------------------------------
	// Record x & y offset within dWin and set this.Window
	function mouseDown( e ) {

		if( DW.overTitleBar ) {

			this.Window = document.getElementById("dWinID");

			if( IE ) {
				this.dWinOffsetX = event.offsetX;
				this.dWinOffsetY = event.offsetY;
			}
			else {
				this.dWinOffsetX = e.layerX;
				this.dWinOffsetY = e.layerY;
				return false;
			}
		}
	}

	//------------------------------------- METHOD DW -------------------------------------

	function mouseMove( e ) {
		if( this.Window ) {

			var ClickPos = DW.getClickPosition( e );
			// Don not let user move menu off left or top edge of screen
			if( ClickPos[ 0 ] <= 0 ||  ClickPos[ 1 ] <= 0 ) {
				this.Window = null;
				return false;
			}

			if( IE ) {
				if( event.button != 1 ) return false; // mouse moved off screen
				this.Window.style.left = ( event.clientX - this.dWinOffsetX + DW.IeBody.scrollLeft ) + "px";
				this.Window.style.top = ( event.clientY - this.dWinOffsetY + DW.IeBody.scrollTop ) + "px";
				return false;
			}

			else {
				this.Window.style.top = ( e.pageY - this.dWinOffsetY ) + "px";
				this.Window.style.left = ( e.pageX - this.dWinOffsetX ) + "px";
			 }
		 }
	}

	//------------------------------------- METHOD DW -------------------------------------

	function removeWin() { // called by x only or clicking photo
		var Window = document.getElementById( "dWinID" );
		// Do not add feature to remove inner HTML by setting it to an empty string
		if( Window ) document.body.removeChild( Window );
	}

	//------------------------------------- METHOD DW -------------------------------------

	function mouseUp() { this.Window = null; }

}

////////////////////////////////// END DYNAMIC WINDOW //////////////////////////////////


///////////////////////////////// Begin Object FileWriter FW /////////////////////////////////

function FileWriter() {

	// Notes & Buttons can be customized on a per client basis

	////////// 1) HTML //////////
	this.HtmNotes = "";

	// Edit html buttons
	this.HtmButtons =
	"<button onClick='FW.insertTags( \"<br>\", \"\", \"EditedHTML\" ); return false;' title='Inserts line-break tag at cursor position' class='htmlTags'>&lt;br&gt;</button>" +

	"<button onClick='FW.insertTags( \"<b>\", \"</b>\", \"EditedHTML\" ); return false;' title='Inserts bold tags around highlighted text' class='htmlTags'><b>B</b></button>" +

	"<button onClick='FW.insertTags( \"<i>\", \"</i>\", \"EditedHTML\" ); return false;' title='Inserts italic tags around highlighted text' class='htmlTags'><i>I</i></button>";


	////////// 2) JS	 //////////
	if( qStr && qStr.getVal( "db" ) ) { // Edit thumbnail images

		this.JsNotes =

		"The Images Array below controls the photos that show on your Slide-Show & Thumbnail pages. Ideally, your large image (ex: beach.jpg) should have a height of 500 pixels while it's thumbnail (beachTN.jpg) must be 100&times;100 pixels square. Read these <a href='javascript:PopUp.openWin( \"http://www.davidregier.com/webdesign/other/images.html?ss=sstn&tnEdge=100\" );' class='fw' title='Preparing images for the Slide-Show/Thumbnails pages'>detailed instructions</a> on preparing images for the slide-show/thumbnail pages." +

		"<ol>" +

			"<li>Right-click a thumbnail to read properties for the large image.</li>" +

			"<li>To add a new photo you will first prepare & <a href='javascript:PopUp.openWin( \"uploader.aspx\", 650, 350, 2, 0, 0, 0, 0, 0, 0 );' title='Upload files to the server' class='fw'>upload</a> the large image with thumbnail per the instructions above.</li>" +

			"<li>Then enter a new blank line at the position you would like your new photo to appear.</li>" +

			"<li>With your cursor at the beginning of the new line, click the \"Add New Data Structure\" button. A blank data structure is auto-inserted.</li>" +

			"<li>Fill out the photo information. From left to right it is: (1) Photo Filename, within double quotes. (2) Photo width in pixels. (3) Photo height in pixels. (4) Description, if none, leave blank (empty double quotes).</li>" +

			"<li>On rare occasions, you may need to use double quotes w/i the Description (4th field). If so, you must first \"escape the text\" you are quoting. Here's how: (1) Highlight the text you would like quoted. (2) Click Escape.</li>" +

		"</ol>";

		this.JsButtons = "<button onClick='FW.insertTags( \"[\\\"\\\",,, \\\"\\\"],\", \"\", \"EditedJS\" ); return false;' title='Insert new blank data structure at cursor position' class='htmlTags'>Add New Data Structure</button> &nbsp;";

		this.JsButtons +=	"<button onClick='FW.insertTags( \"\\\\\\\"\", \"\\\\\\\"\", \"EditedJS\" ); return false;' title='Surrounds text you have highlighted with double quotes' class='htmlTags'>\\\"Escape\\\"</button>";
	}
	else { // Edit e-commerce data (data.js)


		this.JsNotes =

		"<ol>" +
			"<li>This is your global e-commerce data. Changes made to this file update across entire site immediately" +

			"<li>Always evaluate the site after making any changes to make sure it looks and/or functions as you were expecting" +

			"<li>Remember, if you just published but don't see your changes? Then click the \"Reload\" button below." +

			"<li>Dollar values are always represented as pure mathematical numbers: $52.99 will be 52.99, $6.00 will be 6" +
		"</ol>";


		this.JsButtons ="<button onClick='FW.insertTags( \"\\\\\\\"\", \"\", \"EditedJS\" ); return false;' title='Inserts a single double quote at cursor position' class='htmlTags'>\\\"</button> &nbsp;";

		this.JsButtons +="<button onClick='FW.insertTags( \"\\\\\\\"\", \"\\\\\\\"\", \"EditedJS\" ); return false;' title='Surrounds text you have highlighted with double quotes' class='htmlTags'>\\\"Escape\\\"</button>";


	}

	////////// 3) XML //////////
	this.XmlNotes =

	"<div>Here's why you may need to edit this XML data:</div>" +
	"<ol>" +

		"<li>Change contact information like Name, Address, Phone, etc.</li>" +

		"<li>To change Administrator Names, E-mails, Passwords & Editing Privileges" +
			"<ol class='fSize10' type='a'>" +
				"<li>Set it to yes to allow administrator to edit that particular data type</li>" +
				"<li>Set it to no to prohibit administrator from editing that particular data type</li>" +
				"<li>Set subscribe-to-calendar-updates to &ldquo;yes&rdquo; to receive an e-mail update whenever the calendar is published.</li>" +
			"</ol>" +
		"</li>" +

		"<li>To change calendar read-all password.</li>" +

		"<li>To change e-mail address where website generated error messages (if any) are delivered.</li>" +

	"</ol>";

	// Additional admin links (if any) otherwise set empty str
	this.AdminLinks = "&nbsp;&#149;&nbsp;<a href='javascript:PopUp.openWin( \"http://www.davidregier.com/webdesign/other/images.html?ss=ss\" );' class='fw' title='How to add images to the Slide-Show'>Slide-Show Help</a>";

	// Do not edit past this line -------------------------
	this.getServerTimeZoneOffset = getServerTimeZoneOffset;
	this.forceLogin = forceLogin;
	this.forceLogin();
	this.getLogInGUI = getLogInGUI;
	this.logIn = logIn;
	if( !GetCookie( "userWithWritePrivileges" ) ) return;

	// Methods
	this.help = help;
	this.showHelp = showHelp;
	this.restore = restore;
	this.insertTags = insertTags;
	this.init = init;
	this.checkContent = checkContent;
	this.resetUI = resetUI;
	this.reLoad = reLoad;
	this.logOff = logOff;

	this.cursorReadyHtm = false;
	this.cursorReadyJS = false;
	this.init();

	//------------------------------------- Method FW -------------------------------------
	// Returns serverTimeZoneOffset (in hours). It changes because server observes DST

	function getServerTimeZoneOffset() {

		var serverTimeZoneOffset = 10;

		if( GetCookie( "serverTimeZoneOffset" ) )
			serverTimeZoneOffset = parseInt( GetCookie( "serverTimeZoneOffset" ) );

		else {

			var Today = new Date(), FirstSunNov, SecondSunMar, nSundays = 0;

			for( var i = 1; i <= 31; i++ ) {
				var FirstSunNov = new Date( Today.getFullYear(), 10, i );
				if( FirstSunNov.getDay() == 0 ) break;
			}

			for( var i = 1; i <= 31; i++ ) {
				var SecondSunMar = new Date( Today.getFullYear(), 2, i );
				if( SecondSunMar.getDay() == 0 ) nSundays++;
				if( nSundays == 2 ) break;
			}

			if( live )
				serverTimeZoneOffset = ( Today.getTime() >= SecondSunMar.getTime() && Today.getTime() <= FirstSunNov.getTime() ) ? 4 : 5;

			SetCookie( "serverTimeZoneOffset", serverTimeZoneOffset );

		}

		return serverTimeZoneOffset;
	}

	//------------------------------------- Method FW -------------------------------------

	function forceLogin() {

		try	{
			// Only true if user tries to log-in while another administrator is already logged in
			if( window.LastAdministrator ) {

				var lastAdminFull = LastAdministrator[ 0 ];
				var lastAdminFirst = LastAdministrator[ 0 ].split( " " )[ 0 ];
				var nTicks_Jan_1_1970 = 621355968000000000;
				var ms = ( LastAdministrator[ 1 ] - nTicks_Jan_1_1970 ) / 10000;
				var loggedIn = new Date( ms + this.getServerTimeZoneOffset() * 60 * 60 * 1000 ).toLocaleString();

				// SF/Mac Mail chokes on single quotes in sub or body

				var sub = "Are you logged onto " + theHost + " right now?";
				sub = ( SF ) ? sub : escape( sub );

				var body = "\r\n\r\n" + lastAdminFirst + ", are you logged onto the site as Administrator right now? I am trying to log-in and I am getting a warning indicating you logged-in on " + loggedIn + " and are still logged in!\r\nThe current time on my computer is " + new Date().toLocaleString();
				body = ( SF ) ? body : escape( body );

				var htm = "<div class='fwForceLogin'>" +

					"Hello " + qStr.getVal( "user" ).split( "_" )[ 0 ] + ". " + lastAdminFull + " logged in on " + loggedIn + ". " + lastAdminFirst + " is either presently logged in or may have failed to log-out!<br><br>" +

					"In order to protect the integrity of our data, two or more users editing the same data at the same time is not allowed. With that in mind, you can:" +

				 "<ol style='margin-top:6px; margin-bottom:6px;'>" +

						"<li style='margin-bottom:2px;'>Wait until " + lastAdminFirst + " logs out.</li>" +

						"<li style='margin-bottom:2px;'>Email " + lastAdminFirst + " at <a href='mailto:" +  DB.Administrators[ lastAdminFull ] + "?subject=" + sub + "&body=" + body + "' title='Send e-mail asking if this person is logged-in' class='dwLink'>" + DB.Administrators[ lastAdminFull ] + "</a> to ask.</li>" +

						( ( fileName == "calendar.aspx" ) ? "<li style='margin-bottom:2px;'><a href='calendar.aspx?pw=" + rapw + "' title='You can read-all booking info but you cannot edit it' class='dwLink'>Load the calendar</a> with read-all access, because you only need to get info not edit it...</li>" : "" ) +

						"<li><a href='" + document.location.href + "' onClick='SetCookie( \"forcedLogin\", \"yes\" ); return true;' title='Logs you in & forces out other active administrator (if any)' class='dwLink'>Force Log-In</a> now because you know that " + lastAdminFirst + " failed to log-out last time and is NOT actively logged-in. Note that you will terminate " + lastAdminFirst + "'s session if " + lastAdminFirst + " is logged-in right now.</li>" +

				 "</ol>" +

			 "</div>";

				DW.createWindow( [ "Concurrent Administrator Conflict", htm ], [0,500,0], null, null, 6, [4,0,0] );
			}
		}

		catch( Err ) {
			if( local ) {
				var err = "";
				for( member in Err ) err += member + ": " + Err[ member ] + "\n";
				alert( "Exception at method FW.forceLogin:\n\n" + err );
			}
			else {
				setTimeout( "FW.forceLogin();", 250 );
				self.status = "Initializing File Writer: FW.forceLogin()...";
			}
		}

	}

	//------------------------------------- Method FW -------------------------------------

	function showHelp( Link ) {

		var PlsMin = Link.previousSibling;
		var Content = Link.nextSibling;

		if( Content.className == "fw1" ) {
			Content.className = "fw0";
			PlsMin.innerHTML = "+";
		}
		else {
			Content.className = "fw1";
			PlsMin.innerHTML = "-";
		}
	}

	//------------------------------------- Method FW -------------------------------------

	function help( nType, Link, evt ) {

		// sub function
		function getHelpTxt( helpType ) {

			var htm =

			"<div class='fwHelpSect'>" +
				"<a href='javascript:void(0)' onClick='FW.showHelp(this.nextSibling);' class='fwPlusMinus'>+</a><a href='javascript:void(0);' onClick='FW.showHelp(this);' class='dwLink'>Reload & Cache</a>" +
				"<div class='fw0'>" +

					"<u>Cache Defined</u>: All browsers seamlessly store all recent pages that you have visited on your hard drive. This process is called \"caching\" and it greatly speeds up your web browsing because your browser is able to later retrieve these web pages off your hard drive much quicker than downloading them again from the server.<br><br>" +

					"<u>Caching will cause problems for you</u> because after you press Publish, and the page reloads, you may be looking at a past cached version of that page rather than the most recent version which you just published and are naturally expecting to see.<br><br>" +

					"<u>Remember this mantra</u> & you will eliminate cache frustrations forever!<br>" +
					"&nbsp;&nbsp;\"Just Published but don't see your changes? Then press Reload\"" +
				"</div>" +
			"</div>" +

			"<div class='fwHelpSect'>" +
				"<a href='javascript:void(0)' onClick='FW.showHelp(this.nextSibling);' class='fwPlusMinus'>+</a><a href='javascript:void(0);' onClick='FW.showHelp(this);' class='dwLink'>Publish " + helpType + "</a>" +
				"<div class='fw0'>" +
					"Press Publish-" + helpType + " after you have made your edits. Your changes will be permanently written to file and the page will be reloaded. After the page reloads, verify your changes. If you don't see them press Reload.";

					if( helpType == "XML" )
						htm += " Changes made to XML data update across entire site immediately";

					htm +=
				"</div>" +
			"</div>" +

			"<div class='fwHelpSect'>" +
				"<a href='javascript:void(0)' onClick='FW.showHelp(this.nextSibling);' class='fwPlusMinus'>+</a><a href='javascript:void(0);' onClick='FW.showHelp(this);' class='dwLink'>Reset</a>" +
				"<div class='fw0'>" +
					"Press Reset if you made edit(s) but then changed your mind or you just want to start over! The content in the text-box will revert back to original start-up values since you last published." +
				"</div>" +
			"</div>" +

			"<div class='fwHelpSect'>" +
				"<a href='javascript:void(0)' onClick='FW.showHelp(this.nextSibling);' class='fwPlusMinus'>+</a><a href='javascript:void(0);' onClick='FW.showHelp(this);' class='dwLink'>Restore</a>" +
				"<div class='fw0'>" +

					"Restore is the ultimate \"safety net\" and more powerful that reset because it let's you go back to an earlier date & time. If you made a mistake, which you only realized after publishing, then try restore." +

					"<div align='center' style='margin:4px 0px 0px 0px;'><form>";
						if( helpType == "HTML" ) {
							var BackUpHTM = document.AspForm.BackUpHTM;

							htm += "<input type='button' value='Restore To:' onClick='return FW.restore( \"RestoreHTM\" );' title='Restore this file to a prior selected time' />&nbsp;&nbsp;";

							htm += "<select id='BackUpHTM_PopUp' title='Select a prior restore point'>";
							for( var i = 0; i < BackUpHTM.length; i++ )
								htm += "<option " + ( ( i == 1 ) ? "selected=\"selected\"" : "" ) + "value='" + BackUpHTM[ i ].value + "'>" + ( ( i > 0 ) ? ( i + ". " ) : "" ) + BackUpHTM[ i ].text + "</option>";
							htm += "</select>";
						}
						else if( helpType == "JavaScript" ) {
							var BackUpJS = document.AspForm.BackUpJS;

							htm += "<input type='button' value='Restore To:' onClick='return FW.restore( \"RestoreJS\" );' title='Restore this file to a prior selected time' />&nbsp;&nbsp;";

							htm += "<select id='BackUpJS_PopUp' title='Select a prior restore point'>";
							for( var i = 0; i < BackUpJS.length; i++ )
								htm += "<option " + ( ( i == 1 ) ? "selected=\"selected\"" : "" ) + "value='" + BackUpJS[ i ].value + "'>" + ( ( i > 0 ) ? ( i + ". " ) : "" ) + BackUpJS[ i ].text + "</option>";
							htm += "</select>";
						}
						else {
							var BackUpXML = document.AspForm.BackUpXML;

							htm += "<input type='button' value='Restore To:' onClick='return FW.restore( \"RestoreXML\" );' title='Restore this file to a prior selected time' />&nbsp;&nbsp;";

							htm += "<select id='BackUpXML_PopUp' title='Select a prior restore point'>";
							for( var i = 0; i < BackUpXML.length; i++ )
								htm += "<option " + ( ( i == 1 ) ? "selected=\"selected\"" : "" ) + "value='" + BackUpXML[ i ].value + "'>" + ( ( i > 0 ) ? ( i + ". " ) : "" ) + BackUpXML[ i ].text + "</option>";
							htm += "</select>";
						}
					htm += "</form></div>" +

					"<ol style='margin-top:4px; margin-bottom:4px;'>" +

						"<li style='margin-left:-10px;'>Select a restore date. They will be listed & numbered with the most recent at the top.</li>" +

						"<li style='margin-left:-10px;'>If you don't know which date to select, try the immediate prior backup. It will be #1 and selected for you by default. \"Restore To\" the selected date & time. If that doesn't help try #2, #3 and so on...</li>" +

						"<li style='margin-left:-10px;'>After restoring, if it appears the problem is not resolved, first press reload before doing another restore.</li>" +

						"<li style='margin-left:-10px;'>The restore process itself is completely reversible and you can go back in time, then come forward again. After performing restore(s), you can even come right back to where you began by restoring to the current working file. It's the only unnumbered choice located at the very top of the list.</li>" +

					"</ol>" +
				"</div>" +
			"</div>" +

			"<div class='fwHelpSect'>" +
				"<a href='javascript:void(0)' onClick='FW.showHelp(this.nextSibling);' class='fwPlusMinus'>+</a><a href='javascript:void(0);' onClick='FW.showHelp(this);' class='dwLink'>About " + helpType + "</a>" +
				"<div class='fw0'>";

					if( helpType == "HTML" )
						htm += "<ol style='margin-top:4px; margin-bottom:4px;'><li style='margin-left:-10px;'>HTML (<b>H</b>yper <b>T</b>ext <b>M</b>arkup <b>L</b>anguage) is a web formating language: <a href='javascript:PopUp.openWin( \"http://en.wikipedia.org/wiki/Html\" );' class='dwLink'>Learn more</a></li><li style='margin-left:-10px;'>Need help with your HTML skills? Try <a href='javascript:PopUp.openWin( \"http://www.w3schools.com/html/html_primary.asp\" );' class='dwLink'>W3schools.com</a></li></ol>";

					else if( helpType == "JavaScript" )
						htm += "JavaScript is a popular web programming language: <a href='javascript:PopUp.openWin( \"http://en.wikipedia.org/wiki/JavaScript\" );' class='dwLink'>Learn more</a>";

					else
						htm += "XML (e<b>X</b>tensible <b>M</b>arkup <b>L</b>anguage) is a web data-base language: <a href='javascript:PopUp.openWin( \"http://en.wikipedia.org/wiki/Xml\" );' class='dwLink'>Learn more</a>";

				htm +=
				"</div>" +
			"</div>";

			return htm;
		}

		var DataSrc;

		switch( nType ) {

			case 1:
				DataSrc = [ "Publishing HTML", getHelpTxt( "HTML" ) ];
				break;

			case 2:
				DataSrc = [ "Publishing JavaScript", getHelpTxt( "JavaScript" ) ];
				break;

			case 3:
				DataSrc = [ "Publishing XML", getHelpTxt( "XML" ) ] ;
				break;

		}

		if( window.DW ) DW.createWindow( DataSrc, [1,600,300], Link, evt, 6, [2,0,-15] );
	}

	//------------------------------------- Method FW -------------------------------------

	function restore( aspJob ) {

		var Form = document.AspForm;

		if(
				aspJob == "RestoreHTM" && Form.BackUpHTM && Form.BackUpHTM[ Form.BackUpHTM.selectedIndex ].value == "" ||
				aspJob == "RestoreJS" && Form.BackUpJS && Form.BackUpJS[ Form.BackUpJS.selectedIndex ].value == "" ||
				aspJob == "RestoreXML" && Form.BackUpXML && Form.BackUpXML[ Form.BackUpXML.selectedIndex ].value == ""
			) {
			alert( "No action taken: There are no restore dates..." );
			return false;
		}

		switch( aspJob ) {
			case "RestoreHTM": Form.BackUpHTM.selectedIndex = document.getElementById( "BackUpHTM_PopUp" ).selectedIndex; break;
			case "RestoreJS": Form.BackUpJS.selectedIndex = document.getElementById( "BackUpJS_PopUp" ).selectedIndex; break;
			case "RestoreXML": Form.BackUpXML.selectedIndex = document.getElementById( "BackUpXML_PopUp" ).selectedIndex; break;
			default: alert( "Switch/Case Error at FW.restore" );
		}

		Form.ASP_Job.value = aspJob;
		Form.submit();
	}
	//------------------------------------- Method FW -------------------------------------


	function insertTags( tagOpen, tagClose, TextBoxID ) {

		var editHTML = ( TextBoxID == "EditedHTML" );
		var editDATA = !editHTML;

		if( this.cursorReadyHtm && editHTML || this.cursorReadyJS && editDATA ) {

			var TextArea = document.getElementById( TextBoxID );

			if( IE ) {
				var theSelection = document.selection.createRange().text;
				TextArea.focus();
				if( theSelection.charAt(theSelection.length - 1) == " " ) { // exclude ending space char, if any
					theSelection = theSelection.substring(0, theSelection.length - 1);
					document.selection.createRange().text = tagOpen + theSelection + tagClose + " ";
				}
				else
					document.selection.createRange().text = tagOpen + theSelection + tagClose;

			}

			else {
				var replaced = false;
				var startPos = TextArea.selectionStart;
				var endPos = TextArea.selectionEnd;
				if( endPos - startPos )
					replaced = true;

				var scrollTop = TextArea.scrollTop;

				var myText = (TextArea.value).substring(startPos, endPos );

				if( myText.charAt(myText.length - 1 ) == " " ) // exclude ending space char, if any
					subst = tagOpen + myText.substring(0, ( myText.length - 1 ) ) + tagClose + " ";
				else
					subst = tagOpen + myText + tagClose;

				TextArea.value = TextArea.value.substring(0, startPos ) + subst +
					TextArea.value.substring(endPos, TextArea.value.length );
				TextArea.focus();

				if( replaced ) {
					var cPos = startPos+( tagOpen.length + myText.length + tagClose.length );
					TextArea.selectionStart = cPos;
					TextArea.selectionEnd = cPos;
				}
				else {
					TextArea.selectionStart = startPos + tagOpen.length;
					TextArea.selectionEnd = startPos + tagOpen.length + myText.length;
				}
				TextArea.scrollTop = scrollTop;

			}
			// reposition cursor if possible
			if( TextArea.createTextRange )
			TextArea.caretPos = document.selection.createRange().duplicate();
		}
		else {
			if( !tagClose )
				alert( "To auto-insert you must place your cursor at the location where you are inserting into." );
			else
				alert( "To auto-insert you must first highlight the text you would like formatted." );
		}

	}
	//------------------------------------- Method FW -------------------------------------

	function init() {

		var help = "About Caching, Reload, Publish, Reset & Restore";
		var justPub = "Refresh page to override cached (old) version";
		try	{

			var EditContainerHTM = document.getElementById( "EditContainerHTM" );

			// Init HTML Section
			if( EditContainerHTM && EditContainerHTM.className == "on" ) {

				// Title, Notes & Buttons can each be overloaded on a per-page basis (if needed)
				var HtmTitle = document.getElementById( "HtmTitle" );
				if( HtmTitle.innerHTML == "" ) HtmTitle.innerHTML = "HTML CONTENT FOR THIS PAGE";

				var HtmNotes = document.getElementById( "HtmNotes" );
				if( HtmNotes.innerHTML == "" ) HtmNotes.innerHTML = this.HtmNotes;

				var HtmButtons = document.getElementById( "HtmButtons" );
				if( HtmButtons.innerHTML == "" ) HtmButtons.innerHTML = this.HtmButtons;

				var EditedHTML = document.getElementById( "EditedHTML" );
				EditedHTML.onfocus = function() {
					this.title = "Edit text then press \"Publish HTML\"";
					self.status = this.title;
					FW.cursorReadyHtm = true;
				}
				EditedHTML.onblur = function() { self.status=""; }

				var HelpHTM = document.getElementById( "HelpHTM" );
				HelpHTM.onmouseover = function() { this.title = help; }

				var ReloadHTM = document.getElementById( "ReloadHTM" );
				ReloadHTM.onmouseover = function() { this.title = justPub; }
				ReloadHTM.onclick = function() { FW.reLoad( "EditedHTML" ); }

				var PublishHTM = document.getElementById( "PublishHTM" );
				PublishHTM.onmouseover = function() { this.title = "Write HTML to file"; }
				PublishHTM.onclick = function() { return FW.checkContent( 1, 1 ); }
				PublishHTM.oncontextmenu = function() { return FW.checkContent( 1, 0 ); }

				var ResetHTM = document.getElementById( "ResetHTM" );
				ResetHTM.onmouseover = function() { this.title = "Revert HTML back to original values since you last published"; }
				ResetHTM.onclick = function() { FW.resetUI( "EditedHTML" ); }
			}

			// Init JS Section
			var EditContainerJS = document.getElementById( "EditContainerJS" );
			if( EditContainerJS && EditContainerJS.className == "on" ) {

				// Title, Notes & Buttons can each be overloaded on a per-page basis (if needed)
				var JsTitle = document.getElementById( "JsTitle" );
				if( JsTitle.innerHTML == "" ) JsTitle.innerHTML = "JAVASCRIPT DATA";

				var JsNotes = document.getElementById( "JsNotes" );
				if( JsNotes.innerHTML == "" ) JsNotes.innerHTML = this.JsNotes;

				var JsButtons = document.getElementById( "JsButtons" );
				if( JsButtons.innerHTML == "" ) JsButtons.innerHTML = this.JsButtons;

				var EditedJS = document.getElementById( "EditedJS" );
				EditedJS.onfocus = function() {
					this.title = "Edit data then press \"Publish JavaScript\"";
					self.status = this.title;
					FW.cursorReadyJS = true;
				}
				EditedJS.onblur = function() { self.status=""; }

				var HelpJS = document.getElementById( "HelpJS" );
				HelpJS.onmouseover = function() { this.title = help; }

				var ReloadJS = document.getElementById( "ReloadJS" );
				ReloadJS.onmouseover = function() { this.title = justPub; }
				ReloadJS.onclick = function() { FW.reLoad( "EditedJS" ); }

				var PublishJS = document.getElementById( "PublishJS" );
				PublishJS.onmouseover = function() { this.title = "Write JavaScript to file"; }
				PublishJS.onclick = function() { return FW.checkContent( 2, 1 ); }
				PublishJS.oncontextmenu = function() { return FW.checkContent( 2, 0 ); }

				var ResetJS = document.getElementById( "ResetJS" );
				ResetJS.onmouseover = function() { this.title = "Revert JavaScript back to original values since you last published"; }
				ResetJS.onclick = function() { FW.resetUI( "EditedJS" ); }
			}

			// Init XML Section
			var EditContainerXML = document.getElementById( "EditContainerXML" );
			if( EditContainerXML && EditContainerXML.className == "on" ) {

				// Title, Notes & Buttons can each be overloaded on a per-page basis (if needed)
				var XmlTitle = document.getElementById( "XmlTitle" );
				if( XmlTitle.innerHTML == "" ) XmlTitle.innerHTML = "GLOBAL XML DATA";

				var XmlNotes = document.getElementById( "XmlNotes" );
				if( XmlNotes.innerHTML == "" ) XmlNotes.innerHTML = this.XmlNotes;

				var EditedXML = document.getElementById( "EditedXML" );
				EditedXML.onfocus = function() {
					this.title = "Edit data then press \"Publish XML\"";
					self.status = this.title;
				}
				EditedXML.onblur = function() { self.status=""; }

				var HelpXML = document.getElementById( "HelpXML" );
				HelpXML.onmouseover = function() { this.title = help; }

				var ReloadXML = document.getElementById( "ReloadXML" );
				ReloadXML.onmouseover = function() { this.title = justPub; }
				ReloadXML.onclick = function() { FW.reLoad( "EditedXML" ); }

				var PublishXML = document.getElementById( "PublishXML" );
				PublishXML.onmouseover = function() { this.title = "Write XML to file"; }
				PublishXML.onclick = function() { return FW.checkContent( 3, 1 ); }
				PublishXML.oncontextmenu = function() { return FW.checkContent( 3, 0 ); }

				var ResetXML = document.getElementById( "ResetXML" );
				ResetXML.onmouseover = function() { this.title = "Revert XML back to original values since you last published"; }
				ResetXML.onclick = function() { FW.resetUI( "EditedXML" ); }
			}

			var htm =
			"<div class='otherFunctions'>" +
				"<a href='javascript:FW.logOff();' title='Log off as administrator' class='fw'>Log Off</a>" +
				"&nbsp;&#149;&nbsp;" +
				"<a href='javascript:PopUp.openWin( \"uploader.aspx\", 650, 350, 2, 0, 0, 0, 0, 0, 0 );' title='Upload files to the server' class='fw'>Upload</a>";
				htm += this.AdminLinks;
			htm +=
			"</div>";

			document.getElementById( "fwBottomRow" ).innerHTML = htm;

			// Scan restore pulldowns and convert server-side time from ticks to user-friendly local times
			var nTicks_Jan_1_1970 = 621355968000000000;
			var offsetMS = this.getServerTimeZoneOffset() * 60 * 60 * 1000;

			var BackUpHTM = document.getElementById( "BackUpHTM" );
			if( BackUpHTM && BackUpHTM[ 0 ].value ) {
				for( var i = 0; i < BackUpHTM.length; i++ ) {
					var Option = BackUpHTM[ i ];
					var ms = ( parseInt( Option.text ) - nTicks_Jan_1_1970 ) / 10000;
					Option.text = new Date( ms + offsetMS ).toLocaleString();
				}
			}

			var BackUpJS = document.getElementById( "BackUpJS" );
			if( BackUpJS && BackUpJS[ 0 ].value ) {
				for( var i = 0; i < BackUpJS.length; i++ ) {
					var Option = BackUpJS[ i ];
					var ms = ( parseInt( Option.text ) - nTicks_Jan_1_1970 ) / 10000;
					Option.text = new Date( ms + offsetMS ).toLocaleString();
				}
			}

			var BackUpXML = document.getElementById( "BackUpXML" );
			if( BackUpXML && BackUpXML[ 0 ].value ) {
				for( var i = 0; i < BackUpXML.length; i++ ) {
					var Option = BackUpXML[ i ];
					var ms = ( parseInt( Option.text ) - nTicks_Jan_1_1970 ) / 10000;
					Option.text = new Date( ms + offsetMS ).toLocaleString();
				}
			}

			self.status = "";

		}
		catch( Err ) {
			if( local ) {
				var err = "";
				for( member in Err ) err += member + ": " + Err[ member ] + "\n";
				alert( "Exception at method FW.init:\n\n" + err );
			}
			else {
				setTimeout( "FW.init();", 250 );
				self.status = "Initializing File Writer: FW.init()...";
			}
		}
	}
	//------------------------------------- Method FW -------------------------------------

	function checkContent( formType, leftClick ) {


		function subDisableTextBoxes( htm, js, xml ) {

			if( htm && document.getElementById( "EditedHTML" ) )
				document.getElementById( "EditedHTML" ).disabled = true;

			if( js && document.getElementById( "EditedJS" ) )
				document.getElementById( "EditedJS" ).disabled = true;

			if( xml && document.getElementById( "EditedXML" ) )
				document.getElementById( "EditedXML" ).disabled = true;
		}

		var Form = document.AspForm;

		var EditedHTML = Form.EditedHTML;
		var EditedJS = Form.EditedJS;
		var EditedXML = Form.EditedXML;

		// HTML
		if( formType == 1 ) {

			if( leftClick && EditedHTML.value == EditedHTML.defaultValue ) {
				alert( "Edit the text then press Publish HTML..." );
				EditedHTML.focus();
				FW.cursorReadyHtm = false;
				return false;
			}
			else {
				EditedHTML.value = EditedHTML.value.trim();
				document.getElementById( "PublishHTM" ).disabled = true;
				Form.Which_Button.value = ( leftClick ) ? "html" : "htmlRightClick";
				subDisableTextBoxes( 0, 1, 1 );
			}
		}

		// JS
		else if( formType == 2 ) {


			if( leftClick && EditedJS.value == EditedJS.defaultValue ) {
				alert( "Edit the data then press Publish JavaScript..." );
				EditedJS.focus();
				FW.cursorReadyJS = false;
				return false;
			}
			else {
				try {
					eval( EditedJS.value );
				}
				catch( Err ) {
					var err = "";
					for( member in Err ) err += member + ": " + Err[ member ] + "\n";
					alert( "Sorry, you have mistakenly broken JavaScript's rigid syntax. As a result, the file cannot be saved to disk. Fix the error & try again or click \"Reset\"...\n\n" + err );
				return false;
				}
				EditedJS.value = EditedJS.value.trim();
				document.getElementById( "PublishJS" ).disabled = true;
				Form.Which_Button.value = ( leftClick ) ? "js" : "jsRightClick";
				subDisableTextBoxes( 1, 0, 1 );
			}
		}

		// XML
		else {


			if( leftClick ) {
				if( EditedXML.value == EditedXML.defaultValue ) {
					alert( "Edit the text then press Publish XML..." );
					EditedXML.focus();
					return false;
				}
				else {

					var textOrig = EditedXML.defaultValue;
					var textNew = EditedXML.value.trim();

					var xmlOrig = textOrig.replace( />[^<>]*</g, "><" );
					var nLinesOrig = textOrig.split( "\n" ).length;

					var xmlNew = textNew.replace( />[^<>]*</g, "><" );
					var nLinesNew = textNew.split( "\n" ).length;

					if( xmlOrig == xmlNew && nLinesOrig == nLinesNew ) {

						var xml = EditedXML.value;

						xml = xml.replace( /&amp;/g, "a_m_p_e_r_s_a_n_d" );
						xml = xml.replace( /\\\"/g, "q_u_o_t_e" );

						xml = xml.replace( /&/g, "&amp;" );
						xml = xml.replace( /\"/g, "\\\"" );

						xml = xml.replace( /q_u_o_t_e/g, "\\\"" );
						xml = xml.replace( /a_m_p_e_r_s_a_n_d/g, "&amp;" );

						EditedXML.value = xml;

						document.getElementById( "PublishXML" ).disabled = true;
						Form.Which_Button.value = "xml";
						subDisableTextBoxes( 1, 1, 0 );
					}
					else {
						var err = ", as a result, the file cannot be saved to disk. Please edit the data only then press Publish XML.\n\n==> Fix the error & try again or click \"Reset\"";

						if( nLinesOrig != nLinesNew )
							alert( "ERROR: You have added or removed lines" + err );
						else
							alert( "ERROR: You have edited XML tag(s)" + err );
						EditedXML.focus();
						return false;
					}
				}
			}
			else { // rightClick
				document.getElementById( "PublishXML" ).disabled = true;
				Form.Which_Button.value = "xmlRightClick";
				subDisableTextBoxes( 1, 1, 0 );
			}
			EditedXML.value = EditedXML.value.trim();
		}

		Form.ASP_Job.value = "File_Writer";
		Form.submit();
		return ( leftClick ) ? true : false;
	}
	//------------------------------------- Method FW -------------------------------------

	function resetUI( TextBox ) {
		if( TextBox == "EditedHTML" ) this.cursorReadyHtm = false;
		else if( TextBox == "EditedJS" ) this.cursorReadyJS = false;
		eval( "document.AspForm." + TextBox + ".value = document.AspForm." + TextBox + ".defaultValue;" );
	}
	//------------------------------------- Method FW -------------------------------------

	function reLoad( TextBox ) {

		if( eval( "document.AspForm." + TextBox + ".value" ) == eval( "document.AspForm." + TextBox + ".defaultValue" ) )
			document.location.reload( true );
		else if( confirm ( "You have made edits that you have not published. Click OK to reload the page & clear all non-published edits." ) )
			document.location.reload( true );

	}
	//------------------------------------- Method FW -------------------------------------

	function logOff() {
		var qStrOut = ( qStr ) ? qStr + "&logoff=yes" : "logoff=yes";
		document.location.replace( fileName + "?" + qStrOut );
	}

	//------------------------------ Method FW ------------------------------
	// This method takes user name/pw from log-in popup GUI and sends it to server (in query string)

	function logIn() {

		var Form = document.LogIn;

		if( Form.Privileges[ 1 ].checked ) {
			var formUser = Form.user.value;
			for( var user in DB.Administrators ) {
				if( user == formUser.replace( /_/g, " " ) ) { Form.pw.value = rapw; break; }
			}
		}

		var userNameFW = Form.user.value;

		if( userNameFW == "" ) {
			alert( "Please enter your user name" );
			Form.user.focus();
			return false;
		}

		else if( Form.pw.value == "" ) {
			alert( "Please enter your password" );
			Form.pw.focus();
			return false;
		}

		if( userNameFW )
			SetCookie( "userNameFW", userNameFW, expDate12Mon );

		// If we got an existing qStr maintain it but remove log-in related name/val pairs if any
		var qStrExisting = qStr;
		if( qStrExisting ) {

			var user = qStr.getVal( "user" );
			if( user != null )
				qStrExisting = qStrExisting.split( "user=" + user ).join( "" );

			var pw = qStr.getVal( "pw" );
			if( pw != null )
				qStrExisting = qStrExisting.split( "pw=" + pw ).join( "" );

			var ms = qStr.getVal( "ms" );
			if( ms != null )
				qStrExisting = qStrExisting.split( "ms=" + ms ).join( "" );

			var logoff = qStr.getVal( "logoff" );
			if( logoff != null )
				qStrExisting = qStrExisting.split( "logoff=" + logoff ).join( "" );

			qStrExisting += "&";
			qStrExisting = qStrExisting.replace( /\&{2,}/g, "&" );
		}

		var user = ( Form.Privileges[ 0 ].checked ) ? "user=" + Form.user.value + "" : "user=";

		var url = fileName + "?" + qStrExisting + user + "&pw=" + Form.pw.value + "&ms=" + new Date().getTime();

		document.location.replace( url );

	}

	//------------------------------ Method FW ------------------------------
	// This method launches Log-In pop-up GUI

	function getLogInGUI( evt ) {

		var userNameFW = ( GetCookie( "userNameFW" ) ) ? GetCookie( "userNameFW" ) : "";

		var gui =

		"<form name='LogIn' style='margin:0px;'>" +
			"<table align='center' border='0' cellspacing='0' cellpadding='0'>" +
				"<tr>" +
					"<td>" +
						"<table align='center' border='0' cellspacing='0' cellpadding='0'>" +

							// Privileges
							"<tr class='" + ( ( fileName == "calendar.aspx" ) ? "on" : "off" ) + "'>" +
								"<td class='fwField' style='padding-top:6px;'>" +
									"Privileges" +
								"</td>" +
								"<td class='fwValue' style='padding-top:6px;' id='tdBookingID'>" +
									// Values Write & Read read internally by code.cs so never change them
									"<input type='radio' name='Privileges' value='Write' title='Allows you to add/edit bookings' checked /> Read & Write;&nbsp;&nbsp;&nbsp;" +
									"<input type='radio' name='Privileges' value='Read' title='Allows you to read-all booking info but not add or edit them' /> Read Only;" +
								"</td>" +
							"</tr>" +

							// User Name
							"<tr>" +
								"<td class='fwField' style='padding-top:6px;'>" +
									"User Name" +
								"</td>" +
								"<td class='fwValue' style='padding-top:6px;' id='tdBookingID'>" +
									"<input type='text' name='user' class='fwText' title='Enter your user-name' value='" + userNameFW + "' onkeypress='if( window.event && window.event.keyCode == 13 || event.which == 13 ) { FW.logIn(); return false; }' />" +
								"</td>" +
							"</tr>" +

							// Password
							"<tr>" +
								"<td class='fwField' style='padding-top:6px;'>" +
									"Password" +
								"</td>" +
								"<td class='fwValue' style='padding-top:6px;' id='tdBookingID'>" +
									"<input type='password' name='pw' autocomplete='off' class='fwText' onMouseover='this.title=( document.LogIn.Privileges[0].checked ) ? \"Enter your password\" : \"Enter read-all password, User Name not required\";' onkeypress='if( window.event && window.event.keyCode == 13 || event.which == 13 ) { FW.logIn(); return false; }' />" +
								"</td>" +
							"</tr>" +

							// OK/Cancel Buttons
							"<tr>" +
								"<td align='center' colspan='2' style='padding:10px 0px 0px 0px; white-space:nowrap;'>" +
									"<input type='button' value='OK' style='margin:0px 4px 0px 0px;' onClick='return FW.logIn();' />" +
									"<input type='button' value='Cancel' onClick='DW.removeWin();' style='margin:0px 0px 0px 4px;' />" +
								"</td>" +
							"</tr>" +

						"</table>" +
					"</td>" +
				"</tr>" +
			"</table>" +
		"</form>";

		DW.createWindow( [ "Administrator Log-In", gui ], [0,400,0], null, evt, 6 );

		if( userNameFW )
			setTimeout( "document.LogIn.pw.focus();", 100 );
		else
			setTimeout( "document.LogIn.user.focus();", 100 );

	}

}
///////////////////////////////// End Object FileWriter FW /////////////////////////////////


//////////////////////////////////////// START SLIDE SHOW: SS ////////////////////////////////////////

/*
VAR: qStr, local, winIE, MZ, SF
FUN: Image Library Functions
OBJ: DW
CLS: .ss*
*/

//--------------------------------- OBJECT CONSTRUCTOR ---------------------------------

function SlideShow( popUp ) {

	initImagesArr();

	if( popUp ) {
		if( !AOL ) {
			window.moveTo( 0, 0 );
			window.resizeTo( screen.availWidth, screen.availHeight );
		}
	}

	this.userIsAdministrator = GetCookie( "userWithWritePrivileges" );
	this.popUp = popUp;
	this.slideNum = ( Settings.SS.randomStart && !this.userIsAdministrator ) ? Math.floor( Math.random() * Images.length ) : 0;
	this.nFirstSlide = this.slideNum;
	this.speedActual = Settings.SS.speed;
	this.automated = ( this.speedActual < 86400000 ); // 86400000 ms = 1 day
	this.SPEED_FAST = 500;
	this.preLoadTimer = 0;
	this.NextImage = null;
	this.slideDelay = 0;
	this.running = true;
	this.forward = true;
	this.buttons = false;
	this.dissolve = true;
	this.maxDissolveMZ = 800 * 800;
	this.maxImgWid = this.maxImgWid;
	this.maxImgHgt = this.maxImgHgt;
	this.longestCaption = "";

	// Methods...
	this.init = init;
	this.start = start;
	this.showSlide = showSlide;
	this.skipErrantSlide = skipErrantSlide;
	this.preLoadNext = preLoadNext;
	this.imgClickHandler = imgClickHandler;
	this.back = back;
	this.stop = stop;
	this.reStart = reStart;
	this.next = next;
	this.showMsg = showMsg;
	this.getCoordinates = getCoordinates;
	this.moveImgOverlay = moveImgOverlay;
	this.pauseSS = pauseSS;
	this.getControls = getControls;
	this.getGUI = getGUI;
	window.onresize = this.moveImgOverlay;
	this.rightClick = rightClick;
	this.changeSpeed = changeSpeed;

	this.msg = new Array();
	this.msg.ssRunning = "Slide Show Running...";
	this.msg.downloadingImg = "Preparing next slide...";
	this.msg.pleaseWait = "Downloading image, please wait...";
	this.msg.ssPaused = "Slide Show Paused, re-click \"Pause\" to continue...";
	this.msg.ssPausedSF = "Slide Show Paused, click \"Run\" to continue...";
	this.msg.next = "Jump forward";
	this.msg.back = "Go back";
	this.msg.ssExit = "Close this slide-show window";

	//------------------------------------ METHOD: SS ------------------------------------
	// Called on page load

	function start() {

		if( Settings.SS.console ) {
			var Console = document.getElementById( "ssConsole" );
			Console.style.height = Console.offsetHeight + "px";
		}

		this.showMsg();

		if( Settings.SS.console )
			Console.style.visibility = "visible";
		this.preLoadNext();
	}

	//------------------------------------ METHOD: SS ------------------------------------

	function getCoordinates( TheImage ) {

		// Get on screen position of overlay so we can lay new one on top
		var x = 0; var y = 0;
		TheElement = TheImage;
		var parPosAbs = false;
		while( TheElement ) {
			if( SF ) {
				if( !parPosAbs ) parPosAbs = ( TheElement.style.position == "absolute" );
				if( parPosAbs && TheElement == document.body ) break;
			}
			y += TheElement.offsetTop;
			x += TheElement.offsetLeft;
			TheElement = TheElement.offsetParent;
		}
		return[ x, y ];

	}
	//------------------------------------ METHOD: SS ------------------------------------

	function moveImgOverlay() {
		if( SS.ImgOverlay ) {
			var OverlayPos = SS.getCoordinates( document.images.slideShow.parentNode );
			SS.ImgOverlay.style.left = OverlayPos[ 0 ] + "px";
			SS.ImgOverlay.style.top = OverlayPos[ 1 ] + "px";
		}
	}

	//------------------------------------ METHOD: SS ------------------------------------
	function showSlide() {

		if( this.NextImage ) {

			this.showMsg();
			var TheImage = document.images.slideShow;
			var widNew = Images[ this.slideNum ][ 1 ];
			var hgtNew = Images[ this.slideNum ][ 2 ];
			var imgArea = widNew * hgtNew;

			checkDim( this.NextImage.src, widNew, hgtNew );

			////////// Dissolve: winIE, Mozilla & Safari //////////
			if( this.forward && this.dissolve && ( winIE || ( MZ && imgArea <= this.maxDissolveMZ ) || ( SF && Settings.dissolveSF ) ) && Settings.transNum >= 1 && this.speedActual > this.SPEED_FAST ) {

				var nNewImg = ( Images.length == this.slideNum ) ? 0 : this.slideNum;
				var nOldImg = ( nNewImg == 0 ) ? Images.length - 1 : nNewImg - 1;

				// Place image that was just showing on bottom
				TheImage.width = Images[ nOldImg ][ 1 ];
				TheImage.height = Images[ nOldImg ][ 2 ];
				TheImage.src = Settings.folder + Images[ nOldImg ][ 0 ];

				if( Settings.borderWid && Images[ nOldImg ][ 4 ] ) TheImage.style.borderColor = "rgb( " + getRGB( Images[ nOldImg ][ 4 ] ) + " )";

				var imgStyle = ( Settings.borderWid && Images[ nNewImg ][ 4 ] ) ? " style='border:" + Settings.borderWid + "px solid rgb(" + getRGB( Images[ nNewImg ][ 4 ] ) + ");'" : "";

				var newImg = "<img name='slideShowNew' src='" + Settings.folder + Images[ nNewImg ][ 0 ] + "' width='" + Images[ nNewImg ][ 1 ] + "' height='" + Images[ nNewImg ][ 2 ] + "' title='" + TheImage.title + "'" + imgStyle + " onmousedown='SS.imgClickHandler( event );' onContextMenu='return SS.rightClick( this, event );' class='ssImage'>";

				// Create overlay off-screen
				if( !SS.ImgOverlay ) {
					SS.ImgOverlay = document.createElement( "DIV" );
					SS.ImgOverlay.style.textAlign = "center";
					SS.ImgOverlay.style.top = ( screen.height * -1 ) + "px";
					SS.ImgOverlay.style.left = ( screen.width * -1 ) + "px";
					SS.ImgOverlay.style.zIndex = 1000;
					SS.ImgOverlay.style.position = "absolute";
					SS.ImgOverlay.style.backgroundColor = "rgb( " + Settings.SS.bkgColor + " )";
					document.body.appendChild( SS.ImgOverlay );
				}

				// Re-size overlay
				SS.ImgOverlay.style.width = this.maxImgWid + "px";
				SS.ImgOverlay.style.height = this.maxImgHgt + "px";

				// Make overlay transparent
				if( winIE ) SS.ImgOverlay.style.visibility = "hidden";
				if( MZ ) SS.ImgOverlay.style.opacity = 0;
				else SS.ImgOverlay.style.opacity = 0;

				// Move transparent overlay into position
				var OverlayPos = SS.getCoordinates( TheImage.parentNode );
				SS.ImgOverlay.style.left = OverlayPos[ 0 ] + "px";
				SS.ImgOverlay.style.top = OverlayPos[ 1 ] + "px";

				// Fade-in overlay
				SS.ImgOverlay.innerHTML = newImg;
				if( winIE ) startFade( SS.ImgOverlay, Settings.transNum, Settings.transDur, 0, 0, 0 );
				else fadeIn( SS.ImgOverlay );
			}

			else { // No transitions: going backwards
				if( this.ImgOverlay ) {
					document.body.removeChild( this.ImgOverlay );
					this.ImgOverlay = null;
				}
				TheImage.style.visibility = "hidden";
				TheImage.width = widNew;
				TheImage.height = hgtNew;
				if( Settings.borderWid && Images[ this.slideNum ][ 4 ] )
					TheImage.style.borderColor = "rgb( " + getRGB( Images[ this.slideNum ][ 4 ] ) + " )";
				TheImage.src = this.NextImage.src;
				TheImage.style.visibility = "visible";
			}

			this.dissolve = true;
			this.forward = true;

		}

	}
	//------------------------------------ METHOD: SS ------------------------------------
	function showMsg() {

		if( Settings.SS.statusBar || Settings.SS.console ) {
			var imgTitle = ( Images[ this.slideNum ][ 3 ] ) ? Images[ this.slideNum ][ 3 ].replace( /\^/g, "\"" ) : "";
			var colon = ( imgTitle ) ? ": " : "";
			var slideNumDisplay = this.slideNum - this.nFirstSlide + 1;
			if( slideNumDisplay < 1 ) slideNumDisplay = Images.length + slideNumDisplay;
			var slideCount = slideNumDisplay + " of " + Images.length

			if( imgTitle == "*" )
				imgTitle = Settings.pageTitle;
			else if( imgTitle.indexOf( "*+" ) == 0 )
				imgTitle = Settings.pageTitle + imgTitle.split( "+" )[ 1 ];
			else if( imgTitle.indexOf( "+*" ) >= 0 )
				imgTitle = imgTitle.split( "+" )[ 0 ] + Settings.pageTitle;

			if( Settings.SS.statusBar )
				self.status = "Slide " + slideCount + colon + imgTitle;
			if( Settings.SS.console ) {
				if( document.getElementById( "ssConsoleAlt" ) ) {
					document.getElementById( "ssConsoleAlt" ).innerHTML = slideCount;
					document.getElementById( "ssConsole" ).innerHTML = imgTitle;
				}
				else
					document.getElementById( "ssConsole" ).innerHTML = slideCount + colon + imgTitle;
			}

		}
	}
	//------------------------------------ METHOD: SS ------------------------------------
	function skipErrantSlide() {
		if( local || SS.speedActual == SS.SPEED_FAST ) {
			if( !SS.errReported ) {
				alert( "Slide #" + ( SS.slideNum + 1 ) + "; " + SS.NextImage.src + " failed to load" );
				SS.errReported = true;
			}
		}
		SS.NextImage = null;
	}

	//------------------------------------ METHOD: SS ------------------------------------

	function preLoadNext() {

		if( !Settings.SS.statusBar && this.automated ) self.status = this.msg.ssRunning;

		var recursionTimer = 100;

		this.slideDelay += recursionTimer;

		if( !this.NextImage ) {

			this.slideNum++;
			if( this.slideNum == Images.length ) this.slideNum = 0;
			this.NextImage = new Image();
			this.NextImage.onerror = this.skipErrantSlide;
			this.NextImage.src = Settings.folder + Images[ this.slideNum ][ 0 ];
		}

		if( this.NextImage && this.NextImage.complete && this.slideDelay> this.speedActual ) {
			this.slideDelay = 0;
			this.showSlide();
			this.NextImage = null;
			clearTimeout( this.preLoadTimer );
			this.preLoadNext();
			if( Settings.SS.controls && document.getElementById( "backBut" ) )
				document.getElementById( "backBut" ).disabled = false;
			if( Settings.SS.scrollSlide )
				window.scroll( Settings.SS.scrollSlide[ 0 ], Settings.SS.scrollSlide[ 1 ] );
		}
		else
			this.preLoadTimer = setTimeout( "SS.preLoadNext()", recursionTimer );

	}
	//------------------------------------ METHOD: SS ------------------------------------
	function imgClickHandler( e ) {

		if( !e ) e = window.event;

		if( e.ctrlKey || e.metaKey ) {
			if( this.speedActual == Settings.SS.speed )
				this.speedActual = this.SPEED_FAST;
			else
				this.speedActual = Settings.SS.speed;
		}
		if( e.shiftKey ) {
			if( this.running )
				this.pauseSS( true );
			else
				this.pauseSS( false );
		}
	}
	//------------------------------------ METHOD: SS ------------------------------------

	function back()  {
		if( Settings.SS.console ) document.getElementById( "ssConsole" ).innerHTML = this.msg.pleaseWait;
		if( Settings.SS.statusBar ) self.status = this.msg.pleaseWait;
		clearTimeout( this.preLoadTimer );
		this.forward = false;
		this.slideNum -= 3;
		if( this.slideNum == -2 ) this.slideNum = Images.length - 2;
		if( this.slideNum == -3 ) this.slideNum = Images.length - 3;
		this.NextImage = null;
		this.pauseSS( false );
	}

	function stop()  { clearTimeout( this.preLoadTimer ); }
	function reStart() { this.slideDelay = Settings.SS.speed + 1; this.preLoadNext(); }
	function next()  {
		if( Settings.SS.console ) document.getElementById( "ssConsole" ).innerHTML = this.msg.pleaseWait;
		if( Settings.SS.statusBar ) self.status = this.msg.pleaseWait;
		clearTimeout( this.preLoadTimer );
		this.dissolve = Settings.SS.dissolveOnJump;
		this.forward = true;
		this.pauseSS( false );
	}
	//--------------------------------------------------------------------------------------

	function pauseSS( pause ) {

		var Button = ( this.buttons ) ? document.getElementById( "pauseButton" ) : null;
		if( pause ) {
			if( SF ) {
				if( Button ) Button.value = "Run";
				self.status = this.msg.ssPausedSF;
			}
			else {
				if( Button ) Button.className = "ssButtonOn";
				self.status = this.msg.ssPaused;
			}
			this.stop();
			this.running = false;
			if( Button ) Button.title = "Resume";
		}
		else {
			this.reStart();
			if( this.automated ) self.status = this.msg.ssRunning;
			if( Button ) {
				if( SF ) Button.value = "Pause";
				Button.className = "ssButton";
				Button.title = "Pause";
			}
			this.running = true;
		}
		DW.removeWin();
	}

	//------------------------------------ METHOD: SS ------------------------------------

	function changeSpeed( Button ) {

		if( this.speedActual == Settings.SS.speed ) {
			this.speedActual = this.SPEED_FAST;
			if( SF )
				Button.value = "Lo-Speed";
			else
				Button.className = "ssButtonOn";
			Button.title = "Revert to normal speed";
		}

		else {
			SS.speedActual = Settings.SS.speed;
			if( SF )
				Button.value = "Hi-Speed";
			else
				Button.className = "ssButton";
			Button.title = "Run at Hi-Speed";
		}
		this.forward = true;
		this.pauseSS( false );

	}
	//------------------------------------ METHOD: SS ------------------------------------

	function getControls() {

		this.buttons = true;

		htm =

		"<input type='button' id='backBut' class='ssButton' value='&lt;&lt;' onClick='SS.back();' title='" + this.msg.back + "'>&nbsp;" +

		"&nbsp;<input name='pauseButton' class='ssButton' id='pauseButton' type='button' value='Pause' onClick='SS.pauseSS( ( ( SS.running ) ? true : false ) );' title='Pause'" + ( ( SF ) ? " style='width:60px;'" : "" ) +">&nbsp;";

		if( this.userIsAdministrator )
			htm += "&nbsp;<input class='ssButton' type='button' value='Hi-Speed' onClick='SS.changeSpeed( this );' title='Run at Hi-Speed'" + ( ( SF ) ? " style='width:80px;'" : "" ) +">&nbsp;";

		htm +=
			"&nbsp;<input type='button' class='ssButton' value='&gt;&gt;' onClick='SS.next();' title='" + this.msg.next + "'>";

		return htm;
	}

	//------------------------------------ METHOD: SS ------------------------------------
	// Called one time by getGUI just before onLoad.
	// Tip: When setting up a custom SS (no buttons & w/o calling getGUI) mimic html table structure defined in getGUI method

	function init() {

		var maxWid = -1, maxHgt = -1, bordWid = Settings.borderWid * 2;
		for( var i = 0; i < Images.length; i++ ) {
			if( Images[ i ][ 1 ] > maxWid ) maxWid = Images[ i ][ 1 ];
			if( Images[ i ][ 2 ] > maxHgt ) maxHgt = Images[ i ][ 2 ];
		}
		this.maxImgWid = maxWid + bordWid;
		this.maxImgHgt = maxHgt + bordWid;

		var nChars = 0;

		//sets image border-color if undefined & set longest photo caption
		for( var i = 0; i < Images.length; i++ ) {
			if( !Images[ i ][ 4 ] ) Images[ i ][ 4 ] = Settings.borderCol;
			var caption = Images[ i ][ 3 ];
			if( caption && caption.length > nChars ) { this.longestCaption = Images[ i ][ 3 ]; nChars = caption.length; }
			checkImgName( Images[ i ][ 0 ] );
		}
	}

	//------------------------------------ METHOD: SS ------------------------------------

	function rightClick( Photo, evt ) {

		if( this.userIsAdministrator ) {

			this.pauseSS( true );
			var nImages = Images.length;
			var indexNum = ( this.slideNum > 0 ) ? this.slideNum - 1 : nImages - 1;
			var Img = Images[ indexNum ];
			var wid = Img[ 1 ], hgt = Img[ 2 ], tnWid = -1, tnHgt = -1, longestEdge = 150;

			var shape = ( wid > hgt ) ? "horizontal" : ( ( wid < hgt ) ? "vertical" : "square" );

			if( shape == "horizontal" ) {
				tnWid = longestEdge;
				tnHgt = parseInt( hgt * longestEdge / wid );
			}
			else {
				tnWid = parseInt( wid * longestEdge / hgt );
				tnHgt = longestEdge;
			}
			var fileSize = Photo.fileSize;
			if( fileSize ) fileSize = Math.round( fileSize / 1000 ) + " KB";

			var htm = "" +

			"<table align='left' border='0' cellspacing='0' cellpadding='0'>" +
				"<tr>" +
					"<td align=center valign=top>" +
						"<img src='" + Photo.src + "' width='" + tnWid + "' height='" + tnHgt + "'>" +
					"</td>" +
					"<td align=center valign=top style='padding:4px;'>" +
						"<table align='center' border='0' cellspacing='0' cellpadding='0' class='dwText'>" +
							"<tr><td align=right>Name:&nbsp;</td><td align=left>" + Img[ 0 ] + "</td></tr>" +
							"<tr><td align=right>Number:&nbsp;</td><td align=left>" + ( ( this.slideNum > 0 ) ? this.slideNum : nImages ) + " of " + Images.length + "</td></tr>" +
							"<tr><td align=right>Dimensions:&nbsp;</td><td align=left>" + wid + " &times; " + hgt + " px; " + shape + "</td></tr>" +
							( ( fileSize ) ? "<tr><td align=right valign=top>File Size:&nbsp;</td><td align=left>" + fileSize + "</td></tr>" : "" ) +
							( ( typeof Img[ 3 ] == "string" ) ? "<tr><td align=right valign=top> Caption:&nbsp;</td><td align=left>" + Img[ 3 ] + "</td></tr>" : "" ) +
							"<tr><td align=left colspan=2>Slide-Show paused, <a href='javascript:SS.dissolve=false; SS.pauseSS( false );' class='dwLink'>click here</a> to resume</td></tr>" +
						"</table>" +
					"</td>" +
				"</table>";

			DW.createWindow( [ "Image Properties", htm ], [ 0, 500, 0 ], Photo, evt );

			return false;
		}
		else
			return ( Settings.disableRightClick ) ? false : true;

	}

	//------------------------------------ METHOD: SS ------------------------------------

	function getGUI( guiAlign, consoleLoc, buttonsLoc ) {

		this.init();
		var imgStyle = ( Settings.borderWid && Images[ this.slideNum ][ 4 ] ) ? " style='border-color:rgb(" + getRGB( Images[ this.slideNum ][ 4 ] ) + ");'" : "";
		var img1Title = ( Images[ 0 ][ 3 ] ) ? Images[ 0 ][ 3 ].replace( /\^/g, "\"" ) : "";

		var console = "", buttons = "";

		// Initialize with longest title because console height is measured & set permanently using it
		if( Settings.SS.console )
			console =
			"<tr>" +
				"<td align='center'>" +
					// Never let console width exceed largest image width
					"<div class='ssConsole' id='ssConsole' style='visibility:hidden; width:" + this.maxImgWid + "px;'>" + Images.length + " of " + Images.length + ( ( img1Title ) ? ": " : "" ) + this.longestCaption + "</div>" +
				"</td>" +
			"</tr>";

		if( Settings.SS.controls )
			buttons =
			"<tr>" +
				"<td align='center'>" +
					"<div class='ssControls' style='white-space:nowrap;'>" +
						SS.getControls() +
					"</div>" +
				"</td>" +
			"</tr>";

		var htm =

		"<table align='" + guiAlign + "' border='0' cellspacing='0' cellpadding='0' id='ssGUI'>";

		if( Settings.pageTitle )
			htm +=
			"<tr>" +
				"<td align='center'>" +
					"<div class='ssTnTitle'>" +
						Settings.pageTitle +
					"</div>" +
				"</td>" +
			"</tr>";

			if( buttonsLoc == "above" )
				htm += buttons;

			if( consoleLoc == "above" )
				htm += console;

			htm +=
			"<tr>" +
				"<td valign='top' align='center'>" +
					"<table align='center' border='0' cellspacing='0' cellpadding='0'>" +
						"<tr>" +
							"<td valign='top'>" +
								"<table align='center' border='0' cellspacing='0' cellpadding='0'>" +
									"<tr>" +
										"<td align='center' valign='top' style='width:" + this.maxImgWid + "px; height:" + this.maxImgHgt + "px;'>" +
											"<img name='slideShow' src='" + Settings.folder + Images[ this.slideNum ][ 0 ] + "' onError='SS.skipErrantSlide(); SS.preLoadNext(); this.slideDelay = this.speedActual + 1;' width='" + Images[ this.slideNum ][ 1 ] + "' height='" + Images[ this.slideNum ][ 2 ] + "' title='Slide-Show' onmousedown='SS.imgClickHandler( event );'" + imgStyle + " galleryimg='no' onAbort='this.src=this.src;' class='ssImage' onContextMenu='return SS.rightClick( this, event );'>" +
										"</td>" +
									"</tr>";

								if( consoleLoc == "below" )
									htm += console;

								if( buttonsLoc == "below" )
									htm += buttons;

								htm +=
								"</table>" +
							"</td>" +
						"</tr>" +
					"</table>" +
				"</td>" +
			"</tr>" +
		"</table>";

		if( this.popUp )
			htm += "<div style='position:absolute; top:0%; right:1%; margin:10px 15px 0px 0px;'><a href='javascript:void(0);' onClick='window.close(); return false;' onMouseover='this.title=SS.msg.ssExit; self.status=SS.msg.ssExit; return true;' onMouseOut='self.status=\"\"; return true;' class='ssExitPopUp'>Exit</a></div>";

		return htm;
	}

}

///////////////////////////////////////// END SLIDE SHOW: SS ////////////////////////////////////////

function initNavLinks() {
	try {

		// Disable top text links
		var Links = document.links;
		for( var i = 0; i < Links.length; i++ ) {
			var LinkComponents = Links[ i ].href.split( "/" );
			var file = LinkComponents[ LinkComponents.length - 1 ].replace( /\?.*/, "" );
			if( file.toLowerCase() == fileName.toLowerCase() && Links[ i ].className == "navTop" )
				Links[ i ].className = "navDisabled";
		}

		// Hide bottom graphical links
		var fileNameLC = fileName.toLowerCase();
		fileNameLC = fileNameLC.replace( /\?.*/, "" );

		switch( fileName.toLowerCase() ) {

			case "default.aspx":
				document.getElementById( "Bullet5" ).style.display = "none";
				document.getElementById( "TdHomepage" ).style.display = "none";
				break;

			case "ss.aspx":
				document.getElementById( "Bullet3" ).style.display = "none";
				document.getElementById( "TdPhotos" ).style.display = "none";
				break;

			case "calendar.aspx":
				document.getElementById( "Bullet2" ).style.display = "none";
				document.getElementById( "TdAvailability" ).style.display = "none";
				break;

			case "rates.aspx":
				document.getElementById( "Bullet1" ).style.display = "none";
				document.getElementById( "TdRates" ).style.display = "none";
				break;

			case "about.aspx":
				document.getElementById( "Bullet1" ).style.display = "none";
				document.getElementById( "TdAbout" ).style.display = "none";
				break;

			default:
				alert( "Switch/Case Error at initNavLinks" );

		}

		self.status = "";
	}
	catch( Err ) {
		if( local ) alert( Err );
		self.status = "Initializing at initNavLinks()...";
		setTimeout( "initNavLinks()", 200 );
	}
}

//--------------------------------------------------------------------------------------
function reportError( sub, msg ) {

	var Now = new Date();

	var diagnostics = " \nURL: " + document.location.href;

	try{ var topURL = top.document.location.href; }
	catch( e ){ var topURL = "Exception thrown while reading top URL"; }

	try{ var ref = document.referrer; }
	catch( e ){ var ref = "Exception thrown while reading Referrer"; }

	diagnostics += " \nTop URL: " + topURL;
	diagnostics += " \nTime: " + Now.toLocaleString() + " (client's time)";
	diagnostics += " \nPrior Page: " + ref;
	diagnostics += " \nGMT Offset: " + Now.getTimezoneOffset() / 60 + " hours";
	diagnostics += " \nMonitor: " + screen.width + "x" + screen.height + "x" + screen.colorDepth;
	diagnostics += " \nJava Enabled: " + navigator.javaEnabled();
	for( i in navigator ) { if( typeof navigator[ i ] != "object" ) diagnostics += " \n" + i + ": " + navigator[ i ]; }

	if( confirm ( sub + "\n\n" + msg + "\n\n==> Help us improve our site, click OK to report this problem to our Web Site Administrator..." ) )
		document.location.href = "mailto:" + DB.ReportErrorsTo + "?subject=" + escape( theHost + "; " + sub ) + "&body=" + escape( msg + " \n\nDIAGNOSTICS: This info may be used to help us troubleshoot technical problems" + diagnostics );
}

