onerror = function(msg,url,line) { top.document.title = "Error: L#" + line + ": " + msg; return true; }

window.onload = bodyOnLoadItems;

singlePhotoViewerPresent=0; //init var
slideShowPresent=0; //init var
factSheetPresent=0; //init var
inlineActive=0; //init var
videoformat=0; //init var for adjusting footer location with wide video format
localfolder=0;
//buildingPhotos=0; //init var for selection of building photos
function bodyOnLoadItems(){  //this function handles the first load to make sure entire page is loaded before timer starts. Subsequent timers are started by mainImageLoadItems()
			var agt=navigator.userAgent.toLowerCase();
		var is_ie6up  = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
		var is_gecko = (agt.indexOf('gecko') != -1);
		d2=document.getElementById("content");
		dc=document.getElementById("container");
		ph=document.getElementById("pageheader");
		pf=document.getElementById("pagefooter");
		sf=document.getElementById("sitefooter");
		//sf.style.bottom=10;

		//if(is_gecko) pf.style.bottom=-3;
		//m4=document.getElementById("meta4footer");
		//m4.style.display='';
		//if(is_gecko) m4.style.bottom=-60;


	if(ph.offsetHeight) {phheight=ph.offsetHeight*1;}
		else {phheight=ph.style.pixelHeight*1;}
		
	createMenuCategoryArrays();  //build array of all menus

	if(d2.offsetHeight) {h2=d2.offsetHeight*1;}
		else {h2=d2.style.pixelHeight*1;}
		
		//maxHeight=Math.max(h1,h2); 
		
		adjfactor = 0;
		
		//if(is_ie6up) adjfactor=adjfactor;
		if(is_gecko) adjfactor=adjfactor+0; //required due to different treatment of borders
		
		//if (h1 < maxHeight) d1.style.height=maxHeight;
		//if (h2 < h1) d2.style.height=maxHeight;
		if(inlinePage==1){
			adjfactor = -38;
			sft=textHeight*1+60;
			sf.style.top=sft;
			d2h=textHeight*1;
			d2.style.pixelHeight=d2h;//sf.style.top=d2.style.pixelHeight+phheight+textHeight+30;} //textHeight is set only when inline frames are used. This uses the preset inline height instead of measuring the content div
			pft=d2h+phheight+adjfactor;
			
			//pf.style.top=pft;
			//pf.style.top=pft;
			pf.style.top=d2h+phheight+adjfactor;
			
			
			//sf.style.top=h2+phheight+adjfactor+10;

			}
		
		else	{
			//d2.style.pixelHeight=990;	
			pf.style.top=h2+phheight+adjfactor-30;
			//alert(sf.style.top);
			sf.style.top=h2+phheight+adjfactor+10;
		

		}
		
		

		if(document.contactfields) document.contactfields.name.focus(); //focus to name field if contact page loaded
		
		if(singlePhotoViewerPresent==1){singlePhotoViewerBodyOnLoadItems();}
}


function createMenuCategoryArrays(){  //called by onload items to update main menu color
		
		 mainMenu=document.getElementById("menusystem");
		 menuItems=mainMenu.getElementsByTagName("a"); //create array of menu items in menu table
		 menuItemsCount = menuItems.length ; //count all members
		 for ( var i = 0; i < menuItemsCount; i++) {  //restore all menu items to white
			if(menuItems[i].name==menuName){
				menuItems[i].style.color = '#ffff00';
				//alert(i);
				}
			else menuItems[i].style.color='#ffffff'; //collect variable from index to determine which menu item clicked and give it a distinctive color
			}
}

function menuItemMouseOver(f) {
	
	//f.style.color='#ffff00';
	//f.style.textDecoration='underline';
	//f.style.backgroundColor = '#ffff00';
		}

function menuItemMouseOut(f) {
	//f.style.textDecoration='none';
	//f.style.fontweight='normal';
	}

function menuSearchMouseOver(f) {
	window.clearTimeout(menuTimer);
	searchMenuPopup.style.visibility='visible';
	}

menuTimer=0;

function menuSearchMouseOut(f) {
		searchMenuPopup.style.visibility='hidden';
	}

