(function ($) {
// VERTICALLY ALIGN FUNCTION
$.fn.vAlign = function() {
	return this.each(function(i){
	var ah = $(this).height();
	var ph = $(this).parent().height();
	var mh = Math.ceil((ph-ah) / 2);
	$(this).css('margin-top', mh);
	});
};
})(jQuery);

$(window).ready(function(){		
	
	$("#blackout").delay(3000).fadeOut(2500);
	$("#blackout").click(function () { 
      $("#blackout").slideUp(); 
    });
	$("#blackoutimage").vAlign();
		
	$(".media").fancybox({
		'cyclic' : true,
		'titlePosition'	: 'over',
		'titleFormat': 'formatTitle',
		'autoDimensions': false,
		'onComplete': function() {
			$("#fancybox-wrap").hover(function() {
				$("#fancybox-title").show();
			}, function() {
				$("#fancybox-title").hide();
			}), $("#fancybox-title").hide();
		}
	});
	
	$("a.links").fancybox({
		 'width': '80%',
		 'height': '90%',
		 'type': 'iframe' 
	});
	
	$("a.video").fancybox({
		 'width': 600,
		 'height': 480,
		 'type': 'iframe',
		 'onComplete' : function() {
		 	$("#jquery_jplayer_1").jPlayer("stop");
		 }
	});
	
	$("a.agenda").fancybox({
		'width': '80%',
		'height': '90%',
		'type': 'iframe' 
	});
	
	$("a.downloads").fancybox({
		 'width': '10%',
		 'height': '10%',
		 'type': 'iframe' 
	});
	
	$("a.press").fancybox();

	$("a.expl").fancybox({
		 'width': 400,
		 'height': 200,
		 'type': 'iframe' 
	});
	
	$('#slides').slides({
		preload: true,
		generatePagination: false,
		effect: 'slide',
		play: 7500,
		pause: 700,
		hoverPause: true
	});

	$('#imageslider').slides({
		preload: true,
		preloadImage: 'images/site/loading.gif',
		generatePagination: false,
		play: 4500,
		randomize: true
	});
	
	$("#agendatable").tablesorter({
		dateFormat : 'uk',
		widgets: ['zebra'],
		headers: {
			2: { sorter: false },
			4: { sorter: false }
		}
	}); 
}); 



