function setFocus()
{
	document.f.q.focus()
}

function submitSearch(src, tgt, def)
{
	if (src.q.value != '')
	{
		tgt.q.value = src.q.value;
		tgt.submit();
	}
	else
	{
		window.location = def;
	}
}

function hideDiv(id)
{
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showDiv(id)
{
	//safe function to show an element with a specified id

	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

function switchDiv(id)
{
	//safe function to switch an element with a specified id on or off

	if (document.getElementById) // DOM3 = IE5, NS6
    { 
		if (document.getElementById(id).style.display == 'block')
            document.getElementById(id).style.display = 'none';
        else
            document.getElementById(id).style.display = 'block';
	}
	else
    {
		if (document.layers) // Netscape 4
        { 
			if (document.id.display == 'block')
                document.id.display == 'none';
            else
                document.id.display == 'block';
		}
		else // IE 4
        {
            if (document.all.id.style.display = 'block')
                document.all.id.style.display = 'none';
            else
                document.all.id.style.display = 'block';
		}
	}
}

function updateSelectedOption(id, typeCount)
{
    for (i = 1; i <= typeCount; i++)
    {
        tmp_id = 'divtype_' + i;
        if (document.getElementById)
            document.getElementById(tmp_id).style.display = 'none';
    	else
        {
    		if (document.layers) // Netscape 4
                document.tmp_id.display = 'none';
    		else // IE 4
                document.all.tmp_id.style.display = 'none';
        }
    }
    
    showDiv(id);
}

function updateInputValue(id, newValue)
{
    if (document.getElementById)
        document.getElementById(id).value = newValue;
	else
    {
		if (document.layers) // Netscape 4
            document.id.value = newValue;
		else // IE 4
            document.all.id.value = newValue;
    }
}

function popUp(URL, width, height, name)
{
    if (width == undefined) width = 525;
    if (height == undefined) height = 400;
    if (name == undefined)
    {
        day = new Date();
        id = day.getTime();
        name = "page" + id;
    }
    w = window.open(URL, name, "toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height=" + height + ",left = 252,top = 184");
    w.focus();
}

function setFocus(a_field_id) 
{
	document.getElementById(a_field_id).focus();
}


/*****************************************************
 Google Maps stuff
******************************************************/

// Creates a marker at the given point with the given number label
function createMarker(point, tooltip)
{
	var marker = new GMarker(point,
		{
			title: tooltip
		});
	GEvent.addListener(marker, "click");
	return marker;
}

function GMapLoad(mapName, lat, lng, zoom)
{
	if (GBrowserIsCompatible())
	{
		var map = new GMap2(document.getElementById(mapName), {draggableCursor: "default"});
		/*  Add the zooming and pan control*/
		map.addControl(new GLargeMapControl());
		/*  Add the satellite control*/
		map.addControl(new GMapTypeControl());
	   /*  Centre the map on the shop*/
		map.setCenter(new GLatLng(lat, lng), zoom);
		/* Allow zooming on double-click*/
		map.enableDoubleClickZoom();
		/* Smooth zooming */
		map.enableContinuousZoom();

		var point = new GLatLng(lat, lng);
		var tooltip = "Revel Outdoors";
		map.addOverlay(createMarker(point, tooltip));
	}
}