//slide show settings - add overrides in each photo-tour
timerDelay=5000; //number of miliseconds between slides
autoStartSlideShow = 1;
useSlideTransition = 1; //set javascript var from PHP var to allow/prevent transitions
slideShowTitle = 'Photos';  //used to display on first slide, and all slides if persiatent
slideShowTitlePersistant = 'n'; //used to preserve title across all slides in place of filenames or other captions 
maxImageHeight = 0;  //used by setImageSize() to limit slide height
 
//Initialize JavaScript Globals
slideShowRunningFlag = 0;  //used by slideTimer(), mainImageOnLoadItems(), updated by bodyOnLoadItems()
firstLoadFlag = 1;  //used by setImageCaption() to apply slide-show title in place of other caption
positionInArray = 0; //initialize var that determines the 'active' thumbnail. Updated by updateThumbnailInfo() after main image loads  
thumbnailCount = 1; //initialize count var. Updated by updateThumbnailInfo
thumbnails = 0;  //initialize var to hold array of images in thumbnail table
pausedFlag=0; //used to track if slide-show is paused by clicking on fact sheet button
pageloadedflag='no'; //used to suppress menus pre-load

//slide show functions

function mainImageOnLoadItems(){ 
	
	
	if(firstLoadFlag == 0){ // these items cause occasional errors when triggered by image load on first page load, when image outruns page and theumbnails not all there yet
		updateThumbnailInfo(); //update thumbnails position in array for setCaptions()
		setImageCaption();
		locateCurrentImageInCategoryArrays();
		}
	if(useSlideTransition == 1) fadeIn(document.pic,0)  //fadeIn() starts timer if needed
	else {
		document.pic.style.visibility = 'visible'; //restore visibility removed by getNextPhoto() or selectPhoto() and otherwise restored by fadeIn()
		slideTimer();
		
		}
}

function slidesBodyOnLoadItems(){  //this function handles the first load to make sure entire page is loaded before timer starts. Subsequent timers are started by mainImageLoadItems()
	if(firstLoadFlag == 1){ //
		if(targetPhoto != 'no'){
			sourcetext=document.pic.src;
			startSplit=sourcetext.lastIndexOf("/") ;  //get location of the last slash in path of new main image
			endSplit=sourcetext.lastIndexOf(".") ;	//get location of the last dot preceeding file extension
				
			textToReplace = sourcetext.substring(startSplit+1,endSplit); //extracts file name from full path to look up dimensions in js array
			document.pic.src=document.pic.src.replace(textToReplace,targetPhoto);
			setImageSize() 
			}
	
		updateThumbnailInfo(); //update thumbnails position in array for setCaptions()
		setImageCaption();
		createTourMenuCategoryArrays();  //build array of all tour menus
		createImageCategoryArrays();  //build array of div image arrays
		//sf.style.display='none';
		
		//createMenuContentArrays(); //build array of other content 
		//createFactSheetCategoryArrays() //build array of all factsheet sections
		//createFactSheetMenuCategoryArrays() //build array all factsheet menus
		//parent.I1.focus();
		
		
		}
		
	if(autoStartSlideShow){
		toggleStartStopButton();  //update startStopButton labels
		slideShowRunningFlag = 1;
		autoStartSlideShow = 0;  //clear autoStart flag after first image load and rely on slide show running flag
		slideTimer();
		}
	
	
	pageloadedflag='yes';  //used as conditional in rules to prevent menu click too soon
	revealHiddenItemsOnLoad(); //menu table and fact sheet hidden by style and displayed after document load to prevent premature clicking
	
	//if(targetPhoto != 'no') selectByNumber(targetPhoto);
	if(autoplayOverride!= 'no') toggleStartStopButton();
		
}

function singlePhotoViewerBodyOnLoadItems(){
	sf.style.top='595px';
	sf.style.left='310';

	if(targetPhoto != 'no') selectByNumber(targetPhoto);
}


