// ******************************************************************************************
// ** Olivier LEMETTAIS														              www.loxal.com **
// ** -------------------------------------------------------------------------------------**
// ** Site loXal 																							       **
// ** 17/02/2003																									 **
// ** -------------------------------------------------------------------------------------**
// ** LXLSTATIC.JS		    																					 **
// ******************************************************************************************
// ** définition de la class Static avec edition en mode Admin

ActiveObj = new Object();
FocusOut ();

Menus = new Array ( 
	new Array ( 
		new Array ( 'Couper'   		, 'Cut'     		, 'cut'   		),
		new Array ( 'Copier'   		, 'Copy'     		, 'copy'   		),
		new Array ( 'coller'			, 'Paste'   		, 'paste'		)
	),
	new Array ( 
		new Array ( 'Gras'     		, 'Bold'     		, 'bold'   		),
		new Array ( 'Italique' 		, 'Italic'   		, 'italic'		),
		new Array ( 'souligner'		, 'Underline'		, 'underline'	)
	),
	new Array ( 
		new Array ( '-->'				, 'Indent'			, 'indent'		),
		new Array ( '<--'				, 'Outdent'			, 'outdent'		)
	),
	new Array ( 
		new Array ( 'Centrer'		, 'JustifyCenter'	, 'center'		),
		new Array ( 'A gauche'		, 'JustifyLeft'	, 'left'			),
		new Array ( 'A droite'		, 'JustifyRight'	, 'right'		)
	),
	new Array ( 
		new Array ( 'Couleur Texte', 'ForeColor'		, 'fgcolor'		),
		new Array ( 'Couleur Fond'	, 'BackColor'		, 'bgcolor'		),
		new Array ( 'RemoveFormat'	, 'RemoveFormat'	, 'rem_format'	)
	),
	new Array ( 
		new Array ( 'Lien'		   , 'CreateLink'		, 'lien'			),
		new Array ( 'Image'		   , 'InsertImage'	, 'image'		)
	),
	new Array ( 
		new Array ( 'Titre 1'		, 'FormatBlock1'	, 'formatblock1'),
		new Array ( 'Titre 2'		, 'FormatBlock2'	, 'formatblock2'),
		new Array ( 'Titre 3'		, 'FormatBlock3'	, 'formatblock3')
	)
	
//	new Array ( 'SelectAll','SelectAll','newfolder')
);

function pick_color()
{
	return showModalDialog ( "pick_color.php", "", "dialogWidth:445px; dialogHeight:140px; status:no; scroll:no; help:no");
}

function pick_link()
{
	return showModalDialog ( "pick_link.php", "", "dialogWidth:445px; dialogHeight:140px; status:no; scroll:no; help:no");
}

function pick_image()
{
	var parameters = window.showModalDialog ( "/forms/form_files.php?withaction=2&withmenu=0", "", "dialogWidth:450px; dialogHeight:300px; status:no; scroll:yes; help:no");	
	return '/forms/photo.php?id='+parameters[3];
}

function FocusOut ()
{
	if (ActiveObj.Id)
	{
		var div = document.getElementById('div_'+ActiveObj.Id);
		var inp = document.getElementById(ActiveObj.Id);
		eval ( "inp.value=div.innerHTML");
	}
	ActiveObj.Id=0;
}

function FocusIn(qui)
{
	ActiveObj.Id=qui;
}

var popup_menu_open=false;
var popup_dialog_open=false;

var popup_menu = window.createPopup();

function do_action(action)
{
	switch(action)
	{
		case 'ForeColor'	 : return document.execCommand( action,false,pick_color());
		case 'BackColor'	 : return document.execCommand( action,false,pick_color());
		case 'CreateLink'	 : return document.execCommand( action,true);
		case 'InsertImage' : return document.execCommand( action,false,pick_image());
		case 'FormatBlock1': return document.execCommand( 'FormatBlock',false,'<H1>');
		case 'FormatBlock2': return document.execCommand( 'FormatBlock',false,'<H2>');
		case 'FormatBlock3': return document.execCommand( 'FormatBlock',false,'<H3>');
	}
	
	var sText = document.selection.createRange();
	if (!sText=="")
	{
     return document.execCommand(action);
   }
   return 0;
}

