$(function(){

	$('#background').fullBg();
	
	$('.toggle').click(function(){
		if($(this).is(':not(.active)')){
			$(this).addClass('active').siblings('.active').removeClass('active');
			var target = $('div.hide');
			target.removeClass('hide').prev('div').addClass('hide');
			target.next('div').addClass('hide');
		}
		return false;
	})
	$('#songtext_overview a').click(function(){
		if($(this).is(':not(.active)')){
			$(this).addClass('active').siblings('.active').removeClass('active');
			$('#songtext').load($(this).attr('href'))
			if($(document).scrollTop() != 0){			
				$.scrollTo(0, 200);
			}
		}
		return false;
	})
	$('.image, .colorbox').colorbox({
		maxHeight: '90%',
		maxWidth: '90%',
		current: 'afbeelding {current} van {total}'
	});
	$('.videobox').colorbox({
		iframe:true, 
		innerWidth:425, 
		innerHeight:344,
		current: 'video {current} van {total}'
	})
	if(jQuery.browser.msie && parseInt(jQuery.browser.version, 10) == 6) {
	  try {
	    document.execCommand('BackgroundImageCache', false, true);
	  } catch(err) {}
	}

/*
	if($('.form').length){
		$('.form').each(function(){			
			$(this).validate({
				submitHandler: function(form){
					$(form).find("input[type='submit']").attr('disabled', 'disabled');
					var formid = $(form).attr('id');
					$.ajax({
						type: 'post',
						url: '/site/handlers/ajax/'+ formid +'.php',
						data: $(form).serialize(),
						success: function(result){
							if(result == 'success'){
								$(form).fadeOut(300, function(){
									$('.intro p').text($(this).next().text());
								})
							} else if(result == 'error'){
								$(form).fadeOut(300, function(){
									$(this).parent().append('helaas is er een fout opgetreden, probeer het later nogmaals');
								})								
							}
						}
					})
				}
			})			
		})
	}
*/
	$('.read_older').live('click', function(){
		var offset = $(this).attr('href').split('#');
		el = $(this);
		var type = $('body').attr('class');
		$.ajax({
			url: '/site/ajax/news.php',
			type: 'post',
			data: 'offset='+offset[1]+'&type='+type,
			success: function(result){
				$('.tome').remove();
				el.after('<div class="tome"></div>' + result);
				$.scrollTo('.tome', {duration:1000, offset: -30})
				el.remove();
			}
		})
		return false;
	})

});

$(window).resize(function(){
	$('#background').fullBg();
});