function toggleStartStopButton(caller){
	if(slideShowRunningFlag==0){  //if slide-show stopped
		document.getElementById("startStopButton").value = "Click to Pause";  //update button labels
		document.getElementById("nextButton").style.visibility="visible";
		document.getElementById("backButton").style.visibility="visible";
		//delay=timerDelay; //reset timer to default
	
		if(caller == 'startStopButton') {
			getNextPhoto(1); //immediately advance to next slide if show started by clicking startStopButton, but not if autoplay
			slideShowRunningFlag=1;  //then set the running flag to on
			}
		if(pausedFlag==1) {
			getNextPhoto(1); ////if slide-show stopped by clicking fact sheet button
			slideShowRunningFlag=1;  //then set the running flag to on
			pausedFlag=0;
			}
			
			
				
		}
	else {  //if slide-show already running
		slideShowRunningFlag=0;
		window.clearTimeout(slideTimerID); //cancel any running slide timers so pending slide change does not happen
		document.getElementById("startStopButton").value = "Click to Autoplay";
		document.getElementById("nextButton").style.visibility="hidden";
		document.getElementById("backButton").style.visibility="hidden";
	}
}


function slideTimer(){
		if(slideShowRunningFlag==1){
			window.clearTimeout(slideTimerID); //cancel any running slide timers - important if you click on thumbnail while slide-show running
			slideTimerID = window.setTimeout("getNextPhoto(1);", delay);
		}
}

function fadeIn(objId,opacity) {  //The fadeIn function is called by the main image's load event and uses a Timeout function to call itself every 'X' miliseconds with an object Id and an opacity. The opacity is specified as a percentage and increased 10% at a time. The loop stops once the opacity reaches 100%:
      document.pic.style.visibility = 'visible';
      if (opacity >= 99) {document.pic.style.filter='';} //clear filter after transition to remove distortion it creates/reveals in some images
      if (opacity <= 100) {
      setOpacity(document.pic, opacity);
      if(opacity > 0) opacity = opacity*1.222846;
      	else opacity += 20;
      fadeInTimerID = 0;
      var fadeInTimerID = window.setTimeout("fadeIn('"+objId+"',"+opacity+")", 40);
    	}
	  if(slideShowRunningFlag) slideTimer(); //start timer once transition is complete
	  document.pic.style.opacity = 100; //restore firefox opacity
}

function setOpacity(obj, opacity) {
  opacity = (opacity == 100)?99.999:opacity;
  
  // IE/Win
  obj.style.filter = "alpha(opacity:"+opacity+")";
  //obj.style.filter='progid:DXImageTransform.Microsoft.BasicImage(opacity="+opacity+")'; //try later
  
  // Safari 1.2, newer Firefox and Mozilla, CSS3
  obj.style.opacity = opacity/100;
}

function updateThumbnailInfo(){  //determines position of thumbnail coresponding to current main image and sets borders accordingly. Also sets positionInArray and thumbnailCount 
	thumbnailCell=document.getElementById("thumbnailDiv");
	if(thumbnails=thumbnailCell.getElementsByTagName("img")){  // Make sure thumbnail table download completed before relying on it to get size. Just playing it safe with this conditional
	 	thumbnailCount = thumbnails.length ; //count all thumbnail table images. If not downloaded yet, use defaults set in declarations
	 	//alert(thumbnailCount);
	 }
	currentThumbnailFileName = document.pic.src.replace('images', 'thumbnails')  //gets name of thumbnail version of current main photo
		for ( var i = 0; i < thumbnailCount; i++) {  //find current thumbnail's index in images array
			if (currentThumbnailFileName == thumbnails[i].src){
					positionInArray = i;
								}
	}
	for ( var i = 0; i < thumbnailCount; i++) {  //set all thumbnail borders to standard color to clear out any that have distinctive border color
		thumbnails[i].style.borderColor='#555555';	}
		
	thumbnails[positionInArray].style.borderColor='#ff0000';  //add distinctive border to current thumbnail
	preloadNextImage(positionInArray)
}

function selectPhoto(source)	{  //triggered by clicking on thumbnail image which sends its name as argument to this function
	document.pic.style.visibility = 'hidden';  //hide current photo
	document.pic.src=source.replace('thumbnails', 'images') ;  // sets main image equal to full-sized version of clicked thumbnail
	setImageSize(); //needed only in html version. Size update automatically in PHP
}

