function writethis(serveur,appletwidth,appletheight,uniqueupload,maxsize,userid) {
	
	var _info = navigator.userAgent;
	var _ns = false;
	var _ns6 = false;
	var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
	if (_info.indexOf("Opera") > 0) _ie = false;
	var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0) || (_info.indexOf("IRIX") > 0)));
	var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
	if (_ie == true) {
	  document.writeln('<OBJECT classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" WIDTH="'+appletwidth+'" HEIGHT="'+appletheight+'" NAME="clientupload" codebase="http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,4,0,0">');
	}
	else if (_ns == true && _ns6 == false) { 
	  // BEGIN: Update parameters below for NETSCAPE 3.x and 4.x support.
	  document.write('<EMBED ');
	  document.write('type="application/x-java-applet;version=1.4" ');
	  document.write('CODE="javazoom.upload.client.MApplet.class" ');
	  document.write('JAVA_CODEBASE="./" ');
	  document.write('ARCHIVE="lib/jclientupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" ');
	  document.write('NAME="clientupload" ');
	  document.write('WIDTH="'+appletwidth+'" ');
	  document.write('HEIGHT="'+appletheight+'" ');
	  document.write('resources="i18n" ');
	  document.write('maxsize="'+maxsize+'" ');
	  document.write('zipmaxsize="'+maxsize+'" ');
	  document.write('ziponfly="true" ');
	  document.write('url="'+serveur+'/modules/upload.php" ');
	  document.write('forward="'+serveur+'/index.php?module=addnewupload&uniqueupload='+uniqueupload+'&userid='+userid+'" ');
	  document.write('paramfile="uploadfile" ');
	  document.write('param1="todo" ');
	  document.write('value1="upload" ');
	  document.write('param2="errorheader" ');
	  document.write('value2="custommessage" ');
	  document.write('param3="relativefilename" ');
	  document.write('value3="true" ');
	  document.write('param4="userid" ');
	  document.write('value4="'+userid+'" ');
	  document.write('param5="uploadcode" ');
	  document.write('value5="'+uniqueupload+'" ');
	  document.write('folderdepth="-1" ');
	  document.write('mode="http" ');
	  document.write('scriptable=true ');
	  document.writeln('pluginspage="http://java.sun.com/products/plugin/index.html#download"><NOEMBED>');
	  // END
	}
	else {
	  document.writeln('<APPLET CODE="javazoom.upload.client.MApplet.class" JAVA_CODEBASE="./" ARCHIVE="lib/jclientupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar" WIDTH="'+appletwidth+'" HEIGHT="'+appletheight+'" NAME="clientupload">');
	}
	// BEGIN: Update parameters below for INTERNET EXPLORER, FIREFOX, SAFARI, OPERA, MOZILLA, NETSCAPE 6+ support.
	document.writeln('<PARAM NAME=CODE VALUE="javazoom.upload.client.MApplet.class">');
	document.writeln('<PARAM NAME=CODEBASE VALUE="./">');
	document.writeln('<PARAM NAME=ARCHIVE VALUE="lib/jclientupload.jar,lib/httpimpl.jar,lib/chttpclient.jar,lib/clogging.jar">');
	document.writeln('<PARAM NAME=NAME VALUE="clientupload">');
	document.writeln('<PARAM NAME="type" VALUE="application/x-java-applet;version=1.4">');
	document.writeln('<PARAM NAME="scriptable" VALUE="true">');
	document.writeln('<PARAM NAME="url" VALUE="'+serveur+'/modules/upload.php">');
	document.writeln('<PARAM NAME="paramfile" VALUE="uploadfile">');
	document.writeln('<PARAM NAME="param1" VALUE="todo">');
	document.writeln('<PARAM NAME="value1" VALUE="upload">');
	document.writeln('<PARAM NAME="forward" VALUE="'+serveur+'/index.php?module=addnewupload&uniqueupload='+uniqueupload+'&userid='+userid+'">');
	document.writeln('<PARAM NAME="resources" VALUE="i18n">');
	document.writeln('<PARAM NAME="maxsize" VALUE="'+maxsize+'">');
	document.writeln('<PARAM NAME="zipmaxsize" VALUE="'+maxsize+'">');
	document.writeln('<PARAM NAME="ziponfly" VALUE="true">');
	document.writeln('<PARAM NAME="chunksize" VALUE="1500000">');
	document.writeln('<PARAM NAME="param2" VALUE="errorheader">');
	document.writeln('<PARAM NAME="value2" VALUE="custommessage">');
	document.writeln('<PARAM NAME="param3" VALUE="relativefilename">');
	document.writeln('<PARAM NAME="value3" VALUE="true">');
	document.writeln('<PARAM NAME="param4" VALUE="userid">');
	document.writeln('<PARAM NAME="value4" VALUE="'+userid+'">');
	document.writeln('<PARAM NAME="param5" VALUE="uploadcode">');
	document.writeln('<PARAM NAME="value5" VALUE="'+uniqueupload+'">');
	document.writeln('<PARAM NAME="folderdepth" VALUE="-1">');
	document.writeln('<PARAM NAME="mode" VALUE="http">');
	// END
	if (_ie == true) {
	  document.writeln('</OBJECT>');
	}
	else if (_ns == true && _ns6 == false) {
	  document.writeln('</NOEMBED></EMBED>');
	}
	else {
	  document.writeln('</APPLET>');
	}
}

