$(document).ready(function() {
	
	var width = $(window).width();
	$('.coda-slider').css('width',width+'px');
	$('.panel').css('width',width+'px');
	$('#contentPane').parent().css('height','350px');
	
	$('#coda-slider-1').codaSlider({
		dynamicArrows : false,
		dynamicTabs : false,
		crossLinking : true
	});
	
	
	$("#newsbrief_form").bind("submit", function() {
		$.fancybox.showActivity();
	
		$.ajax({
			type		: 'POST',
			cache		: false,
			url			: URL+'/pages/addReceiver.ajax.php',
			data		: $(this).serializeArray(),
				success: function(data) {
				$.fancybox(data);
			}
		});
		return false;
	});	
		
	$('a.xtrig').click(function() {
		var s_href = $(this).attr('href');
		var i_id = s_href.substr(1,1);
		$('#bg_bottom').css('background-image', $('#bg_top').css('background-image'));
	 	$('#bg_top').animate({opacity: 0}, 'slow', function() { $(this).css({'background-image': 'url('+IMGS+'bg_'+i_id+'.jpg)'}).animate({opacity: 1});});
	 	
	});
	
	//show map on clicks
	$("a.viewMap").fancybox({
		'width'				: '75%',
		'height'			: '75%',
		'autoScale'			: false,
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'	
	});
	
	//Fancybox
	$("a[rel=photoalbum]").fancybox({
		'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'titlePosition' 	: 'over',
		'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">Afbeelding ' + (currentIndex + 1) + ' / ' + currentArray.length + '</span>';
		}
	});
	
	$("#briefPane .clickPane, a.clickPane").click(function() {
		if($('#briefPane').attr('class') == 'closed') {
			$('#briefPane').animate({marginRight: '0px'}, 800, function() {
			    $('#briefPane').attr('class','open');
			});
		} else {
			$('#briefPane').animate({marginRight: '-265px'}, 800, function() {
			    $('#briefPane').attr('class','closed');
			});
		}		
	});
	$("#briefPane .briefForm p.hideLbl").click(function() {
		$('#briefPane').animate({marginRight: '-265px'}, 800, function() {
		    $('#briefPane').attr('class','closed');
		});	
	});
});