function selectByNumber(e)	{  //triggered by typing photo file number
		if(e=='Enter pic #'){
			alert("Please enter four-digit image number");
			}
			
		else {
			imageToFind=e + '.jpg';
			if(singlePhotoViewerPresent) {
				document.pic.src= e +'.jpg';  //local folder defined in each slide-show page
				return;
				}

			if(jsimagesarray[imageToFind]){  //associative array elements accessed directly - no looping needed
				document.pic.style.visibility = 'hidden';  //hide current photo
				document.pic.src=localfolder + e +'.jpg';  //local folder defined in each slide-show page
				
				setImageSize();
				}
			else {
				alert("Photo not found.");
				}
		}
		
		if(slideShowPresent==1){
			document.getElementById("typeImageNumber").value='Enter pic #'; 
			document.getElementById("typeImageNumber").blur();
			}
	//locateCurrentImageInCategoryArrays()
	//alert(currentThumbnailFileName)
	updateThumbnailInfo();
	//alert(positionInArray)
}

function getNextPhoto(direction) {	//called by clicking next or back buttons - if included, or on main photo itself which serves as next button. To add back button call this script with an argument of -1
	

	nextPhotoIndex = positionInArray + direction; //sets images array index of next photos thumbnail
	if(direction == 1 && positionInArray == thumbnailCount-1){nextPhotoIndex = 0};  //override nextPhotoIndex if end of list and direction is next
	if(direction == -1 && positionInArray == 0){nextPhotoIndex = thumbnailCount-1};	//override nextPhotoIndex if end of list and direction is back
	nextPhotoThumbnail = thumbnails[nextPhotoIndex].src  //gets full path name of next image's thumbnail
	document.pic.style.visibility = 'hidden'; //hide image to avoid strange transition. Visibility restored by image's OnLoadItems()
	document.pic.src=nextPhotoThumbnail.replace('thumbnails', 'images') ;  //set full sized image to full sized version of next images thumbnail
	setImageSize(); //needed only in html version. Size update automatically in PHP
}


function setImageSize(){  //called by selectPhoto() and getNextPhoto()
	source=document.pic.src;  //determine current image filename
			
	currentThumbnailFileName = source.replace('images', 'thumbnails') ;  //replace image folder with thumbnail folder name to get full pathname of current thumbnail
	
	startSplit=source.lastIndexOf("/") ;  //get location of the last slash in path of new main image
	endSplit=source.lastIndexOf(".") ;	//get location of the last dot preceeding file extension
	imageToLookup = source.substring(startSplit+1,endSplit+4); //extracts file name from full path to look up dimensions in js array
	//alert(imageToLookup);
	newDimensions=jsimagesarray[imageToLookup];  //finds current main image src in jsimagesarray and gets dimensions string
	
	startSplit=newDimensions.lastIndexOf("width") ;  //parse dimensions string for width
	endSplit=newDimensions.lastIndexOf("height") ; //find 'height' and back up	
	newWidth = newDimensions.substring(startSplit+7,endSplit-2); 
		
	startSplit=newDimensions.lastIndexOf("=") ;  //parse dimensions string for height
	endSplit=newDimensions.length ;	
	newHeight = newDimensions.substring(startSplit+2,endSplit-1);
	
	if(maxImageHeight > 0 && newHeight > maxImageHeight) {
		 newWidth = maxImageHeight/newHeight * newWidth;
		 newHeight = maxImageHeight;
		 }
		
	document.pic.width=newWidth; //apply dimensions of current jpg to documents main image
	document.pic.height=newHeight;
	
	//preloadNextImage();
	//preloadAllImages();
}

function preloadNextImage(positionInArray){ //called by updateThumbnailInfo, which passes positionInArray of current thumbnail
	nextPosition = positionInArray + 1; //sets images array index of next photo's thumbnail
	if(nextPosition > thumbnailCount-1){return;}  //return if end of list
	else {
		nextThumbnail = thumbnails[nextPosition].src;
		nextImage = nextThumbnail.replace('thumbnails', 'images')  //gets name of full-sized version of next thumbnail
 		var imageToPreload = "image" + 	nextPosition ; //create unique name
		imageToPreload = new Image();
		imageToPreload.src = nextImage;
		}
}


