// We like ugly fixes.
is_ie 				= false;
var delete_url		= './ajax.php?m=delete&sid=e017b11f1221c9a91a1f25ac415fc7cc';
var edit_url    	= './ajax.php?m=edit&sid=e017b11f1221c9a91a1f25ac415fc7cc';
var version_url    	= './ajax.php?m=version&sid=e017b11f1221c9a91a1f25ac415fc7cc';
var print_ver		= 'Breizh Shoutbox v1.1.0';
var print_ver_alt 	= 'Breizh Shoutbox v1.1.0 © 2010';
var print_perm		= '';


function shout_popup(pop_url)
{
	popup(pop_url, '1000', '580', '_blank', "toolbar=0,menubar=0,scrollbars=0,statusbar=0,copyhistory=0,directories=0");
	return false;
}

function forum_url(url)
{
	window.open(url, '_blank'); 
	return false;
}

function shout_priv(url)
{
	window.open(url); 
	return false;
}

function more_smilies()
{
	popup('./ajax.php?m=smilies_popup&amp;sid=e017b11f1221c9a91a1f25ac415fc7cc', '600', '450', '_phpbbsmilies');
	return false;
}

function load_shout()
{
	try
	{
		var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
		if (display_shoutbox == false)
		{
			return;
		}
		
		if (document.getElementById('shoutbox') == null)
		{
		
			var ev = err_msg('La div shoutbox ne peut pas être trouvée.', true);
	
			ev.name = 'E_CORE_ERROR';
			throw ev; 
			return;
		}
		else
		{
			div = document.getElementById('shoutbox');
			div.innerHTML = '';

			// Display message ;)
			message('Chargement...');
			// HTTP vars, required to relead/post things.
			
			hin = http();
			
			if (!hin)
			{
				return;
			}
			hin2 = http();
			huit = http();	
			hsmilies = http();
			hnr = http();
						// Div exists in the html, write it.
			write_main();
		}
	}
	catch (e)
	{
			handle(e);
			return;
	}
}

