// JavaScript Document

function removeNode(n)
{
    if(n.hasChildNodes())
    {
        for(var i=0;i<n.childNodes.length;i++)
        {
            n.parentNode.insertBefore(n.childNodes[i].cloneNode(true),n);
        }
    }
    n.parentNode.removeChild(n);
}

function domFunction(f, a)
{
	var n = 0;
	var t = setInterval(function()
	{
		var c = true;
		n++;
		if(typeof document.getElementsByTagName != 'undefined' && (document.getElementsByTagName('body')[0] != null || document.body != null))
		{
			c = false;

			if(typeof a == 'object')
			{
				for(var i in a)
				{
					if ( (a[i] == 'id' && document.getElementById(i) == null) || (a[i] == 'tag' && document.getElementsByTagName(i).length < 1)	) 
					{ 
						c = true; 
						break; 
					}
				}
			}
			if(!c) { f(); clearInterval(t); }
		}
		if(n >= 60)
		{
			//clear the timer
			clearInterval(t);
		}
		
	}, 250);
}

function clearNavLink()
{
	if (document.getElementById("nav"))
	{	
		var a = document.getElementById("nav").getElementsByTagName("A");
		var b = document.getElementsByTagName("body");
    	for(var i=0;i<a.length;i++)
    	{
       		if(a[i].href.split("#")[0] == window.location.href.split("#")[0])
       		{
				a[i].firstChild.style.backgroundColor = "white";
				a[i].firstChild.className = 'font_color' + i;
				b[0].className = 'home_color' + i;
				removeNode(a[i]);
       		}    
		}
	}
}


    var map = null;
    var geocoder = null;

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
        map.setCenter(new GLatLng(34.024206, -84.252302), 13);
        geocoder = new GClientGeocoder();
      }
    }

    function showAddress() {
	  if (geocoder) {
        geocoder.getLatLng(
          address,
          function(point) {
            if (!point) {
              alert(address + " not found");
            } else {
              map.setCenter(point, 13);
              var marker = new GMarker(point);
              map.addOverlay(marker);
			  var display = "<p><span class='page_header'>SoHo Salon</span><br />9950 Jones Bridge Rd.<br />Suite 1000<br />John's Creek, GA 30022<br />678.356.4343 </p>";  
              marker.openInfoWindowHtml(display);
            }
          }
        );
      }
    }
	
var navInit = new domFunction(clearNavLink);
var mapAddress = new domFunction (showAddress);