$(document).ready(function(){
	
	$('div.moduleCentre h2').css('cursor', 'pointer');
	
	$('div.moduleCentre h2').each(function() {
		$(this).css('background', 'url(images/icon-plus-sign.gif) 519px center no-repeat #000');
	});
	
	$('div.moduleCentre h2').eq(0).css('background', 'url(images/icon-minus-sign.gif) 519px center no-repeat #000');
	
	$('div.moduleCenterContent').each(function() {
		$(this).css('display', 'none');																				 
	});
	
	$('div.moduleCenterContent').eq(0).css('display', 'block');
	
	$('div.moduleCentre h2').click(function() {
		if ($(this).next().css('display') == 'none') {
			$(this).css('background-image', 'url(images/icon-minus-sign.gif)')
				.next().slideDown('slow');
		} else {
			$(this).css('background-image', 'url(images/icon-plus-sign.gif)')
				.next().slideUp('slow');
		}
	});
	
	$('#containerContent').after(
														
		'<div id="lightBoxBg"></div>' + 
		'<div id="lightBoxContainer">' +
			'<div id="lightBox">' +
				'<a id="closeBtn" href="">close</a>' +
				'<div id="lightBoxContent"></div>' +
			'</div>' +
		'</div>'
		
	);
	
	$('#lightBoxContainer').after(
														
		'<div id="imgBoxBg"></div>' + 
		'<div id="imgBoxContainer">' +
			'<div id="imgBox">' +
				'<a href="">close</a>' +
				'<div id="imgBoxContent"></div>' +
			'</div>' +
		'</div>'
		
	);	
	
	$('.openLightbox').click(function() {
		
		var url = this.href;
		
		$('#lightBoxBg').height($(document).height());
		$(document).scrollTop(0);
		$('#lightBoxBg').css('opacity', '0.9').fadeIn('slow');
		$('#lightBoxContainer').fadeIn('slow');
		$('#lightBox a').slideDown('slow');
		
		$('#lightBoxContent').load(url + ' #containerRules');
		
		return false;
			
	});
	
	$('#lightBox a').click(function() {
																		 
		$(this).slideUp('slow');
		$('#lightBoxBg').fadeOut('slow');
		$('#lightBoxContainer').fadeOut('slow');
		
		return false;
			
	});
	
	$('.enlarge').click(function() {
		
		var url = this.href;
		
		$('#imgBoxBg').height($(document).height());
		$('#imgBoxContent').addClass('loading');
		$(document).scrollTop(0);
		$('#imgBoxBg').css('opacity', '0.9').fadeIn('slow');
		$('#imgBoxContainer').fadeIn('slow');
		$('#imgBox a').slideDown('slow');
		
		var img = new Image();
		
		$(img).load(function() {
				
			$(this).hide();
			
			$('#imgBoxContent').removeClass('loading').html(this);
			
			$(this).fadeIn('slow');
			
		})

		.attr('src', url);

		
		return false;
			
	});
	
	$('#imgBox a').click(function() {
																		 
		$(this).slideUp('slow');
		$('#imgBoxBg').fadeOut('slow');
		$('#imgBoxContainer').fadeOut('slow', function() {
			$('#imgBoxContent').empty();																					 
		});
		
		return false;
			
	});
	
});