//' Web software by DavidRegier.com

/*

function activateBut
function activateMsg
function blinkSpecial
function isValid
function cleanIt
function DynamicIndex as Object
function DataBaseStatus
function deActivateBut
function deActivateMsg
function DynamicMenu as Object
function DynamicWindow as Object
function formatDate
function getCallout
function getCookieVal
function getEmailLink
function getErrLink
function getFormatedDate
function getGalleryPullDown
function getWinWid
function goTo
function getPullDown
function getRandomNum
function getVal
function initPullDowns
function largePic
function linkToPopUp
function linkToWin
function listingStatus
function noContextMenu
function noRightClick
function PopUp as Object
function PreLoader
function recordData
function removeHtmlTags
function replaceLiteral
function reportError
function resetGalleryPullDown
function resetPullDown
function scramble
function setGlobalQstr
function showHawaiiTime
function SlideShow
function sloganStatus
function startFilter
function trimString
function unscramble
function writeCookMsg
function writeFooter
function writeSeparator
IMAGE LIBRARY FUNCTIONS

*/


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;

cookieDomain = null;
if( live && theHost ) {
	var Host = theHost.split( "." ), hLen = Host.length;
	if( hLen >= 2 )
		cookieDomain = "." + Host[ hLen - 2 ] + "." + Host[ hLen - 1 ];
}

qStr = unescape( document.location.search ).substring( 1 );

popUp = ( qStr.indexOf( "CONTEXT=popup" ) >= 0 );
homePage = "index.html"
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 ];

var bDoesTrans = ( winIE );

var ieTrans = ( winIE );
var ncTrans = ( MZ );

var framed = true;
if( top == self ) framed = false;

gErrReported = false;

cookiesOn = navigator.cookieEnabled;

pageTitle = ( typeof window.TVV == "object" ) ? "We are just a toll free phone call away at " + TVV.PhoneTollFree + " ext " + TVV.RentalInqExt : "";

if( window.ShowLastMinutePage )
	document.write( "<style>.showLastMinute{ display:inline; }</style>" );

// Define literals that can be used in place of numbers & null.
y = 1, yes = 1, n = 0, no = 0, a = 2, append = 2, end = null;

// Create alternate hash-table data-base from cal data (if present)
CALENDAR_RECORDS_HT = null;
if( window.CALENDAR_RECORDS ) {
	CALENDAR_RECORDS_HT = new Array();
	for( var i = 0; i < CALENDAR_RECORDS.length - 3; i++ )
		CALENDAR_RECORDS_HT[ CALENDAR_RECORDS[ i ][ 2 ] ] = CALENDAR_RECORDS[ i ];
}

readP = 0, writeP = "";
staffUser = ( GetCookie( "agentCookie" ) || GetCookie( "writeCookie" ) );
if( GetCookie( "writeCookie" ) ) SetCookie( "agentCookie", true, null, "/" );
publicUser = !staffUser;


if( window.UltraPrivateVillasPW )
	UltraPrivateVillasPW = UltraPrivateVillasPW.replace( /[^a-zA-Z]/g, "" );
if( window.PrivateListingsPW )
	PrivateListingsPW = PrivateListingsPW.replace( /[^a-zA-Z]/g, "" );
if( window.CalendarPW )
	CalendarPW = CalendarPW.replace( /[^a-zA-Z]/g, "" );

//--------------------------------------------------------------------------------------

function getAjaxRequest() {

	var Request = null;

	// W3C
	if( window.XMLHttpRequest ) {
		try { Request = new XMLHttpRequest(); }
		catch( Err ) { Request = null; }
	}

	// IE 6-
	else if( window.ActiveXObject ) {
		try { Request = new ActiveXObject( "Msxml2.XMLHTTP" ); }
		catch( Err ) {
			try { Request = new ActiveXObject( "Microsoft.XMLHTTP" ); }
			catch( Err ) { Request = null; }
		}
	}

	return Request;
}

//alert( "UltraPrivateVillasPW: " + UltraPrivateVillasPW + "\nPrivateListingsPW: " + PrivateListingsPW + "\nCalendarPW: " + CalendarPW );
//--------------------------------------------------------------------------------------

function initPullDowns() {
	if( window.yachtFS )
		document.getElementById( "YachtSelect" ).selectedIndex = 0;
}

//--------------------------------------------------------------------------------------

function getWinWid() { return ( document.body.clientWidth ) ? document.body.clientWidth : window.innerWidth; }
//--------------------------------------------------------------------------------------

// Used for SE Friendly pages like fs-bf-polynesianparadise.html; updated 6/5/2006

function setGlobalQstr() {
	var path = document.location.pathname;
	var FileComponents = path.split( "-" );

	var sortVal = FileComponents[ 1 ];
	var propName = FileComponents[ 2 ].replace( /\.html$/, "" );
	qStr = "data=fs-" + sortVal + "-" + propName + ".js";
}

//////////////////////////////// Start PreLoader: PL ////////////////////////////////

