/**                  
 * dereehorst.js
 *
 * @version 1.0
 * @package dereehorst.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:
 ----------------------------------------------------------*/
/**
 * GOOGLE MAPS:
 ----------------------------------------------------------*/
var map;
var geocoder = null;
var addressMarker;

function load() {
	if(GBrowserIsCompatible()) {      
		map = new GMap2(document.getElementById("map"));
		map.setMapType(G_SATELLITE_MAP);
	
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
	
		gdir = new GDirections(map, document.getElementById("directions"));
		GEvent.addListener(gdir, "load", onGDirectionsLoad);
		GEvent.addListener(gdir, "error", handleErrors);
		setDirections('52.115506,6.33615', '52.115506,6.33615', 'nl');
		//setDirections('SEnzerinckweg 12, VORDEN', 'Enzerinckweg 12, VORDEN', "nl");

		
	}
}

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(/dereehorst\.js(\?.*)?$/) ) {
			var path = scripts[i].src.replace(/dereehorst\.js(\?.*)?$/, '');
			for( var x = 0, len = required.length; x < len; x++ ) {
				document.write('<script type="text/javascript" src="' + (path + required[x]) + '"></script>');
			}
		}
	}
}


/*
jQuery(function( $ ){

	/**
	 * Most jQuery.localScroll's settings, actually belong to jQuery.ScrollTo, check it's demo for an example of each option.
	 * @see http://flesler.demos.com/jquery/scrollTo/
	 * You can use EVERY single setting of jQuery.ScrollTo, in the settings hash you send to jQuery.LocalScroll.
	 
	
	/**
	 * Restart the scroll position to ( 0, 0 ) (Firefox doesn't reset it)
	 * could use $(target).scrollTo( 0, {axis:'xy'));
	 * but this needs to be quick(synchronous), to reset before $.localScroll.hash() begins
	 
	$('#maincontent').attr({scrollTop:0,scrollLeft:0});
	
	// Scroll initially if there's a hash (#something) in the url 
	$.localScroll.hash({
		target: '#maincontent', //could be a selector or a jQuery object too.
		axis:'xy',//the default is 'y'
		queue:true,
		duration:1500
	});
	
	var $last = $([]);//save the last link
	
	/**
	 * NOTE: I use $.localScroll instead of $('#navigation').localScroll() so I
	 * also affect the >> and << links. I want every link in the page to scroll.
	 
	$.localScroll({
		target: '#maincontent', //could be a selector or a jQuery object too.
		axis:'xy', //the default is 'y'
		queue:true,
		duration:1000,
		hash:true,
		onBefore:function( e, anchor, $target ){//'this' is the clicked link
			$last.removeClass('scrolling');
			$last = $(this).addClass('scrolling');
			if( this.blur )
				this.blur();//remove the awful outline
		},
		onAfter:function( anchor ){
			$last.removeClass('scrolling');
		}
	});
});
*/

//]]>
