function menuHide()
{
	$('page').setStyle({
		'margin-left': '0px'
	});
	$('menu').hide();
	$('menu_bouton').update('<a href="#" Onclick="menuShow();">&rarr; M E N U</a>');
}
function menuShow()
{
	$('page').setStyle({
		'margin-left': '150px'
	});
	$('menu').show();
	$('menu_bouton').update('<a href="#" Onclick="menuHide();">&larr; M E N U</a>');
}
function ouvrirPopup(url, titre)
{
	popup = new Window({className: "difuxpopup", title: titre, width:500, height:450, destroyOnClose: true, recenterAuto:false}); 
	popup.setAjaxContent(url); 
	popup.showCenter();
}
function fermerPopup()
{
	popup.destroy();
}
function ouvrirDétail(id, url)
{
	$(id).show();
	new Ajax.Updater(id, url), {evalScripts: true};
}
function fermerDétail(id)
{
	$(id).hide();
	new Ajax.Updater(id, 'aide.php');
}
function submitFormulaire(url, idpopup)
{
	$('patience').show();
	texte=$('formPopup').serialize();
	new Ajax.Updater(idpopup, url, {
		 		 evalScripts: true, 
		 		 method: 'post', 
		 		 parameters: texte,
		 		 onFailure: function() { alert('Erreur submitFormulaire'); } 
		 		 });
}
function confirmationSupUni(url, nom, parameters)
{
	if (confirm("Etes-vous sûr de vouloir supprimer " + nom + "?"))
	{
		new Ajax.Updater('page', url, {
						evalScripts: true, 
						method: 'post', 
						parameters: 'suppressionUni=' + parameters,
						onFailure: function() { alert('Erreur confirmationSupUni'); } 
						});
	}
}
function confirmationSupMas(url)
{
	if (confirm("Etes-vous sûr de vouloir supprimer la sélection?"))
	{
		check=Form.serializeElements( $('formulaire').getInputs('checkbox') );
		new Ajax.Updater('page', url, {
						evalScripts: true, 
						method: 'post', 
						parameters: 'suppressionMas=true&' + check,
						onFailure: function() { alert('Erreur confirmationSupUni'); } 
						});
	}
}
function inverSelectionner(form)
{
	var input = document.forms[form].getElementsByTagName("input");
	var tr = document.forms[form].getElementsByTagName("tr");
	for ( var cpt = 0; cpt < input.length; cpt++)
		if (input[cpt].checked == true)
		{
			input[cpt].checked = false ;
		}
		else if (input[cpt].checked == false)
		{
			input[cpt].checked = true ;
		}
	for ( var cpt = 0; cpt < tr.length; cpt++)
		if (tr[cpt].className == "select")
		{
			tr[cpt].className=  "pasSelect";
		}
		else if (tr[cpt].className == "pasSelect")
		{
			tr[cpt].className=  "select";
		}
	return true;
}
function selectionTr(element)
{
	if (document.getElementById(element).checked == true)
	{
		document.getElementById(element).checked= false;
		document.getElementById("tr" + element).className= "pasSelect";
	} 
	else if (document.getElementById(element).checked == false)
	{
		document.getElementById(element).checked= true;
		document.getElementById("tr" + element).className= "select";
	}	
	return true;
}
function ajoutDocumentType(chemin, onglet)
{
	typeDocument=document.getElementById('typeDocument').value;
	$('documentUpload').show();
	$('delais').hide();
	if (onglet == undefined)
	{
		onglet = "navigateur";
	}
	if (typeDocument == 1 || typeDocument == 2)
	{
		instruction='<div id="onglet"><ul><li>2 méthodes : </li><li><a onclick="ajoutDocumentType(\'' + chemin + '\', \'navigateur\');" href="#">Navigateur</a></li><li><a onclick="ajoutDocumentType(\'' + chemin + '\', \'webdav\');" href="#">WebDav</a></li></ul></div>';
		if (typeDocument == 1)
		{
			instruction=instruction+'<p>Les fichiers supporté : avi, mov, mpeg, wmv, flv</p>';
		}
		else
		{
			instruction=instruction+'<p>Les fichiers supporté : Photo (jpg, jpeg, png) Diaporama OpenOffice (odp) PDF</p>';
			$('delais').show();
		}
		if (onglet == "webdav")
		{
			instruction=instruction+'<p><b>Pour transfèrer votre document vous devez : </b></p>';
			instructionLinux='<p>Utiliser des explorateurs de fichiers qui savent également faire navigateur web pour faire une connexion WebDAV. <br />Exemple avec <b>Konqueror</b>, il suffit de taper l\'adresse <input type="text" size="50" value="webdav://' + chemin + '" /> \n<br />Dans <b>Nautilus</b>, rendez vous à l\emplassement  <input type="text" size="50" value="dav://' + chemin + '" /></p>';
			instructionMac='<p>Depuis le Finder, faire pomme+K puis entrer l\'URL WebDAV : <input type="text" size="320" value="http://' + chemin + '" /></p>';
			instructionWin='<p>Ouvrir l\'explorateur windows et indiquer dans la barre d\'adresse : <input type="text" size="32" value="\\\\' + chemin + '" /></p>';
			if (checkIt('x11')) instruction=instruction+instructionLinux;
			else if (checkIt('mac')) instruction=instruction+instructionMac;
			else if (checkIt('win')) instruction=instruction+instructionWin;
			else instruction=instruction+'<i>Pour Linux:</i>'+instructionLinux+'<i>Pour Windows:</i>'+instructionWin+'<i>Pour Mac:</i>'+instructionMac;
			instruction=instruction+'<p>Enfin copier votre document directement dans ce répertoire (sans créer de dossier)</p>';
		}
		else
		{
			instruction=instruction+'<iframe src="document.php?action=upload&type='+ typeDocument +'&chemin='+ chemin +'" width="440" height="150" marginheight="0" marginwidth="0" frameborder="0"></iframe>';
		}
		$('documentUpload').update(instruction);
	}
	else if (typeDocument == 3)
	{
		instruction='<p>Vous devez entrer le contenu du message textuel dans la fenêtre qui viens de s\'ouvrir.</p>';
		instruction=instruction+'<p><small>Si la fenêtre ne c\'est pas ouverte <a href="#" onclick="window.open(\'document.php?action=formTexte&chemin=' + chemin + '\', \'formTexte\', \'top=0, left=0, toolbar=no, status=no, scrollbars=yes, resizable=yes, width=\' + screen.width + \',height=\' + screen.height); return false;">cliquer ici</a></small></p>';
		$('documentUpload').update(instruction);
		window.open('document.php?action=formTexte&chemin=' + chemin, 'formTexte', 'top=0, left=0, toolbar=no, status=no, scrollbars=yes, resizable=yes, width=' + screen.width + ',height=' + screen.height); 		
	}
	$('documentUpload').innerHTML
}
/* Pour la détection des navigateur et OS : http://www.misfu.com/static/Javascript/detect.html */
function checkIt(string)
{
	var detect = navigator.userAgent.toLowerCase();
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}

