/* Fonction pour confirmer un lien */
function confirm_link(phrase)
{
	rep=confirm(phrase);
	if(rep)
	{
		return true;
	}
	else
	{
		return false;
	}
}

/* Affichage ou cachage d'un élément mais avec un interrupteur */
function show_hidde_bis(id, inter)
{
	// Traitement de l'id
	if(inter=='on')
	{
		document.getElementById(id).style.display='block';
	}
	else
	{
		document.getElementById(id).style.display='none';
	}
}


/* Affichage ou cachage d'un élément attribut display */
function show_hidde(id, img)
{
	// Traitement de l'id
	if(document.getElementById(id).style.display=='none')
	{
		document.getElementById(id).style.display='block';
	}
	else
	{
		document.getElementById(id).style.display='none';
	}
	
	// Traitement de l'image
	if(img!="")
	{
		if(document.getElementById(id).style.display=='none')
		{
			document.getElementById(img).src='../imgs/plus.gif';
		}
		else
		{
			document.getElementById(img).src='../imgs/moins.gif';
		}
	}
}

/* Affichage ou cachage d'un élément attribut visible */
function visible_hidde(id, inter)
{
	// Traitement de l'id
	if(inter==true)
	{
		
		document.getElementById(id).style.visibility='visible';
	}
	else
	{
		document.getElementById(id).style.visibility='hidden';
	}
}


// Fonction pour afficher un texte par défaut dans un input
function indic_input(inputid, lib)
{
	try
	{
		document.getElementById('inputid').value=lib;
	}
	catch(e)
	{
		alert('schwach.js, fonction indic_input: '+e.message);
	}
}

// Fonction pour effacer le texte d'un input lorsque l'on clic dessus
function clear_input(inputid)
{
	try
	{
		document.getElementById('inputid').value='';
		document.getElementById('inputid').style.color='#000000';
	}
	catch(e)
	{
		alert('schwach.js, fonction clear_input: '+e.message);
	}
}


/* Info bulle dynamique */

/***********************************************
* Cool DHTML tooltip script II- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=15 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip" style="display:none"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="../imgs/structure/arrowpopup.gif" style="display:none">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip



/* Préchargement et fonction des puces du menu */

var isIMG = document.images;
var Bton;
var Btoff;

if (isIMG) {
   Bton = new Image(8,8);
   Bton.src = "../imgs/structure/menu/puce_off.gif";
   Btoff = new Image(10,10);
   Btoff.src = "../imgs/structure/menu/puce_on.gif";
}
function Bt(Arrowname) {
     if (isIMG) {
     document.getElementById(Arrowname).src = (document.getElementById(Arrowname).src.indexOf('imgs/structure/menu/puce_on.gif') != -1) ? '../imgs/structure/menu/puce_off.gif' : '../imgs/structure/menu/puce_on.gif';
     }
}

function Window(mypage, myname, w, h) {
var winl = (screen.width - (w)) / 2;
var wint = (screen.height - (h)) / 2;
var neww = parseInt(w) + parseInt(40);
var newh = parseInt(h) + parseInt(40);
winprops = 'height='+newh+',width='+neww+',top='+wint+',left='+winl+',toolbar=0, location=0, directories=0, status=0, scrollbars=0, resizable=0, copyhistory=0, menuBar=0'
win = window.open(mypage, 'caca', winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

/*
CRYPTAGE DE PAGES WEB
*/


// FONCTIONS DE CODAGE HEXADECIMAL


var codesHexa="0123456789ABCDEF";


function codeHexa (octetDec) // octet décimal ==> hexadécimal
	{
	return (codesHexa.charAt(octetDec>>>4)+codesHexa.charAt(octetDec&15));
	}


function decodeHexa (octetHex) // octet hexadécimal ==> décimal
	{
	return ( (codesHexa.indexOf(octetHex.charAt(0))<<4) + codesHexa.indexOf(octetHex.charAt(1)) );
	}


// FONCTIONS DE CRYPTAGE


var clef="9Ajf0kDhD4GBwnuis1ys1d45br7uyZ"; // Vous pouvez modifier cette clef


function crypte (texte) // texte en clair ==> texte crypté
	{
	resultat="";
	l=texte.length;
	lc=clef.length;

	m=0;
	for (n=0;n<l;n++)
		{
		c=texte.charCodeAt(n);
		if (c<256) // Uniquement les caractères ASCII
			{
     			resultat+=codeHexa( c ^ clef.charCodeAt(m%lc) );
			m++;
			}
		}

	return resultat;
	}


function decrypte (texte) // texte crypté ==> texte en clair
	{
	resultat="";
	l=texte.length;
	lc=clef.length;

	m=0;
	for (n=0;n<l;n+=2)
		{
		c=decodeHexa(texte.substr(n,2));
		resultat+=String.fromCharCode( c ^ clef.charCodeAt(m%lc) );
		m++;
		}
		return resultat;
	}