function write_main()
{
	try
	{
		// Write the base.

		var base = ce('ul');
		base.className = 'topiclist forums';
		base.id = 'base_ul'
		base.style.height = '97%';

		var li = ce('li');
		li.style.display = 'none';
		li.className = 'button_background button_background_transparent';
		var dl = ce('dl');
		dl.style.width = '100%';
		var posting_form = ce('dt');
		posting_form.id = 'post_message';
		posting_form.className = 'row';
		
		posting_form.style.display = 'none';
		posting_form.style.paddingtop = '5px';
		posting_form.height = '20px';
		posting_form.style.width = '99.5%';

		var posting_box = ce('form');
		posting_box.id = 'chat_form';

		
				
		li.style.display = 'block';
		li.style.borderBottom = '1px solid #00608F';
		
		posting_box.appendChild(tn(' '));
		posting_box.appendChild(tn('Message: '));

		el = null;
		var el = ce('input');el.className = 'inputbox';el.name = el.id = 'chat_message';el.style.width = '325px';
		el.onkeypress = function(evt)
		{
			try
			{
				evt = (evt) ? evt : event;
				var c = (evt.wich) ? evt.wich : evt.keyCode;
				if (c == 13)
				{
					document.getElementById('user').click();
					evt.returnValue = false;
					this.returnValue = false;
					return false;
				}
				return true;
			}
			catch (e)
			{
				handle(e);
				return;
			}
		}	
		posting_box.appendChild(el);
		posting_box.appendChild(tn(' '));

		var el = ce('input');el.name = el.id = 'user';el.value = el.defaultValue = 'Poster';el.title = 'Poster un message';el.type = 'button';el.className = 'button1 btnmain';
		el.onclick = function()
		{
			try
			{
								if (smilies == true)
				{
					smilies = false;
					document.getElementById('smilies').innerHTML = '';
					document.getElementById('smilies').style.display = 'none';
					el.title = 'Refermer le panneau des Smileys';
				}
								if (colour == true)
				{
					colour = false;
					document.getElementById('colour').innerHTML = '';
					document.getElementById('colour').style.display = 'none';
					colored.title = 'Refermer la colorisation du texte';
				}
							
				// Here we send later the message ;)
				this.disabled = true;
				
	
				document.getElementById('post_message').style.display = 'none';
				this.disabled = false;
				document.getElementById('msg_txt').innerHTML = '';
				document.getElementById('msg_txt').appendChild(tn('Envoi du message...'));

				if (document.getElementById('chat_message').value == '')
				{
					document.getElementById('msg_txt').innerHTML = '';
					throw err_msg('Le message est vide.', true);
				}

				if (huit.readyState == 4 || huit.readyState == 0)
				{

					// Lets got some nice things :D
					huit.open('POST','./ajax.php?m=post&sid=e017b11f1221c9a91a1f25ac415fc7cc&rand='+Math.floor(Math.random() * 300000),true);

					huit.onreadystatechange = function()
					{
						try
						{
							if (huit.readyState != 4)
							{
								return;
							}
							if (huit.readyState == 4)
							{
								xml = huit.responseXML;
								
								if (typeof xml != 'object')
								{
									throw err_msg(lang['SERVER_ERR']);
									return;
								}
								
								if (xml.getElementsByTagName('error') && xml.getElementsByTagName('error').length != 0)
								{
									err = xml.getElementsByTagName('error')[0].childNodes[0].nodeValue;
									document.getElementById('msg_txt').innerHTML = '';
									document.getElementById('post_message').style.display = 'block';
									last = 0;
									message(err, true);
									return;
								}
								else
								{
									document.getElementById('msg_txt').innerHTML = '';
									document.getElementById('msg_txt').appendChild(tn('Message posté...'));
									setTimeout("document.getElementById('msg_txt').innerHTML = ''",2000);
									document.getElementById('post_message').style.display = 'block';
									count = 0;// Set count to 0, because otherwise user willn't see his message
									clearTimeout(timer_in);
									timer_in = setTimeout('reload_post();reload_page();', 200);
									setTimeout('last = 0;', 500);
								}
								document.getElementById('chat_message').focus();
							}
						}
						catch (e)
						{
							handle(e);
							return;
						}
					}
					post = 'chat_message=';

					post += encodeURIComponent(document.getElementById('chat_message').value);

					document.getElementById('chat_message').value = '';
					
										if (smilies == true)
					{
						smilies = false;
						document.getElementById('smilies').innerHTML = '';
						document.getElementById('smilies').style.display = 'none';
						el.title = 'Refermer le panneau des Smileys';
					}
										if (colour == true)
					{
						colour = false;
						document.getElementById('colour').innerHTML = '';
						document.getElementById('colour').style.display = 'none';
						colored.title = 'Refermer la colorisation du texte';
					}
										huit.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

					huit.send(post);
				}
				else
				{
					throw err_msg('This should not happen, double request found!');
				}
			}
			catch (e)
			{
				document.getElementById('post_message').style.display = 'inline';
				setTimeout("document.getElementById('msg_txt').innerHTML = ''",3000);
				handle(e);
				return;
			}
		}
		posting_box.appendChild(el);
		posting_box.appendChild(tn(' '));
		
				el = ce('input')
		el.value = el.defaultValue = '';
		el.type = 'button';
		el.className = 'button_shout_smile button_shout';
		if (smilies == true){el.title = 'Refermer le panneau des Smileys';}else{el.title = 'Inclure des Smileys';}
		el.onclick = function()
		{
			try
			{
				if (smilies == true)
				{
					smilies = false;
					document.getElementById('smilies').innerHTML = '';
					document.getElementById('smilies').style.display = 'none';
					el.title = 'Inclure des Smileys';
				}
				else
				{
					smilies = true;
					document.getElementById('smilies').style.display = 'block';
					document.getElementById('smilies').appendChild(tn('Chargement...'));
					el.title = 'Refermer le panneau des Smileys';
					if (hsmilies.readyState == 4 || hsmilies.readyState == 0)
					{

						// Lets got some nice things :D
						hsmilies.open('GET','./ajax.php?m=smilies&sid=e017b11f1221c9a91a1f25ac415fc7cc&rand='+Math.floor(Math.random() * 300000),true);

						hsmilies.onreadystatechange = function()
						{
							try
							{
								if (hsmilies.readyState != 4)
								{
									return;
								}
								if (hsmilies.readyState == 4)
								{
									xml = hsmilies.responseXML;
									
									if (typeof xml != 'object')
									{
										throw err_msg(lang['SERVER_ERR']);
										return;
									}
									
									if (xml.getElementsByTagName('error') && xml.getElementsByTagName('error').length != 0)
									{
										err = xml.getElementsByTagName('error')[0].childNodes[0].nodeValue;
										document.getElementById('smilies').innerHTML = '';
										message(err, true);
									}
									else
									{
										document.getElementById('smilies').innerHTML = '';
										var tmp = xml.getElementsByTagName('smilies');
										for (var i = (tmp.length - 1); i >= 0 ; i--)
										{
											var inh = tmp[i];
											var a = ce('a');
											a.code = inh.getElementsByTagName('code')[0].childNodes[0].nodeValue;
											a.title = inh.getElementsByTagName('title')[0].childNodes[0].nodeValue;
											a.style.cursor = 'pointer';
											a.onclick = function() { document.getElementById('chat_message').value += ' ' + this.code + ' '; }
											
											var img = ce('img');
											img.src = inh.getElementsByTagName('img')[0].childNodes[0].nodeValue;
											img.width = inh.getElementsByTagName('width')[0].childNodes[0].nodeValue;
											img.title = inh.getElementsByTagName('title')[0].childNodes[0].nodeValue;
											img.alt = inh.getElementsByTagName('code')[0].childNodes[0].nodeValue;
											img.border = 0;
											
											a.appendChild(img);
											document.getElementById('smilies').appendChild(a);
											document.getElementById('smilies').appendChild(tn(' '));
										}
										var a = ce('a');
										a.title = 'Cliquez ici pour voir plus de smilies';
										a.style.cursor = 'pointer';
										a.style.marginBottom = '5px';
										a.onclick = function() { more_smilies(); }
										a.appendChild(tn(' Plus de smilies'));
										document.getElementById('smilies').appendChild(a);
										document.getElementById('smilies').appendChild(tn(' '));
									}
								}
							}
							catch (e)
							{
								handle(e);
								return;
							}
						}
						hsmilies.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
						hsmilies.send(null);
					}
				}
			}
			catch (e)
			{
				handle(e);
				return;
			}
		}
		posting_box.appendChild(el);posting_box.appendChild(tn(' '));
				var colored = ce('input');colored.type = 'button';colored.className = 'button_shout_color button_shout';colored.accesskey = 'co';colored.name = colored.id = 'color_0';colored.value = colored.defaultValue = '';
		if (colour == true){colored.title = 'Refermer la colorisation du texte';}else{colored.title = 'Coloriser le texte';}
		colored.onclick = function()
		{
			if (colour == true)
			{
				colour = false;
				document.getElementById('colour').innerHTML = '';
				document.getElementById('colour').style.display = 'none';
				colored.title = 'Coloriser le texte';
			}
			else
			{
				colour = true;
				document.getElementById('colour').style.display = 'block';
				colored.title = 'Refermer la colorisation du texte';
				var s_img = 'images/spacer.gif';
				p_width = '25';
				p_height = '11';
				
				var table = ce('table');table.cellSpacing = '5';table.cellPadding = '1';table.border = '0';

				var tr = ce('tr');tr.appendChild(tn('Couleurs: '));
				
				var td = ce('td');td.bgColor= '#000000';td.style.width = p_width + 'px';td.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function(){bbfontstyle('[color=#000000]', '[/color]');return false;}
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'noir';img.title = 'noir';
				a.appendChild(img);td.appendChild(a);tr.appendChild(td);
				
				var tdbrown = ce('td');tdbrown.bgColor= '#A52A2A';tdbrown.style.width = p_width + 'px';tdbrown.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#A52A2A]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'marron';img.title = 'marron';
				a.appendChild(img);tdbrown.appendChild(a);tr.appendChild(tdbrown);
							
				var tddark_red = ce('td');tddark_red.bgColor= '#8B0000';tddark_red.style.width = p_width + 'px';tddark_red.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function(){bbfontstyle('[color=#8B0000]', '[/color]');return false;}
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'rouge foncé';img.title = 'rouge foncé';
				a.appendChild(img);tddark_red.appendChild(a);tr.appendChild(tddark_red);
				
				var tdred = ce('td');tdred.bgColor= '#FF0000';tdred.style.width = p_width + 'px';tdred.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#FF0000]', '[/color]');return false; } 
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'rouge';img.title = 'rouge';
				a.appendChild(img);tdred.appendChild(a);tr.appendChild(tdred);
				
				var tdorange = ce('td');tdorange.bgColor= '#FFA500';tdorange.style.width = p_width + 'px';tdorange.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#FFA500]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'orange';img.title = 'orange';
				a.appendChild(img);tdorange.appendChild(a);tr.appendChild(tdorange);
				
				var tdyellow = ce('td');tdyellow.bgColor= '#FFFF00';tdyellow.style.width = p_width + 'px';tdyellow.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#FFFF00]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'jaune';img.title = 'jaune';
				a.appendChild(img);tdyellow.appendChild(a);tr.appendChild(tdyellow);
				
				var tdlight_green = ce('td');tdlight_green.bgColor= '#80FF40';tdlight_green.style.width = p_width + 'px';tdlight_green.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#80FF40]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'vert clair';img.title = 'vert clair';
				a.appendChild(img);tdlight_green.appendChild(a);tr.appendChild(tdlight_green);
				
				var tdgreen = ce('td');tdgreen.bgColor= '#40BF00';tdgreen.style.width = p_width + 'px';tdgreen.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#40BF00]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'vert';img.title = 'vert';
				a.appendChild(img);tdgreen.appendChild(a);tr.appendChild(tdgreen);
				
				var tddark_green = ce('td');tddark_green.bgColor= '#008000';tddark_green.style.width = p_width + 'px';tddark_green.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#008000]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'vert foncé';img.title = 'vert foncé';
				a.appendChild(img);tddark_green.appendChild(a);tr.appendChild(tddark_green);
				
				var tdolive = ce('td');tdolive.bgColor= '#808000';tdolive.style.width = p_width + 'px';tdolive.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#808000]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'olive';img.title = 'olive';
				a.appendChild(img);tdolive.appendChild(a);tr.appendChild(tdolive);
				
				var tdcyan = ce('td');tdcyan.bgColor= '#00FFFF';tdcyan.style.width = p_width + 'px';tdcyan.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#00FFFF]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'cyan';img.title = 'cyan';
				a.appendChild(img);tdcyan.appendChild(a);tr.appendChild(tdcyan);
				
				var tdblue = ce('td');tdblue.bgColor= '#0000FF';tdblue.style.width = p_width + 'px';tdblue.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#0000FF]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'bleu';img.title = 'bleu';
				a.appendChild(img);tdblue.appendChild(a);tr.appendChild(tdblue);
				
				var tddark_blue = ce('td');tddark_blue.bgColor= '#00008B';tddark_blue.style.width = p_width + 'px';tddark_blue.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#00008B]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'bleu foncé';img.title = 'bleu foncé';
				a.appendChild(img);tddark_blue.appendChild(a);tr.appendChild(tddark_blue);
				
				var tdindigo = ce('td');tdindigo.bgColor= '#4B0082';tdindigo.style.width = p_width + 'px';tdindigo.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#4B0082]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'indigo';img.title = 'indigo';
				a.appendChild(img);tdindigo.appendChild(a);tr.appendChild(tdindigo);
				
				var tdviolet = ce('td');tdviolet.bgColor= '#8000BF';tdviolet.style.width = p_width + 'px';tdviolet.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#8000BF]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'violet';img.title = 'violet';
				a.appendChild(img);tdviolet.appendChild(a);tr.appendChild(tdviolet);
				
				var tdwhite = ce('td');tdwhite.bgColor= '#FFFFFF';tdwhite.style.width = p_width + 'px';tdwhite.style.height = p_height + 'px';
				var a = ce('a');a.href = '#';a.onclick = function() { bbfontstyle('[color=#FFFFFF]', '[/color]'); return false; }
				var img = ce('img');img.src = s_img;img.width = p_width;img.height = p_height;img.border = 0;img.alt = 'blanc';img.title = 'blanc';
				a.appendChild(img);tdwhite.appendChild(a);tr.appendChild(tdwhite);
				
				tr.appendChild(tn(' '));
				table.appendChild(tr);
				document.getElementById('colour').appendChild(table);
				document.getElementById('colour').appendChild(tn(' '));
			}
		}
		posting_box.appendChild(colored);posting_box.appendChild(tn(' '));
				var bbcode = ce('input');bbcode.type = 'button';bbcode.className = 'button_shout_bold button_shout';bbcode.accesskey = 'b';bbcode.name = bbcode.id = 'addbbcode0';bbcode.value = bbcode.defaultValue = '';bbcode.title = 'Mettre en gras';
		bbcode.onclick = function(){var tfn = form_name;form_name = 'chat_form';var ttn = text_name;text_name = 'chat_message';bbstyle(0);form_name = tfn;text_name = ttn;}
		posting_box.appendChild(bbcode);posting_box.appendChild(tn(' '));

		var bbcode = ce('input');bbcode.type = 'button';bbcode.className = 'button_shout_italic button_shout';bbcode.accesskey = 'i';bbcode.name = bbcode.id = 'addbbcode2';bbcode.value = bbcode.defaultValue = '';bbcode.title = 'Mettre en italique';
		bbcode.onclick = function(){var tfn = form_name;form_name = 'chat_form';var ttn = text_name;text_name = 'chat_message';bbstyle(2);form_name = tfn;text_name = ttn;}
		posting_box.appendChild(bbcode);posting_box.appendChild(tn(' '));

		var bbcode = ce('input');bbcode.type = 'button';bbcode.className = 'button_shout_under button_shout';bbcode.accesskey = 'u';bbcode.name = bbcode.id = 'addbbcode4';bbcode.value = bbcode.defaultValue = '';bbcode.title = 'Souligner le texte';
		bbcode.onclick = function(){var tfn = form_name;form_name = 'chat_form';var ttn = text_name;text_name = 'chat_message';bbstyle(4);form_name = tfn;text_name = ttn;}
		posting_box.appendChild(bbcode);posting_box.appendChild(tn(' '));

		var bbcode = ce('input');bbcode.type = 'button';bbcode.className = 'button_shout_img button_shout';bbcode.accesskey = 'p';bbcode.name = bbcode.id = 'addbbcode6';bbcode.value = bbcode.defaultValue = '';bbcode.title = 'inclure une image';
		bbcode.onclick = function(){var tfn = form_name;form_name = 'chat_form';var ttn = text_name;text_name = 'chat_message';bbstyle(6);form_name = tfn;text_name = ttn;}
		posting_box.appendChild(bbcode);posting_box.appendChild(tn(' '));

		var bbcode = ce('input');bbcode.type = 'button';bbcode.className = 'button_shout_url button_shout';bbcode.accesskey = 'w';bbcode.name = bbcode.id = 'addbbcode8';bbcode.value = bbcode.defaultValue = '';bbcode.title = 'inclure une adresse web';
		bbcode.onclick = function(){var tfn = form_name;form_name = 'chat_form';var ttn = text_name;text_name = 'chat_message';bbstyle(8);form_name = tfn;text_name = ttn;}
		posting_box.appendChild(bbcode);posting_box.appendChild(tn(' '));
				var popup = ce('input');popup.type = 'button';popup.className = 'button_shout_popup_no button_shout';popup.value = popup.defaultValue = '';popup.title = 'Vous n’êtes pas autorisé à utiliser la shoutbox dans une popup...';popup.onclick = function() {alert('Vous n’êtes pas autorisé à utiliser la shoutbox dans une popup...');}
		posting_box.appendChild(popup);posting_box.appendChild(tn(' '));
		
				var purge_r = ce('input');purge_r.type = 'button';purge_r.name = purge_r.id = 'user';purge_r.className = 'button_shout_robot_no button_shout';purge_r.value = purge_r.defaultValue = '';purge_r.title = 'Vous n’êtes pas autorisé à purger les infos de la shoutbox';
		purge_r.onclick = function(){alert('Vous n’êtes pas autorisé à purger les infos de la shoutbox')};
		posting_box.appendChild(purge_r);posting_box.appendChild(tn(' '));
		
		var purge = ce('input');purge.type = 'button';purge.name = purge.id = 'user';purge.className = 'button_shout_purge_no button_shout';purge.value = purge.defaultValue = '';purge.title = 'Vous n’êtes pas autorisé à purger la shoutbox';
		purge.onclick = function(){alert('Vous n’êtes pas autorisé à purger la shoutbox')};
		posting_box.appendChild(purge);posting_box.appendChild(tn(' '));

				var priv = ce('input');priv.type = 'button';priv.className = 'button_shout_priv_no button_shout';priv.value = priv.defaultValue = '';priv.title = 'Vous n’êtes pas autorisé à entrer dans la shoutbox privée...';priv.onclick = function() {alert('Vous n’êtes pas autorisé à entrer dans la shoutbox privée...');}
		posting_box.appendChild(priv);posting_box.appendChild(tn(' '));
		
				var smilies = ce('div');
		smilies.style.display = 'none';
		smilies.name = smilies.id = 'smilies';
		posting_box.appendChild(smilies);
				var colour = ce('div');
		colour.style.display = 'none';
		colour.name = colour.id = 'colour';
		posting_box.appendChild(colour);
				posting_form.appendChild(posting_box);
		dl.appendChild(posting_form);
		li.appendChild(dl);
		base.appendChild(li);
		
		var msg_txt = ce('div');
		msg_txt.id = 'msg_txt';
		msg_txt.height = '180px';
		msg_txt.appendChild(tn(' '));
		base.appendChild(msg_txt);

		//In this div, the chats will be placed ;)
		var post = ce('div');
		post.style.display = 'block';
		post.id = 'msg';
		post.style.width = '99.5%';

		post.style.height = '150px';
			post.style.overflow = 'auto';		post.appendChild(tn('Chargement...'));
		base.appendChild(post);

		// pagin div - pagination
		var pagin = ce('li');
		pagin.id = 'nr';pagin.className = 'button_background button_background_transparent pagination';
		pagin.style.textAlign = 'left';pagin.style.marginTop = '0px';pagin.style.paddingTop = '2px';pagin.style.paddingBottom = '2px';pagin.style.height = '16px';pagin.style.width = '100%';
		base.appendChild(pagin);
		 
		div.innerHTML = '';
		div.appendChild(base);
		// Everyting loaded, lets select posts :)
		reload_post();
		reload_page();
	}
	catch (e)
	{
		handle(e);
		return;
	}
}