function PreLoader() {

	this.Files = [

		"listings.html",
		"listings.html?show=sp",
		"listings.html?show=lm",
		"images/comp_name1.gif",
		"images/legend_bot_left.gif",
		"images/LogoTVV02.png",
		"data/listings.js",
		"data/incentives.js",
		"images/TVV.gif",
		"images/IndexPhotos01.jpg",
		"images/IndexPhotos02.jpg",
		"images/IndexPhotos03.jpg",
		"images/IndexPhotos04.jpg",
		"images/IndexPhotos05.jpg",
		"images/IndexPhotos06.jpg",
		"images/IndexPhotos07.jpg",
		"images/IndexPhotos08.jpg",
		"calendar.html",
		"calendar/cal-data.js",
		"code/calendar.js",
		"code/villa1.js",
		"code/villa2.js",
		"code/fact-sheet.js",
		"code/yacht.js",
		"code/thumbnails.js",
		"code/ss.js",
		"data/car-rentals.js",
		"code/calendarAdmin.js",
		"concierge-services.html",
		"our-friends.html",
		"doorway-gallery.html",
		"testmonial-main.html",
		"privacy-stmt.html",
		"terms_cond_disc.html",
		"res-process.html",
		"credentials.html",
		"staff-member.html",
		"staff-services.html",
		"car-rentals.html",
		"inquiry-form.html",
		"code/form.js",
		"mail-calendar.aspx",
		"code/mail-calendar.js",

	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 ////////////////////////////////

function writeCookMsg() {
	if( !navigator.cookieEnabled )
		document.write( "<div align='center' style='margin:0px 0px 10px 0px;'><iframe src='cookies.html' width='750' height='80' frameborder='0' scrolling='yes' marginheight='0' marginwidth='0' align='top'></iframe></div>" );
}
//--------------------------------------------------------------------------------------

// New 3-10-2006 & will replace dText eventually!

Msg = new Array();
Msg.enlarge = "Click to enlarge";

//---------------------------------------------------------------------------------------
// Use ^ to represent the double quote character

var dText = new Array(
	"Luxury Vacation Villa Reservations with Personal Concierge Services...",
	"We've got a wide selections of villas on Maui...",
	"You'll love our Tropical Yacht Vacations...",
	"Find out about special promotions & holiday openings",
	"We have Villas on Kauai, Oahu, Big Isle, Molokai & Lanai",
	"You're going to love our fully automated slide shows...",
	"We have villas in Asia & the South Pacific too...",
	"Learn about us, our villas and how we do business...",
	"Real Estate Services \"teaser tip\" forthcoming...",
	"Concierge Services \"teaser tip\" forthcoming...",
	"Rocky Mountain Retreats \"teaser tip\" forthcoming...",
	"Learn more about our business friends and affiliates...",
	"Fill out our rental inquiry form & we will get right back to you",
	"Goes back to our homepage...",
	"ADMIN: Click to view private listings...; this link only appears local...",
	"Opening connection to Data-Base - please wait...",
	"Click to learn more about this property...",
	"ADMIN: Click for web site help; this link only appears local...",
	"You'll love viewing photos of this property with our automated slide-show...",
	"View photos of this property in a traditional \"click to enlarge\" style &amp; print them too...",
	"Read our detailed \"printer-friendly\" fact sheet &amp; learn more about this property",
	"Record this property in your \"List of Favorites\" so you can submit it with your inquiry",
	"E-mail this property to your friends and family so they can review it too...",
	"View our current booking calendar to check this property for availability",
	"Fill out our Rental Inquiry/Reply form and send us your \"List of Favorites\" too...",
	"Read what our many other satisfied customers said about this property",
	"Click to show bedroom info...",
	"Click to hide bedroom info...",
	"View our reservation calendars & find open dates",
	"Send us an e-mail now...",
	"Loads calendar in a pop-up - you WILL NOT LOSE info you have entered into this form",
	"Click flower links below to learn more about ",
	"View this property's availability-calendar in a pop-up window",
	"Get exact pricing and submit a rental-request...",
	"Place Holder"
);

//--------------------------------------------------------------------------------------
function writeFooter() {

	document.write( "<DIV ALIGN='center'>For Reservations & Information, complete our <A HREF='inquiry-form.html' onMouseOver='if( window.DM ) DM.killOthers( this ); self.status=dText[12]; return true;' onMouseOut='self.status=\"\"; return true;' TITLE='" + dText[12] +"'>Inquiry Form</A> OR;<BR>Send e-mail to " + getEmailLink( TVV.EmailInquiryReservations, "Tropical Villa Vacations Web Site E-Mail", "" ) + " or call us at " + TVV.PhoneTollFree + " ext " + TVV.RentalInqExt + "</DIV><BR>" );

	if( pageTitle ) document.title = pageTitle;
}

//----------------------------------- String Prototype -----------------------------------

function trimString() {
	var TestString = this;
	var SpaceChar  = " ";
	while (TestString.charAt(0) == SpaceChar) {TestString = TestString.substr(1)};
	while (TestString.charAt(TestString.length-1) == SpaceChar) {TestString = TestString.substr(0,TestString.length-1)};
	return TestString.toString();
}
String.prototype.trimMe = trimString;

//----------------------------------- String Prototype -----------------------------------

function replaceLiteral( target, replacement ) {
	var tilda = ( target == "~" ) ? "" : "~";
	var str = tilda + this.toString() + tilda;
	str = str.split( target ).join( replacement );
	return str.substring( tilda.length, str.length - tilda.length );
}
String.prototype.replaceLiteral = replaceLiteral;

//----------------------------------- String Prototype -----------------------------------
//                   req,  req,       opt
function recordData( key, value, CookieExpDate ) {

	var cookieName = this.toString();
	var data = GetCookie( cookieName ); if( !data ) data = "";

	// In unlikely event user input special delimiters, replace them english definitions
	value = value.replace( /&/g, "and" ).replace( /=/g, "is" );

	// Split old cookie data
	var KeyVals = data.split( "&" );
	var existingKey = 0;

	// Scan old cookie data. If key already exists then update the value it contains
	for( var i = 0; i < KeyVals.length; i++ ) {
		var ThisPair = KeyVals[ i ].split( "=" );
		if( key == ThisPair[ 0 ] ) {
			if( value ) // Set new value
				KeyVals[ i ] = key + "=" + value;
			else // value is empty string to remove thisy entry
				KeyVals.splice( i, 1 );
			data = KeyVals.join( "&" );
			existingKey = 1;
			break;
		}
	}

	// Otherwise, existing key does not exist so append new key/value pair to end of string
	if( value && !existingKey )
		data += ( ( data ) ? "&" : "" ) + key + "=" + value;

	if( data )
		SetCookie( cookieName, data, ( ( CookieExpDate ) ? CookieExpDate : null ), "/", cookieDomain );
	else
		DeleteCookie ( cookieName, "/", cookieDomain );

	//alert( GetCookie( cookieName ) );
}
String.prototype.recordData = recordData;

//----------------------------------- String Prototype -----------------------------------
// Updated 3/5/06; 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;

// 3/19/2008
//----------------------------------- String Prototype -----------------------------------
// Trims white space (which includes line breaks) off both ends
function trim() {
	var str = this.toString();
	return str.replace( /^\s*|\s*$/g, "" );
}
String.prototype.trim = trim;

//----------------------------------- String Prototype -----------------------------------

var tmpStr = "";

function removeHtmlTags() { // String Method

	var theString = this.toString(); // Object ==> String
	tmpStr = theString;

	var startPos = theString.indexOf( "<" );
	var endPos = theString.indexOf( ">" );

	// If we got an HTML tag...
	if( startPos != -1 && endPos != -1 && ( endPos > startPos ) ) {
		var htmlTag = "<" + theString.substring( startPos + 1, endPos ) + ">";
		tmpStr = theString.replaceLiteral( htmlTag, "" );
		tmpStr.removeHtmlTags();
	}
	return tmpStr;
}
String.prototype.removeHtmlTags = removeHtmlTags;

//----------------------------------- String Prototype -----------------------------------

function cleanIt() {
	var out = this.toString();
	return out.replace( /\^/g, "\"" );
}
String.prototype.cleanIt = cleanIt;

//----------------------------------- String Prototype -----------------------------------

function unscramble() {
	var eMailOut = "";
	var eMailIn = this.toString();
	if( eMailIn && eMailIn.indexOf( "@" ) == -1 ) {
		eMailIn = eMailIn.replace( /\s{2}/g, "." ).replace( /\s{1}/g, "@" );
		for( k = 0; k <= eMailIn.length; k++ )
			eMailOut = eMailIn.charAt( k ) + eMailOut;
		return eMailOut;
	}
	else
		return eMailIn;
}
String.prototype.unscramble = unscramble;

//----------------------------------- String Prototype -----------------------------------

function isValid( Element ) {

	var eMail = this.toString();

	if( eMail ) {
		var emailRE = /^[\w\.-]+[^\.-]@[\w\.-]+\.[a-zA-Z]{2,}$/;

		EmailArr = eMail.split( "," );
		for( i in EmailArr ) {
			EmailArr[ i ] = EmailArr[ i ].replace( /^\s*|\s*$/g, "" );
			if( !emailRE.test( EmailArr[ i ] ) ) {
				alert( "Sorry but \"" + EmailArr[ i ] + "\" is an invalid e-mail address.\n\nHere's some examples of valid e-mail addresses:\n1. joe@hotmail.com\n2. sally_smith@aol.com\n3. jim.clark@co.la.ca.us\n4. ron-kent254@yahoo.com\n\nTIP: Valid e-mails contain 1 \"@\" character & end with .com, .net, .us, .ca, etc. etc." );
				if( Element ) Element.focus();
				return false;
			}
		}
	}

	return true;

}
String.prototype.isValid = isValid;

//----------------------------------- String Prototype -----------------------------------

function scramble() {
	var eMailIn = this.toString();
	if( eMailIn && eMailIn.indexOf( "@" ) >= 0 ) {
		eMailIn = eMailIn.replace( /\./g, "  " ).replace( /@/g, " " );
		var eMailOut = "";
		for( i = 0; i <= eMailIn .length; i++ )
			eMailOut = eMailIn.charAt(i) + eMailOut;
		return eMailOut;
	}
	else
		return eMailIn;
}
String.prototype.scramble = scramble;

//--------------------------------------------------------------------------------------

function getEmailLink( recipient, subject, message ) {

	if( !subject && message ) subject = " ";

	if( recipient.indexOf( "@" ) == -1 ) {
		var eMailOut = "";
		var eMailIn = recipient.replace( /\s{2}/g, "." ).replace( /\s{1}/g, "@" );
		for( k = 0; k <= eMailIn.length; k++ )
			eMailOut = eMailIn.charAt( k ) + eMailOut;
		recipient = eMailOut;
	}

	return "<a href='mailto:" + recipient + "?subject=" + escape( subject ) + ( ( message ) ? "&body=" + escape( message ) : "" ) + "' onMouseOver='self.status=this.title; return true;' onMouseOut='self.status=\"\"; return true;' title='Send e-mail to " + recipient + "'>" + recipient + "</a>";
}

// 08/31/2006
///////////////////////////// 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 = 1;
		else GuiObj.style.opacity = 1;
		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 ///////////////////////////////

function getCallout( dTextIndex ) {

	var calloutType = "<BR>";
	var dTextCol = "#ffffcc";

	var fontSize = 10;

	var msg = ( dTextIndex >= 0 ) ? dText[ dTextIndex ] + Villas[gVillaRecNum][1] : "&nbsp;";

	calloutType = "<DIV ID='callout' STYLE='color:" + dTextCol + "; margin:4px; font-size: " + fontSize + "pt; font-family: arial, helvetica;'>" + msg + "</DIV>";

	return calloutType;
}
//--------------------------------------------------------------------------------------
var timeout = 0;

function activateMsg( msg ) {

	try {
		clearTimeout( timeout );
		document.getElementById( 'callout' ).innerHTML = msg;
	}
	catch( e ) {}
}

//--------------------------------------------------------------------------------------
function deActivateMsg( dTextIndex ) {
	try {
		gMsgOff = ( dTextIndex >= 0 ) ? dText[ dTextIndex ] + Villas[gVillaRecNum][1] : "&nbsp;";
		timeout = setTimeout('document.getElementById( \'callout\' ).innerHTML = gMsgOff', 500);
	}
	catch( e ) {}
}

//--------------------------------------------------------------------------------------

function writeSeparator( txt0, txt1 ) {
	document.write( txt0 + '<DIV CLASS="normFaint">___________________________________________________________________________________</DIV>' + txt1 );}

//Updated 3/2006
//////////////////////////// START OPEN BROWSER WIN: PopUp ////////////////////////////

/*
ACCESSOR VAR: None
ACCESSOR FUN: None
*/

function PopUp() {

	this.winName = "tvvWin";
	this.PrinterFriendlyContactInfo = null;
	this.printerFriendlyCss = "code/stylesPrintFriendly.css";

	// Do not edit past this line -------------------------
	this.Win = null;
	this.openWin = openWin;
	this.printerFriendly = printerFriendly;
	this.closeWin = closeWin;
	this.linkToWin = linkToWin;

	//------------------------------------ METHOD: PopUp ------------------------------------

	function openWin( url, tBar, lBar, sBar, mBar, wWid, wHgt, scBar, reSize, wPos ) {

		var nArgs = arguments.length;
		if( nArgs == 2 || nArgs == 10 ) {

			if( nArgs == 2 ) {
				switch( tBar ) {
					case 1: tBar=1; lBar=1; sBar=1; mBar=1; wWid=.8; wHgt=.6; scBar=1; reSize=1; wPos=1; break; // Ext Links
					case 2: tBar=0; lBar=0; sBar=1; mBar=0; wWid= .7; wHgt= .5; scBar=1; reSize=1; wPos=1; break; // Help Win
					case 3: tBar=0; lBar=0; sBar=1; mBar=0; wWid= 1; wHgt= 1; scBar=1; reSize=1; wPos=1; break; // SS
				}
			}

			this.closeWin();

			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:
					leftPos = parseInt( ( avWid - wWid ) / 2 );
					break;

				case 2:
					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);
		}

		else
			alert( "ERROR: " + nArgs + " arguments have been passed to method \"PopUp.openWin\", it accepts either 2 or 10 arguments." );

	}

	//------------------------------------ METHOD: PopUp ------------------------------------
	// Classes are pf*
	// Explicitily define pf sections w/ ids of pfContent1,2,3,etc and/or hide sections by setting them with pfHide class (display:none) defined in printer-friendly.css file only

	//                        opt           opt
	function printerFriendly( removeImages, ExcludedPfContentSections ) {

		// Got excluded sections so set class to pfHide, which is only defined in printer-friendly.css
		if( ExcludedPfContentSections ) {
			for( var i = 0; i < ExcludedPfContentSections.length; i++ ) {
				if( document.getElementById( ExcludedPfContentSections[ i ] ) )
					document.getElementById( ExcludedPfContentSections[ i ] ).className = "pfHide";
			}
		}

		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='" + this.printerFriendlyCss + "' type='text\/css'>" +
			"</head>";
			htm += ( live ) ? "<body onLoad='if( window.print ) window.print();'>" : "<body>";
			//htm +=
			//"<div class='pfTitle'>" + pfPageTitle + "</div>" +
			//"<div class='pfOtherData'>" + theHost;

			if( this.PrinterFriendlyContactInfo ) {
				for( var i = 0; i < this.PrinterFriendlyContactInfo.length; i++ ) {
					htm += this.PrinterFriendlyContactInfo[ i ][ 0 ] + eval( this.PrinterFriendlyContactInfo[ i ][ 1 ] ) + this.PrinterFriendlyContactInfo[ i ][ 2 ];
				}
			}

			htm += "</div>";

			var nContent = 1;
			outer:
			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 , "" );

				if( removeImages )
					content = content.replace( /<img\s.*?>/gi , "" );

				// Get rid all script sections as they may cause js errors since include files not present
				content = content.replace( /<script[\d\D]*?<\/script>/gi , "" );
				htm += content;
				nContent++;
			}

			if( document.getElementById( "pfFooter" ) )
				htm += "<p class='pfFooter'>" + 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..." );

		// Got excluded sections so set class to pfShow, which is only defined in printer-friendly.css
		if( ExcludedPfContentSections ) {
			for( var i = 0; i < ExcludedPfContentSections.length; i++ ) {
				if( document.getElementById( ExcludedPfContentSections[ i ] ) )
					document.getElementById( ExcludedPfContentSections[ i ] ).className = "pfShow";
			}
		}
	}
	//------------------------------------ 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 ) {
			if( PopUp.Win.MyOpener != self ) PopUp.Win.MyOpener = self;
		}
		else setTimeout( "PopUp.linkToWin()", 250 );
	}
}