function popup_menu_over(obj, over)
{
	if(over)
	{
		obj.style.backgroundColor = 'Highlight';
		obj.style.color = 'HighlightText';
	}
	else
	{
		obj.style.backgroundColor = '';
		obj.style.color = '';
	}
}

function make_popup_menu_item ( menus)
{
	var code = '';

	name 		= menus[0];
	action 	= menus[1];
	img_name = menus[2];
	
	code += '<tr>';
	if(name != '<HR>')
	{
		code += '<td onclick="parent.do_action(\''+action+'\'';
		code += '); parent.popup_dialog_open=true; parent.popup_menu_open=false; parent.popup_menu.hide();';
		code += '" style="cursor:hand; font-family:Verdana; font-size:10px;"';
		code += ' onmouseover="parent.popup_menu_over(this, true);"';
		code += ' onmouseout="parent.popup_menu_over(this);">';
	}
	else
	{
		code += '<td>';
	}

	code += '<nobr>';
	if(img_name)
	{
		code += '<img src="../images/icones/'+img_name+'.gif" width="20" height="20" alt="'+name+'" align="absmiddle" hspace="4">';
	}
	else
	{
		code += '<img src="../images/vide.gif" width="20" height="20" hspace="4">';
	}

	if(name != '<HR>')
	{
		code += name;
	}
	else
	{
		code += '<br><img src="../images/vide.gif" width="100%" height="1" style="BACKGROUND-COLOR: buttonshadow"><br>';
		code += '<img src="../images/vide.gif" width="100%" height="1" style="BACKGROUND-COLOR: buttonhighlight"><br>';
	}

	code += '<img src="../images/vide.gif" width="8" height="1"></nobr>';
	code += '</td></tr>';

	return code;
}

function make_popup_menu_button_item ( menus)
{
	var i;
	var code = '';

	code += '<tr><td><table align=left cellspacing=0 cellpadding=0 border=0><tr>';
	for (i=0; i<menus.length; i++)
	{
		code += '<td onclick="parent.do_action(\''+menus[i][1]+'\'';
		code += '); parent.popup_dialog_open=true; parent.popup_menu_open=false; parent.popup_menu.hide();';
		code += '" style="cursor:hand; font-family:Verdana; font-size:10px;"';
		code += ' onmouseover="parent.popup_menu_over(this, true);"';
		code += ' onmouseout="parent.popup_menu_over(this);">';
	
		code += '<img src="../images/icones/'+menus[i][2]+'.gif" width="20" height="20" alt="'+menus[i][0]+'" align="absmiddle" hspace="2">';
		code += '</td>';
	}
	code += '</tr></table></td></tr>';

	return code;
}

function make_popup_menu_body(innerHTML)
{
	var code = '';

	code += '<table cellspacing=1 cellpadding=0 border=0 bgcolor=black width=100% height=100%>';
	code += '<tr><td>';
	code += '<table cellspacing="0" cellpadding="0" border="0" bgcolor="buttonface" width="100%" height="100%">';
	code += '<tr bgcolor=buttonshadow><td style="font-family:Verdana; font-size:10px;" align=center>Menu</td></tr>';
	code += innerHTML;
	code += '</table>';
	code += '</td></tr>';
	code += '</table>';

	return code;
}

function close_popup_menu ()
{
	if (popup_menu_open)
	{
		popup_menu_open=false;
	}
}

function make_popup_menu ()
{
	if(!popup_menu || !ActiveObj.Id || popup_menu_open) return false;
	popup_menu_open=true;

	var td_height = 20;
	var hr_height = 4;

	var width = 0;
	var height = 4;

	var char_width = 8;//13
	var max_chars = 0;

	var innerHTML = '';
	
	var i;
	
	for (i=0; i<Menus.length; i++)
	{
		if (Menus[i][0] instanceof Array)			// make_popup_menu_button_item
		{
			innerHTML += make_popup_menu_button_item ( Menus[i]); 
			height += td_height;
		}
		else 													// make_popup_menu_item
		{
			innerHTML += make_popup_menu_item ( Menus[i]); 
			height += td_height;
		}
	}
	
	max_chars = Math.max(max_chars, 10);
//	width     = max_chars*char_width+40;
	width     = 3*25;
		
	popup_menu.document.body.innerHTML = make_popup_menu_body ( innerHTML); height += td_height;
	popup_menu.document.body.onunload = close_popup_menu;
	popup_menu.show ( event.clientX, event.clientY, width, height, document.body);
	return false;
}

