var propertyMenu=null;
var ibFloatPanelMode = 'i';
var  ibFloatPanelLon = 0.0;
var  ibFloatPanelLat = 0.0;
var  ibFloatPanelZ = 15;
var lifePathUrl;
var sizeHandlerSet = false;
var xmlhttp=false;
var newhttp=false;
var ib_lid="";
var ib_featureType='empty';
var ib_fieldLongName='';
var ib_fieldName='';
var optionalChar = -1;
var seqnum = Math.floor(Math.random()*10000)*100;
var FBarticleHeader = "My ZoomAtlas LifePath Timeline";
var FBarticleBody   = "Come check out all the places I've been.";
var FBtileFname     = "http://www.zoomatlas.com/pix/FBLifeLineB.png";
var FBuid           = 0;
// This is the Yahoo tab widget representing the current set of 4 note tabs
var currentNoteTabView = null;
var currentMyPlacesTabView = null;

var gnomeCount = 0;
var gnomeMsgs = new Array(14);
gnomeMsgs[0] = "Click&nbsp;here&nbsp;to&nbsp;edit&nbsp;property&nbsp;locations and&nbsp;the&nbsp;road&nbsp;paths.";
gnomeMsgs[1] = "Use&nbsp;this&nbsp;slider&nbsp;to&nbsp;fade&nbsp;between&nbsp;the satellite&nbsp;image&nbsp;and&nbsp;the&nbsp;map.";
gnomeMsgs[2] = "Is&nbsp;your&nbsp;house&nbsp;in&nbsp;the&nbsp;wrong&nbsp;place? Click&nbsp;<i>Edit&nbsp;Map</i>&nbsp;to&nbsp;fix&nbsp;it.";
gnomeMsgs[3] = "You&nbsp;can&nbsp;turn&nbsp;on&nbsp;and&nbsp;off&nbsp;the map&nbsp;labels&nbsp;by&nbsp;clicking&nbsp;here.";
gnomeMsgs[4] = "If&nbsp;you&nbsp;can\'t&nbsp;find&nbsp;your&nbsp;address up&nbsp;here,&nbsp;just&nbsp;try&nbsp;street&nbsp;name.";
gnomeMsgs[5] = "Detail&nbsp;your&nbsp;property!&nbsp;Add&nbsp;roofs,&nbsp;trees, flowers,&nbsp;patios,&nbsp;driveways.";
gnomeMsgs[6] = "Zoom&nbsp;in&nbsp;really&nbsp;close&nbsp;on&nbsp;a&nbsp;road&nbsp;or house&nbsp;to&nbsp;see&nbsp;amazing&nbsp;detail!";
gnomeMsgs[7] = "Streets&nbsp;don\'t&nbsp;line&nbsp;up&nbsp;with&nbsp;the&nbsp;satellite image?&nbsp;Click&nbsp;<i>Edit&nbsp;Map</i>&nbsp;to&nbsp;fix&nbsp;it.";
gnomeMsgs[8] = "Turn&nbsp;on&nbsp;map&nbsp;labels&nbsp;to&nbsp;see&nbsp;house numbers&nbsp;and&nbsp;street&nbsp;names.";
gnomeMsgs[9] = "Try&nbsp;searching&nbsp;for&nbsp;an&nbsp;address,&nbsp;business, school,&nbsp;airport&nbsp;or&nbsp;arena."
gnomeMsgs[10] = "Turn&nbsp;those&nbsp;little&nbsp;green&nbsp;squares&nbsp;into&nbsp;a detailed&nbsp;map&nbsp;of&nbsp;your&nbsp;property.";
gnomeMsgs[11] = "Move&nbsp;this&nbsp;slider&nbsp;up&nbsp;to&nbsp;see&nbsp;the&nbsp;map without&nbsp;the&nbsp;satellite&nbsp;image.";
gnomeMsgs[12] = "After&nbsp;editing&nbsp;the&nbsp;map,&nbsp;zoom&nbsp;in&nbsp;close&nbsp;to see&nbsp;photo-realistic&nbsp;details!";
gnomeMsgs[13] = "Hold&nbsp;<i>shift</i>&nbsp;and&nbsp;draw&nbsp;a&nbsp;rectangle for&nbsp;a&nbsp;precise&nbsp;zoom.";

/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
 try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 } catch (e) {
  try {
   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  } catch (E) {
   xmlhttp = false;
  }
 }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
try {
xmlhttp = new XMLHttpRequest();
} catch (e) {
xmlhttp=false;
}
}
if (!xmlhttp && window.createRequest) {
try {
xmlhttp = window.createRequest();
} catch (e) {
xmlhttp=false;
}
}



function gnomeNextMsg() {
	gnomeCount++;
	if (gnomeCount > 13) { gnomeCount = 0; }
	var gifName = "lbg21";
	var headGifName = "tl";
	if ((gnomeCount == 1) || (gnomeCount == 11))
	{
		gifName = "lbg";
	}
	if ((gnomeCount == 6) || (gnomeCount == 13))
	{
		gifName = "lbg5";
	}
	if ((gnomeCount == 3) || (gnomeCount == 8))
	{
		headGifName = "tl3";
		gifName = "lbg3";
	}
	if ((gnomeCount == 4) || (gnomeCount == 9))
	{
		headGifName = "tl4";
		gifName = "lb4";
	}
	document.getElementById('gnomeMsg').innerHTML =
		gnomeMsgs[gnomeCount];
        document.getElementById('gnomeHead').innerHTML =
	"<img src=\"http://www.zoomatlas.com/images/"+headGifName+".gif\" width=\"91\" height=\"39\">";
        document.getElementById('gnomeBody').innerHTML =
	"<img src=\"http://www.zoomatlas.com/images/"+gifName+".gif\" width=\"91\" height=\"50\">";
}

// Called when the GoInside tab is opened (true) or closed (false)
function g_enableTabGoInside(isOpen) {
   if (isOpen && (g_SelectedLid != null) && (g_SelectedLid != 0) && (g_SelectedLid != "")) {
 	ibFloatPanelMode = 'x';
	loadSlider();
   }
//       floatPanelNow();
}

function g_enableTabNotes(isOpen) {
   if (isOpen && (g_SelectedLid != null) && (g_SelectedLid != 0) && (g_SelectedLid != "")) {
 	ibFloatPanelMode = 'n';
	loadSlider();
   }
}

function g_enableTabArticle(isOpen) {
   if (isOpen && (g_SelectedLid != null) && (g_SelectedLid != 0) && (g_SelectedLid != "")) {
 	ibFloatPanelMode = 'a';
	loadSlider();
   }
}

function g_enableTabMyPlaces(isOpen) {
   if (isOpen && (g_SelectedLid != null) && (g_SelectedLid != 0) && (g_SelectedLid != "")) {
 	ibFloatPanelMode = 'm';
	loadSlider();
   }
}