function setImageCaption(){
	source=document.pic.src;  //determine current image filename
	startSplit=source.lastIndexOf("/") ;  //get location of the last slash in path of current image
	endSplit=source.lastIndexOf(".") ;	//get location of the last dot preceeding file extension
	imageCaptionText = source.substring(endSplit-4,endSplit); //extracts short file name from full path to use as caption text
	imageCaptionText=imageCaptionText.replace('_', ' ');	//replace underscores with spaces
	
	if (thumbnails[positionInArray].name != 'EnterCaptionHere'){ //override caption text if a custom thumbnail caption has been added in place of the thumbnail's HTML default of 'EnterCaptionHere'
		imageCaptionText = thumbnails[positionInArray].name;
		}
		
	if(firstLoadFlag){
		firstLoadFlag=0; //clear flag that otherwise causes mainImageOnLoadItems() to use slide title in place of normal caption on first slide
		if(slideShowTitle) imageCaptionText = slideShowTitle ; // Override caption text with slide-show title/welcome text if welcome text exists and this is initial page load.
		}
	if(slideShowTitle && slideShowTitlePersistant == 'y') imageCaptionText = slideShowTitle ; // Override caption text with slide-show title/welcome text for all slides
	document.getElementById("captionText").innerHTML = imageCaptionText ;  //set caption equal to file name or custom caption if found in thumbnail name tag - use innerHTML instead of innerText for compatabilty with firefox
}	 	


toggleSpanTimedTimerID = 0;

function toggleSpanTimed(e){			//displays/hides span
	if (e.style.display == "none"){
		e.style.display = "";
		toggleSpanTimedTimerID = window.setTimeout("navigationTextMessage.style.display = 'none'", 7000);
	}
	else{
		e.style.display = "none";
	}
}

	
function checkKeycode(e) { //attached to body - onkeydown in myrules below
	if (!e) e = window.event;
	keycode = e.which || e.keyCode;
	//window.status = keycode;
		if(keycode==39){getNextPhoto(1)} //right arrow
		if(keycode==37){getNextPhoto(-1)} //left arrow
		if(keycode==32){getNextPhoto(1)} //spacebar to advance
		if(keycode==13){
			if(document.getElementById("typeImageNumber").value != "Enter pic #") {selectByNumber(document.getElementById("typeImageNumber").value);}  //select specific photo by number is enter pressed and non-default text in select photo box
			else {getNextPhoto(1)} //enter to advance
		}
			
		if(keycode==75){toggleSpanTimed(navigationTextMessage)} //K for keyboard shortcuts
		if(keycode==107){toggleSpanTimed(navigationTextMessage)} //k for keyboard shortcuts
			
		if(keycode==27 && slideShowRunningFlag == 1){toggleStartStopButton()} //escape to stop slideshow
		if(keycode==65 || keycode == 97){document.getElementById("startStopButton").click()} // 'a' to toggle Autoplay
		//if(keycode==83 || keycode == 115){document.getElementById("startStopButton").click()} // 'S' to toggle Autoplay
			
		if(keycode==38 && slideShowRunningFlag == 1){document.getElementById("nextButton").click()} // cursor up to increase speed
		if(keycode==40 && slideShowRunningFlag == 1){document.getElementById("backButton").click()} // cursor down to decrease speed
	}


delay = timerDelay;  //timer uses this variable to preserve default timerDelay value
timerID0 = 0; //one for next and back buttons so their text reverts to standard label from slide speed independently of each other
timerID1 = 0;
slideTimerID = 0;
speedAdjustmentInterval = 1000;  //number of miliseconds added/subtracted from slide internal when clicking on faster/slower buttons
maxSpeed = 1000;  //this is the shortest interval allowed. 500 ms is one-half second. Smaller numbers represent faster speeds

function evalButton(e){
	if(e=='next') getNextPhoto(1);
	if(e=='back') getNextPhoto(-1);
	if(e=='pic') getNextPhoto(1);
	if(e=='backArrow') getNextPhoto(-1);
	if(e=='nextButton' && slideShowRunningFlag == 0) getNextPhoto(1);
	if(e=='backButton' && slideShowRunningFlag == 0) getNextPhoto(-1);
	if(e=='nextButton' && slideShowRunningFlag == 1) { //shorten delay and speed up
		delay = delay - speedAdjustmentInterval; //shorten delay and speed up if not at max
		if(delay <= maxSpeed) delay=maxSpeed;
		//delayFriendly = Math.round(60000/delay) //round to whole numbers
		delayFriendly = Math.round(delay /1000); //add a decimal place when below 10
		document.getElementById("nextButton").value = delayFriendly + " sec.";
		if(delay <= maxSpeed) {document.getElementById("nextButton").value = "Maximum";}
		window.clearTimeout(timerID0); //reset timer so multiple instances aren't running
		timerID0=window.setTimeout("document.getElementById('nextButton').value = ' Faster '", 3000);
		}
	if(e=='backButton' && slideShowRunningFlag == 1){
		delay = delay - -speedAdjustmentInterval; //shorten delay and speed up if not at max
		//alert(delay);
		delayFriendly = Math.round(delay/1000); //round to whole numbers
		document.getElementById("backButton").value = delayFriendly + " sec.";
		window.clearTimeout(timerID1); //reset timer so multiple instances aren't running
		timerID1=window.setTimeout("document.getElementById('backButton').value = ' Slower '", 3000);
		}
}