PopUp = new PopUp();

////////////////////////////// END OPEN BROWSER WIN: PopUp /////////////////////////////

// Cookie library updated 3/11/06
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//----------------------------------------------------------------------------------------
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;
}
//----------------------------------------------------------------------------------------
function SetCookie (name,value,expires,path,domain,secure) {
  document.cookie = name + "=" + escape (value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "");
}
//----------------------------------------------------------------------------------------
function DeleteCookie (name,path,domain) {
  if (GetCookie(name)) {
    document.cookie = name + "=" +
      ((path) ? "; path=" + path : "") +
      ((domain) ? "; domain=" + domain : "") +
      "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  }
}
//----------------------------------------------------------------------------------------
//Global function read everytime page loads
var expdate = new Date ();
var expdate1 = new Date ();
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 365 * 1000)); // 1 year from now
expdate1.setTime (expdate1.getTime() + (24 * 60 * 60 * 30 * 1000)); // 30 days from now - hardcoded in help.html
//----------------------------------------------------------------------------------------

var qStrReferrer = qStr;
var refPage = ( qStrReferrer != null && qStrReferrer.indexOf( "tvvref=" ) == 0 ) ? qStrReferrer.split( "tvvref=" )[1] : document.referrer;
if( !GetCookie( 'tvvReferrer' ) ) SetCookie( 'tvvReferrer', refPage, null, '/' );

