//#16.0.1.0 MenuContextuel.js
//VersionVI: 30F160056n
// Le seul support technique disponible pour cette librairie est
// accessible a travers le service "Assistance Directe".

var gbEnDehors = 0
var gsChampEnCours = ""
var gnNbCtx = 4

if(!window.event && window.captureEvents)
{
	// set up event capturing for mouse events (add or subtract as desired)
	window.captureEvents(Event.MOUSEOVER|Event.MOUSEOUT|Event.CLICK|Event.DBLCLICK);
	// set window event handlers (add or subtract as desired)
	window.onmouseover = WM_getCursorHandler;
	window.onmouseout = WM_getCursorHandler;
	window.onclick = WM_getCursorHandler;
	window.ondblclick = WM_getCursorHandler;
	// create an object to store the event properties
	window.event = new Object;
}


function WM_getCursorHandler(e)
{
	// set event properties to global vars (add or subtract as desired)
	window.event.clientX = e.pageX;
	window.event.clientY = e.pageY;
	window.event.x = e.layerX;
	window.event.y = e.layerY;
	window.event.screenX = e.screenX;
	window.event.screenY = e.screenY;
	// route the event back to the intended function
	if ( routeEvent(e) == false ) {
		return false;
	} else {
		return true;
	}
}

function _WWCTX_AFFICHE(oEvent)
{
	oEvent = oEvent ? oEvent : event;

	//Rend visible et modifie la position du menu contextuel en fonction du curseur de la souris
	var szCtx = "MCTX"
	document.getElementById(szCtx).style.top = _SPY(oEvent, 0);
	document.getElementById(szCtx).style.left = _SPX(oEvent, 0);
	document.getElementById(szCtx).style.visibility = "visible"
	_WWCTX_SELECTION(1)
}

function _WWCTX_CACHE()
{
	if(gbEnDehors==1)
		document.getElementById("MCTX").style.visibility = "hidden"
}

function _WWCTX_FERME()
{
	gbEnDehors = 1;
	setTimeout("_WWCTX_CACHE()",500);
}

function _WWCTX_BLOQUE()
{
	return false;
}

// cadre interne : 0 ou 1
CtxCadInt = 0
// couleur de fond
CtxColFon = "#ffffff"
// couleur de cadre
CtxColCad = "#000000"
// image de bordure
CtxImgBor = "MenuBordure.gif"
// marge (depend de l'image de bordure)
CtxMarge = 21
// couleur de fond de selection
CtxColFonSel = "#A1ABC6"

function _WWCTX_SELECTION(idCtx)
{
	gbEnDehors = 0;
	for(i=1;i<=gnNbCtx;i++)
	{
		var Elm = document.getElementById("Option" + i)
		var Fnt = document.getElementById("OptionText" + i)
		Elm.style.borderWidth=0
		Fnt.style.marginLeft=CtxMarge
		Elm.style.backgroundColor = ""
	}
	var Elm = document.getElementById("Option" + idCtx)
	var Fnt = document.getElementById("OptionText" + idCtx)
	Elm.style.borderWidth=1
	Fnt.style.marginLeft=CtxMarge-CtxCadInt
	Elm.style.borderColor = CtxColCad
	Elm.style.backgroundColor = CtxColFonSel
}

function _WWCTX_OBJET(szNomObjet)
{
	return document.getElementById("ct_" + szNomObjet);
}

