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

window.onload = bodyOnLoadItems;

slideShowPresent=0; //init var
factSheetPresent=0; //init var
inlineActive=0; //init var
//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);
		var is_safari = (agt.indexOf('safari') != -1);
		
		createMenuCategoryArrays();  //build array of all menus
				
		cc=document.getElementById("contentcontainer");
		sf=document.getElementById("sitefooter");
		
		pmip=document.getElementById("propertyInfoMenuPopup"); //adjust position of Firefox popup menu height
		cimp=document.getElementById("communityInfoMenuPopup");
		timp=document.getElementById("tenantInfoMenuPopup");
		
		ght='13px'; //gecko height
						
		if(is_gecko && !is_safari) { //safari reports it is gecko, but includes 'safari' in string. Safari 3.0 beta positions popup menus like IE7, so I exclude it from the FireFox/Gecko adjustment
		pmip.style.top=ght; 
		cimp.style.top=ght;
		timp.style.top=ght;
		}
				
		//if(is_ie6up) sf.style.bottom=pf.style.bottom - 40;
		//else pf.style.top=conh+'70px';
		//if(inlineActive==0){ //show footers only when no inline
		//	sf.style.display='';
			//}
		//if(inlineActive==1){ document.getElementById.I1.top='200px';}
		

		if(slideShowPresent==1){slidesBodyOnLoadItems();}
		if(menuName != 'contact' && menuName != 'blog') sf.style.visibility='visible';
		if(factSheetPresent==1){createFactSheetCategoryArrays();updateFactSheetAndMenuDisplay(0);} //hide all but first factsheet div
		
		if(buildingPhotos  != 0){updateImage('photos/' + buildingPhotos + '.jpg',inputnumber);}
		
		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 createMenuCategoryArrays(){  //called by onload items to update 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 = '#fed242';
				
				}
			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.backgroundImage = '/graphics/menubackgroundover.gif';
	}

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 = 'Paoli Village Shoppes';  //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

//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 fetNextPhoto() 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){ //
		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';
		
		//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();
		}
	
	//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 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
}

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(jsimagesarray[imageToFind]){  //associative array elements accessed directly - no looping needed
				document.pic.style.visibility = 'hidden';  //hide current photo
				document.pic.src='images/' + e +'.jpg';
				setImageSize();
				}
			else alert("Photo not found.")
		}
		
		typeImageNumber.value='Enter pic #'; 
		typeImageNumber.blur();
}

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
	
	//alert(imageCaptionText)
	
	captext=document.getElementById("captionText");
	captext.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(typeImageNumber.value != "Enter pic #") {selectByNumber(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 = 500;  //number of miliseconds added/subtracted from slide internal when clicking on faster/slower buttons
maxSpeed = 500;  //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
		if(delay - speedAdjustmentInterval >= maxSpeed) {delay = delay - speedAdjustmentInterval;} //shorten delay and speed up if not at max
		delayFriendly = Math.round(60000/delay) //round to whole numbers
		if(delayFriendly <10) {delayFriendly = Math.round(60000/delay*10)/10;} //add a decimal place when below 10
		document.getElementById("nextButton").value = delayFriendly + " FPM";
		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 + 500; 
		delayFriendly = Math.round(60000/delay) //round to whole numbers
		if (delayFriendly <10) {delayFriendly = Math.round(60000/delay*10)/10;} //add a decimal place when below 10
		document.getElementById("backButton").value = delayFriendly + " FPM";
		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')
	imageWindow=window.open('largeImage','newWin', 'width=150 height=150 toolbar=no,menubar=no,location=no,status=no,,,,resizable=yes,left=100,top=100');
	imageWindow.document.write("<html><head><Title>Click image to close window.</Title></head><body bgcolor='#2F3342' topmargin=0 leftmargin=0><img onclick='self.close()' border='1' onload='window.resizeTo(document.images[0].width,document.images[0].height)' src='"); 
	imageWindow.document.write(largeImage);
	imageWindow.document.write("'><p align='center'></p></body></html>")
	imageWindow.focus();
	imageWindow.document.close();
}

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 table divs
		//alert(categoryDivsCount);
		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

		if(tourMenuItems=document.getElementById("tourMenus")){	
			tourMenuItems=document.getElementById("tourMenus").getElementsByTagName("a"); //create array of menu items in menu table
			tourMenuItemsCount = tourMenuItems.length ; //count all members 
			//alert(tourMenuItemsCount);
		 }
}



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
		category=0;  //initialize category as 0, the first category, in case a specific photo not in a category is requested via query string
		
		if(categoryDivsCount) {
		
		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
			
		} //end if
	
}

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
			//topIncludeDiv.style.display='none';  //hide factsheet include
			//bottomcontent.style.display = '';
			//imageSpan.style.display='';  //reveal image
			//captionSpan.style.display='';
			//backArrow.style.display='';
			//nextArrow.style.display='';	
			//startStopButton.style.display='';
			//nextButton.style.display='';
			//backButton.style.display='';
			//navigationText.style.display='';
			//slideShowLabel.style.display='';
			//if(pausedFlag==1){ //when restoring slide-show after viewing factsheets, restart it only if it was already running before
			//	toggleStartStopButton('menuclick');
			//	}
					
			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(tourMenuItems=document.getElementById("tourMenus")){
			tourMenuItems=document.getElementById("tourMenus").getElementsByTagName("a")
			tourMenuItemsCount = tourMenuItems.length ; //count all members 
			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(tourMenuItems=document.getElementById("tourMenus")){
			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
				//alert(e);
				tourMenuItems[e].style.color='#ff0000';
			//}else  categoryDivs[0].style.display = "";  //display first/only category div 
			}
			
			
			
			
}

