//////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////// Drives P-101 & Alii /////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////

var DB = new Array();
DB[ "DavidEmail" ] = "david" + "@" + "creativetouchphoto." + "com";
REPORT_ERRORS_TO = DB[ "DavidEmail" ];

var theUserAgent = navigator.userAgent;
var theAppVersion = navigator.appVersion;
var bName = navigator.appName;
var exactVer = parseFloat( theAppVersion );
var bVer = parseInt( exactVer );
var bMinor = navigator.appMinorVersion;
var os = navigator.platform;

var IE = false;
var NC = false; var NC6 = false; var NC7 = false;
var SF = false;

if( bName == "Microsoft Internet Explorer" ) {
	var splitAppVersion = theAppVersion.split( "MSIE" );
	bVer = parseInt( splitAppVersion[1] );
	exactVer = parseFloat( splitAppVersion[1] );
	IE = true;
}
else if( theAppVersion.indexOf( "Safari" ) >= 0 )
	SF = true;
else if( bName == "Netscape" ) {
	if( theUserAgent.lastIndexOf( "Netscape" ) >= 0 ) { // NC6 or NC7
		var nInfo = theUserAgent.split( "Netscape" )[ 1 ];
		var slash = ( nInfo.indexOf( "/" ) >= 0 ) ? true : false;
		exactVer = ( slash ) ? parseFloat( nInfo.split( "/" )[ 1 ] ) : parseFloat( nInfo );
		bVer = parseInt( exactVer );
		if( bVer >= 7 ) NC7 = true;
		else if( bVer == 6 ) NC6 = true;
	}
	NC = true;
}
var winOS = ( os.substring( 0, 3 ) == "Win" );
var winIE = ( winOS && IE );
var macOS = ( os.substring( 0, 3 ) == "Mac" );
var macIE = ( macOS && IE );
//macIE = true;

var theHost = document.location.hostname.toLowerCase();

var local = ( theHost.length == 0 || theHost == "127.0.0.1" || theHost == "localhost" );
//local = false;
var live = !local;

var Snippets = new Array();
Snippets[ "lgImg" ] = "Click to enlarge";

var qStr = unescape( document.location.search.substring( 1 ) );
calAdmin = ( IE && winOS && ( qStr.indexOf( "iam=owner" ) >= 0 || local ) );
//calAdmin = false;

cb = ( document.getElementById ) ? true : false;
//----------------------------------------------------------------------------------------
function errorHandler( msg, url, line ) {
	if ( local ) {
		alert( "ERROR: " + msg + "\n\nURL: " + url + "\n\nLINE: " + line );
		return false;
	}
	return true;
}
///////////////////////////// START IMAGE LIBRARY FUNCTIONS /////////////////////////////

// ACCESSOR VARS: winIE, NC, SF, exactVer, local, REPORT_ERRORS_TO

var ImgReal = null;
function checkDim( img, imgWidToCk, imgHgtToCk ) {

	if( ImgReal == null ) {
		ImgReal = new Image();
		ImgReal.src = ( typeof img == "string" ) ? eval( "document.images." + img + ".src;" ) : eval( "document.images[" + img + "].src;" );
	}
	if( ImgReal.complete ) {
		var realWid = ImgReal.width;
		var realHgt = ImgReal.height;
		if( realWid > 1 && realHgt > 1 ) {
			if( imgWidToCk != realWid || imgHgtToCk != realHgt ) {
				var msg = ImgReal.src + " has incorrect dimensions set: \n\n• " + imgWidToCk + "x" + imgHgtToCk + " are the errant values \n• " + realWid + "x" + realHgt + " are the true values."
				if( confirm ( msg + "\n\nClick OK to report this problem to our Web Site Administrator:" ) )
					document.location.href = "mailto:" + REPORT_ERRORS_TO + "?subject=" + escape( 'Image Dimension Error' ) + "&body=" + escape( 'Error occured at: ' + document.location.href + ' \n' + msg.replaceLiteral( '•', '' ) );
			}
		}
		ImgReal = null;
	}
	else {
		this.img = img;
		this.imgWidToCk = imgWidToCk;
		this.imgHgtToCk = imgHgtToCk;
		setTimeout( "checkDim( img, imgWidToCk, imgHgtToCk );", 500 );
	}
}
//----------------------------------------------
function randompick() {
  return randompick.arguments[ Math.floor( Math.random()*randompick.arguments.length ) ];
}