function selectdeselectline(i)
	{
		obj = document.getElementById('ligne'+i);
		if (obj.value.checked)
		{
			obj.value.checked=false;
		}
		else 
		{
			obj.value.checked=true;
		}
		obj2 = document.getElementById('lastselected');
		if (obj2.value == '0')
		{
			obj2.value=document.getElementById('ligneval'+i).value;
		}
		else
		{
			if (obj2.value == document.getElementById('ligneval'+i).value)
			{
				obj2.value='0';
			}
			else
			{
				obj2.value = document.getElementById('ligneval'+i).value;
				//envoi requête
				envoieRequete("loaddetails.php?detailarboid=" + document.getElementById('ligneval'+i).value,"loaddetails");
			}
			
		}
		
		
	}
function envoieRequete(vurl,id,ctl,vcompleteurl)
	{
		var xhr_object = null;
		var position = id;
		
		if (ctl)
		{
			obj2 = document.getElementById('lastselected');
			if (obj2.value > 0){return;}
		}
		
		if(window.XMLHttpRequest) xhr_object = new XMLHttpRequest();
		else
		if (window.ActiveXObject) xhr_object = new ActiveXObject('Microsoft.XMLHTTP');
		
		
		// On ouvre la requete vers la page désirée
		xhr_object.open('GET',vurl, true);
		xhr_object.onreadystatechange = function(){
		if ( xhr_object.readyState == 4 )
		{
		//if(xhr_object.readyState == 4) alert(xhr_object.responseText);
		// j'affiche dans la DIV spécifiées le contenu retourné par le fichier
			document.getElementById(position).innerHTML = xhr_object.responseText;
			if (id=='preparation')
			{
			  envoieRequete('modules/compressionwait.php','compression',false,vcompleteurl);
			  envoieRequete('modules/compression.php','compression',false,vcompleteurl);
			}
			if (vurl=='modules/compression.php')
			{
			  envoieRequete('modules/download.php','download',false,vcompleteurl);
			  //envoieRequete('modules/download2.php','downloadfile',false,vcompleteurl);
			  var _info = navigator.userAgent;
			  var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
			  if (_ie == true)
			  {	
	  		  	
				//obj=document.getElementById('framed');
				//obj.src="http://"+vcompleteurl+"modules/download2.php";
			  	window.location="modules/download2.php";
				//obj.refresh();
			  	//objw=window.open("","_webstocksdownload",'toolbar=no, status=no,menubar=no, width=1, height=1, top=100000, left=100000,screenX=1000000');
				//objw.location="http://"+vcompleteurl+"modules/download2.php";
				
			  }
			  else
			  {
			  	obj=document.getElementById('framed');
				obj.src="http://"+vcompleteurl+"modules/download2.php";
			  }
			  
			}
		}
		}
		// dans le cas du get
		xhr_object.send(null);
		
	}

function getsel()
{
	i=1;
	vURL='';
	nbsel=1;
	//recherche des lignes selectionnees
	while (obj=document.getElementById("ligne"+i))
	{
		if (obj.checked)
		{
			vURL=vURL+'&selected['+nbsel+']='+document.getElementById("ligneval"+i).value;
			nbsel=nbsel+1;
		}
		i=i+1;
	}
	return (vURL);
}

function delsel()
{
	urldel='index.php?module=supprfichier';
	urlsel=getsel();
	if (urlsel == "")
	{
		alert("Rien a été séléctionné");
	}
	else
	{
		urldel=urldel+urlsel;
		document.location=urldel;
	}
		
}

function movsel()
{

	urlmov='index.php?module=deplacerselection';
	urlsel=getsel();
	if (urlsel == "")
	{
		alert("Rien a été séléctionné");
	}
	else
	{
		urlmov=urlmov+urlsel;
		document.location=urlmov;
	}
}

function telsel()
{
	urldel='index.php?module=download3';
	urlsel=getsel();
	if (urlsel == "")
	{
		alert("Rien a été séléctionné");
	}
	else
	{
		urldel=urldel+urlsel;
		document.location=urldel;
	}
		
}

function selallchk()
{
		i=1;
		while (obj=document.getElementById("ligne"+i))
		{
			obj.checked=document.getElementById("selall").checked;
			i=i+1;
		}
}

function imgOver(t)
{
	img = t.src;
	t.src=img.substr(0,img.length-4)+'over.gif';
}

function imgOut(t)
{
	img = t.src;
	t.src=img.substr(0,img.length-8)+'.gif';
}

