/* * * * * * * * * * * * * * * *
*		NAVIGATION :
* 	On donne l'id de l'onglet 
*/

var mediatek_path = '/gestion/mediatek/';

function showTab (tab_id, media_url) {
	// cacher le contenu et afficher le 'ajax loader'
	//jQuery("#mediatek_box").hide();
	jQuery("#mediatek_ajaxloading").show();
	// rendre l'onglet courant en 'non sélectionné'
	jQuery("#mediatek_tabs .selected").removeClass('selected');
	// sélectionner l'onglet clické :
	jQuery("#mediatek_tab"+tab_id).addClass('selected');
	jQuery("#mediatek_tab"+tab_id).blur();
	// charger le contenu :
	//alert(mediatek_path + media_url);
	jQuery.ajax({
		url: mediatek_path + media_url,
		type: 'GET',
		success: function(msg) {
			//alert(msg);
			jQuery('#mediatek_box').html( msg );
			jQuery("#mediatek_ajaxloading").hide();
			//jQuery("#mediatek_box").fadeIn("slow");
			//jQuery("#mediatek_box").show();
			mediatek_testHeight();
		}
	});
	return false;
}

function mediatek_testHeight() {
	if (jQuery("#mediatek_box").height() > 425) {
		jQuery("#mediatek").height('auto');
	}
	else jQuery("#mediatek").height('450px');
}

/* * * * * * * * * * * * 
 *	SELECTION MULTIPLE :
 * * * * * * * * * * * */

function mediatek_selectAll(val) {
	// val = 1 (true) ou 0 (false)
	var res = false;
	if (val == 1) res = true;
	var tab = document.getElementById('img_list').getElementsByTagName('input');
	for (var i=0; i<tab.length; i++) { tab[i].checked = res; }
	mediatek_imgSelect(); // tourner le bouton en VERT ou GRIS
}

function mediatek_enableMoveTo(val) {
	if (val==2) { jQuery("#mediatek_id_folder").removeAttr("disabled"); }
	else { jQuery("#mediatek_id_folder").attr("disabled", "disabled"); }
}

function mediatek_imgSelect() {	// Cette fonction test si on doit afficher ou non le bouton 'OK' (actions multi-selection)
	var buttonOK = 0;
	var tab = document.getElementById("img_list").getElementsByTagName("input");
	for (i=0; i<tab.length; i++) {
		if (tab[i].checked) buttonOK = 1;
	}
	if (buttonOK == 1) {
		jQuery("#buttonActionAll").attr('src', mediatek_path+'img/button_ok_vert.jpg');	
	}
	else {
		jQuery("#buttonActionAll").attr('src', mediatek_path+'img/button_ok_gris.jpg');
	}
}

function mediatek_actionSelected() { // Réalise l'action choisie sur les fichiers sélectionnés
	// Trouver les images sélectionnées :
	var id_list = "";
	var tab = document.getElementById("img_list").getElementsByTagName("input");
	for (i=0; i<tab.length; i++) {
		if (tab[i].checked) id_list += tab[i].value + ",";
	}
	
	if (id_list != "") id_list = id_list.substr(0,id_list.length-1); // supprime la derniere virgule
	else return; // si la liste est vide on n'effectue aucune action, on quitte simplement.
	
	var choice = jQuery('#mediatek_id_option').val();
	switch (choice) {
		case "1":	mediatek_action('del', jQuery('#folder_current').val(), id_list);
					break;
		case "2":	mediatek_action('move', jQuery('#mediatek_id_folder').val(), id_list);
					break;
		case "3":	showTab(
						1,
						"contenu/images_ajouterblog_multi.php?fid=" + jQuery('#folder_current').val()
						+ "&pid=" + id_list
					);
					break;
	}
}


function delete_shared_videos(id, title){
	if(window.confirm('Voulez-vous supprimer la vid\351o \' '+title+' \'?')){
		var result = file('/gestion/traitement/manage_videos.php?act=d&idv='+id); //Voir dans la fction treat_video() depuis videos.tpl
		
		if('done'==result){
			document.getElementById('media_vid_'+id).style.display='none'; //On cache la video depuis la videotheque
			if(document.getElementById('line_'+id)) document.getElementById('line_'+id).style.display='none'; //On cache la video sur la page des videos partagees si on est dessus
		}
		else{
			display_win_error('');
		}
	}
	else{
		return false;
	}
}


