var active_feature = 'product';
function featured_toggle(toShow, toHide)
{
	if(toShow != active_feature)
	{
		// Swap containers
		$('featured-'+toHide+'-cont').hide();
		$('featured-'+toShow+'-cont').show();
		
		// Change background images on links
		if($('featured-'+toShow+'-link').hasClassName('pos-1') == true)
		{
			class_to_add = 'pos-2';
			class_to_remove = 'pos-1';
		}
		else
		{
			class_to_add = 'pos-1';
			class_to_remove = 'pos-2';
		}
		$('featured-'+toHide+'-link').removeClassName(class_to_remove);
		$('featured-'+toHide+'-link').addClassName(class_to_add);
		
		$('featured-'+toShow+'-link').removeClassName(class_to_remove);
		$('featured-'+toShow+'-link').addClassName(class_to_add);
		
		// Set active
		active_feature = toShow;
	}
}

function toggle_internal_feature(id)
{
	$('featured-'+id+'-internal-content').show();
}

function top_nav_swap(nav_id)
{
	if(nav_id != top_nav_active)
	{
		$('top-nav-image').src = '../images/top-nav-'+nav_id+'.gif';
		top_nav_active = nav_id;
	}
}

// google maps
var geocoder;
var map;
var dirObj;

function requestdirections2(mapobj,toaddr,fromaddr)
{
	if(typeof(dirObj) != 'undefined')
	{
		dirObj.clear();
	}
	mapobj.clearOverlays();
	$('directions').innerHTML = "";
	dirObj = new GDirections(mapobj,document.getElementById("directions"));
	dirObj.load('from:'+fromaddr+' to: '+toaddr);
	return false;
}

function showAddress(address) {
	map = new GMap2(document.getElementById("map"));
	geocoder = new GClientGeocoder();
	
	geocoder.getLatLng(
		address,
		function(point) {
			if (!point) {
				alert(address + " not found");
			} else {
				map.addControl(new GSmallMapControl());
				map.setCenter(point, 14);
				var marker = new GMarker(point);
				map.addOverlay(marker);
				marker.openInfoWindowHtml("217 Haverford Ave.<br />Narberth PA, 19072<br />610-667-3663");
			}
		}
	);
}

function loadMap()
{
	if (GBrowserIsCompatible())
	{
		showAddress("217 Haverford Ave Narberth PA 19072");
	}
}
