// JavaScript Document

$(function() {
	$('#mainbreadcrumbs .separator').html('&raquo;');
	
	$('#mainbreadcrumbs li:first-child a').html('<img src="/sitescene/custom/images/breadcrumbs-home.png" />');
	
	//$('#maincontent ul li').prepend('<span class="bullet">&raquo;</span>');
	
	$("#newsletterform").validate({
		
	});
	
	$("#formcontact").validate({
		
	});
	
	$("#structured_comment_form").validate({
		
	});
	
	
	/*$('<h2><a>Toon Reacties</a></h2>')
		.insertBefore('#structured_comments')
		.css({'cursor': 'pointer'})
		.click(function() {
			$('#structured_comments').slideDown();
			$(this).text('Reacties');
		});*/
	
	$('<h2 id="structured_comments_title">Reacties</h2>')
		.insertBefore('#structured_comments');
		
	if(!$('#structured_comments > div.item').length) {
		$('#structured_comments').prepend('<h3>Er zijn nog geen reacties</h3><br/>');
	}
	
	/*$('<a href="javascript:void(0);" class="small">Zelf reageren</a>')
		.prependTo('#structured_comments')
		.click(zelfReageren);*/
		
	//$('#new_comment').before('<h2>Zelf reageren</h2>');
	
	$('#new_comment').prepend('<h2>Zelf reageren</h2>');
	
	if($('#new_comment_message').length) {
		$('html,body').animate({ scrollTop: $('#structured_comments #new_comment').offset().top }, { duration: 'slow', easing: 'swing'});
		$('#zelfreagerenbtn').hide();
	} else {
		$('#new_comment').hide();
		$('<a href="javascript:void(0);" class="button standout" id="zelfreagerenbtn">Zelf reageren</a>')
			.insertBefore('#new_comment')
			.click(function() { $(this).fadeOut('fast',zelfReageren);});
	};
	
	/*$('.lightboxwrapper img')
		.each(function() { $(this).wrap('<a href="' +$(this).attr('src')+ '" />'); })
		.slimbox();*/
	
	$('.lightbox img').each(function() {
		$(this).wrap('<a href="' +$(this).attr('src')+ '" title="' +$(this).attr('alt')+ '" />');
	});
	
	$('.lightbox img').parent().slimbox({counterText: "Afbeelding {x} van {y}"});
	
	$('.lightbox').before('<div class="small">Klik voor een grotere afbeelding</div>');
	
	/*
	$('###attributes.divId# img').each(function() {
		//alert($(this).attr('src'));
		var thisPath = $(this).attr('src');
		$(this).css({'width': '120px', 'height': 'auto'});
		$(this).wrap('<a href="' +thisPath+ '" rel="lightbox-item" />');
	});*/
	
	
	/*$('#structured_comments')
		.hide();*/
	
	//$('#formcontact input.required').after('<span class="requiredindicator">*</span>');
});
	
function zelfReageren() {
	$('#new_comment').slideDown();
	$('html,body').animate({ scrollTop: $('#structured_comments #new_comment').offset().top }, { duration: 'slow', easing: 'swing'});
}
