/* ---------------------------------------------------------------
	AJUSTER LA TAILLE DE LA POLICE
 --------------------------------------------------------------- */
function ajusterTaillePolice(){
// id, classe ou balise HTML dont la fonte est modifiable dans ce tableau
	// indiquez html ou body si vous voulez modifier toute la page
	var section = new Array('.ajust');
	section = section.join(',');

	// Restaurer la taille
	var originalFontSize = $(section).css('font-size');  
	$(".resetFont").click(function(){
		$(section).css('font-size', originalFontSize);
	});
	// Augmenter la taille
	$(".increaseFont").click(function(){
		var currentFontSize = $(section).css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*1.1;
		$(section).css({'font-size' : newFontSize , 'line-height' : newFontSize * 1.5 + 'px'});
		return false;
	});
  
	// Diminuer la taille
	$(".decreaseFont").click(function(){
		var currentFontSize = $(section).css('font-size');
		var currentFontSizeNum = parseFloat(currentFontSize, 10);
		var newFontSize = currentFontSizeNum*0.9;
		$(section).css({'font-size' : newFontSize , 'line-height' : newFontSize * 1.5 + 'px'});
		return false;
	});
}
/* ---------------------------------------------------------------
	COMMENTAIRES
 --------------------------------------------------------------- */
function affichageCommentaire(categorie){
	categorie_commentaire = categorie;
	var myAjax = $.ajax({
		url: 'ajax/commentaire/' + categorie_commentaire + '/commentaire.php',
		type: 'POST',
		success: function(retour){$('#zone_commentaire').html(retour);},
		complete: function(){
			// Affichage du nombre de commentaire
			$('span#ancre_nbre_commentaire').text($('span#nbre_commentaire').text());
			
			// Gestion des censures
			if($("table.commentaire th.action").length > 0){
				$('table.commentaire th.action a').each( function(noeud){	
					$(this).click( function(){
						// Ligne impactée
						var tabCommentaire = $(this).attr('href').split('?');
						var idCommentaire = tabCommentaire[1];
												
						// Session
						var myAjax = $.ajax({
							url: 'ajax/commentaire/' + categorie + '/censure.php',
							type: 'POST',
							data: 'idCommentaire=' + idCommentaire,
							complete: function(){
								affichageCommentaire(categorie);
							}
						});
						return false;
					});
						
				});
			}

			// Si le visiteur est connecté
			if($("#fml_ins_commentaire").length > 0){
				// Gestion des abonnements
				$('a#abonnement_ok').click(function(){
					loader30('#abonnement_commentaire p.action');
					var myAjax = $.ajax({
						url: 'ajax/commentaire/' + categorie_commentaire + '/abonnement.php',
						data: 'choix=ok',
						type: 'POST',
						complete: function(){
							affichageCommentaire(categorie_commentaire);
						}
					});
					return false;
				});
				$('a#abonnement_ko').click(function(){
					loader30('#abonnement_commentaire p.action');
					var myAjax = $.ajax({
						url: 'ajax/commentaire/' + categorie_commentaire + '/abonnement.php',
						data: 'choix=ko',
						type: 'POST',
						complete: function(){
							affichageCommentaire(categorie_commentaire);
						}
					});
					return false;
				});

				// Affichage du TinyMce
				affichageTinyMceCommentaire();			

				// Controle avant validation
				$("#fml_ins_commentaire").validate({
					debug: true,
	  				submitHandler: function(form) {
						var options = { 
							url: 'ajax/commentaire/' + categorie_commentaire + '/ins_commentaire.php', 
							type: 'post', dataType: 'json',
							beforeSubmit: loader30('#validation'),
							complete: function(){
								affichageCommentaire(categorie_commentaire);
							}
						}; 
						$("#fml_ins_commentaire").ajaxSubmit(options); 
						return false; 
				   }
				});
			}

		}
	});
}
/* ---------------------------------------------------------------
	ALBUM PHOTO
 --------------------------------------------------------------- */