function createFactSheetCategoryArrays(){  //called by img on load items

		 factSheetContentDivs=document.getElementById("factsheetcontent");
		 factSheetDivs=factSheetContentDivs.getElementsByTagName("div"); //create array of divs in thumbnail table
		 factSheetDivsCount = factSheetDivs.length ; //count all thumbnail table divs
	
}

function createFactSheetMenuCategoryArrays(){  //called by img on load items to update menus color and tvisible category divs during auto-play
		 factSheetMenuItems=factSheetMenuTable.getElementsByTagName("input"); //create array of menu items in menu table
		 factSheetMenuItemsCount = factSheetMenuItems.length ; //count all members 
}

function updateFactSheetAndMenuDisplay(e,caller){  //update menu color and thumbnail display when category changes called by menu click
		if(e=='last') {document.location.href='http://www.haverfordcommons.com/index.php?m=propertyinfo&p=http://www.haverfordcommons.com/pages/rates.php';}
		
		else {	
		for ( var i = 0; i < factSheetDivsCount; i++) { //hide all category divs
			factSheetDivs[i].style.display = "none";
			}
			
		//for ( var i = 0; i < factSheetMenuItemsCount; i++) {  //restore all menu items to white
		//	factSheetMenuItems[i].style.color = '#ffffff';	
		//	}
			   
				
		factSheetDivs[e].style.display = "";  //display current category div
		//factSheetMenuItems[e].style.color='#ff0000';
		}
		
}





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 revealHiddenItemsOnLoad(){
	//menudiv.style.display='';
	//details.style.display='';
	//highlights.style.display='';
	//mapsButton.style.display='';
}
	
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 nextBuildingPhoto(g) {
	var jsphotosarray = new Array('platebldg0.jpg','platebldg1.jpg','platebldg2.jpg','platebldg3.jpg','platebldg4.jpg','platebldg5.jpg','platebldg6.jpg','platebldg7.jpg');
	startSplit=g.lastIndexOf("/") ;  //get location of the last slash in path of new main image
	endSplit=g.lastIndexOf(".") ;
	currentImageName=g.substring(startSplit+1,endSplit+4);
	//alert(currentImageName);
	buildingPhotoCount = jsphotosarray.length ; //count all thumbnail table images. If not downloaded yet, use defaults set in declarations
	 
	for ( var i = 0; i < buildingPhotoCount ; i++) {  //find current thumbnail's index in images array
			if (currentImageName == jsphotosarray[i]){
					positionInArray = i;
					}
	}
	if(positionInArray == buildingPhotoCount-1) nextPhotoPosition = 0;
	else nextPhotoPosition = positionInArray +1;
	//alert(nextPhotoPosition);
	updateImage('photos/' + jsphotosarray[nextPhotoPosition],nextPhotoPosition);
	
}
	