var showAllErrors = ( GetCookie( "ReportErrors" ) == "true" ) ? true : false;

//---------------------------------- DISABLE RIGHT CLICK ---------------------------------

function noContextMenu( theEvent ) {
	if( theEvent ) event = theEvent;
  event.cancelBubble = true; event.returnValue = false; return false;
}

function noRightClick( e ) {
  if( window.Event ) {
    if( e.which == 2 || e.which == 3 || e.ctrlKey ) return false;
  }
  else if( event.button == 2 || event.button == 3 || event.ctrlKey ) {
    event.cancelBubble = true; event.returnValue = false; return false;
  }
}


if( ( live || live ) && !GetCookie( "ReportErrors" ) && !GetCookie( "agentCookie" ) )
	document.oncontextmenu = function() { return false; }

//----------------------------------------------------------------------------------------
function sloganStatus() { setTimeout("defaultStatus = dText[0]", 500); }
function listingStatus() { setTimeout("defaultStatus = nDataRows + ' listings available...'", 500); }
function DataBaseStatus() { self.status = dText[15]; }
//--------------------------------------------------------------------------------------

function formatDate( theDate ) {

	var date = new Date( theDate );
	var unForYear = "" + date.getYear();
	var forYear = unForYear.substring( unForYear.length - 2 );

	return "" + ( date.getMonth() + 1 ) + "/" + date.getDate() + "/" + forYear;
}
//---------------------------------------------------------------------------------------

function startFilter() {
	if( winIE ) {
		eval( "" +
			"try{ " +
				"photo.filters.item(0).apply();" +
				"photo.style.visibility = 'visible';" +
				"photo.filters.item(0).play();" +
			"}" +
			"catch( e ) { photo.style.visibility = 'visible'; }" +
		"" );
	}
}
var flowerOff = new Image(); flowerOff.src = "images/flowerOff.png";
var flowerOn = new Image(); flowerOn.src = "images/flowerOn.png";
//--------------------------------------------------------------------------------------
function activateBut( imgName ) { try{ document[imgName].src = eval( "flowerOn.src" ); } catch(e){} }
function deActivateBut( imgName ) { try{ document[imgName].src = eval( "flowerOff.src" ); } catch(e){} }
//--------------------------------------------------------------------------------------
function getRandomNum( maxNum ) {
	if( maxNum == null ) maxNum = 5;
	var randNum = ( Math.round( maxNum * Math.random() ) + 1 ) % maxNum + 1;
	return randNum;
}

//--------------------------------------------------------------------------------------

function resetGalleryPullDown() {
	if( eval("typeof document.gallery_form.gallery") == "object" )
		document.gallery_form.gallery.selectedIndex = 0;
}
//--------------------------------------------------------------------------------------

function resetPullDown( pullDownID ) { // args are top OR bot
	//if( eval("typeof document.pull_down_" + pullDownID) == 'object' )
		//eval( 'document.pull_down_' + pullDownID + '.' + pullDownID + '.selectedIndex = 0' );
}

//--------------------------------------------------------------------------------------
function getGalleryPullDown() {

	return "" +

	"<form name='gallery_form'>" +
		"<select name='gallery' onChange='goTo( this );' class='pullDown'>" +

			"<option value='doorway-gallery.html|none'>Take me to another photo gallery...</option>" +
				"<option value='ss.html?data=pg-southmaui.js|3'>&nbsp;&#149;&nbsp;South Maui Slide Show</option>" +
				"<option value='thumbnails.html?data=pg-southmaui.js'>&nbsp;&#149;&nbsp;South Maui Thumbnails</option>" +
				"<option value='ss.html?data=pg-westmaui.js|3'>&nbsp;&#149;&nbsp;West Maui Slide Show</option>" +
				"<option value='thumbnails.html?data=pg-westmaui.js'>&nbsp;&#149;&nbsp;West Maui Thumbnails</option>" +
				"<option value='ss.html?data=pg-northmaui.js|3'>&nbsp;&#149;&nbsp;North Maui Slide Show</option>" +
				"<option value='thumbnails.html?data=pg-northmaui.js'>&nbsp;&#149;&nbsp;North Maui Thumbnails</option>" +
				"<option value='ss.html?data=pg-bigisle.js|3'>&nbsp;&#149;&nbsp;Hawaii Big Island Slide Show</option>" +
				"<option value='thumbnails.html?data=pg-bigisle.js'>&nbsp;&#149;&nbsp;Hawaii Big Island Thumbnails</option>" +
				"<option value='ss.html?data=pg-japan.js|3'>&nbsp;&#149;&nbsp;Japan Slide Show</option>" +
				"<option value='thumbnails.html?data=pg-japan.js'>&nbsp;&#149;&nbsp;Japan Thumbnails</option>" +
				"<option value='ss.html?data=pg-tahiti.js|3'>&nbsp;&#149;&nbsp;Tahiti Slide Show</option>" +
				"<option value='thumbnails.html?data=pg-tahiti.js'>&nbsp;&#149;&nbsp;Tahiti Thumbnails</option>" +

		"</select>" +
	"</form>" +
	"";
}

//--------------------------------------------------------------------------------------

function getFormatedDate( theDate ) {

	var date = new Date( theDate );
	var unForYear = "" + date.getYear();
	var forYear = unForYear.substring( unForYear.length - 2 );

	return "" + ( date.getMonth() + 1 ) + "/" + date.getDate() + "/" + forYear;
}


