function fermeEnvoiAmis(){
	$('#envoiAmis').animate({ opacity: 'hide' }, 'slow');
	$('#envoiAmis').DraggableDestroy();
	}
		
function afficheEnvoiAmis(kelFavoris,typeEnvoi){
	$.get('formEnvoiAmis.php' , { idFavoris : kelFavoris, typeEnvoi : typeEnvoi }, function(text){ 
		document.getElementById('envoiAmisTxt').innerHTML = text;
		scrolling=document.body.scrollTop;
		document.getElementById('envoiAmis').style.top = (scrolling+150);
		
		$('#envoiAmis').animate({ opacity: 'show' }, 'slow');
		$('#envoiAmis').Draggable({ zIndex:1000, handle:'#moveBar' });
		})
	}
		
function envoiAmis(koi){
	kelForm = document.getElementById('formAmis');
	typeEnvoi = kelForm.TYPEENVOI.value;
	//alert(koi+" "+typeEnvoi);
	switch(typeEnvoi){
		case "fiche" :		kelFavoris = '';
							kelFiche = koi;
							break;
		case "favourites" :	kelFavoris = '';
							kelFiche = koi;
							break;
		default :			kelFavoris = '';
							kelFiche = '';
							break;
	}
	message = "";
	if(kelForm.NOM.value == ""){
		message += "\n- Your name";
		}
	if(kelForm.EMAIL1.value == ""){
		message += "\n- Your e-mail address";
		}
	if(kelForm.EMAIL2.value == ""){
		message += "\n- E-mail address of your friend";
		}
	if(kelForm.TEXTE.value == ""){
		message += "\n- Your message";
		}
	if(message){
		alert("Incomplet Form :"+message);
		}else{
		TABTEXTE = kelForm.TEXTE.value.split('\n');
		TEXTE = "";
		for(i=0;i<TABTEXTE.length;i++){
			if(TEXTE!="") TEXTE += "[retour]";
			TEXTE += TABTEXTE[i];
			}
		//text = file('envoiAmis.php?idFiche='+kelFavoris+'&idssfamille='+kelFam+'&NOM='+kelForm.NOM.value+'&TEXTE='+TEXTE+'&EMAIL1='+kelForm.EMAIL1.value+'&EMAIL2='+kelForm.EMAIL2.value);
		$.get('envoiAmis.php' , { idFavoris : kelFavoris, idFiche : kelFiche, typeEnvoi : typeEnvoi, NOM : kelForm.NOM.value, TEXTE : TEXTE, EMAIL1 : kelForm.EMAIL1.value, EMAIL2 : kelForm.EMAIL2.value }, function(text){ 
			fermeEnvoiAmis();
			//alert(text);
			if(text == "true"){
				alert("Message send !");
				}else{
				//alert(text);
				}
			});
		}
	}