///////////////////////////// WEB SOFTWARE BY DAVID REGIER /////////////////////////////
///////////////////////////// http://www.ctpmaui.com/david /////////////////////////////
///////////////////// UNAUTHORIZED USE OF THIS CODE IS PROHIBITED /////////////////////

//--------------------------------------------------------------------------------------
function ContactInfo() {

	this.Owner = "Toni Rojas";
	this.CompName = "A Perfect Maui Wedding";
	this.PhoneTollFree = "";
	this.Phone = "(808) 573-7626";
	this.Fax = "(808) 573-7627";
	this.PO = "";
	this.City = "";
	this.Island = "";
	this.State = "";
	this.Zip =  "";
	this.Email = "toni@perfectmauiwedding.com";
	this.WebAddress = "www.perfectmauiwedding.com";
	this.StreetAddress = "";
}

var CI = new ContactInfo();

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

var TAX_RATE = 0.04167;
var taxRatePercent = ( 100 * TAX_RATE ) + "%";
var DEPOSIT = 500;
var COMMISSION = 0.20;
var commPercent = ( 100 * COMMISSION ) + "%";
var COORD_FEE = 450;
var OUTSTANDING_DUE = "Outstanding balance due one month prior to wedding";
var PRICE_STARTS_AT = "Submit this order and we'll get you an exact price which will be subject to your approval. ";
var PRICE_INQUIRY = "Inquiry for Price: Submit this order and we'll get you a price which will be subject to your approval. ";
var NO_COMM = "No commission on this item. ";

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

cb = true;

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

var NC = false; var NC4 = false; var NC6 = false; var NC7 = false;
var IE = false; var IE4 = false; var IE5 = false;
var SF = false;

if( bName == "Microsoft Internet Explorer" ) {
	exactVer = parseFloat( navigator.appVersion.split( "MSIE" )[ 1 ] );
	if( document.getElementById ) IE5 = true;
	else IE4 = true;
	IE = true;
}
else if( theAppVersion.indexOf( "Safari" ) >= 0 )
	SF = true;
else if( bName == "Netscape" ) {
	if( theUserAgent.lastIndexOf( "Netscape" ) >= 0 ) { // NC6 or NC7
		var nInfo = theUserAgent.split( "Netscape" )[ 1 ];
		var slash = ( nInfo.indexOf( "/" ) >= 0 ) ? true : false;
		exactVer = ( slash ) ? parseFloat( nInfo.split( "/" )[ 1 ] ) : parseFloat( nInfo );
		bVer = parseInt( exactVer );
		if( bVer >= 7 ) NC7 = true;
		else if( bVer == 6 ) NC6 = true;
	}
	NC = true;
}

var dHTML_DOM = ( document.getElementById ) ? true : false;
var dHTML_IE4 = ( !dHTML_DOM && document.all ) ? true : false;
var dHTML = ( dHTML_DOM || dHTML_IE4 ) ? true : false;

var macOS = ( os.indexOf( "Mac" ) == 0 ) ? true : false;
var macIE = ( macOS && IE );
var winOS = ( os.indexOf( "Win" ) == 0 ) ? true : false;
var winIE = ( winOS && IE );
var bDoesTrans = ( IE5 && winOS ) ? true : false;
var ieTrans = ( IE5 && winOS );
var ncTrans = ( NC && winOS );

var theHost = document.location.hostname.toLowerCase();
var local = ( theHost.length == 0 || theHost == "127.0.0.1" ) ? true : false;
var live = !local;

//if( live && theHost.indexOf( "www.perfectmauiwedding.com" ) == -1 )
	//top.document.location.replace( "http://www.perfectmauiwedding.com/" );

oldBrowserMsg = '';
//----------------------------------------------------------------------------------------

window.onerror = errorHandler;

function errorHandler( msg, url, line ) {
	if ( local ) {
		alert("Error Trapped: " + msg + "\n\nURL: " + url + "\n\nLine: " + line)
		if( NC6 ) return false;
	}
	return true;
}
/*
//----------------------------------------------------------------------------------------

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 ) return false;
  }
  else if( event.button == 2 || event.button == 3 ) {
    event.cancelBubble = true; event.returnValue = false; return false;
  }
}

if( window.Event ) { // NC4 & 6
	document.captureEvents( Event.MOUSEUP );
	document.captureEvents( Event.MOUSEDOWN );
}

if( live ) {
	document.oncontextmenu = noContextMenu;
	document.onmousedown = noRightClick;
	document.onmouseup = noRightClick;
}
*/
//----------------------------------------------------------------------------------------

if( NC4 ) { // overwrite css classes n4 can't handle
	document.write( "<STYLE>.mainLinks{ padding:0px; }</STYLE>" );
	document.write( "<STYLE>.botLink { color:#ffffff; padding-right:0px; padding-left:0px; }</STYLE>" );
}

	var marginTop = 0;

	var sHgt = screen.height;

	if( sHgt < 553 ) marginTop = 0;
	else if( sHgt <= 600 ) marginTop = 30;
	else if( sHgt <= 768 ) marginTop = 110;
	else marginTop = 140;
//---------------------------------------------------------------------------------------

function getValueFromKey( key, strToSearch, eqDelim, fieldDelim ) {

	var value = null;
	var lookUpPattern = key + eqDelim;

	// If lookUpPattern is found
	if( strToSearch.indexOf( lookUpPattern ) != -1 ) {

		// if string has more than 1 key/value pair
		if( strToSearch.indexOf( fieldDelim ) != -1 ) {
			var searchArr = strToSearch.split( fieldDelim );
			for( var i = 0; i < searchArr.length; i++ ) {
				if( searchArr[ i ].indexOf( lookUpPattern ) == 0 ) {
					value = searchArr[ i ].split( eqDelim )[1];
					break;
				}
			}
		}
		else // There is only one key/value pair in strToSearch
			value = strToSearch.split( eqDelim )[1];
	}
	if( typeof value == "undefined" ) value = null; //N6 problem
	return value;
}

//--------------------------------------------------------------------------------------
var ImgReal = null;
function checkDim( imgNameToCk, imgWidToCk, imgHgtToCk ) {

	if( ImgReal == null ) {
		ImgReal = new Image();
		ImgReal.src = eval( "document.images." + imgNameToCk + ".src;" );
	}
	if( ImgReal.complete ) {
		var realWid = ImgReal.width;
		var realHgt = ImgReal.height;
		if( realWid > 1 && realHgt > 1 ) {
			if( imgWidToCk != realWid || imgHgtToCk != realHgt )
				alert( ImgReal.src + " has incorrect dimensions set:\n\n• " + imgWidToCk + "×" + imgHgtToCk + " are the errant values\n• " + realWid + "×" + realHgt + " are the true values" );
		}
		ImgReal = null;
	}
	else {
		this.imgNameToCk = imgNameToCk;
		this.imgWidToCk = imgWidToCk;
		this.imgHgtToCk = imgHgtToCk;
		setTimeout( "checkDim( imgNameToCk, imgWidToCk, imgHgtToCk );", 500 );
	}
}

//////////////////////////////// START IMAGE VIEWER: IV ////////////////////////////////

/*
ACCESSOR CLS: off, on, ivLgImgMargin, ivLgImgTitle
ACCESSOR FUN: checkDim, getObject, getTransition, randompick, replaceLiteral
ACCESSOR VAR: macIE, IE, ieTrans, ncTrans
*/

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

