<!--

	var directions, directions_panel, from_table, directions_table, current_spot;
	var map_size, current_spot, arr_spots;
	var this_spot = -1;

	function add_guide_comments()
	{
		section           = 'addGuideCom';
		results_element   = document.getElementById('guide-com-res');
		ajax_page         = 'http://www.plane-mad.com/ajax-edit-guide.php';
		var guide         = document.getElementById('guide').value;
		var com_name      = document.getElementById('com-name').value;
		var country       = document.getElementById('com-country').options[document.getElementById('com-country').selectedIndex].value;
		var question      = document.getElementById('com-question').options[document.getElementById('com-question').selectedIndex].value;
		var comments      = document.getElementById('com-comments').value;
		submit_string     = 'request=add-comment&guide='+guide+'&com-name='+escape(com_name)+'&com-country-id='+escape(country)+'&com-question='+question+'&com-comments='+escape(comments);
		wait_element      = document.getElementById('guide-com-res').innerHTML;
		wait_element      = html_wait('Please Wait - Loading');
		get_page(ajax_page, submit_string);
	}

	function check_printer_version()
	{
		var direction_ticked = false;
		
		for (var i=0; i < arr_lat.length; i++)
		{
			var j = i + 1;
			if ((document.getElementById('spot-directions-' + j)) && (document.getElementById('spot-directions-' + j).checked))
				direction_ticked = true;
		}
		
		if (direction_ticked)
		{
			if (document.getElementById('directions-address').value == '')
			{
				alert('Please enter a place to get directions from or remove the directions from your print option');
				return false;
			}
		}
		
		return true;
	}

	function directions_success()
	{
		if (from_table)
		{
			var address = from_table.value;
			m_html  = '<img src="http://www.plane-mad.com/pictures/print.png" alt="Print" /> - <a href="http://www.plane-mad.com/guides.php?guide=' + guide + '&amp;spot-directions[]=' + current_spot + '&amp;directions-from=' + address + '&amp;version=printer" target="_blank">Guide Plus Directions</a>';
			m_html += ' | <a href="http://www.plane-mad.com/guides.php?guide=' + guide + '&amp;spot-directions[]=' + current_spot + '&amp;directions-from=' + address + '&amp;version=printer&amp;show-guide=no" target="_blank">Just Directions</a>';
			directions_table.innerHTML   = m_html;
			directions_table.className = 'bold right';
		}
	}

	function handle_errors()
	{
		if (directions.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
			directions_table.innerHTML += '<p class="bold red">No corresponding location could be found for the specified address. This may be due to the fact that the address is relatively new, or it may be incorrect.<br />Try entering a more vague address, such as using the name of your local village or town.</p>';
		else if (directions.getStatus().code == G_GEO_SERVER_ERROR)
			directions_table.innerHTML += '<p class="bold red">A directions request could not be successfully processed, the exact reason for the failure is not known, please try again.</p>'; 
		else if (directions.getStatus().code == G_GEO_MISSING_QUERY)
			directions_table.innerHTML += '<p class="bold red">The HTTP query parameter was either missing or had no value. Tthis means that no address was specified in the input.</p>';
		else if (directions.getStatus().code == G_GEO_BAD_KEY)
			directions_table.innerHTML += '<p class="bold red">The given key is either invalid or does not match the domain for which it was given.</p>';
		else if (directions.getStatus().code == G_GEO_BAD_REQUEST)
			directions_table.innerHTML += '<p class="bold red">A directions request could not be successfully parsed.</p>';
		else
	   		directions_table.innerHTML += '<p class="bold red">An unknown error occurred.</p>';
	   	
	   	map_tag.style.height  = '0';
	   	map_tag.style.display = 'none';
	   	
	   	map_error = true;
	   	
	   	if (this_spot >= 0)
	   		print_guide();
	 }

	function initialise_directions(p_arr_spots)
	{
		this_spot = 0;
		arr_spots = p_arr_spots;
		//alert(arr_spots + '\n' + arr_spots.length);
		load_next_spot();
	}
	
	function load_next_spot()
	{
		if (this_spot < 0)
			return;
			
		if (this_spot < arr_spots.length)
		{
			show_directions(arr_spots[this_spot]);
			var loading_html =  '<p class="loading-message">Please wait - Currently loading directions to spot ' + arr_spots[this_spot];
			loading_html    += '<br />The guide will print automatically when loading has completed.</p>';
			document.getElementById('loading-message').innerHTML = loading_html;
			this_spot++;
		}
		else
		{
			var t = setTimeout('print_guide()', 1000);
			//close();
		}
	}
	
	function print_guide()
	{
		if (map_error)
		{
			alert('There was an error getting directions to your photo spots.\n\nThis is most likely because you entered an incorrect address to fetch directions from. Please check the address or try entering a more vague departure point such as your local village or town.');
		}
		else
		{
			document.getElementById('loading-message').innerHTML = '';
			window.print();
		}
	}

	function select_all_spots()
	{
		for (var i=0; i < arr_lat.length; i++)
		{
			var j = i + 1;
			if (document.getElementById('spot-directions-' + j))
				document.getElementById('spot-directions-' + j).checked = true;
		}
	}

	function show_direction_form(p_spot)
	{
		if (!dir_visible[p_spot])
		{
			document.getElementById('directions-' + p_spot).className = '';
			
			if (document.getElementById('directions-map-' + p_spot))
				document.getElementById('directions-map-' + p_spot).style.display = 'block';
				
			if (document.getElementById('direction-results-' + p_spot))
				document.getElementById('direction-results-' + p_spot).style.display = 'block';
			
			document.getElementById('get-dir-' + p_spot).innerHTML = 'Hide Directions';
			
			dir_visible[p_spot] = true;
		}
		else
		{
			document.getElementById('directions-' + p_spot).className = 'invisible';
			
			if (document.getElementById('directions-map-' + p_spot))
				document.getElementById('directions-map-' + p_spot).style.display = 'none';
				
			if (document.getElementById('direction-results-' + p_spot))
				document.getElementById('direction-results-' + p_spot).style.display = 'none';
				
			document.getElementById('get-dir-' + p_spot).innerHTML = 'Show Directions';
				
			dir_visible[p_spot] = false;
		}
	}
	
	function show_directions(p_spot)
	{
		current_spot = p_spot;
		map_size = new GSize(979, 400);
		var m_from, m_lang;
		
		if (document.getElementById('from-' + current_spot))
		{
			from_table = document.getElementById('from-' + current_spot);
			m_from     = document.getElementById('from-' + current_spot).value;
			default_from_address = m_from;
			directions_table     = document.getElementById('directions-table-' + current_spot);
		}
		else
		{
			from_table        = '';
			m_from            = default_from_address;
			directions_table  = document.getElementById('direction-results-' + current_spot);
		}
		
		if (document.getElementById('language-' + current_spot))
		{
			m_lang = document.getElementById('language-' + current_spot).options[document.getElementById('language-' + current_spot).selectedIndex].value;
			default_lang = m_lang;
		}
		else
			m_lang = default_lang;
		
		var arr_id = current_spot - 1;
		
		if (m_from == '')
		{
			alert('Please enter a place to get directions from');
			return false;
		}
		
		map_tag = document.getElementById('directions-map-' + current_spot);
		map_tag.style.height  = '400px';
	   	map_tag.style.display = 'block';
		var directions_map  = new GMap2(map_tag);
		directions_map.size = map_size;
		directions_map.addControl(new GSmallMapControl());
		directions_map.addControl(new GMapTypeControl());
		GEvent.addListener(directions_map, 'load', load_next_spot);

		directions_panel = document.getElementById('direction-results-' + current_spot);
		directions       = new GDirections(directions_map, directions_panel);
		GEvent.addListener(directions, "error", handle_errors);
		GEvent.addListener(directions, "load", directions_success);

		var lat              = arr_lat[arr_id];
		var lng              = arr_lng[arr_id];
		var load_text        = 'from: ' + m_from + ' to: ' + lat + ', ' + lng;
		
		directions.load(load_text, { "locale": m_lang });
		return false;
	}
	
	function show_print_options()
	{
		document.getElementById('print-options').className  = '';
		document.getElementById('directions-address').value = default_from_address;
	}

-->
