
var activeTab = false;
var sliding = false;
var geocoder = null;

document.observe('dom:loaded', tab_init);
//document.observe('dom:loaded', map);
//document.observe('unload', GUnload);

/*
function map ()
{
	if (GBrowserIsCompatible())
	{	
		geocoder = new GClientGeocoder();
		address = 'DY8 1JN';
		geocoder.getLatLng (
			address,
			function (point)
			{
				if (point)
				{
					var m = new GMap2($('map'));
					m.addControl(new GLargeMapControl());
					m.setCenter(point, 13);
					var marker = new GMarker(point);
					m.addOverlay(marker);
					//m.openInfoWindowHtml(address);
				}
			}
		);
	}
}
*/

function tab_init ()
{
	var tabs = $w('about features reviews findus offers');
	var pic = Array();
	tabs.each(function (tabname) 
	{
		var tab = $(tabname + 'tab');
		var actTab = /2.gif$/;
		var disTab = /0.gif$/;
		if (actTab.exec(tab.src))
			activeTab = tabname;
		if (! disTab.exec(tab.src))
		{
			tab.observe('click', tab_swap);
		}
	});
}

function tab_swap (e)
{
	if (sliding)
	{
		return false;
	}
	else
	{
		sliding = true;
	}
	var newTab = e.element().id;
	var newBox = newTab.substring(0, newTab.length-3);
	var imgDir = '/images/listing/';
	$(activeTab + 'box').visualEffect('BlindUp', {afterFinish: function ()
	{
		$(activeTab + 'tab').src = imgDir + activeTab + '1.gif';
		$(newBox + 'tab').src = imgDir + newBox + '2.gif';
		$(newBox + 'box').visualEffect('BlindDown');
		activeTab = newBox;
		sliding = false;
	}});
}
