var iFrameCategories;
var iFrameThumbnails;

var docMain;
var docCategories;
var docThumbnails;
var docTarget;
var dateCurrentMain = new Date();
var timeMillisecondsMain = dateCurrentMain.getTime();

//Note that even though we only have two data elements for services we are using the same format as categories;
//so the middle element needs to be filled in with a dummy value. The last value is the number of photos in that;
//service or category;

var saServiceInfo = new Array( 5 );
saServiceInfo[ 0 ] = "Weddings^^Bride & Groom^^59";
saServiceInfo[ 1 ] = "Weddings^^Bridal Party^^43";
saServiceInfo[ 2 ] = "Weddings^^Cakes & Cutting^^47";
saServiceInfo[ 3 ] = "Weddings^^Rings & Decor^^44";
saServiceInfo[ 4 ] = "Weddings^^Churches^^15";
saServiceInfo[ 5 ] = "Portraits^^X^^17";
saServiceInfo[ 6 ] = "High School Seniors^^X^^16";
saServiceInfo[ 7 ] = "Corporate^^X^^18";
saServiceInfo[ 8 ] = "Purchase Art^^X^^0";

var saCategoryInfo = new Array( 25 );
saCategoryInfo[ 0 ] = "Animals^^Birds^^28";
saCategoryInfo[ 1 ] = "Animals^^Insects^^14";
saCategoryInfo[ 2 ] = "Animals^^Mammals^^28";
saCategoryInfo[ 3 ] = "Animals^^Fish^^2";
saCategoryInfo[ 4 ] = "Animals^^Other^^7";
saCategoryInfo[ 5 ] = "Nature^^Waterfalls^^15";
saCategoryInfo[ 6 ] = "Nature^^Landscapes^^70";
saCategoryInfo[ 7 ] = "Nature^^Winter^^19";
saCategoryInfo[ 8 ] = "Nature^^Fall^^9";
saCategoryInfo[ 9 ] = "Nature^^Other^^41";
saCategoryInfo[ 10 ] = "People^^Adults^^29";
saCategoryInfo[ 11 ] = "People^^Children^^25";
saCategoryInfo[ 12 ] = "People^^HS Seniors^^48";
saCategoryInfo[ 13 ] = "People^^Groups^^30";
saCategoryInfo[ 14 ] = "People^^Weddings^^60";
saCategoryInfo[ 15 ] = "Transport^^Planes^^10";
saCategoryInfo[ 16 ] = "Transport^^Trains^^3";
saCategoryInfo[ 17 ] = "Transport^^Cars^^14";
saCategoryInfo[ 18 ] = "Transport^^Bikes^^10";
saCategoryInfo[ 19 ] = "Transport^^Other^^11";
saCategoryInfo[ 20 ] = "Architecture^^Interiors^^21";
saCategoryInfo[ 21 ] = "Architecture^^Exteriors^^43";
saCategoryInfo[ 22 ] = "Architecture^^Details^^25";
saCategoryInfo[ 23 ] = "Architecture^^Monuments^^34";
saCategoryInfo[ 24 ] = "Architecture^^Other^^33";

var saCategoryPanos = new Array( 13 );
saCategoryPanos[ 0 ] = '2_1_1013.jpg';
saCategoryPanos[ 1 ] = '2_2_1012.jpg';
saCategoryPanos[ 2 ] = '2_2_1013.jpg';
saCategoryPanos[ 3 ] = '2_2_1041.jpg';
saCategoryPanos[ 4 ] = '2_2_1052.jpg';
saCategoryPanos[ 5 ] = '2_2_1053.jpg';
saCategoryPanos[ 6 ] = '2_2_1054.jpg';
saCategoryPanos[ 7 ] = '2_2_1057.jpg';
saCategoryPanos[ 8 ] = '4_3_1005.jpg';
saCategoryPanos[ 9 ] = '5_2_1034.jpg';
saCategoryPanos[ 10 ] = '5_2_1043.jpg';
saCategoryPanos[ 11 ] = '5_4_1010.jpg';
saCategoryPanos[ 12 ] = '5_5_1033.jpg';

var saServicePanos = new Array( 0 );

var iaMainCategoryIndex = new Array( 5 );
var saMainCategoryNames = new Array( 5 );
var iaSubCategoryCount = new Array( 5 );
var imgHeights = new Array(0,0,0,0,0);

var iaMainServiceIndex = new Array( 5 );
var saMainServiceNames = new Array( 5 );
var iaSubServiceCount = new Array( 5 );
var imgServiceHeights = new Array(0,0,0,0,0);

var sBrowserBrand;
var sBrowserversion;
var XMLHttpRequestStatusText = '';
var sCategoryActive = '0';
var sMenuActive = '0';
var sLuisActive = '0';
var sServiceActive = '0';
var sIFrameBig = '0';
var sMenuCategory;
var sMenuService;
var sExternalSiteUnload;

var iMainCategoryCount = 0;
var iCategoryCount = 0;
var iCategory = 1;
var iMainServiceCount = 0;
var iServiceCount = 0;
var iService = 1;

var divBottomLeftVerticalBar;
var divBottomLeftBar;
var divCategories;
var divLuis;
var divLuisBioNormal;
var divLuisBioOver;
var divPhotoWatermarkNormal;
var divPhotoWatermarkPano;
var divPhotoMenuNormal;
var divPhotoMenuOver;
var divExternalSiteBackNormal;
var divExternalSiteBackOver;

var spanAudio;

var boolMenuLoaded = false;
var boolSwappingAudio = false;
var boolExternalSite;
var boolBrowserAlert = true;

var sURL = window.location.href;
var iSlash = sURL.lastIndexOf( '/' );
sURL = sURL.substr( 0, iSlash );

//================================================================================;
//General functions;

