/*

PROBLEM: If you are reading this program code it's probably because you are still using
Netscape 3 which has a bug that sometimes displays this code rather than the site itself!!!

SOLUTION: Go to the Netscape Menu Item called "Options", then select "Network Preferences",
then click the "Languages" tab and now uncheck "Enable JavaScript". Now click your "Back" button.

*/

var useLayers = false;
var ver = "unknown";

var theAppVersion = navigator.appVersion;
var bName = navigator.appName;
var bVer = parseInt(theAppVersion);
var exactVer = parseFloat(navigator.appVersion);
dHTML = false;

if (bName == "Microsoft Internet Explorer") {
	var splitAppVersion = theAppVersion.split('MSIE');
	bVer = parseInt( splitAppVersion[1] );
	exactVer = parseFloat( splitAppVersion[1] );
	if(bVer >= 5) ver = "e5";
	else ver = "e4";
	dHTML = true;
}

else if (bName == "Netscape") {
	if (bVer == 4) useLayers = true;
	if (bVer >= 4) ver = "n4";
}
//ver = "n6"
currentBrowser = true;
//----------------------------------------------------------------------------------------

var runningLive = false;
if( document.location.hostname.length > 0 ) runningLive = true;

window.onerror = errorHandler;

function errorHandler(msg, url, line) {
	if ( !runningLive ) alert("\rError Trapped: " + msg + "\r\rURL: " + url + "\r\rLine: " + line);
	return true;
}
//---------------------------------------------------------------------------------------
// "Internal" function to return the decoded value of a cookie
function getCookieVal (offset) {
  var endstr = document.cookie.indexOf (";", offset);
  if (endstr == -1)
    endstr = document.cookie.length;
  return unescape(document.cookie.substring(offset, endstr));
}
//----------------------------------------------------------------------------------------
function FixCookieDate (date) {
  var base = new Date(0);
  var skew = base.getTime(); // dawn of (Unix) time - should be 0
  if (skew > 0)  // Except on the Mac - ahead of its time
    date.setTime (date.getTime() - skew);
}
//----------------------------------------------------------------------------------------
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 ();
FixCookieDate (expdate); // Correct for Mac date bug - call only once for given Date object!
expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 365 * 1000)); // 1 year from now

//---------------------------------------------------------------------------------------
var newWin = null;

function openWin( theSite, tool, loc, menu, winSize ) {

	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;
	}

	newWin = window.open("","new_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+"");

	newWin.location.href = theSite;

	newWin.focus();
}
function closeWin() { if( newWin != null ) newWin.close(); }
//--------------------------------------------------------------------------------------

var dText = new Array(
	"&nbsp;", // 0
	"Enjoy Maui - the way it used to be...", // 1
	"See maps showing where we're located", // 2
	"View Outside Pictures", // 3
	"View Inside Pictures", // 4
	"Check our booking calendar for availability", // 5
	"Get our rates and make a reservation", // 6
	"Return to our Home Page...", // 7
	"Read what our Guests have said about us", // 8
	"Send us e-mail, please use \"Rates & Reservations\" for initial inquiries", // 9
	"Click map to view it full size...", // 10
	"Learn about specials we are offering!", // 11
	"Please read our Terms and Conditions", // 12
	"Things To Do On Maui", // 13
	"Visit our Guest Book" // 14

);
//----------------------------------------------------------------------------------------
function getBotCallout() {

	var callout = '<BR>';

	if( ver == "e4" || ver == "e5" )
		callout = '<DIV ID="botCallout" CLASS="bodyText" STYLE="margin:15px;">&nbsp;</DIV>';
	else if( useLayers ) {
		callout = '<ILAYER NAME=masterLayer visibility=show>';
		for( i = 0; i <= 11; i++ ) // Build and place in masterLayer container...
			callout += '<LAYER NAME=myBotLayer' + i + ' visibility=hide><TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN=center><SPAN CLASS=dText>' + dText[ i ] + '</SPAN></TD></TR></TABLE></LAYER>'
		callout += '</ILAYER><BR><BR>';
	}

	return callout;
}
//----------------------------------------------------------------------------------------
function getTopCallout( length ) {

	var vertSkew = 180;
	var callout = '';

	if( ver == "e4" || ver == "e5" )
		callout = '<SPAN CLASS="dText" STYLE="position:absolute; left:391px; top:' + vertSkew + 'px;">&#151;&#151;&#151; <SPAN ID="callout" CLASS="dText" STYLE="position:relative; top:0px; left:0px;">' + dText[1] + '</SPAN></SPAN><BR>';
		// Keep trailing <BR>; otherwise ie4 table "jumps" up & down...
	else if( useLayers ) { // N4 only
		for( i = 1; i <= length; i++ ) { // Build layers...
			callout += '<LAYER NAME=myLayer' + i + ' visibility=hide TOP=' + (vertSkew + 1) + ' LEFT=391><FONT SIZE=2 FACE="arial, helvetica" COLOR=#ffff66>&#151;&#151;&#151; ' + dText[ i ] + '</FONT></LAYER>'
			//alert( callout );
		}
	}
	else { // Any other browser, N6 etc.
		callout = '<SPAN CLASS="dText" STYLE="position:absolute; left:391px; top:' + (vertSkew + 1) + 'px;">&#151;&#151;&#151; <SPAN ID="callout" CLASS="dText" STYLE="position:relative; top:0px; left:0px;">' + dText[1] + '</SPAN></SPAN><BR>';
	}
	return callout;
}
//--------------------------------------------------------------------------------------
var timeoutBot;
function activateBottomMsg( index ) {

	clearTimeout(timeoutBot);
	if( dHTML ) botCallout.innerHTML = dText[ index ];
	else if( useLayers ) {
		hideBotLayers();
		document.masterLayer.layers[ 'myBotLayer' + index ].visibility = 'show';
	}
}