function ImageViewer() {

	this.transNum = 0;
	this.transDur = 0.8;

	this.Link = null;
	this.setSectVis = setSectVis;
	this.hideOtherPhotos = hideOtherPhotos;
	this.show = show;
	this.hideLgImg = hideLgImg;
	this.startFilter = startFilter;
	this.setImgTitle = setImgTitle;
	this.Photo = null;
	this.opacity = 0;
	this.opacityTimer = 0;
	this.scrollFromTop = 0;
	this.scrollFromLeft = 0;

	//-------------------------------------- METHOD --------------------------------------
	// Loops thru any section(s) that are to be hidden when large image is displayed AND
	// Loops thru any section(s) that are to be re-shown when large image is is hidden

	function setSectVis( sectName, className ) {
		var i = 0;
		while( getObject( sectName + i ) ) {
			Section = getObject( sectName + i );
			Section.className = className;
			i++;
		}
	}
	//-------------------------------------- METHOD --------------------------------------
	// Loops thru other open photos (if any) and hides them.
	// Keeps more than 1 large photos from showing simultaneously

	function hideOtherPhotos( tnPage ) {
		if( document.getElementById && !tnPage ) {
			var OtherDivs = document.getElementsByTagName( "DIV" );
			for( var i = 0; i < OtherDivs.length; i++ ) {
				if( OtherDivs[i].id.indexOf( "bigIV" ) == 0 )
					this.hideLgImg( OtherDivs[i].id.substring( 5, OtherDivs[i].id.length ) );
			}
		}
	}
	//-------------------------------------- METHOD --------------------------------------
	// [ 'images/', 'princeWFReid.jpg', 347, 351, 'Maui Prince', 'b', 1, LinkObj , 'sectName' ]
	//      0               1           2    3           4       5   6     7           8

	// Displays full size image on the current page
	function show( ImgInfoArr ) {

		if( document.getElementById ) {

			// Record where page is scrolled to so it can be reset back later
			var ieCSS = ( IE && document.compatMode) ? document.compatMode ==  "CSS1Compat" : false;
			if( IE ) var IeBody = ieCSS ? document.documentElement : document.body;
			this.scrollFromTop = ( IE ) ? IeBody.scrollTop : window.pageYOffset;
			this.scrollFromLeft = ( IE ) ? IeBody.scrollLeft : window.pageXOffset;

			var tnPage = ( ImgInfoArr[ 8 ] == "thumbnails" ) ? true : false;

			if( tnPage ) this.Link = ImgInfoArr[ 7 ];

			this.hideOtherPhotos( tnPage );
			var sectName = ImgInfoArr[ 8 ];
			this.setSectVis( sectName, "off" );

			switch( ImgInfoArr[ 5 ] ) {
				case "w": ImgInfoArr[ 5 ] = "255,255,255"; break;
				case "b": ImgInfoArr[ 5 ] = "0,0,0"; break;
			}

			var imgFilter = "";

			if( ieTrans ) imgFilter = "visibility:hidden; filter:" + getTransition( this.transNum,this.transDur );
			else if( ncTrans ) imgFilter = "-moz-opacity:0";

			var html = ( tnPage ) ? "<DIV ID='bigIV" + sectName + "' STYLE='position:absolute; top:50%; left:50%; margin-left:-" + ( ImgInfoArr[ 2 ] / 2 ) + "px; margin-top:-" + ( ImgInfoArr[ 3 ] / 2 + 20 ) + "px;'>" : "<DIV ID='bigIV" + sectName + "' CLASS='ivLgImgMargin'>";

			if( tnPage ) {

				// Evaluate & set global stmts from arrGlobalInfo
				for( i = 0; i < arrGlobalInfo.length - 1; i++ ) eval( arrGlobalInfo[ i ] );

				var BodyStyle = document.body.style;
				BodyStyle.backgroundImage = "url( none )";
				BodyStyle.backgroundColor = bkgColOnTN;
				BodyStyle.marginTop = "0px";
				BodyStyle.marginRight = "0px";
				BodyStyle.marginBottom = "0px";
				BodyStyle.marginLeft = "0px";

				if( macIE )
					html = "<DIV ID='bigIV" + sectName + "'>" + "<TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0' WIDTH='100%' HEIGHT='" + ( document.body.clientHeight - 60 ) + "'><TR><TD ALIGN='center' VALIGN='middle'>";
				if( !WRITE_TN_IMAGE_TITLE ) ImgInfoArr[ 4 ] = "&nbsp; <BR>";
			}

				html +=
				"<TABLE BORDER='0' CELLSPACING='0' CELLPADDING='0'>" +
					"<TR>" +
						"<TD>" +
							"<A HREF='javascript:void(0);' ID='topFocalPt'></A><BR>" +
						"</TD>" +
					"</TR>" +
					"<TR>";

						var bkgStyle = ( tnPage ) ? " STYLE='background-color:" + bkgColOnTN + ";'" : " ";
						html +=
						"<TD ALIGN='center'" + bkgStyle + ">" +
							"<A HREF='javascript:IV.hideLgImg( \"" + sectName + "\" );' onMouseOver='self.status=this.title; return true;' onMouseOut='self.status=\"\"; return true;' TITLE='Click to go back'" + bkgStyle + "><IMG NAME='" + sectName + "IV' SRC='" + ImgInfoArr[ 0 ] + ImgInfoArr[ 1 ] + "' BORDER='0' WIDTH='" + ImgInfoArr[ 2 ] + "' HEIGHT='" + ImgInfoArr[ 3 ] + "' HSPACE=0 VSPACE=0 STYLE='border:" + ImgInfoArr[ 6 ] + "px solid rgb( " + ImgInfoArr[ 5 ] + " ); float:left; " + imgFilter + ";' onAbort='this.src=this.src;' onLoad='checkDim( \"" + sectName + "IV\", " + ImgInfoArr[ 2 ] + ", " + ImgInfoArr[ 3 ] + " ); if( ieTrans || ncTrans ) IV.startFilter( this ); IV.setImgTitle( \"" + ImgInfoArr[ 4 ] + "\" );'></A>" +
						"</TD>" +
					"</TR>" +
					"<TR>" +
						"<TD ALIGN='center'>" +
							"<DIV ID='imgTitleIV' CLASS='ivLgImgTitle'>Loading image, please wait...</DIV><DIV STYLE='line-height:4px;'> &nbsp;</DIV>" +
						"</TD>" +
					"</TR>" +
					"<TR>" +
						"<TD ALIGN='center'>" +
							"<A HREF='javascript:IV.hideLgImg( \"" + sectName + "\" );' onMouseOver='self.status=this.title; return true;' onMouseOut='self.status=\"\"; return true;' TITLE='Click photo to go back to thumbnail' ID='botFocalPt'>Back</A>" +
						"</TD>" +
					"</TR>" +
				"</TABLE><BR>";

			if( macIE && tnPage ) html += "</TD></TR></TABLE><BR>";
			html += "</DIV>";
			var ImgConsole = getObject( sectName );
			ImgConsole.innerHTML = html;
			ImgConsole.className = "on";
			var FocuserBot = getObject( "botFocalPt" ); FocuserBot.focus();
			var FocuserTop = getObject( "topFocalPt" ); FocuserTop.focus();
			return false;
		}
		else { // Old Browsers
			document.location.href = ImgInfoArr[ 0 ] + ImgInfoArr[ 1 ];
			return false;
		}
	}

	//-------------------------------------- METHOD --------------------------------------
	// Set page back to default state by hiding large image
	function hideLgImg( sectName ) {

		var tnPage = ( sectName == "thumbnails" ) ? true : false;
		var ImgConsole = getObject( "bigIV" + sectName );
		ImgConsole.innerHTML = "";
		ImgConsole.className = "off";
		if( tnPage ) {
			var BodyStyle = document.body.style;
			BodyStyle.backgroundImage = TN_PAGE_STYLE.bkgImg;
			BodyStyle.backgroundColor = TN_PAGE_STYLE.bkgCol;
			BodyStyle.marginTop = TN_PAGE_STYLE.marTop;
			BodyStyle.marginRight = TN_PAGE_STYLE.marRgt;
			BodyStyle.marginBottom = TN_PAGE_STYLE.marBot;
			BodyStyle.marginLeft = TN_PAGE_STYLE.marLft;
		}

		IV.setSectVis( sectName, "on" );
		if( tnPage && typeof this.Link == "object" ) {
			this.Link.focus();
			this.Link.blur();
		}
		// Scroll window back to where it was before
		window.scroll( this.scrollFromLeft, this.scrollFromTop );
	}
	//-------------------------------------- METHOD --------------------------------------
	function startFilter( Photo ) {
		if( ieTrans ) {
			eval( "" +
				"try {" +
					"Photo.filters(0).apply();" +
					"Photo.style.visibility = 'visible';" +
					"Photo.filters(0).play();" +
				"}" +
				"catch( e ) { Photo.style.visibility = 'visible'; }" +
			"" );
		}
		else {

			Photo.onload = function() { /*cancel photo onload function*/ }
			Photo.style.MozOpacity = this.opacity;
			this.opacity += .05;

			if( IV.opacity < 1 ) {
				this.Photo = Photo;
				IV.opacityTimer = setTimeout( "IV.startFilter( IV.Photo )", 40 );
			}
			else {
				Photo.style.MozOpacity = 0.9999; // 1.0 causes flicker
				clearTimeout( IV.opacityTimer );
				IV.opacity = 0;

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

	function setImgTitle( imgTitle ) {
		var ImgTitle = getObject( "imgTitleIV" );
		imgTitle = imgTitle.replaceLiteral( '^^', "'" );
		imgTitle = imgTitle.replaceLiteral( '^', '"' );
		ImgTitle.innerHTML = imgTitle + "<DIV STYLE='line-height:4px;'> &nbsp;</DIV>";

	}
}
var IV = new ImageViewer();
////////////////////////////////// END IMAGE VIEWER: IV //////////////////////////////////

function getHelpLink() {

	return "<A HREF='javascript:openWin(\"help.html\", \"0\", \"0\", \"1\", \"0\", 0.70 );' onMouseOver='self.status=dText[ 12 ]; return true;' onMouseOut='self.status=\"\"; return true;' TITLE='" + dText[ 12 ] + "'><NOBR CLASS='smLink' onMouseOver='linkOn(this); return true;' onMouseOut='linkOff(this); return true;'>Help</NOBR></A><SPAN CLASS='horBar'> &#149; </SPAN>";
}
//--------------------------------------------------------------------------------------
function getErrLink() {

	recipient = "david" +
	"@" +
	"creativetouchphoto.com";

	var eURL = "http://www.creativetouchphoto.com/other/error.html?" + escape( "recipient»" + recipient + "¦subject»APMW Web Site Problem¦referrer»" + document.location.href + "¦top»" + parent.document.location.href + "¦compName»A Perfect Maui Wedding" );

	return getHelpLink() + "<A HREF='javascript:openWin(\"" + eURL + "\", \"0\", \"0\", \"1\", \"0\", 0.70 );' onMouseOver='self.status=\"Report a technical problem to the Web Master\"; return true;' onMouseOut='self.status=\"\"; return true;' TITLE='Report a technical problem to the Web Master'><NOBR CLASS='smLink' onMouseOver='linkOn(this); return true;' onMouseOut='linkOff(this); return true;'>Report a Problem</NOBR></A>";
}
//--------------------------------- OBJECT CONSTRUCTOR ---------------------------------
// ACCESOR FUNCTIONS: getObject
// ACCESSOR CLASSES: offP, onP
function PrinterFriendly() {

	this.dText = [
		"Printer-Friendly", // 0
		"Reformat Page Back To Default Web-Layout", // 1
		"Compacts page and maximizes it for your printer..", // 2
		"Reformat page back to default \"web\" layout..." // 3
	];

	this.getElemArr = getElemArr;
	this.setView = setView;
	this.printPage = printPage;

	//-------------------------------------- METHOD --------------------------------------
	// Scans page and returns array of elements (as objects) that start with elemNameStr
	function getElemArr( elemNameStr ) {

		var elemArr = new Array();

		if( dHTML_DOM ) var allElements = document.getElementsByTagName( "*" );
		else var allElements = document.all;

		var k = 0;

		for ( var i = 0; i < allElements.length; i++ ) {
			if( allElements[ i ].id.indexOf( elemNameStr ) == 0 ) {
				elemArr[ k ] = allElements[ i ];
				k++;
			}
		}

		return elemArr;
	}
	//-------------------------------------- METHOD --------------------------------------
	function setView( ThisPrnFrnLink, bkgImg, printPullDowns ) {

		var hide = ( ThisPrnFrnLink.innerHTML == this.dText[ 0 ] ) ? true : false;

		var prnFrnLinksArr = getElemArr( "printer_friendly" );

		for( member in prnFrnLinksArr ) {
			if( hide ) {
				prnFrnLinksArr[ member ].innerHTML = this.dText[ 1 ];
				prnFrnLinksArr[ member ].title = this.dText[ 3 ];
			}
			else {
				prnFrnLinksArr[ member ].innerHTML = this.dText[ 0 ];
				prnFrnLinksArr[ member ].title = this.dText[ 2 ];
			}
		}

		// If there are pull-downs then get their text values and display them so they print
		if( hide ) {
			if( typeof document.cart == "object" && printPullDowns ) {
				var cartElements = document.cart.elements;

				for( var k = 0; k < cartElements.length; k++ ) {
					if( cartElements[ k ].type == "select-one" ) {
						var ThisPullDown = cartElements[ k ];
						var html = "<BR>";
						for( var j = 1; j < ThisPullDown.length; j++ )
							html += "<NOBR>•&nbsp;" + ThisPullDown[ j ].text + "</NOBR><BR>";

						var consoleID = "CONSOLE_PRN_" + ThisPullDown.name;
						var ConsolePrn = getObject( consoleID );
						ConsolePrn.innerHTML = html;

					}
				}
			}
		}
		// Reset all consoles back to default empty string values
		else {
			var consoleArr = getElemArr( "CONSOLE_PRN_" );
			for( member in consoleArr ) consoleArr[ member ].innerHTML = "";
		}

		var divArr = getElemArr( "PRN_" );

		// Show or Hide all elements starting with "PRN_"
		for( member in divArr ) {
			if( hide ) divArr[ member ].className = "offP";
			else divArr[ member ].className = "onP";
		}

		if( hide ) {
			if( bkgImg ) document.body.style.backgroundImage = "url( none )";
		}
		else {
			if( bkgImg ) document.body.style.backgroundImage = "url( " + bkgImg + " )";
		}
		if( ThisPrnFrnLink.focus ) {
			ThisPrnFrnLink.focus();
			ThisPrnFrnLink.blur();
		}
	}
	//-------------------------------------- METHOD --------------------------------------
	function printPage( TheLink ) {
		if( window.print && TheLink.innerHTML == this.dText[ 1 ] ) {
			document.title += "; " + CI.TEL_TOLL_FREE + " & " + CI.TEL_DIRECT;
			self.print();
		}
	}
}

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

function writeFooter() {

	var footer = "" +
		"<SPAN ID='PRN_Footer_APMW'>" +
			"<DIV ALIGN='center' CLASS='normFaint'>" +
				"A PERFECT MAUI WEDDING&nbsp;&nbsp;&#149;&nbsp;&nbsp;(808) 573-7626 DIRECT";

				footer += ( dHTML ) ?"&nbsp;&nbsp;&#149;&nbsp;&nbsp;MAUI TIME: <SPAN ID='time'>&nbsp;</SPAN>" : "";

			footer += "</DIV>" +

			"<DIV CLASS='vSpacer5'>&nbsp; </DIV>" +
		"</SPAN>"

	document.write( footer );

}
//----------------------------------------------------------------------------------------
function musicLoaded() {
	if( typeof music_frame == "object" && typeof music_frame.initialized == "boolean" ) return true;
	else return false;
}

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

function getObject( strObjName ) {
	return ( dHTML_DOM ) ? document.getElementById( strObjName ) : eval( strObjName );
}


function getSub() { return ( dbLoaded() ) ? getData( "SubTotal" ) : "dbNotLoaded"; }
//----------------------------------------------------------------------------------------
function dbLoaded() {
	return ( myPar && eval( "typeof parent.hid_frame" ) == "object" && eval( "typeof parent.hid_frame.initialized" ) == "boolean" ) ? true : false;
}

// All access to Data Base pass through these 3 functions and they must
// only be called when dbLoaded() returns true

function getData( fieldName ) { // Accessor
	return eval( "parent.hid_frame.document.form." + fieldName + ".value" );
}

function setData( fieldName, fieldVal ) { // Modifier
	eval( "parent.hid_frame.document.form." + fieldName + ".value  = fieldVal" );
}

// Returns entire db as an object which can be used as an Accessor or Modifier;
function getDB() { return parent.hid_frame.document.form; }

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

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

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.trimStr = trimString;

//---------------------------------------------------------------------------------------
var perfWin = null;
function openWin( theSite, tool, loc, status, menu, winSize ) {

	closeWin();

	if( !window.print ) { // It's important that user can print these pop-ups...
		if( theSite == "contact-info.html" || theSite == "terms_conditions.html" || theSite == "card.html" ) { tool = 1; menu = 1; }
	}

	var wid = 800 * 1.1 * winSize;
	var hgt = 450 * winSize;

	// Works on AOL, IE, N6 & NC4
	// IE Makes pop up same size as INNER DIMENSIONS of parent window.
	// AOL makes pop up same exact size as parent since toobars etc. don't attribute to inner dim of AOL window

	if( winSize == 1 ) { // Make a full size pop-up...
		if( IE ) {
			var aolCookie = GetCookie( "AOL" );
			var AOL = ( aolCookie == null || aolCookie == "true" ) ? true : false;
			wid = ( AOL ) ? document.body.clientWidth : screen.availWidth - 10;
			hgt = ( AOL ) ? document.body.clientHeight : screen.availHeight - 50;
		}
		else { // NC4 & 6
			var hSkew = ( NC6 ) ? 50 : 100;
			wid = screen.availWidth - 10;
			hgt = screen.availHeight - hSkew;
		}
	}

	var scroll = ( theSite == 'cart-popup.html' ) ? '0' : '1';
	var resize = ( theSite == 'cart-popup.html' ) ? '0' : '1';

	perfWin = window.open("","perf_window","toolbar="+tool+",location="+loc+",directories=0,status="+status+",menubar="+menu+",scrollbars="+scroll+",resizable="+resize+",width="+wid+",height="+hgt+",top=0,left=0");

	perfWin.location.href = theSite;
	focusWin();
}

function closeWin() {
	if( popUpIsOpen() ) {
		perfWin.close();
		perfWin = null;
	}
}
function focusWin() {
	if( popUpIsOpen() && ( eval( "typeof perfWin.registered" ) == 'boolean' ) )
		perfWin.focus();
	else setTimeout( "focusWin()", 100 );
}

function popUpIsOpen() {

	theConditions = 0;

	if( !macOS ) {
		theConditions++;
		if( perfWin != null ) {
			theConditions++;
			if( perfWin.open ) {
				theConditions++;
				if( !perfWin.closed ) {
					theConditions++;
				}
			}
		}
	}
	return ( theConditions == 4 ) ? true : false;
}

function linkToPopUp() {
	if( eval( "typeof perfWin.registered" ) == "boolean" && perfWin.registered )
		perfWin.myOpener = self;
	else
		setTimeout( "linkToPopUp()", 250 );
}

//----------------------------------------------------------------------------------------
function showImg( imgInfo ) {
	openWin( "image_viewer.html?" + escape( imgInfo ), 0, 0, 1, 0, 1 );
	linkToPopUp();
	return false;
}
//----------------------------------------------------------------------------------------
function showStatus() {
	setTimeout("self.status = 'A Perfect Maui Wedding - accept nothing less...'", 500);
}

//----------------------------------------------------------------------------------------
// "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 expOneYear = new Date ();
var expOneMonth = new Date ();
FixCookieDate (expOneYear); // Correct for Mac date bug
FixCookieDate (expOneMonth); // Correct for Mac date bug
expOneYear.setTime (expOneYear.getTime() + (24 * 60 * 60 * 365 * 1000));
expOneMonth.setTime (expOneMonth.getTime() + (24 * 60 * 60 * 30 * 1000));
//----------------------------------------------------------------------------------------

//Refresh cookies...
var pmwClientCookie = GetCookie("pmwClientCookie");
if( pmwClientCookie && !myPar )
	SetCookie("pmwClientCookie", pmwClientCookie, expOneYear, "/");


//----------------------------------------------------------------------------------------
var pmwCartCookie = GetCookie( "pmwCartCookie" );

function checkCartCookies() {

	if( pmwCartCookie && !myPar ) {
		alert( "Aloha & greetings from " + CI.Owner + " at " + CI.CompName + ". Per your request, I am about to set up your shopping cart as you left it on your last visit.\n\n==> Click \"OK\" then wait while I set up your shopping cart for today's visit..." );
		document.location.href = "home.html?page=cart.html";
	}

}
if( !NC6 ) checkCartCookies(); // NC6 calls from onLoad of index.html; otherwise it hangs...
//---------------------------------------------------------------------------------------

function linkOn( link ) {
	if( dHTML ) {

		switch( link.id ) {
			case "top":
				link.style.backgroundColor = "rgb( 240,240,240 )"; link.style.color = "rgb( 0,0,0 )"; break;
			case "bot":
				link.style.backgroundColor = "rgb( 153,153,240 )";  link.style.color = "rgb( 255,255,255 )"; break;
			default:
				link.style.backgroundColor = "rgb( 255,255,204 )"; link.style.color = "rgb( 0,0,0 )"; break;

		}
	}
}

function linkOff( link, bkgCol ) {
	if( dHTML ) {

		switch( link.id ) {
			case "top":
				link.style.backgroundColor = "transparent"; link.style.color = "rgb( 102,102,102 )"; break;
			case "bot":
				link.style.backgroundColor = "rgb( 153,153,204 )"; link.style.color = "rgb( 255,255,255 )"; break;
			default:
				link.style.backgroundColor = "transparent"; link.style.color = "rgb( 0,0,255 )"; break;

		}
	}
}

//---------------------------------------------------------------------------------------
var dText = new Array(
	" &nbsp;",
	"Complete wedding coordination for the most discriminating bride & groom...",
	"Goes back to our home page...",
	"Learn about your Wedding Planner - " + CI.Owner + "...",
	"You'll love viewing our &#34;real-life&#34; wedding photos with our automated slide-show",
	"Maui's Wailea-Makena area offers first-class hotels on lovely white sand beaches...",
	"Hawaii’s exotic tropical flowers are a perfect compliment for your wedding ensemble",
	"Photography & Video: We provide our clients with Maui's finest Artisans...",
	"Customize & upgrade your wedding: Cakes, Officiants, Limos, Doves, Music...",
	"Check out our complete wedding packages, from simple-elegance to extraordinary!",
	"View or edit items in your shopping cart...",
	"Submit your shopping cart order or make a wedding inquiry...",
	"About using shopping cart, submitting tentative orders & more...",
	"Click to view this image full size...",
	"View or edit items in your shopping cart...", // Called by cart.html
	"Loads Site Designer's web site...",
	"Back to the last page you were on...",
	"Goes right into the directory where the slide show images are stored...",
	"EZ visual instructions for AOL users unable to view the slide show images...",
	"click to add this item to your shopping cart...",
	"You'll love our quick loading \"location\" slide shows...",
	"Send e-mail, please use the Inquiry Form for all initial inquiries...",
	"You'll love our quick loading \"floral\" slide show...",
	"Frequently Asked Questions & tips about planning your Maui Wedding",
	"Goes to our &#34;main&#34; slide-show - sit back, relax, turn on the music & enjoy...",
	"Any order that does not inlude a package is subject to a Coordination Fee",
	"Click to view image...",
	"PLEASE NOTE: A " + commPercent + " coordination fee is added to all individual (non-package) items",
	"Need a fresh start? Then empty all items from your cart!",
	"Finished Ordering? Go to our Checkout Stand to submit it...",
	"Remove this item from your shopping cart",
	"Change quantity of this item...",
	"Any transaction where a service is performed in Hawaii is taxable",
	"About saving your cart for future visits & how it works...",
	"Close this \"pop-up\" window",
	"Get our Contact Info: Phone, Fax, Address, E-mail...",
	"Provide written authorization to charge your credit card",
	"Terms & Conditions - about how we do business",
	"View thumbnails on a \"click to enlarge\" page",
	"View images with our automated slide-show",
	"Read descriptions & view wedding location photos...",
	"Get prices & info",
	"Hide prices & info",
	"Compacts page and maximizes it for your printer..",
	"Reformat page back to default \"web\" layout...",
"place holder"
	);

//----------------------------------------------------------------------------------------
function writeCallout( calloutId, textAlign, textCol ) {

	var html = "";

	if( dHTML )
		html = "<DIV CLASS='" + calloutId + "Text' ID='" + calloutId + "'> &nbsp;</DIV>";

	else if( NC4 ) {

		var tag1 = "";
		var tag2 = "";
		if( textAlign == "center" ) {
			tag1 = "<TABLE WIDTH=100% BORDER=0 CELLPADDING=0 CELLSPACING=0><TR><TD ALIGN=center>";
			tag2 = "</TD></TR></TABLE>";
		}
		var name1 = "masterTopLayer";
		var name2 = "myTopLayer";
		if( calloutId == "calloutBot" ) {
			name1 = "masterBotLayer";
			name2 = "myBotLayer";
		}
		var fontSize = 2;
		html = "&nbsp;<ILAYER NAME=" + name1 + " visibility=show>";
		for( i = 0; i < dText.length; i++ ) {  // Build layers...
			html += "<LAYER NAME=" + name2 + "" + i + " visibility=hide>" + tag1 + "<FONT SIZE=" + fontSize + " FACE='arial, helvetica' COLOR=" + textCol + ">" + dText[ i ] + "</FONT>" + tag2 + "</LAYER>";
		}
		html += "</ILAYER><BR>";
	}

	//alert(html)
	document.write( html );
}
//--------------------------------------------------------------------------------------
// turns on top or bottom nav link messages on all pages.
// Cart has it's own function: activateCartMsg( index ) for cart messages

var timeout = 0;

function activateMsg( callout, index ) {

	if( index == 10 ) {
		var subTot = getSub();
		if( subTot != "dbNotLoaded" ) {
			if( dHTML ) dText[10] = "View & edit your shopping cart. Your Running Subtotal: $" + subTot;
			self.status = "Your Running Subtotal: $" + subTot;
		}
	}

 	clearTimeout( timeout );

	if( dHTML ) {
		var Callout = getObject( callout );
		if( eval( "typeof Callout" ) == "object" )
			Callout.innerHTML = dText[ index ];
	}

	else if( NC4 ) {
		if( callout == "calloutTop" ) {
			hideTopLayers( 0 );
			document.masterTopLayer.layers[ "myTopLayer" + index ].visibility = "show";
		}
		else {
			hideBotLayers( 0 );
			document.masterBotLayer.layers[ "myBotLayer" + index ].visibility = "show";
		}
	}
}

//--------------------------------------------------------------------------------------
// turns off top or bottom nav link messages on all pages.
// Cart has it's own function: deActivateCartMsg() for cart messages

function deActivateMsg( callout, index ) {
	self.status = " ";
	this.index = index;
	if( dHTML ) {
		var Callout = getObject( callout );
		if( eval( "typeof Callout" ) == "object" ) {
			this.Callout = Callout;
			timeout = setTimeout( "Callout.innerHTML = dText[ index ]", 500 );
		}
	}
	else if( NC4 ) {
		if( callout == "calloutTop" ) timeout = setTimeout( "hideTopLayers( index )", 500 );
		else timeout = setTimeout( "hideBotLayers( index )", 500 );
	}
}
//--------------------------------------------------------------------------------------
function hideTopLayers( index ) {
	for( i = 0; i < document.masterTopLayer.layers.length; i++ ) {
		if( document.masterTopLayer.layers[ i ].name.indexOf( "myTopLayer" ) == 0 )
			document.masterTopLayer.layers[ i ].visibility = "hide";
			document.masterTopLayer.layers[ "myTopLayer" + index ].visibility = "show";
	}
}
//--------------------------------------------------------------------------------------
function hideBotLayers( index ) {
	for( i = 0; i < document.masterBotLayer.layers.length; i++ ) {
		if( document.masterBotLayer.layers[ i ].name.indexOf( "myBotLayer" ) == 0 )
			document.masterBotLayer.layers[ i ].visibility = "hide";
			document.masterBotLayer.layers[ "myBotLayer" + index ].visibility = "show";
	}
}
//--------------------------------------------------------------------------------------

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 getHawaiiTime() {

	var gmtOffset = 10; // for Hawaii
	var now = new Date();
	var difhrs = now.getTimezoneOffset()/60;
	var lochrs = now.getHours();
	GMThours = (difhrs < 0) ? lochrs - difhrs : lochrs + difhrs;
	now.setHours( GMThours - gmtOffset );

	var am_pm = "AM";
	var hours = now.getHours();

	if( hours >= 12 ) am_pm = "PM";
	if( hours >= 13 ) hours -= 12;
	if( hours == 0 ) hours = "12";

	var minutes = now.getMinutes();
	if( minutes < 10 ) minutes = "0" + minutes;

	var seconds = now.getSeconds();
	if( seconds < 10 ) seconds = "0" + seconds;

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

	return mauiTime;
}
//---------------------------------------------------------------------------------------

function showTime() {

	if( dHTML ) {

		var mauiTime = getHawaiiTime();
		var timeObj = null;

		if( dHTML_DOM ) timeObj = document.getElementById( "time" );
		else timeObj = eval( "time" );

		if( typeof timeObj == "object" ) timeObj.innerHTML = mauiTime;
	}
}
//--------------------------------------------------------------------------------------

function launchSS( fileName ) {
	openWin( "ss.html?db=" + fileName, "0", "0", "1", "0", 1.0 );
	linkToPopUp();
}
//--------------------------------------------------------------------------------------

function writePopUpLinks() {

	var html = "<SPAN CLASS='gray'>[ </SPAN>";

	if( window.print)
		html +=		"<A HREF='javascript:self.print();' TITLE='Print this information'><NOBR CLASS='medLink' onMouseOver='linkOn(this); return true;' onMouseOut='linkOff(this); return true;'>Print</NOBR></A><SPAN CLASS='gray'> | </SPAN>";

	html += "<A HREF='javascript:self.close();' TITLE='Close this pop-up window'><NOBR CLASS='medLink' onMouseOver='linkOn(this); return true;' onMouseOut='linkOff(this); return true;'>Close</NOBR></A><SPAN CLASS='gray'> ]</SPAN>";

	document.write( html );
}
//--------------------------------------------------------------------------------------
// Write thank you onto homepage after checkout

function writeThanks() {

	if( myPar ) {

		var qStr = parent.getQueryStr( "visible_frame" )

		var checkedOut = ( qStr && ( qStr.indexOf( "show=pay" ) == 0 || qStr.indexOf( "show=notPay" == 0 ) ) )

		if( checkedOut ) {

			var showPayment = ( qStr.indexOf( "show=pay" ) == 0 ) ? true : false;

			var instruct = "";
			if( showPayment ) {
				openWin('card.html', '0', '0', '0', '0', 0.80 );
				var instruct = "<DIV CLASS='sm'>P.S. If you are ready to provide payment & our payment form didn't auto-load, click the PAY link below</DIV>";
			}

			var html =  "" +

			"<TABLE ALIGN='center' BORDER=0 CELLPADDING=4 CELLSPACING=0>" +
				"<TR>" +
					"<TD CLASS='norm' BGCOLOR='#ffffff'>" +

						"<DIV CLASS='bold'>Mahalo from " + CI.Owner + " at " + CI.CompName + "...</DIV>" +
						"<DIV>&nbsp;&nbsp;&nbsp;&#151; Thanks for your order/inquiry, I'll get back to you right away</DIV>" +

						"<DIV CLASS='vSpacer5'>&nbsp; </DIV>" +

						instruct +

					"</TD>" +
				"</TR>" +
			"</TABLE>" +
			"<BR>";

			marginTop -= 60;

			document.write( html );
		}
	}
}
//---------------------------------------------------------------------------------------

function isMainSite( dataFile ) { return ( dataFile == "ss-pwm-main.js" ) ? true : false; }

//---------------------------------------------------------------------------------------
function getDataFile() {
	var dataFile = "null";
	if( myPar ) {
		var queryString = parent.getQueryStr( "visible_frame" );
		if( queryString != null ) dataFile = queryString.split( "=" )[ 1 ];
	}
	return dataFile;
}
//--------------------------------------------------------------------------------------

function getBackLink() {
	var html = "";
	if( myPar ) {
		// Don't allow visitors to go back to "unframed" index.html; otherwise music stops
		if( !parent.firstPageVisit ) {
			html = "<A HREF='javascript:self.history.back();' onMouseOver='self.status=dText[ 16 ]; return true;' onMouseOut='self.status=\"\"; return true;' TITLE='" + dText[ 16 ] + "'><NOBR CLASS='normLink' onMouseOver='linkOn(this); return true;' onMouseOut='linkOff(this); return true;'>Back</NOBR></A>";
		}
	}
	return html;
}

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

function getThumbnails() {
	document.location.href = ( myPar ) ?  "thumbnails.html?db=ss-pwm-main.js" : "home.html?page=tn-pwm-main";
	return false;
}

//--------------------------------------------------------------------------------------
function borderIm( image, color ) { image.style.borderColor=color; }

var activeColor = "rgb( 0,0,0 )";
var staticColor = "rgb( 245,245,245 )";

if( dHTML )
	var theStyles = ".borderImage{ border:1px solid " + staticColor + "; } ";
else
	var theStyles = ".borderImage{ border:0px } ";

document.write( "<STYLE>" + theStyles + "</STYLE>" );

//---------------------------------------------------------------------------------------
function section( sectionNum, command ) {

	if ( dHTML ) {
		sectionNum = getObject( sectionNum );
		if ( command == "on" ) sectionNum.className="on";
		else sectionNum.className = "off";

	}
}

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

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;
//--------------------------------------------------------------------------------------

function showHidTxt( linkID,
										 consoleID,
										 consoleClassName,
										 consoleTxt,
										 offLinkInnerHTML,
										 onLinkInnerHTML,
										 offToolTip,
										 onToolTip,
										 otherLinks ) {

	consoleTxt = consoleTxt.replaceLiteral( "^", '"' );

	if( dHTML ) {

		var Link = getObject( linkID );
		var Info = getObject( consoleID );
		var showInfo = ( Link.innerHTML == offLinkInnerHTML ) ? true : false;

		if( showInfo ) {

			// Reset all other links on this row back to default state...
			if( otherLinks ) {
				var otherLinkArr = otherLinks.split( "|" );
				for( member in otherLinkArr ) {
					var OtherLink = getObject( otherLinkArr[ member ] );
					OtherLink.innerHTML = offLinkInnerHTML;
					OtherLink.title = onToolTip;
					OtherLink.style.color = "rgb( 0,0,255 )"; // For NC6
					OtherLink.style.backgroundColor = "rgb( 255,255,255 )"; // For NC6
				}
			}

			Link.innerHTML = onLinkInnerHTML;
			Link.title = offToolTip;
			section( consoleID, "on" );
			Info.className = consoleClassName;
			Info.innerHTML = consoleTxt;
			if( !NC6 ) Info.focus();

		}
		else {
			Link.innerHTML = offLinkInnerHTML;
			Link.title = onToolTip;
			section( consoleID, "off" );
			Info.className = "off";
		}
	}
	else
		alert( removeHtmlTags( consoleTxt ) );

}
//--------------------------------------------------------------------------------------

function getPullDownTxt( openTxt, pullDownName, endTxt ) {

	var PullDown = eval( "document.cart." + pullDownName );

	// Must be NC4 and pull down must be in a hidden layer...
	if( eval ( "typeof PullDown" ) != "object" )
		PullDown = eval( "document.layers[ '" + pullDownName + "Layer' ].document.cartHidden." + pullDownName );

	var pullDownTxt = "";
	var nOptions = PullDown.length - 1;

	if( dHTML ) pullDownTxt += "<UL>";

	for( var i = 1; i <= nOptions; i++ ) {

		if( dHTML ) pullDownTxt += "<LI>";
		else pullDownTxt += "\n • ";

		pullDownTxt += PullDown[ i ].text;

	}

	if( dHTML ) pullDownTxt += "</UL>";

	return openTxt + pullDownTxt + endTxt;

}

//--------------------------------------------------------------------------------------
function randompick() {
  return randompick.arguments[ Math.floor( Math.random()*randompick.arguments.length ) ];
}
//--------------------------------------------------------------------------------------
// ACCESSOR VARS: bDoesTrans, exactVer

function getTransition( transNum, duration ) {

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

		if( exactVer >= 5.5 ) {

			var thisTrans = ( transNum == 0 ) ? Math.floor( Math.random() * 17 ) + 1 : transNum;

			switch ( thisTrans ) {
				case 1: trans="Fade(duration="+d+",overlap=1)"; break;
				case 2: trans="Blinds(duration="+d+",bands="+randompick(2,4,6,8)+",direction="+randompick('up','down','right','left')+")"; break;
				case 3: trans="CheckerBoard(duration="+d+",squaresX="+randompick(2,4,8,12)+",squaresY="+randompick(2,4,8,12)+",direction="+randompick('up','down','right','left')+")"; break;
				case 4: trans="Barn(duration="+d+",motion="+randompick('in','out')+",orientation=",randompick('horizontal','vertical')+")"; break;
				case 5: 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 6: trans="Inset(duration="+d+")"; break;
				case 7: trans="Iris(duration="+d+",irisStyle="+randompick('DIAMOND','CIRCLE','CROSS','PLUS','SQUARE','STAR')+",motion="+randompick('in','out')+")"; break;
				case 8: trans="RadialWipe(duration="+d+",wipeStyle="+randompick('CLOCK','WEDGE','RADIAL')+")"; break;
				case 9: trans="RandomBars(duration="+d+",orientation="+randompick('horizontal','vertical')+")"; break;
				case 10: trans="RandomBars(duration="+d+")"; break;
				case 11: trans="Slide(duration="+d+",pushStyle="+randompick('HIDE','PUSH','SWAP')+",bands="+randompick(1,2,3,4,5,6,7)+")"; break;
				case 12: trans="Spiral(duration="+d+",gridSizeX="+randompick(8,16,32,64)+",gridSizeY="+randompick(8,16,32,64)+")"; break;
				case 13: trans="Stretch(duration="+d+",stretchStyle="+randompick('HIDE','PUSH','SPIN')+")"; break;
				case 14: trans="Strips(duration="+d+",motion="+randompick('leftdown','leftup','rightdown','rightup')+")"; break;
				case 15: trans="Wheel(duration="+d+",spokes="+randompick(2,4,10,16,20)+")"; break;
				case 16: trans="Zigzag(duration="+d+",gridSizeX="+randompick(8,16,32,64)+",gridSizeY="+randompick(8,16,32,64)+")"; break;
				case 17: trans="RandomDissolve(duration="+d+")"; break;
        //case 18: 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 1: trans="blendTrans(duration="+d+")"; break;
				default: trans="revealTrans(duration="+d+",transition=" + Math.floor(Math.random()*23) + ")";
			}
		}
	}
	return trans;
}

////////////////////////////// START EMBEDDED SLIDE SHOW: SS //////////////////////////////

/*
ACCESSOR VAR: local, ieTrans, ncTrans
ACCESSOR FUN: replaceLiteral, getTransition
ACCESSOR CLS:
MUTATOR  FUN: getImage, showMsg, preLoadNext, stop
*/

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

function SlideShow() {

	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 ];
	SSImageArr.length = SSImageArr.length - 1;
	this.speedActual = this.speedNorm;
	this.SPEED_FAST = 1000;
	this.preLoadTimer = 0;
	this.NextImage = null;
	this.slideDelay = 0;
	this.slideNum = 0;
	this.opacity = 0;
	this.opacityTimer = 0;
	this.NcOverlay = null;

	// Define methods...
	this.showSlide = showSlide;
	this.skipErrantSlide = skipErrantSlide;
	this.preLoadNext = preLoadNext;
	this.imgClickHandler = imgClickHandler;
	this.stop = stop;
	this.getImage = getImage;
	this.dissolve = dissolve;
	this.getRGB = getRGB;
	this.showMsg = showMsg;
	//-------------------------------------- METHOD --------------------------------------

	function getRGB( abbrev ) {
		var rgb = abbrev;
		switch( abbrev ) {
			case "b": rgb = "0,0,0"; break;
			case "w": rgb = "255,255,255"; break;
		}
		return rgb;
	}
	//-------------------------------------- METHOD --------------------------------------
	function showSlide() {

		if( this.NextImage ) {

			var TheImage = document.images.slideShow;

			var useFilterIE = ( ieTrans && this.imgFiltNum >= 0 && this.speedActual > this.SPEED_FAST );
			var transErr = false;

			if( useFilterIE ) {
				TheImage.style.filter = getTransition( this.imgFiltNum, this.imgFiltDur );
				eval( "try{ TheImage.filters(0).Apply(); } catch( e ){ transErr = true; }" );

				TheImage.src = this.NextImage.src;

				if( this.borderWid )
					TheImage.style.borderColor = "rgb( " + this.getRGB( SSImageArr[ this.slideNum ][ 2 ] ) + " )";

				if( !transErr ) eval( "try{ TheImage.filters(0).Play(); } catch( e ){ /*null action*/; }" );
			}

			else if( ncTrans && this.imgFiltNum >= 0 ) {

				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( " + this.getRGB( SSImageArr[ nOldImg ][ 2 ] ) + " )";

				var imgStyle = ( this.borderWid ) ? " style='border:" + this.borderWid + "px solid rgb(" + this.getRGB( SSImageArr[ nNewImg ][ 2 ] ) + "); -moz-opacity:0;'" : " style='-moz-opacity:0;'";

				var newImg = "<img name='slideShowNew' src='" + this.imageDir + SSImageArr[ nNewImg ][ 0 ] + "' width='" + TheImage.width + "' height='" + TheImage.height + "' alt='" + TheImage.alt + "' title='" + TheImage.title + "'" + imgStyle + ">";

				if( !SS.NcOverlay ) {
					SS.NcOverlay = document.createElement( "DIV" );
					document.body.appendChild( SS.NcOverlay );
					SS.NcOverlay.style.zIndex = 1000;
					SS.NcOverlay.style.position = "absolute";
				}

				// Get on screen position of slide-show image so we can lay new one on top
				var x = 0; var y = 0;
				TheElement = TheImage;
				while( TheElement != document.body ) {
					y += TheElement.offsetTop;
					x += TheElement.offsetLeft;
					y -= TheElement.scrollTop;
					x -= TheElement.scrollLeft;
					TheElement = TheElement.offsetParent;
				}

				SS.NcOverlay.style.top = y + "px";
				SS.NcOverlay.style.left = x + "px";

				SS.NcOverlay.innerHTML = newImg;
				dissolve();

			}
			else { // Macs or no transitions
				TheImage.src = this.NextImage.src;
				if( this.borderWid )
					TheImage.style.borderColor = "rgb( " + this.getRGB( SSImageArr[ this.slideNum ][ 2 ] ) + " )";
			}

			this.showMsg();
		}

	}
	//-------------------------------------- METHOD --------------------------------------
	function showMsg() {

		if( this.showStatus || this.showConsole ) {
			var msg = SSImageArr[ this.slideNum ][ 1 ].replaceLiteral( '^', '"' );
			var colon = ( msg ) ? ": " : "";
			var slideCount = "Slide " + ( this.slideNum + 1 ) + " of " + SSImageArr.length
			if( this.showStatus )
				self.status = slideCount + colon + msg;
			if( this.showConsole )
				document.getElementById( "ssConsole" ).innerHTML = slideCount + colon + msg;
		}
	}
	//-------------------------------------- METHOD --------------------------------------
	function dissolve() { // NC Win Only; Duration: 0.8 seconds
		var NewImg = document.images.slideShowNew;
		NewImg.style.MozOpacity = SS.opacity;
		SS.opacity += .05;
		if( SS.opacity < 1 ) SS.opacityTimer = setTimeout( "SS.dissolve()", 40 );
		else {
			NewImg.style.MozOpacity = 0.9999; // 1.0 causes flicker
			clearTimeout( SS.opacityTimer );
			SS.opacity = 0;
		}
	}
	//-------------------------------------- METHOD --------------------------------------
	function skipErrantSlide() {
		if( local || SS.speedActual == SS.SPEED_FAST ) alert( "Slide #" + SS.slideNum + "; " + SS.NextImage.src + " failed to load" );
		SS.NextImage = null;
	}

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

	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();
			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 --------------------------------------
	function imgClickHandler() {
		if( window.event && event.ctrlKey && event.altKey ) {
			if( this.speedActual == this.speedNorm ) this.speedActual = this.SPEED_FAST;
			else this.speedActual = this.speedNorm;
		}
	}
	//-------------------------------------- METHOD --------------------------------------
	function stop() { clearTimeout( this.preLoadTimer ); 	}
	//-------------------------------------- METHOD --------------------------------------

	function getImage( imgWid, imgHgt, toolTip ) {

		var imgStyle = ( this.borderWid ) ? " style='border:" + this.borderWid + "px solid rgb(" + this.getRGB( SSImageArr[ 0 ][ 2 ] ) + ");'" : "";

		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();'" + imgStyle + " galleryimg='no' onAbort='this.src=this.src;'>";
	}
}

/////////////////////////////// END EMBEDDED SLIDE SHOW: SS //////////////////////////////

function popUp( theURL ) { openWin( theURL, 1, 1, 1, 1, 0.80, 1 ) }

//////////////////////////////// START DYNAMIC MENU ////////////////////////////////
/*
ACCESSOR VARIABLES: IE, NC, winIE, macIE, SF
ACCESSOR FUNCTIONS: None
*/
//--------------------------------- OBJECT CONSTRUCTOR ---------------------------------

function DynamicMenu( objName ) {


	// Begin User Settings
	this.Links = new Array();

	if( parent == self ) { // Not framed, just arrived on homepage

		this.Links[ "photos" ] = [
			[ "Slide-Show", "home.html?page=ss-pwm-main", "View photos with our automated slide-show" ],
			[ "Thumbnails", "javascript:getThumbnails();", "View photos on a traditional \\&#34;click-to-enlarge\\&#34; page" ],
			[  "",        8,     [0,0],   [0, 5], [0, 0], [0, 0], [0,0] ]
			// Title, fontSize, relative, above,  right,  below,  left: [xPos, yPos]
		];

		this.Links[ "alacarte" ] = [
			[ "Wedding Cakes", "home.html?page=alacarte.html#cakes", "We offer a variety of delicious cakes" ],
			[ "Coordination Services", "home.html?page=alacarte.html#coord", "Consulting & On-Site Wedding Director" ],
			[ "Officiants & Ministers ", "home.html?page=alacarte.html#min", "Religious, Hawaiian, Non-denominational & others" ],
			[ "Music", "home.html?page=alacarte.html#music", "Hawaiian Guitarist/Vocalist, Harpist & more" ],
			[ "Entertainment", "home.html?page=alacarte.html#entertain", "Hula Dancers, Lei Greeters, Conch Shell Blowers..." ],
			[ "Doves & Butterflies", "home.html?page=alacarte.html#doves", "Upgrade your wedding with a dove release" ],
			[ "Transportation", "home.html?page=alacarte.html#transport", "From Limos to Rolls Royces we&#39;ve got it all" ],
			[ "Keepsakes & Indulgences", "home.html?page=alacarte.html#keepsakes", "Wedding Certificates, Manicures, Hair Stylist..." ],
			[ "Arches & Floral Accents", "home.html?page=alacarte.html#arches", "Upgrade your wedding with a lovely floral arch" ],
			[ "Receptions, Luaus & Dinner", "home.html?page=alacarte.html#reception", "Our Intimate dinner for two is unforgettable" ],
			[  "",        8,     [0,0],   [0, 5], [0, 0], [0, 0], [0,0] ]
			// Title, fontSize, relative, above,  right,  below,  left: [xPos, yPos]
		];

	}

	else { // Normal operation: within frameset
		this.Links[ "photos" ] = [
			[ "Slide-Show", "javascript:launchSS( \\&#39;ss-pwm-main.js\\&#39; );", "View photos with our automated slide-show" ],
			[ "Thumbnails", "javascript:getThumbnails();", "View photos on a traditional \\&#34;click-to-enlarge\\&#34; page" ],
			[  "",        8,     [0,0],   [-5, -2], [0, 0], [0, 0], [0,0] ]
			// Title, fontSize, relative, above,  right,  below,  left: [xPos, yPos]
		];

		this.Links[ "alacarte" ] = [
			[ "Wedding Cakes", "alacarte.html#cakes", "We offer a variety of delicious cakes" ],
			[ "Coordination Services", "alacarte.html#coord", "Consulting & On-Site Wedding Director" ],
			[ "Officiants & Ministers ", "alacarte.html#min", "Religious, Hawaiian, Non-denominational & others" ],
			[ "Music", "alacarte.html#music", "Hawaiian Guitarist/Vocalist, Harpist & more" ],
			[ "Entertainment", "alacarte.html#entertain", "Hula Dancers, Lei Greeters, Conch Shell Blowers..." ],
			[ "Doves & Butterflies", "alacarte.html#doves", "Upgrade your wedding with a dove release" ],
			[ "Transportation", "alacarte.html#transport", "From Limos to Rolls Royces we&#39;ve got it all" ],
			[ "Keepsakes & Indulgences", "alacarte.html#keepsakes", "Wedding Certificates, Manicures, Hair Stylist..." ],
			[ "Arches & Floral Accents", "alacarte.html#arches", "Upgrade your wedding with a lovely floral arch" ],
			[ "Receptions, Luaus & Dinner", "alacarte.html#reception", "Our Intimate dinner for two is unforgettable!" ],
			[  "",        8,     [0,0],   [-5, -2], [0, 0], [0, 0], [0,0] ]
			// Title, fontSize, relative, above,  right,  below,  left: [xPos, yPos]
		];
	}

	this.Links[ "otherSites" ] = [
		[ "Creative Touch Photography", "javascript:popUp( \\&#39;http://www.creativetouchphoto.com\\&#39; );", "Maui Wedding Photographer" ],
		[ "Tropical Villa Vacations", "javascript:popUp( \\&#39;http://www.tropicalvillavacations.com\\&#39; );", "Exclusive Maui Vacation Rentals" ],
		[ "Kumulani Vacation Rentals", "javascript:popUp( \\&#39;http://www.kumulani.com/\\&#39; );", "Maui Vacation Rentals" ],
		[ "Kumula`au Hale Vacation Rentals", "javascript:popUp( \\&#39;http://www.kumulaauhale.com/\\&#39; );", "Maui Vacation Rentals" ],
		[ "BridalClicks.com", "javascript:popUp( \\&#39;http://www.bridalclicks.com\\&#39; );", "Wedding Planning" ],
		[ "www.weddings", "javascript:popUp( \\&#39;http://www.wwwweddings.com/\\&#39; );", "Wedding Planning" ],
		[ "Bliss", "javascript:popUp( \\&#39;http://www.blissweddings.com\\&#39; );", "Wedding Planning" ],
		[ "Wedding Links Galore", "javascript:popUp( \\&#39;http://weddinglinksgalore.com\\&#39; );", "Wedding Planning" ],
		[ "BridalPlanner.com", "javascript:popUp( \\&#39;http://bridalplanner.com\\&#39; );", "Wedding Planning" ],
		[  "LINKS TO OTHER SITES",        8,     [-5, -3],   [0, 5], [0, 0], [0, 0], [0,0] ]
		// Title, fontSize, relative, above,  right,  below,  left: [xPos, yPos]
	];

	this.settings = new Array();
	this.settings[ "fgColorOff" ] = "51,51,51";
	this.settings[ "fgColorOn" ] = "255,255,255";
	this.settings[ "fgColorDisable" ] = "151,151,151";
	this.settings[ "bgColorOff" ] = "225,225,225";
	this.settings[ "bgColorOn" ] = "0,0,102";
	this.settings[ "borderColor" ] = "102,102,102";
	this.settings[ "fgTitleColor" ] = "51,51,51";
	this.settings[ "bgTitleColor" ] = "204,204,204";
	this.settings[ "formElements" ] = null;
	this.settings[ "delayToKill" ] = 1000;
	this.settings[ "showToolTip" ] = true;

	// Do not edit past this line -------------------------

	this.Menu = null;
	this.OldLink = null;
	this.timer = 0;

	this.start = start;
	this.show = show;
	this.killOthers = killOthers;
	this.hide = hide;
	this.resetTimer = resetTimer;
	this.getPos = getPos;
	this.setElemVis = setElemVis;

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

	function start( Link, theEvent, arrName, menuPosition ) {
		killOthers( Link );
		show( Link, theEvent, arrName, menuPosition );
	}

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

	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 --------------------------------------
	// It appears that Safari fails to add BODY: margin-top to y however it correctly determines y when link is set as position:absolute.
	function getPos( TheElement ) {
		var x = 0; var y = 0;
		//var deBugStr = ""
		while( TheElement != document.body ) {
			y += TheElement.offsetTop;
			x += TheElement.offsetLeft;
			y -= TheElement.scrollTop;
			x -= TheElement.scrollLeft;
			//deBugStr += "TAG: " + TheElement.tagName + ";  x:" + x + ";  y:" + y + "\n";
			TheElement = TheElement.offsetParent;
		}
		//prompt( "", deBugStr );
		return[ x, y ];
	}
	//-------------------------------------- METHOD --------------------------------------

	function show( Link, theEvent, arrName, menuPosition ) {

		if( !DM.Menu ) {

			DM.setElemVis( arrName, "hidden" )

			var e = ( window.event ) ? event : theEvent;

			var borderCol = DM.settings.borderColor;
			var borderStyle = ( borderCol ) ? " STYLE='border:1px solid rgb( " + borderCol + " );'" : "";

			var nLinks = DM.Links[ arrName ].length - 1;

			var menuTitle = DM.Links[ arrName ][ nLinks ][ 0 ];

			var fontSize = DM.Links[ arrName ][ nLinks ][ 1 ];

			var table = "" +

			"<TABLE ALIGN='left' BORDER='0' CELLSPACING='0' CELLPADDING='1' " + borderStyle + " onMouseover='DM.resetTimer();' onMouseout='DM.hide( 0 );'>";
				for( var i = 0; i < nLinks; i++ ) {

					if( menuTitle && i == 0 ) {
						table +=
						"<TR>" +
							"<TD NOWRAP ALIGN='center' STYLE='color:rgb( " + DM.settings.fgTitleColor + " ); background-color:rgb( " + DM.settings.bgTitleColor + " ); font-size:" + fontSize + "pt; font-family:arial,helvetica; font-weight:bold;'>&nbsp;" +
							menuTitle +
							"&nbsp;</TD>" +
						"</TR>";
					}

					table +=
					"<TR ALIGN='left' VALIGN='middle'>";

						var thePage = document.location.href;
						var pageShowing = ( thePage.indexOf( DM.Links[ arrName ][ i ][ 1 ] ) != -1 && !document.location.hash );

						var selfStatusCode = "";

						if( DM.Links[ arrName ][ i ][ 2 ] && !pageShowing ) {
							if( DM.settings.showToolTip )
								selfStatusCode = "this.title = \"" + DM.Links[ arrName ][ i ][ 2 ] + "\"; self.status = \"" + DM.Links[ arrName ][ i ][ 2 ] + "\"; ";
							else
								selfStatusCode = "self.status = \"" + DM.Links[ arrName ][ i ][ 2 ] + "\"; ";
						}

						var mouseOutCode = ( DM.Links[ arrName ][ i ][ 2 ] ) ? " self.status = \"\"; " : "";

						var fgColOn = ( pageShowing ) ? DM.settings[ "fgColorDisable" ] : DM.settings[ "fgColorOn" ];

						var fgColOff = ( pageShowing ) ? DM.settings[ "fgColorDisable" ] : DM.settings[ "fgColorOff" ];

						var bgCol = ( pageShowing )  ? DM.settings[ "bgColorOff" ] : DM.settings[ "bgColorOn" ];

						var cursorType = ( pageShowing ) ? "default" : "hand";
						if( NC ) cursorType = "default";

						var onClickCode = ( pageShowing ) ? "self.status = \"You are already on the \\&#34;" + DM.Links[ arrName ][ i ][ 0 ]  + "\\&#34; page\"; return true;" : "document.location.href=\"" + DM.Links[ arrName ][ i ][ 1 ] + "\"";

						table +=
						"<TD NOWRAP STYLE='background-color:rgb( " + DM.settings[ 'bgColorOff' ] + " );' onMouseOver='" + selfStatusCode + "this.firstChild.style.color=\"rgb( " + fgColOn + ")\"; style.cursor = \"" + cursorType + "\"; style.backgroundColor=\"rgb( " + bgCol + ")\"; return true;' onMouseOut='" + mouseOutCode + "this.firstChild.style.color=\"rgb( " + fgColOff + ")\"; style.backgroundColor=\"rgb( " + DM.settings[ 'bgColorOff' ] + ")\"; return true;' onClick='" + onClickCode + "'>" +

							"<SPAN STYLE='font-size:" + fontSize + "pt; font-family:arial,helvetica; color:rgb( " + ( ( pageShowing ) ? fgColOn : DM.settings[ 'fgColorOff' ] ) + ");'>&nbsp;" + DM.Links[ arrName ][ i ][ 0 ]  + "&nbsp;</SPAN>" +

						"</TD>" +
					"</TR>";
				}

			table +=
			"</TABLE><BR>"; // Trailing "<BR>" nesessary for macIE - don't delete!

			DM.Menu = document.createElement( "DIV" );
			document.body.appendChild( DM.Menu );

			DM.OldLink = Link;
			DM.Menu.style.zIndex = 1000;
			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;

			if( macIE || SF ) menuPosition = "relative";
			if( menuPosition != "relative" ) var PosArr = getPos( Link );

			switch( menuPosition ) {

				case "relative":

					var ieCSS = ( IE && document.compatMode) ? document.compatMode ==  "CSS1Compat" : false;
					if( IE ) var IeBody = ieCSS ? document.documentElement : document.body;

					var bodyHgt = ( IE ) ? IeBody.clientHeight : window.innerHeight;
					var topEdge = ( IE ) ? e.clientY + IeBody.scrollTop : e.pageY;
					topEdge += DM.Links[ arrName ][ nLinks ][ 2 ][ 1 ];

					var bodyWid = ( IE ) ? IeBody.clientWidth : window.innerWidth;
					var leftEdge = ( IE ) ? e.clientX + IeBody.scrollLeft : e.pageX;
					leftEdge += DM.Links[ arrName ][ nLinks ][ 2 ][ 0 ];

					// Prevent menu from going off bottom of page
					var menuHgt = DM.Menu.offsetHeight;
					var vScreenPos = topEdge - ( ( IE ) ? IeBody.scrollTop : window.pageYOffset );
					var vSkew = bodyHgt - vScreenPos;
					if( vSkew < menuHgt + 10 ) topEdge -= menuHgt - vSkew + 10;

					// Prevent menu from going off right edge of page
					var menuWid = DM.Menu.offsetWidth;
					var hScreenPos = leftEdge - ( ( IE ) ? IeBody.scrollLeft : window.pageXOffset );
					var hSkew = bodyWid - hScreenPos;
					if( hSkew < menuWid + 10 ) leftEdge -= menuWid - hSkew + 10;

					DM.Menu.style.top = topEdge + "px";
					DM.Menu.style.left = leftEdge + "px";
					break;

				case "above":
					DM.Menu.style.top = PosArr[ 1 ] - DM.Menu.offsetHeight + DM.Links[ arrName ][ nLinks ][ 3 ][ 1 ] + "px";
					DM.Menu.style.left = PosArr[ 0 ] + DM.Links[ arrName ][ nLinks ][ 3 ][ 0 ] + "px";
					break;

				case "right":
					DM.Menu.style.top = PosArr[ 1 ] + DM.Links[ arrName ][ nLinks ][ 4 ][ 1 ] + "px";
					DM.Menu.style.left = PosArr[ 0 ] + Link.offsetWidth + DM.Links[ arrName ][ nLinks ][ 4 ][ 0 ] + "px";
					break;

				case "below":
					DM.Menu.style.top = PosArr[ 1 ] + Link.offsetHeight + DM.Links[ arrName ][ nLinks ][ 5 ][ 1 ] + "px";
					DM.Menu.style.left = PosArr[ 0 ] + DM.Links[ arrName ][ nLinks ][ 5 ][ 0 ] + "px";
					break;

				case "left":
					DM.Menu.style.top = PosArr[ 1 ] + DM.Links[ arrName ][ nLinks ][ 6 ][ 1 ] + "px";
					DM.Menu.style.left = PosArr[ 0 ] - DM.Menu.offsetWidth + DM.Links[ arrName ][ nLinks ][ 6 ][ 0 ] + "px";
					break;

				default:
					alert( "SWITCH/CASE ERROR: menuPosition \"" + menuPosition + "\" is invalid. It must be set to \"relative\", \"above\", \"right\", \"below\" or \"left\"." );

			}
			DM.Menu.style.visibility = "visible";

		}
	}

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

	function setElemVis( arrName, vis ) {
		if( winIE && DM.settings.formElements ) {
			for( member in DM.settings.formElements ) {
				if( vis == "visible" || arrName == DM.settings.formElements[ member ][ 0 ] )
					document.getElementById( DM.settings.formElements[ member ][ 1 ] ).style.visibility = vis;
			}
		}
	}
	//-------------------------------------- METHOD --------------------------------------

	function hide( delay ) {
		if( !arguments.length ) delay = DM.settings.delayToKill;
		if( DM.timer == 0 && DM.Menu ) {
			DM.timer = setTimeout( "" +
				"DM.Menu.innerHTML = '';" +
				"DM.Menu = null;" +
				"DM.timer = 0;" +
				"DM.setElemVis( '', 'visible' );",
				delay
			);
		}
	}

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

	function resetTimer() {
		clearTimeout( DM.timer );
		DM.timer = 0;
	}
}

DM = ( document.getElementById ) ? new DynamicMenu() : null;

////////////////////////////////// END DYNAMIC MENU //////////////////////////////////

////////////////////////// START COLLAPSABLE/EXPANDABLE INDEX //////////////////////////

/*

ACCESSOR VARIABLES: None
ACCESSOR FUNCTIONS: None
ACCESSOR STYLES: Yes, see "COLLAPSABLE INDEX STYLES"
*/

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

function ColExpIndex() {

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

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

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


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

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

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

	function switchDisplay( Link ) {

		var PlusMinus = getPlusMinus( Link );
		PlusMinus.innerHTML = ( PlusMinus.innerHTML == "+" ) ? "-" : "+";


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

		Content.style.display = ( Content.style.display == "block" ) ? "none" : "block";
		showTip( Link );

	}


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

	function showTip( Link ) {

		var PlusMinus = getPlusMinus( Link );

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

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

	function toggleAll( Link ) {

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

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

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

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

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

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

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

		}

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



	}

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

	function getToggleAllLink() {

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

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