function mediatek_action(action, folder, id) {
	var action_url = "";
	switch (action) {
		case "del":		action_url = "contenu/fct_images_actions.php?action=del&id=" + id
						+ "&fid=" + folder;
						break;
		case "move":	action_url = "contenu/fct_images_actions.php?action=move&id=" + id
						+ "&fid=" + folder;
						break;
		case "addinblog":	var html2insert = charger_dans_editeur(
								jQuery('#mediatek_param_vpos').val(),
								jQuery('#mediatek_param_vsize').val(),
								jQuery('#mediatek_param_vurl').val(),
								jQuery('#mediatek_param_vsizemax').val(),
								jQuery('#mediatek_param_vsizereal').val()
							);
							insertObject( html2insert );
						break;
		case "addinblog_multi":	var vpos = jQuery('#mediatek_param_vpos').val(); // position choisie par l'utilisateur
								var html2insert = '';
								jQuery.each(
									jQuery('#img_list img'), function() {
										var vsize = jQuery('#mediatek_param_vsize').val(); // taille choisie par l'utilisateur
										var id = this.id.substr(3,10);
										var vsizemax = jQuery('#sizemax_'+id).val(); // taille max de l'image
										
										if (mediatek_imgSizeCompare(vsizemax,vsize)>0) vsizemax = vsize;
										while ((mediatek_imgSizeCompare(vsizemax,vsize)<0) && (vsize != -1)) {
											vsize = mediatek_imgSizeReduce(vsize);
										}
										
										if (vsize != 0) html2insert = html2insert + charger_dans_editeur(
																jQuery('#mediatek_param_vpos').val(),
																vsize,
																jQuery('#url_'+id).val(),
																vsize,
																0
															);
									}
								);
								insertObject( html2insert );
								break;
		case "img_edt":		action_url = "contenu/fct_images_actions.php?action=img_edt&id=" + id
						+ "&fid=" + jQuery("#id_folder").val()
						+ "&new_name=" + jQuery("#fname_id").val()
						+ "&new_description=" + jQuery("#description_id").val();
						break;
		case "dir_create":	action_url = "contenu/fct_images_actions.php?action=dir_create"
						+ "&fname=" + jQuery('#fname').val()
						+ "&fgallerie=" + jQuery('#fgallerie').val()
						+ "&fdesc=" + jQuery('#fdesc').val()
						+ "&fcomments=" + jQuery('#fcomments').val()
						+ "&fpass=" + jQuery('#fpass').val();
						break;
		case "dir_edt":	action_url = "contenu/fct_images_actions.php?action=dir_edt"
						+ "&fid=" + folder
						+ "&fname=" + jQuery('#fname').val()
						+ "&fgallerie=" + jQuery('#fgallerie').val()
						+ "&fdesc=" + jQuery('#fdesc').val()
						+ "&forder=" + jQuery('#forder').val()
						+ "&fcomments=" + jQuery('#fcomments').val()
						+ "&fpass=" + jQuery('#fpass').val();
						break;
		case "dir_del": 	action_url = "contenu/images_dossier_suppr.php?fid="+folder;
							break;
		case "audio_playlist_create": 	action_url = "contenu/fct_audio_actions.php?action=playlist_create"
										+ "&fname=" + jQuery('#fname').val();
										break;
		case "audio_playlist_edit": 	action_url = "contenu/fct_audio_actions.php?action=playlist_edit"
										+ "&fid=" + folder
										+ "&fname=" + jQuery('#fname').val();
										break;
		case "audio_upload": 	if ((jQuery('#fauthor').val() != "") && (jQuery('#ftitle').val()  != "")) {
									jQuery.ajaxFileUpload({
										url: mediatek_path
											+ 'contenu/fct_audio_actions.php?action=music_upload&fid=' + jQuery('#select_folder').val()
												+ '&fauthor=' + jQuery('#fauthor').val() + '&ftitle=' + jQuery('#ftitle').val()
												+ '&fname=' + jQuery('#fileuploaded_id').val(),
										secureuri: false,
										fileElementId: 'filetosave',
										dataType: 'html',
										success: function(msg) {
											// recharger la page d'edition de la musique
											showTab('1', 'contenu/audio_playlist_ouvrir.php?fid=' + jQuery('#select_folder').val());
										}
									});
								} else display_win_error('Tu dois completer les champs auteur et titre avant de valider.');
								break;
		case "audio_import_radio":	if (jQuery("#webradios_idradio").val() == -1) {
										display_win_error('Tu n\'as pas choisi de radio');
									} else if (jQuery("#fid").val() < 0) {
										display_win_error("Tu n'as pas de playlist.");
									} else {
										action_url = 'contenu/fct_audio_actions.php?action=radio_import&fid=' + jQuery('#fid').val()
													+ '&rid=' + jQuery('#webradios_idradio').val();
									}
									break;
		case "music_del": 	action_url = 'contenu/fct_audio_actions.php?action=music_del&fid=' + folder
											+ '&mid=' + id;
											break;
		case "music_edit": 	action_url = 'contenu/fct_audio_actions.php?action=music_edit&fid=' + jQuery('#fid').val()
											+ '&mid=' + id
											+ '&fauthor=' + jQuery('#fauthor').val()
											+ '&ftitle=' + jQuery('#ftitle').val();
											break;
		case "music_jaquette": 	if (jQuery('#filetosave').val() == '') {
									display_win_error('Selectionne un fichier a envoyer.');
									return;
								}
								else {
									jQuery.ajaxFileUpload({
										url: mediatek_path
											+ 'contenu/fct_audio_actions.php?action=music_jaquette&fid=' + folder
											+ '&mid=' + id,
										secureuri: false,
										fileElementId: 'filetosave',
										dataType: 'html',
										success: function(msg) {
											// recharger la page d'edition de la musique
											showTab('1', 'contenu/audio_musique_edit.php?fid=' + folder + '&mid=' + id);
										}
									});
								}
								break;
		case "music_addinblog":	insertObject( jQuery('#music_fplayer_'+id).html() );
								break;
		case "vid_edit": 	action_url = 'contenu/fct_video_actions.php?action=vid_edit&vid=' + id
								+ '&fid=' + jQuery("#id_folder").val()
								+ '&fname=' + jQuery("#fname_id").val()
								+ '&fdesc=' + jQuery("#description_id").val()
								+ '&oldf=' + jQuery("#old_folder").val();
								break;
		case "vid_del": 	action_url = 'contenu/fct_video_actions.php?action=vid_del&fid=' + folder
								+ '&vid=' + id;
								break;
		case "vid_folder_create":	if (jQuery('#fname').val() != '') {
										action_url = "contenu/fct_video_actions.php?action=folder_create"
													+ "&fname=" + jQuery('#fname').val();
									} else display_win_error('Le dossier n\'a pas de nom.');
									break;
		case "vid_folder_edit":	if (jQuery('#fname').val() != '') {
										action_url = "contenu/fct_video_actions.php?action=folder_edit"
													+ "&fid=" + jQuery('#fid').val()
													+ "&fname=" + jQuery('#fname').val();
								} else display_win_error('Le dossier n\'a pas de nom.');
								break;
		case "vid_folder_del":	action_url = "contenu/fct_video_actions.php?action=folder_del"
											+ "&fid=" + jQuery('#fid').val();
								break;
	}
	if (action_url != "") showTab('1', action_url);
}

function mediatek_enableOptional(val) {
	// val = 0 (NON) ou 1 (OUI)
	var res = "";
	if (val == 0) res = "true";
	var tab = jQuery('.optional').attr("disabled", res);
	jQuery('#fpasswd').attr("disabled", "disabled");
}

function mediatek_listChangeOrder(type) {
	var id_list = "";
	var action_file = "";
	var tab = "";
	if (document.getElementById("img_list")) tab = document.getElementById("img_list").getElementsByTagName("input");
	else tab = document.getElementById("folders_list_id").getElementsByTagName("input");
	
	for (i=0; i<tab.length; i++) {
		if (id_list.indexOf(tab[i].value) < 0) id_list += tab[i].value + ",";
	}
	if (id_list != "") id_list = id_list.substr(0,id_list.length-1); // supprime la derniere virgule
	else return; // si la liste est vide on n'effectue aucune action, on quitte simplement.
	
	if (type == 'img') action_file = "fct_images_actions.php?action=img_order";
	else if (type == 'music') action_file = "fct_audio_actions.php?action=music_order";
	else if (type == 'folders') action_file = "fct_images_actions.php?action=dir_order";
	
	// requête ajax pour mettre à jour l'ordre dans la base :
	jQuery.ajax({
		url: mediatek_path + "contenu/"+action_file+"&fid=" + jQuery('#folder_current').val() + "&id=" + id_list,
		type: 'GET'
	});
}

