var SiteNotifications = {
	gotoNotificationsListURL : null,

	displayNotificationsList : false,

	control : null,
	notificationsContainer : null,
	notificationsArea : null,

	create : function(notificationsURL) {
		SiteNotifications.gotoNotificationsListURL = notificationsURL;

		SiteNotifications.control = $('notificationDisplayControl');
		SiteNotifications.notificationsArea = $('notesDetail');

		SiteNotifications.notificationsContainer = $('viewnotes');
		SiteNotifications.notificationsContainer
				.clonePosition(
						SiteNotifications.control,
						{
							setWidth : false,
							setHeight : false,
							offsetTop : SiteNotifications.control.getHeight(),
							offsetLeft : (SiteNotifications.control.getWidth() - SiteNotifications.notificationsContainer
									.getWidth()) / 2
						});
		SiteNotifications.setEventObservation();
	},

	setEventObservation : function() {
		SiteNotifications.control.observe('click',
				SiteNotifications.toggleDisplayNotifications);
		$$('div.singleNoteContent').each(
				function(item) {
					item.observe('click',
							SiteNotifications.navigateToSiteNotificationsList);
				});
	},

	toggleDisplayNotifications : function(event) {
		if (SiteNotifications.displayNotificationsList == false) {
			SiteNotifications.displayNotificationsList = true;
			Effect.SlideDown(SiteNotifications.notificationsContainer, {
				duration : 0.3,
				queue : {
					position : 'end',
					scope : "SiteNotificationsScope"
				}
			});
		} else {
			SiteNotifications.displayNotificationsList = false;
			Effect.SlideUp(SiteNotifications.notificationsContainer, {
				duration : 0.3,
				queue : {
					position : 'end',
					scope : "SiteNotificationsScope"
				}
			});
		}
		event.stop();
	},

	navigateToSiteNotificationsList : function(event) {
		location.href = SiteNotifications.gotoNotificationsListURL;
		event.stop();
	},

	changeClass : function(notificationId, read) {
		notificationDiv = $(notificationId);
		actionLink = notificationDiv.down('a');
		if (read) {
			notificationDiv.removeClassName('unreadNote');
			notificationDiv.addClassName('readNote');
			actionLink.update("Leído");
		} else {
			notificationDiv.removeClassName('readNote');
			notificationDiv.addClassName('unreadNote');
			actionLink.update("No Leído");
		}
	}
};

