///////////////////////////////////////////////////////////////////////////////
//////////                                DO NOT CHANGE ANYTHING                                 //////////
///////////////////////////////////////////////////////////////////////////////

	var ie4 = (document.all)? true:false;
	var dom = (document.getElementById)? true:false;
	var ns4 = (document.layers)? true:false;

	function createRequestObject()
	{
		if(ie4)
		{
			ro = new ActiveXObject('Microsoft.XMLHTTP');
		}
		else
		{
			ro = new XMLHttpRequest();
			ro.overrideMimeType('text/xml');
		}
		return ro;
	}
	
	var http = createRequestObject();

	function getObject(id)
	{
		if (ie4)
		{
			var object = document.all[id];
			return object;
		}
		if (dom) {
			var object = document.getElementById(id);
			return object;
		}
		if (ns4) {
			var object = eval('document.' + id);
			return object;
		}
	}

	function handleResponse()
	{
		if(http.readyState == 4)
		{
			var response = http.responseText;
			var update = new Array();
			if(response.indexOf('|' != -1))
			{
				update = response.split('|');
				var i = 0;
				while (update[i] != "")
				{
					getObject(update[i]).innerHTML = update[i+1];			
					i = i +2;
				}
			}
		}
	}
	
	function cache(identifiant)
	{
		if (getObject('i_' + identifiant).style.display == 'none')
		{
			getObject('i_' + identifiant).style.display = '';
			getObject('img_' + identifiant).src = 'images/noncross.gif';
		
		} 
		else
		{
			getObject('i_' + identifiant).style.display = 'none';
			getObject('img_' + identifiant).src = 'images/cross.gif';
		} 		  
	}

	function expand(bState, id1, id2, img)
	{
		var oItem,oItem2,oGif;
		oItem = getObject(id1);
		oItem2 = getObject(id2);
		oGif = getObject(img);
		if (bState == 'toggle')
			bState = (oItem.style.display=='block');
		if(bState) {
			bState = (oItem.style.display='none');
			bState = (oItem2.style.display='block');
			bState = (oGif.src='images/cross.gif');
		}
		else {
			bState = (oItem.style.display='block');
			bState = (oItem2.style.display='none');
			bState = (oGif.src='images/noncross.gif');
		}
	}
	
	function SetDiv(ID,Content)
	{
		if (dom || ie4)
		{
			getObject(ID).innerHTML = Content;
		}
		if (ns4) {
			with (eval('document.'+ID+'.document')) {
				open();
				write(Content);
				close();
			}
			return;
		}
	}

	function ShowShouts()
	{
		http.open('get','shoutbox.php',true);
		http.onreadystatechange = function()
		{
			if(http.readyState == 4)
			{
				var content;
				content = http.responseText;
				SetDiv('shoutbox',content);
			}
		}
		http.send(null);
	}

	function ShowShoutbox()
	{
		ShowShouts();
		var timer = setInterval('ShowShouts()', 60000);
	}
	
	function sndReqDetails(action)
	{
		http.open('get', 'details.php?mode=details&info_hash='+action);
		http.onreadystatechange = handleResponse;
		http.send(null);
	}
	
	function sndAjaxReq(page, number)
	{
		http.open('get', page+'.php?mode=ajax&page='+number);
		http.onreadystatechange = handleResponse;
		http.send(null);
	}

	function sndAjaxShout(page)
	{
		var postusername = document.forms['ttshoutform'].elements['username'].value;
		var postmessage = document.forms['ttshoutform'].elements['message'].value;
		var postdata = 'username='+postusername+"&message="+postmessage;
		http.open('post',page+'.php',false);
		http.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
		http.send(postdata);
		ShowShouts();
	}

	function sndAjaxShoutKey(evenement, page)
	{
		var key = window.event ? evenement.keyCode : evenement.which;
		if (key == 13)
		{
			sndAjaxShout(page);
		}
	}

if (ajax_browse == 'yes')
{
	function ShowSmilies()
	{
		var SmiliesWindow = window.open('./smilies.php','Smilies','width=200,height=200,resizable=yes,scrollbars=yes,toolbar=no,location=no,directories=no,status=no');
	}
	document.onload = ShowShoutbox();
}