function reload_page()
{
	if (hnr.readyState == 4 || hnr.readyState == 0)
	{
	    if (error_number > 8)
	    {
	        return;
		}

		// Lets got some nice things :D
		hnr.open('GET','./ajax.php?m=number&sid=e017b11f1221c9a91a1f25ac415fc7cc&rand='+Math.floor(Math.random() * 300000),true);

		hnr.onreadystatechange = function()
		{
			try
			{
				if (hnr.readyState != 4)
				{
					return;
				}
				if (hnr.readyState == 4)
				{
					xml = hnr.responseXML;
					
					if (xml.getElementsByTagName('error') && xml.getElementsByTagName('error').length != 0)
					{
						err = xml.getElementsByTagName('error')[0].childNodes[0].nodeValue;
						message(err, true);
						return;
					}

					if (typeof xml != 'object' || xml.getElementsByTagName('nr').length <= 0)
					{
						throw err_msg(lang['SERVER_ERR']);
						return;
					}

					var nr = xml.getElementsByTagName('nr')[0].childNodes[0].nodeValue;
					var f = document.getElementById('nr');f.innerHTML = '';
					var d = ce('div');

					if (nr < 20){return;}

					var per_page = 20;
					var total_pages = Math.ceil(nr / per_page);
					var is_page = 'Page N° ';
					if (total_pages == 1 || !nr){return;}
					on_page = Math.floor(count / per_page) + 1;

					var p = ce('span');
					var a = ce('a');
					var b = ce('strong');

					if (on_page == 1)
					{
						b.appendChild(tn('1'));b.title = is_page+'1';
						p.appendChild(b);
						b = ce('strong');
					}
					else
					{
						a.c = ((on_page - 2) * per_page);a.href = 'javascript:;';a.title = 'Précédente';
						a.onclick = function(){count = this.c;last = 0;clearTimeout(timer_in);reload_post();reload_page();}
						a.appendChild(tn('Précédente'));
						p.appendChild(a);p.appendChild(tn(' '));

						a = ce('a');a.c = 0;a.href = 'javascript:;';a.title = is_page+'1';
						a.onclick = function(){count = this.c;last = 0;clearTimeout(timer_in);reload_post();reload_page();}
						a.appendChild(tn('1'));
						p.appendChild(a);
						a = ce('a');
					}

					if (total_pages > 5)
					{
						var start_cnt = Math.min(Math.max(1, on_page - 4), total_pages - 5);
						var end_cnt = Math.max(Math.min(total_pages, on_page + 4), 6);

						p.appendChild((start_cnt > 1) ? tn(' ... ') : cp());

						for (var i = start_cnt + 1; i < end_cnt; i++)
						{
							if (i == on_page)
							{
								b.appendChild(tn(i));b.title = is_page+on_page;
								p.appendChild(b);
								b = ce('strong');
							}
							else
							{
								a.c = (i - 1) * per_page;a.href = 'javascript:;';a.title = is_page+i;
								a.onclick = function(){count = this.c;last = 0;clearTimeout(timer_in);reload_post();reload_page();}
								a.appendChild(tn(i));
								p.appendChild(a);
								a = ce('a');
							}
							if (i < end_cnt - 1)
							{
								p.appendChild(cp());
							}
						}
						p.appendChild((end_cnt < total_pages) ? tn(' ... ') : cp());
					}
					else
					{
						p.appendChild(cp());
						for (var i = 2; i < total_pages; i++)
						{
							if (i == on_page)
							{
								b.appendChild(tn(i));b.title = is_page+on_page;
								p.appendChild(b);
								b = ce('strong');
							}
							else
							{
								a.c = (i - 1) * per_page;a.href = 'javascript:;';
								a.onclick = function(){count = this.c;last = 0;clearTimeout(timer_in);reload_post();reload_page();}
								a.appendChild(tn(i));
								p.appendChild(a);
								a = ce('a');
							}
							if (i < total_pages)
							{
								p.appendChild(cp());
							}
						}
					}

					if (on_page == total_pages)
					{
						b.appendChild(tn(total_pages));b.title = is_page+on_page;
						p.appendChild(b);
						b = ce('strong');
					}
					else
					{
						a = ce('a');a.c = ((total_pages - 1) * per_page);a.href = 'javascript:;';a.title = is_page+total_pages;
						a.onclick = function(){count = this.c;last = 0;clearTimeout(timer_in);reload_post();reload_page();}
						a.appendChild(tn(total_pages));

						p.appendChild(a);
						a = ce('a');a.c = ((on_page) * per_page);a.href = 'javascript:;';a.title = 'Suivante';
						a.onclick = function(){count = this.c;last = 0;clearTimeout(timer_in);reload_post();reload_page();}
						a.appendChild(tn('Suivante'));
						p.appendChild(tn(' '));p.appendChild(a);
						a = ce('a');
					}
					f.appendChild(p);
				}
			}
			catch (e)
			{
				handle(e);
				clearTimeout(timer_in);
				return;
			}
		}
		hnr.setRequestHeader('Content-Type','application/x-www-form-urlencoded');

		hnr.send(null);
	}
}