/* * * * * * * * * * * * * * *
* 	Upload d'images
*/

var upload_multiple = 0; // nombre d'upload en cours, réinitialisé au chargement de la page 'Importer plusieurs images'

function mediatek_imgAddMore() {	// ENVOI MULTIPLE : Ajout d'une image supplémentaire
	
	// Vérifier les champs :
	if ( jQuery('#select_folder').val() == 0) {
		display_win_error("Aucun dossier sélectionné");
		jQuery('#select_folder_id').focus();
		return;
	}
	else if (jQuery('#filetosave').val() == "") {
		display_win_error("Sélectionne une image");
		return;
	}
	
	// optenir le nom du fichier (sans tout le chemin) :
	var filename = jQuery('#filetosave').val();
	var pos = -1;
	if ((pos = filename.lastIndexOf('/', filename.length-1)) >=0) filename = filename.substr(pos+1,filename.length);
	if ((pos = filename.lastIndexOf('\\', filename.length-1)) >=0) filename = filename.substr(pos+1,filename.length);
	
	// verrouiller les options (dossier & taille réelle) :
	jQuery('#select_folder').attr('disabled', 'disabled');
	jQuery('#up_size').attr('disabled', 'disabled');
	
	// modifier le onClick du bouton Valider
	jQuery('#bouton_submit').click(
		function () {
			showTab(1,'contenu/images_dossier_ouvrir.php?fid='+jQuery('#select_folder').val());
		}
	);
	
	// afficher le message "patientez..." :
	jQuery('#envoi_patientez').show();
	
	jQuery("#mediatek_imgAddButton").remove(); // supprimer le bouton 'ajouter'
	upload_image(); // envoi de l'upload
	jQuery('#filetosave').replaceWith('<em>'+filename+'</em>');
	var newline = 	'<tr>'
		+'<td class="cell_left"></td>'
		+'<td class="cell_label">Image &agrave; importer :</td>'
		+'<td class="cell_field" colspan="2">'
			+'<a href="javascript:void(0)" onClick="mediatek_imgAddMore()" id="mediatek_imgAddButton" style="float:right; margin:0px;" title="Ajouter une autre image">'
			+'	<img src="'+mediatek_path+'img/button_add.jpg" />'
			+'</a>'
			+'<input class="upload" type="file" size="15" name="filetosave" id="filetosave" />'
		+'</td>'
		+'<td class="cell_right"></td>'
	+'</tr>';
	jQuery(newline).appendTo("#mediatek_content table"); // ajout de la ligne d'upload dans la table
	mediatek_testHeight();	// test la hauteur de la fenêtre pour l'agrandir si besoin
}

function upload_image() {
	// Connaitre le type d'upload :
	var up_type = jQuery('#up_type').val(); // 3 types d'upload : 1 image, +images ou url
	// Vérifier les champs :
	if ( jQuery('#select_folder').val() == 0) {
		display_win_error("Aucun dossier sélectionné");
		jQuery('#select_folder').focus();
	}
	else if ((jQuery('#filetosave').val() == "") && (up_type != 2)) {
		display_win_error("Sélectionne une image");
	}
	else {
		var up_url = 'contenu/fct_images_upload.php?select_folder=' + jQuery('#select_folder').val() // dossier destination
			+ '&up_type=' + jQuery('#up_type').val() // type d'upload, 'hidden' (1,2 ou 3)
			+ '&up_size=' + jQuery('#up_size').val(); // taille réelle ou non
		
		if (up_type != '2') {
			up_url += '&iname=' + jQuery('#iname_id').val(); // ajout du nom de l'image à l'url
			if (up_type == '3') up_url += '&filetosave=' + jQuery('#filetosave').val(); // image-url à upload
			jQuery('#bouton_submit').remove(); // on supprime le bouton d'upload
			jQuery('#mediatek_import_loading').show(); //  on affiche le chargement d'upload :
		}
		
		// Envoi du formulaire normal :
		if (up_type != '2') {
			jQuery.ajaxFileUpload({
				url:mediatek_path + up_url,
				secureuri:false,
				fileElementId:'filetosave',
				dataType: 'html',
				success: function(msg) {
					// aller dans le dossier de destination :
					showTab('1', 'contenu/images_dossier_ouvrir.php?fid=' + jQuery('#select_folder').val());
				}
			});
		}
		else { // formulaire sans changement de fenêtre pour l'envoi multiple :
			upload_multiple +=1;
			jQuery('#bouton_submit').hide();
			jQuery('#envoi_patientez').show();
			// envoi du formulaire :
			jQuery.ajaxFileUpload({
				url: mediatek_path + up_url,
				secureuri:false,
				fileElementId:'filetosave',
				dataType: 'html',
				success: function(msg) {
					//alert(msg);
					upload_multiple -=1;
					if (upload_multiple == 0) {
						jQuery('#envoi_patientez').hide();
						jQuery('#bouton_submit').show();
					}
				}
			});
		}
	}
}

/* * * * * * * * * * * * * * *
* 	Ajout IMG > Blog
*/

function mediatek_addblog_param(action, param) {
	switch(action) {
		case 'size': 	jQuery('#mediatek_param_vsize').val(param);
						break;
		case 'pos': 	jQuery('#mediatek_param_vpos').val(param);
						break;
	}
	jQuery('#mediatek_param_'+action+' a').removeClass("mediatek_param_selected");
	jQuery('#mediatek_param_'+action+'_'+param).addClass("mediatek_param_selected");
	jQuery('#mediatek_param_'+action+'_'+param).blur();
}

function mediatek_imgSizeCompare(a, b) {
	var sizeTable = new Array();
	sizeTable['S'] = 1;
	sizeTable['M'] = 2;
	sizeTable['L'] = 3;
	sizeTable['XL'] = 4;
	return sizeTable[a] - sizeTable[b];
}

function mediatek_imgSizeReduce(size) {
	if (size=='XL') return 'L';
	else if (size=='L') return 'M';
	else if (size=='M') return 'S';
	else return -1;
}