//---------------------------------------------------------------------------------------
// Updated 3/11/06
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 ); }
}
//--------------------------------------------------------------------------------------
// Always returns false
function goToPrvPage() {

	var thisPW = "";
	var pwCookie = GetCookie( "PrivateListingsPW" );

	if( pwCookie == PrivateListingsPW ) thisPW = PrivateListingsPW;
	else thisPW = prompt( "Password Provided by Tropical Villa Vacations:", "" );

	if ( thisPW == PrivateListingsPW ) {
		document.location.href = "listings.html?show=pv";
		return false;
	}
	else {
		resetPullDown( "top" );
		resetPullDown( "bot" );
		if( thisPW ) alert( "Sorry, but \"" + thisPW + "\" is not the correct password..." );
		return false
	}

}
//---------------------------------------------------------------------------------------
// Loads page from onChange event in Take Me To pull-down
function goTo( PullDown ) {

	var val = PullDown[ PullDown.selectedIndex ].value;

	if( val ) {

		var page = val;
		var nPopUp = 0;

		if( val.indexOf( "|" ) >= 0 ) {
			var Val = val.split("|" );
			page = Val[ 0 ];
			nPopUp = parseInt( Val[ 1 ] );
		}

		if( nPopUp ) { // PopUp Win
			if( nPopUp == 2 )
				PopUp.openWin( page, 0, 0, 1, 0, 600, 300, 1, 1, 2 );
			else
				PopUp.openWin( page, nPopUp );
		}


		else { // In-line page

			// Selected Availability Calendar from pull-down
			if( /^calendar\./i.test( page ) ) {
				var cal = ( window.writeP ) ? "calendar.aspx" : "calendar.html";
				document.location.href = cal;
			}
			else {
				if( fileName == "calendar-villa.aspx" && calModified )
					return unpublishedOnClick( page );
				if( val.indexOf( "?show=pv" ) >= 0 ) // Private listings requested
					return goToPrvPage();
				else
					document.location.href = page;
			}
		}

	}
}
//--------------------------------------------------------------------------------------
// Pull down disable if w/i frameset since it's impossible to clear frames if user navigates this way...

function getPullDown( pullDownID ) { // args are top OR bot

	var htm = "" +

	"<select name='" + pullDownID + "' id='select_" + pullDownID + "' onChange='goTo( this );' class='pullDown'>" +

		"<option value=''>Take me to...</option>" +

		// Options defined in data/global-data.js
		Pull_Down +

	"</select>";

	return htm;
}



////////////////////////////// START EMBEDDED SLIDE SHOW: SS //////////////////////////////

/*
ACCESSOR VAR: local, winIE, MZ, SF
ACCESSOR FUN: Image Library Functions
ACCESSOR CLS:
MUTATOR  FUN: getImage, showMsg, preLoadNext, stop
*/

//--------------------------------- OBJECT CONSTRUCTOR ---------------------------------

function SlideShow() {

	this.dissolveSF = 1;

	this.imageDir = SSImageArr[ SSImageArr.length - 1 ][ 0 ];
	this.speedNorm = SSImageArr[ SSImageArr.length - 1 ][ 1 ];
	this.showStatus = SSImageArr[ SSImageArr.length - 1 ][ 2 ];
	this.showConsole = SSImageArr[ SSImageArr.length - 1 ][ 3 ];
	this.imgFiltNum = SSImageArr[ SSImageArr.length - 1 ][ 4 ];
	this.imgFiltDur = SSImageArr[ SSImageArr.length - 1 ][ 5 ];
	this.borderWid = SSImageArr[ SSImageArr.length - 1 ][ 6 ];
	this.randomStart = SSImageArr[ SSImageArr.length - 1 ][ 7 ];
	SSImageArr.length = SSImageArr.length - 1;
	this.slideNum = ( this.randomStart ) ? Math.floor( Math.random() * SSImageArr.length ) : 0;
	this.nFirstSlide = this.slideNum;
	this.speedActual = this.speedNorm;
	this.SPEED_FAST = 1000;
	this.preLoadTimer = 0;
	this.NextImage = null;
	this.slideDelay = 0;
	this.maxImgArea = 1000 * 1000;

	// Methods...
	this.showSlide = showSlide;
	this.skipErrantSlide = skipErrantSlide;
	this.preLoadNext = preLoadNext;
	this.imgClickHandler = imgClickHandler;
	this.stop = stop;
	this.getImage = getImage;
	this.showMsg = showMsg;
	this.getImgPos = getImgPos;
	this.moveImgOverlay = moveImgOverlay;
	window.onresize = this.moveImgOverlay;
	//------------------------------------ METHOD: SS ------------------------------------

	function getImgPos( TheImage ) {

		// MZ/SF Only; get on screen position of image so we can lay new one on top
		var x = 0; var y = 0;
		TheElement = TheImage;
		var posImgPar =  TheImage.parentNode.style.position;
		while( TheElement ) {
			if( SF && posImgPar == "absolute" && TheElement == document.body ) break;
			y += TheElement.offsetTop;
			x += TheElement.offsetLeft;

			// remd by DR 9/16/2009
			// y -= TheElement.scrollTop;
			// x -= TheElement.scrollLeft;

			TheElement = TheElement.offsetParent;
		}
		return[ x, y ];

	}
	//------------------------------------ METHOD: SS ------------------------------------

	// MZ/SF Only; called onresize
	function moveImgOverlay() {
		if( SS.ImgOverlay ) {
			var ImgPos = SS.getImgPos( document.images.slideShow );
			SS.ImgOverlay.style.left = ImgPos[ 0 ] + "px";
			SS.ImgOverlay.style.top = ImgPos[ 1 ] + "px";
		}

	}
	//------------------------------------ METHOD: SS ------------------------------------
	function showSlide() {

		if( this.NextImage ) {

			this.showMsg();
			var TheImage = document.images.slideShow;

			var newImgArea = ( TheImage.width + ( 2 * this.borderWid ) ) * ( TheImage.height + ( 2 * this.borderWid ) );

			if( winIE && this.imgFiltNum >= 1 && this.speedActual > this.SPEED_FAST )
				dissolveDirectX( TheImage, this.NextImage.src, this.borderWid, SSImageArr[ this.slideNum ][ 2 ], this.imgFiltNum, this.imgFiltDur );

			else if( ( ( MZ && newImgArea <= this.maxImgArea ) || ( SF && this.dissolveSF ) ) && this.imgFiltNum >= 1 && this.speedActual > this.SPEED_FAST ) {

				var nNewImg = ( SSImageArr.length == this.slideNum ) ? 0 : this.slideNum;
				var nOldImg = ( nNewImg == 0 ) ? SSImageArr.length - 1 : nNewImg - 1;
				TheImage.src = this.imageDir + SSImageArr[ nOldImg ][ 0 ];

				if( this.borderWid )
					TheImage.style.borderColor = "rgb( " + getRGB( SSImageArr[ nOldImg ][ 2 ] ) + " )";

				var opac = getOpacity( this.dissolveSF, 1 );

				var imgStyle = ( this.borderWid ) ? " style='border:" + this.borderWid + "px solid rgb(" + getRGB( SSImageArr[ nNewImg ][ 2 ] ) + ");" + opac + "'" : " style='" + opac + "'";

				var newImg = "<img name='slideShowNew' src='" + this.imageDir + SSImageArr[ nNewImg ][ 0 ] + "' width='" + TheImage.width + "' height='" + TheImage.height + "' alt='" + TheImage.alt + "' title='" + TheImage.title + "'" + imgStyle + " onmousedown='SS.imgClickHandler( event );'>";

				if( !SS.ImgOverlay ) {
					SS.ImgOverlay = document.createElement( "DIV" );
					document.body.appendChild( SS.ImgOverlay );
					SS.ImgOverlay.style.zIndex = -1;
					SS.ImgOverlay.style.position = "absolute";
				}

				var ImgPos = SS.getImgPos( TheImage );

				SS.ImgOverlay.style.left = ImgPos[ 0 ] + "px";
				SS.ImgOverlay.style.top = ImgPos[ 1 ] + "px";

				SS.ImgOverlay.innerHTML = newImg;
				fadeIn( SS.ImgOverlay.firstChild );

			}
			else { // macIE or no transitions
				if( this.ImgOverlay ) {
					document.body.removeChild( this.ImgOverlay );
					this.ImgOverlay = null;
				}
				TheImage.src = this.NextImage.src;
				if( this.borderWid )
					TheImage.style.borderColor = "rgb( " + getRGB( SSImageArr[ this.slideNum ][ 2 ] ) + " )";
			}

		}

	}
	//------------------------------------ METHOD: SS ------------------------------------
	function showMsg() {

		if( this.showStatus || this.showConsole ) {
			var msg = SSImageArr[ this.slideNum ][ 1 ].replaceLiteral( "^", "\"" );
			var colon = ( msg ) ? ": " : "";
			var slideNumDisplay = this.slideNum - this.nFirstSlide + 1;
			if( slideNumDisplay < 1 ) slideNumDisplay = SSImageArr.length + slideNumDisplay;
			var slideCount = "Slide " + slideNumDisplay + " of " + SSImageArr.length
			if( this.showStatus )
				self.status = slideCount + colon + msg;
			if( this.showConsole )
				document.getElementById( "ssConsole" ).innerHTML = slideCount + colon + msg;
		}
	}
	//------------------------------------ METHOD: SS ------------------------------------
	function skipErrantSlide() {
		if( SS.speedActual == SS.SPEED_FAST ) alert( "Slide #" + SS.slideNum + "; " + SS.NextImage.src + " failed to load" );
		SS.NextImage = null;
	}

	//------------------------------------ METHOD: SS ------------------------------------

	function preLoadNext() {

		var recursionTimer = 500;

		this.slideDelay += recursionTimer;

		if( !this.NextImage ) {

			this.slideNum++;
			if( this.slideNum == SSImageArr.length ) this.slideNum = 0;
			this.NextImage = new Image( document.slideShow.width, document.slideShow.height );
			this.NextImage.onerror = this.skipErrantSlide;
			this.NextImage.src = this.imageDir + SSImageArr[ 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();
		}
		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 == this.speedNorm ) {
				top.document.title = "ADMIN: Slide-Show running at high-speed, click image while holding " + ( ( e.ctrlKey ) ? "\"Ctrl\"" : "\"Cmd\"" ) + " to revert to normal speed...";
				this.speedActual = this.SPEED_FAST;
			}
			else {
				top.document.title = "Slide-Show running at normal speed";
				this.speedActual = this.speedNorm;
			}
			self.status = top.document.title;
		}
		if( e.shiftKey ) {
			if( this.preLoadTimer ) {
				top.document.title = "ADMIN: Slide-Show paused, click image while holding \"Shift\" to resume...";
				this.stop();
			}
			else {
				top.document.title = "Slide-Show running...";
				this.preLoadNext();
			}
			self.status = top.document.title;
		}
	}
	//------------------------------------ METHOD: SS ------------------------------------
	function stop() { clearTimeout( this.preLoadTimer ); this.preLoadTimer = 0; 	}
	//------------------------------------ METHOD: SS ------------------------------------

	function getImage( imgWid, imgHgt, toolTip ) {


		return "<img name='slideShow' src='" + this.imageDir + SSImageArr[ this.slideNum ][ 0 ] + "' onError='skipErrantSlide(); preLoadNext(); slideDelay = speedActual + 1;' width='" + imgWid + "' height='" + imgHgt + "' alt='" + toolTip + "' title='" + toolTip + "' onmousedown='SS.imgClickHandler( event );' galleryimg='no' onAbort='this.src=this.src;'>";

	}
}