// One of the side tabs have been selected: GoInside, Notes, Article, MyPlaces
function loadSlider() {
  // What is in the status bar?
  var currStatus = getStatusBar();
  if ((currStatus != null) && (currStatus.length < 40))
  {
    // If it is "No Object Selected", re-select the current object
    if ((g_SelectedLid != null) && (g_SelectedLid != 0) && (g_SelectedLid != ""))
	{
	    // Treat blank and null the same for inside Lid
	    g_setGlobalSelection(g_SelectedLid, 
		(g_SelectedLidInside==null?null:(g_SelectedLidInside==''?null:g_SelectedLidInside)));
	}
  }

  // Get rid of the bubble
//  closePopup();

  var g_useLid = g_SelectedLid;
  if ((g_SelectedLidInside != null) && (g_SelectedLidInside != 0) && (g_SelectedLidInside != ""))
  {
	g_useLid = g_SelectedLidInside;
  }
  url="http://www.zoomatlas.com/InfoBoxManager/InfoBox?click=Y&floatMode="+ibFloatPanelMode+
	"&lid="+g_useLid+"&seqnum="+seqnum;
  seqnum++;
  xmlhttp.open("get",url,true);
  xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
    // Read the returned JSON data from InfoBoxManager
    var format = new OpenLayers.Format.JSON();
    var jsonData = format.read(xmlhttp.responseText);
    var htmlText = "";
    var newMode = ibFloatPanelMode.substring(0,1);
    if (newMode == "x")
    {
	// GoInside Tab
	htmlText = "<div id=\"container\"></div>";
    }
    else if (newMode == "m")
    {
	// MyPlaces tab
	htmlText = "<div id=\"myplacescontainer\"></div>";
    }
    else if (newMode == "a")
    {
	// Article Tab
        htmlText = "<div id=\"articlecontainer\">"+
        	   "<table><tr><td width=\"6\">&nbsp;</td><td width=\"100%\"><div id=\"articletabcontainer\"></div></td></tr></table>"+
		   "</div>"; 
    }
    else if (newMode == "n")
    {
	// Note Tab
	htmlText = "<div id=\"notecontainer\"></div>";
// OLD:        htmlText = "<table><tr><td width=\"6\">&nbsp;</td><td>"+jsonData.html+"</td></tr></table>";
    }
    else
    {
	// Extract the HTML to display
        htmlText = "<div style=\"overflow:scroll\">"+jsonData.html+"</div>"; 
    }
    // Which tab does it go into?
    if (newMode != null)
    {
      // Only do this if the mode is not null. Grab first (only sometimes) character
      var modeCh = ibFloatPanelMode.substring(0,1);
      var tabName = "Notes";
      if (modeCh == "a")
      {
	tabName = "Article";
      }
      else if (modeCh == "x")
      {
	tabName = "GoInside";
      }
      else if (modeCh == "n")
      {
	tabName = "Notes";
      }
      else if (modeCh == "m")
      {
	tabName = "MyPlaces";
      }
      else
      {
//	alert("ibFloatPanelMode: lid:"+g_SelectedLid);
      }


      var thisSlideTab = document.getElementById("tab"+tabName+"ContentsInner");
      thisSlideTab.innerHTML = htmlText;

      // After sliding in the GoInside or MyPlaces tab, call the appropriate init function
      if (modeCh == 'x')
	{
	  goInsideInit(jsonData);
 	}
      if (modeCh == 'n')
	{
	  notesInit(jsonData);
 	}
      if (modeCh == 'm')
	{
	  myPlacesInit(url);
 	}
      if (modeCh == 'a')
	{
	  articleInit(jsonData);
 	}
    }
    cursor_clear();
   }
  };
 xmlhttp.setRequestHeader('Accept','message/x-formresult');
 xmlhttp.send(null);
 return false;
}


function slidePanel(newMode,lid) {
  ibFloatPanelMode = newMode;
  if (ibFloatPanelMode != null)
    {
      // Only do this if the mode is not null. Grab first (only sometimes) character
      var modeCh = ibFloatPanelMode.substring(0,1);
      var tabName = "Notes";
      if (modeCh == "a")
      {
	tabName = "Article";
      }
      else if (modeCh == "x")
      {
	tabName = "GoInside";
      }
      else if (modeCh == "n")
      {
	tabName = "Notes";
      }
      else if (modeCh == "m")
      {
	tabName = "MyPlaces";
      }
      else
      {
//	alert("slidePanel: lid:"+g_SelectedLid);
      }
      var thisSlideTab = document.getElementById("tab"+tabName+"ContentsInner");
      slideTab("tab"+tabName+"Contents", "tab"+tabName+"ContentsInner");

    // Get rid of the bubble
      closePopup();
    }
}

// Called when a user clicks on one of the three post-note links in the bubble.
// Remember the coordinates of the click
function setLongLatZ(lon,lat,z) {
  ibFloatPanelLon = lon;
  ibFloatPanelLat = lat;
  ibFloatPanelZ = z;
}

// Called when a user clicks on a post-tab link (article, inside, notes, 
// lifepath) in the bubble. Get the content but DON'T load it yet
function floatPanel(newMode,lon,lat,z) {
  ibFloatPanelMode = newMode;
  ibFloatPanelLon = lon;
  ibFloatPanelLat = lat;
  ibFloatPanelZ = z;

  // Don't query the url, just slide open the correct panel
      var modeCh = ibFloatPanelMode.substring(0,1);
      var tabName = "Notes";
      if (modeCh == "a")
      {
	tabName = "Article";
      }
      else if (modeCh == "x")
      {
	tabName = "GoInside";
      }
      else if (modeCh == "n")
      {
	tabName = "Notes";
      }
      else if (modeCh == "m")
      {
	tabName = "MyPlaces";
      }

      var thisSlideTab = document.getElementById("tab"+tabName+"ContentsInner");
      slideTab("tab"+tabName+"Contents", "tab"+tabName+"ContentsInner");
      closePopup();
      return false;

// OLD: Used to get the tab contents directly
//  return floatPanelNow();
}

function floatPanelNow() {
  var g_useLid = g_SelectedLid;
  if ((g_SelectedLidInside != null) && (g_SelectedLidInside != 0) && (g_SelectedLidInside != ""))
  {
	g_useLid = g_SelectedLidInside;
  }
  url="http://www.zoomatlas.com/InfoBoxManager/InfoBox?click=Y&floatMode="+ibFloatPanelMode+
	"&lid="+g_useLid+"&seqnum="+seqnum;
  seqnum++;
  xmlhttp.open("get",url,true);
  xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
    // Read the returned JSON data from InfoBoxManager
    var format = new OpenLayers.Format.JSON();
    var jsonData = format.read(xmlhttp.responseText);
    // Which tab does it go into?
    if (ibFloatPanelMode != null)
    {
      // Only do this if the mode is not null. Grab first (only sometimes) character
      var modeCh = ibFloatPanelMode.substring(0,1);
      var tabName = "Notes";
      if (modeCh == "a")
      {
	tabName = "Article";
      }
      else if (modeCh == "x")
      {
	tabName = "GoInside";
      }
      else if (modeCh == "n")
      {
	tabName = "Notes";
      }
      else if (modeCh == "m")
      {
	tabName = "MyPlaces";
      }
      else
      {
//	alert("ibFloatPanelMode: lid:"+g_SelectedLid);
      }


      var thisSlideTab = document.getElementById("tab"+tabName+"ContentsInner");
      slideTab("tab"+tabName+"Contents", "tab"+tabName+"ContentsInner");

    // Get rid of the bubble
      closePopup();
    }
   }
  };
 xmlhttp.setRequestHeader('Accept','message/x-formresult');
 xmlhttp.send(null);
 return false;
 }




var sliderResize = function(e) {   
      if (ibFloatPanelMode.substring(0,1) == 'a')
	{
          var lu = m_Layout.getUnitByPosition("right");
          var newHeight = lu.get("height");
	  document.getElementById("articlecontainer").style.height = newHeight + "px";
	  return true;
	}
      else if (ibFloatPanelMode.substring(0,1) == 'x')
	{
          var lu = m_Layout.getUnitByPosition("right");
          var newHeight = lu.get("height");
	  newHeight -= 35;
      	  for (var i = 0; i < numInsideTabs; i++)
          {
	    insideTabs[i].get("contentEl").style.height = newHeight + "px";
          }
	  return true;
	}
     else if (ibFloatPanelMode.substring(0,1) == 'm')
     {
        numTries = 0;
	// There is a timing issue...the myPlacesTable may not be built yet. Keep checking every second (for up
	// to 10 seconds) until the object is created and can be properly sized.
        intervalId = setInterval(function() {
	        var thisSlideTab = Dom.get("tabMyPlacesContentsInner");
	        var newWidth = m_Layout.getUnitByPosition("right").get("width");
		var myPlacesTable = document.getElementById("lifepathouterdiv");
		newWidth -= 45;
		// Careful, first time through myPlacesTable could be null
		if (myPlacesTable != null)
		{
		  // We can resize it now
		  myPlacesTable.style.width = newWidth + "px";
		  // Stop the interval callbacks
		  clearInterval(intervalId);
		}
		else
		{
		  // No luck this time, keep trying unless we are up to 10 tries.
		  numTries++;
		  if (numTries > 10) { clearInterval(intervalId); }
		}
	},1);
     }
     return false;
} 
var intervalId = 0;
var numTries = 0;

var numInsideTabs = 0;
var insideTabs = new Array();
var selectedInsideTab = null;

