$(document).ready(function(){
	
	$(".accordion h3:first").addClass("active");
	$(".accordion div:not(:first)").hide();

	$(".accordion h3").eq(1).addClass("active");
	$(".accordion div").eq(1).show();

	$(".accordion h3").click(function(){
		$(this).next("div").slideToggle("slow")
		.siblings("div:visible").slideUp("slow");
		$(this).toggleClass("active");
		$(this).siblings("h3").removeClass("active");
	});

	$('a.poplight[href^=#]').click(function() {
		var popID = $(this).attr('rel'); 
		var popURL = $(this).attr('href');

		var query = popURL.split('?');
		var dim = query[1].split('&');
		var popWidth = dim[0].split('=')[1];

		
		$('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="/img/close_pop.png" class="btn_close" style="border:0;" title="Close Window" alt="Close" /></a>');

		var popMargTop = ($('#' + popID).height() + 80) / 2;
		var popMargLeft = ($('#' + popID).width() + 80) / 2;

		$('#' + popID).css({
		    'margin-top' : -popMargTop,
		    'margin-left' : -popMargLeft
		});

		$('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.
		$('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn();

		return false;
	});

	$('a.close, #fade').live('click', function() { 
		$('#fade , .popup_block').fadeOut(function() {
		    $('#fade, a.close').remove();
		});
		return false;
	});
	
	var eventsPane = $($('.events')[0]);
	eventsPane.scrollTo($("#events_top").parent());
	eventsPane.scrollTo("-=20", 0, {axis: 'y'});

});