function viewLargeImage(){ //create popup window, add image, resize window to fit
	largeImage=document.pic.src.replace('images', 'originals');
	PopupWindow=window.open(largeImage,'Popup', 'toolbar=yes,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes,left=10,top=10');PopupWindow.focus();return false;
}

function orderPrints(url,stopSlides){ //
	if(slideShowRunningFlag == 1){toggleStartStopButton()};
	//largeImage=document.pic.src.replace('images', 'originals');
	PopupWindow=window.open(url,'Popup', 'toolbar=yes,menubar=yes,location=no,status=no,scrollbars=yes,resizable=yes,left=10,top=10');PopupWindow.focus();return false;
}



function viewLargeMap(){ //create popup window, add image, resize window to fit
	largeImage=document.targetmapimage.src.replace('/maps', '/originals');
	PopupWindow=window.open(largeImage,'Popup', 'toolbar=yes,menubar=no,location=no,status=no,scrollbars=yes,resizable=yes,left=10,top=10');PopupWindow.focus();return false;
	
}


allStatusFlag=0; //used by updateMenu() - prevent onload event from firing if all was clicked.

function createImageCategoryArrays(){  //called by img on load items 
		categoryDivs=document.getElementById("thumbnailDiv").getElementsByTagName("div"); //create array of divs in thumbnail table
		categoryDivsCount = categoryDivs.length ; //count all thumbnail divs
		divImagesArray = new Array(); //creates multi-dim array of images within each category div array
	 		for ( var i = 0; i < categoryDivsCount ; i++) {  
				divImagesArray[i]=categoryDivs[i].getElementsByTagName("img");	
				}
}



function createTourMenuCategoryArrays(){  //called by img on load items to update menus color and tvisible category divs during auto-play
		 tourMenuItems=document.getElementById("tourMenus").getElementsByTagName("a"); //create array of menu items in menu table
		 tourMenuItemsCount = tourMenuItems.length ; //count all members 
		 //alert(tourMenuItemsCount);

		
}
function createMenuContentArrays(){  //called by img on load items to update menus color and tvisible category divs during auto-play
		//menuContentItems=tourMenuItems.getElementsByTagName("a"); //create array of menu items in menu table
		//menuContentItemsCount = tourMenuItems.length ; //count all members 
}




function locateCurrentImageInCategoryArrays()	{  //called by image onload events
		category=0;  //initialize category as 0, the first category, in case a specific photo not in a category is requested via query string
		currentThumbnailFileName = document.pic.src.replace('images', 'thumbnails');  //gets name of thumbnail version of current main photo
		
		for ( var i = 0; i < categoryDivsCount ; i++) {  //find current thumbnail's category and index within that category
			for (var j = 0; j < divImagesArray[i].length ; j++) { 
				if (currentThumbnailFileName == divImagesArray[i][j].src){
					category=i;
					sequence=j;
				}
			}
		}
		
	
	updateCategoryAndMenuDisplay(category,'function');  //caller used to distinguish between menuclick and autoadvance in called function
}



function updateTopInclude(e){  //called by clicking on factsheet button
	topIncludeDiv.style.display='';
	imageSpan.style.display='none';  //hide image
	captionSpan.style.display='none';
	backArrow.style.display='none';
	nextArrow.style.display='none';
	startStopButton.style.display='none';
	nextButton.style.display='none';
	backButton.style.display='none';
	navigationText.style.display='none';
	//document.floorplanimg.src='graphics/floorplan.gif'; //replace low weight holder image in factsheet
	//mapHolder.background='graphics/pelicanmap1.gif';  //replace low weight holder image in factsheet
	//slideShowLabel.style.display='none';
	if(slideShowRunningFlag==1){
		toggleStartStopButton()
		pausedFlag=1};  //set so menu click function will only restart it if it was paused here
	bottomcontent.style.display = "none";
	
			

	
}