function getTransition( transNum, duration ) {

	var trans = "";
	if( winIE ) {
		var d = duration;

		if( exactVer >= 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;
}
//----------------------------------------------
function getRGB( abbrev ) {
	var rgb = abbrev;
	switch( abbrev ) {
		case "b": rgb = "0,0,0"; break;
		case "w": rgb = "255,255,255"; break;
	}
	return rgb;
}
//----------------------------------------------
function getOpacity() {
	var opac = "";
	if ( winIE )   opac = "visibility:hidden;";
	else if( NC )  opac = "-moz-opacity:0;"
	else if ( SF ) opac = "opacity:0;"
	return opac;
}
//----------------------------------------------
function startFade( FadeInPhoto, transNum, transDur, transDelay ) {
	if( !transNum  ) transNum = 2;
	if( !transDur  ) transDur = 0.8;
	if( !transDelay) transDelay = 0;
	window.FadeInPhoto = FadeInPhoto;
	window.transNum = transNum;
	window.transDur = transDur;
	window.transDelay = transDelay;
	if( winIE ) setTimeout( "fadeInDirectX()", transDelay );
	else if ( NC || SF ) {
		FadeInPhoto.onload = function() { /*cancel photo onload function*/ }
		setTimeout( "fadeIn( FadeInPhoto )", transDelay );
	}
	else FadeInPhoto.style.visibility = "visible";
}
//----------------------------------------------
// 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";
	}
}
//----------------------------------------------
// SF & NC: Uses recursion

FadeInPhoto = null, fadeOpacity = 0, fadeOpacityTimer = 0;
function fadeIn( FadeInPhoto ) {

	if( NC ) FadeInPhoto.style.MozOpacity = this.fadeOpacity;
	else FadeInPhoto.style.opacity = this.fadeOpacity;

	this.fadeOpacity += .05;
	if( fadeOpacity < 1 ) {
		window.FadeInPhoto = FadeInPhoto;
		fadeOpacityTimer = setTimeout( "fadeIn( FadeInPhoto )", 40 );
	}
	else {
		if( NC ) FadeInPhoto.style.MozOpacity = 0.9999; // 1.0 causes flicker
		else FadeInPhoto.style.opacity = 1.0;
		clearTimeout( fadeOpacityTimer );
		fadeOpacity = 0;
	}
}

//----------------------------------------------
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 ) + " )";
	}
}

/////////////////////////////// END IMAGE LIBRARY FUNCTIONS ///////////////////////////////

//----------------------------------- STRING PROTOTYPE -----------------------------------


function replaceLiteral( target, replacement ) { // String Method
	return this.split( target ).join( replacement );
}
String.prototype.replaceLiteral = replaceLiteral;

//----------------------------------------------------------------------------------------
function getObj( strObjName ) {
	if( document.getElementById || document.all )
		return ( document.getElementById ) ? document.getElementById( strObjName ) : eval( strObjName );
}

//----------------------------------------------------------------------------------------
function replaceLiteral( target, replacement ) {
	return this.split( target ).join( replacement );
}
//---------------------------------------------------------------------------------------
function borderIm( Img, on ) {
	if( Img.complete ) Img.className = ( on ) ? "imgBorderOn" : "imgBorderOff";
}
//----------------------------------------------------------------------------------------

function clearField(field) {
	if ( field.value == field.defaultValue ) field.value = "";
}

function checkField(field) {
	if ( field.value == "") field.value = field.defaultValue;
}

//---------------------------------------------------------------------------------------