function initGlobalVariables()
{
	//Only needs to be done on initial site load;

	var sMainCategory;
	var sMainService;
	var iIndex;
	dateCurrentMain = new Date();
	timeMillisecondsMain = dateCurrentMain.getTime();

	docMain = document;

	//set the SRC for the ImgPhotoWatermarkNormal and ImgPhotoWatermarkPano IMG tags;
	imgPhotoWatermarkNormal = getObject( docMain, 'ImgPhotoWatermarkNormal' );
	ImgPhotoWatermarkNormal.src = sURL + '/pics/photoWatermarkNormal.gif?' + timeMillisecondsMain;
	imgPhotoWatermarkPano = getObject( docMain, 'ImgPhotoWatermarkPano' );
	ImgPhotoWatermarkPano.src = sURL + '/pics/photoWatermarkPano.gif?' + timeMillisecondsMain;

	iFrameCategories = document.getElementById( "IFrameCategories" );
	iFrameThumbnails = document.getElementById( "IFrameThumbnails" );
	if ( iFrameCategories.contentWindow )
	{
		var iFrameCategoriesWindow = iFrameCategories.contentWindow;
		var iFrameThumbnailsWindow = iFrameThumbnails.contentWindow;
		if ( iFrameCategoriesWindow.document )
		{
			docCategories = iFrameCategoriesWindow.document;
			docThumbnails = iFrameThumbnailsWindow.document;
		} else if ( iFrameCategories.contentDocument )
		{
			docCategories = iFrameCategories.contentDocument;
			docThumbnails = iFrameThumbnails.contentDocument;
		}
	}

	
	if ( sBrowserBrand == "GC" )
	{
		iFrameCategories = window.frames["IFrameCategories"];
		iFrameThumbnails = window.frames["IFrameThumbnails"];
	} else {
		iFrameCategories = getObject( docMain, 'IFrameCategories' );
		iFrameThumbnails = getObject( docMain, 'IFrameThumbnails' );
	}
	var iFrameCategoriesWindow = iFrameCategories.contentWindow;
	var iFrameThumbnailsWindow = iFrameThumbnails.contentWindow;
	if ( iFrameCategories.contentDocument )
	{
		docCategories = iFrameCategories.contentDocument;
		docThumbnails = iFrameThumbnails.contentDocument;
	} else if ( iFrameCategories.contentWindow )
	{
		docCategories = iFrameCategories.contentWindow.document;
		docThumbnails = iFrameThumbnails.contentWindow.document;
	} else {
		docCategories = iFrameCategories.document;
		docThumbnails = iFrameThumbnails.document;
	}
	//var iFrameCategoriesWindow = (iFrameCategories.contentWindow) ? iFrameCategories.contentWindow : (iFrameCategories.contentDocument.document) ? iFrameCategories.contentDocument.document : (iFrameCategories.contentWindow.document) ? iFrameCategories.contentWindow.document : iFrameCategories.contentDocument;
	//docCategories = iFrameCategoriesWindow.document;
	//var iFrameThumbnailsWindow = (iFrameThumbnails.contentWindow) ? iFrameThumbnails.contentWindow : (iFrameThumbnails.contentDocument.document) ? iFrameThumbnails.contentDocument.document : (iFrameThumbnails.contentWindow.document) ? iFrameThumbnails.contentWindow.document : iFrameThumbnails.contentDocument;
	//docThumbnails = iFrameThumbnailsWindow.document;


	divBottomLeftVerticalBar = getObject( docMain, 'DivBottomLeftVerticalBar' );
	divBottomLeftBar = getObject( docMain, 'DivBottomLeftBar' );
	divCategories = getObject( docMain, 'DivCategories' );
	/*divMenu1Normal = getObject( docMain, 'DivMenu1Normal' );
	divMenu2Normal = getObject( docMain, 'DivMenu2Normal' );
	divMenu3Normal = getObject( docMain, 'DivMenu3Normal' );
	divMenu4Normal = getObject( docMain, 'DivMenu4Normal' );
	divMenu1Over = getObject( docMain, 'DivMenu1Over' );
	divMenu2Over = getObject( docMain, 'DivMenu2Over' );
	divMenu3Over = getObject( docMain, 'DivMenu3Over' );
	divMenu4Over = getObject( docMain, 'DivMenu4Over' );
	divService1Normal = getObject( docMain, 'DivService1Normal' );
	divService2Normal = getObject( docMain, 'DivService2Normal' );
	divService3Normal = getObject( docMain, 'DivService3Normal' );
	divService4Normal = getObject( docMain, 'DivService4Normal' );
	divService5Normal = getObject( docMain, 'DivService5Normal' );
	divService1Over = getObject( docMain, 'DivService1Over' );
	divService2Over = getObject( docMain, 'DivService2Over' );
	divService3Over = getObject( docMain, 'DivService3Over' );
	divService4Over = getObject( docMain, 'DivService4Over' );
	divService5Over = getObject( docMain, 'DivService5Over' );*/

	divLuis = getObject( docMain, 'DivLuis' );
	divLuisBioNormal = getObject( docMain, 'DivLuisBioNormal' );
	divLuisBioOver = getObject( docMain, 'DivLuisBioOver' );

	spanAudio = getObject( docMain, 'SpanAudio' );

	divPhotoWatermarkNormal = getObject( docMain, 'DivPhotoWatermarkNormal' );
	divPhotoWatermarkPano = getObject( docMain, 'DivPhotoWatermarkPano' );
	divPhotoMenuNormal = getObject( docMain, 'DivPhotoMenuNormal' );
	divPhotoMenuOver = getObject( docMain, 'DivPhotoMenuOver' );
	divExternalSiteBackNormal = getObject( docMain, 'DivExternalSiteBackNormal' );
	divExternalSiteBackOver = getObject( docMain, 'DivExternalSiteBackOver' );

	//count the number of main and subcategories;
	iaMainCategoryIndex[ 0 ] = 0;
	var sCategoryInfoTemp = saCategoryInfo[ 0 ];
	var saCategoryInfoTemp = sCategoryInfoTemp.split( '^^' );
	var sMainCategoryPrev = saCategoryInfoTemp[ 0 ];
	for ( iIndex = 0; iIndex < saCategoryInfo.length; iIndex++ )
	{
		sCategoryInfoTemp = saCategoryInfo[ iIndex ];
		saCategoryInfoTemp = sCategoryInfoTemp.split( '^^' );
		sMainCategory = saCategoryInfoTemp[ 0 ];
		if ( sMainCategory != sMainCategoryPrev )
		{
			if ( iMainCategoryCount == 0 )
			{
				iaSubCategoryCount[ iMainCategoryCount ] = iIndex;
			} else {
				iaSubCategoryCount[ iMainCategoryCount ] = iIndex - iaMainCategoryIndex[ iMainCategoryCount ];
			}
			iMainCategoryCount++;
			iaMainCategoryIndex[ iMainCategoryCount ] = iIndex;
			saMainCategoryNames[ iMainCategoryCount - 1 ] = sMainCategoryPrev;
			sMainCategoryPrev = sMainCategory;
		}
	}
	saMainCategoryNames[ iMainCategoryCount ] = sMainCategory;
	iaSubCategoryCount[ iMainCategoryCount ] = saCategoryInfo.length - iaMainCategoryIndex[ iMainCategoryCount ];

	iMainCategoryCount++;
	iCategoryCount = iMainCategoryCount;

	//count the number of main and sub services;
	iaMainServiceIndex[ 0 ] = 0;
	var sServiceInfoTemp = saServiceInfo[ 0 ];
	var saServiceInfoTemp = sServiceInfoTemp.split( '^^' );
	var sMainServicePrev = saServiceInfoTemp[ 0 ];
	for ( iIndex = 0; iIndex < saServiceInfo.length; iIndex++ )
	{
		sServiceInfoTemp = saServiceInfo[ iIndex ];
		saServiceInfoTemp = sServiceInfoTemp.split( '^^' );
		sMainService = saServiceInfoTemp[ 0 ];
		if ( sMainService != sMainServicePrev )
		{
			if ( iMainServiceCount == 0 )
			{
				iaSubServiceCount[ iMainServiceCount ] = iIndex;
			} else {
				iaSubServiceCount[ iMainServiceCount ] = iIndex - iaMainServiceIndex[ iMainServiceCount ];
			}
			if ( iaSubServiceCount[ iMainServiceCount ] == 1 )
			{
				iaSubServiceCount[ iMainServiceCount ] = 0;
			}
			iMainServiceCount++;
			iaMainServiceIndex[ iMainServiceCount ] = iIndex;
			saMainServiceNames[ iMainServiceCount - 1 ] = sMainServicePrev;
			sMainServicePrev = sMainService;
		}
	}
	saMainServiceNames[ iMainServiceCount ] = sMainService;
	iaSubServiceCount[ iMainServiceCount ] = saServiceInfo.length - iaMainServiceIndex[ iMainServiceCount ];

	iMainServiceCount++;
	iServiceCount = iMainServiceCount;

	return false;
}