function charger_dans_editeur(position, largeur, urlphoto, maxDimphoto, tailleReelle) {
	// Params :
	// - urlphoto =	url de l'image en taille S (vignette)
	var urlphoto_large = "";
	var urlphoto_reelle = "";
	var lien_taille_relle = "";
	
	switch (maxDimphoto) {
		case "M":	urlphoto_large = urlphoto.replace("-S", "-M");
						break;
		case "L":	urlphoto_large = urlphoto.replace("-S", "-L");
						break;
		default:		urlphoto_large = urlphoto;
						break;
	}
	urlphoto_large = "http://www.kazeo.com" + urlphoto_large;
	
	if (tailleReelle) {
		urlphoto_reelle = urlphoto.replace("-S", "-XL");
		urlphoto_reelle = "http://www.kazeo.com" + urlphoto_reelle;
		lien_taille_relle = "<br /><a href=\"" + urlphoto_reelle + "\" target=\"_blank\">Voir taille r&eacute;elle</a>";
	}
	
	// taille choisie par l'utilisateur :
	switch (largeur) {
		case "S": 			break;
		case "L":			urlphoto = urlphoto.replace("-S", "-L"); break;
		default: 			urlphoto = urlphoto.replace("-S", "-M"); break;
	}
	urlphoto = "http://www.kazeo.com" + urlphoto;
	
	switch (position) {
		case "left":
			var zone_photo = "<span><a href=\"" + urlphoto_large + "\" style=\"text-decoration: none\"><img src=\"" + urlphoto + "\" border=\"0\" align=\"left\" /></a>" + lien_taille_relle + "</span>";
			break;
		case "center":
			var zone_photo = "<div style=\"text-align: center\"><a href=\"" + urlphoto_large + "\" style=\"text-decoration: none\"><img src=\"" + urlphoto + "\" border=\"0\" /></a>" + lien_taille_relle + "</div>";
			break;
		case "right":
			var zone_photo = "<span><a href=\"" + urlphoto_large + "\" style=\"text-decoration: none\"><img src=\"" + urlphoto + "\" border=\"0\" align=\"right\" /></a>" + lien_taille_relle + "</span>";
			break;
		default:
			var zone_photo = "<div style=\"text-align: left\"><a href=\"" + urlphoto_large + "\" style=\"text-decoration: none\"><img src=\"" + urlphoto + "\" border=\"0\" /></a>" + lien_taille_relle + "</div>";
			break;
	}
	return zone_photo;
}
/* [maj:08.12.09] by Kazuzu -> remplace unn noeud par un nouveau noeud dans le contenu de l'éditeur */
function ReplaceObject(sHTML) {
if(window.parent.CKEDITOR){
		sHTML = sHTML.replace('../../..', 'http://www.kazeo.com');
		InCKEditor('field_mess','insert_html',sHTML);
		close_window();
	}else if(tinyMCE.get('field_mess'))
		{
			sHTML = sHTML.replace('../../..', 'http://www.kazeo.com');
			ReplaceObjectInKazeoditor(sHTML);
			jQuery.facebox.close();
		}
}

function insertObject(sHTML) {
if(window.parent.CKEDITOR){
		sHTML = sHTML.replace('../../..', 'http://www.kazeo.com');
		InCKEditor('field_mess','insert_html',sHTML);
		close_window();
	}else{
		if(tinyMCE.get('field_mess'))
		{
			sHTML = sHTML.replace('../../..', 'http://www.kazeo.com');
			/*tinyMCE.execCommand('mceInsertContent',false,sHTML);*/
			InsertObjectInKazeoditor(sHTML);
			jQuery.facebox.close();
		}
		else
		{
			// Est-ce que l'editeur est present sur la page (dans le DOM) ?
			if (window.parent.FCKeditorAPI) {
				var oEditor = window.parent.FCKeditorAPI.GetInstance("field_mess");
				sHTML = sHTML.replace('../../..', 'http://www.kazeo.com');
				oEditor.InsertHtml(sHTML);
				jQuery.facebox.close();
			} else {
				// Sinon : Redirection vers l'editeur en lui envoyant le code a inserer :
				var html2insert = '<form name="mediatek2EditorForm" action="http://www.kazeo.com/gestion/admin.php?page=remplir" method="POST" style="display:none">'
								+ 	'<textarea name="html2insert" style="display:none">'
								+ 		sHTML.replace('../../..', 'http://www.kazeo.com')
								+ 	'</textarea>'
								+ '</form>';
				jQuery('#mediatek_content').append(html2insert);
				document.mediatek2EditorForm.submit();
			}
		}
	}

}

/* [maj:04.12.09] New method for insert elements in CKEditor by Kazuzu (lounis) */
function insertObject_New(version,sHTML) {
if(version=='ckeditor'){
	if(window.parent.CKEDITOR)
	{
		sHTML = sHTML.replace('../../..', 'http://www.kazeo.com');
		InCKEditor('field_mess','insert_html',sHTML); 
		close_window();
	}
}
else if(version=='tinymce'){insertObject(sHTML);}
else{insertObject(sHTML);}
}
/*--------------------------------------------*/

/* * * * * * * * * * * * * * *
* 	Image - Crop
*/

var crop_actif = 0;

function callEdit(id, action_type) {
	editor = document.getElementById('editor_id');
	width = document.getElementById('crop_originalImageWidth_id').value;
	height = document.getElementById('crop_originalImageHeight_id').value;
	action_url = "";
	
	switch (action_type) {
		case 'left': 	jQuery('#restore_id').val('right');
						action_url = 'contenu/fct_images_rotate_img.php?act=rotate&ang=left&pid='+id+'&width='+width+'&height='+height;
						break;
		case 'right': 	jQuery('#restore_id').val('left');
						action_url = 'contenu/fct_images_rotate_img.php?act=rotate&ang=right&pid='+id+'&width='+width+'&height='+height;
						break;
		case 'mirror': 	jQuery('#restore_id').val('mirror');
						action_url = 'contenu/fct_images_rotate_img.php?act=mirror&pid='+id+'&width='+width+'&height='+height;
						break;
		case 'crop': 	//orginal image info
						width = document.getElementById('crop_originalImageWidth_id').value;
						height = document.getElementById('crop_originalImageHeight_id').value;

						//updated varible for ajax projkect
						crop_x = document.getElementById('input_crop_x').value;
						crop_y = document.getElementById('input_crop_y').value;

						// Size of image shown in crop tool
						crop_width = document.getElementById('input_crop_width').value;
						crop_height = document.getElementById('input_crop_height').value;
						crop_percent = document.getElementById('crop_percent_size').value;
						
						action_url = 'contenu/fct_images_rotate_img.php?act=crop&pid='+id+'&crop_x='+crop_x+'&crop_y='+crop_y
						+'&crop_width='+crop_width+'&crop_height='+crop_height
						+'&crop_percent='+crop_percent+'&width='+width+'&height='+height;
						
						break;
	}
	
	if (action_type != '') jQuery.ajax({
		url: mediatek_path + action_url,
		type: 'GET',
		success: function(msg) {
			callEditResponse(msg); 
		}
	});
	
}

