<!--

function modifySiteInformation (theMarker) {
		var theForm=document.forms["Site Information"];
		var theSite=theMarker.Site
			theSite.Name=theForm.elements["Name"].value;
			theSite.Address1=theForm.elements["Address1"].value;
			theSite.Address2=theForm.elements["Address2"].value
			theSite.City=theForm.elements["City"].value
			theSite.County=theForm.elements["County"].value
			theSite.State=theForm.elements["State"].value
			theSite.Zip=theForm.elements["Zip"].value
			theSite.Organization=theForm.elements["OrgType"].value
		};
	
function modifySiteInfo(){modifySiteInformation(theCurrentMarker)}
	
function updateSiteInformation (theMarker) {
		var theForm=document.forms["Site Information"];
		var theSite=theMarker.Site
			theForm.elements["Name"].value=theSite.Name;
			theForm.elements["Address1"].value=theSite.Address1;
			theForm.elements["Address2"].value=theSite.Address2;
			theForm.elements["City"].value=theSite.City;
			theForm.elements["County"].value=theSite.County;
			theForm.elements["State"].value=theSite.State;
			theForm.elements["Zip"].value=theSite.Zip;
			theForm.elements["OrgType"].value=theSite.Organization;
		
		};
		
function updateMarkerInformation (theMarker){
		var theForm=document.forms["Site Information"];
			theForm.elements["lat_mrkr"].value=theMarker.getPoint ().lat ().toFixed (6);
			theForm.elements["lng_mrkr"].value=theMarker.getPoint ().lng ().toFixed (6);};

function updateViewPortInformation (theMarker){
		var theForm=document.forms["Site Information"];
			theForm.elements["lat_c"].value =theMap.getCenter().lat ().toFixed(6);
			theForm.elements["lng_c"].value =theMap.getCenter().lng ().toFixed(6);
			theForm.elements["lat_sw"].value=theMap.getBounds().getSouthWest().lat().toFixed(6);
			theForm.elements["lng_sw"].value=theMap.getBounds().getSouthWest().lng().toFixed(6);
			theForm.elements["lat_ne"].value=theMap.getBounds().getNorthEast().lat().toFixed(6);
			theForm.elements["lng_ne"].value=theMap.getBounds().getNorthEast().lng().toFixed(6);
			theForm.elements["Zoom"].value  =theMap.getZoom().toString();};


function updateFormInformation (theMarker)	{ 
//		updateViewPortInformation(theMarker);
//		updateSiteInformation(theMarker); 
//		updateMarkerInformation(theMarker);
	}

function newsite(Name,point)
	{var temp = new site("",Name,"","","","","","",point.lat().toFixed(6), point.lng().toFixed(6),"");
	return temp}

		
function setActiveMarker(theMarker)
		{ if (theMarker == null) 
			{setMarkerInactive (theCurrentMarker);
			 theCurrentMarker = null}
			else {if (theCurrentMarker != theMarker)
					 {setMarkerInactive (theCurrentMarker);
					  setMarkerActive   (theMarker)
					  theCurrentMarker = theMarker
					   }
				 };
		};
	
function setMarkerActive   (theMarker)
	{theMarker.visited = true; 
			 theMarker.BGColor = "turquoise";
			 theMarker.FGColor = "gray";
			 theMarker.setImage(greeniconimage);
			 theMarker.enableDragging();
			};
			
function setMarkerInactive (theMarker)
	 {if (theMarker != null) {theMarker.disableDragging();
	  			theMarker.setImage((theMarker.visited==true) ? turquoiseiconimage:rediconimage);}
	  };
       
function newDraggableMarker (name,point)
		{	var theIcon       = new GIcon(baseIcon);
 	      	theIcon.image = G_DEFAULT_ICON.image;
       		var theMarkerOptions	= {title: name, draggable: true, icon:theIcon};
        	var theMarker			= new GMarker (point, theMarkerOptions);
			theMap.addOverlay (theMarker);
			theMarker.disableDragging();
			return theMarker;
		};

function makeNewMarker ()	{
  		var theMarker		= newDraggableMarker("Unnamed Point",theMap.getCenter());
		setCurrentMarker(theMarker);
		theMarker.enableDragging();
		GEvent.addListener(theMarker, "click", function() {
			setCurrentMarker(theMarker);
			updateFormInformation (theMarker);
			displayLatLong(theMarker);  });
		GEvent.addListener(theMarker, "dragend", function() {
			updateFormInformation (theMarker);
			displayLatLong(theMarker);  });
		GEvent.addListener(theMarker, "dblclick", function() {
			updateFormInformation (theMarker);
			displayLatLong(theMarker);  });
  	  }
  	  