/////////////////////////////// END EMBEDDED SLIDE SHOW: SS //////////////////////////////

//Updated 3/9/06
//////////////////////////////// START DYNAMIC MENU ////////////////////////////////

/*
ACCESSOR VARIABLES: IE, MZ, winIE, macIE, SF
ACCESSOR FUNCTIONS: None
CLASSES           : .dm*
*/

//-------------------------------- OBJECT CONSTRUCTOR DM --------------------------------

function DynamicMenu( FormElements ) {

	this.homePage = "index.html";

	// Begin User Settings; Menu items defined in data/global-data.js
	this.Links = new Array();

	this.Links[ "hawaii" ] = Menu_Hawaii;

	this.Links[ "aboutUs" ] = Menu_AboutUs;

	this.Links[ "contact" ] = Menu_Contact;

	this.formElements = ( FormElements ) ? FormElements : [ [ "aboutUs", "select_bot" ], [ "hawaii", "botPD" ], [ "hawaii", "select_bot" ], [ "hawaii", "gallery" ] ];


	// Do not edit past this line -------------------------
	this.Menu = null;
	this.OldLink = null;
	this.timer = 0;
	this.start = start;
	this.hide = hide;
	this.killOthers = killOthers;
	this.keepInWin = keepInWin;
	this.show = show;
	this.setElemVis = setElemVis;
	this.resetTimer = resetTimer;

	//------------------------------------- METHOD DM -------------------------------------
	function start( Link, theEvent, arrName, menuPosition ) {
		killOthers( Link );
		show( Link, theEvent, arrName, menuPosition );
	}
	//------------------------------------- METHOD DM -------------------------------------
	function hide( delay ) {
		if( !arguments.length ) delay = 1000;
		if( DM.timer == 0 && DM.Menu ) {
			DM.timer = setTimeout( "" +
				"DM.Menu.innerHTML = '';" +
				"DM.Menu = null;" +
				"DM.timer = 0;" +
				"DM.setElemVis( '', 'visible' );",
				delay
			);
		}
	}
	//------------------------------------- METHOD DM -------------------------------------
	function killOthers( NewLink ) {
		resetTimer();
		if( DM.Menu && DM.OldLink && DM.OldLink != NewLink ) {
			DM.Menu.innerHTML = '';
			DM.Menu = null;
			DM.timer = 0;
			DM.OldLink = null;
			DM.setElemVis( "", "visible" );
		}
	}
	//------------------------------------- METHOD DM -------------------------------------
	function keepInWin( topEdge, leftEdge, IeBody ) {

		var bodyHgt = ( IE ) ? IeBody.clientHeight : window.innerHeight;
		var bodyWid = ( IE ) ? IeBody.clientWidth : window.innerWidth;

		// Prevent menu from going off bottom & top of page
		var menuHgt = DM.Menu.offsetHeight;
		var yOffset = ( IE ) ? IeBody.scrollTop : window.pageYOffset;
		var vScreenPos = topEdge - yOffset;
		var vSkew = bodyHgt - vScreenPos;
		if( vSkew < menuHgt + 10 ) topEdge -= menuHgt - vSkew + 10; // bottom edge
		else if( vScreenPos < 10 ) topEdge = 10 + yOffset; // top edge

		// Prevent menu from going off right & left edges
		var menuWid = DM.Menu.offsetWidth;
		var xOffset = ( IE ) ? IeBody.scrollLeft : window.pageXOffset;
		var hScreenPos = leftEdge - xOffset;
		var hSkew = bodyWid - hScreenPos;
		if( hSkew < menuWid + 10 ) leftEdge -= menuWid - hSkew + 10; // right edge
		else if( hScreenPos < 10 ) leftEdge = 10 + xOffset; // left edge

		return[ topEdge, leftEdge ];
	}
	//------------------------------------- METHOD DM -------------------------------------
	function show( Link, theEvent, arrName, menuPosition ) {

		if( !DM.Menu ) {

			DM.setElemVis( arrName, "hidden" );

			var e = ( window.event ) ? event : theEvent;

			var nLinks = DM.Links[ arrName ].length - 1;

			var menuTitle = DM.Links[ arrName ][ nLinks ][ 0 ];

			var table = "" +

			"<table align='left' border='0' cellspacing='0' cellpadding='0' class='dmBorder' onMouseover='DM.resetTimer();' onMouseout='DM.hide( 0 );'>";
				for( var i = 0; i < nLinks; i++ ) {

					if( menuTitle && i == 0 ) {
						table +=
						"<tr>" +
							"<td nowrap class='dmTitleBg'>" +
								"<div style='width:100%;'>" +
									"<div class='dmTitleFg'>" + menuTitle + "</div>" +
								"</div>" +
							"</td>" +
						"</tr>";
					}

					table += "<tr align='left' valign='middle'>";

						var content = "link";
						if( DM.Links[ arrName ][ i ][ 1 ] == "-" ) content = "separator";
						else if( DM.Links[ arrName ][ i ][ 1 ] == "text" ) content = "text";

						var target = ( DM.Links[ arrName ][ i ][ 4 ] ) ? DM.Links[ arrName ][ i ][ 4 ] : "_self";
						var domTarget = ( target.indexOf( "_" ) == 0 ) ? target.substring( 1, target.length ) : "parent." + target;

						var thePage = eval( domTarget + ".document.location.href" );
						var newPage = eval( "!" + domTarget + ".document.location.hash" );

						var pageShowing = ( ( thePage.substring( thePage.length - DM.Links[ arrName ][ i ][ 1 ].length, thePage.length ) == DM.Links[ arrName ][ i ][ 1 ] && newPage ) || ( thePage.charAt( thePage.length - 1 ) == "/" && DM.Links[ arrName ][ i ][ 1 ] == DM.homePage ) || DM.pageShowing == DM.Links[ arrName ][ i ][ 1 ] );
						var selfStatusCode = "";

						if( DM.Links[ arrName ][ i ][ 2 ] && !pageShowing )
								selfStatusCode = "self.status = \"" + DM.Links[ arrName ][ i ][ 2 ] + "\"; ";

						var mouseOutCode = ( DM.Links[ arrName ][ i ][ 2 ] ) ? "self.status = \"\"; " : "";

						var cursorType = ( pageShowing ) ? "default" : ( IE ) ? "hand" : "pointer";

						var onClickMore = ( DM.Links[ arrName ][ i ][ 3 ] ) ? DM.Links[ arrName ][ i ][ 3 ] : " return true;";

						/////////////// MAKE MENU LINK ///////////////
						if( content == "link" ) { table +=

							"<td nowrap class='dmMenuBgOff' onMouseOver='" + selfStatusCode + "firstChild.firstChild.className=\"" + ( ( pageShowing ) ? "dmMenuFgDisable" : "dmMenuFgOn" ) + "\"; className=\"" + ( ( pageShowing )  ? "dmMenuBgOff" : "dmMenuBgOn" ) + "\"; return true;' onMouseOut='" + mouseOutCode + "firstChild.firstChild.className=\"" + ( ( pageShowing ) ? "dmMenuFgDisable" : "dmMenuFgOff" ) + "\";  className=\"dmMenuBgOff\"; return true;'>" +

								"<a href='" + ( ( pageShowing ) ? "javascript:void(0);" : DM.Links[ arrName ][ i ][ 1 ] ) + "' TARGET='" + target + "' style='text-decoration:none;' onClick='if( href != \"javascript:void(0);\" ) { DM.hide( 0 ); DM.pageShowing = this.href; if( fileName == \"calendar-villa.aspx\" ) return unpublishedOnClick( this.href ); } else return false;' onMouseOver='style.cursor = \"" + cursorType + "\"; return true;'>" +

									"<div style='width:100%;' class='" + ( ( pageShowing ) ? "dmMenuFgDisable" : "dmMenuFgOff" ) + "'>" +
										"" + DM.Links[ arrName ][ i ][ 0 ] + "" +
									"</div>" +

								"</a>" +

							"</td>";
						}
						/////////////// MAKE SEPARATOR ///////////////
						else if( content == "separator" ) { table +=
							"<td align='center' class='dmMenuBgOff'>" +
								"<table border='0' cellspacing='0' cellpadding='0' style='width:100%; margin:2px 0px 2px 0px;'>" +
									"<tr>" +
										"<td style='height:1px; width:100%;' class='dmSepCol'></td>" +
									"</tr>" +
								"</table>" +
							"</td>";
						}
						/////////////// MAKE READ-ONLY CONTENT ///////////////
						else {  table +=
							"<td align='center' class='dmMenuBgOff'>" +
								"<div class='dmTxt' onClick='self.status=\"" + DM.Links[ arrName ][ i ][ 2 ] + "\"; return true;' onMouseout='self.status=\"\"; return true;'>" +
									DM.Links[ arrName ][ i ][ 0 ] +
								"</div>" +
							"</td>";
						}

					table += "</tr>";
				}

			table += "</table><br>"; // Trailing <br> for macIE

			DM.Menu = document.createElement( "DIV" );
			document.body.appendChild( DM.Menu );

			DM.OldLink = Link;
			DM.Menu.style.zIndex = 20000;
			DM.Menu.style.visibility = "hidden";
			DM.Menu.style.position = "absolute";
			DM.Menu.style.top = ( screen.height * -1 ) + "px";
			DM.Menu.style.left = ( screen.width * -1 ) + "px";
			DM.Menu.innerHTML = table;

			var ieCSS = ( IE && document.compatMode) ? document.compatMode ==  "CSS1Compat" : false;
			var IeBody = null;
			if( IE ) IeBody = ( ieCSS ) ? document.documentElement : document.body;

			var useLnkPos = ( winIE || MZ || SF ), useEvtPos = !useLnkPos;

			var x = 0, y = 0;
			if( useEvtPos || menuPosition == "relative" ) {
				x = ( IE ) ? e.clientX + IeBody.scrollLeft : e.pageX;
				y = ( IE ) ? e.clientY + IeBody.scrollTop  : e.pageY;
			}
			else {
				var ThisLink = Link;
				var parPosAbs = false;
				while( ThisLink ) {
					if( SF ) {
						if( !parPosAbs ) parPosAbs = ( ThisLink.style.position == "absolute" );
						if( parPosAbs && ThisLink == document.body ) break;
					}
					y += ThisLink.offsetTop;
					x += ThisLink.offsetLeft;
					ThisLink = ThisLink.offsetParent;
				}
			}

			switch( menuPosition ) {

				case "relative":
					var topEdge = ( IE ) ? e.clientY + IeBody.scrollTop : e.pageY;
					topEdge += DM.Links[ arrName ][ nLinks ][ 1 ][ 1 ];
					var leftEdge = ( IE ) ? e.clientX + IeBody.scrollLeft : e.pageX;
					leftEdge += DM.Links[ arrName ][ nLinks ][ 1 ][ 0 ];
					break;

				case "aboveRel":
					var topEdge = ( IE ) ? e.clientY + IeBody.scrollTop : e.pageY;
					topEdge = topEdge - DM.Links[ arrName ][ nLinks ][ 6 ][ 1 ] - DM.Menu.offsetHeight;
					var leftEdge = ( IE ) ? e.clientX + IeBody.scrollLeft : e.pageX;
					leftEdge += DM.Links[ arrName ][ nLinks ][ 6 ][ 0 ];
					break;

				case "above":
					var skewY = ( useEvtPos ) ? parseInt( Link.offsetHeight / 2 ) : 0;
					var skewX = ( useEvtPos ) ? parseInt( DM.Menu.offsetWidth / 2 ) : 0;
					var topEdge = y - skewY - DM.Menu.offsetHeight + DM.Links[ arrName ][ nLinks ][ 2 ][ 1 ];
					var leftEdge = x - skewX + DM.Links[ arrName ][ nLinks ][ 2 ][ 0 ];
					break;

				case "right":
					var skewX = ( useEvtPos ) ? Link.offsetWidth : 0;
					var topEdge = y + DM.Links[ arrName ][ nLinks ][ 3 ][ 1 ];
					var leftEdge = x - skewX + Link.offsetWidth + DM.Links[ arrName ][ nLinks ][ 3 ][ 0 ];
					break;

				case "below":
					var skewY = ( useEvtPos ) ? parseInt( Link.offsetHeight / 2 ) : 0;
					var skewX = ( useEvtPos ) ? parseInt( DM.Menu.offsetWidth / 2 ) : 0;
					var topEdge = y - skewY + Link.offsetHeight + DM.Links[ arrName ][ nLinks ][ 4 ][ 1 ];
					var leftEdge = x - skewX + DM.Links[ arrName ][ nLinks ][ 4 ][ 0 ];
					break;

				case "left":
					var topEdge = y + DM.Links[ arrName ][ nLinks ][ 5 ][ 1 ];
					var leftEdge = x - DM.Menu.offsetWidth + DM.Links[ arrName ][ nLinks ][ 5 ][ 0 ];
					break;

				default:
					alert( "SWITCH/CASE ERROR: menuPosition \"" + menuPosition + "\" is invalid." );

			}
			var MenuPos = DM.keepInWin( topEdge, leftEdge, IeBody );
			DM.Menu.style.top = MenuPos[ 0 ] + "px";
			DM.Menu.style.left = MenuPos[ 1 ] + "px";
			DM.Menu.style.visibility = "visible";

		}
	}
	//------------------------------------- METHOD DM -------------------------------------

	function setElemVis( arrName, vis ) {
		if( winIE && DM.formElements ) {
			for( member in DM.formElements ) {
				if( vis == "visible" || arrName == DM.formElements[ member ][ 0 ] ) {
					if( document.getElementById( DM.formElements[ member ][ 1 ] ) )
						document.getElementById( DM.formElements[ member ][ 1 ] ).style.visibility = vis;
				}
			}
		}
	}
	//------------------------------------- METHOD DM -------------------------------------
	function resetTimer() {
		clearTimeout( DM.timer );
		DM.timer = 0;
	}
}