function reload_post()
{
	// If there is a open edit field, we dont reload.
	// If we reload, this edit field will be closed, and data lost.
	if (one_open)
	{
	    timer_in = setTimeout('reload_post();',3000);
		return;
	}
	
    if (error_number > 8)
    {
        return;
	}
	
	// First check if there new posts.
	if (hin2.readyState == 4 || hin2.readyState == 0)
	{
		hin2.open('GET','./ajax.php?m=check&sid=e017b11f1221c9a91a1f25ac415fc7cc&last='+last+'&rand='+Math.floor(Math.random() * 40000),true);
		hin2.onreadystatechange = function()
		{
			try
			{
				if (hin2.readyState != 4)
				{
					return;
				}
				if (hin2.readyState == 4)
				{
					if (!hin2.responseXML)
					{
						throw err_msg('Erreur XML, rafraichissez la page...');
					}
					var xml = hin2.responseXML;		
					
					if (typeof xml != 'object')
					{
						throw err_msg('Quelque chose s’est mal déroulé après avoir envoyé une requête au serveur, veuillez rafraichir la page...');
						return;
					}
					
					if (xml.getElementsByTagName('error') && xml.getElementsByTagName('error').length != 0)
					{
						err = xml.getElementsByTagName('error')[0].childNodes[0].nodeValue;
						throw err_msg(err, true);
						return;
					}
					
					if (xml.getElementsByTagName('time').length <= 0 || xml.getElementsByTagName('time')[0].childNodes.length <= 0)
					{
						throw err_msg('Quelque chose s’est mal déroulé après avoir envoyé une requête au serveur, veuillez rafraichir la page...');
						return;
					}
					
					var t = xml.getElementsByTagName('time')[0].childNodes[0].nodeValue;
					if (t == '0')
					{
						// If start is true, we let notice that there are no messages
						if (start == true)
						{
														if (first)
							{
								document.getElementById('post_message').style.display = 'inline';
								first = false;
							}
													
							var posts = document.getElementById('msg');
							posts.innerHTML = '';
							posts.appendChild(tn('Il n’y a aucun message.'));
						}
					}
					else
					{
						if (hin.readyState == 4 || hin.readyState == 0)
						{
							last = xml.getElementsByTagName('last')[0].childNodes[0].nodeValue;
							// Lets got some nice things :D
							hin.open('GET','./ajax.php?m=view&sid=e017b11f1221c9a91a1f25ac415fc7cc&start='+count+'&rand='+Math.floor(Math.random() * 300000),true);
							hin.onreadystatechange = function()
							{
								try
								{
									if (hin.readyState != 4)
									{
										return;
									}
									if (hin.readyState == 4)
									{
										if (!hin.responseXML)
										{
											throw err_msg('Erreur XML, rafraichissez la page...');
											return;
										}
										var xml = hin.responseXML;
										
										if (typeof xml != 'object')
										{
											throw err_msg(lang['SERVER_ERR']);
											return;
										}
										
										if (xml.getElementsByTagName('error') && xml.getElementsByTagName('error').length != 0)
										{
											var msg = xml.getElementsByTagName('error')[0].childNodes[0].nodeValue;
											throw err_msg(msg, true);
											return;
										}
										else
										{
											start = false;
											var tmp = xml.getElementsByTagName('posts');
											if (tmp.length == 0)
											{
																								if (first)
												{
													document.getElementById('post_message').style.display = 'inline';
													first = false;
												}
																							
												var posts = document.getElementById('msg');
												posts.innerHTML = '';
												posts.appendChild(tn('Il n’y a aucun message.'));
												timer_in = setTimeout('reload_post();',3000);
												return;
											} 
											var posts = document.getElementById('msg');
											posts.innerHTML = '';
													
											var row = false;
											for (var i = 0; i < tmp.length ; i++)
											{
												var li = ce('li');
												li.className = (!row) ? 'row row1' : 'row row2';
												row = !row;
												
												var dl = ce('dl');
												var dd = ce('dt');
												var dt = ce('dd');
												
												var inh = tmp[i];
												dd.className = 'button_background button_background_transparent';
												dd.style.styleFloat = dd.style.cssFloat = 'left';
												dd.style.width = 'auto';
												dt.style.width = 'auto';
												dt.id = 'ddshout' + i;
												dt.style.display = 'inline';
												dt.style.styleFloat = dt.style.cssFloat = 'left';
												dt.style.paddingLeft = '3px';
												dt.style.paddingRight = '5px';

												var s = ce('span');
												var msg = parse_xml_to_html(inh.getElementsByTagName('shout_text')[0]);
												
												dt.appendChild(parse_xml_to_html(inh.getElementsByTagName('shout_time')[0]));
												dt.appendChild(tn(' | '));
												dt.appendChild(parse_xml_to_html(inh.getElementsByTagName('username')[0]));
												dt.appendChild(tn(': '));

												
												delete_button = ce('input');delete_button.post_id = inh.getElementsByTagName('shout_id')[0].childNodes[0].nodeValue;delete_button.value = delete_button.defaultValue = '';delete_button.type = 'button';
												if (inh.getElementsByTagName('delete').length >= 1 &&  inh.getElementsByTagName('delete')[0].childNodes.length >= 1 && inh.getElementsByTagName('delete')[0].childNodes[0].nodeValue == 1){
													delete_button.className = 'button_shout_del button_shout_l';delete_button.style.display = 'inline';delete_button.title = 'Supprimer le message';
													delete_button.onclick = function(){this.style.display = 'none';if (confirm('Êtes vous sûr de vouloir supprimer ce message?')){delete_message(this.post_id);}else{this.style.display = 'inline';}}
												}else{
													delete_button.className = 'button_shout_del_no button_shout_l';delete_button.style.display = 'inline';delete_button.title = 'Vous n’êtes pas autorisé à supprimer le message...';
													delete_button.onclick = function(){alert('Vous n’êtes pas autorisé à supprimer le message...');}
												}
											
												dd.appendChild(delete_button);
												
												info_button = ce('input');info_button.post_id = inh.getElementsByTagName('shout_id')[0].childNodes[0].nodeValue;info_button.value = info_button.defaultValue = '';info_button.type = 'button';
												if (inh.getElementsByTagName('show_ip').length >= 1 &&  inh.getElementsByTagName('show_ip')[0].childNodes.length >= 1 && inh.getElementsByTagName('show_ip')[0].childNodes[0].nodeValue == 1){
													var textalerte = 'IP de l’auteur du message:';
													info_button.style.display = 'inline';info_button.className = 'button_shout_ip button_shout_l';info_button.title = 'Voir l’ip du posteur';info_button.ip = inh.getElementsByTagName('shout_ip')[0].childNodes[0].nodeValue;info_button.onclick = function(){alert(textalerte + '\n' + this.ip);}
												}else{
													var noiptextalerte = 'Vous n’êtes pas autorisé à voir les ip des posteurs, par contre nous voyons la vôtre...';
													info_button.style.display = 'inline';info_button.className = 'button_shout_ip_no button_shout_l';info_button.title = noiptextalerte;info_button.is_ip = inh.getElementsByTagName('is_ip')[0].childNodes[0].nodeValue;info_button.onclick = function(){alert(noiptextalerte + '\n IP: ' + this.is_ip);}
												}
												dd.appendChild(info_button);
												
												edit_button = ce('input');edit_button.post_id = inh.getElementsByTagName('shout_id')[0].childNodes[0].nodeValue;edit_button.value = edit_button.defaultValue = '';edit_button.type = 'button';
												if (inh.getElementsByTagName('edit').length >= 1 &&  inh.getElementsByTagName('edit')[0].childNodes.length >= 1 && inh.getElementsByTagName('edit')[0].childNodes[0].nodeValue == 1){
													edit_button.style.display = 'inline';edit_button.className = 'button_shout_edit button_shout_l';edit_button.title = 'Éditer le message';
												}else{
													edit_button.style.display = 'inline';edit_button.className = 'button_shout_edit_no button_shout_l';edit_button.title = 'Vous n’êtes pas autorisé à éditer le message...';edit_button.onclick = function(){alert('Vous n’êtes pas autorisé à éditer le message...');}
												}
												dd.appendChild(edit_button);
												
												dl.appendChild(dd);
												dd = ce('dd');
												dd.style.paddingLeft = '3px';

												dl.appendChild(dt);
												var msg2 = ce('span');
												msg2.id = 'shout' + i;
												msg2.i = i;
												msg2.appendChild(msg);
												edit_form = ce('span');
												var spa = ce('dd');
												spa.id = 'spa' + i;
												
												if (inh.getElementsByTagName('edit').length >= 1 &&  inh.getElementsByTagName('edit')[0].childNodes.length >= 1 && inh.getElementsByTagName('edit')[0].childNodes[0].nodeValue == 1)
												{
													dd = handle_edit(dd, inh, i);
												}

												edit_form.appendChild(spa);
												dd.appendChild(msg2);
												dd.appendChild(edit_form);
												dd.id = 'msgbody';
												dd.style.width = 'auto';
												dd.style.styleFloat = dd.style.cssFloat = 'none';
												dd.style.paddingLeft = '3px';
												dd.style.paddingRight = '5px';

												dl.appendChild(dd);
												li.appendChild(dl);
												posts.appendChild(li);

											}

																						if (first)
											{
												document.getElementById('post_message').style.display = 'inline';
												first = false;
											}
																					}
									}
								}
								catch (e)
								{
//									timer_in = setTimeout('reload_post();',3000);
									handle(e);
									return;
								}
							}
							hin.send(null);
						}
					}
					timer_in = setTimeout('reload_post();',3000);
				}
			}
			catch (e)
			{
				handle(e);
				return;
			}
		}
		hin2.send(null);
	}
}

lang['COMMA_SEPARATOR'] = ', ';
lang['NO_AJAX'] = 'Non ajax';
lang['SERVER_ERR'] = 'Quelque chose s’est mal déroulé après avoir envoyé une requête au serveur, veuillez rafraichir la page...';
lang['JS_ERR'] = 'Il y a eu une erreur JavaScript. Erreur: ';
lang['LINE'] = 'Ligne';
lang['FILE'] = 'Fichier';
lang['MSG_DEL_DONE'] = 'Message en cours de suppression...';
lang['ONLY_ONE_OPEN'] = 'Vous ne pouvez avoir qu’une seule boite d’édition ouverte';
lang['EDIT'] = 'Éditer';
lang['SHOUT_EDIT'] = 'Éditer le message';
lang['SENDING_EDIT'] = 'Publication après édition...';
lang['EDIT_DONE'] = 'Le message a été édité';
lang['CANCEL'] = 'Abandonner';
lang['PURGE_PROCESS'] = 'Purge de la shoutbox en cours...';