function emailAlert() {
	var eMail = document.form.email.value;

	var theMsg = 'You provided "' + eMail + '" as your e-mail address. Please review it and make sure you entered it accurately! It\'s important because if you make a "typo" in your e-mail address we will be unable to contact you by e-mail.';

	var eMsg1 = 'Sorry, but you have entered an invalid e-mail address! ALL e-mail addresses contain';
	var eMsg2 = 'character. Here\'s some examples of valid e-mail addresses: "joe@hotmail.com" OR "sally@aol.com" etc.';

//lbmartin@rmlaw.org.or.lbmom21@aol.com ==> This e-mail was mistakenly accepted, fix it!

	if( eMail.indexOf('@') == -1 ) theMsg = eMsg1 + ' exactly one "@" ' + eMsg2;
	else if( eMail.indexOf('@') == 0 || eMail.indexOf('@') == eMail.length - 1 ) theMsg = eMsg1 + ' exactly one "@" but it\'s never the first or last ' + eMsg2;
	else if( eMail.indexOf('.') == -1 ) theMsg = eMsg1 + ' at least one "." ' + eMsg2;
	else if( eMail.indexOf('.') == 0 || eMail.indexOf('.') == eMail.length - 1 ) theMsg = eMsg1 + ' at least one "." but it\'s never the first or last ' + eMsg2;

	alert( theMsg );

}

//---------------------------------------------------------------------------------------
// Used by Royal & Alii

function checkForm() {

	var firstNameObj = document.form.firstName;

	if( firstNameObj.value.indexOf( "^_^" ) >= 0 ) {
		alert( "TEST MODE ^_^: Recipient is " + DB.DavidEmail + "; otherwise, it goes to " + document.form.recipient.value );
		document.form.recipient.value = DB.DavidEmail;
	}

	document.form.submit_button.disabled = true;

	var missingInfo = "";
	var lineNumber = 0;
	var missingObj = null;

	if( firstNameObj.value == firstNameObj.defaultValue ) {
		lineNumber++;
		missingInfo += "\n   " + lineNumber + ". First Name";
		if( missingObj == null ) missingObj = firstNameObj;
	}

	var lastNameObj = document.form.lastName;
	if( lastNameObj.value == lastNameObj.defaultValue ) {
		lineNumber++;
		missingInfo += "\n   " + lineNumber + ". Last Name";
		if( missingObj == null ) missingObj = lastNameObj;
	}

	var home_telObj = document.form.home_tel;
	var work_telObj = document.form.work_tel;
	if(home_telObj.value == home_telObj.defaultValue  && work_telObj.value == work_telObj.defaultValue) {
		lineNumber++;
		missingInfo += "\n   " + lineNumber + ". One phone Number (home or work)";
		if( missingObj == null ) missingObj = home_telObj;
	}

	var emailObj = document.form.email;
	if(emailObj.value == '') {
		lineNumber++;
		missingInfo += "\n   " + lineNumber + ". Email Address";
		if( missingObj == null ) missingObj = emailObj;
	}

	var guestsObj = document.form.guests;
	var wedDate = guestsObj.value;
	if( wedDate == guestsObj.defaultValue) {
		lineNumber++;
		missingInfo += "\n   " + lineNumber + ". Number Guests";
		if( missingObj == null ) missingObj = guestsObj;
	}


	var visitVal = -1;
	var visitObj = document.form.visit; // RADIO BUTTON
	for( i = 0; i < visitObj.length; i++ ) {
		if( document.form.visit[ i ].checked ) visitVal = i;
	}
	if( visitVal == -1 ) {
		lineNumber++;
		missingInfo += "\n   " + lineNumber + ". Visited Kaanapali?";
		if( missingObj == null ) missingObj = visitObj[0];
	}

	var amonthObj = document.form.amonth;
	var adayObj = document.form.aday;
	var ayearObj = document.form.ayear;

	var dmonthObj = document.form.dmonth;
	var ddayObj = document.form.dday;
	var dyearObj = document.form.dyear;

	if( amonthObj.selectedIndex == dmonthObj.selectedIndex && adayObj.selectedIndex == ddayObj.selectedIndex && ayearObj.selectedIndex == dyearObj.selectedIndex ) {
		lineNumber++;
		missingInfo += "\n   " + lineNumber + ". Arrival & Departure Dates";
		if( missingObj == null ) missingObj = amonthObj;
	}


	var check_calendarVal = -1;
	var check_calendarObj = document.form.check_calendar; // RADIO BUTTON
	for( i = 0; i < check_calendarObj.length; i++ ) {
		if( document.form.check_calendar[ i ].checked ) check_calendarVal = i;
	}
	if( check_calendarVal == -1 ) {
		lineNumber++;
		missingInfo += "\n   " + lineNumber + ". Booking Calendar";
		if( missingObj == null ) missingObj = check_calendarObj[0];
	}
	else if( check_calendarObj[1].checked ) {
		alert( 'Sorry! To submit this form, you must indicate that you have checked our booking calendar and the dates you requested are available...' );
		document.form.submit_button.disabled = false;
		check_calendarObj[0].focus();
		return false;
	}


	///////////////////////// FORM DID NOT PASS; TELL USER /////////////////////////
	if( missingInfo != "" && document.form.firstName.value != "^_^" ) {
		alert("You failed to provide the following information:\n" + missingInfo + "\n\nPlease enter this information and try again...");
		missingObj.focus();
		document.form.submit_button.disabled = false;
		return false;
	}
	///////////////////////// FORM PASSED; SEND IT /////////////////////////
	else {

		if( 0 ) { // Set to true to load homepage w/o generating e-mail
			alert( "Running in Test Mode: No e-mail will be generated" );
			document.location.href = "success.html";
			return false;
		}

		document.form.submit_button.value = "Please Wait...";
		document.form.submit_button.disabled = true;
		return true;
	}
}
//---------------------------------------------------------------------------------------
var pkmWin = null;