////////////////////////////////// END DYNAMIC MENU //////////////////////////////////

function blinkSpecial() {
	var calPage = ( document.location.pathname.indexOf( "calendar" ) >= 0 );
	if( MakeSpecialsBlink && !calPage ) {
			if( qStr && qStr.indexOf( "CONTEXT=popup" ) == -1 || !qStr ) {
			var Label = document.getElementById( "specials" );
			if( winIE ) {
				if( Label.style.visibility == "visible" ) {
					eval( "try{ Label.filters(0).Stop(); } catch( e ){}" );
					Label.style.filter = "blendTrans( duration='0.3' )";
					eval( "try{ Label.filters(0).Apply(); } catch( e ){}" );
					Label.style.visibility = "hidden";
					eval( "try{ Label.filters(0).Play(); } catch( e ){}" );
				}
				else {
					eval( "try{ Label.filters(0).Stop(); } catch( e ){}" );
					Label.style.filter = "blendTrans( duration='0.3' )";
					eval( "try{ Label.filters(0).Apply(); } catch( e ){}" );
					Label.style.visibility = "visible";
					eval( "try{ Label.filters(0).Play(); } catch( e ){}" );

				}
			}
			else {
				if( Label.style.visibility == "visible" ) Label.style.visibility = "hidden";
				else Label.style.visibility = "visible";
			}
			setTimeout( "blinkSpecial()", ( ( winIE ) ? 1000 : 800 ) );
		}
	}
}

