Ext.BLANK_IMAGE_URL = './css/images/default/s.gif';
Ext.MessageBox.buttonText.yes = "oui"; //french
Ext.MessageBox.buttonText.no = "non"; //french
Ext.MessageBox.buttonText.ok = "ok"; //french
Ext.MessageBox.buttonText.cancel = "annuler"; //french


var add_event = new Array();
var add_tooltip = new Array();

function AjaxError(text)
{	
	$('ajax_error').innerHTML = text;
	$('ajax_error').innerHTML += '<br>Contacter l\'administrateur';
	$('ajax_error').show();
}


function MyAjaxCall(php,parameters,callback)
{
	new Ajax.Request('./bib_php/' + php, 
	{
		method:'post',
		parameters : parameters,
		onSuccess : function(transport,json)  { 
				MyWaitHide();
				if (transport.responseText.length > 0) 
				{
					AjaxError(transport.responseText,php,call,'php');
					return;
				}
				if (json.code == 0)
				{
					callback(json);
				}
				else
				{
					AjaxError(json.errorMsg,php,call,'ajax');
				}
			},
		onException : function(request,exception) { 
			MyWaitHide();
			AjaxError(exception,php,call,'ajax > exception');
			}	
	});
}



// conversion entre extjs et mysql
function ExtJS2MysqlDate(d)
{
	alert(Ext.util.JSON.decode(d));
	if (d != "") d = d.substr(0,10);
	return(d);
}


function ExtendedCharEncode(str)
{
	// EN PREMIER !!
	str = (str.replace(/&/g,    "&amp;"));

	str = (str.replace(/à/g, "&agrave;"));
	str = (str.replace(/é/g, "&eacute;"));
	str = (str.replace(/è/g, "&egrave;"));
	str = (str.replace(/ê/g,  "&ecirc;"));
	str = (str.replace(/ç/g, "&ccedil;"));
	str = (str.replace(/ë/g,   "&euml;"));
	str = (str.replace(/ï/g,   "&iuml;"));
	str = (str.replace(/â/g,  "&acirc;"));
	str = (str.replace(/î/g,  "&icirc;"));
	str = (str.replace(/ô/g,  "&ocirc;"));
	str = (str.replace(/ù/g, "&ugrave;"));
	str = (str.replace(/û/g,  "&ucirc;"));
	
	str = (str.replace(/"/g,   "&quot;"));
	
	str = (str.replace(/«/g,   "&laquo;"));
	str = (str.replace(/»/g,   "&raquo;"));
	
	
	str = (str.replace(/€/g,   "&euro;"));
	
	
	
	
	return(str);
}
function ExtendedCharDecode(str)
{
	str = (str.replace(/&agrave;/g, "à"));
	str = (str.replace(/&eacute;/g, "é"));
	str = (str.replace(/&egrave;/g, "è"));
	str = (str.replace(/&ecirc;/g,  "ê"));
	str = (str.replace(/&ccedil;/g, "ç"));
	str = (str.replace(/&euml;/g,   "ë"));
	str = (str.replace(/&iuml;/g,   "ï"));
	str = (str.replace(/&acirc;/g,  "â"));
	str = (str.replace(/&icirc;/g,  "î"));
	str = (str.replace(/&ocirc;/g,  "ô"));
	str = (str.replace(/&ugrave;/g, "ù"));
	str = (str.replace(/&ucirc;/g,  "û"));
	
	str = (str.replace(/&Agrave;/g, "À"));
	str = (str.replace(/&Eacute;/g, "É"));
	str = (str.replace(/&Egrave;/g, "è"));
	str = (str.replace(/&Ecirc;/g,  "ê"));
	str = (str.replace(/&Ccedil;/g, "ç"));
	str = (str.replace(/&Euml;/g,   "ë"));
	str = (str.replace(/&Iuml;/g,   "ï"));
	str = (str.replace(/&Acirc;/g,  "â"));
	str = (str.replace(/&Icirc;/g,  "î"));
	str = (str.replace(/&Ocirc;/g,  "ô"));
	str = (str.replace(/&Ugrave;/g, "ù"));
	str = (str.replace(/&Ucirc;/g,  "û"));
	
	str = (str.replace(/&quot;/g,   "\""));
	
	str = (str.replace(/&laquo;/g,   "«"));
	str = (str.replace(/&raquo;/g,   "»"));
	
	str = (str.replace(/&euro;/g,   "€"));
	
	
	// EN DERNIER !!
	str = (str.replace(/&amp;/g,    "&"));
	
	return(str);
}

function tooltip_init()
{
	// On commence par vider la liste des evenetmeents !
	
	var add_tooltip = new Array();
}

function event_init()
{
	var add_event = new Array();
}


function img_menu(tag_id,img_file,w,h,tooltip,event,un_event,style,link)
{
	tag = "";
	
	tag = '<img ';
	tag += (tag_id != "") ? ' id="'+tag_id+'"' : '';
	tag += ' src="'+img_file+'" width="'+w+'" height="'+h+'"';
	tag += (style != "") ? ' style="'+style+'"' : '';
	tag += '>';
	if (tag_id != "")
	{
		if (tooltip != "") { add_tooltip.push(new Array(tag_id,tooltip)) };
		if (event != "") { add_event.push(new Array(tag_id,event,un_event)) };
	}
	if (link != "")
	{
		tag = '<a href="'+link+'" target = "_blank">'+tag+'</a>';
	}
	return(tag);
}

