//onerror = function(msg,url,line) { top.document.title = "Error: L#" + line + ": " + msg; return true; }
if(menuName=='powersearch' || menuName=='realtorsearch') menuName='search'; //picked up from php in index
if(menuName=='news1' || menuName=='news2') menuName='news';

window.onload = bodyOnLoadItems;

function bodyOnLoadItems(){  //this function handles the first load to make sure entire page is loaded before timer starts. Subsequent timers are started by mainImageLoadItems()
		createMenuCategoryArrays();  //build array of all menus
		document.getElementById("searchMenuPopup").style.display=''; //hides searchmenu popup div onload
		document.getElementById("searchMenuPopup").style.visibility='hidden'; //hides searchmenu popup div onload
		
		document.getElementById("marketupdateMenuPopup").style.display=''; //hides newshmenu popup div onload
		document.getElementById("marketupdateMenuPopup").style.visibility='hidden'; //hides menu popup div onload
		
		
		document.getElementById("transportationMenuPopup").style.display=''; //hides menu popup div onload
		document.getElementById("transportationMenuPopup").style.visibility='hidden'; //hides menu popup div onload

		
		d1=document.getElementById("menubar");
		d2=document.getElementById("contentpagecontainer");
		
		if(d1.offsetHeight) h1=d1.offsetHeight; 
		else h1=d1.style.pixelHeight;
		 
		if(d2.offsetHeight) {h2=d2.offsetHeight;}
		else {h2=d2.style.pixelHeight;}
		
		maxHeight=Math.max(h1,h2); 
		//alert(h1)
		
		d1.style.height=maxHeight;
		
		if (h1 < maxHeight) d1.style.height=maxHeight;
		if (h2 < maxHeight-50) d2.style.height=maxHeight+50;
		//if(currentPage=='http://www.dlalexander.com/properties/27cornell/inline.php') document.getElementById("container").style.width='1160px';
		//else document.getElementById("container").style.width='940px';
		
		//if(menuName=='services-sellers') d1.style.height='690px';d2.style.height='670px';
	
			
		
}

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 = '#ff0000';
			
			if(menuName == 'listings' || menuName== 'rentals' || menuName== 'commercial') menuItems[i].style.color='#ffff00'; // set menu text to yellow due to red background
				
				}
			else menuItems[i].style.color='#ffffff'; //collect variable from index to determine which menu item clicked and give it a distinctive color
			}
		homeSearchMenu=document.getElementById("homesearch");
		homeSearchMenu.style.color='#ffff00';	
		
}

function menuItemMouseOver(f) {
	//f.style.color='#ffff00';
	f.style.borderColor ='#ffff00';
	f.style.backgroundImage = 'none';
	}