function goInsideInit(jsonData) {
  var tabView = new YAHOO.widget.TabView();
  tabView.subscribe('beforeActiveIndexChange', function(e){
        var newTabIndex = e.newValue;
        var newTab = tabView.getTab(newTabIndex);
	selectedInsideTab = newTab;
        var newDS= newTab.get('dataSrc');
	var seqPos = newDS.lastIndexOf('seq=');
	if (seqPos <= 0) { newDS += "&seq="; newDS += seqnum; }
	else { newDS = newDS.substring(0,seqPos+4); newDS += seqnum;}
	seqnum++;
        newTab.set('dataSrc', newDS);
        return true;});
  var tabname;
  var indexVal = 0;
  insideTabs = new Array();
  for (tabname in jsonData)
  {
    var tabObj = jsonData[indexVal];
    var newTab = new YAHOO.widget.Tab(tabObj);
    newTab.get("contentEl").style.overflow = "scroll";
    newTab.set('content', 'Loading...');

//    newTab.get("contentEl").style.height = "600px";

    insideTabs[indexVal] = newTab;
    tabView.addTab(newTab);
    indexVal++;
  }
  numInsideTabs = indexVal;
  tabView.appendTo('container');
  handleSlider();
}

// Initialize the article panel with 2 tabs: Article and Edit
var articleTabView = null;
var articleEditUrl = null;

function articleInit(jsonData) {
  articleEditUrl = decodeURIComponent(jsonData.editUrl);
  articleTabView = new YAHOO.widget.TabView();
  articleTabView.subscribe('beforeActiveIndexChange', function(e){
        var newTabIndex = e.newValue;
	if (newTabIndex==1)
	{
	  var seqPos = articleEditUrl.lastIndexOf('seq=');
	  if (seqPos <= 0) { articleEditUrl += "&seq="; articleEditUrl += seqnum; }
	  else { articleEditUrl = articleEditUrl.substring(0,seqPos+4); articleEditUrl += seqnum;}
	  seqnum++;
	  // Edit tab was selected. Go fetch Edit tab content
	  xmlhttp.open("get",articleEditUrl,true);
	  xmlhttp.onreadystatechange=function() {
	    if (xmlhttp.readyState==4) {
	    // Read the returned HTML
	    var editHtml = xmlhttp.responseText;
	    var editTab = articleTabView.getTab(1);
	    // And fill the tab
	    editTab.set('content', editHtml);
	    }
	  }
	  xmlhttp.setRequestHeader('Accept','message/x-formresult');
	  xmlhttp.send(null);
	}
        return true;});
  var newTab1 = new YAHOO.widget.Tab({ 
	        label: 'Article', 
	        content: jsonData.html, 
//		dataSrc: "http://www.google.com?test=Y",
		cacheData: false,
	        active: true 
	    }); 
  newTab1.get("contentEl").style.overflow = "scroll";
  // DAVID....I JUST EDITED THIS:
  var tabht = getBrowserWindowHeight()-120;
  newTab1.get("contentEl").style.height = tabht+"px";
  newTab1.get("contentEl").style.background = "white";
  articleTabView.addTab(newTab1);
  var newTab2 = new YAHOO.widget.Tab({ 
	        label: 'Edit', 
	        content: "Loading Wiki Editor...", 
		cacheData: false,
	        active: false 
	    });
  newTab2.get("contentEl").style.overflow = "scroll";
  newTab2.get("contentEl").style.height = tabht+"px";
  newTab2.get("contentEl").style.background = "white";
  articleTabView.addTab( newTab2 ); 
  articleTabView.appendTo('articletabcontainer');

  handleSlider();
}

// Select one of the tabs. Called when a note is selected for viewing
function selectNoteTab(tabIndex) {
   	setTimeout(function(){
	   if ((currentNoteTabView != null) && (tabIndex>0) && (tabIndex<=3)) {
		currentNoteTabView.selectTab(tabIndex);
           }
  	}, 1000);
  }

function notesInit(jsonData) {
  var tabView = new YAHOO.widget.TabView();
  currentNoteTabView = tabView;
  tabView.subscribe('beforeActiveIndexChange', function(e){
        var newTabIndex = e.newValue;
        var newTab = tabView.getTab(newTabIndex);
        var newDS= newTab.get('dataSrc');
	var seqPos = newDS.lastIndexOf('seq=');
	if (seqPos <= 0) { newDS += "&seq="; newDS += seqnum; }
	else { newDS = newDS.substring(0,seqPos+4); newDS += seqnum;}
	seqnum++;
        newTab.set('dataSrc', newDS);
        return true;});
  var tabname;
  var indexVal = 0;
  var notesTabs = new Array();
  ib_featureType = jsonData.featureType;
  ib_lid = jsonData.lid;

  for (tabname in jsonData)
  {
      var tabObj = jsonData[indexVal];
      var newTab = new YAHOO.widget.Tab(tabObj);
      newTab.get("contentEl").style.height = "600px";
      newTab.get("contentEl").style.overflow = "auto";
//      newTab.get("contentEl").style.overflow = "scroll";
//    newTab.get("contentEl").style.height = "456px";
      notesTabs[indexVal] = newTab;
      tabView.addTab(newTab);
      indexVal++;
    // After loading the 4 tabs, get out of this loop and read the lid and featureType
      if (indexVal > 3)
	{
	break;
	}
  }
  // The first tab is selected (usually)
  tabView.set('activeIndex',0);
  tabView.appendTo('notecontainer');

  handleSlider();
}


// Select one of the tabs. Called when a note is selected for viewing
function selectMyPlacesTab(tabIndex) {
   	setTimeout(function(){
	   if ((currentMyPlacesTabView != null) && (tabIndex>0) && (tabIndex<=2)) {
		currentMyPlacesTabView.selectTab(tabIndex);
           }
  	}, 1000);
  }

// Tells showWallPostLink() whether to put the link in a Map/view.html tab OR under the postnote.html LifePath
var wallPostDestination = 'tab';
function showWallPostLink() 
{
  xmlhttp.open("get","http://www.zoomatlas.com/InfoBoxManager/InfoBox?wall=Y&seq="+seqnum,true);
  seqnum++;
  xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
    // Read the returned XML data from InfoBoxManager
    var xmlDoc = xmlhttp.responseXML; 
    var response = xmlDoc.documentElement;
    var errElt=response.getElementsByTagName('error');
    if (errElt != null)
    {
      var errEltZero=errElt[0];
      if (errEltZero != null)
      {
	var errChild=errEltZero.firstChild;
        if (errChild != null)
        {
	    alert(errChild.data);
	    return;
        }
      }
    }
    FBarticleHeader = response.getElementsByTagName('articleHeader')[0].firstChild.data;
    FBarticleBody   = response.getElementsByTagName('articleBody')[0].firstChild.data;
    FBtileFname     = response.getElementsByTagName('tileFname')[0].firstChild.data;
    FBuid           = response.getElementsByTagName('fb_uid')[0].firstChild.data;
    if (FBarticleHeader == null) { FBarticleHeader = "My ZoomAtlas LifePath Timeline"; }
    if (FBarticleBody   == null) { FBarticleBody = "Come check out all the places I've been."; }
    if (FBtileFname     == null) { FBtileFname = "http://www.zoomatlas.com/pix/FBLifeLineB.png"; }
    if (FBuid           == null) { FBuid = 0; }

    var wallArticleHtml = "<span style=\"color:blue\"><b>"+FBarticleHeader+
			  "</b></span><br/>"+FBarticleBody;

    if (wallPostDestination == 'tab')
    {
        // Add the second tab
        currentMyPlacesTabView.addTab( new YAHOO.widget.Tab({
            label: 'Publish My LifePath',
            content: '<br/><br/><table><tr><td><img src=\"http://www.zoomatlas.com/cgi-bin/lifepath_banner.prl?seqnum='+seqnum+'\" width=\"130\" height=\"130\"></td><td>&nbsp;</td><td valign=\"top\">'+wallArticleHtml+'</td></tr></table><br/><center><div onclick=\"javascript:fbPublish();\" style=\"cursor:hand;\"><u>Click Here to Publish to Your Wall</u></div></center><fb:fan profile_id=\"180887002485\" stream=\"\" connections=\"\" width=\"300\"></fb:fan><div style=\"font-size:8px; padding-left:10px\">',
     
            cacheData: false,
            active: false
          }));
    
        // Add the third tab
        var lifePathFriendsUrl = lifePathUrl.replace("floatMode=m","floatMode=mfriends");
        currentMyPlacesTabView.addTab( new YAHOO.widget.Tab({
            label: 'My Friends\' LifePaths',
    //        content: '<div class=\"scrolledFriendSelector\"><div style=\"cursor:pointer\" onclick=\"showFriendLifePath(\'http://www.zoomatlas.com/InfoBoxManager/InfoBox?click=Y&floatMode=m100000244076538&seqnum=0\');\">Lief Lowry</div><br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a<br/>a</div><div id=\"FriendLifePath\">&nbsp;</div>',
            dataSrc: lifePathFriendsUrl,
            cacheData: false,
            active: false
          }));
    
        currentMyPlacesTabView.appendTo('myplacescontainer');
    
        // Pretend there was a resize. Makes the scroll bars paint correctly
        handleSlider();
      }
      else
      {
	// Put the Share link under the LifePath window in postnote.html
	document.getElementById('life_path_link_div').innerHTML = "<div onclick=\"javascript:fbPublish();\" style=\"cursor:pointer; cursor:hand;\"><table><tr><td valign=\"bottom\"><img src=\"/images/fbshare.png\" /></td><td>&nbsp;<u>Publish to Your Wall</u></td></tr></table></div>";
      }
    }
 };
 // Now that we defined the callback function, make the url call
 xmlhttp.setRequestHeader('Accept','message/x-formresult');
 xmlhttp.send(null);
 return true;
}


