﻿// Fichier JScript
var UrlRoot;

function RTE_InsertImage(strBaseElementID)
{
	RTE_SaveSelection(strBaseElementID);
	
	var urlWeb = window.location.href;
	
	var opts=RTE_ModalDialogImageInsert(
		strBaseElementID, 'InsertImage', g_RTE_Dialog_Width, g_RTE_Dialog_Height, urlWeb ,null );
	if (opts !=null)
	{
		var href=STSHtmlEncode(opts[1]);
		var altText=STSHtmlEncode(opts[0]);
		var fAllowRelativeLinks=false;
		var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
		if (variables !=null && variables.aSettings !=null)
		{
			fAllowRelativeLinks=variables.aSettings.fAllowRelativeLinks;
		}
		if (IsSafeHrefAlert(href,fAllowRelativeLinks))
		{
			var imgHtml='<IMG SRC="'+href+'" ALT="'+altText+'">';
			RTE_GetSelection(strBaseElementID).pasteHTML(imgHtml);
		}
		if(RTE_UseDynamicHeightSizing(strBaseElementID))
		{
			RTE_DocEditor_AdjustHeight(strBaseElementID);
		}
	}
}


function RTE_ModalDialogImageInsert(
	strBaseElementID,
	strDialogName,
	width,
	height,
	webUrl,
	dialogArg)
{
	var variables=RTE_GetEditorInstanceVariables(strBaseElementID);
	return showModalDialog(
		"/ITN_RTE_ConvertTextAreaToRichEditPages/Pages/RteDialogImage.aspx?Dialog="+			strDialogName+			"&LCID="+RTE_GetWebLocale(strBaseElementID)+ "&UrlRoot=" + webUrl ,
		dialogArg,
		"resizable: yes; status: no; help: no; "+			"center: yes; dialogWidth:"+width+"px; "+			"dialogHeight:"+height+"px;");
}
