/* Ask for confirmation on buttons with the confirm-delete class */
$(document).ready(function(){
	
	$('input.confirm-delete').click(function() {
		return confirm("Weet u zeker dat u dit item wilt verwijderen?");
	});
	
	$('.news-block .news-item').click(function() {
		if($('.hide',this).hasClass('hidden')){
			$('.hide',$(this).parent()).addClass('hidden').slideUp();
			$('.hide',this).removeClass('hidden').slideUp(0).slideDown();
			// google analytics
			if (typeof(_gaq) !== 'undefined')
				/* Preserve the stats url from the old
				 * Rabposport on old news items. Get the
				 * href from the .nojs-href link inisde
				 * the .news-item. */
				if ($('.nojs-href',this).attr('stats-href'))
					_gaq.push(['_trackPageview', $('.nojs-href',this).attr('stats-href')]);
				else
					_gaq.push(['_trackPageview', $('.nojs-href',this).attr('href')]);
			return false;
		}else{
			$('.hide',this).addClass('hidden').slideUp();
		}	return false;
	});

	/* Prevent click events on links _inside_ the toggle block from
	 * bubbling up, so they don't trigger the above handler (and
	 * instead are handled normally, by following the link). Make an
	 * exception for the .nojs-href, which is only intended to use
	 * without javascript and .new-window, which has its own javascript we
	 * should not cancel... */
	$('.hide a').not('.nojs-href').not('.new-window').click(function(event){
		event.stopImmediatePropagation();
	});


	$('.more').hide();
	$('.show-more').css("display","block");
	
	$('.show-more').click(function() {
		$('.more',$(this).parent()).show();
		$(this).hide(); 
		return false;
	});
	
	
	/* Call the small css for browser screen below 800 */
	function adjustStyle(width) {
	    width = parseInt(width);
	    if (width < 1024) {
		$('body').addClass('small-screen');
	    } else {
		$('body').removeClass('small-screen');
	    }
	    
	}
	adjustStyle($(window).width());
	$(window).resize(function() {
		adjustStyle($(this).width());
	});
	
});