var staticMsgBot = '';

function deActivateBottomMsg( index ) {
	staticMsgBot = dText[ index ];
	if( dHTML ) timeoutBot = setTimeout('botCallout.innerHTML = staticMsgBot', 500);
	else if( useLayers )
		timeoutBot = setTimeout( 'hideBotLayers(), document.masterLayer.visibility = "hide"', 500 );
}

function hideBotLayers() {
	for( i = 0; i < document.masterLayer.layers.length; i++ ) {
		if( document.masterLayer.layers[ i ].name.indexOf( 'myBotLayer' ) == 0 )
		 document.masterLayer.layers[ i ].visibility = 'hide';
	}
}
//--------------------------------------------------------------------------------------
var timeoutTop;
function activateTopMsg( index ) {

	clearTimeout(timeoutTop);
	if( dHTML ) callout.innerHTML = dText[ index ];
	else if( useLayers ) {
		hideTopLayers();
		document.layers[ 'myLayer' + index ].visibility = 'show';
	}
}

var staticMsgTop = '';
var layerIndex = -1;
function deActivateMsg( index ) {
	staticMsgTop = dText[ index ];
	if( dHTML ) timeoutTop = setTimeout('callout.innerHTML = staticMsgTop', 500);
	else if( useLayers ) {
		layerIndex = index + 2;
		timeoutTop = setTimeout( 'hideTopLayers(), document.layers[ layerIndex ].visibility = "show"', 500 );
	}
}
function hideTopLayers() {
	for( i = 0; i < document.layers.length; i++ ) {
		if( document.layers[ i ].name.indexOf( 'myLayer' ) == 0 )
		 document.layers[ i ].visibility = 'hide';
	}
}
function initTopLayer() {
	if( useLayers ) document.layers[ 3 ].visibility = 'show';
}
//----------------------------------------------------------------------------------------

var hibiscusOn = new Image();  hibiscusOn.src = "images/hibiscusOn.gif";
var hibiscusOff = new Image(); hibiscusOff.src = "images/hibiscusOff.gif";
//--------------------------------------------------------------------------------------
function actHibiscus(imgName) { document[imgName].src = eval( "hibiscusOn.src" ); }
function deActHibiscus(imgName) { document[imgName].src = eval( "hibiscusOff.src" ); }

function actImage(imgName) { document[imgName].src = eval( imgName + "On.src" ); }
function deActImage(imgName) { document[imgName].src = eval( imgName + "Off.src" ); }
//--------------------------------------------------------------------------------------
function imageViewer( imgInfo ) {

	SetCookie("imgInfo", imgInfo, null, "/");
	if ( GetCookie("imgInfo") == imgInfo ) { // if cookies are on...

		 var theHost = document.location.hostname;

		//alert('_' + theHost + '_');

		if( theHost.length == 0 )
			theURL = "image_viewer.php";
		else theURL = "image_viewer.php";
			//theURL = "http://" + theHost + "/image_viewer.html";

		document.location.href = theURL;
		return false;
	}
	else // cookies off
		return true;
}
