function submission_type(type)
{
	if(type == 'word')
	{
		document.getElementById('submit_quote').style.display = 'none';
		document.getElementById('submit_word').style.display = 'inline';
	}
	else
	{
		document.getElementById('submit_quote').style.display = 'inline';
		document.getElementById('submit_word').style.display = 'none';
	}
}

function round_precision(n,p)
{
	return (Math.round(n*Math.pow(10,p))/Math.pow(10,p))
}

/*Google map*/
window.map_display = null;
var marker = null

function break_coords(coords)
{
	if(coords.charAt(0) == '(') coords = coords.substring(1,(coords.length-1));
	var p = (coords.indexOf(',')*1);
	var x = round_precision((coords.substring(0,p)*1),4);
	var y = round_precision((coords.substring(p+1)*1),4);
	return [x,y];
}

function zoom(coords)
{
	var c = break_coords(coords);
	map_display.setCenter(new GLatLng(c[0],c[1]),3);
}
function create_marker(coords,colour,info)
{
	var marker_icon = new GIcon();
	marker_icon.image = ('images/map_marker_'+colour+'.png');
	marker_icon.shadow = 'images/map_marker_shadow.png';
	marker_icon.iconSize = new GSize(12, 20);
	marker_icon.shadowSize = new GSize(22, 20);
	marker_icon.iconAnchor = new GPoint(6, 20);
	marker_icon.infoWindowAnchor = new GPoint(5, 1);
	var c = break_coords(coords);
	var new_marker = new GMarker(new GLatLng(c[0],c[1]),marker_icon);
	return new_marker;
}

function load_map(coords)
{
	if(GBrowserIsCompatible())
	{
		map_display = new GMap2(document.getElementById('map'));
		map_display.addControl(new GLargeMapControl());
		map_display.addControl(new GScaleControl());
		map_display.addControl(new GMapTypeControl());
		map_display.setCenter(new GLatLng(0,0),1);
		if(coords)
		{
			GEvent.addListener(map_display,'click',
			function (m, p)
			{
				if(marker)
				{
					map_display.removeOverlay(marker);
					marker = null;
					document.getElementById('coords').value = '';
				}
				if(p)
				{
					marker = create_marker(p.toString(),'red','');
					map_display.addOverlay(marker);
					var c = break_coords(p.toString());
					document.getElementById('coords').value = (''+c[0]+','+c[1]);
				}
			});
			marker = create_marker(coords,'red','');
			map_display.addOverlay(marker);
			document.getElementById('coords').value = coords;
		}
	}
}