var init = function() {

	// INITIAL SEARCH FIELD TEXT REPLACEMENT
	$('search').getElements('input[name=query]')[0].addEvents({
		'focus': function(){
			if(this.value == 'search this website' || this.value == 'vul uw zoekterm in') {
				this.value = '';
				this.style.color = '#00265d';
			}
		},
		'blur': function(){
			if(!this.value) {
				if (pagePath[0] == 'en') {
					this.value = 'search this website';
				} else {
					this.value = 'vul uw zoekterm in';
				}
				this.style.color = '#909090';
			}
		}
	});

	// INITIAL LOGIN FIELD TEXT REPLACEMENT
	if (pagePath[1] == 'bookshop') { // || pagePath[1] == 'index.php'
		$('content').getElements('div.login input[name=auth_user]').addEvents({
			'focus': function(){
				if(this.value == 'e-mail') {
					this.value = '';
					this.style.color = '#00265d';
				}
			},
			'blur': function(){
				if(!this.value) {
					this.value = 'e-mail';
					this.style.color = '#909090';
				}
			}
		});
		$('content').getElements('div.login input[name=auth_pass]').addEvents({
			'focus': function(){
				if(this.value == 'wachtwoord' || this.value == 'password') {
					this.value = '';
					this.style.color = '#00265d';
				}
			},
			'blur': function(){
				if(!this.value) {
					if (pagePath[0] == 'en') {
						this.value = 'password';
					} else {
						this.value = 'wachtwoord';
					}
					this.style.color = '#909090';
				}
			}
		});
	}

	// MOUSE-OVER EFFECTS FOR TOPNAV
	$('header').getElements('ul.topnav a').addEvents({
		'mouseenter': function() {
			if (!this.hasClass('active')) {
				this.set('tween', {property: 'color', duration: '50'}).tween('#82B702');
			}
		},
		'mouseleave': function() {
			if (!this.hasClass('active')) {
				this.set('tween', {property: 'color', duration: '200'}).tween('#ffffff');
			}
		}
	});

	// MOUSE-OVER EFFECT FOR LANGUAGE FLAG
	$('langselect').getElements('a img').addEvents({
		'mouseenter': function() {
			this.set('tween', {property: 'border-color', duration: '50'}).tween('#23550f');
		},
		'mouseleave': function() {
			this.set('tween', {property: 'border-color', duration: '200'}).tween('#b4e348');
		}
	});

	// MOUSE-OVER EFFECTS FOR HEADNAV
	$('header').getElements('div.headnav a').addEvents({
		'mouseenter': function() {
			if (!this.hasClass('active')) {
				this.set('morph', {duration: '50'}).morph({'background-color':'#b4e348','color':'#418b03'});
			}
		},
		'mouseleave': function() {
			if (!this.hasClass('active')) {
				this.set('morph', {duration: '200'}).morph({'background-color':'#81b80a','color':'#ffffff'}); //
			}
		}
	});

	// MOUSE-OVER EFFECTS FOR LEFTNAV
	if (pagePath[1] == 'bookshop' || pagePath[1] == 'target' || pagePath[1] == 'general') {
		$('leftnav').getElements('ul a').addEvents({
			'mouseenter': function() {
				if (!this.hasClass('active')) {
					this.set('tween', {property: 'color', duration: '50'}).tween('#7ab322');
				}
			},
			'mouseleave': function() {
				if (!this.hasClass('active')) {
					this.set('tween', {property: 'color', duration: '200'}).tween('#00265d');
				}
			}
		});
	}

	// MOUSE-OVER EFFECTS FOR LINKS IN NORMAL PAGE CONTENT
	if ($chk($('content').getElements('a'))) {
		$('content').getElements('a').addEvents({
			'mouseenter': function() {
				if (!this.hasClass('no_js') && !this.hasClass('active') && !this.hasClass('arrow') && !this.hasClass('btn') && !this.hasClass('more_info') && !this.getParent('div.newsblock')) {
					this.set('morph', {duration: '50'}).morph({'color':'#cd1041'});
				}
			},
			'mouseleave': function() {
				if (!this.hasClass('no_js') && !this.hasClass('active') && !this.hasClass('arrow') && !this.hasClass('btn') && !this.getParent('div.newsblock')) {
					this.set('morph', {duration: '200'}).morph({'color':'#4b8d11'});
				}
			}
		});
	}

	// SETTING INITIAL HEIGHT OF HEADNAV
	$('header').getElements('div.headnav').set('styles', {'height': 0, 'padding-top':0, 'padding-bottom': 0});

	// MAKING HEADNAV ROLL OUT AND ROLL IN WHEN MOUSE ENTERS/LEAVES THEM
	$('header').getElements('div.headnav').addEvents({
		'mouseenter': function() {
			this.set('morph', {duration: 1000,transition: Fx.Transitions.Bounce.easeOut}).morph({'height': 121, 'padding-top':38, 'padding-bottom': 5});
		},
		'mouseleave': function() {
			this.set('morph', {duration: 500,transition: Fx.Transitions.Sine.easeOut}).morph({'height': 0, 'padding-top':0, 'padding-bottom': 0});
		}
	});

	// MAKING HEADNAV ROLL OUT AND ROLL IN WHEN MOUSE ENTERS/LEAVES THE H2-TAGS ABOVE THEM
	$('container').getElements('div#header>h2').addEvents({
		'mouseenter': function() {
			$(this.get('class')).set('morph', {duration: 1000,transition: Fx.Transitions.Bounce.easeOut}).morph({'height': 121, 'padding-top':38, 'padding-bottom': 5});
		},
		'mouseleave': function() {
			$(this.get('class')).set('morph', {duration: 500,transition: Fx.Transitions.Sine.easeOut}).morph({'height': 0, 'padding-top':0, 'padding-bottom': 0});
		}
	});

	// SHOP NAVIGATION BULLET FOR CATS WITH SUBCAT + MOUSE-OVER
	if (pagePath[1] == 'bookshop') {
		$('leftnav').getElements('li.has_sub').setStyle('background-image', "url(/skin/bullet.gif)");
		$('leftnav').getElements('li.active_has_sub').setStyle('background-image', "url(/skin/bullet_down_active.gif)");

		$('leftnav').getElements('li.has_sub div').setStyle('display', 'none');
		$('leftnav').getElements('li.active_has_sub div.sub').setStyle('display', 'block');

		$('leftnav').getElements('li.has_sub div').setStyle('display', 'none');
		$('leftnav').getElements('li.active_has_sub div.sub').setStyle('display', 'block');

		$$('div#leftnav li.has_sub li a.active').getParent('li.has_sub').setStyle('background-image', "url(/skin/bullet_down.gif)");
		$$('div#leftnav li.has_sub li a.active').getParent('div.sub').setStyle('display', 'block');

		$('leftnav').getElements('li.has_sub').addEvents({
			'click': function() {
				if(this.getStyle('background-image') == "url(/skin/bullet_down.gif)") {
					this.setStyle('background-image', "url(/skin/bullet.gif)");
					this.getElement('div.sub').setStyle('display', 'none');
				} else {
					this.setStyle('background-image', "url(/skin/bullet_down.gif)");
					this.getElement('div.sub').setStyle('display', 'block');
				}
			}
		});
		$('leftnav').getElements('li.active_has_sub').addEvents({
			'click': function() {
				if(this.getStyle('background-image') == "url(/skin/bullet_down_active.gif)") {
					this.setStyle('background-image', "url(/skin/bullet_active.gif)");
					this.getElement('div.sub').setStyle('display', 'none');
				} else {
					this.setStyle('background-image', "url(/skin/bullet_down_active.gif)");
					this.getElement('div.sub').setStyle('display', 'block');
				}
			}
		});

		// LANG SWITCH FOR ARTICLE INDEX
		$('store_page').getElements('div.series select.lang').addEvents({
			'change': function() {
				var series_id = this.getParent('div.series').getChildren('input.series_id').get('value');
				var art_lang = this.options[this.selectedIndex].value;
				this.getParent('div.series').getChildren('div.article').removeClass('active');
				this.getParent('div.series').getChildren('div#article_'+series_id+'_'+art_lang).addClass('active');
			}
		});

		// LANG SWITCH FOR ARTICLE PAGE
		$('content').getElements('div#article select.lang').addEvents({
			'change': function() {
				var series_id = this.getPrevious('input.series_id').get('value');
				var art_lang = this.options[this.selectedIndex].value;
				$('article').getChildren('div.artinfo').removeClass('active');
				$('article').getChildren('div#info'+'_'+art_lang).addClass('active');
			}
		});

		// INFO SWITCH TABS ON ARTICLE PAGE
		$('content').getElements('div#article a#tab_1').addEvents({
			'click': function() {
				$('article').getElements('div.tabs li').removeClass('active');
				this.getParent('li').addClass('active');
				$('article').getElements('div.bottom_1').setStyle('display', 'block');
				$('article').getElements('div.bottom_2').setStyle('display', 'none');
				return false;
			}
		});
		$('content').getElements('div#article a#tab_2').addEvents({
			'click': function() {
				$('article').getElements('div.tabs li').removeClass('active');
				this.getParent('li').addClass('active');
				$('article').getElements('div.bottom_2').setStyle('display', 'block');
				$('article').getElements('div.bottom_1').setStyle('display', 'none');
				return false;
			}
		});

		// INFO SWITCH TABS ON ARTICLE PAGE
		$('content').getElements('table.total input.payment').addEvents({
			'change': function() {
				document.forms.cart.submit();
			},
			'click': function() {
				document.forms.cart.submit();
			}
		});
	}
};

window.addEvent('domready',init);