function noteGetContainerDiv() {
	return document.getElementById('wrapper-note');
}


function noteGetItemsDiv() {
	return document.getElementById('wrapper-note-items');
}


function noteShow(){
	var div = noteGetContainerDiv();
	div.style.display = 'block';
}

function noteHide(){
	var div = noteGetContainerDiv();
	div.style.display = 'none';
}


function noteGetItems() {
	var cookieValue = cookieGet('manitu-note');
	if (cookieValue) {
		var items = JSON.parse(cookieValue);
		items.sort;
		return items;
	} else {
		return {};
	}
}


function noteUpdateContent() {
	var items = noteGetItems();
	
	var content = '';
	var length = 0;
	for (var id in items) {
		
		content_item  = '';
		content_item += '<li>';
		content_item += ' <div class="wrapper-note-item-close">';
		content_item += '  <a href="javascript:noteDel(\''+id+'\')"><img src="/images/header/note_del.png" border="0" /></a>';
		content_item += ' </div>';
		content_item += items[id].text;
		content_item += '';
		
		content = content_item + content;

		length++;
	}
	
	content = '<ol>'+content+'</ol>';
	
	var div = noteGetItemsDiv();
	if (!div) {
		return;
	}
	div.innerHTML = content;
	
	if (length > 0) {
		noteShow();
	} else {
		noteHide();
	}
}


function noteAdd(id, text) {
	var items = noteGetItems();
	
	items[id] = {
		"text" : text,
	};
	
	cookieCreate('manitu-note', JSON.stringify(items));
	
	noteUpdateContent();
}


function noteDel(id) {
	var items = noteGetItems();
	
	delete items[id];
	
	cookieCreate('manitu-note', JSON.stringify(items));
	
	noteUpdateContent();
}


function noteClearAll(){
	cookieErase('manitu-note');

	noteUpdateContent();
}




