// JavaScript Document

function position_locations() {
	if ($('locationContainer')) {
			var pos 	= YAHOO.util.Dom.getXY('contactMenu');

			//set cart position
			$('locationContainer').style.left = (pos[0]+1)+"px";
			$('locationContainer').style.top = (pos[1]+27)+"px";

	}
}

function position_conditions() {
	if ($('conditionsContainer')) {
			var pos 	= YAHOO.util.Dom.getXY('conditionsMenu');
			
			//set position
			$('conditionsContainer').style.left = (pos[0]+1)+"px";
			$('conditionsContainer').style.top = (pos[1]+20)+"px";

	}
}

	
function close_menu(menuName) {
	new Effect.toggle(menuName, 'blind');
}

function select_location(num) {
	var city = $('city').innerHTML;
	var phone = $('phone').innerHTML;
	
	$('city').innerHTML = $('city' + num).innerHTML;
	$('phone').innerHTML = $('phone' + num).innerHTML;
	
	close_menu('locationContainer');
}

function loadBio(dr_name) {
	new Ajax.Updater(
		{
			success:'col1Content',
			failure:'alert(&quot;An error occurred while loading the requested information&quot;)'
		},

		'doctors/' + dr_name + '.html',

		{
			asynchronous:true, evalScripts:true, method:'get',
			onComplete:function(request){ new Effect.Highlight('col1Content', {duration: 3.0})}
		}
	);
}

function loadCondition(condition) {
	new Ajax.Updater(
		{
			success:'col1Content',
			failure:'alert(&quot;An error occurred while loading the requested information&quot;)'
		},

		'glossary/' + condition + '.html',

		{
			asynchronous:true, evalScripts:true, method:'get',
			onComplete:function(request){ new Effect.Highlight('col1Content', {duration: 3.0})}
		}
	);
	
	if ($('conditionsContainer')) {
		close_menu('conditionsContainer');
	}
}

function loadTreatment(treatment) {
	new Ajax.Updater(
		{
			success:'col1Content',
			failure:'alert(&quot;An error occurred while loading the requested information&quot;)'
		},

		treatment + '.html',

		{
			asynchronous:true, evalScripts:true, method:'get',
			onComplete:function(request){ new Effect.Highlight('col1Content', {duration: 3.0})}
		}
	);
}

//This script allows the primary nav CSS dropdown menu to work in IE
//requires prototype
function startList () {
	if (document.all && document.getElementById) {
			navRoot = $("conditionsNav");
			for (i=0; i<navRoot.childNodes.length; i++) {
				node = navRoot.childNodes[i];
				if (node.nodeName=="LI") {
					node.onmouseover=function() {
						this.className+=" over";
				}
				node.onmouseout=function() {
					this.className=this.className.replace
					(" over", "");
				}
			}
		}
	}
}

// Google maps API code
//<![CDATA[

    var map = null;
    var geocoder = null;

    function load() {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("map"));
				map.addControl(new GSmallMapControl());
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
        geocoder = new GClientGeocoder();
      }
    }

    function showAddress(address) {
      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);
              marker.openInfoWindowHtml(address);
            }
          }
        );
      }
    }
    //]]>