function openWin( theSite, tool, loc, menu, winSize ) {

	closeWin();

	var theWidth = 800 * 1.1 * winSize;
	var theHeight = 450 * winSize;

	if( screen.width < 800 && screen.height < 553 ) {
		theWidth = screen.availWidth - 30;
		theHeight = screen.availHeight - 200;
	}

	pkmWin = window.open("","pkm_window","toolbar="+tool+",location="+loc+",directories=0,status=1,menubar="+menu+",scrollbars=1,resizable=1,width="+theWidth+",height="+theHeight+",top="+screen.availTop+",left="+screen.availLeft+"");

	pkmWin.location.href = theSite;
	focusWin();

}
function closeWin() {
	if( pkmWin != null && pkmWin.closed == false ) {
		pkmWin.close();
		pkmWin = null;
	}
}
function focusWin() {
	if( pkmWin != null && typeof pkmWin.registered == 'boolean' ) pkmWin.focus();
	else setTimeout( "focusWin()", 500 );
}
//---------------------------------------------------------------------------------------

function getCloseButton() {
	var popUp = ( document.location.href.indexOf( '#stop' ) != -1 ) ? true : false;
	if( popUp )
		document.write( '<FORM><INPUT TYPE="button" value="Close Window" onClick="self.close()" onMouseover="self.status=\'Closes this calendar pop-up window\';" onMouseout="self.status=\'\';" TITLE="Closes this calendar pop-up window"></FORM>' );
}
////////////////////////// START COLLAPSABLE/EXPANDABLE INDEX //////////////////////////

/*

ACCESSOR VARIABLES: None
ACCESSOR FUNCTIONS: None
ACCESSOR STYLES: cePlusMinus
*/

//--------------------------------- OBJECT CONSTRUCTOR ---------------------------------