function makeNewDraggableMarker (theSite,index)	{
	   	   	var theMarker			= newDraggableMarker(theSite.Name, theSite.Location());
			theMarker.Site      	= theSite
			theSite.Marker			= theMarker
			theMarker.ix			= index
							
		var tabs=[];
		
		function updatetabs()
			{
			tabs[0]=new GInfoWindowTab("Site",'<div style="width:'+3*100+'px">' 
				+ theSite.NameAddressFoto_HTML() + '</div>');
			switch (theSite.SiteType)
			 {case 'ServiceType':
			 	tabs[1]=new GInfoWindowTab("Times",theSite.DateTimesHTML);	
				tabs[2]=new GInfoWindowTab("Notes",theSite.OtherInfo);
				break;
			  case 'UserDefined':
			    tabs[1]=new GInfoWindowTab("LatLong",theMarker.getPoint ().toUrlValue(6));
			    break;
			  default:
			  }
			  }

	    updatetabs();
	    		      	
		theMarker.visited = false;
		theMarker.setImage(rediconimage);
		theMarker.BGColor = "white";
		theMarker.FGColor = "black";
		theMarker.HighLightColor = "yellow";


        // save the info we need to use later for the side_bar
        gmarkers[index] = theMarker;
        // add a line to the side_bar html
		side_bar_html += '<span class="sidebar" onclick="myclick(' + index + ')" onmouseover="mymouseover(' + index + ')" onmouseout="mymouseout(' + index + ')">' + theSite.Name + '</span><br>';
			
		document.getElementById("sidebar").innerHTML = side_bar_html;
		
		function displayLatLong (theMarker){theMarker.openInfoWindowHtml(theMarker.getPoint().toUrlValue(6))};

		function displayInfoWindowTabs() {theMarker.openInfoWindowTabs(tabs)};
		
		function updateLatLongTab()
			{
			document.getElementById("sidebar").getElementsByTagName("span")[theMarker.ix].innerHTML
								=theMarker.Site.Name;
/*			tabs[0]=new GInfoWindowTab("Site",theMarker.Site.NameAddressFoto_HTML())					//		//		tabs[1]=new GInfoWindowTab("LatLong",theMarker.getPoint ().toUrlValue(6));
			tabs[1]=new GInfoWindowTab("Times",theSite.DateTimesHTML);	
			tabs[2]=new GInfoWindowTab("Notes",theSite.OtherInfo)		
*/			
			updatetabs()
				};
					
	
	GEvent.addListener(theMarker, "click",  
				function() {setActiveMarker(theMarker);
							updateLatLongTab();
							displayInfoWindowTabs()
							updateFormInformation(theMarker);
							});
	GEvent.addListener(theMarker, "dragstart",  function() {setActiveMarker(theMarker)});
	GEvent.addListener(theMarker, "mouseover",  function(){
		document.getElementById("sidebar").getElementsByTagName("span")[index].style.color = 													theMarker.FGColor;
			theMarker.setImage(yellowiconimage);
			document.getElementById("sidebar").getElementsByTagName("span")[index].style.background = 								theMarker.HighLightColor});
	GEvent.addListener(theMarker, "mouseout",  function(){
		document.getElementById("sidebar").getElementsByTagName("span")[index].style.color =											theMarker.FGColor;
			if (theCurrentMarker!=theMarker) {
			theMarker.setImage((theMarker.visited == true)? turquoiseiconimage:rediconimage)}
				else {theMarker.setImage(greeniconimage)};
			document.getElementById("sidebar").getElementsByTagName("span")[index].style.background = 								theMarker.BGColor });
	GEvent.addListener(theMarker, "dragend", function() {
			updateFormInformation(theMarker); 
			updateLatLongTab();
			displayInfoWindowTabs() });
  	GEvent.addListener(theMarker, "dblclick", function() {
			setActiveMarker(theMarker);
			updateFormInformation(theMarker);
			zoomToGeog0(theMarker.getPoint(),theMap.getZoom () +1);
			updateLatLongTab();
			displayInfoWindowTabs();
  		});
    return theMarker
    }
 
 //-->