/*
 * @license Proprietary
 * @copyright Copyright (c) 2014 borkedLabs - All Rights Reserved
 */

function globalnotes(options)
{
	this.defaults = {
		baseUrl: ''
	};

	this.settings = $.extend(this.defaults, options);
	
	this.globalNotesEle = null;
	this._blinkNotesInterval = null;
	this.globalNotes = '';
	this.editingGlobalNotes = false;
	
	this.siggyMain = null;
}

globalnotes.prototype.initialize = function()
{
	var $this = this;

	$this.globalNotesEle = $('#global-notes');
	$('#global-notes-button').click(function ()
	{
		if ( $this.globalNotesEle.is(":visible") )
		{
			$this.globalNotesEle.hide();
			$('#global-notes-button').html('Notes <i class="fa fa-caret-down"></i>');
		}
		else
		{
			$this.globalNotesEle.show();
			$('#global-notes-button').html('Notes <i class="fa fa-caret-up"></i>');
			$this.stopBlinkingNotes();
		}
	});

	$('#global-notes-edit').click(function ()
	{
		$(this).hide();
		$('#global-notes-content').hide();
		$('#global-notes-edit-box').val($this.globalNotes).show();
		$('#global-notes-save').show();
		$('#global-notes-cancel').show();
	});

	$('#global-notes-save').click(function ()
	{
		$this.globalNotes = $('#global-notes-edit-box').val();

		$.post($this.settings.baseUrl + 'siggy/notes_save', {
			notes: $this.globalNotes
		}, function (data)
		{
			$this.editingGlobalNotes = false;
			$this.lastGlobalNotesUpdate = data;
			setCookie('notesUpdate', $this.lastGlobalNotesUpdate, 365);
			$('#global-notes-time').text(siggy2.Helpers.displayTimeStamp($this.lastGlobalNotesUpdate));
		});

		$('#global-notes-content').html($this.globalNotes.replace(/\n/g, '<br />')).show();
		$('#global-notes-edit-box').hide();
		$('#global-notes-edit').show();
		$('#global-notes-cancel').hide();
		$(this).hide();
	});


	$('#global-notes-cancel').click(function ()
	{
		$this.editingGlobalNotes = false;
		$('#thegnotes').show();
		$('#global-notes-edit-box').hide();
		$('#global-notes-edit').show();
		$('#global-notes-save').hide();
		$(this).hide();
	});
}

globalnotes.prototype.blinkNotes = function()
{
	if( this._blinkNotesInterval != null )
	{
		return;
	}

	$('#globalNotesButton').flash("#A46D00", 3000);

	this._blinkNotesInterval = setInterval( function() {
			$('#globalNotesButton').flash("#A46D00", 3000);
	}, 4000 );
}

globalnotes.prototype.stopBlinkingNotes = function()
{
	if( this._blinkNotesInterval != null )
	{
		clearInterval(this._blinkNotesInterval);
		this._blinkNotesInterval = null;
	}
}

globalnotes.prototype.update = function(data)
{
	if (!this.editingGlobalNotes)
	{
		if( typeof(data.globalNotes) != 'undefined' && data.globalNotes != null )
		{
			if( getCookie('notesUpdate') != null )
			{
				var nlu = parseInt(getCookie('notesUpdate'));
			}
			else
			{
				var nlu = this.siggyMain.groupCacheTime;
			}

			if( !this.globalNotesEle.is(':visible') && data.group_cache_time > nlu && nlu != 0 )
			{
				this.blinkNotes();
			}

			setCookie('notesUpdate', data.group_cache_time, 365);

			this.globalNotes = data.globalNotes;
			$('#global-notes-content').html(this.globalNotes.replace(/\n/g, '<br />'));
			$('#global-notes-time').text( siggy2.Helpers.displayTimeStamp(data.group_cache_time) );
		}
	}
}
@@ -530,319 +530,426 @@
 %7B%0A%09%09
-if ( 
 $this.
-globalNotesEle.is(%22:visible%22) )%0A%09%09%7B%0A%09%09%09$this.globalNotesEle.hide();%0A%09%09%09$('#global-notes-button').html('Notes %3Ci class=%22fa fa-caret-down%22%3E%3C/i%3E');%0A
+stopBlinkingNotes();%0A%09%0A%09%09$.blockUI(%7B%0A%09%09%09message: $this.globalNotesEle,%0A%09%09%09css: %7B%0A%09%09%09%09border: 'none',%0A%09%09%09%09padding: '15px',%0A%09%09%09%09background: 'transparent',%0A%09%09%09%09color: 'inherit',%0A%09%09%09%09cursor: 'auto',%0A%09%09%09%09textAlign: 'left',%0A%09%09%09%09centerX: true,%0A%09%09%09%09centerY: true%0A%09
 %09%09%7D
+,
 %0A%09%09
-else%0A%09%09%7B%0A%09%09%09$this.globalNotesEle.show(
+%09overlayCSS: %7B%0A%09%09%09%09cursor: 'auto'%0A%09%09%09%7D,%0A%09%09%09fadeIn:  0,%0A%09%09%09fadeOut:  0%0A%09%09%7D
 );%0A
-%09
 %09%09$('
-#global-notes-button').html('Notes %3Ci class=%22fa fa-caret-up%22%3E%3C/i%3E');%0A%09%09%09$this.stopBlinkingNotes();%0A%09%09%7D
+.blockOverlay').attr('title','Click to unblock').click($.unblockUI);
 %0A%09%7D)
@@ -1956,17 +1956,28 @@
 $('#
-thegnotes
+global-notes-content
 ').s

Add back old group notes temporarily.