document.oncontextmenu = make_popup_menu;

// ******************************************************************************************
// ** Olivier LEMETTAIS														              www.loxal.com **
// ******************************************************************************************

function mouseover() { 
window.status = 'Les Cavaliers de Cecvan - '+mouseover.arguments[0];
}

function mouseout() { 
window.status = 'Les Cavaliers de Cecvan'; 
}

function setLg (lg) {
	document.forms.lxl._lg_.value=lg;
	document.forms.lxl.submit();
}

function setMenu (menu) {
	document.forms.lxl._lg_.value=document.forms.lxl._lg__.value;
	document.forms.lxl._menu_.value=menu;
	document.forms.lxl._sousmenu_.value='0';
	document.forms.lxl._pagemenu_.value='0';
	document.forms.lxl.submit();
}

function setSousMenu (sousmenu) {
	document.forms.lxl._lg_.value=document.forms.lxl._lg__.value;
	document.forms.lxl._menu_.value=document.forms.lxl._menu__.value;
	document.forms.lxl._sousmenu_.value=sousmenu;
	document.forms.lxl._pagemenu_.value='0';
	document.forms.lxl.submit();
}

function setPage (page) {
	document.forms.lxl._lg_.value=document.forms.lxl._lg__.value;
	document.forms.lxl._menu_.value=document.forms.lxl._menu__.value;
	document.forms.lxl._sousmenu_.value=document.forms.lxl._sousmenu__.value;
	document.forms.lxl._pagemenu_.value=page;
	document.forms.lxl.submit();
}

function seePhoto( lien, nom, ww, hh) {
	document.images[lien].src    = nom;
	document.images[lien].width  = ww; 
	document.images[lien].height = hh; 
	window.status = 'Les Cavaliers de Cecvan'; 
}

function setAction (action) {
	document.forms.lxl._lg_.value=document.forms.lxl._lg__.value;
	document.forms.lxl._menu_.value=document.forms.lxl._menu__.value;
	document.forms.lxl._sousmenu_.value=document.forms.lxl._sousmenu__.value;
	document.forms.lxl._pagemenu_.value=document.forms.lxl._pagemenu__.value;
	document.forms.lxl._action_.value=action;
	document.forms.lxl.submit();
}

function setEdt (id) {
	document.forms.lxl._id_edt_.value=id;
	document.forms.lxl._menu_edt_.value=document.forms.lxl._menu__.value;
	document.forms.lxl._sousmenu_edt_.value=document.forms.lxl._sousmenu__.value;
	document.forms.lxl._pagemenu_edt_.value=document.forms.lxl._pagemenu__.value;
	document.forms.lxl._menu_.value='admin';
	document.forms.lxl._sousmenu_.value='9998';
	document.forms.lxl.submit();
}

function setPopup (page) {
	var url = '/popup.php?';
	url += '_page_='+page;
	url += '&_ADMIN_='+document.forms.lxl._ADMIN_.value;
	url += '&_lg_='+document.forms.lxl._lg__.value;
	window.open ( url, 'popup', 'toolbar=0,scrollbars=0,location=0,statusbar=1,menubar=0,resizable=0,width=350,height=250');
}

function setSound () {
	var url = '/sound.php';
	window.open ( url, 'sound', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=130,height=10');
}

function change_photo( obj, id)
{
	var parameters = window.showModalDialog ( "/forms/form_files.php?withaction=2&withmenu=0", "", "dialogWidth:450px; dialogHeight:300px; status:no; scroll:yes; help:no");	
	eval ( 'photoid = document.forms.lxl.'+id);
	photoid.value = parameters[3];
	obj.src    = '/forms/photo.php?id='+parameters[3];
	obj.width  = parameters[1];
	obj.height = parameters[2];
//	alert ( parameter);
//	alert ( parameters[1]);
}

this.name = 'namepagedbmckc';

//window.history.forward(1);

mouseout();
