/* ---------------------------------------------------------------
	DEMO TEL
 --------------------------------------------------------------- */

function demoTel(cible){

	// Recuperation du contenu
	var myAjax = $.ajax({
		url: cible, 
		type: 'POST',
		success: function(retour){$("#demo_tel").html(retour);},
		complete: function(){
			$("#exemple").attr("style","top:88px;");
			$("#exemple").fadeIn(1500);
			setTimeout('$("div.affichage_cover").fadeOut("slow")', 5000);

			$('#nav_haut').click(function(){
				$('div.affichage_texte').scrollTo({top:'-=200px', left:'0px'}, 800, {axis:'y'});
			});
			$('#nav_bas').click(function(){
				$('div.affichage_texte').scrollTo({top:'+=200px', left:'0px'}, 800, {axis:'y'});
			});

		}
	});
	
}

/* ---------------------------------------------------------------
	TINY MCE
 --------------------------------------------------------------- */
function affichageTinyMce() {
	
	// TINYMCE
	tinyMCE.init({
		mode : "textareas",
		theme : "advanced",
		entity_encoding : "raw",
		//plugins : "safari,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,imagemanager,filemanager",
		plugins : "paste,fullscreen,style",
theme_advanced_buttons1:"styleprops,bold,italic,underline,justifyleft,justifycenter,justifyright,justifyfull,formatselect,removeformat,undo,forecolor,fullscreen,code,link",
		theme_advanced_buttons2:"",
		theme_advanced_buttons3:"",
		theme_advanced_toolbar_location : "top"
	});
	// TINYMCE - ASTUCE IMPORTANTE
	$('#mySubmitButton').click(function() {
		var content = tinyMCE.activeEditor.getContent(); // get the content
		$('#contenu').val(content); // put it in the textarea
	});
	
}
function affichageTinyMceQrCode() {

	// TINYMCE
	tinyMCE.init({
		mode : "exact",
		elements : "contenu",
		theme : "advanced",
		language : "fr",
		entity_encoding : "raw",
		plugins : "spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,contextmenu",
		theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,removeformat,|,forecolor,backcolor",
		theme_advanced_buttons2 : "styleselect,fontselect,fontsizeselect",
		theme_advanced_buttons3 : "image,|,link,unlink,charmap,media",
		theme_advanced_buttons4 : "tablecontrols,|,code",
		theme_advanced_statusbar_location : "",
		theme_advanced_toolbar_location : "top",
		theme_advanced_toolbar_align : "left",
		theme_advanced_resizing : true,

		// Style formats
		style_formats : [
			{title : 'Indentation', block : 'p', classes : 'style_indentation'},
			{title : 'Line-height:14', block : 'p', classes : 'style_line_height_14'}
		]

	});	

}
/* ---------------------------------------------------------------
	GESTION DES FORMULAIRE
 --------------------------------------------------------------- */
function gestionFormulaire(idFormulaire) {
	// AFFICHAGE DU FORMULAIRE
	$("#" + idFormulaire).fadeIn('slow');
	
	// FOCUS SUR LE PREMIER ELEMENT
	$("#" + idFormulaire + " :text:visible:enabled:first").focus();
	
	// SURVOL DES BOUTONS des boutons
	$("#submit input").each(function(){ survolBouton(this); });			
}
/* ---------------------------------------------------------------
	REGLES FORMULAIRES
 --------------------------------------------------------------- */
function regleFormulaire() {
	
	var traitement = $('#traitement').attr('value');
	
	jQuery.validator.addMethod('verificationApple', function(id_apple) {
		   var postURL = "ajax/admin_roman/verification_apple.php";
		   $.ajax({
			   cache:false,
				async:false,
				type: "POST",
				data: "id_apple=" + id_apple + "&traitement=" + traitement,
				url: postURL, dataType: 'json',
				success: function(json) {
					result = (json.message_retour == '0') ? true : false;
				}//,
				//complete: function(json){
				//	var messageAlerte = json.message_alerte;
				//}
			});
			return result;
		}, 'Identifiant déjà utilisé !');

}
/* ---------------------------------------------------------------
	SURVOL DES BOUTONS
 --------------------------------------------------------------- */
function survolBouton(idBouton) {
	$(idBouton).hover(
		function(){
		// Affichage du fonds
			$(idBouton).attr("style","background-position: left bottom;");					
		},
		function(){
			$(idBouton).attr("style","background-position: left top;");					
		}
	);
}
/* ---------------------------------------------------------------
	BOUTONS DU MENU PRINCIPAL
 --------------------------------------------------------------- */
function boutonMenu(idBouton) {
	// Gestion du menu
	$('#menu_principal a').each( function(noeud){ $(this).removeAttr("style");	});
	$('#menu_principal li a span').each( function(noeud){ $(this).removeAttr("style");	});
	$('#menu_principal a').each( function(noeud){ $(this).focus(function() { $(this).blur(); } );	});
	$('#menu_' + idBouton).attr("style", "background-position: left bottom;color:#FFFFFF;");
	$('#menu_' + idBouton + ' span').attr("style", "top:65px;");
}
function boutonMenuxxx() {	
	// Surveillance menu gauche
	$('#menu_principal li a').each( function(noeud){

		// Annule les effets visuels indesirables lors du click
		gestionAncre($(this));

		// Action !
		$(this).click( function(){
			
			// Modification visuelle des elements
			$('#menu_principal li a').attr('style','');
			$(this).css('backgroundPosition','bottom left');
			
		});

	});
}
/* ---------------------------------------------------------------
	GESTION DES ANCRES
 --------------------------------------------------------------- */
function gestionAncre(idAncre) {
	$(idAncre).attr('onclick', 'return false');
	$(idAncre).focus(function() { $(idAncre).blur(); } );
}
/* ---------------------------------------------------------------
	MESSAGES
 --------------------------------------------------------------- */
function affichageMessage(statut , 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 p").fadeIn('normal');
	// Mise en forme css
	$("#zone_message p").addClass(statut);
	
	// Effacement du message le cas échéant
	if(statut == 'success') setTimeout('$("#zone_message p").fadeOut("slow")', 10000);
}
/* ---------------------------------------------------------------
	FONCTIONS A LANCER LORS DU CHARGEMENT DE LA PAGE
 --------------------------------------------------------------- */
$(document).ready(function(){

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