/*
*
*	Javascript for Nachtwinkelingent.be
*
*	Written by Ad Eggermont (adeggermont@gmail.com)
*	
*/


/*!
 * $.preload() function for jQuery
 * Preload images, CSS and JavaScript files without executing them
 * Script by Stoyan Stefanov – http://www.phpied.com/preload-cssjavascript-without-execution/
 * Slightly rewritten by Mathias Bynens – http://mathiasbynens.be/
 * Demo: http://mathiasbynens.be/demo/javascript-preload
 * Note that since this script relies on jQuery, the preloading process will not start until jQuery has finished loading.
 */

$.extend({
 preload: function(arr) {
  var i = arr.length,
      o;
  while (i--) {
   if ($.browser.msie) {
    new Image().src = arr[i];
    continue;
   };
   o = document.createElement('object');
   o.data = arr[i];
   o.width = o.height = 0;
   document.body.appendChild(o);
  };
 }
});


$(document).ready(function() {
	//Images preloaden
	$.preload([
		'/_img/bubble_big.png',
		'/_img/bubble_small.png'
	]);
	
	// Met vertrekpunt
	$('#nav li#met_vertreklocatie a').mouseenter(function() {
		$('#bubbles').append('<div id="bubble1">Hier kunt u uw huidige locatie ingeven en wordt de route naar de dichtsbijzijnde nachtwinkel berekend</div>');
		$('#bubble1').animate({ opacity: '1', top: '0'}, 400);
	});
	
	$('#nav li#met_vertreklocatie a').mouseleave(function() {
		$('#bubble1').animate({ opacity: '0', top: '15px'}, {duration: 200, complete: function() { $('#bubble1').remove(); }});
	});
	
	
	// Zonder vertrekpunt
	$('#nav li#zonder_vertreklocatie a').mouseenter(function() {
		$('#bubbles').append('<div id="bubble2">Hier kunt u de prijzen van de verschillende nachtwinkels vergelijken</div>');
		$('#bubble2').animate({ opacity: '1', top: '0'}, 400);
	});
	
	$('#nav li#zonder_vertreklocatie a').mouseleave(function() {
		$('#bubble2').animate({ opacity: '0', top: '15px'}, {duration: 200, complete: function() { $('#bubble2').remove(); }});
	});
	
	
	// Overzicht
	$('#nav li#overzicht a').mouseenter(function() {
		$('#bubbles').append('<div id="bubble3">Hier vindt u een overzicht van alle nachtwinkels</div>');
		$('#bubble3').animate({ opacity: '1', top: '0'}, 400);
	});
	
	$('#nav li#overzicht a').mouseleave(function() {
		$('#bubble3').animate({ opacity: '0', top: '15px'}, {duration: 200, complete: function() { $('#bubble3').remove(); }});
	});
});