function getObject( doc, sObjName )
{
	//get a handle to an HTML object;

	//alert( sObjName );
	var elem;
	if ( doc )
	{
		if( doc.getElementById ) // this is the way current standards work;
			elem = doc.getElementById( sObjName );
		else if( doc.all ) // this is the way old msie versions work;
			elem = doc.all[ sObjName ];
		else if( doc.layers ) // this is the way nn4 works;
			elem = doc.layers[ sObjName ];
		if ( elem )
		{
			return elem;
		} else {
			alert( 'getObject( ' + sObjName + '): Error - could not locate object' );
			return false;
		}
			
	} else {
		alert( 'getObject( ' + sObjName + '): Error - no document passed' );
		return false;
	}
}

function openExternalSite( sURLExternalSite )
{
	//This will open the site in the Categories frame. User can click Home to reload the categories.;

	docCategories.open();
	docCategories.write('<HTML>');

	docCategories.write('<HEAD>');
	NoCacheHeader( docCategories );
	docCategories.write('<STYLE type="text/css">');
	docCategories.write('.body');
	docCategories.write('{');
	docCategories.write('	margin: 0px;');
	docCategories.write('	padding: 0px;');
	docCategories.write('	background-color: #FFFFFF;');
	docCategories.write('}');
	docCategories.write('</STYLE>');
	docCategories.write('</HEAD>');

	docCategories.write('<BODY ');
	docCategories.write(' CLASS="body" onload="parent.showExternalSiteBack();" ');
	securityBody( docCategories );
	docCategories.write('>');

	docCategories.write('<IFRAME ID="IFrameExternalLink" NAME="IFrameExternalLink" WIDTH="668" HEIGHT="');
	if ( sIFrameBig == '1' )
	{
		docCategories.write( '468' );
	} else {
		docCategories.write( '364' );
	}
	docCategories.write('" FRAMEBORDER="0" SCROLLING="AUTO" MARGINHEIGHT="0" MARGINWIDTH="5" SRC="' + sURLExternalSite + '">');
	docCategories.write('</IFRAME>');
	docCategories.write('</BODY>');

	docCategories.write('<HEAD>');
	NoCacheHeader( docCategories );
	docCategories.write('</HEAD>');

	docCategories.write('</HTML>');
	docCategories.close();
	boolExternalSite = true;

	return false;
}

function unloadExternalSite()
{
	//go back to where we were before the external site was loaded.;
	var iIndex = sExternalSiteUnload.indexOf( '^^' );
	var sExternalSiteFunction = sExternalSiteUnload.substring( 0, iIndex );
	var saParameters;
	if ( sExternalSiteFunction == 'loadMainPage' )
	{
		loadMainPage();
	} else if ( sExternalSiteFunction == 'loadMenu' )
	{
		saParameters = sExternalSiteUnload.substr( iIndex + 2 ).split( '^^');
		loadMenu( saParameters[ 0 ], saParameters[ 1 ], saParameters[ 2 ] );
	} else if ( sExternalSiteFunction == 'loadService' )
	{
		saParameters = sExternalSiteUnload.substr( iIndex + 2 );
		loadService( saParameters );
	}
	hideExternalSiteBack();
	boolExternalSite = false;

	return false;

}

function getTextInfo( sFrameTarget, sFilename, sLoadingMessage, sTopMargin, sBottomMargin, sRightMargin )
{
	//Load the specified text file into the specified frame;
	//Note that the text file will be interpreted as HTML;
	if ( sFrameTarget == 'IFrameCategories' )
	{
		docTarget = docCategories;
		clearThumbnailFrame();
	} else if ( sFrameTarget = 'IFrameThumbnails' )
	{
		docTarget = docThumbnails;
	}
	docTarget.open();
	docTarget.write('<HTML>');

	docTarget.write('<HEAD>');
	NoCacheHeader( docTarget );
	docTarget.write('<STYLE type="text/css">');
	docTarget.write('.body');
	docTarget.write('{');
	docTarget.write('	margin: 0px;');
	docTarget.write('	padding: 0px;');
	docTarget.write('	background-color: #000000;');
	docTarget.write('	background-image: url(\'' + sURL + '/pics/backgroundBody.gif\');');
	docTarget.write('	color: #FFFFFF;');
	docTarget.write('}');
	docTarget.write('.divText');
	docTarget.write('{');
	docTarget.write('	margin: 0px;');
	docTarget.write('	padding-top: ' + sTopMargin + 'px;');
	docTarget.write('	padding-left: 8px;');
	docTarget.write('	padding-right: ' + sRightMargin + 'px;');
	docTarget.write('	padding-bottom: ' + sBottomMargin + 'px;');
	docTarget.write('}');
	docTarget.write('p');
	docTarget.write('{');
	docTarget.write('	margin: 0px;');
	docTarget.write('	padding: 0px;');
	docTarget.write('}');
	docTarget.write('a:link {color: #9CC6FE;}');
	docTarget.write('a:visited {color: #0040FF;}');
	docTarget.write('a:hover {color: #FFFF00;}');
	docTarget.write('</STYLE>');
	docTarget.write('</HEAD>');

	docTarget.write('<BODY BGCOLOR="#000000" CLASS="body" ');
	securityBody( docTarget );
	docTarget.write('>');

	docTarget.write('<DIV ID="DivText" NAME="DivText" CLASS="divText"><FONT face=\'Verdana, Arial\' color=\'#FFFFFF\' size=\'2\'>&nbsp; ' + sLoadingMessage + '...</FONT></DIV>');
	docTarget.write('</BODY>');

	docTarget.write('<HEAD>');
	NoCacheHeader( docTarget );
	docTarget.write('</HEAD>');

	docTarget.write('</HTML>');
	docTarget.close();

	var divText = getObject( docTarget, 'DivText' );
	var XMLHttpRequestObject = false;
	if ( window.ActiveXObject )
	{
		try
		{
			XMLHttpRequestObject = new ActiveXObject( "MSXML2.XMLHTTP" );
		} catch(e)
		{
			try
			{
				XMLHttpRequestObject = new ActiveXObject( "Microsoft.XMLHTTP" );
			} catch(e)
			{
				XMLHttpRequestObject = null;
				alert( "Your browser does not support Ajax!" );
			}
		}
	} else if ( window.XMLHttpRequest )
	{
		XMLHttpRequestObject = new XMLHttpRequest();
	} else {
		alert( "Your browser does not support Ajax!" );
	}
	if ( XMLHttpRequestObject )
	{
		XMLHttpRequestObject.open( "GET", sFilename, true ); 
		XMLHttpRequestObject.onreadystatechange = function()
		{
			if( XMLHttpRequestObject.readyState == 4 )
			{ 
				divText.innerHTML = XMLHttpRequestObject.responseText;
			}
		}
		XMLHttpRequestObject.send( null );
	}
	//note that the script will continue while the above function retrieves the text file and loads it;

	return false;
}