function nextBuildingPhotoNew(g) {
	var jsphotosarray = new Array('plate-overview.jpg','platebldg1.jpg','platebldg2.jpg','plate-homecooked.jpg','plate-bank.jpg','plate-grind.jpg','plate-cutters.jpg');
	startSplit=g.lastIndexOf("/") ;  //get location of the last slash in path of new main image
	endSplit=g.lastIndexOf(".") ;
	currentImageName=g.substring(startSplit+1,endSplit+4);
	//alert(currentImageName);
	buildingPhotoCount = jsphotosarray.length ; //count all thumbnail table images. If not downloaded yet, use defaults set in declarations
	 
	for ( var i = 0; i < buildingPhotoCount ; i++) {  //find current thumbnail's index in images array
			if (currentImageName == jsphotosarray[i]){
					positionInArray = i;
					}
	}
	if(positionInArray == buildingPhotoCount-1) nextPhotoPosition = 0;
	else nextPhotoPosition = positionInArray +1;
	//alert(nextPhotoPosition);
	updateImage('photos/' + jsphotosarray[nextPhotoPosition],nextPhotoPosition);
	
}

	
	

function updateImage(e,f) { 
	//alert(e,f);
	document.getElementById("targetImage").setAttribute("src",e);
	imagelinks=document.getElementById("imageButtons").getElementsByTagName("a");
	for ( var i = 0; i < imagelinks.length; i++) {
		imagelinks[i].style.color = "white";
			}
 	imagelinks[f].style.color = "#fed653";
 	
}


	
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 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 revealHiddenItemsOnLoad(){		
	if(document.getElementById("tourMenuDiv"))document.getElementById("tourMenuDiv").style.display='';
	if(document.getElementById("slideShowButtons"))document.getElementById("slideShowButtons").style.display='';
	if(document.getElementById("vieworiginalbutton"))document.getElementById("vieworiginalbutton").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='';
	if(document.getElementById("imagesloadingmessage"))document.getElementById("imagesloadingmessage").style.display='none';
	
	
}