function mf_callEdit(id, action_type) {
	
	switch(action_type){
		case 'left'		: var alert_msg = 'rotation vers la gauche'; break;
		case 'right'	: var alert_msg = 'rotation vers la droite'; break;
		case 'mirror'	: var alert_msg = 'symétrie verticale'; break;
		case 'crop'		: var alert_msg = 'recadrage'; break;
	}
	
	if(window.confirm('Effectuer '+('crop'!=action_type?'la ':'le ')+alert_msg+' de l\'image ?')){
		mf_cropDesactiver(); //Supprime le cadrillage
		
		editor = document.getElementById('editor_id');
		width = document.getElementById('crop_originalImageWidth_id').value;
		height = document.getElementById('crop_originalImageHeight_id').value;
		action_url = "";
		
		//var image_edited = document.getElementById('editor_id').innerHTML; //Récupère l'image
		document.getElementById('mf_item_image_box').innerHTML = '<img src="mediatek/img/_ajaxload.gif" style="margin-top:130px" /><br /><br />'+alert_msg+'...';
		
		switch (action_type) {
			case 'left': 	jQuery('#restore_id').val('right');
							action_url = 'contenu/fct_mf_images_rotate_img.php?act=rotate&ang=left&pid='+id+'&width='+width+'&height='+height;
							break;
			case 'right': 	jQuery('#restore_id').val('left');
							action_url = 'contenu/fct_mf_images_rotate_img.php?act=rotate&ang=right&pid='+id+'&width='+width+'&height='+height;
							break;
			case 'mirror': 	jQuery('#restore_id').val('mirror');
							action_url = 'contenu/fct_mf_images_rotate_img.php?act=mirror&pid='+id+'&width='+width+'&height='+height;
							break;
			case 'crop': 	//orginal image info
							width = document.getElementById('crop_originalImageWidth_id').value;
							height = document.getElementById('crop_originalImageHeight_id').value;
	
							//updated varible for ajax projkect
							crop_x = document.getElementById('input_crop_x').value;
							crop_y = document.getElementById('input_crop_y').value;
	
							// Size of image shown in crop tool
							crop_width = document.getElementById('input_crop_width').value;
							crop_height = document.getElementById('input_crop_height').value;
							crop_percent = document.getElementById('crop_percent_size').value;
							
							action_url = 'contenu/fct_mf_images_rotate_img.php?act=crop&pid='+id+'&crop_x='+crop_x+'&crop_y='+crop_y
							+'&crop_width='+crop_width+'&crop_height='+crop_height
							+'&crop_percent='+crop_percent+'&width='+width+'&height='+height;
							
							break;
		}
		
		if (action_type != '') jQuery.ajax({
			url: mediatek_path + action_url,
			type: 'GET',
			success: function(msg) {
				mf_callEditResponse(id, msg);
			}
		});
	}
	else{
		return false;
	}
	
}

function callEditResponse(ajax_response) {
	
	editor = document.getElementById('editor_id');
	output = ajax_response.split('~');

	editor.innerHTML = output[0].replace('src="upload', 'src="'+mediatek_path+'upload');
	document.getElementById('crop_originalImageWidth_id').value=parseInt(output[1]);
	document.getElementById('crop_originalImageHeight_id').value=parseInt(output[2]);
	document.getElementById('crop_imageWidth_id').value=parseInt(output[1]);
	document.getElementById('crop_imageHeight_id').value=parseInt(output[2]);
	
	editor.style.width=parseInt(output[1])+'px';
	editor.style.height=parseInt(output[2])+'px';
	
	cropDesactiver(); // au cas où...
}

function mf_callEditResponse(id, ajax_response) {
	
	mf_item_image_box = document.getElementById('mf_item_image_box');
	output = ajax_response.split('~');

	mf_item_image_box.innerHTML = output[0].replace('src="upload', 'src="'+mediatek_path+'upload');
	document.getElementById('crop_originalImageWidth_id').value=parseInt(output[1]);
	document.getElementById('crop_originalImageHeight_id').value=parseInt(output[2]);
	document.getElementById('crop_imageWidth_id').value=parseInt(output[1]);
	document.getElementById('crop_imageHeight_id').value=parseInt(output[2]);
	
	document.getElementById('mf_folder_item_image'+id).remove(); //On supprime la vignette actuelle
	var item_img = output[3].replace('src="upload', 'src="'+mediatek_path+'upload'); //Nouvelle vignette de l'image dans la liste des images
	var item_content = document.getElementById('mf_item_box'+id).innerHTML;
	document.getElementById('mf_item_box'+id).innerHTML = item_img+item_content; //on met à jour la vignette
	
}


function makeCropable(id) {
	if (!crop_actif) { // Lancement du CROP
		cropActiver();
	}
	else { // Réinitialisation par défaut
		callEdit(id, 'crop');
		cropDesactiver();
	}
}

//Pour la nouvelle Mediatek
function mf_makeCropable(id, img_width, img_height) {
	if('none'==document.getElementById('mf_item_submit_crop_button').style.display){ // Lancement du CROP
		mf_cropActiver(img_width, img_height);
	}
	else{ // Réinitialisation par défaut
		mf_cropDesactiver();
	}
}


function cropActiver() {
	crop_actif = 1;
	// Changement du bouton :
	jQuery('#crop_btn').attr('src', mediatek_path+'img/tools/recadrer_valider.png');
	jQuery('#crop_btn').blur();
	// Déclaration des variables de taille :
	crop_originalImageWidth = jQuery('#crop_originalImageWidth_id').val();
	crop_originalImageHeight = jQuery('#crop_originalImageHeight_id').val();
	crop_imageWidth = jQuery('#crop_imageWidth_id').val();
	crop_imageHeight = jQuery('#crop_imageHeight_id').val();
	cropScript_setBasicEvents(); // initialisation de l'algo
	crop_createDivElements(); //
	cropScript_updateFormValues();
	if (crop_script_fixedRatio && crop_script_alwaysPreserveAspectRatio) {
		crop_initFixedRatio();
	}
}