function swapOver( sDocTarget, sObjName, sClasses, sHideAllOver )
{
	//alert( 'swapOver( ' + sDocTarget + ', ' + sObjName + ', ' + sClasses + ', ' + sHideAllOver + ' )' );
	var doc;

	switch ( sDocTarget )
	{
	case 'docCategories':
		doc = docCategories;
		break;
	case 'docThumbnails':
		doc = docThumbnails;
		sHidePhotoWatermark = 'No';
		break;
	case 'docMain':
		doc = docMain;
		break;
	}

	if ( boolMenuLoaded == true )
	{
		var elem = getObject( doc, sObjName );
		if ( elem )
		{
			if ( sHideAllOver == 'Yes' )
			{
				hideAllOver();
			}
			elem.className = sClasses;
			return true;
		}
	}
	return false;
}

function hideAllOver()
{
	//hide every object that is in an "over" status;

	if ( boolMenuLoaded == true )
	{
		if ( sCategoryActive != '0' )
		{
			hideCategoryOver( sCategoryActive, 'No' );
		}
		if ( sMenuActive != '0' )
		{
			hideMenuOver( sMenuActive, 'No' );
		}
		swapOver( 'docMain', 'DivPhotoMenuOver', 'divPhotoMenu divPhotoMenuHide', 'No' );
		//swapOver( 'docMain', 'DivSoundOff', 'divSound divSoundHide', 'No' );
		//swapOver( 'docMain', 'DivSoundOn', 'divSound divSoundHide', 'No' );

		if ( sLuisActive == '1' )
		{
			divLuis.className = 'divLuis divLuisOverHide';
			divLuisBioOver.className = 'divLuisBioOverHide';
			sLuisActive = '0';
		}
		if ( sServiceActive != '0' )
		{
			hideServiceOver( sServiceActive, 'No' );
		}
	}

	return false;
}

//Sound;

function audioOn()
{
	swapOver( 'docMain', 'DivSoundOff', 'divSound divSoundShow', 'No' );
	swapOver( 'docMain', 'DivSoundOn', 'divSound divSoundHide', 'No' ); 
	if ( spanAudio )
	{
		spanAudio.innerHTML = '<embed src="' + sURL +'/music/intro.mp3" hidden=true autostart=true loop=false>';
	}
	return false;
}

function audioOff()
{
	swapOver( 'docMain', 'DivSoundOn', 'divSound divSoundShow', 'No' ); 
	swapOver( 'docMain', 'DivSoundOff', 'divSound divSoundHide', 'No' );
	if ( spanAudio )
	{
		spanAudio.innerHTML = '';
	}
	return false;
}

function NoCacheHeader( doc )
{
	doc.write('<META http-equiv="Cache-Control" content="no-store, no-cache, must-revalidate">');
	doc.write('<META http-equiv="Pragma" content="no-cache">');
	doc.write('<META http-equiv="Expires" content="Mon, 26 Jul 1997 05:00:00 GMT">');
	doc.write('<META http-equiv="Last-Modified" content="Sat, 10 Nov 1997 09:08:07 GMT">');
	doc.write('<META HTTP-EQUIV="Expires" CONTENT="-1">');

	doc.write('<?php');
	doc.write('header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");');
	doc.write('header("Last-Modified: " . gmdate("D, d M Y H:i:s", time() + 300) . " GMT");');
	doc.write('header("Cache-Control: no-cache, must-revalidate");');
	doc.write('header("Pragma: no-cache");');
	doc.write('?>');

	return false;
}

function securityBody( doc )
{
	doc.write('onselectstart="return false;" ');
	doc.write('ondragstart="return false;" ');
	doc.write('onmousedown="if (event.preventDefault){event.preventDefault();}" ');
	doc.write('onBeforePrint="document.body.style.display=\'none\';" ' );
	doc.write('onAfterPrint="document.body.style.display = \'\';" ');
	doc.write('onContextmenu="return false;" ');
	doc.write('onClick="if(event.button==2||event.button==3){event.preventDefault();event.stopPropagation();return false;}"');

	return false;
}

function showExternalSiteBack()
{
	divExternalSiteBackNormal.className = 'divExternalSiteBack divExternalSiteBackShow';
	return false;
}

function hideExternalSiteBack()
{
	divExternalSiteBackNormal.className = 'divExternalSiteBack divExternalSiteBackHide';
	divExternalSiteBackOver.className = 'divExternalSiteBack divExternalSiteBackHide';
	return false;
}