var myrules = {
	
	'a' : function(element){
		
		element.onfocus = function(){
			this.hideFocus=true;
		}
	
	},
	
	'img' : function(element){
		
		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;}
		}
	},
		
	
	'#tenantlist a' : function(element){
		element.onfocus = function(){
			this.hideFocus=true;
		}
		element.onclick = function(){
		if(this.href.indexOf('mailto')==-1) //prevents new window on email links, manifested in two blank emails being created
		
			{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;}
		}
	},
	
	'a.nopopup' : function(element){  //this class overrides the popup behavior of links on tenant list that normally open client sites in popup windows. Used for featured tenant pages.
		element.onfocus = function(){
			this.hideFocus=true;
		}
		element.onclick = function(){
		document.location=this.href; return false;	
		}
	},
		
	
		
	'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=='email')parent.location='mailto:info@PaoliVillageShoppes.com?subject=Email From Web Site';
			if(this.name=='neighborhood'){PopupWindow=window.open('pages/eneighborhoodreport.pdf','Popup', 'width = 900, height = 600, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
						
			else{

			menuName=this.name;
			if(this.name=="propertyinfo" || this.name=="communityinfo" ||this.name=="tenantinfo" ||this.name=="photos") return false  //cancel out top menus
			
			if(this.name=="features" || this.name=="rates" || this.name=="maps" || this.name=="floorplans" || this.name=="siteplan") {menuName='propertyinfo';}
			if(this.name=="attractions" || this.name=="township" || this.name=="transportation") {menuName='communityinfo';} 
			if(this.name=="tenants" || this.name=="faq" || this.name=="announcements" || this.name=="news") {menuName='tenantinfo';} 
			if(this.name=="generalphotos" || this.name=="generalphotos08" || this.name=="streetfair") {menuName='photos';}
			if (this.name=="propertyphotos") {menuName='propertyinfo'; document.location.href='index.php?p=' + this.href +'&m=' + menuName + 'platebldg0' + '&inputnumber=0'; return false; }//the zero highlights first menu
 
			
			document.location.href='index.php?m=' + menuName +'&p=' + this.href; return false;
						
			}
		}
		element.onfocus = function(){
			this.hideFocus=true;
		}
	
	},
	
	'a.photoslink' : function(element){
		
		element.onclick = function(){
								
			menuName='propertyinfo'; //don't include contact page here or it won't go in frame, based on menuName
			document.location.href='index.php?m=' + menuName +'&p=' + this.href + '&bldg=' + this.name + '&inputnumber=' + this.id; return false;
			}
		
		element.onfocus = function(){
			this.hideFocus=true;
		}
	
	},


	'div.thumbs img' : function(element){
		element.onclick = function(){
			selectPhoto(this.src);
		}

	},
	
	'div#propertyInfoMenu' : function(element){
		element.onmouseover = function(){
			document.getElementById("propertyInfoMenuPopup").style.visibility='visible';
			//menuSearchMouseOver(this);
		}
		element.onmouseout = function(){
			document.getElementById("propertyInfoMenuPopup").style.visibility='hidden';
			//menuSearchMouseOut(this);
		}
		
	},
	
	'div#propertyInfoMenuPopup' : function(element){
		element.onclick = function(){
			document.getElementById("propertyInfoMenuPopup").style.visibility='hidden';
		}
	},
	
	'div#communityInfoMenu' : function(element){
		element.onmouseover = function(){
			document.getElementById("communityInfoMenuPopup").style.visibility='visible';
			//menuSearchMouseOver(this);
		}
		element.onmouseout = function(){
			document.getElementById("communityInfoMenuPopup").style.visibility='hidden';
			//menuSearchMouseOut(this);
		}
		
	},
	
	'div#communityInfoMenuPopup' : function(element){
		element.onclick = function(){
			document.getElementById("communityInfoMenuPopup").style.visibility='hidden';
		}
	},
	
	'div#tenantInfoMenu' : function(element){
		element.onmouseover = function(){
			document.getElementById("tenantInfoMenuPopup").style.visibility='visible';
			//menuSearchMouseOver(this);
		}
		element.onmouseout = function(){
			document.getElementById("tenantInfoMenuPopup").style.visibility='hidden';
			//menuSearchMouseOut(this);
		}
		
	},
	
	'div#tenantInfoMenuPopup' : function(element){
		element.onclick = function(){
			document.getElementById("tenantInfoMenuPopup").style.visibility='hidden';
		}
	},
	
	
	'div#photoMenu' : function(element){
		element.onmouseover = function(){
			document.getElementById("photoMenuPopup").style.visibility='visible';
			//menuSearchMouseOver(this);
		}
		element.onmouseout = function(){
			document.getElementById("photoMenuPopup").style.visibility='hidden';
			//menuSearchMouseOut(this);
		}
		
	},
	
	'div#photoMenuPopup' : function(element){
		element.onclick = function(){
			document.getElementById("photoMenuPopup").style.visibility='hidden';
		}
	},
	
	'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);
		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.factsheetnextbutton' : function(element){
		element.onmouseover = function(){
			menuButtonMouseOver(this);
		}
		element.onmouseout = function(){
			menuButtonMouseOut(this);
		}
		element.onclick = function(){
			updateFactSheetAndMenuDisplay(this.getAttribute("inputNumber"),"menuClick");
		}
		element.onfocus = function(){
			this.hideFocus=true;
		}
	},
	

	
	'div.thumbs img' : function(element){
		element.onclick = function(){
			window.location='#top'; 
			selectPhoto(this.src);
		}

	},
	'body' : function(element){
	     if (document.all) element.onkeydown = checkKeycode; else { document.onkeypress = checkKeycode; }
        }



}