function ColExpIndex() {

	this.msg = new Array();
	this.msg[ "show" ] = "Click to show content";
	this.msg[ "hide" ] = "Click to hide content";

	this.toggleLink = new Array();
	this.toggleLink[ "show" ] = [ "Show All Answers", "Show (expose) all answers on page" ];
	this.toggleLink[ "hide" ] = [ "Hide All Answers", "Hide (collapse) all answers on page" ];

	this.getPlusMinus = getPlusMinus;
	this.switchDisplay = switchDisplay;
	this.showTip = showTip;
	this.toggleAll = toggleAll;
	this.getToggleAllLink = getToggleAllLink;
	this.reloadPhotos = reloadPhotos;


	//-------------------------------------- METHOD --------------------------------------

	function getPlusMinus( Link ) { return Link.parentNode.firstChild; }

	//-------------------------------------- METHOD --------------------------------------

	function switchDisplay( Link ) {

		var PlusMinus = getPlusMinus( Link );
		var turnOn = ( PlusMinus.innerHTML == "+" );

		var Content = ( Link.parentNode.nextSibling.style ) ?
			Link.parentNode.nextSibling :
			Link.parentNode.nextSibling.nextSibling;

		if( turnOn ) {
			PlusMinus.innerHTML = "-";
			var focuserID = new Date().getTime();

			var focuser = "<A HREF='javascript:void( 0 );' ID='focuser" + focuserID + "'>&nbsp;</A>";
			Content.innerHTML = focuser + Content.innerHTML;
			Content.style.display = "block";
			var Focuser = document.getElementById( "focuser" + focuserID );
			if( Focuser ) {
				if( Focuser.focus ) {
					Focuser.focus();
					Link.focus();
				}
				Focuser.style.display = "none";
			}
			setTimeout( "CE.reloadPhotos()", 10 );
		}
		else {
			PlusMinus.innerHTML = "+";
			Content.style.display = "none";
		}

		showTip( Link );

	}

	//-------------------------------------- METHOD --------------------------------------

	function reloadPhotos() {
		var Photos = document.images;
		for( var i = 0; i < Photos.length; i++ )
			Photos[ i ].src = Photos[ i ].src;
	}
	//-------------------------------------- METHOD --------------------------------------

	function showTip( Link ) {

		var PlusMinus = getPlusMinus( Link );

		if( PlusMinus.innerHTML == "+" ) {
			Link.title = CE.msg.show;
			self.status = CE.msg.show;
		}
		else {
			Link.title = CE.msg.hide;
			self.status = CE.msg.hide;
		}

	}
	//-------------------------------------- METHOD --------------------------------------

	function toggleAll( Link ) {

		var divElements = document.getElementsByTagName( "span" );

		var showAll = ( Link.innerHTML == CE.toggleLink.show[ 0 ] ) ? true : false;

		for ( var i = 0; i < divElements.length; i++ ) {

			if( divElements[i].className == "cePlusMinus" ) {

				var TheLink = divElements[i].parentNode.firstChild;

				if( showAll ) {
					if( divElements[i].innerHTML == "+" ) switchDisplay( TheLink );
				}

				else {
					if ( divElements[i].innerHTML == "-" ) switchDisplay( TheLink );
				}
			}

		}

		if( showAll ) {
			Link.innerHTML = CE.toggleLink.hide[ 0 ];
			Link.title = CE.toggleLink.hide[ 1 ];
			Link.focus();
			window.scrollBy( 0, 10 );
		}
		else {
			Link.innerHTML = CE.toggleLink.show[ 0 ];
			Link.title = CE.toggleLink.show[ 1 ];
			Link.focus();
		}

	}

	//-------------------------------------- METHOD --------------------------------------

	function getToggleAllLink() {

		return "<A HREF='javascript:void( 0 );' onClick='CE.toggleAll( this ); return false;' onMouseover='self.status=this.title; return true;' onMouseout='self.status=\"\"; return true;' TITLE='" + CE.toggleLink.show[ 1 ] + "'>" + CE.toggleLink.show[ 0 ] + "</A>";

	}
}
////////////////////////// END COLLAPSABLE/EXPANDABLE //////////////////////////

///////////////////////////////// DYNAMIC WINDOW DW /////////////////////////////////
/*
	ACCESSOR VARS:  IE, NC, SF, macIE, winIE, exactVer
	ACCESSOR FUNC:  String.replaceLiteral, checkDim
	ACCESSOR CLASS: dw*, off
*/
//--------------------------------- OBJECT CONSTRUCTOR DW ---------------------------------