function browserInfo()
{
	var sUserAgent = navigator.userAgent;
	if (/MSIE (\d+\.\d+);/.test( sUserAgent ) )
	{
		var sIEVersion = new Number( RegExp.$1 );
		if ( sIEVersion >= 9 )
		{
			return( 'IE9' );
		} else if ( sIEVersion >= 8 )
		{
			return( 'IE8' );
		} else if ( sIEVersion >= 7 )
		{
			return( 'IE7' );
		} else if ( sIEVersion >= 6 )
		{
			return( 'IE6' );
		} else if ( sIEVersion >= 5 )
		{
			return( 'IE5' );
		} else
		{
			return( 'IE?' );
		}
	}
	if (/Firefox[\/\s](\d+\.\d+)/.test( sUserAgent ) )
	{
		var sFFVersion = new Number( RegExp.$1 );
		if ( sFFVersion >= 5 )
		{
			return( 'FF5' );
		} else if ( sFFVersion >= 4 )
		{
			return( 'FF4' );
		} else if ( sFFVersion >= 3 )
		{
			return( 'FF3' );
		} else if ( sFFVersion >= 2 )
		{
			return( 'FF2' );
		} else if ( sFFVersion >= 1 )
		{
			return( 'FF1' );
		}
	}
	if (/Opera[\/\s](\d+\.\d+)/.test( sUserAgent ) )
	{
		var sOperaVersion = new Number( RegExp.$1 );
		if ( sOperaVersion >= 11 )
		{
			return( 'OP11' );
		} else if ( sOperaVersion >= 10 )
		{
			return( 'OP10' );
		} else if ( sOperaVersion >= 9 )
		{
			return( 'OP9' );
		} else if ( sOperaVersion >= 8 )
		{
			return( 'OP8' );
		} else if ( sOperaVersion >= 7 )
		{
			return( 'OP7' );
		} else
		{
			return( 'OP?' );
		}
	}
	if (/Chrome[\/\s](\d+\.\d+)/.test( sUserAgent ) )
	{
		var sChromeVersion = new Number( RegExp.$1 );
		if ( sChromeVersion >= 12 )
		{
			return( 'GC12' );
		} else if ( sChromeVersion >= 11 )
		{
			return( 'GC11' );
		} else if ( sChromeVersion >= 10 )
		{
			return( 'GC10' );
		} else if ( sChromeVersion >= 9 )
		{
			return( 'GC9' );
		} else if ( sChromeVersion >= 8 )
		{
			return( 'GC8' );
		} else if ( sChromeVersion >= 7 )
		{
			return( 'GC7' );
		} else if ( sChromeVersion >= 6 )
		{
			return( 'GC6' );
		} else if ( sChromeVersion >= 5 )
		{
			return( 'GC5' );
		} else if ( sChromeVersion >= 4 )
		{
			return( 'GC4' );
		} else if ( sChromeVersion >= 3 )
		{
			return( 'GC3' );
		} else if ( sChromeVersion >= 2 )
		{
			return( 'GC2' );
		} else if ( sChromeVersion >= 1 )
		{
			return( 'GC1' );
		} else if ( sChromeVersion >= 0 )
		{
			return( 'GC0' );
		} else
		{
			return( 'GC?' );
		}
	}
	if (/Safari/.test( navigator.userAgent ) )
	{
		var sSafariVersion = /Version\/\d\.\d\.\d*/.exec( sUserAgent );
		sSafariVersion= /\d/.exec( sSafariVersion );
		if ( sSafariVersion >= 5 )
		{
			return "SF5";
		} else if ( sSafariVersion >= 4 )
		{
			return "SF4";
		} else if ( sSafariVersion >= 3 )
		{
			return "SF3";
		} else if ( sSafariVersion >= 2 )
		{
			return "SF2";
		} else
		{
			return "SF1";
		}
	}
	//alert( navigator.userAgent );
	return( 'unk - ' + sUserAgent );
}

function iFixThumbnailFrame()
{
	var sBrowser = browserInfo();
	if ( sBrowser.substr( 0, 2 ) == 'IE' )
	{
		iFrameThumbnails.className = 'iFrameThumbnails iFrameThumbnailsIE';
	} else {
		iFrameThumbnails.className = 'iFrameThumbnails iFrameThumbnailsNonIE';
	}
	return false;
}

//================================================================================;
//Right Navigation Panel functions;

//Menu options, Luis bio & Services;

function unhideMenuOver( sMenu, sHideAllOver )
{
	if ( swapOver( 'docMain', 'DivMenu' + sMenu + 'Over', 'divMenu divMenu' + sMenu + ' divMenuOverShow', sHideAllOver ) == true )
	{
		sMenuActive = sMenu;
	}
	return false;
}

function hideMenuOver( sMenu, sHideAllOver )
{
	if ( swapOver( 'docMain', 'DivMenu' + sMenu + 'Over', 'divMenu divMenu' + sMenu + ' divMenuOverHide', sHideAllOver ) == true )
	{
		sMenuActive = '0';
	}
	return false;
}

function unhideServiceOver( sService, sHideAllOver )
{
	if ( swapOver( 'docMain', 'DivService' + sService + 'Over', 'divService divService' + sService + ' divServiceOverShow', sHideAllOver ) == true )
	{
		sServiceActive = sService;
	}
	return false;
}

function hideServiceOver( sService, sHideAllOver )
{
	if ( swapOver( 'docMain', 'DivService' + sService + 'Over', 'divService divService' + sService + ' divServiceOverHide', sHideAllOver ) == true )
	{
		sServiceActive = '0';
	}
	return false;
}

function loadMenu( sMenu, sFileName, sLoadingMessage )
{
	sExternalSiteUnload = 'loadMenu^^' + sMenu + '^^' + sFileName + '^^' + sLoadingMessage;
	hidePhotoWatermark();
	hidePhotoMenu();

	if ( boolExternalSite == true )
	{
		hideExternalSiteBack();
		boolExternalSite = false;
	}

	switch ( sMenu )
	{
	case '1':
		iCategory = 1;
		iCategoryCount = iMainCategoryCount;
		iFrameCategoriesSize( 'Normal' );
		loadCategoryFrame( '' );
		getTextInfo( 'IFrameThumbnails', sURL + '/moreinfo/welcome.txt', sLoadingMessage, '0', '0', '0' );
		break;
	case '5':
		if ( boolMenuLoaded == true )
		{
			sLuisActive = '1';
			hideAllOver();
			iFrameCategoriesSize( 'Big' );
			if ( sBrowserBrand == 'IE' )
			{
				getTextInfo( 'IFrameCategories', sURL + '/moreinfo/' + sFileName, sLoadingMessage, '5', '5', '5' );
			} else {
				getTextInfo( 'IFrameCategories', sURL + '/moreinfo/' + sFileName, sLoadingMessage, '5', '5', '10' );
			}
		}
		break;
	default:
		if ( boolMenuLoaded == true )
		{
			hideAllOver();
			iFrameCategoriesSize( 'Big' );
			if ( sBrowserBrand == 'IE' )
			{
				getTextInfo( 'IFrameCategories', sURL + '/moreinfo/' + sFileName, sLoadingMessage, '5', '5', '0' );
			} else {
				getTextInfo( 'IFrameCategories', sURL + '/moreinfo/' + sFileName, sLoadingMessage, '5', '5', '10' );
			}
		}
		break;
	}
	return false;
}

function loadService( sService )
{
	sMenuService = sService;

	if ( boolExternalSite == true )
	{
		hideExternalSiteBack();
		boolExternalSite = false;
	}

	sExternalSiteUnload = 'loadService^^' + sService;

	hidePhotoWatermark();
	hidePhotoMenu();

	if ( boolMenuLoaded == true )
	{
		hideAllOver();
		iFrameCategoriesSize( 'Normal' );
		var saServiceInfoTemp = getCategoryInfo( sService, '', 'SERVICE' );
		getTextInfo( 'IFrameCategories', sURL + '/moreinfo/service' + sService + '.txt', saServiceInfoTemp[ 0 ], '5', '5', '5' );
		if ( sService != '5' )
		{
			loadThumbnails( sService, '', 'SERVICE' );
		}
	}
	return false;
}

//================================================================================;
//Category and subcategory functions;