function menuItemMouseOut(f) {
	f.style.borderColor ='#ffffff';
	f.style.backgroundImage ='none';
	}


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",'../properties/brandywineland/plotplan.gif'); 
if(e==1)planImage.setAttribute("src",'floorplans/355floorplan-1.gif');
if(e==2)planImage.setAttribute("src",'floorplans/355floorplan-2.gif');
  	
}


	
var myrules = {
	
	'a.remotelink' : function(element){
		element.onclick = function(){
		if(this.href.lastIndexOf('#')==-1); document.location.href='index.php?m=' + this.name + '&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#menusystem a' : function(element){
		element.onmouseover = function(){
			if(this.name=='commercial' || this.name=='listings' || this.name=='rentals') menuItemMouseOver(this);
			}
		element.onmouseout = function(){
			if(this.name=='commercial' || this.name=='listings' || this.name=='rentals') menuItemMouseOut(this);
		}
		element.onclick = function(){
			//updateMenuAndPage(this.getAttribute("inputNumber"));
			if(this.name=='email')parent.location='mailto:Dave@DLAlexander.com?subject=Email From Web Site';
			if(this.name=='haverfordcommons'){PopupWindow=window.open('http://www.haverfordcommons.com','Popup', 'width = 1050, height = 715, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			if(this.name=='phillynewsarticle'){PopupWindow=window.open(this.href,'Popup', 'width = 1050, height = 715, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			if(this.name=='trendmarketoverview'){PopupWindow=window.open(this.href,'Popup', 'width = 1050, height = 715, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			if(this.name=='septarail'){PopupWindow=window.open(this.href,'Popup', 'width = 1050, height = 915, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			if(this.name=='amtrak'){PopupWindow=window.open(this.href,'Popup', 'width = 1050, height = 715, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			if(this.name=='regionalmap'){PopupWindow=window.open(this.href,'Popup', 'width = 1050, height = 715, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			if(this.name=='katrina'){document.location.href='http://nolamissions.com';return false;}
			if(this.name=='haiti2010'){document.location.href='http://haiti2010.us';return false;}
			if(this.name=='residentialupdatevideo'){PopupWindow=window.open(this.href,'Popup', 'width = 1050, height = 915, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			if(this.name=='residentialupdate'){PopupWindow=window.open(this.href,'Popup', 'width = 1050, height = 915, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			if(this.name=='commercialupdate'){PopupWindow=window.open(this.href,'Popup', 'width = 1050, height = 915, toolbar=no,menubar=no,location=yes,status=no,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			if(this.name=='propertyvalues'){PopupWindow=window.open(this.href,'Popup', 'width = 1050, height = 915, toolbar=yes,menubar=yes,location=yes,status=yes,scrollbars=yes,resizable=yes');PopupWindow.focus();return false;}
			
			if(this.name=='search')return false;
			if(this.name=='news')return false;
			if(this.name=='transportation')return false;
			if(this.name=='marketupdate')return false;
			
			else{
			
			document.location.href='index.php?m=' + this.name +'&p=' + this.href; return false;
			
			
			}
		}
		element.onfocus = function(){
			this.hideFocus=true;
		}
	},

		'a#contactlink' : function(element){
			element.onmouseover = function(){
			this.style.color='#ffff00';
			this.style.backgroundImage = 'none';  //overrides style for menu buttons

		}
		element.onmouseout = function(){
			this.style.color='#ffffff';
		}
		
			element.onclick = function(){
			document.location.href='index.php?m=' + this.name +'&p=' + this.href; return false;
		}
		element.onfocus = function(){
			this.hideFocus=true;
		}
	},

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

	},
	'div#marketupdatemenu' : function(element){
		element.onmouseover = function(){
			document.getElementById("marketupdateMenuPopup").style.visibility='visible';
			//menuSearchMouseOver(this);
		}
		element.onmouseout = function(){
			document.getElementById("marketupdateMenuPopup").style.visibility='hidden';
			//menuSearchMouseOut(this);
		}
		
	},
	'div#searchMenuPopup' : function(element){
		element.onclick = function(){
			document.getElementById("marketupdateMenuPopup").style.visibility='hidden';
		}
	
		
	},
	
	'div#searchmenu' : function(element){
		element.onmouseover = function(){
			document.getElementById("searchMenuPopup").style.visibility='visible';
			//menuSearchMouseOver(this);
		}
		element.onmouseout = function(){
			document.getElementById("searchMenuPopup").style.visibility='hidden';
			//menuSearchMouseOut(this);
		}
		
	},
	'div#searchMenuPopup' : function(element){
		element.onclick = function(){
			document.getElementById("searchMenuPopup").style.visibility='hidden';
		}
	
		
	},
	
	'div#transportationmenu' : function(element){
		element.onmouseover = function(){
			document.getElementById("transportationMenuPopup").style.visibility='visible';
			//menuSearchMouseOver(this);
		}
		element.onmouseout = function(){
			 document.getElementById("transportationMenuPopup").style.visibility='hidden';
			//menuSearchMouseOut(this);
		}
		
	},
	'div#transportationMenuPopup' : function(element){
		element.onclick = function(){
			document.getElementById("transportationMenuPopup").style.visibility='hidden';
		}
	},
	
	'div#marketupdatemenu' : function(element){
		element.onmouseover = function(){
			document.getElementById("marketupdateMenuPopup").style.visibility='visible';
			//menuSearchMouseOver(this);
		}
		element.onmouseout = function(){
			 document.getElementById("marketupdateMenuPopup").style.visibility='hidden';
			//menuSearchMouseOut(this);
		}
		
	},
	
	'div#marketupdateMenuPopup' : function(element){
		element.onclick = function(){
			document.getElementById("marketupdateMenuPopup").style.visibility='hidden';
		}
	},
	
	
	'a#aboutdave' : function(element){
		element.onmouseover = function(){
			photoPopupText.style.display='';
			//menuSearchMouseOver(this);
		}
		element.onmouseout = function(){
			photoPopupText.style.display='none';
			//menuSearchMouseOut(this);
		}
		element.onclick = function(){
			document.location.href='index.php?m=' + this.name +'&p=' + this.href; photoPopupText.style.display='none';return false;
		}
		element.onfocus = function(){
			this.hideFocus=true;
		}


	}

	
		
}