function adjustFooterPosition(){
	sf.style.top='630px';
	if(localfolder=='bohemiavideo') sf.style.top = '600px';
	if(localfolder=='races/ironhill08') sf.style.top = '710px';
	
}	

function revealHiddenItemsOnLoad(){		
	document.getElementById("tourMenuDiv").style.display='';
	document.getElementById("slideShowButtons").style.display='';
	if(document.getElementById("vieworiginalbutton"))document.getElementById("vieworiginalbutton").style.display='';
	if(document.getElementById("orderprintsbutton"))document.getElementById("orderprintsbutton").style.display='';
	if(document.getElementById("raceresults"))document.getElementById("raceresults").style.display='';
	if(document.getElementById("getImageByNumber"))document.getElementById("getImageByNumber").style.display='';
	if(document.getElementById("typeImageNumber"))document.getElementById("typeImageNumber").style.display='';
	if(document.getElementById("viewvideobutton"))document.getElementById("viewvideobutton").style.display='';
	document.getElementById("imagesloadingmessage").style.display='none';
	
	
}
	
function menuButtonMouseOver(f) {
	//f.style.backgroundColor ='2f3342';
	f.style.textDecoration='underline';
	
	}

function menuButtonMouseOut(f) {
	//f.style.backgroundColor ='42475b';
	f.style.textDecoration='none';
	}
	
function contentButtonMouseOver(f) {
	//f.style.backgroundColor ='2f3342';
	//f.style.color ='ffff00';
	f.style.textDecoration='underline';
	
	}

function contentButtonMouseOut(f) {
	//f.style.backgroundColor ='42475b';
	//f.style.color ='ffffff';
	f.style.textDecoration='none';
	}
	
	
function updateCategoryAndMenuDisplay(e,caller){  //update menu color and thumbnail display when category changes called by menu click
		if(caller=='menuClick'){  //used to prevent reverting to overview when all clicked since first image in all is in first cat div
			if(e=='all') {allStatusFlag=1;}
			else {allStatusFlag=0;}
		}		
		
		for ( var i = 0; i < categoryDivsCount; i++) { //hide all category divs
			categoryDivs[i].style.display = "none";
			}
			
		if(document.getElementById("sitefootertour"))document.getElementById("sitefootertour").style.display='';
			
		for ( var i = 0; i < tourMenuItemsCount; i++) {  //restore all menu items to white
			tourMenuItems[i].style.color = '#ffffff';	
			}
			
		  
				
		if (allStatusFlag==1){
			if(caller=='menuClick') {selectPhoto(divImagesArray[0][0].src.replace('thumbnails','images')) } //set active image to first member of all thumbnails category
			
			for ( var i = 0; i < categoryDivsCount; i++) { //reveal all divs
				categoryDivs[i].style.display = "";
			}
						
			menuItems.menuall.style.color = '#ff0000';	//make 'all' menu red	
		}
		
		else{
			if(caller=='menuClick') {
				selectPhoto(divImagesArray[e][0].src.replace('thumbnails','images')) } //set active image to first member of thumbnail category div
				categoryDivs[e].style.display = "";  //display current category div
				tourMenuItems[e].style.color='#ff0000';
			}
}
	
	

function updateImage(e) { 
	//alert(e);
	if(e=='maps/') e='maps/whiteclay111107.gif';
	document.getElementById("targetmapimage").setAttribute("src",e);
	 	
}


	
planFlag=0;

function createAndUpdateFloorPlan(e) { //

if(planFlag==0){
		planImage = document.createElement("img");
	  	document.getElementById("floorPlanZone").appendChild(planImage);
	  	planImage.setAttribute("border",'1');
	 	
	  	planFlag=1;
	  	}
	 	
if(e==0)planImage.setAttribute("src",'floorplans/355floorplan-g.gif'); 
if(e==1)planImage.setAttribute("src",'floorplans/355floorplan-1.gif');
if(e==2)planImage.setAttribute("src",'floorplans/355floorplan-2.gif');
  	
}