//Pour la nouvelle Mediatek
function mf_cropActiver(img_width, img_height) {
	crop_actif = 1;
	// Changement du bouton :
	jQuery('#crop_btn').attr('src', mediatek_path+'img/tools/recadrer_valider.png');
	jQuery('#crop_btn').blur();
	// Déclaration des variables de taille :
	crop_originalImageWidth = jQuery('#crop_originalImageWidth_id').val();
	crop_originalImageHeight = jQuery('#crop_originalImageHeight_id').val();
	crop_imageWidth = jQuery('#crop_imageWidth_id').val();
	crop_imageHeight = jQuery('#crop_imageHeight_id').val();
	cropScript_setBasicEvents(); // initialisation de l'algo
	mf_crop_createDivElements(img_width, img_height); //
	cropScript_updateFormValues();
	if (crop_script_fixedRatio && crop_script_alwaysPreserveAspectRatio) {
		crop_initFixedRatio();
	}
	
	jQuery("#mf_item_submit_crop_button").show("slide", { direction: "right" }, 500); //Affiche le bouton de validation
	document.getElementById('mf_ico_crop_box').innerHTML = '<img title="Annuler le recadrage de l\'image" src="imgs/ico/ico_no_crop.png" style="margin:2px 0 0 4px" />'; //Change l'icone
}

function cropDesactiver() {
	crop_actif = 0;
	jQuery('#crop_btn').attr('src', mediatek_path + 'img/tools/recadrer.gif');
	jQuery('#crop_btn').blur();
}

function mf_cropDesactiver() {
	crop_actif = 0;
	jQuery('#crop_btn').attr('src', mediatek_path + 'img/tools/recadrer.gif');
	jQuery('#crop_btn').blur();
	
	//On supprime le cadrillage
	if(document.getElementById('mf_crop_transparentDiv_left')){
		document.getElementById('mf_crop_transparentDiv_left').remove();
		document.getElementById('mf_crop_transparentDiv_top').remove();
		document.getElementById('mf_crop_transparentDiv_right').remove();
		document.getElementById('mf_crop_transparentDiv_bottom').remove();
		document.getElementById('mf_crop_dottedDiv').remove();
		
		jQuery("#mf_item_submit_crop_button").hide("slide", { direction: "right" }, 500); //Cache le bouton de validation
		document.getElementById('mf_ico_crop_box').innerHTML = '<img title="Recadrer l\'image" src="imgs/ico/ico_crop.png" style="margin-top:6px" />'; //Change l'icone
	}
	
}

function responseRotate(msg) {
	output = msg.split('~');
	jQuery('#crop_originalImageWidth_id').val( parseInt(output[1]) );
	jQuery('#crop_originalImageHeight_id').val( parseInt(output[2]) );
	jQuery('#crop_imageWidth_id').val( parseInt(output[1]) );
	jQuery('#crop_imageHeight_id').val( parseInt(output[2]) );
	jQuery('#editor_id').width(output[1]+'px');
	jQuery('#editor_id').height(output[2]+'px');
	jQuery('#editor_id').innerHTML = output[0];
	return true;
}

/* * * * * * * * * * * * * * *
* 	Videotheque
*/

function vid_addinblog(id) {
	var html2insert = jQuery("#vid_"+id).html();
	
	html2insert = html2insert.replace(/width="100"/g, 'width="420"');
	html2insert = html2insert.replace(/height="100"/g, 'height="336"');
	// Fixe bug pour IE7 qui transforme le code a sa sauce (ici il a enleve les guillemets) ...
	html2insert = html2insert.replace(/width=100/g, 'width="420"');
	html2insert = html2insert.replace(/height=100/g, 'height="336"');
	
	//prise en charge des videos LetMotiv
	//html2insert = html2insert.replace('<letmotiv', '<div style="margin: 0; padding: 0; width: 465px; height: 406px; background-color: #fff; background-image: url(http://www.kazeo.com/gestion/imgs/video_kazeo.gif);"><script');
	//html2insert = html2insert.replace('/letmotiv>', '/script></div>');
	
	html2insert = html2insert.replace('<letmotiv', '<p><img');
	html2insert = html2insert.replace('<LETMOTIV', '<p><img');
	html2insert = html2insert.replace('></letmotiv>', 'style="float: left; width: 465px; height: 406px; background-color: #ffffff;" /></p>');	
	html2insert = html2insert.replace('></LETMOTIV>', 'style="float: left; width: 465px; height: 406px; background-color: #ffffff;" /></p>');	
	
	insertObject( html2insert );
}

function vid_addinblog_multi() {
	// Trouver les vidéos à ajouter :
	var vid_html = "";
	var html2insert = "";
	// Parcourir la liste pour trouver les vidéos cochées :
	var tab = document.getElementById("img_list").getElementsByTagName("input");
	for (i=0; i<tab.length; i++) {
		if (tab[i].checked) {
			vid_html = jQuery("#vid_"+tab[i].value).html();
			
						
			vid_html = vid_html.replace(/width="100"/g, 'width="420"');
			vid_html = vid_html.replace(/height="100"/g, 'height="336"');
			// Fixe bug pour IE7 qui transforme le code a sa sauce (ici il a enleve les guillemets) ...
			vid_html = vid_html.replace(/width=100/g, 'width="420"');
			vid_html = vid_html.replace(/height=100/g, 'height="336"');
								
			//prise en charge des videos LetMotiv
			vid_html = vid_html.replace('<letmotiv', '<p><img style="width: 465px; height: 406px; background-color: #fff; float: left"');
			vid_html = vid_html.replace('<LETMOTIV', '<p><img style="width: 465px; height: 406px; background-color: #fff; float: left"');
			vid_html = vid_html.replace('></letmotiv>', '/></p>');
			vid_html = vid_html.replace('></LETMOTIV>', '/></p>');
			
			html2insert += vid_html;
		}
	}
	// Insertion dans l'editeur
	insertObject( html2insert );
}

function mediatek_vidActionSelected() {
	// Trouver les vidéos sélectionnées :
	var id_list = "";
	var tab = document.getElementById("img_list").getElementsByTagName("input");
	for (i=0; i<tab.length; i++) {
		if (tab[i].checked) id_list += tab[i].value + ",";
	}
	// Action à réaliser sur les videos :
	// 1: ajouter au blog
	// 2: supprimer
	// 3: déplacer
	switch (jQuery("#mediatek_id_option").val()) {
		case '3':	vid_addinblog_multi();
					break;
		case '1':	showTab(1, 'contenu/fct_video_actions.php?action=vid_many_del&fid='+jQuery("#folder_current").val() + '&id_list='+id_list);
					break;
		case '2':	showTab(1, 'contenu/fct_video_actions.php?action=vid_many_move&fid='+jQuery("#mediatek_id_folder").val() + '&id_list='+id_list);
					break;
	}
}

