function getErrorImage(id, text)
{
	return text;
}

function generateTooltips()
{
	$("img").tooltip(
	{
			showURL: false,
			opacity: 0.99,
			fade: 150,
			positionRight: true,
			bodyHandler: function()
			 {
				return $("#"+this.id).attr("hovertext");
			 }
	});
}

function initTooltip(div)
{
  $(div).mouseover(function(){
 	 generateTooltips();
	});
}

function connect (lg, pd, success, failure, err)
	{
		var cpd = MD5("$1$/G10LWKG" + lg.toUpperCase() + "*" + pd);
		$.ajax({
			type:"POST",
			dataType:"text",
			url: "/login",
			success: function(data)
			{
				if (data == '<connection result="success"/>')
				{
					if (typeof(success) == "function")
						success();
				}
				else
				{
					if (typeof(failure) == "function")
						failure();			
				}
			},
			error:function(data)
			{
				if (typeof(err) == "function")
					err();
			},				
			data:{login:lg, password:cpd, lang:"FRA"}
			}
			);
	}
	
	function setTabs(menuName, divName, select)
	{
		var n = 0;
		$('#' + divName).children().each(
		function()
		{
			var titleLi = $("#" + menuName + " li:nth-child(" + ($(this).index() + 1) + ")");
			if (n != select)
			{
				$("#" + this.id).hide();
				titleLi.removeClass("selectedTab");
			}
			else
			{
				$("#" + this.id).show();
				titleLi.addClass("selectedTab");
			}			
			n++;
		});
	}
	
	function initTabs(menuName, divName)
	{								
		setTabs(menuName, divName, 0);
		$('#' + menuName).children().each(
		function()
		{
			$("#" + this.id).click(function (event)
			{	
				setTabs(menuName, divName, $("#" + this.id).index());
			});
		});
	}
	
	function resizeImage(which, maxWidth, maxHeight)
	{
	  var elem = document.getElementById(which);
	  var ratio = elem.width / elem.height;
	  var newH = maxHeight * ratio;
	  
	  
	  if (elem == undefined || elem == null) return false;
	 
	  if (elem.width > elem.height)
	  {
		if (elem.width > maxWidth)
		{
			elem.width = maxWidth;
		}
	  }
	  else
	  {
		if (elem.height > maxHeight)
		{
			elem.height = maxHeight;
		}
	  }
	}