function saveFile (fname)
{
	document.execCommand('SaveAs',null,fname)
	
}



	
var myrules = {
	
	'a.emaillink' : function(element){
		
		element.onfocus = function(){
			this.hideFocus=true;
		}
		
		element.onclick = function(){
			{if(this.name=='email')parent.location='mailto:tom@Meta4Photo.com?subject=Email From GPS Bike Maps Site'; return false;}
		}

	
	},
	
	'img' : function(element){
		
		element.onfocus = function(){
			this.hideFocus=true;
		}
	
	},

	
	'div#menusystem a' : function(element){
		element.onmouseover = function(){
			menuItemMouseOver(this);
		}
		element.onmouseout = function(){
			menuItemMouseOut(this);
		}
		element.onclick = function(){
			//updateMenuAndPage(this.getAttribute("inputNumber"));
			
			
			
			if(this.name=='altpage'){parent.location=this.href; return false;}
			
			//if(this.name=='home'){menuName='home';document.location.href='index.php?m=company'; return false;}
			//if(this.name=='video'){menuName='video';document.location.href='index.php?m=' + menuName +'&p=' + this.href; return false;}
			if(this.name=='granogue-video' || this.name=='other-video'){menuName='video';document.location.href='index.php?m=' + menuName +'&p=' + this.href; return false;}

			if(this.name=='email')parent.location='mailto:tom@Meta4Photo.com?subject=Email GPS Bike Maps Site';
									
			else{
			menuName=this.parentNode.parentNode.firstChild.name; //set menu name to first 'a' under parent name for drop-down menu items
			
			if(this.name=="company" || this.name=="corporatesites" ||this.name=="weddings" ||this.name=="sportsleisure"||this.name=="floral" ||this.name=="linksmenu") return false  //cancel out top menus
			
			

			//if(this.parent.name=="photoMenuPopup")  {menuName='phototoursmenu';}
			if(this.name=="photoofthemonth") {menuName='phototoursmenu';}
			if(localfolder == 'races/ironhill08') {menuName='races';} 
			
			//menuName=this.parentNode.parentNode.firstChild.name; //set menu name to first 'a' under parent name for drop-down menu items - IE Only as typed
			
			
			document.location.href='index.php?m=' + menuName +'&p=' + this.href; return false;
						
			}
		}
		element.onfocus = function(){
			this.hideFocus=true;
		}
	
	},
	
	'a.poplink' : function(element){
		element.onfocus = function(){
			this.hideFocus=true;
		}
		element.onclick = function(){
			{PopupWindow=window.open(this.href,'Popup', 'toolbar=yes,menubar=yes,location=yes,status=no,scrollbars=yes,resizable=yes,left=50,top=50');PopupWindow.focus();return false;}
		}
	},
		
	'div.popupMenu' : function(element){  //displays and hides sub menu items on mouse over/out
		element.onmouseover = function(){
		targetMenu=this.getElementsByTagName('div');
		targetMenu[0].style.visibility='visible';
			//menuSearchMouseOver(this);
		//this.backgroundColor='#ff0000';
		if(document.getElementById("videoiframe")) document.getElementById("videoiframe").style.visibility='hidden';
		if(document.getElementById("widevideoiframe")) document.getElementById("widevideoiframe").style.visibility='hidden';



			
		}
		element.onmouseout = function(){
			targetMenu=this.getElementsByTagName('div');
			targetMenu[0].style.visibility='hidden';

			//menuSearchMouseOut(this);
		if(document.getElementById("videoiframe")) document.getElementById("videoiframe").style.visibility='visible';
		if(document.getElementById("widevideoiframe")) document.getElementById("widevideoiframe").style.visibility='visible';

		}
		
		
	},
	
	'a.tourCategoryLink' : function(element){
		element.onmouseover = function(){
			menuButtonMouseOver(this);
		}
		element.onmouseout = function(){
			menuButtonMouseOut(this);
		}
		element.onclick = function(){
			updateCategoryAndMenuDisplay(this.getAttribute("inputNumber"),"menuClick");
		}
		element.onfocus = function(){
			this.hideFocus=true;
		}
	},
	
		
	'a.viewLargeMap' : function(element){
		element.onclick = function(){
			viewLargeMap();
			}
		
	},
	
		
	'body' : function(element){
	     if (document.all) element.onkeydown = checkKeycode; else { document.onkeypress = checkKeycode; }
        }



}