// Import de videos par Internet :
function vid_import() {
	// Recuperation des variables :
	var fid = jQuery('#select_folder_id').val();
	var vname = jQuery('#vname_id').val();
	var vhtml = jQuery('#vhtml_id').val();
	
    var valHTML = " " + vhtml  + " ";
	var maReg = new RegExp("<object*","g");
	var resultat = valHTML.split( maReg );
	
	if ( !(resultat.length > 1) && (vhtml.indexOf('http://')!=0) ) display_win_error("La video n'est pas valide");
	else if (fid < 1) display_win_error("Aucun dossier.");
	else if(vname == "") {
		display_win_error("La video n'a pas de nom.");
	}
	else{
		showTab(1, 'contenu/fct_video_actions.php?action=vid_import&fid='+fid
				+ '&vname='+vname
				+ '&vhtml='+escape(vhtml)
			);
	}
}

/* * * * * * * * * * * * * * *
* 	Audiotheque
*/

// Envoi terminé :
function upload_complete(name,size,type,ft,dir) {
	//window.location="index.php?name="+name+"&size="+size+"&type="+type+"&exts="+ft+"&dir="+dir;
	document.getElementById('flashcontent').innerHTML = 'Fichier <b>' + name + '</b> envoy&eacute; !';
	jQuery('#fileuploaded_id').val( jQuery('#fileuploaded_id').val() + '_' + name);
	jQuery('#bouton_submit').show();
}
// Quand un fichier est sélectionné :
function fileProps(name,size,type,cdate,mdate,dir) {
	//var props = document.getElementById('props');
	//props.innerHTML = "<div class='sucErr'><div class='tableHeader' style='width: 400px; height: 20px; padding-top: 5px;'>Selected File:</div><br /><table border='0' cellspacing='0' cellpadding='0' style='margin:10px;'><tr><td width='100'><b>NAME:</b></td><td> "+dir+"/"+name+"</td></tr><tr><td><b>SIZE:</b></td><td> "+size+"</td></tr><tr><td><b>TYPE:</b></td><td> "+type+"</td></tr><tr><td><b>CREATED:</b></td><td> "+cdate+"</td></tr><tr><td><b>MODIFIED:</b></td><td> "+mdate+"</td></tr></table></div>";
	//props.style.display = "block";
	
	// code ici : afficher le bouton 'Terminer'
	// ..
}
function mediatek_audio_upload() {
	if (jQuery('#select_folder').val() == '-1') {
		display_win_error('La playlist est pleine. Merci d\'en choisir une autre.');
		return;
	}
	jQuery('#bouton_submit').hide();
	jQuery.ajax({
		url: 'contenu/fct_audio_actions.php?action=music_upload&fid=' + jQuery('#select_folder').val()
			+ '&fauthor=' + jQuery('#fauthor').val() + '&ftitle=' + jQuery('#ftitle').val()
			+ '&fname=' + jQuery('#fileuploaded_id').val(),
		type: "GET",
		success: function() {
			showTab(1, 'contenu/audio_playlist_ouvrir.php?fid='+jQuery('#select_folder').val());
		}
	});
}

function mediatek_audio_addinmyblog_popup(id_music) {
	jQuery.facebox('<div style="text-align:center"><img src="/gestion/mediatek/img/_ajaxload.gif" alt="loading..." /></div>');
	jQuery.ajax({
		url: mediatek_path + 'contenu/audio_musique_addinmyblog.php?mid=' + id_music,
		type: 'GET',
		success: function(msg) {
			jQuery.facebox(msg);
		}
	});
}

function mediatek_audio_addinmyblog(id_music) {
	var fid = jQuery('#fid').val();
	jQuery.facebox('<div style="text-align:center"><img src="/gestion/mediatek/img/_ajaxload.gif" alt="loading..." /></div>');
	jQuery.ajax({
		url: mediatek_path + 'contenu/fct_audio_actions.php?action=music_addinmyblog&mid=' + id_music + '&fid=' + fid,
		type: 'GET',
		success: function(msg) {
			jQuery.facebox(msg);
		}
	});
}


/* * * * * * * * * * * * * * *
* 	Lientheque
*/

/*ajouté le 26.03.09 modif {v1 : 2.04.09 , v2 : 24.11.09 } by kazuzu 
  note : récupère les ancres dans un article en cours d'écriture. */
function GetAnchorsEditor(ed_content)
{	
	if(ed_content != ""){
	var nodes = []; var name; var i = 0; var exist_anchors=false; var CumulAnchorhtml='';
	jQuery(ed_content).find('a').each(function(i){
		if(jQuery(this).find('name')){nodes[i] = jQuery(this).attr('name');}
	});
	for (i=0; i<nodes.length; i++)
	{	name = nodes[i]; if (name != "") { CumulAnchorhtml += '<option value="' + name + '">' + name + '</option>'; exist_anchors=true;} }
	
	if(exist_anchors==true){
	var anchorhtml = '<select id="listbox_ancres" style="width:150px;display:none;" name="listbox_ancres">'; 
		anchorhtml += '<option value="">--ancres--</option>';
		anchorhtml += CumulAnchorhtml;
		anchorhtml += '</select>'; jQuery('#listbox_ancres').replaceWith(anchorhtml);
	}
	}
}

/* 9.04.09 */
function optionAdvancedLink(titlelink,targetlink,w_link,h_link) {
	var opAdvLink="";
	if(targetlink!=1)
			{
				if(targetlink==2){opAdvLink+='target="_blank" ';}
				if(targetlink==3){
				opAdvLink+='onclick="window.open(this, ';
				if(titlelink!=""){opAdvLink+="'"+titlelink+"',";}else{opAdvLink+="'',"}
				if(w_link!=""){opAdvLink+="'width="+w_link+"',";}else{opAdvLink+="'',"}
				if(h_link!=""){opAdvLink+="'height="+h_link+"'";}else{opAdvLink+="''"}
				opAdvLink+='); return false;" ';
				}
			}
	return opAdvLink;
}

