// ENVOI FORMULAIRE TAGS
function form_tags_envoi() {
	tags_ok = document.getElementById('form_tags').tags.value;
	tags_ok = tags_ok.replace(/\++/g, '+');
	tags_ok = tags_ok.replace(/(^\+|\+$)/, '');
	tags_ok = tags_ok.replace(/\+/g, '~');
	window.location.href='Chroniques-Tags' + '-' + tags_ok;
}

// NUAGE DE TAGS
function tags_nuage_js(affichage) {
	if (affichage == 'nuage') {
		document.getElementById('affichage_nuage').style.display = 'block';
		document.getElementById('affichage_liste').style.display = 'none';
		document.getElementById('affichage_nuage_btn').rel = 'on';
		document.getElementById('affichage_liste_btn').rel = 'off';
		document.cookie = 'tags_nuage = nuage';
	}
	if (affichage == 'liste') {
		document.getElementById('affichage_nuage').style.display = 'none';
		document.getElementById('affichage_liste').style.display = 'block';
		document.getElementById('affichage_nuage_btn').rel = 'off';
		document.getElementById('affichage_liste_btn').rel = 'on';
		document.cookie = 'tags_nuage = liste';
	}
}

// LISTE DE TAGS
function tags_liste_js () {
	if (document.getElementById('tags_liste').style.display == 'block') {
		$('#tags_liste').slideUp("normal");
	} else {
		$('#tags_liste').slideDown("normal");
	}
}

// AJOUT / SUPPRESSION DE TAG
function tags_clic_js (tag) {
	regex = new RegExp(tag, 'g');
	tags_ok = document.getElementById('formulaire').tags.value;
	if (regex.test(tags_ok)) {
		// Si contient le tag, alors suppression
		tags_ok = tags_ok.replace(regex, '');
	} else {
		// Si ne contient pas le tag, alors rajout
		tags_ok += '+' + tag;
	}
	tags_ok = tags_ok.replace(/\++/g, '+');
	tags_ok = tags_ok.replace(/(^\+|\+$)/, '');
	document.getElementById('formulaire').tags.value = tags_ok;
}

// PREVISUALISATION FORMULAIRE
function form_preview_js () {
	document.getElementById('formulaire').preview.value = 'true';
	document.getElementById('formulaire').submit();
}


// VALIDATION SUPPRESSION
function popup_validation (message, lien) {
	if (confirm(message)) {
		window.location.href = lien;
	}
}

// RECHERCHE TEST
function test_recherche () {
	recherche_categorie = document.getElementById('test_recherche').recherche_categorie.value;
	recherche_nom = document.getElementById('test_recherche').recherche_nom.value;
	// Filtres ?
	document.getElementById('test_recherche').submit();
}

// AJOUTER CATEGORIE (TEST)
function test_nouvelle_categorie () {
	window.location.href = 'Banc_essai-Nouvelle_categorie';
}

// ORDRE TESTS (date ou note)
function test_ordre (ordre) {
	if (ordre == 'date') {
		document.cookie = 'test_ordre = date';
	}
	if (ordre == 'note') {
		document.cookie = 'test_ordre = note';
	}
	window.location.href = 'Banc_essai';
}