﻿//<!--
/* ******************************************************************************
	INFORMATION :
	Ce fichier est la propriété de la société ELSIMPEX / TECHNICIENS-DU-NET.COM.
	Il fait partit de la suite "manuSCRIPT" qui n'est PAS libre de droits.
	Ce logiciel est protégé et sa copie, même partielle, est ILLICITE.
	Pour toute informations, contactez info@techniciens-du-net.com
   ******************************************************************************/

function sablier()
{
	//e.style.cursor="wait";
	document.body.style.cursor="wait";
	
}
function insertion(repdeb, repfin, textbox) {
  //var input = document.forms['formulaire'].elements['saisie'];
  var input=textbox;
  
  input.focus();
  /* pour l'Explorer Internet */
  if(typeof document.selection != 'undefined') {
    /* Insertion du code de formatage */
    var range = document.selection.createRange();
    var insText = range.text;
    range.text = repdeb + insText + repfin;
    /* Ajustement de la position du curseur */
    range = document.selection.createRange();
    if (insText.length == 0) {
      range.move('character', -repfin.length);
    } else {
      range.moveStart('character', repdeb.length + insText.length + repfin.length);
    }
    range.select();
  }
  /* pour navigateurs plus récents basés sur Gecko*/
  else if(typeof input.selectionStart != 'undefined')
  {
    /* Insertion du code de formatage */
    var start = input.selectionStart;
    var end = input.selectionEnd;
    var insText = input.value.substring(start, end);
    input.value = input.value.substr(0, start) + repdeb + insText + repfin + input.value.substr(end);
    /* Ajustement de la position du curseur */
    var pos;
    if (insText.length == 0) {
      pos = start + repdeb.length;
    } else {
      pos = start + repdeb.length + insText.length + repfin.length;
    }
    input.selectionStart = pos;
    input.selectionEnd = pos;
  }
  /* pour les autres navigateurs */
  else
  {
    /* requête de la position d'insertion */
    var pos;
    var re = new RegExp('^[0-9]{0,3}$');
    while(!re.test(pos)) {
      pos = prompt("Insertion à la position (0.." + input.value.length + "):", "0");
    }
    if(pos > input.value.length) {
      pos = input.value.length;
    }
    /* Insertion du code de formatage */
    var insText = prompt("Veuillez entrer le texte à formater:");
    input.value = input.value.substr(0, pos) + repdeb + insText + repfin + input.value.substr(pos);
  }
}

function on_aide(element)
{
	combo=document.getElementById('insere'+element);
	var balise=combo.options[combo.options.selectedIndex].value;
	var aide="";
	//alert(balise);
	switch(balise)
	{
		case "**~**":
			aide="format";
			break;
		case "//~//":
			aide="format";
			break;
		case "__~__":
			aide="format";
			break;
		case "--~--":
			aide="format";
			break;
		case "''~''":
			aide="format";
			break;
		case "%%~|%%":
			aide="format";
			break;
		case "[[~]]":
			aide="lien";
			break;
		case "[[page|~]]":
			aide="lien";
			break;
		case "[[http://www.~]]":
			aide="lien";
			break;
		case "[[http://www.|~]]":
			aide="lien";
			break;
		case "[[nom|~]]":
			aide="lien";
			break;
		case "<<~<<":
			aide="paragraphe";
			break;
		case ">>~>>":
			aide="paragraphe";
			break;
		case "::~::":
			aide="paragraphe";
			break;
		case "----":
			aide="separateur";
			break;
		case "####":
			aide="separateur";
			break;
		case "{{&~&}}":
			aide="liste";
			break;
		case "{{&ligne 1&ligne 2&}}":
			aide="liste";
			break;
		case "(((~)))":
			aide="tableau";
			break;
		case "((&(~)&()&))":
			aide="tableau";
			break;
		case "((&(~)()&()()&))":
			aide="tableau";
			break;
		case "((&(~)()()&()()()&()()()&))":
			aide="tableau";
			break;
		case ":-)" :
			aide="frimousse";
			break;
		case ";-)" :
			aide="frimousse";
			break;
		case ":-(" :
			aide="frimousse";
			break;
		case ":-p" :
			aide="frimousse";
			break;
		case ":-|" :
			aide="frimousse";
			break;
		case ":-O" :
			aide="frimousse";
			break;
		case ":-D" :
			aide="frimousse";
			break;
		case ":-/" :
			aide="frimousse";
			break;
		case "8-)" :
			aide="frimousse";
			break;
		case ":-))" :
			aide="frimousse";
			break;
		case "!!PAGE_CODE!!" :
			aide="variable";
			break;
		case "!!PAGE_TITRE!!" :
			aide="variable";
			break;
		case "!!PAGE_AUTEUR!!" :
			aide="variable";
			break;
		case "!!PAGE_TYPE!!" :
			aide="variable";
			break;
		case "!!PAGE_DATE!!" :
			aide="variable";
			break;
		default:
			aide="";
	}
	//alert('http://www.techniciens-du-net.com/aide/page_consultation.php?page='+aide);
	if(aide!="")
		window.open('http://www.techniciens-du-net.com/aide/page_consultation.php?page='+aide,'_blank','toolbar=0, location=0, directories=0, status=0, scrollbars=1, resizable=0, copyhistory=0, menuBar=0, width=400, height=500');
}

