// JavaScript Document

jQuery.noConflict();

var txtDown1 = "";
var txtDown2 = "";

function changeLangue(sLangue)
{
	jQuery("#lang_menu").load("chgLangue.asp", {LG: sLangue}, function()
 	{
		document.location.reload();
  	});
}

function changeLangueNL(sLangue)
{
	jQuery("#lang_menu").load("chgLangue_non_loggue.asp", {LG: sLangue}, function()
 	{
		document.location.reload();
  	});
}

function Connexion()
{
	jQuery("#connexion_message").load("user_droit.asp", jQuery("#connexion").serializeArray(), function(retour)
	{																										   
		if (retour == 'OK')
		{document.connexion.submit();}
		
		if (retour == 'admin')
		{document.location.href='bases/start.asp';}
			
	});
}
function ConnexionRenew()
{
	jQuery("#connexion_message").load("ow_renew.asp", jQuery("#renew").serializeArray(), function(retour)
	{																										   
		
			
	});
}

function addPanier(sLabel, sEnreg, sClasseur, sDoc)
{
	jQuery("#left_panier_div").load("ajx_chutier.asp", {enreg: sEnreg, classeur: sClasseur, doc: sDoc, CMD: 'ADD', label:sLabel}, function()
 	{
		menu_open('2');
  	});
}

function delPanier(fonds, sEnreg, sClasseur, sDoc)
{
	jQuery("#left_panier_div").load("ajx_chutier.asp", {enreg: sEnreg, classeur: sClasseur, doc: sDoc, CMD: 'DEL', fonds:fonds}, function()
 	{
		document.location.reload();
		menu_open('2');
		
  	});
	
}

function viderPanier()
{
	if (confirm(txtViderPanier)) jQuery("#left_panier_div").load("ajx_chutier.asp", {CMD: 'VIDER'},  function()
 	{
		document.location.reload();
		menu_open('2');
  	});
}

function delSelection(sSelectionId)
{
	if (confirm(txtSupprimerSelection)) jQuery("#left_panier_div").load("del_selection.asp", {selid: sSelectionId},  function()
 	{
		document.location.reload();
		menu_open('2');
  	});
}

function telechargerSelection(sID, sTaille)
{
	window.setTimeout('telechargerSelectionAct(\'' + sID + '\', \'' + sTaille + '\')',1000);
}

function telechargerSelectionAct(sID, sTaille, sAvecFiche, sLG, sBase)
{
	var mText=''
	if (sLG=='FR')
		{
			document.getElementById("downloaddiv").innerHTML = "<img src='images/ajax-loader.gif'><br /><span style='font-family:Arial, Helvetica, sans-serif;font-size:14px;color:#0E0E0E;line-height:10px;'>T&eacute;l&eacute;chargement en cours</span>";
			mText = 'Cliquer sur le lien pour t&eacute;l&eacute;charger';
		}
	
	if (sLG=='EN')
		{
			document.getElementById("downloaddiv").innerHTML = "<img src='images/ajax-loader.gif'><span style='font-family:Arial, Helvetica, sans-serif;font-size:14px;color:#0E0E0E;line-height:10px;'>Download in progress</span>";
			mText = 'Clic here for download';
		}
	
	if (sLG=='ES')
		{
			document.getElementById("downloaddiv").innerHTML = "<img src='images/ajax-loader.gif'><span style='font-family:Arial, Helvetica, sans-serif;font-size:14px;color:#0E0E0E;line-height:10px;'>Descarga en curso</span>";
			mText = 'Clic aqui para descargar';
		}
	jQuery("#downloaddiv").load("sel_zipact.asp?ID="+sID+"&taille="+sTaille+"&avecfiche="+sAvecFiche+"&base="+sBase, {}, function(retour)
	{																										   
		 window.open(retour);
		 document.getElementById("downloaddiv").innerHTML = "<span class='telecharger_black_text2'><br><a href='"+retour+"'>" + mText +"</a></span>";
	});
	
}

function writetostatus(input){
    window.status=input;
    return true;
}

function partagerSelection(sID, sLabel)
{
	val = prompt('Entrer l\'email de l\'utilisateur : ','');
	if (val != null)
	jQuery("#downloaddiv").load("add_partage.asp", {ID: sID, label: sLabel, email:val}, function(retour)
	{																										   
		 document.getElementById("downloaddiv").innerHTML = "";
		 if(retour == "OK") document.location.reload();
		 else alert(retour);
		 
	});
	else
	{
		alert('Vous devez saisir un email');
	}
}


function envoyerSelection(sID)
{
	val = prompt('Entrer l\'email de l\'utilisateur : ','');
	if (val != null)
	jQuery("#downloaddiv").load("envoyer_ami.asp", {nochutier: sID, destinataire:val, html:'1'}, function(retour)
	{																										   
		 document.getElementById("downloaddiv").innerHTML = "";
		 if(retour == "OK") document.location.reload();
		 else alert(retour);
		 
	});
	else
	{
		alert('Vous devez saisir un email');
	}
}

function envoyerImage(sEnreg, sClasseur)
{
	val = prompt('Entrer l\'email de l\'utilisateur : ','');
	if (val != null)
	jQuery("#downloaddiv").load("envoyer_image_ami.asp", {enreg: sEnreg, classeur: sClasseur, destinataire:val, html:'1'}, function(retour)
	{																										   
		 document.getElementById("downloaddiv").innerHTML = "";
		 if(retour == "OK") document.location.reload();
		 else alert(retour);
		 
	});
	else
	{
		alert('Vous devez saisir un email');
	}
}

function delPartage(sID)
{
	jQuery("#downloaddiv").load("del_partage.asp", {ID: sID, acc: 'del'}, function(retour)
	{																										   
		 document.getElementById("downloaddiv").innerHTML = "";
		 document.location.reload();
	});
}

function afficheDossierPartage()
{
	jQuery("#shared_dossiers_div").load("dossier_partage.asp", {}, function(retour)
	{																										   
/*		 document.getElementById("downloaddiv").innerHTML = "";
		 document.location.reload();
		 */
	});
}

function perdupass()
{
	val = prompt('Entrer votre email : ','');
	if (val != null || val=="")
	jQuery("#action").load("perdu_pass_act.asp", {email:val}, function(retour)
	{																										   
		 document.getElementById("action").innerHTML = "";
		 if(retour == "OK") alert("Dans un instant vous allez recevoir un email avec les informations de votre compte.");
		 else alert(retour);
		 
	});
	else
	{
		alert('Vous devez saisir un email');
	}
}

function Inscription()
{
	hide_forms();
	jQuery("#connexion_message").load("inscription_act.asp", jQuery("#inscription_form").serializeArray(), function(retour)
	{																										   
		if (retour == 'OK') alert('Votre inscription est en cours de traitement');
		else alert(retour);
		document.getElementById("connexion_message").innerHTML = "";
	});
}