function myPlacesInit(url) {
  lifePathUrl = url;
  currentMyPlacesTabView = new YAHOO.widget.TabView();
  currentMyPlacesTabView.subscribe('beforeActiveIndexChange', function(e){
        var newTabIndex = e.newValue;
        var newTab = currentMyPlacesTabView.getTab(newTabIndex);
        var newDS= newTab.get('dataSrc');
	var seqPos = newDS.lastIndexOf('seq=');
	if (seqPos <= 0) { newDS += "&seq="; newDS += seqnum; }
	else { newDS = newDS.substring(0,seqPos+4); newDS += seqnum;}
	seqnum++;
        newTab.set('dataSrc', newDS);
        return true;});
  var tabname;
  var myPlacesTab = new YAHOO.widget.Tab({
        label: 'My LifePath',
        dataSrc: lifePathUrl,
        cacheData: false,
        active: true
    });
  // Do something like this on the MyPlaces tab to be informed or resize events
  // myPlacesTab.get("contentEl").onResize(handler);
  // handler:  document.getElementById('categoryAdd').style.width = 600;
  currentMyPlacesTabView.addTab( myPlacesTab );

  // Before we build the second tab, we need to call InfoBoxManager and get the custom
  // text for this user.

  // Set this variable for the benefit of the callback
  wallPostDestination = 'tab';

  // Now set up the remaining tabs
  showWallPostLink();

 return true;
}

function showFriendLifePath(url)
{
  var seqPos = url.lastIndexOf('seq=');
  if (seqPos <= 0) { url += "&seq="; url += seqnum; }
  else { url = url.substring(0,seqPos+4); url += seqnum;}
  seqnum++;
  // A friend's LifePath was selected...get the content
  xmlhttp.open("get",url,true);
  xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState==4) {
    // Read the returned HTML
    var lpHtml = xmlhttp.responseText;
    document.getElementById('FriendLifePath').innerHTML = lpHtml;
    }
  }
  xmlhttp.setRequestHeader('Accept','message/x-formresult');
  xmlhttp.send(null);
}

function fbPublish()
{
    FBtileFname = FBtileFname.replace("lpbanner","lpb");
    var FBsafeUrl = "http://www.zoomatlas.com";
    if (FBuid > 0) { FBsafeUrl = "http://apps.facebook.com/zoomatlas/lifepath.html?fbid="+FBuid+"&fb_force_mode=fbml"; }
    var attachment = {'media':[{'type':'image',
	'src':FBtileFname,'href':FBsafeUrl,'width':'130','height':'130'}],
		'name': FBarticleHeader,
		'href': 'http://www.zoomatlas.com',
		'description': FBarticleBody};
    var action_links = [{ 'text': 'Build your own LifePath', 'href': 'http://www.zoomatlas.com/postnote.html'}];
                
    FB.Connect.streamPublish('Check out my ZoomAtlas LifePath...the timeline of my life', attachment, action_links,  null, FBarticleHeader , wallPostCallback, false, null);
        
    return true;
}

function inviteFriend(friendName,friendFBID)
{
    var actionLinks = [{ "text": "Visit ZoomAtlas", "href": "http://www.zoomatlas.com"}];
    var attachment = {'media':[{'type':'image',
	'src':'http://www.zoomatlas.com/pix/FBLifeLineB.png','href':'http://www.zoomatlas.com','width':'130','height':'130'}],
		'name': 'ZoomAtlas: Mapping Every Square Inch of America',
		'href': 'http://www.zoomatlas.com',
		'description': 'Map your life...find old friends. Get reconnected with people from your past who are not on Facebook. Drop notes at your old homes, and your friends\' old homes. Build a LifePath timeline of your life, and share it with friends on Facebook.'};
  FB.Connect.streamPublish('I built my LifePath timeline on ZoomAtlas...you should too.',attachment,actionLinks,friendFBID);
}

function wallPostCallback()
{
  var url="http://www.zoomatlas.com/cgi-bin/recordWallPost.prl?seq="+seqnum;
  seqnum++;
  xmlhttp.open("get",url,true);
  xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
    // OK, we got a reply
    }
  };
 xmlhttp.setRequestHeader('Accept','message/x-formresult');
 xmlhttp.send(null);

 return true;
}

function handleSlider()
{
  if (!sizeHandlerSet)
  {
    m_Layout.getUnitByPosition("right").on("resize", sliderResize);
    sizeHandlerSet = true;
  }
  sliderResize(null);
}


var lastPopup=0;
var activeLifePathTimeout = 0;
var popupLoaded=0; // Popup is considered loaded when cursor floats over content
var slotSize = 120;
var livedBgImage = "url(http://www.zoomatlas.com/notebar/images/popbgblue.png)";
var workedBgImage = "url(http://www.zoomatlas.com/notebar/images/popbgorange.png)";
var playedBgImage = "url(http://www.zoomatlas.com/notebar/images/popbggreen.png)";

function showLifePathPopup(e,noteId,lid,parentLid,featureType,verb,activity,fromDate,toDate,frmo,fryr,tomo,toyr,popupId,featureType,encodedTextstr,encodedComment)
{
  var evt; if (window.event) { evt = window.event; } else { evt = e;}
  if (popupId == lastPopup) { /* hidePopup(popupId);*/ return; }
  popupLoaded = 0;
  newImage = livedBgImage;
  if (verb == 'worked') { newImage = workedBgImage; }
  if (verb == 'played') { newImage = playedBgImage; }

  // Comment Text
  var comment = decodeURIComponent(encodedComment.replace(/\+/g," "));

  // Location Text
  var textstr = decodeURIComponent(encodedTextstr.replace(/\+/g," "));

  // Location Link. Pass (parentLid,lid) for inside objects or just (lid) for objects with geometries
  var clickstr = "<span style=\"cursor:pointer\" onclick=\"javascript:g_setGlobalSelection("+
		(parentLid>0?parentLid+",":"")+
		lid+");\"><u>"+textstr+"</u></span>";

  document.getElementById('popupCell').style.backgroundImage = newImage;
  document.getElementById('boxcontent').innerHTML = "<table><tr><td rowspan=\"2\" valign=\"top\">" + 
	"<img width=\"58\" height=\"58\" src=\"http://www.zoomatlas.com/pix/"+featureType+".png\"></td><td valign=\"top\"><span class='earn_small'>Location: </span></td><td class='data' valign=\"top\">" + clickstr + "</td></tr><tr><td class='data' valign=\"bottom\"><span class='earn_small'>From:</span></td><td class='data' valign=\"bottom\">"+fromDate+" <span class='earn_small'>To:</span>"+toDate+"<span id=\"getAddrLidElement\" style=\"cursor: pointer\" onclick=\"setCallback(); getAddressLid();\"></td></tr><tr><td class='data' colspan=\"3\">" +
           "<img alt=\"Upload a Photo...\" src=\"http://www.zoomatlas.com/notebar/images/popphoto.png\" width=\"32\" height=\"32\">" +
           "<span class='earn_small'>Details: </span><i>" + comment + "</i><br/>"+
// Next line adds the edit and delete icons
//           "<span id=\"getAddrLidElement\" style=\"cursor: pointer\" onclick=\"setCallback(); hidePopup(); getAddressLid2(" + noteId +"," + lid +"," + featureType +",'"+ textstr+"','"+activity+"',"+frmo+","+fryr+","+tomo+","+toyr+",'"+encodedComment + "'); \"><img alt=\"Edit\" src=\"http://www.zoomatlas.com/notebar/images/popedit.png\" width=\"32\" height=\"32\"></span>&nbsp;<span id=\"deleteNote\" style=\"cursor:pointer\" onclick=\"javascript:deleteNote("+noteId+");\"><img alt=\"Delete from my LifePath\" src=\"http://www.zoomatlas.com/notebar/images/popdelete.png\" width=\"32\" height=\"32\"></span>"+
           "</td></tr></table>";

  var xOffset = evt.clientX - 125;
// alert("X:"+evt.clientX+" Y:"+evt.clientY);
  document.getElementById('popupLifePathBox').style.left = xOffset;
//  var yOffset = 200 + slotSize; if (verb == 'worked') { yOffset += slotSize; } if (verb == 'played') { yOffset += (2*slotSize); }
  var yOffset = evt.clientY + 30;
  document.getElementById('popupLifePathBox').style.top = yOffset;
  document.getElementById('popupLifePathBox').style.display = 'block';
  lastPopup = popupId;
  if (activeLifePathTimeout != 0)
  {
	clearTimeout(activeLifePathTimeout);
  }
  activeLifePathTimeout = setTimeout("popdownLifePathBox()",5000);
}

