function addListener(element, type, expression, bubbling) {
	bubbling = bubbling || false;
	
	if(window.addEventListener)	{ // Standard
		element.addEventListener(type, expression, bubbling);
		return true;
	} else if(window.attachEvent) { // IE
		element.attachEvent('on' + type, expression);
		return true;
	} else {
		return false;
	}
}

var ImageLoader = function(url) {
	this.url = url;
	this.image = null;
	this.element = null;
	this.loadEvent = null;
};

ImageLoader.prototype = {
	load:function(image){
		this.image = image;
		var url = this.url;
		var image = this.image;
		var loadEvent = this.loadEvent;
		var element = this.element;
		
		addListener(this.image, 'load', function(e){
			if(loadEvent != null){
				loadEvent(url, image, element);
			}
		}, false);
		
		this.image.src = this.url;
	},
	
	getImage:function(){
		return this.image;
	}
};

$(document).ready(function() {	
	$('div.Album').each(function() {
		$(this).ThumbEnlarger({
			selector : 'a.Thumb',
			events : 'click' });
	});
	
	$('td.Enlargements').each(function() {
		$(this).Gallery({
			close : '#closeGallery',
			darklayer : '#DarkLayer',
			container : '#LightBoxHolder',
			photoHolder : '#LightBoxFotoHolder',
			trigger : '.Enlargements'
		});
	})

	$('ul#Menu li').hover(
		function() { $('> ul', this).show() },
		function() { $('> ul', this).hide() }
	);
	
	$('#ToggleHeight').toggle(
		function() { 
			$('#NewsLetter').animate({
				height: "180"
			}, { duration: 500, queue: false });
	},
	function() {
		$('#NewsLetter').animate({
			height: "45"
		}, { duration: 500, queue: false });
	});
	
	$('input[name=Name]').bind({
		  click: function() {
			if($(this).val().match( 'Je naam' )) {
				$(this).val('');
			}
		  },
		  blur: function() {
			if($(this).val() == '') {
				$(this).val( 'Je naam' );
			}
		  }
	});
	
	$('input[name=Email]').bind({
		  click: function() {
			if($(this).val().match( 'Je e-mailadres' )) {
				$(this).val('');
			}
		  },
		  blur: function() {
			if($(this).val() == '') {
				$(this).val( 'Je e-mailadres' );
			}
		  }
	});
});