function DynamicWindow( transNum, transDur ) {

	// Do not edit past this line -------------------------
	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;

	// Methods
	this.createWindow = createWindow;
	this.showImg = showImg;
	this.keepInWin = keepInWin;
	this.getClickPosition = getClickPosition;
	this.getIeBody = getIeBody;
	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 -------------------------------------

	function createWindow( dataSrc, TheLink, theEvent, RequestedPos, WinDim, bodyMargin ) {

		if( TheLink ) TheLink.blur();

		var Data = getData( dataSrc, TheLink ), title, body;
		title = Data[ 0 ].replaceLiteral( '^', '"' );
		body =  Data[ 1 ].replaceLiteral( '^', '"' );

		// Read vals from 4-member RequestedPosition
		var clickPos   = ( RequestedPos[ 0 ] == 1 );
		var topLeft    = ( RequestedPos[ 0 ] == 2 );
		var center     = ( RequestedPos[ 0 ] == 3 );
		var xOffset    = RequestedPos[ 1 ];
		var yOffset    = RequestedPos[ 2 ];
		var placeInWin = ( typeof RequestedPos[ 3 ] == "undefined" ) ? true : RequestedPos[ 3 ];

		// Read vals from 3-member WindowDimension, if image then get wid/hgt from tag
		var showImg = ( body.indexOf( "imgSrc=" ) == 0 );
		var scrollStyle = ( WinDim[ 0 ] ) ? " overflow:auto;" : "";
		var winWid = WinDim[ 1 ];
		var winHgt = WinDim[ 2 ];

		if( showImg ) {

			// 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() + "' 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;
		}

		if( !bodyMargin ) bodyMargin = 0;

		this.removeWin();

		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 ) ? ( 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'>" +
			"<table align='center' border='0' cellspacing='0' cellpadding='0'>" +
				"<tr>" +
					"<td class='dwTitle' style='width:100%; text-align:center;' onmouseover='DW.overTitleBar=true; if( macIE ) style.cursor=\"text\";' onmouseout='DW.overTitleBar=false;'>" +
						"<div id='dwTitleBarID'>" +
							title +
						"</div>" +
					"</td>" +
					"<td valign='top'>" +
						"<a href='javascript:DW.removeWin();' onMouseOver='style.textDecoration=\"none\"; self.status=this.title; return true;' onMouseOut='self.status=\"\"; return true;' onClick='this.blur(); return true;' TITLE='Close' STYLE='text-decoration:none; font-weight:normal;'><span class='dwX' STYLE='text-decoration:none; font-size:" + ( ( macIE ) ? 100 : 130 ) + "%;'>×</span></a>" +
					"</td>" +
				"</tr>" +
			"</table>" +
		"</div>" +

		"<div class='dwBodyParent' style='width:100%;" + bodyHgtStyle + scrollStyle + "'>" +
			"<div class='dwBody' id='dwBodyID' style='margin:" + bodyMargin + "px;'>" +
				body +
			"</div>" +
		"</div>";

		NewWindow.innerHTML = myWindow;
		var xPos, yPos;

		// 1) Place at click position & add offset (if any)
		if( clickPos ) {
			var ClickPos = getClickPosition( theEvent );
			xPos = ClickPos[ 0 ] + xOffset;
			yPos = ClickPos[ 1 ] + yOffset;
		}

		// 2) Place in upper left hand corner of visible body & add offset (if any)
		else if( topLeft ) {
			if( IE ) {
				IeBody = getIeBody();
				xPos = IeBody.scrollLeft + xOffset;
				yPos = IeBody.scrollTop + yOffset;
			}
			else {
				xPos = window.pageXOffset + xOffset;
				yPos = window.pageYOffset + yOffset;
			}
		}

		// 3) Place in center of visible body & add offset (if any)
		else {

			var IeBody, scrollX, scrollY, bodyWid, bodyHgt;

			if( IE ) {
				IeBody = getIeBody();
				scrollX = IeBody.scrollLeft;
				scrollY = IeBody.scrollTop;
				bodyWid = IeBody.clientWidth;
				bodyHgt = 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 );
			yPos = parseInt( ( bodyHgt - winHgt ) / 2 + scrollY + yOffset );
		}

		if( placeInWin ) {
			var NewWindowPos = keepInWin( NewWindow, xPos, yPos );
			xPos = NewWindowPos[ 0 ];
			yPos = 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.onmouseover = function() {
			Photo.title = "Click to close";
			self.status = Photo.title;
			Photo.style.cursor = "hand";
			return true;
		}
		Photo.onmouseout = function() { self.status = ""; return true; }

		var imgNum = -1;
		for( var i = 0; i < document.images.length; i++ ) {
			if( document.images[ i ] == Photo ) { imgNum = i; break; }
		}
		checkDim( imgNum, Photo.width, Photo.height );

		document.getElementById( "dwTitleBarID" ).innerHTML = this.title;

		startFade( Photo, this.transNum, this.transDur );

	}

	//------------------------------------- METHOD DW -------------------------------------

	function keepInWin( NewWindow, leftEdge, topEdge ) {

		if( IE ) var IeBody = getIeBody();

		var bodyHgt = ( IE ) ? IeBody.clientHeight : window.innerHeight;
		var bodyWid = ( IE ) ? IeBody.clientWidth : window.innerWidth;

		// Prevent window from going off bottom & top of page
		var winHgt = NewWindow.offsetHeight;
		var yOffset = ( IE ) ? 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 ) ? IeBody.scrollLeft : window.pageXOffset;
		var hScreenPos = leftEdge - xOffset;
		var hSkew = bodyWid - hScreenPos;
		if( hSkew < winWid + 10 ) { // right edge
			leftEdge -= winWid - hSkew + 10;
			// NC & vert scroll bar is present
			if( NC && document.height > window.innerHeight - 25 ) leftEdge -= 15;
		}
		else if( hScreenPos < 10 ) leftEdge = 10 + xOffset; // left edge


		return[ leftEdge, topEdge ];

	}
	//------------------------------------- METHOD DW -------------------------------------

	function getIeBody() {
		var ieCSS = ( document.compatMode) ? document.compatMode ==  "CSS1Compat" : false;
		return ( ieCSS ) ? document.documentElement : document.body;
	}
	//------------------------------------- METHOD DW -------------------------------------

	function getClickPosition( theEvent ) {

		try {
			if( IE ) IeBody = getIeBody();
			var x = ( IE ) ? event.clientX + IeBody.scrollLeft : theEvent.pageX;
			var y = ( IE ) ? event.clientY + IeBody.scrollTop  : theEvent.pageY;
		}
		// Catch exceptions when action does not create an event, like when
		// creating window from NC 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 it's 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 && !macIE ) {

			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 = getClickPosition( e );
			// Don't 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 + document.body.scrollLeft;
				this.Window.style.top = event.clientY - this.dWinOffsetY + document.body.scrollTop;
				return false;
			}

			else {
				this.Window.style.top = e.pageY - this.dWinOffsetY;
				this.Window.style.left = e.pageX - this.dWinOffsetX;
			 }
		 }
	}

	//------------------------------------- METHOD DW -------------------------------------

	function removeWin() {
		var Window = document.getElementById( "dWinID" );
		if( Window ) document.body.removeChild( Window );
	}

	//------------------------------------- METHOD DW -------------------------------------

	function mouseUp() { this.Window = null; }

}