function iFrameCategoriesSize( sSize )
{
	if ( sSize == 'Normal' )
	{
		divCategories.className = 'divCategories';
		iFrameCategories.className = 'iFrameCategoriesNormal';
		divBottomLeftVerticalBar.className = 'divBottomLeftVerticalBar divBottomLeftVerticalBarHide';
		divBottomLeftBar.className = 'divBottomLeftBar divBottomLeftBarHide';
		sIFrameBig = '0';
	} else {
		sIFrameBig = '1';
		divCategories.className = 'divCategoriesBig';
		iFrameCategories.className = 'iFrameCategoriesBig';
		divBottomLeftVerticalBar.className = 'divBottomLeftVerticalBar divBottomLeftVerticalBarShow';
		divBottomLeftBar.className = 'divBottomLeftBar divBottomLeftBarShow';
	}
	return false;
}

function initCategoryVariables()
{
	//Called every time a category is changed;

	boolMenuLoaded = false;
	iCategory = 1;
	imgHeights[4] = 0;
	imgHeights[3] = 0;
	imgHeights[2] = 0;
	imgHeights[1] = 0;
	imgHeights[0] = 0;

	return false;
}

function getCategoryInfo( sMainCategory, sSubCategory, sType )
{
	var iMainCategory = parseInt( sMainCategory, 10 ) - 1;
	var sCategoryInfo = '';
	var iIndex;

	if ( sType == 'SERVICE' )
	{
		//alert( saServiceInfo[ 0 ] );
		//sCategoryInfo = saServiceInfo[ iMainCategory ];
		//alert( sCategoryInfo );

		iIndex = iaMainServiceIndex[ iMainCategory ];
		if ( sSubCategory != '' )
		{
			iIndex = iIndex + ( parseInt( sSubCategory, 10 ) - 1 );
		}
		sCategoryInfo = saServiceInfo[ iIndex ];

	} else {
		iIndex = iaMainCategoryIndex[ iMainCategory ];
		iIndex = iIndex + ( parseInt( sSubCategory, 10 ) - 1 );
		sCategoryInfo = saCategoryInfo[ iIndex ];
	}
	return sCategoryInfo.split( '^^' );
}

function showCategoryImages( iCount )
{
	//this function does the stretch-down animation;

	//first get rid of the "Loading..." message.;
	var divLoading = getObject( docCategories, 'DivLoading' );
	divLoading.className = 'divLoading divLoadingHide';

	imgHeight = 0;

	var elem = getObject( docCategories, 'ImgCategory' + iCategory + 'Normal' );
	imgHeight = imgHeights[ iCategory - 1 ] + 33;
	elem.style.height = imgHeight + 'px';
	imgHeights[ iCategory - 1 ] = imgHeight;
	if ( imgHeight >= 363 )
	{
		elem.style.height = '363px';
		iCategory++;
	}
	if ( iCategory <= iCount )
	{
		//sets the rate at which the IMG expands from top to bottom;
		window.setTimeout('showCategoryImages(' + iCount + ')', 20 );
	} else {
		boolMenuLoaded = true;
	}

	return false;
}

function unhideCategoryOver( sCategory, sHideAllOver )
{
	if ( swapOver( 'docCategories', 'DivCategory' + sCategory + 'Over', 'divCategory divCategoryOver divCategory' + sCategory + 'Over divCategoryShow', sHideAllOver ) == true )
	{
		sCategoryActive = sCategory;
	}
	return false;
}

function hideCategoryOver( sCategory, sHideAllOver )
{
	if ( swapOver( 'docCategories', 'DivCategory' + sCategory + 'Over', 'divCategory divCategoryOver divCategoryHide', sHideAllOver ) == true )
	{
		sCategoryActive = '0';
	}
	return false;
}

function loadMainPage()
{
	var sUserAgent = browserInfo();
	sBrowserBrand = sUserAgent;
	sBrowserversion = sBrowserBrand.substr( 2 );
	sBrowserBrand = sBrowserBrand.substr( 0, 2 );
	sExternalSiteUnload = 'loadMainPage';
	initGlobalVariables();
	iFixThumbnailFrame();
	hidePhotoWatermark();
	hidePhotoMenu();
	loadCategoryFrame( '' );
	if ( sBrowserBrand == 'IE' )
	{
		getTextInfo( 'IFrameThumbnails', sURL + '/moreinfo/welcome.txt', 'Loading welcome text...', '0', '0', '0' );
	} else {
		getTextInfo( 'IFrameThumbnails', sURL + '/moreinfo/welcome.txt', 'Loading welcome text...', '0', '0', '10' );
	}
	sAlertMessage = '';
	if ( sBrowserBrand == 'IE' )
	{
		if ( sBrowserVersion < '7' )
		{
			sAlertMessage = 'This site requires Internet Explorer 7 or greater to function properly. You may experience funtional issues.';
		}
	} elseif ( sBrowserBrand = 'FF' )
	{
		if ( sBrowserVersion < '5' )
		{
			sAlertMessage = 'This site requires Firefox 5 or greater to function properly. You may experience funtional issues.';
		}
	} elseif ( sBrowserBrand = 'OP' )
	{
		if ( sBrowserVersion < '11' )
		{
			sAlertMessage = 'This site requires Opera 11 or greater to function properly. You may experience funtional issues.';
		}
	} elseif ( sBrowserBrand = 'GC' )
	{
		if ( sBrowserVersion < '12' )
		{
			sAlertMessage = 'This site requires Google Chrome 12 or greater to function properly. You may experience funtional issues.';
		}
	} elseif ( sBrowserBrand = 'SF' )
	{
		if ( sBrowserVersion < '5' )
		{
			sAlertMessage = 'This site requires Safari 5 or greater to function properly. You may experience funtional issues.';
		}
	}
	if ( sBrowserBrand != 'IE' && sBrowserBrand != 'FF' && sBrowserBrand != 'OP' && sBrowserBrand != 'GC' && sBrowserBrand != 'SF' )
	{
		sAlertMessage = 'You are using an untested browser on this web site. You may experience funtional issues. Browser identified as ' + sUserAgent;
	}
	if ( sAlertMessage != '' && boolBrowserAlert == true )
	{
		boolBrowserAlert = false;
		alert( sAlertMessage );
	}
	return true;
}