function CreateLink(titlelink,targetlink,w_link,h_link,ptl_link,href_link,a_titlelink)
{
if(href_link!=""){
	var addlink="";
	addlink+= "<a ";
	if(ptl_link!="ancre"){
		if(targetlink!=1){
			if(targetlink==2){addlink+='target="_blank" ';}
			if(targetlink==3){
			addlink+='onclick="window.open(this, ';
			if(titlelink!=""){addlink+="'"+titlelink+"',";}else{addlink+="'',"}
			if(w_link!=""){addlink+="'width="+w_link+"',";}else{addlink+="'',"}
			if(h_link!=""){addlink+="'height="+h_link+"'";}else{addlink+="''"}
			addlink+='); return false;" ';
			}
		}
	}else{ptl_link="#";}

	if(href_link!=""){ if(ptl_link!=""){
	href_link = href_link.replace(new RegExp('http://([^"]*)|https://([^"]*)|mailto:([^"]*)','gi'),'$1');
	addlink+=' href="'+ptl_link+href_link+'">';}
	}

	if(a_titlelink!=""){addlink+=a_titlelink;}else{addlink+="lien";}
	addlink+= "</a>&nbsp;";
	return addlink;
}

}

/* 9.04.09 */
function CreateLink_dev(titlelink,targetlink,w_link,h_link,ptl_link,href_link,a_titlelink)
{

if(href_link!="")
{	var addlink="";
	addlink+= "<a ";
	if(ptl_link!="ancre"){addlink+=optionAdvancedLink(titlelink,targetlink,w_link,h_link);}else{ptl_link="#";}
	if(href_link!=""){ if(ptl_link!=""){addlink+=' href="'+ptl_link+href_link+'">';} }
	if(a_titlelink!=""){addlink+=a_titlelink;}else{addlink+="lien";}
	addlink+= "</a>&nbsp;";
	return addlink;
}

}

function UpdateLink(node_elm,titlelink,targetlink,w_link,h_link,ptl_link,href_link)
{

if(href_link!="" && node_elm !=""){
	var updtlink="";
	if(node_elm.search('href=')== -1){
	node_elm=node_elm.replace(new RegExp('<\/?p>','gi'),'');
	updtlink+= "<a ";
	if(ptl_link!="ancre"){updtlink+=optionAdvancedLink(titlelink,targetlink,w_link,h_link);}else{ptl_link="#";}
	/*cas sans A href dans nodes*/
	if(href_link!=""){ if(ptl_link!=""){updtlink+=' href="'+ptl_link+href_link+'">';} }
	if(node_elm!=""){updtlink+=node_elm;}else{updtlink+="erreur de récupération";}
	updtlink+= "</a>&nbsp;";
	}
	else{/*cas avec A href dans nodes*/
	node_elm=node_elm.replace(new RegExp('<\/?p>','gi'),'');
	if(ptl_link=="ancre"){ptl_link="#";}
	updtlink+=node_elm.replace(new RegExp('href="([^"]*)"', 'gi'),'href="'+ptl_link+href_link+'"');
	}
	return updtlink;
}

}

function mediatek_addlink(mode_addlink,link_url,link_title)
{	var html2insert="";var mode_addlink_interne="";var anchorlink_id="";
		var node_el=jQuery('#node_el').val();
		if(node_el!=""){mode_addlink+='_modif';}
		if(mode_addlink=="externe_modif")
		{
			var titlelink=jQuery('#popup_n').val();
			var targetlink=jQuery('#target').val();
			var w_link=jQuery('#popup_w').val();
			var h_link=jQuery('#popup_h').val();
			var href_link=jQuery('#extLink').val();
			var ptl_link=jQuery('#protocol option:selected').text();
			if(href_link.search('http://')!= -1){ptl_link='http://';}
			if(href_link.search('mailto:')!= -1){ptl_link='mailto:';}
			if(href_link.search('https://')!= -1){ptl_link='https://';}
			href_link = href_link.replace(new RegExp('http://([^"]*)|https://([^"]*)|mailto:([^"]*)','gi'),'$1');
			var a_titlelink=jQuery('#linkLabel').val();
			var node_elm = node_el;
			html2insert = UpdateLink(node_elm,titlelink,targetlink,w_link,h_link,ptl_link,href_link);
			if(mode_addlink=="externe_modif"){ReplaceObject( html2insert );}
		}
		
		if(mode_addlink=="externe")
		{
			var titlelink=jQuery('#popup_n').val();
			var targetlink=jQuery('#target').val();
			var w_link=jQuery('#popup_w').val();
			var h_link=jQuery('#popup_h').val();
			var href_link=jQuery('#extLink').val();
			var ptl_link=jQuery('#protocol option:selected').text();
			if(href_link.search('http://')!= -1){ptl_link='http://';}
			if(href_link.search('mailto:')!= -1){ptl_link='mailto:';}
			if(href_link.search('https://')!= -1){ptl_link='https://';}
			href_link = href_link.replace(new RegExp('http://([^"]*)|https://([^"]*)|mailto:([^"]*)','gi'),'$1');
			var a_titlelink=jQuery('#linkLabel').val();
			
		}

		if( mode_addlink.search('interne_')!= -1){mode_addlink_interne="interne";}
		if( mode_addlink.search('interne_')!= -1){anchorlink_id = mode_addlink.replace(/interne_(.*?)/gi,"$1").replace(/(.*?)_modif/gi,"$1");}
		if(mode_addlink_interne=="interne" || mode_addlink=="interne")
		{
			var href_link; var anchors_list="";
			var titlelink=jQuery('#popup_n').val();
			var targetlink=jQuery('#target').val();
			var w_link=jQuery('#popup_w').val();
			var h_link=jQuery('#popup_h').val();
			if(anchorlink_id!=""){anchors_list =(jQuery('#ancres_liste_'+anchorlink_id+' option:selected').text()!="vers une ancre ?")?jQuery('#ancres_liste_'+anchorlink_id+' option:selected').text():""; } else{anchors_list ="";}
			if(anchors_list!="" && anchors_list!='vers une ancre ?'){href_link=link_url+"#"+anchors_list;}else{href_link=link_url;}
			if(jQuery('#titre_lien').val()!=link_title && jQuery('#titre_lien').val()!="")
			{var a_titlelink=jQuery('#titre_lien').val();} else {var a_titlelink=link_title;}
			var ptl_link='http://';
		
		}
	if(mode_addlink=="externe" || mode_addlink=="interne" || mode_addlink_interne=="interne")
	{
		html2insert = CreateLink(titlelink,targetlink,w_link,h_link,ptl_link,href_link,a_titlelink);
		if(mode_addlink=="externe"){insertObject( html2insert );}
		if(mode_addlink=="interne" || mode_addlink_interne=="interne"){insertObject( html2insert );}
		
	}	

}
/* Fin Lientheque */