$(function() {
	$('.join-class').live('click', function() {
	var id = $(this).attr('id').split('_')[1];
	if ($(this).hasClass('attend') || $(this).hasClass('attend-archive')) {
		$("#register-login").dialog("open");
		PS.current_event = $(this).attr('id').split('_')[1];
		return false;
	}
	else if ($(this).hasClass('sign-up')) {
		//$(this).parent().append('<span class="signing-up-ajax">Signing up <br/> <img src="/images/ajax-loader-squares.gif"/></span>');
		$(this).addClass('signing-up').attr('title',$(this).text()).html('<img src="http://www.torahlive.org/graphics/animation/signing-in.gif"/>');
		PS.sign_up(id, $(this).hasClass('enter'));
		return false;
	}
	else if ($(this).hasClass('enter') && $(this).hasClass('before-fifteen')) {
		$('#not-started-yet').dialog("open");
		return false;
	}
	else if ($(this).hasClass('view-event')) {
		var button = $(this);
		$("#close-button").click(function() {
			$('#presentation').hide().attr('src', '');
			$("#close-button").hide();	
			button.show();
			
			return false;
		});
		
		$('#presentation').attr('src', $('#presentation').attr('rc'));
		if ($("#presentation")[0].contentDocument) {
			$("#presentation")[0].contentDocument.location.href = $('#presentation').attr('src');
		}
		else {
			//$("#presentation")[0].contentWindow.document.location.href = $('#presentation').attr('src');
		}
		$('#presentation').show();
		
		$.get('/log_user/' + id);

		$("#close-button").show();	
		$(this).hide();
		return false;
	}
});
	if (location.hash == '#enter') {
		$('.join-class').filter('.view-event').not('.before-fifteen').click();
	}
});