function popdownLifePathBox()
{
  document.getElementById('popupLifePathBox').style.display = 'none';
  activeLifePathTimeout = 0;
}

// Doom the LifePath popup to only 5 more seconds of life
function doomLifePathBox()
{
  if (activeLifePathTimeout != 0)
  {
	clearTimeout(activeLifePathTimeout);
  }
  activeLifePathTimeout = setTimeout("popdownLifePathBox()",5000);
}

// Grant an indefinite stay-of-execution to the LifePath popup
function keepAliveLifePathBox()
{
  if (activeLifePathTimeout != 0)
  {
	clearTimeout(activeLifePathTimeout);
  }
}


// Called when a user selects the '+' add category tab in the goInside box
function addCategoryTab(lid,optionHTML)
{
  var decodedStr = decodeURIComponent(optionHTML).replace(/\+/g," ");
  ib_fieldName = "NewCategory";
  ib_lid = lid;
  document.getElementById('categoryAdd').innerHTML = 
   "<select id=\"ib_"+ib_fieldName+"\">"+
decodedStr+"</select><input type=submit onclick=\"javascript:saveTextChanges();\" value=\"+\">"; 
}

// Called when the user saves text (or option menu) changes
function saveTextChanges() {
  var fieldValueElt= document.getElementById("ib_"+ib_fieldName);
  var fieldValue= fieldValueElt.value;
  if ((ib_fieldName == "block") || (ib_fieldName == "addrblock"))
  {
    fieldValue = fieldValue + "." + document.getElementById("housenum").value;
  }
  if (fieldValue != null)
  {
	// A -999999 value indicates that user selected [New...] on the pulldown menu
      if (fieldValue == -999999)
      {
	fieldValue = "NEW_"+prompt("New Value:","");
      }
      fieldValue = encodeURIComponent(fieldValue);
  }
  // Call the actual work function
  return saveEditChanges(ib_lid,ib_featureType,ib_fieldName,ib_fieldLongName,fieldValue);
  }

// Handles the JSON response from a goInside edit
function saveInsideChanges(lidStr,featureTypeStr,fieldName,fieldLongName,fieldValue) 
{
  var categoryTabName = fieldName.substring(10);
  categoryTabName = categoryTabName.substring(0,categoryTabName.indexOf('_'));
  url="http://www.zoomatlas.com/InfoBoxManager/InfoBox?edit=Y&lid="+lidStr+"&featureType="+featureTypeStr+"&fieldName="+fieldName+"&fieldLongName="+encodeURIComponent(fieldLongName)+"&"+fieldName+"="+fieldValue+"&seqnum="+seqnum;
  seqnum++;
  xmlhttp.open("get",url,true);
  xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
    // Read the returned JSON data from InfoBoxManager
    var format = new OpenLayers.Format.JSON();
    var jsonData = format.read(xmlhttp.responseText);
    if (jsonData.error != null) 
    {
	if (jsonData.error.length > 0)
	{
	    alert(jsonData.error);
	    return;
        }
    }
    var insideLid=jsonData.ib_insideLid;
    var newHtml=jsonData.html;
    document.getElementById("categoryTab"+categoryTabName).innerHTML = newHtml;
    }
  };
 xmlhttp.setRequestHeader('Accept','message/x-formresult');
 xmlhttp.send(null);
 return false;
}


