/**                  
 * lindenhof.js
 *
 * @version 1.0
 * @package lindenhof.nl
 * @author  a.j.de vries
 *
 * Copyright (c) Malibomba                               
 * IT IS NOT ALLOWED TO USE OR MODIFY ANYTHING OF 
 * THIS CODE, WITHOUT THE PERMISION OF THE AUTHOR.                       
 * Info? Mail to info@malibomba.com                             
 */
//<![CDATA[

/**
 * GOOGLE MAPS:
 --------------------------------------------------------------------------------------------------*/
var map;
var geocoder = null;
var addressMarker;

function load() {
	if(GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));

		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng(52.115506,6.33615), 16);
		gdir = new GDirections(map, document.getElementById("directions"));
		GEvent.addListener(gdir, "load", onGDirectionsLoad);
		GEvent.addListener(gdir, "error", handleErrors);
		//setDirections('52.297529102002024,6.199057102203369', '52.297529102002024,6.199057102203369', 'nl');
		//setDirections('Harselaarseweg 49-51, 3771 MA Barneveld', 'Harselaarseweg 49-51, 3771 MA Barneveld', "nl");
		map.setMapType(G_SATELLITE_MAP);


		function createMarker(point) {
				var marker = new GMarker(point);
				GEvent.addListener(marker, "click", function() {
				marker.openInfoWindowHtml("<b>Chaletpark Lindenhof</b><br/> Wolfhezerweg 111/113<br/>6874 AD Wolfheze<br/>(Gem. Renkum)");
				});
				return marker;
			  }

				var point = new GLatLng(52.115506,6.33615);
				var marker = createMarker(point);
				map.addOverlay(marker);


			}
		}

function setDirections(fromAddress, toAddress, locale) {
	gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale });
}

function handleErrors(){
	if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		alert("Er is geen adres gevonden. Dit kan zijn dat het adres nog relatief nieuw is en nog niet is opgenomen in de databases. \n Probeer het opnieuw door alleen uw postode in te voeren.\nError code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
		alert("A geocoding or directions request could not be successfully processed, yet the exact reason for the failure is not known.\n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
		alert("The HTTP q parameter was either missing or had no value. For geocoder requests, this means that an empty address was specified as input. For directions requests, this means that no query was specified in the input.\n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_BAD_KEY)
		alert("The given key is either invalid or does not match the domain for which it was given. \n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
		alert("A directions request could not be successfully parsed.\n Error code: " + gdir.getStatus().code);
	else alert("An unknown error occurred.");
}

function onGDirectionsLoad(){ }





/**
 * ADD REQUIRED SCRIPTS:
 ----------------------------------------------------------*/

var required = [
	'jquery.marquee.js',
	'sifr.js', 
	'sifr-debug.js',
	'sifr-config.js',
	'fv_dutch.js',
	'fv_engine.js'

];

if( (scripts = document.getElementsByTagName('script')) !== null ) {
	for( var i = 0, len = scripts.length; i < len; i++ ) {
		if( scripts[i] && scripts[i].src.match(/lindenhof\.js(\?.*)?$/) ) {
			var path = scripts[i].src.replace(/lindenhof\.js(\?.*)?$/, '');
			for( var x = 0, len = required.length; x < len; x++ ) {
				document.write('<script type="text/javascript" src="' + (path + required[x]) + '"></script>');
			}
		}
	}
}



//]]>

