	/* ------------------------------------------------- */
/* ON DOM READY
/* ------------------------------------------------- */
jQuery(document).ready(function($) {
	/* ------------------------------------------------- */
	/* MENU CLOSE/OPEN LOGIC
	/* When menu button is clicked open nav
	/* with the native jquery slidedown function
	/* ------------------------------------------------- */
		$('#wrapper #inner-wrapper #btn-menu').click(function(e) {
			e.preventDefault();
			$(this).toggleClass('open');
			$('#wrapper #inner-wrapper #header #menu-wrapper').slideToggle('fast');
		});
	/* --------------------------------------------------------- */
	/* PORTAL MENU LOGIC
	/* Make parent (li) clickable and slide the a (child)
	/* href up/down on rollover, apply pointer cursor to parent
	/* AND only do this when we have a class over!
	/* --------------------------------------------------------- */
		$('#wrapper #inner-wrapper #portal li a').each(function() {
			var parent = $(this).parent();
			var child = $(this);
			var href = this.href;
			if(parent.hasClass('over')) {
				parent.css({'cursor':'pointer'});
				parent.click(function() { window.location = href; });
				parent.hover(function() { child.animate({'bottom':0}, 200); }, function () { child.animate({'bottom':-60}, 500); });
			}
		});
	/* --------------------------------------------------------- */
	/* INIT SCROLLABLE ON PORTAL
	/* --------------------------------------------------------- */
		if($('a.nav').size() > 0) $('a.nav').click(function(e) { e.preventDefault(); })
		if($('div.scrollable').size() > 0) $('div.scrollable').scrollable({size:1,next:'.prev',prev:'.next'}).mousewheel().autoscroll(4000);
	/* --------------------------------------------------------- */
	/* TIME MENU
	/* Automagically add the class 'no-entries' to li's with no
	/* sub ul, open li's with sub ul's and change their class
	/* --------------------------------------------------------- */
		if($('#time-menu').size() > 0) {
			
			$('#time-menu li.month').each(function() {
				var ul = $(this).find('ul');
				var li = $(this);
				var a = $(this).find('a:not(.link)');
				if(ul.size() > 0) {
					if(!ul.find('a.current').size() > 0) {
						ul.hide();
					} else {
						li.addClass('active');
					}
					a.click(function(e) {
						e.preventDefault();
						$('#time-menu li.active').removeClass('active').find('ul').slideToggle('fast');
						ul.slideToggle('fast');
						li.addClass('active');
					})
				} else {
					a.click(function(e) { e.preventDefault(); }).css({'cursor':'default'})
					$(this).addClass('no-entries');
				}
			});
			
		}
	/* --------------------------------------------------------- */
	/* COLORBOX INT
	/* --------------------------------------------------------- */
		$('a[rel="lightbox"]').colorbox();
	/* --------------------------------------------------------- */
	/* SUBMIT FORM VIA AJAX
	/* --------------------------------------------------------- */
		$('#mailinglist button').live('click', function(e) {
			e.preventDefault();
			$.ajax({
				url: $('#mailinglist').attr('action'),
				type: 'POST',
				data: $('#mailinglist').serialize(),
				success: function(data, textStatus) {
					$('#mailinglist').replaceWith(data);
				},
				error: function(data, textStatus) {
					$('#mailinglist').replaceWith(data);
				}
			});
		})
	/* ------------------------------------------------- */
	/* VALIDATION SPORT FORM
	/* ------------------------------------------------- */
		if($('#form-sport').size() > 0) {
			$("#form-sport").validate();
		}
		if($('#form-buzzypass').size() > 0) {
			$("#form-buzzypass").validate();
			$("#BuzzypassRegisternr").mask("999999-999-99");

		}
	/* ------------------------------------------------- */
	/* EMPTY FIELDS ON FOCUS
	/* ------------------------------------------------- */
		if($('#SubscriptionEmail').size() > 0) {
			$("#SubscriptionEmail").focus(function() {
				if( this.value == this.defaultValue ) {
					this.value = "";
				}
			}).blur(function() {
				if( !this.value.length ) {
					this.value = this.defaultValue;
				}
			});
		}
		if($('#search-field').size() > 0) {
			$("#search-field").focus(function() {
				if( this.value == this.defaultValue ) {
					this.value = "";
				}
			}).blur(function() {
				if( !this.value.length ) {
					this.value = this.defaultValue;
				}
			});
		}
	/* ------------------------------------------------- */
	/* CLICKABLE DIV
	/* ------------------------------------------------- */
		if($('#online-aanvraag').size() > 0) {
			$("#online-aanvraag").click(function (){
                window.location = $(this).find('a').attr('href');
            });
		}
});