function loadCategoryFrame( sMainCategory )
{
	//sMainCategory will be null for the initial main menu load;

	var sMainCategoryName;
	var iMainCategory;
	var iSubCategory;
	var iSubCategoryCount;
	var sIMGURL;

	hidePhotoWatermark();
	hidePhotoMenu();

	boolMenuLoaded = false;
	if ( sMainCategory == '' )
	{
		sMainCategoryName = 'main menu';
		iSubCategoryCount = iMainCategoryCount;
	} else {
		sMainCategoryName = saMainCategoryNames[ parseInt( sMainCategory, 10 ) - 1 ] + ' submenu'
		iSubCategoryCount = iaSubCategoryCount[ parseInt( sMainCategory, 10 ) - 1 ];
		iCategoryCount = iSubCategoryCount;
	}
	docCategories.open();
	docCategories.write('<HTML>');
	docCategories.write('<HEAD>');
	NoCacheHeader( docCategories );
	docCategories.write('<link rel="stylesheet" href="' + sURL + '/categories.css" type="text/css">');
	docCategories.write('</HEAD>');
	docCategories.write('<BODY BGCOLOR="#000000" CLASS="body" onload="parent.initCategoryVariables(); parent.showCategoryImages(' + iSubCategoryCount + ');" ');
	securityBody( docCategories );
	docCategories.write('>' );
	docCategories.write('<DIV ID="DivLoading" NAME="DivLoading" CLASS="divLoading divLoadingShow"><P ID="PLoading" NAME="PLoading"><FONT face=\'Verdana, Arial\' color=\'#FFFFFF\' size=\'2\'>Loading ' + sMainCategoryName + '...</FONT></P></DIV>');

	for ( iSubCategory = iSubCategoryCount; iSubCategory >= 1; iSubCategory-- )
	{
		docCategories.write('<DIV ID="DivCategory' + iSubCategory + 'Normal" NAME="DivCategory' + iSubCategory + 'Normal" CLASS="divCategory divCategoryNormal divCategory' + iSubCategory + 'Normal divCategoryShow" onmouseover="parent.unhideCategoryOver(\'' + iSubCategory + '\', \'Yes\');" ' );
		if ( sMainCategory == '' )
		{
			docCategories.write('onmousedown="parent.loadCategoryFrame( \'' + iSubCategory + '\' );">');
			sIMGURL = '/pics/categories/' + iSubCategory + '_normal.jpg';
		} else {
			docCategories.write('onmousedown="parent.loadThumbnails( \'' + sMainCategory + '\', \'' + iSubCategory + '\', \'CATEGORY\' );">');
			sIMGURL = '/pics/categories/' + sMainCategory + '_' + iSubCategory + '_normal.jpg';
		}
		docCategories.write('<IMG ID="ImgCategory' + iSubCategory + 'Normal" NAME="ImgCategory' + iSubCategory + 'Normal" CLASS="imgCategoryNormal" SRC="' + sURL + sIMGURL + '" HEIGHT="0" WIDTH="132"></DIV>');
	}
	for ( iSubCategory = iSubCategoryCount; iSubCategory >= 1; iSubCategory-- )
	{
		docCategories.write('<DIV ID="DivCategory' + iSubCategory + 'Over" NAME="DivCategory' + iSubCategory + 'Over" CLASS="divCategory divCategoryOver divCategoryHide" ');
		if ( sMainCategory == '' )
		{
			docCategories.write('onmousedown="parent.loadCategoryFrame( \'' + iSubCategory + '\' );" ');
			sIMGURL = '/pics/categories/' + iSubCategory + '_over.jpg';
		} else {
			docCategories.write('onmousedown="parent.loadThumbnails( \'' + sMainCategory + '\', \'' + iSubCategory + '\', \'CATEGORY\' );" ');
			sIMGURL = '/pics/categories/' + sMainCategory + '_' + iSubCategory + '_over.jpg';
		}
		docCategories.write('onmouseout="parent.hideCategoryOver(\'' + iSubCategory + '\', \'Yes\');"><IMG ID="ImgCategory' + iSubCategory + 'Over" NAME="ImgCategory' + iSubCategory + 'Over" CLASS="imgCategoryOver" SRC="' + sURL + sIMGURL + '" HEIGHT="363" WIDTH="226"></DIV>');
	}

	docCategories.write('</BODY>');

	docCategories.write('<HEAD>');
	NoCacheHeader( docCategories );
	docCategories.write('</HEAD>');

	docCategories.write('</HTML>');
	docCategories.close();

	return false;
}

//================================================================================;
//Thumbnails and Photos;

function showPhotoMenu()
{
	divPhotoMenuNormal.className = 'divPhotoMenu divPhotoMenuShow';
	return false;
}

function hidePhotoMenu()
{
	divPhotoMenuNormal.className = 'divPhotoMenu divPhotoMenuHide';
	divPhotoMenuOver.className = 'divPhotoMenu divPhotoMenuHide';
	return false;
}

function showPhotoWatermark( sType )
{
	hidePhotoWatermark();
	if ( sType == 'Normal' )
	{
		divPhotoWatermarkNormal.className = 'divPhotoWatermarkNormal divPhotoWatermarkShow';
	} else {
		divPhotoWatermarkPano.className = 'divPhotoWatermarkPano divPhotoWatermarkShow';
	}
	return false;
}

function hidePhotoWatermark()
{
	divPhotoWatermarkNormal.className = 'divPhotoWatermarkNormal divPhotoWatermarkHide';
	divPhotoWatermarkPano.className = 'divPhotoWatermarkPano divPhotoWatermarkHide';
	return false;
}

function photoMenuBack()
{
	if ( sMenuCategory != '' )
	{
		loadCategoryFrame( sMenuCategory );
		return false;
	}
	if ( sMenuService != '' )
	{
		loadService( sMenuService );
		return false;
	}
	return false;
}

function loadPhoto( sMainCategory, sSubCategory, sFile, sType )
{
	var saPanos;

	if ( boolMenuLoaded == false )
	{
		return false;
	}
	if ( boolExternalSite == true )
	{
		hideExternalSiteBack();
		boolExternalSite = false;
	}
	//load the specified photo into the categories frame;

	var dateCurrent = new Date();
	var timeMilliseconds = dateCurrent.getTime();
	var sFileFull;

	if ( sSubCategory == '' )
	{
		sFileFull = sMainCategory + '_' + sFile;
	} else {
		sFileFull = sMainCategory + '_' + sSubCategory + '_' + sFile;
	}

	//see if the image is a pano, since we have to use a different watermark size div;
	var sPhotoSize = 'Normal';
	if ( sType == 'SERVICE' )
	{
		saPanos = saServicePanos;
	} else {
		saPanos = saCategoryPanos;
	}
	for ( var iIndex = 0; iIndex < saPanos.length; iIndex++ )
	{
		if ( sFileFull == saPanos[ iIndex ] )
		{
			sPhotoSize = 'Pano';
		}
	}

	if ( sType == 'SERVICE' )
	{
		sMenuService = sMainCategory;
		sMenuCategory = '';
	} else {
		sMenuCategory = sMainCategory;
		sMenuService = '';
	}

	docCategories.open();
	docCategories.write('<HTML>');

	docCategories.write('<HEAD>');
	NoCacheHeader( docCategories );
	docCategories.write('<link rel="stylesheet" href="' + sURL + '/photo.css" type="text/css">');
	docCategories.write('</HEAD>');

	docCategories.write('<BODY BGCOLOR="#000000" CLASS="body" ');
	docCategories.write('onload="parent.showPhotoWatermark( \'' + sPhotoSize + '\'); parent.showPhotoMenu();" ');
	securityBody( docCategories );
	docCategories.write('>');

	docCategories.write('<DIV ID="DivPhoto" NAME="DivPhoto" CLASS="divPhoto ' );
	if ( sPhotoSize == 'Normal' )
	{
		docCategories.write('divPhotoNormal' );
	} else {
		docCategories.write('divPhotoPano' );
	}
	docCategories.write('" ALIGN="Center"><IMG ID="ImgPhoto" NAME="ImgPhoto" CLASS="imgPhoto" SRC="' + sURL );

	if ( sType == 'SERVICE' )
	{
		docCategories.write('/pics/services/images/' + sFileFull );
	} else {
		docCategories.write('/pics/categories/images/' + sFileFull );
	}

	docCategories.write('?' + timeMilliseconds + '">' );
	docCategories.write('</DIV>');
	docCategories.write('</BODY>');

	docCategories.write('<HEAD>');
	NoCacheHeader( docCategories );
	docCategories.write('</HEAD>');

	docCategories.write('</HTML>');
	docCategories.close();

	return false;
}

