var txt_lis		= '';
var img_lis		= '';
var effet_lis	= '';

function ferme_bulle(id)
{

	var bulle_sombre	= document.getElementById('bulle_sombre');
	var bulle			= document.getElementById(id);

	if (bulle_sombre)
	{
		bulle_sombre.style.display = 'none';
	}
	
	bulle.style.display = 'none';
}

function cree_bulle_sombre()
{
	var bulle_sombre = document.getElementById('bulle_sombre');

	if (!bulle_sombre)
	{
		document.write('<div id="bulle_sombre">&nbsp;</div>');
	}
}

function aff_bulle_sombre()
{
	var bulle_sombre = document.getElementById('bulle_sombre');

	if (txt_lis != '')
	{
		document.getElementById('album_menu').alerter(txt_lis, img_lis, effet_lis);
	}

	if (bulle_sombre)
	{
		bulle_sombre.style.width	= document.body.scrollWidth +'px';
		bulle_sombre.style.height	= document.body.scrollHeight +'px';
	}
}


function aff_bulle_sombre_asap()
{
	var bulle_sombre = document.getElementById('bulle_sombre');

	if (txt_lis != '')
	{
		document.getElementById('album_menu').alerter(txt_lis, img_lis, effet_lis);
	}
	if (bulle_sombre)
	{
		bulle_sombre.style.width	= '2000px';
		bulle_sombre.style.height	= '2000px';
	}
}






function aff_bulle(id, display)
{
	document.getElementById(id).style.display = display;
}

function getPosMouse(e)
{
	x = (navigator.appName.substring(0,3) == 'Net') ? e.pageX : event.x + document.documentElement.scrollLeft;
	y = (navigator.appName.substring(0,3) == 'Net') ? e.pageY : event.y + document.documentElement.scrollTop;
	tab_mouse = new Array(x,y);
}

function aff_bulle_click(id, masque)
{
	var bulle	= document.getElementById(id);
	var width	= bulle.style.width;
	var height	= bulle.style.height;
	var pos_x	= parseInt(tab_mouse[0]);
	var pos_y	= parseInt(tab_mouse[1]);
	var tab_div	= bulle.getElementsByTagName('div');
	var pointe;
	var classe;

	if (masque === true)
	{
		masque_bulle();
	}

	for (var i = 0; i < tab_div.length; i++)
	{
		classe = tab_div[i].className;

		if (classe && classe.substr(0, 13) == 'pointe_bulle_')
		{
			pointe = classe.substr(13, 2);
		}
	}

	switch (pointe)
	{
		case 'hg':
			pos_x -= 14;
			pos_y += 60;
		break;

		case 'hd':
			pos_x -= (parseInt(width.substr(0, (width.length - 2))) - 20);
			pos_y += 60;
		break;

		case 'dh':
			pos_x -= (parseInt(width.substr(0, (width.length - 2))) + 60);
			pos_y -= 19;
		break;

		case 'db':
			pos_x -= (parseInt(width.substr(0, (width.length - 2))) + 60);
			pos_y -= (parseInt(height.substr(0, (height.length - 2))) - 19);
		break;

		case 'bd':
			pos_x -= (parseInt(width.substr(0, (width.length - 2))) - 20);
			pos_y -= (parseInt(height.substr(0, (height.length - 2))) + 60);
		break;

		case 'bg':
			pos_x -= 19;
			pos_y -= (parseInt(height.substr(0, (height.length - 2))) + 60);
		break;

		case 'gb':
			pos_x += 60;
			pos_y -= (parseInt(height.substr(0, (height.length - 2))) - 19);
		break;

		case 'gh':
			pos_x += 60;
			pos_y -= 19;
		break;
	}


	bulle.style.display	= 'block';
	bulle.style.left	= pos_x +'px';
	bulle.style.top		= pos_y +'px';
}


function masque_bulle()
{
	var tab_div	= document.getElementsByTagName('div');

	for (var i = 0; i < tab_div.length; i++)
	{
		classe = tab_div[i].className;

		if (classe && classe == 'div_bulle')
		{
			tab_div[i].style.display = 'none';
		}
	}
}


function bulle_start_drag(e)
{
	bulle_div = document.getElementById(this.id);

	if (document.all)
	{
		window.lastX	= event.clientX;
		window.lastY	= event.clientY;
	}
	else
	{
		window.lastX	= e.clientX;
		window.lastY	= e.clientY;
	}

	bulle_div.onmousemove	= bulle_do_drag;
	bulle_div.onmouseup		= bulle_end_drag;
}


function bulle_do_drag(e)
{
	if (!no_drag)
	{
		if (document.all)
		{
			var difX				= event.clientX - window.lastX;
			var difY				= event.clientY - window.lastY;
			var newX1				= parseInt(bulle_div.style.left) + difX;
			var newY1				= parseInt(bulle_div.style.top) + difY;
			bulle_div.style.left	= newX1 + 'px';
			bulle_div.style.top		= newY1 + 'px';
			window.lastX			= event.clientX;
			window.lastY			= event.clientY;
		}
		else
		{
			var difX				= e.clientX - window.lastX;
			var difY				= e.clientY - window.lastY;
			var newX1				= parseInt(bulle_div.style.left) + difX;
			var newY1				= parseInt(bulle_div.style.top) + difY;
			bulle_div.style.left	= newX1 + 'px';
			bulle_div.style.top		= newY1 + 'px';
			window.lastX			= e.clientX;
			window.lastY			= e.clientY;
		}
	}
}



function bulle_end_drag(e)
{
	bulle_div.onmousemove = null;
}


function bulle_no_drag(etat)
{
	no_drag = etat;
}


function no_drag_on_input()
{
	no_drag = false;
	var indefini;
	var tab_input	= document.getElementsByTagName('input');
	var tab_select	= document.getElementsByTagName('select');

	for (i = 0; i < tab_input.length; i++)
	{
		if (tab_input[i].onfocus == indefini)
		{
			tab_input[i].onfocus	= function(){bulle_no_drag(true)};
			tab_input[i].onblur		= function(){bulle_no_drag(false)};
		}
	}

	for (i = 0; i < tab_select.length; i++)
	{
		if (tab_select[i].onfocus == indefini)
		{
			tab_select[i].onfocus	= function(){bulle_no_drag(true)};
			tab_select[i].onblur	= function(){bulle_no_drag(false)};
		}
	}
}


if (window.addEventListener)
{
	window.addEventListener('load', aff_bulle_sombre, false);
	window.addEventListener('load', no_drag_on_input, false);
	window.addEventListener('mousemove', getPosMouse, false);
}
else if (window.attachEvent)
{
	window.attachEvent('onload', aff_bulle_sombre);
	window.attachEvent('onload', no_drag_on_input);
	document.onmousemove = getPosMouse;
}