// Notify the InfoBoxManager of new values and handle the reply XML
function saveEditChanges(lidStr,featureTypeStr,fieldName,fieldLongName,fieldValue) {
  // GoInside panel returns JSON data, not XML. Handle it in a special function
  if (fieldName.substr(0,10) == "ib_inside_")
  {
	return saveInsideChanges(lidStr,featureTypeStr,fieldName,fieldLongName,fieldValue);
  }
  url="http://www.zoomatlas.com/InfoBoxManager/InfoBox?edit=Y&lid="+lidStr+"&featureType="+featureTypeStr+"&fieldName="+fieldName+"&fieldLongName="+encodeURIComponent(fieldLongName)+"&"+fieldName+"="+fieldValue+"&seqnum="+seqnum;
  seqnum++;
  xmlhttp.open("get",url,true);
  xmlhttp.onreadystatechange=function() {
   if (xmlhttp.readyState==4) {
    var xmlDoc = xmlhttp.responseXML; 
// Doesnt fix 4K bug in IE:    xmlDoc.normalize();
    var response = xmlDoc.documentElement;

    var errElt=response.getElementsByTagName('error');
    if (errElt != null)
    {
      var errEltZero=errElt[0];
      if (errEltZero != null)
      {
	var errChild=errEltZero.firstChild;
        if (errChild != null)
        {
	    alert(errChild.data);
	    return;
        }
      }
    }
    // The go-inside handler goes through different code
    var insideElt=response.getElementsByTagName('ib_insideLid');
    if (insideElt != null)
    {
      var insideEltZero=insideElt[0];
      if (insideEltZero != null)
      {
	var insideLid=insideEltZero.firstChild;
        if (insideLid != null)
        {
	    var newHtml=response.getElementsByTagName('html')[0].firstChild.data;
	    onGoInsideResponse(response,insideLid,newHtml);
	    return;
        }
      }
    }
    // The NewCategory tab of the go-inside box goes through different code
    insideElt=response.getElementsByTagName('ib_insideNewCategory');
    if (insideElt != null)
    {
      var insideEltZero=insideElt[0];
      if (insideEltZero != null)
      {
	var insideCategory=insideEltZero.firstChild;
        if (insideCategory != null)
        {
	    // Repopulate the float panel with the newly-created
	    // tab already selected
	    floatPanel("x"+insideCategory,ibFloatPanelLon,
			ibFloatPanelLat,ibFloatPanelZ);
	    return;
        }
      }
    }
    var eltList = response.getElementsByTagName('fieldName')[0];
    var num1Child = eltList.firstChild;
    var fieldNameChild = response.getElementsByTagName('fieldName')[0].firstChild;
    var fieldName = "";
    if (fieldNameChild != null)
    {
      fieldName = fieldNameChild.data;
    }
    if (fieldName == "featureFullname")
    {
	// The feature type was changed. Reload entire page
	window.location.reload();
    }
/*      ***** No Longer redirect to named page. The current LID is fine.
    var redirectChild = response.getElementsByTagName('redirectTo')[0].firstChild;
    if (redirectChild != null)
    {
      var redirectURL = redirectChild.data;
      if (redirectURL != '')
	{
	      // The primary feature name was changed so we must redirect to the new article page
	      redirectURL = redirectURL.replace(/''/g,'\'');

	      // Depending on whether we are in the Map editor or the wiki, announce that the
	      // default page name has changed. If we are in the wiki, this will cause a jump to
	      // the newly named page.
	      onLidNameSet(redirectURL);
        }
    }
*/
    var fieldLongNameObj = response.getElementsByTagName('fieldLongName')[0].firstChild;
    var fieldLongName = '';
    if (fieldLongNameObj != null) { fieldLongName = fieldLongNameObj.data; }
    var newValResp = response.getElementsByTagName(fieldName)[0].firstChild;
    var newVal = "";
    if (newValResp != null)
    {
      newVal = newValResp.data;
    }
    var lid = response.getElementsByTagName('lid')[0].firstChild.data;
    var featureType = response.getElementsByTagName('featureType')[0].firstChild.data;
    var infoStrResp = response.getElementsByTagName('info')[0];
    var bbNorthResp = response.getElementsByTagName('bbnorth')[0];
    var bbSouthResp = response.getElementsByTagName('bbsouth')[0];
    var bbEastResp = response.getElementsByTagName('bbeast')[0];
    var bbWestResp = response.getElementsByTagName('bbwest')[0];
    var listFlagResp = response.getElementsByTagName('list')[0];

    // Only fixup the InfoBox if this was a regular text or optionMenu.
    // Road characteristics is a persistent menu which need-not be fixed up.
    if (fieldName != "characteristics")
    {
      var optionMenuChild=response.getElementsByTagName('optionMenu')[0].firstChild;
      var optionMenu="";
      if (optionMenuChild != null)
      {
        optionMenu = decodeURIComponent(optionMenuChild.data);
      }
      var quotedNewVal = newVal.replace(/'/g,"\\'");
      var onClickStr = "onclick=\"javascript:showTextEdit('"+fieldLongName+"','"+fieldName+"','"+
         quotedNewVal + "','5','"+lid+"','"+featureType+"');\"";
      if (listFlagResp != null)
      {
	// Tell the field how to load a new textarea
	onClickStr = "onclick=\"javascript:showListEdit('"+fieldLongName+"','"+fieldName+"','"+
         quotedNewVal + "','"+lid+"','"+featureType+"');\"";
	// Add a couple of &nbsp; characters to indent the list
        newVal = quotedNewVal.replace(/<br\/>/g,"<br\/>&nbsp;&nbsp;");
      }
      if (optionMenu.length > 0)
      {
  	onClickStr = "onclick=\"javascript:showPulldownMenu('"+
  		fieldLongName+"','"+fieldName+"','"+optionMenu+"','"+lid+"','"+featureType+"');\"";
      }
      if (((fieldName == "block")    && (ib_fieldName == "addrblock")) ||
	  ((fieldName == "fullname") && (ib_fieldName == "microfullname"))   )
	{
	  // A name or address edit was performed in the breadcrumb bar
	  var commaPos = newVal.indexOf(',');
	  if (commaPos > 0) { newVal = newVal.substring(0,commaPos); }
	  var htmlElt1 = document.getElementById(ib_fieldName);
	  if (htmlElt1 != null) htmlElt1.innerHTML = newVal;
	  var htmlElt2 = document.getElementById(ib_fieldName+"_R");
	  if (htmlElt2 != null) htmlElt2.innerHTML = ""; 
	}
      else
	{
	  // An edit was performed in the InfoBox
	  var htmlElt1 = document.getElementById(fieldName)
	  if (htmlElt1 != null) htmlElt1.innerHTML = newVal;
	  var htmlElt2 = document.getElementById(fieldName+"_R");
	  if (htmlElt2 != null) htmlElt2.innerHTML = 
         "<span style=\"cursor:pointer\" "+onClickStr+"><span class=\"earn_small\"><u>Edit</u></span> <img src=\"http://www.zoomatlas.com/images/icons/1pts.jpg\" width=\"16\" height=\"15\" alt=\"Earn 1 Point\"></span>";
	}
    }  

    if (infoStrResp != null)
    {
        alert(infoStrResp.firstChild.data);
    }
    if ((bbNorthResp != null) && (bbSouthResp != null) && 
	(bbEastResp != null) && (bbWestResp != null)   )
    {
	// If we got a bounding box back, that means an info box edit
	// changed something on the map. Now we must ask the map to
	// redraw.
	RedrawMap(bbWestResp.firstChild.data, bbSouthResp.firstChild.data, 
		  bbEastResp.firstChild.data, bbNorthResp.firstChild.data);
    }
   }
  };
 xmlhttp.setRequestHeader('Accept','message/x-formresult');
 xmlhttp.send(null);
 return false;
 }



// Refresh the point display
function refreshPoints() {
 return true;
 }

// This function displays the current points
function showPoints(points,pointstoday) {
  return true;
}


// This function gets called when the HTML link gets clicked
function showFileUpload(lid,featureType) {
    document.getElementById('pixup').innerHTML =
"<form method=\"post\" enctype=\"multipart/form-data\"" +
" action=\"http://www.zoomatlas.com/cgi-bin/pixup.prl\">" +
"<input type=\"hidden\" name=\"lid\" value=\""+lid+"\">" +
"<input type=\"hidden\" name=\"featureType\" value=\""+featureType+"\">" +
"<input type=file size=\"10\" name=upfile><br/>" +
"<input type=submit value=Upload></form>";
}


function showTextEdit(fieldLongName,fieldName,fieldValue,fieldSize,lid,featureType)  {
	showEditField(fieldLongName,fieldName,fieldValue,fieldSize,lid,featureType,"Text");
}

function showIntEdit(fieldLongName,fieldName,fieldValue,fieldSize,lid,featureType)  {
	// Period (char=190) is NOT legal for floating point 
	optionalChar = -1;
	// Strip out the commas when posting the integer edit widget
        var newFieldVal = fieldValue.replace(/,/g,"");
	showEditField(fieldLongName,fieldName,newFieldVal,fieldSize,lid,featureType,"Int");
}

function showFloatEdit(fieldLongName,fieldName,fieldValue,fieldSize,lid,featureType)  {
	// Period (char=190) is legal for floating point 
	optionalChar = 190;
	showEditField(fieldLongName,fieldName,fieldValue,fieldSize,lid,featureType,"Int");
}

function showEditField(fieldLongName,fieldName,fieldValue,fieldSize,lid,featureType,dataType)  {
ib_lid = lid;
ib_featureType=featureType;
ib_fieldLongName=fieldLongName;
ib_fieldName=fieldName;
    document.getElementById(fieldName).innerHTML = 
"<input type=\"text\" onkeypress=\"return onIB"+dataType+"Enter(event,this.form);\" id=\"ib_"+fieldName+"\" SIZE=\""+fieldSize+"\" VALUE=\""+fieldValue+"\">";
    document.getElementById(fieldName + "_R").innerHTML = 
"<input type=submit onclick=\"javascript:saveTextChanges();\" style=\"font-size:60%\" value=\"OK\">"; 
}

function onIBTextEnter( evt, frm ) {
	var keyCode = null;

	if( evt.which ) {
	keyCode = evt.which;
	} else if( evt.keyCode ) {
	keyCode = evt.keyCode;
	}
	if( 13 == keyCode ) {
	saveTextChanges();
	return false;
	}
    return true;
}

function onIBIntEnter( evt, frm ) {
	var keyCode = null;

	if( evt.which ) {
	keyCode = evt.which;
	} else if( evt.keyCode ) {
	keyCode = evt.keyCode;
	}
	if( 13 == keyCode ) {
	saveTextChanges();
	return false;
	}
	else if (keyCode < 48) {
	// Character struck is less than zero. Illegal, except for backspace,
	// left/right arrow and delete keys
	// Optionally check for decimal point
	if ((keyCode == 8)  || (keyCode == 37)  || 
	    (keyCode == 39) || (keyCode == 46) || (keyCode == optionalChar))
	{
		return true;
	}
	return false;
	}
	else if (keyCode >= 58) {
	return false;
	}
    return true;
}


function showListEdit(fieldLongName,fieldName,fieldValue,lid,featureType)  {
    var newFieldVal = fieldValue.replace(/<br\/>/g,"\n");
    ib_lid = lid;
    ib_featureType=featureType;
    ib_fieldLongName=fieldLongName;
    ib_fieldName=fieldName;

    document.getElementById(fieldName).innerHTML = 
fieldLongName +
"<textarea id=\"ib_"+fieldName+"\" rows=\"4\" cols=\"20\">"+newFieldVal+"</textarea>";
    document.getElementById(fieldName + "_R").innerHTML = 
"<input type=submit onclick=\"javascript:saveTextChanges();\" style=\"font-size:60%\" value=\"OK\">"; 
}

function showRoadMenu(fieldLongName,fieldName,optionHTML,lid,featureType)  {
    var m1 = new COOLjsMenu("menu1", LOCAL_ROAD_ITEMS);
    ib_lid = lid;
    ib_featureType=featureType;
    ib_fieldLongName=fieldLongName;
    ib_fieldName=fieldName;
    document.getElementById(fieldName).innerHTML = 
fieldLongName +
m1+
"<select id=\"ib_"+fieldName+"\">"+
decodeURIComponent(optionHTML)+"</select>";
    document.getElementById(fieldName + "_R").innerHTML = 
"<input type=submit onclick=\"javascript:saveTextChanges();\" style=\"font-size:60%\" value=\"OK\">"; 
 
}


function showPulldownMenu(fieldLongName,fieldName,optionHTML,lid,featureType)  {
    var addlField = "";
    var brStr = "";
    var fontStr = "";
    if (fieldName == "block")
    {
	brStr = "<br/>";
    }
    if (fieldName == "addrblock")
    {
	// The addrblock bar is not very high, reduce the font size
	fontStr = "style=\"font-size:70%\"";
    }
    if ((fieldName == "block") || (fieldName == "addrblock"))
    {
	addlField = brStr+"House or Bldg #:<input "+fontStr+" type=\"text\" id=\"housenum\" size=\"4\" value=\"\">";
    }
    ib_lid = lid;
    ib_featureType=featureType;
    ib_fieldLongName=fieldLongName;
    ib_fieldName=fieldName;
    var decodedStr = decodeURIComponent(optionHTML).replace(/\+/g," ");

    document.getElementById(fieldName).innerHTML = 
brStr + "<select  "+fontStr+" id=\"ib_"+fieldName+"\">"+
decodedStr+"</select>"+addlField;
    document.getElementById(fieldName + "_R").innerHTML = 
"<input type=submit onclick=\"javascript:saveTextChanges();\" "+fontStr+" value=\"OK\">"; 
 
}

function showSuggestionBox(refId)
{
   var suggestBox = new YAHOO.widget.Panel("suggestBox" + seqnum,
            {
                width:"335px",
                visible:true,
                draggable:true,
                close:true,
                constraintoviewport:true,
                context:[refId,'tl','tl']
            }
	);
    suggestBox.setHeader("Cannot post note here");
    suggestBox.setBody("<img src=\"/images/suggestion.jpg\" />");
    suggestBox.render(document.body);
}


function loadFeatureMenu(featureCategory,lid,featureType,featureTypeDescription) {
     var menuStr = buildPropertyMenu(featureType);
     showPulldownMenu("","featureFullname",menuStr ,lid,featureType);
}


function buildPropertyMenu(selection) {
  if (propertyMenu == null)
  {
	propertyMenu = new Array();

	propertyMenu[0] = new Array(2);
	propertyMenu[1] = new Array(2);
	propertyMenu[2] = new Array(2);
	propertyMenu[3] = new Array(2);
	propertyMenu[4] = new Array(2);
	propertyMenu[5] = new Array(2);
	propertyMenu[6] = new Array(2);
	propertyMenu[7] = new Array(2);
	propertyMenu[8] = new Array(2);
	propertyMenu[9] = new Array(2);
	propertyMenu[10] = new Array(2);
	propertyMenu[11] = new Array(2);
	propertyMenu[12] = new Array(2);
	propertyMenu[13] = new Array(2);
	propertyMenu[14] = new Array(2);
	propertyMenu[15] = new Array(2);
	propertyMenu[16] = new Array(2);
	propertyMenu[17] = new Array(2);
	propertyMenu[18] = new Array(2);
	propertyMenu[19] = new Array(2);
	propertyMenu[20] = new Array(2);
	propertyMenu[21] = new Array(2);
	propertyMenu[22] = new Array(2);
	propertyMenu[23] = new Array(2);
	propertyMenu[24] = new Array(2);
	propertyMenu[25] = new Array(2);
	propertyMenu[26] = new Array(2);
	propertyMenu[27] = new Array(2);
	propertyMenu[28] = new Array(2);
	propertyMenu[29] = new Array(2);
	propertyMenu[30] = new Array(2);
	propertyMenu[31] = new Array(2);
	propertyMenu[32] = new Array(2);
	propertyMenu[33] = new Array(2);
	propertyMenu[34] = new Array(2);
	propertyMenu[35] = new Array(2);
	propertyMenu[36] = new Array(2);
	propertyMenu[37] = new Array(2);
	propertyMenu[38] = new Array(2);
	propertyMenu[39] = new Array(2);
	propertyMenu[40] = new Array(2);
	propertyMenu[41] = new Array(2);
	propertyMenu[42] = new Array(2);
	propertyMenu[43] = new Array(2);
	propertyMenu[44] = new Array(2);
	propertyMenu[45] = new Array(2);
	propertyMenu[46] = new Array(2);
	propertyMenu[47] = new Array(2);
	propertyMenu[48] = new Array(2);
	propertyMenu[49] = new Array(2);
	propertyMenu[50] = new Array(2);
	propertyMenu[51] = new Array(2);
	propertyMenu[52] = new Array(2);
	propertyMenu[53] = new Array(2);
	propertyMenu[54] = new Array(2);
	propertyMenu[55] = new Array(2);
	propertyMenu[56] = new Array(2);
	propertyMenu[57] = new Array(2);
	propertyMenu[58] = new Array(2);
	propertyMenu[59] = new Array(2);
	propertyMenu[60] = new Array(2);
	propertyMenu[61] = new Array(2);
	propertyMenu[62] = new Array(2);
	propertyMenu[63] = new Array(2);
	propertyMenu[64] = new Array(2);
	propertyMenu[65] = new Array(2);
	propertyMenu[66] = new Array(2);
	propertyMenu[67] = new Array(2);
	propertyMenu[68] = new Array(2);
	propertyMenu[69] = new Array(2);
	propertyMenu[70] = new Array(2);
	propertyMenu[71] = new Array(2);
	propertyMenu[72] = new Array(2);
	propertyMenu[73] = new Array(2);
	propertyMenu[74] = new Array(2);
	propertyMenu[75] = new Array(2);
	propertyMenu[76] = new Array(2);
	propertyMenu[77] = new Array(2);
	propertyMenu[78] = new Array(2);
	propertyMenu[79] = new Array(2);
	propertyMenu[80] = new Array(2);
	propertyMenu[81] = new Array(2);
	propertyMenu[82] = new Array(2);
	propertyMenu[83] = new Array(2);
	propertyMenu[84] = new Array(2);
	propertyMenu[85] = new Array(2);
	propertyMenu[86] = new Array(2);
	propertyMenu[87] = new Array(2);
	propertyMenu[88] = new Array(2);
	propertyMenu[89] = new Array(2);
	propertyMenu[90] = new Array(2);
	propertyMenu[91] = new Array(2);
	propertyMenu[92] = new Array(2);
	propertyMenu[93] = new Array(2);
	propertyMenu[94] = new Array(2);
	propertyMenu[95] = new Array(2);
	propertyMenu[96] = new Array(2);
	propertyMenu[97] = new Array(2);
	propertyMenu[98] = new Array(2);
	propertyMenu[99] = new Array(2);

	propertyMenu[0][0] = 187;
	propertyMenu[0][1] = "Academic Building";
	propertyMenu[1][0] = 96;
	propertyMenu[1][1] = "Airport";
	propertyMenu[2][0] = 115;
	propertyMenu[2][1] = "Apartment Complex";
	propertyMenu[3][0] = 215;
	propertyMenu[3][1] = "Aquarium";
	propertyMenu[4][0] = 224;
	propertyMenu[4][1] = "Auto Rental";
	propertyMenu[5][0] = 225;
	propertyMenu[5][1] = "Auto Sales";
	propertyMenu[6][0] = 217;
	propertyMenu[6][1] = "Auto Service";
	propertyMenu[7][0] = 97;
	propertyMenu[7][1] = "Aviation Community";
	propertyMenu[8][0] = 241;
	propertyMenu[8][1] = "Bakery";
	propertyMenu[9][0] = 200;
	propertyMenu[9][1] = "Bank";
	propertyMenu[10][0] = 184;
	propertyMenu[10][1] = "Bar/Nightclub";
	propertyMenu[11][0] = 172;
	propertyMenu[11][1] = "Beach Area";
	propertyMenu[12][0] = 214;
	propertyMenu[12][1] = "Billiards Hall";
	propertyMenu[13][0] = 212;
	propertyMenu[13][1] = "Bowling Alley";
	propertyMenu[14][0] = 98;
	propertyMenu[14][1] = "Business Campus";
	propertyMenu[15][0] = 194;
	propertyMenu[15][1] = "Bus Stop";
	propertyMenu[16][0] = 185;
	propertyMenu[16][1] = "Cafe/Coffee House";
	propertyMenu[17][0] = 209;
	propertyMenu[17][1] = "Campground";
	propertyMenu[18][0] = 161;
	propertyMenu[18][1] = "Cemetery";
	propertyMenu[19][0] = 238;
	propertyMenu[19][1] = "Clothing Store";
	propertyMenu[20][0] = 208;
	propertyMenu[20][1] = "Club / Lodge";
	propertyMenu[21][0] = 110;
	propertyMenu[21][1] = "College/University";
	propertyMenu[22][0] = 169;
	propertyMenu[22][1] = "Commercial Property";
	propertyMenu[23][0] = 179;
	propertyMenu[23][1] = "Cropland";
	propertyMenu[24][0] = 236;
	propertyMenu[24][1] = "Day Care/Nursery";
	propertyMenu[25][0] = 173;
	propertyMenu[25][1] = "Department Store";
	propertyMenu[26][0] = 99;
	propertyMenu[26][1] = "Development";
	propertyMenu[27][0] = 188;
	propertyMenu[27][1] = "Dorm/Student Housing";
	propertyMenu[28][0] = 227;
	propertyMenu[28][1] = "Drive-In Theater";
	propertyMenu[29][0] = 232;
	propertyMenu[29][1] = "Drug Store/Pharmacy";
	propertyMenu[30][0] = 101;
	propertyMenu[30][1] = "Equestrian Community";
	propertyMenu[31][0] = 197;
	propertyMenu[31][1] = "Factory/Utility";
	propertyMenu[32][0] = 219;
	propertyMenu[32][1] = "Fairground";
	propertyMenu[33][0] = 171;
	propertyMenu[33][1] = "Farm / Ranch";
	propertyMenu[34][0] = 183;
	propertyMenu[34][1] = "Fast Food Restaurant";
	propertyMenu[35][0] = 191;
	propertyMenu[35][1] = "Firehouse";
	propertyMenu[36][0] = 205;
	propertyMenu[36][1] = "Florist /Greenhouse";
	propertyMenu[37][0] = 218;
	propertyMenu[37][1] = "Forest";
	propertyMenu[38][0] = 102;
	propertyMenu[38][1] = "Golf Community";
	propertyMenu[39][0] = 162;
	propertyMenu[39][1] = "Golf Course";
	propertyMenu[40][0] = 229;
	propertyMenu[40][1] = "Government Building";
	propertyMenu[41][0] = 103;
	propertyMenu[41][1] = "Government Campus";
	propertyMenu[42][0] = 177;
	propertyMenu[42][1] = "Grazing Land";
	propertyMenu[43][0] = 234;
	propertyMenu[43][1] = "Grocery Store";
	propertyMenu[44][0] = 189;
	propertyMenu[44][1] = "Gymnasium";
	propertyMenu[45][0] = 233;
	propertyMenu[45][1] = "Hair/Beauty Salon";
	propertyMenu[46][0] = 237;
	propertyMenu[46][1] = "Historic Site";
	propertyMenu[47][0] = 199;
	propertyMenu[47][1] = "Hospital";
	propertyMenu[48][0] = 211;
	propertyMenu[48][1] = "Hotel / Motel";
	propertyMenu[49][0] = 176;
	propertyMenu[49][1] = "House of Worship";
	propertyMenu[50][0] = 198;
	propertyMenu[50][1] = "Jail/Prison";
	propertyMenu[51][0] = 240;
	propertyMenu[51][1] = "Jewelry Store";
	propertyMenu[52][0] = 223;
	propertyMenu[52][1] = "Landfill";
	propertyMenu[53][0] = 186;
	propertyMenu[53][1] = "Library";
	propertyMenu[54][0] = 235;
	propertyMenu[54][1] = "Liquor Store";
	propertyMenu[55][0] = 226;
	propertyMenu[55][1] = "Live Theater";
	propertyMenu[56][0] = 116;
	propertyMenu[56][1] = "Mall/Shopping Center";
	propertyMenu[57][0] = 206;
	propertyMenu[57][1] = "Marina";
	propertyMenu[58][0] = 104;
	propertyMenu[58][1] = "Medical Center";
	propertyMenu[59][0] = 117;
	propertyMenu[59][1] = "Military Base";
	propertyMenu[60][0] = 221;
	propertyMenu[60][1] = "Military Building";
	propertyMenu[61][0] = 174;
	propertyMenu[61][1] = "MixedUse Comml/Resid.";
	propertyMenu[62][0] = 231;
	propertyMenu[62][1] = "Mobile Home";
	propertyMenu[63][0] = 121;
	propertyMenu[63][1] = "Mobile Home Park";
	propertyMenu[64][0] = 204;
	propertyMenu[64][1] = "Movie Theater";
	propertyMenu[65][0] = 163;
	propertyMenu[65][1] = "Multi-Family Residential";
	propertyMenu[66][0] = 190;
	propertyMenu[66][1] = "Museum";
	propertyMenu[67][0] = 70;
	propertyMenu[67][1] = "Neighborhood";
	propertyMenu[68][0] = 180;
	propertyMenu[68][1] = "Nursing Home";
	propertyMenu[69][0] = 207;
	propertyMenu[69][1] = "Office Building";
	propertyMenu[70][0] = 222;
	propertyMenu[70][1] = "Orchard";
	propertyMenu[71][0] = 164;
	propertyMenu[71][1] = "Park";
	propertyMenu[72][0] = 182;
	propertyMenu[72][1] = "Parking Lot/Structure";
	propertyMenu[73][0] = 220;
	propertyMenu[73][1] = "Police Station";
	propertyMenu[74][0] = 113;
	propertyMenu[74][1] = "Port Area";
	propertyMenu[75][0] = 230;
	propertyMenu[75][1] = "Post Office";
	propertyMenu[76][0] = 165;
	propertyMenu[76][1] = "Public Space/Plaza";
	propertyMenu[77][0] = 119;
	propertyMenu[77][1] = "Quad";
	propertyMenu[78][0] = 210;
	propertyMenu[78][1] = "Race Track";
	propertyMenu[79][0] = 203;
	propertyMenu[79][1] = "Repair Service";
	propertyMenu[80][0] = 175;
	propertyMenu[80][1] = "Restaurant";
	propertyMenu[81][0] = 245;
	propertyMenu[81][1] = "Retail Store";
	propertyMenu[82][0] = 201;
	propertyMenu[82][1] = "Retirement Home";
	propertyMenu[83][0] = 195;
	propertyMenu[83][1] = "School Property";
	propertyMenu[84][0] = 100;
	propertyMenu[84][1] = "School Campus";
	propertyMenu[85][0] = 114;
	propertyMenu[85][1] = "Section/Subdivision";
	propertyMenu[86][0] = 181;
	propertyMenu[86][1] = "Service Station";
	propertyMenu[87][0] = 239;
	propertyMenu[87][1] = "Shoe Store";
	propertyMenu[88][0] = 170;
	propertyMenu[88][1] = "Single-Family Residential";
	propertyMenu[89][0] = 213;
	propertyMenu[89][1] = "Skating Rink";
	propertyMenu[90][0] = 106;
	propertyMenu[90][1] = "Ski Area";
	propertyMenu[91][0] = 107;
	propertyMenu[91][1] = "Sports/Ent. Complex";
	propertyMenu[92][0] = 193;
	propertyMenu[92][1] = "Subway Station";
	propertyMenu[93][0] = 228;
	propertyMenu[93][1] = "Summer Camp";
	propertyMenu[94][0] = 202;
	propertyMenu[94][1] = "Supermarket";
	propertyMenu[95][0] = 118;
	propertyMenu[95][1] = "Theme Park";
	propertyMenu[96][0] = 178;
	propertyMenu[96][1] = "Timberland";
	propertyMenu[97][0] = 192;
	propertyMenu[97][1] = "Transport Hub";
	propertyMenu[98][0] = 196;
	propertyMenu[98][1] = "Undeveloped Land";
	propertyMenu[99][0] = 120;
	propertyMenu[99][1] = "Zoo";
	}
   var rtnStr = "";
   var i=0;
   for (i=0; i<=99;i++)
   {
    rtnStr += "<option value=";
    rtnStr += propertyMenu[i][0];
    if (selection == propertyMenu[i][0])
    {
        rtnStr += " selected";
    }
    rtnStr += ">";
    rtnStr += propertyMenu[i][1];
    rtnStr += "</option>";
   }
   return rtnStr;
}