function loadThumbnails( sMainCategory, sSubCategory, sType )
{
	var sFile = '';
	var sIMGName = '';
	var sFirstLast = '';
	var iPhotoCount;
	var iIndex;
	var dateCurrent = new Date();
	var timeMilliseconds = dateCurrent.getTime();
	var boolSubService = false;
	var saCategoryInfoTemp = getCategoryInfo( sMainCategory, sSubCategory, sType );
	//alert( saCategoryInfoTemp[0] );
	//alert( saCategoryInfoTemp[1] );
	//alert( saCategoryInfoTemp[2] );
	if ( sType == 'SERVICE' )
	{
		//The service might have a subservice;
		if ( sSubCategory != '' || saCategoryInfoTemp[ 1 ] == 'X' )
		{
			//no subservice;
			iPhotoCount = parseInt( saCategoryInfoTemp[ 2 ], 10 );
		} else {
			//subservice. Get the # of subservices;
			iPhotoCount = iaSubServiceCount[ parseInt( sMainCategory, 10 ) - 1 ];
			boolSubService = true;
		}
	} else {
		iPhotoCount = parseInt( saCategoryInfoTemp[ 2 ], 10 );
	}

	docThumbnails.open();
	docThumbnails.write('<HTML>');

	docThumbnails.write('<HEAD>');
	NoCacheHeader( docThumbnails );
	docThumbnails.write('<link rel="stylesheet" href="' + sURL + '/thumbnails.css" type="text/css">');
	docThumbnails.write('</HEAD>');

	docThumbnails.write('<BODY BGCOLOR="#000000" CLASS="body" ');
	securityBody( docThumbnails );
	docThumbnails.write('>');
	docThumbnails.write('<TABLE CLASS="tableThumbnail">');
	docThumbnails.write('<TR>');

	if ( boolSubService == true )
	{
		for ( iIndex = 1; iIndex <= iPhotoCount; iIndex++ )
		{
			sFile = sMainCategory + '_' + iIndex + '_normal.jpg';
			sIMGName = 'Img' + sMainCategory + iIndex + 'normal';
			docThumbnails.write('<TD class="tdThumbnail">' );

			docThumbnails.write('<IMG ID="' + sIMGName + '" NAME="' + sIMGName + '" SRC="' + sURL );
			docThumbnails.write('/pics/services/' + sFile );
			docThumbnails.write('?' + timeMilliseconds + '" ' );
			docThumbnails.write('CLASS="thumbnail thumbnailNormal" onmouseover="parent.swapOver( \'docThumbnails\', \'' + sIMGName + '\', \'thumbnail thumbnailOver\', \'Yes\' );" onmouseout="parent.swapOver( \'docThumbnails\', \'' + sIMGName + '\', \'thumbnail thumbnailNormal\', \'Yes\' );" onmousedown="parent.loadThumbnails(\'' + sMainCategory + '\', \'' + iIndex + '\', \'SERVICE\');"></TD>');
		}
	} else {
		for ( iIndex = 1001; iIndex < ( 1001 + iPhotoCount ); iIndex++ )
		{
			sFile = iIndex + '.jpg';
			sIMGName = 'Img' + iIndex;
			docThumbnails.write('<TD class="tdThumbnail">' );

			docThumbnails.write('<IMG ID="' + sIMGName + '" NAME="' + sIMGName + '" SRC="' + sURL );
			if ( sType == 'SERVICE' )
			{
				docThumbnails.write('/pics/services/thumbnails/' + sMainCategory + '_' );
				if ( sSubCategory != '' )
				{
					docThumbnails.write( sSubCategory + '_' );
				}
				docThumbnails.write( sFile );
			} else {
				docThumbnails.write('/pics/categories/thumbnails/' + sMainCategory + '_' + sSubCategory + '_' + sFile );
			}
			docThumbnails.write('?' + timeMilliseconds + '" ' );
			docThumbnails.write('CLASS="thumbnail thumbnailNormal" onmouseover="parent.swapOver( \'docThumbnails\', \'' + sIMGName + '\', \'thumbnail thumbnailOver\', \'Yes\' );" onmouseout="parent.swapOver( \'docThumbnails\', \'' + sIMGName + '\', \'thumbnail thumbnailNormal\', \'Yes\' );" onmousedown="parent.loadPhoto(\'' + sMainCategory + '\', \'' + sSubCategory + '\', \'' + sFile + '\', \'' + sType + '\');"></TD>');
		}
	}

	docThumbnails.write('</TR>');
	docThumbnails.write('</TABLE>');
	docThumbnails.write('</BODY>');

	docThumbnails.write('<HEAD>');
	NoCacheHeader( docThumbnails );
	docThumbnails.write('</HEAD>');

	docThumbnails.write('</HTML>');
	docThumbnails.close();

	return false;
}

function clearThumbnailFrame()
{
	docThumbnails.open();
	docThumbnails.write('<HTML>');

	docThumbnails.write('<HEAD>');
	NoCacheHeader( docThumbnails );
	docThumbnails.write('<STYLE type="text/css">');
	docThumbnails.write('.body');
	docThumbnails.write('{');
	docThumbnails.write('	margin: 0px;');
	docThumbnails.write('	background-color: #000000;');
	docThumbnails.write('	background-image: url(\'' + sURL + '/pics/backgroundBody.gif\');');
	docThumbnails.write('}');
	docThumbnails.write('</STYLE>');
	docThumbnails.write('</HEAD>');

	docThumbnails.write('<BODY BGCOLOR="#000000" CLASS="body" ');
	securityBody( docThumbnails );
	docThumbnails.write('>');
	docThumbnails.write('</BODY>');

	docThumbnails.write('<HEAD>');
	NoCacheHeader( docThumbnails );
	docThumbnails.write('</HEAD>');

	docThumbnails.write('</HTML>');
	docThumbnails.close();

	return false;
}