function on_insere(element)
{
	//alert(element);
	combo=document.getElementById('insere'+element);
	textbox=document.getElementById('p'+element);
	
	var valeur=combo.options[combo.options.selectedIndex].value;
	var elements=valeur.split('~');
	
	var elem0=elements[0].replace(/\&/,"\r");
	while(elem0.lastIndexOf("&")!=-1)
	{
		elem0=elem0.replace(/\&/,"\r");
	}
	
	if(!elements[1])
		insertion(elem0,'',textbox);
	else
		var elem1=elements[1].replace(/\&/,"\r");
		while(elem1.lastIndexOf("&")!=-1)
		{
			elem1=elem1.replace(/\&/,"\r");
		}
		insertion(elem0,elem1,textbox);

}


function page_Prope()
{
	d=document.getElementById('prope');
	if(d.style.display=='none' || d.style.display=='')
	{
		d.style.display='block';
	}
	else
	{
		d.style.display='none';
	}
}

function action_dupliquer()
{
	if(document.forms['f_page_traduction'].elements['page'].options.selectedIndex==-1)
	{
		alert('Vous n\'avez sélectionné aucune page à dupliquer ou à traduire. Veuillez en sélectionner une dans la liste "Traduire/dupliquer une page existante".');
		return false;
	}
	return true;
}


function action_modifier()
{
	if(document.forms['f_page_modification'].elements['page'].options.selectedIndex==-1)
	{
		return confirm('Vous n\'avez sélectionné aucune page à modifier.\nVoulez-vous commencer l\'édition d\'une nouvelle page ?');
	}
	return true;
}

function action_supprimer()
{
	if(document.forms['f_page_suppression'].elements['page'].options.selectedIndex==-1)
	{
		alert('Veuillez sélectionner une page à supprimer dans la liste "Effacer une page existante".');
		return false;
	}
	return 	confirm('Voulez-vous supprimer définitivement cette page ?');
}

function action_supprimer_modele()
{
	if(document.forms['f_page_suppression_modele'].elements['page'].options.selectedIndex==-1)
	{
		alert('Veuillez sélectionner un modèle à supprimer dans la liste "Effacer un modèle existant".');
		return false;
	}
	return 	confirm('Voulez-vous supprimer définitivement ce modèle ?');
}

function page_ProprieteTesteDate(champ)
{
	if(champ.value!="")
		if(champ.value.search(/^[0-9]{2}\/[0-9]{2}\/[0-9]{2,4}$/)==-1)
		{
			alert("Merci de bien vouloir formater les dates sous la forme : jj/mm/aaaa !");
			champ.focus();
		}
		else
		{
			var date=champ.value.match(/\d{2,4}/g);
			if(eval(date[0])>31 || eval(date[1])>12)
			{
				alert("La date proposée est invalide !\nMerci de bien vouloir formater les dates sous la forme : jj/mm/aaaa !");
				champ.focus();
			}
		}
}



//-->
