$(function() {

	if(jQuery.url.param('added'))
		$('#added').show();
	else if(jQuery.url.param('updated'))
		$('#updated').show();
	else if(jQuery.url.param('deleted'))
		$('#deleted').show();
	else if(jQuery.url.param('eventMemberRequestSent'))
		$('#eventMemberRequestSent').show();
	else if(jQuery.url.param('friendRequestSent'))
		$('#friendRequestSent').show();
	else if(jQuery.url.param('friendRequestApproved'))
		$('#friendRequestApproved').show();
	else if(jQuery.url.param('friendRequestDenied'))
		$('#friendRequestDenied').show();
	else if(jQuery.url.param('friendDeleted'))
		$('#friendDeleted').show();	
	else if(jQuery.url.param('userProfilePhotoUpdated'))
		$('#userProfilePhotoUpdated').show();
	else if(jQuery.url.param('photoUploaded'))
		$('#photoUploaded').show();	
	else if(jQuery.url.param('commentPosted'))
		$('#commentPosted').show();	
	else if(jQuery.url.param('commentPostApproved'))
		$('#commentPostApproved').show();
	else if(jQuery.url.param('commentPostDenied'))
		$('#commentPostDenied').show();	
	else if(jQuery.url.param('commentDeleted'))
		$('#commentDeleted').show();	
	else if(jQuery.url.param('photoEdited'))
		$('#photoEdited').show();			
	else if(jQuery.url.param('photoDeleted'))
		$('#photoDeleted').show();
	else if(jQuery.url.param('eventMemberDeleted'))
		$('#eventMemberDeleted').show();
	else if(jQuery.url.param('eventMemberRequestApproved'))
		$('#eventMemberRequestApproved').show();
	else if(jQuery.url.param('eventMemberRequestDenied'))
		$('#eventMemberRequestDenied').show();
	else if(jQuery.url.param('eventNotificationCreated'))
		$('#eventNotificationCreated').show();
	else if(jQuery.url.param('eventNotificationEdited'))
		$('#eventNotificationEdited').show();
	else if(jQuery.url.param('eventNotificationDeleted'))
		$('#eventNotificationDeleted').show();
	else if(jQuery.url.param('eventInvitationCreated'))
		$('#eventInvitationCreated').show();
	else if(jQuery.url.param('userRegistered'))
		$('#userRegistered').show();
	else if(jQuery.url.param('notificationUnsubscribed'))
		$('#notificationUnsubscribed').show();
	
	$('a.lightbox').lightBox();
	$('a.lightboxEvent').lightBox('Event');

	// Toggles Comment Form	
		$('#toggle').click(function () {		
		$('#hidden').toggle('fast');
			if ($('#toggle').text()=='Post Comment')
				$('#toggle').text("Close Form");
			else if ($('#toggle').text()=='Close Form')
				$('#toggle').text('Post Comment');
			return false;
    });
		
		// Shows Upload Progress Bar	
		$('#photoUploadFormButton').click(function () {		
			$('#photoUploadProgressBar').show();
			$('#photoUploadFormButton').hide();
    });

});

function logout(uri) {
	if(confirm("Are you sure you want to logout?\n\nOk to continue, Cancel to abort."))
		top.location=uri;
}

function toggleDisplay(idShown,idHidden) {  // might want to deprecate in favor of jquery function toggle()
	
	var shown = document.getElementById(idShown);
	if ( shown.style.display == 'inline' ) shown.style.display = 'none';
	  else shown.style.display = 'inline';
	  
	var hidden = document.getElementById(idHidden);
	if ( hidden.style.display == 'none' ) hidden.style.display = 'inline';
	  else hidden.style.display = 'none';
}



$(function(){
    
	$("#searchEventSelector").change(function () {
		
		currentId = '#'+$('.active').attr('id');
		$(currentId).hide();
	
		$("#searchEventSelector option:selected").each(function () {
					id = '#'+$(this).val();
				});
		
		$(id).show();
							
		$(currentId).removeClass('active');
		$(currentId).addClass('hidden');
		
		$(id).removeClass('hidden');
		$(id).addClass('active');
	})	
});


$(function() { 
	/* This is basic - uses default settings */ 
	$("a#single_image").fancybox(); 
	/* Using custom settings */ 
	$("a.inline").fancybox({ 'hideOnContentClick': true }); 
	$("a.group").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': false }); 
}); 


function clearField(theText) {
	if (theText.value == theText.defaultValue) {
   theText.value = ""
  }
}

function shareOnFacebook(url) {
	var facebook = window.open(url);
	facebook.focus();
}
