window.onload = function()
{
	// Preload images
	homeImage = new Image();		homeImage.src = "img/bigIcons/home.jpg";
	campingImage = new Image();		campingImage.src = "img/bigIcons/camping.jpg";
	livingunitsImage = new Image();	campingImage.src = "img/bigIcons/livingunits.jpg";
	bedandbreakfastImage = new Image();	bedandbreakfastImage.src = "img/bigIcons/bedandbreakfast.jpg";
	environmentImage = new Image();	environmentImage.src = "img/bigIcons/environment.jpg";
	pricesImage = new Image();		pricesImage.src = "img/bigIcons/prices.jpg";
	routeImage = new Image();		routeImage.src = "img/bigIcons/route.jpg";
	activitiesImage = new Image();	activitiesImage.src = "img/bigIcons/activities.jpg";
	contactImage = new Image();	contactImage.src = "img/bigIcons/contact.jpg";

	// Get button elements
	var svr = document.getElementById('svr');
	var vvv = document.getElementById('vvv');
	var mestyle = document.getElementById('mestyle');

	if (svr) {
		svr.onclick = function () {
			window.open('http://www.svr.nl/');
			return false;
		};
	}
	if (vvv) {
		vvv.onclick = function () {
			window.open('http://www.vvv.nl/');
			return false;
		};
	}
	if (mestyle) {
		mestyle.onclick = function () {
			window.open('http://www.mestyle.nl/');
			return false;
		};
	}



	// Get menu elements
	var homeActive = document.getElementById('homeActive');
	var home = document.getElementById('home');
	var campingActive = document.getElementById('campingActive');
	var camping = document.getElementById('camping');
	var livingunitsActive = document.getElementById('livingunitsActive');	
	var livingunits = document.getElementById('livingunits');
	var bedandbreakfastActive = document.getElementById('bedandbreakfastActive');		
	var bedandbreakfast = document.getElementById('bedandbreakfast');
	var environmentActive = document.getElementById('environmentActive');
	var environment = document.getElementById('environment');
	var pricesActive = document.getElementById('pricesActive');
	var prices = document.getElementById('prices');
	var routeActive = document.getElementById('routeActive');
	var route = document.getElementById('route');
	var activitiesActive = document.getElementById('activitiesActive');
	var activities = document.getElementById('activities');
	var contactActive = document.getElementById('contactActive');
	var contact = document.getElementById('contact');
	
	// Active page
	var activePage = 'home';

 	if (campingActive)
		activePage = 'camping';
	else if (campingActive)
		activePage = 'camping';
	else if (livingunitsActive)
		activePage = 'livingunits'; 	
	else if (bedandbreakfastActive)
		activePage = 'bedandbreakfast'; 	 	
	else if (environmentActive)
		activePage = 'environment';
	else if (pricesActive)
		activePage = 'prices';
	else if (routeActive)
		activePage = 'route';
	else if (activitiesActive)
		activePage = 'activities';
	else if (contactActive)
		activePage = 'contact';
	else
		activePage = 'home';

	// Hover functions
	if (home) {
		home.onmouseover = function() {
			icon('home');
		};

		home.onmouseout = function() {
			icon(activePage);
		};
	}
	else if (homeActive) {
		homeActive.onmouseover = function() {
			icon('home');
		};

		homeActive.onmouseout = function() {
			icon(activePage);
		};
	}
	// Camping
	if(camping) {
		camping.onmouseover = function() {
			icon('camping');
		};
		camping.onmouseout = function() {
			icon(activePage);
		};
	}
	else if (campingActive) {
		campingActive.onmouseover = function() {
			icon('camping');
		};
		campingActive.onmouseout = function() {
			icon(activePage);
		};
	}
	
	// Living units
	if(livingunits) {
		livingunits.onmouseover = function() {
			icon('livingunits');
		};
		livingunits.onmouseout = function() {
			icon(activePage);
		};
	}
	else if (livingunitsActive) {
		livingunitsActive.onmouseover = function() {
			icon('livingunits');
		};
		livingunitsActive.onmouseout = function() {
			icon(activePage);
		};
	}
	
	// Bed and breakfast
	if(bedandbreakfast) {
		bedandbreakfast.onmouseover = function() {
			icon('bedandbreakfast');
		};
		bedandbreakfast.onmouseout = function() {
			icon(activePage);
		};
	}
	else if (bedandbreakfastActive) {
		bedandbreakfastActive.onmouseover = function() {
			icon('bedandbreakfast');
		};
		bedandbreakfastActive.onmouseout = function() {
			icon(activePage);
		};
	}	
	
	// Environment
	if (environment) {
		environment.onmouseover = function() {
			icon('environment');
		};
		environment.onmouseout = function() {
			icon(activePage);
		};
	}
	else if (environmentActive) {
		environmentActive.onmouseover = function() {
			icon('environment');
		};
		environmentActive.onmouseout = function() {
			icon(activePage);
		};
	}
	// Prices
	if (prices) {
		prices.onmouseover = function() {
			icon('prices');
		};
		prices.onmouseout = function() {
			icon(activePage);
		};
	}
	else if (pricesActive) {
		pricesActive.onmouseover = function() {
			icon('prices');
		};
		pricesActive.onmouseout = function() {
			icon(activePage);
		};
	}
	// Route
	if (route) {
		route.onmouseover = function() {
			icon('route');
		};
		route.onmouseout = function() {
			icon(activePage);
		};
	}
	else if (routeActive) {
		routeActive.onmouseover = function() {
			icon('route');
		};
		routeActive.onmouseout = function() {
			icon(activePage);
		};
	}
	// Activities
	if (activities) {
		activities.onmouseover = function() {
			icon('activities');
		};
		activities.onmouseout = function() {
			icon(activePage);
		};
	}
	else if (activitiesActive) {
		activitiesActive.onmouseover = function() {
			icon('activities');
		};
		activitiesActive.onmouseout = function() {
			icon(activePage);
		};
	}
	// Contact
	if (contact) {
		contact.onmouseover = function() {
			icon('contact');
		};
		contact.onmouseout = function() {
			icon(activePage);
		};
	}
	else if (contactActive) {
		contactActive.onmouseover = function() {
			icon('contact');
		};
		contactActive.onmouseout = function() {
			icon(activePage);
		};
	}


	// Load googlemaps
	var googlemapsDiv = document.getElementById('googlemaps');
	if (googlemapsDiv) {
		googlemapsDiv.innerHTML = '<iframe width="620" height="520" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.nl/maps?f=d&amp;hl=nl&amp;geocode=&amp;saddr=&amp;daddr=52.9149,4.731545&amp;mra=mi&amp;mrsp=0&amp;sz=18&amp;sll=52.915236,4.731218&amp;sspn=0.002378,0.004699&amp;ie=UTF8&amp;s=AARTsJoONbBNLVM1Qvn9y-__mkG-6_mINg&amp;ll=52.905589,4.7612&amp;spn=0.053838,0.10643&amp;z=13&amp;output=embed"></iframe><br /><small><a href="http://maps.google.nl/maps?f=d&amp;hl=nl&amp;geocode=&amp;saddr=&amp;daddr=52.9149,4.731545&amp;mra=mi&amp;mrsp=0&amp;sz=18&amp;sll=52.915236,4.731218&amp;sspn=0.002378,0.004699&amp;ie=UTF8&amp;ll=52.905589,4.7612&amp;spn=0.053838,0.10643&amp;z=13&amp;source=embed" style="color:#0000FF;text-align:left">Grotere kaart weergeven</a></small>';
	}
};


function icon (icon) {	
	var bigIcon = document.getElementById('bigIcon');

	if (icon == 'home')				bigIcon.src = 'img/bigIcons/home.jpg';
	else if (icon == 'camping')		bigIcon.src = 'img/bigIcons/camping.jpg';
	else if(icon == 'environment')	bigIcon.src = 'img/bigIcons/environment.jpg';
	else if(icon == 'prices')		bigIcon.src = 'img/bigIcons/prices.jpg';
	else if(icon == 'route')		bigIcon.src = 'img/bigIcons/route.jpg';
	else if(icon == 'activities')	bigIcon.src = 'img/bigIcons/activities.jpg';
	else if(icon == 'contact')		bigIcon.src = 'img/bigIcons/contact.jpg';
	else if(icon == 'livingunits')	bigIcon.src = 'img/bigIcons/livingunits.jpg';
	else if(icon == 'bedandbreakfast')	bigIcon.src = 'img/bigIcons/bedandbreakfast.jpg';
	else							bigIcon.src = 'img/bigIcons/home.jpg';
}