//--------------------------------------------------------------------------------------

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:" + TVV.WebErrorEmail.unscramble() + "?subject=" + escape( "Tropical Villa Vacations" + "; " + sub ) + "&body=" + escape( msg + " \n\nDIAGNOSTICS: This info may be used to help us troubleshoot technical problems" + diagnostics );
}

// Updated 3/11/06
//////////////////////////////// START DYNAMIC INDEX DI ////////////////////////////////

/*

ACCESSOR VARIABLES: None
ACCESSOR FUNCTIONS: Cookie
ACCESSOR STYLES: di*, img.borderOn, img.borderOff
*/

//-------------------------------- OBJECT CONSTRUCTOR DI --------------------------------

function DynamicIndex() {

	// Begin User Settings -------------------------
	this.msg = new Array();
	this.msg.show = "Click to open...";
	this.msg.hide = "Click to close...";

	// Do not edit past this line -------------------------
	this.getPlusMinus = getPlusMinus;
	this.reset = reset;
	this.switchDisplay = switchDisplay;
	this.showTip = showTip;
	this.init = init;


	//------------------------------------ METHOD DI ------------------------------------

	function init() {

		// 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 ){};
					}
				}
			}
		}
	}

	//------------------------------------ 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 ) ? "borderOn" : "borderOff";

		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;
			self.status = ( msgOn ) ? msgOn : DI.msg.show;
		}
		else {
			Link.title = ( msgOff ) ? msgOff : DI.msg.hide;
			self.status = ( msgOff ) ? msgOff : DI.msg.hide;
		}

	}

}
//////////////////////////////// END DYNAMIC DI ////////////////////////////////


//--------------------------------------------------------------------------------------

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;
}

//--------------------------------------------------------------------------------------

function getCloseLinkDW( divStyle ) {
	return "" +
	"<div style='" + divStyle + "'>" +
		"<a href='javascript:DW.removeWin();' onMouseOver='self.status=this.title; return true;' onMouseOut='self.status=\"\"; return true;' title='Close this pop-up window' class='dwCloseLink'>Close</a>" +
	"</div>";
}

///////////////////////////////// DYNAMIC WINDOW DW /////////////////////////////////
// Updated 10/31/2006
/*
	ACCESSOR VARS:  IE, MZ, SF, winIE
	ACCESSOR FUNC:  None
	ACCESSOR CLASS: dw*, off
*/

//--------------------------------- OBJECT CONSTRUCTOR DW ---------------------------------

function DynamicWindow( transNum, transDur ) {

	// 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.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;

	// 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;
	this.dissolve = dissolve;

	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 ) {

		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 && this.dissolve( winWid, winHgt ) );
			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 ) ? ( 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 = 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 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 );
			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 = 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 && this.dissolve( Photo.width, Photo.height ) );
			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 ) {

		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;
			// 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 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 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 = 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 + document.body.scrollLeft ) + "px";
				this.Window.style.top = ( event.clientY - this.dWinOffsetY + document.body.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; }

	//------------------------------------- METHOD DW -------------------------------------

	function dissolve( wid, hgt ) {
		var imgArea = wid * hgt;
		var maxImgArea = 500 * 500;
		return ( imgArea <= maxImgArea );
	}

}

////////////////////////////////// END DYNAMIC WINDOW //////////////////////////////////