////////////////////////////////// END DYNAMIC WINDOW //////////////////////////////////

// Alii specific code

var timeout = 0;

//--------------------------------------------------------------------------------------
function img_act(imgName, index) {

	clearTimeout(timeout);

	var dTextHome = new Array("Goes back to our Homepage", "We've got a pool, tennis courts, exercise room and more...", "Find out where we are and learn about fun things to do", "Get our rates &amp; fill out our rental inquiry form", "You're going to love our beautifully remodeled condo", "Check your vacation dates against our booking calendar");

	document.getElementById( "callout" ).innerHTML = dTextHome[index];
	document.getElementById( "callout" ).className = "on";

}

//--------------------------------------------------------------------------------------
function img_inact() {
	timeout = setTimeout('document.getElementById( "callout" ).innerHTML = "&nbsp;"', 500);
}

function getHawaiiTime() {

	var gmtOffset = 10; // for Hawaii
	var now = new Date();
	var difhrs = now.getTimezoneOffset()/60;
	var lochrs = now.getHours();
	GMThours = (difhrs < 0) ? lochrs - difhrs : 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;

	var mauiTime = "" + hours + ":"  + minutes + ":"  + seconds + " " + am_pm;

	//+ " on " + ( now.getMonth() + 1 ) + "/" + now.getDate() + "/" + now.getYear();

	return mauiTime;

}