function _WWCTX_CREE(RepImg)
{
	var tabHTML = [];
	tabHTML.push("<div id=\"MCTX\" name=\"MCTX\" style=\"z-index:999;position:absolute;visibility:hidden\">");
	tabHTML.push("<table border=\"1\ cellspacing=\"");
	tabHTML.push(CtxCadInt);
	tabHTML.push("\" cellpadding=\"0\" bgcolor=\"");
	tabHTML.push(CtxColFon);
	tabHTML.push("\" bordercolor=\"");
	tabHTML.push(CtxColCad);
	tabHTML.push("\" style=\"background-image:url(");
	tabHTML.push(RepImg);
	tabHTML.push("/");
	tabHTML.push(CtxImgBor);
	tabHTML.push(");background-repeat:repeat-y;\" width=\"150\" height=\"66\">");
	tabHTML.push("<tr width=\"100%\" height=\"66\">");
	tabHTML.push("<td style=\"border-width:0\" width=\"100%\" height=\"66\" valign=\"middle\">");
	tabHTML.push("<table border=\"");
	tabHTML.push(CtxCadInt);
	tabHTML.push("\" style=\"border-width:0\" cellspacing=\"0\" cellpadding=\"0\" align=\"center\" border=\"0\" width=\"100%\" height=\"66\">");
	tabHTML.push("<tr height=\"22\" width=\"100%\">");
	tabHTML.push("<td onselectstart=\"return(false)\" border=\"1\" title=\"");
	tabHTML.push(window.TABLE_EXPORT_EXCEL_TITLE ? TABLE_EXPORT_EXCEL_TITLE : "Exporter le contenu vers Excel...");
	tabHTML.push("\" style=\"border-width:0\" id=\"Option1\" height=\"22\" width=\"100%\" onmouseover=\"_WWCTX_SELECTION(1);\" onmouseout=\"_WWCTX_FERME()\" onmouseup=\"_JEC('xls','EXPORTXLS',gsChampEnCours)\" style=\"cursor:hand\" style=\"\">");
	tabHTML.push("<font id=\"OptionText1\" face=\"Tahoma\" style=\"margin-left:15px;font-size:8.000pt\">");
	tabHTML.push(window.TABLE_EXPORT_EXCEL ? TABLE_EXPORT_EXCEL : "Exporter vers Excel...");
	tabHTML.push("</font>");
	tabHTML.push("</td>");
	tabHTML.push("</tr>");
	tabHTML.push("<tr height=22 width=100%>");
	tabHTML.push("<td onselectstart=\"return(false)\" border=1 title=\"");
	tabHTML.push(window.TABLE_EXPORT_WORD_TITLE ? TABLE_EXPORT_WORD_TITLE : "Exporter le contenu vers Word...");
	tabHTML.push("\" style=\"border-width:0\" id=\"Option2\" height=22 width=100% onmouseover=\"_WWCTX_SELECTION(2);\" onmouseout=\"_WWCTX_FERME()\" onmouseup=\"_JEC('rtf','EXPORTRTF',gsChampEnCours)\" style=\"cursor:hand\" style=\"margin-left:15px;\">");
	tabHTML.push("<font id=\"OptionText2\" face=\"Tahoma\" style=\"margin-left:15px;font-size:8.000pt\">");
	tabHTML.push(window.TABLE_EXPORT_WORD ? TABLE_EXPORT_WORD : "Exporter vers Word...");
	tabHTML.push("</font>");
	tabHTML.push("</td>");
	tabHTML.push("</tr>");
	tabHTML.push("<tr height=22 width=100%>");
	tabHTML.push("<td onselectstart=\"return(false)\" border=1 title=\"");
	tabHTML.push(window.TABLE_EXPORT_XML_TITLE ? TABLE_EXPORT_XML_TITLE : "Exporter le contenu vers XML...");
	tabHTML.push("\" style=\"border-width:0\" id=\"Option3\" height=22 width=100% onmouseover=\"_WWCTX_SELECTION(3);\" onmouseout=\"_WWCTX_FERME()\" onmouseup=\"_JEC('xml','EXPORTXML',gsChampEnCours)\" style=\"cursor:hand\" style=\"margin-left:15px;\">");
	tabHTML.push("<font id=\"OptionText3\" face=\"Tahoma\" style=\"margin-left:15px;font-size:8.000pt\">");
	tabHTML.push(window.TABLE_EXPORT_XML ? TABLE_EXPORT_XML : "Exporter vers XML...");
	tabHTML.push("</font>");
	tabHTML.push("</td>");
	tabHTML.push("</tr>");
	tabHTML.push("<tr height=22 width=100%>");
	tabHTML.push("<td onselectstart=\"return(false)\" border=1 title=\"");
	tabHTML.push(window.TABLE_EXPORT_PDF_TITLE ? TABLE_EXPORT_PDF_TITLE : "Imprimer vers un fichier PDF...");
	tabHTML.push("\" style=\"border-width:0\" id=\"Option4\" height=22 width=100% onmouseover=\"_WWCTX_SELECTION(4);\" onmouseout=\"_WWCTX_FERME()\" onmouseup=\"_JEC('pdf','EXPORTPDF',gsChampEnCours)\" style=\"cursor:hand\" style=\"margin-left:15px;\">");
	tabHTML.push("<font id=\"OptionText4\" face=\"Tahoma\" style=\"margin-left:15px;font-size:8.000pt\">");
	tabHTML.push(window.TABLE_EXPORT_PDF ? TABLE_EXPORT_PDF : "Imprimer en PDF...");
	tabHTML.push("</font>");
	tabHTML.push("</td>");
	tabHTML.push("</tr>");
	tabHTML.push("</table>");
	tabHTML.push("</td>");
	tabHTML.push("</tr>");
	tabHTML.push("</table>");
	tabHTML.push("</div>");
	document.write(tabHTML.join(""))
}

function _WWCTX_OUVRE(sChamp, oEvent)
{
	gbEnDehors = 0
	gsChampEnCours = sChamp
	_WWCTX_AFFICHE(oEvent)
}

function _WWCTX_IN(sChamp)
{
	gbEnDehors = 0
	gsChampEnCours = sChamp
	var obj = _WWCTX_OBJET(gsChampEnCours)
	obj.oncontextmenu = _WWCTX_AFFICHE
	document.oncontextmenu = _WWCTX_BLOQUE
}

function _WWCTX_OUT(sChamp)
{
	gbEnDehors = 1
	gsChampEnCours = sChamp
	var obj = _WWCTX_OBJET(gsChampEnCours)
	obj.oncontextmenu = ""
	document.oncontextmenu = ""
}

function _WWCTX_PAGE()
{
	if(gbEnDehors==1 && gsChampEnCours != "" )
	{
		var obj = _WWCTX_OBJET(gsChampEnCours)
		obj.oncontextmenu = ""
		document.oncontextmenu = ""
		gsChampEnCours = ""
		_WWCTX_CACHE()
	}
}

