// Note szerkesztés
document.querySelector('#btn-edit-note').addEventListener('click', function() {
	document.querySelector('#btn-save-note').style.display = 'block';
	document.querySelector('#btn-edit-note').style.display = 'none';

	document.querySelector('#note-title').style.display = 'block';
	document.querySelector('#note-content').style.display = 'block';
	document.querySelector('#noteview-title').style.display = 'none';
	document.querySelector('#noteview-content').style.display = 'none';
});

document.querySelector('#btn-header-search').addEventListener('click', function() {
	document.querySelector('#search').className = 'current';
	document.querySelector('[data-position="current"]').className = 'left';
});


// note vissza
document.querySelector('#btn-note-back').addEventListener('click', function() {
	if (settings.autosave == 1) {
		autosave_counter = 0;
		clearInterval(autosave);
	}
	ListAllNote();
	document.querySelector('#note').className = 'right';
	document.querySelector('[data-position="current"]').className = 'current';
});
// beálltások
document.querySelector('#btn-settings').addEventListener('click', function() {
	SettingsToForm();
	document.querySelector('#settings').className = 'current';
	document.querySelector('[data-position="current"]').className = 'left';
});

/**
 * Kereső képernyő megnyitása
 */
document.querySelector('#btn-search').addEventListener('click', function() {
	document.querySelector('#search').className = 'current';
	document.querySelector('[data-position="current"]').className = 'left';
});

/**
 * Keresés kezdése
 */
document.querySelector('#btn-search-start').addEventListener('click',
		function() {
			var text_search = document.querySelector('#text-search').value;
			if (text_search != '') {
				listSearch(text_search);
				// console.log(text_search);
			}

		});

/**
 * Visszagomb a keresésnél.
 */
document
		.querySelector('#btn-search-back')
		.addEventListener(
				'click',
				function() {
					document.querySelector('#search').className = 'right';
					document.querySelector('[data-position="current"]').className = 'current';
				});

document.querySelector('#btn-about-back').addEventListener('click', function() {
	document.querySelector('#about').className = 'right';
	document.querySelector('[data-position="current"]').className = 'current';
});

// beálltások vissza
document
		.querySelector('#btn-settings-back')
		.addEventListener(
				'click',
				function() {
					document.querySelector('#settings').className = 'right';
					document.querySelector('[data-position="current"]').className = 'current';
				});
// about
document.querySelector('#btn-about').addEventListener('click', function() {
	document.querySelector('#about').className = 'current';
	document.querySelector('[data-position="current"]').className = 'left';
});

// note törlés mégsem
document.querySelector('#btn-delete-note-cancel').addEventListener('click',
		function() {
			document.querySelector('#delete-note').className = 'fade-out';
		});

// note törlés rendben
document.querySelector('#btn-delete-note-confirm').addEventListener('click',
		function() {
			window.localStorage.removeItem(current_note_id);
			ListAllNote();
			document.querySelector('#delete-note').className = 'fade-out';
		});

// settings save
document
		.querySelector('#btn-save-settings')
		.addEventListener(
				'click',
				function() {
					SaveSettings();
					document.querySelector('#settings').className = 'right';
					document.querySelector('[data-position="current"]').className = 'current';
				});

// new note header
document
		.querySelector('#btn-header-new-note')
		.addEventListener(
				'click',
				function() {
					document.querySelector('#btn-save-note').style.display = 'block';
					document.querySelector('#btn-edit-note').style.display = 'none';
					current_note_id = 0;
					document.querySelector('#note-title').value = '';
					document.querySelector('#note-content').value = '';
					if (settings.save_start == 1) {
						NewNote();
					}
					/*
					 * if (settings.autosave == 1) { AutoSaveStart(); }
					 */
					document.querySelector('#note').className = 'current';
					document.querySelector('[data-position="current"]').className = 'left';
				});

// note save
document.querySelector('#btn-save-note').addEventListener('click', function() {
	if (settings.autosave == 1) {
		autosave_counter = 0;
		clearInterval(autosave);
	}

	createNote();
	ListAllNote();
	utils.status.show(navigator.mozL10n.get('save-message'));
	document.querySelector('#note').className = 'right';
	document.querySelector('[data-position="current"]').className = 'current';
});