function albumPhoto(categorie){
	$('#zone_multimedia').hide();
	
	// Affichage de la page
	var myAjax = $.ajax({
		url: 'ajax/phototheque/photo_' + categorie + '.php',
		type: 'POST',
		success: function(retour){$('#zone_multimedia').html(retour);},
		complete: function(){
			$('#zone_multimedia').fadeIn('slow');

			// Initially set opacity on thumbs and add
			// additional styling for hover effect on thumbs
			var onMouseOutOpacity = 0.3;
			$('#thumbs ul.thumbs li').opacityrollover({
				mouseOutOpacity:   onMouseOutOpacity,
				mouseOverOpacity:  1.0,
				fadeSpeed:         'fast',
				exemptionSelector: '.selected'
			});
			
			// Initialize Advanced Galleriffic Gallery
			var gallery = $('#thumbs').galleriffic({
				delay:                     5000,
				numThumbs:                 11,
				preloadAhead:              11,
				enableTopPager:            false,
				enableBottomPager:         true,
				maxPagesToShow:            20,
				imageContainerSel:         '#slideshow',
				controlsContainerSel:      '#controls',
				captionContainerSel:       '#caption',
				loadingContainerSel:       '#loading',
				renderSSControls:          true,
				renderNavControls:         true,
				playLinkText:              '&rsaquo;&rsaquo; Diaporama',
				pauseLinkText:             '|| Pause',
				prevLinkText:              '&lsaquo; Précédente',
				nextLinkText:              'Suivante &rsaquo;',
				nextPageLinkText:          '&rsaquo;',
				prevPageLinkText:          '&lsaquo;',
				enableHistory:             false,
				autoStart:                 false,
				syncTransitions:           true,
				defaultTransitionDuration: 900,
				onSlideChange:             function(prevIndex, nextIndex) {
					// 'this' refers to the gallery, which is an extension of $('#thumbs')
					this.find('ul.thumbs').children()
						.eq(prevIndex).fadeTo('fast', onMouseOutOpacity).end()
						.eq(nextIndex).fadeTo('fast', 1.0);
				},
				onPageTransitionOut:       function(callback) {
					this.fadeTo('fast', 0.0, callback);
				},
				onPageTransitionOut:       function(callback) {
					this.fadeTo('fast', 0.0, callback);
				},
				onPageTransitionIn:        function() {
					this.fadeTo('fast', 1.0);
				}
			});
			$('a').focus(function() { $('a').blur(); } );
		}
	});
}
/* ---------------------------------------------------------------
	MENU ON OFF
 --------------------------------------------------------------- */
function menuOn(idMenu) {
	// Affichage du loader
	$('#' + idMenu).append('<img class="loader" src="multimedia/site/loader_666.gif" />');
}
function menuOff(idMenu) {
	// Suppression du loader et affichage du repere
	$('#' + idMenu + ' img.loader').remove();
	$('#' + idMenu).append('<img class="selected" src="multimedia/site/menu_selected.png" />');
}
function menuOffAdm(idMenu) {
	// Suppression du loader et affichage du repere
	$('#' + idMenu + ' img.loader').remove();
	$('#' + idMenu).append('<img class="selected" src="multimedia/site/menu_selected_adm.png" />');
}
/* ---------------------------------------------------------------
	TINY MCE
 --------------------------------------------------------------- */
function affichageTinyMceNew() {
	tinyMCE.init({
	        // General options
	        mode : "textareas",
	        theme : "advanced",
	        plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

	        // Theme options
	        theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
	        theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
	        theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
	        theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
	        theme_advanced_toolbar_location : "top",
	        theme_advanced_toolbar_align : "left",
	        theme_advanced_statusbar_location : "bottom",
	        theme_advanced_resizing : true,
	
	        // Skin options
	        skin : "o2k7",
	        skin_variant : "silver",
	
	        // Example content CSS (should be your site CSS)
	        content_css : "css/example.css",
	
	        // Drop lists for link/image/media/template dialogs
	        template_external_list_url : "js/template_list.js",
	        external_link_list_url : "js/link_list.js",
	        external_image_list_url : "js/image_list.js",
	        media_external_list_url : "js/media_list.js",
	
	        // Replace values for the template plugin
	        template_replace_values : {
	                username : "Some User",
	                staffid : "991234"
	        }
	});

}

function affichageTinyMce() {
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		entity_encoding : "raw",
		plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		theme_advanced_buttons1 : "fontsizeselect,|,justifyleft,justifycenter,justifyright,justifyfull,|,bold,italic,underline,strikethrough,forecolor,media,|,removeformat,|,link,unlink,|,fullscreen,code",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true
	});	
}

function affichageTinyMceSmall() {
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		entity_encoding : "raw",
		plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true
	});	
}
function affichageTinyMceCommentaire() {
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		entity_encoding : "raw",
		plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,emotions",
		theme_advanced_buttons2 : "",
		theme_advanced_buttons3 : "",
		theme_advanced_buttons4 : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_statusbar_location : "bottom",
		theme_advanced_resizing : true
	});	
}
/* ---------------------------------------------------------------
	LOADER
 --------------------------------------------------------------- */
function loaderAdmin(){
	$('table.action tr td span').html('<img src="multimedia/site/loader_666.gif"/>');
	$('table.action tr td input.submit').hide();
}
function loader30(cible){
	$(cible).html('<img src="multimedia/site/loader_666.gif"/>');
}

/* ---------------------------------------------------------------
	MESSAGES
 --------------------------------------------------------------- */
function affichageMessage(typeMessage , message){
	// Nettoyage de la zone
	$("#zone_message p").html('');
	$("#zone_message p").removeClass()
	// Insertion du message
	$("#zone_message p").html(message);
	// Affichage du message
	$("#zone_message").fadeIn('normal');
	// Mise en forme css
	$("#zone_message p").addClass(typeMessage);
	
	// Effacement du message le cas échéant
	if(typeMessage == 'msg_success') setTimeout('$("#zone_message").fadeOut("slow")', 5000);
	if(typeMessage == 'msg_error') setTimeout('$("#zone_message").fadeOut("slow")', 5000);
}
/* ---------------------------------------------------------------
	FONCTIONS A LANCER LORS DU CHARGEMENT DE LA PAGE
 --------------------------------------------------------------- */
$(document).ready(function(){
	// Supprime le cadre lors du click sur un lien	
	$('a').focus(function() { $('a').blur(); } );

});
// -------------------------------------------------------------
