window.addEvent('domready', function(){
	// Get page
	var page = window.location.href.substring(window.location.href.lastIndexOf('/') + 1).replace('.html', '').split('-');
	if (page.length == 0 || page[0] == ''){
		page[0] = 'index';
	}
	
	// Highlight menu
	$$('#menu a').each(function(menuitem){
		if (menuitem.getProperty('href').test('^' + page[0])){
			menuitem.addClass('active');
			document.title = 'Van der Valk tuinmaterialen - ' + menuitem.get('text');
			
			// Highlight submenu
			if (page.length == 2){
				$$('#submenu a').each(function(submenuitem){
					if (submenuitem.getProperty('href').test('^' + page[0] + '-' + page[1] + '.html')){
						submenuitem.addClass('active');
						document.title += ' - ' + submenuitem.get('text');
					}
				});
			}
		}
	});
	
	// Scan links for external sites
	$$('a[target=_blank]').each(function(a){
		if (a.getProperty('rel') == null || !a.getProperty('rel').contains('external')){
			a.addEvent('click', function(e){
				var event = new Event(e);
				if (!event.shift && !event.control){
					event.stop();
					window.location.href = 'redirect.html?url=' + encodeURIComponent(a.getProperty('href')) + '&referrer=' + encodeURIComponent(document.location.href);
				}
			});
		}
	});

	// Style form
	new amTools.StyledForm({
		checkboxImageHeight: 24,
		radioImageHeight: 24
	});
	
	// Create slideshow
	new amTools.Slideshow({
		container: 'sidebar-onze_showtuin-slideshow',
		elements: 'a'
	});
});