document.movingOne = null;
document.wasDown = false;
document.backScrollTopPosition = 0;
function moveThingsDown()
{
	var div = document.movingOne;
	while((div=getNextNode(div))!=null)
	{
		if(div.id.substr(0,7)=='projet_' && getStyle(div, 'display')!='none' && getScrollTopPosition()<(getTopPosition(div)-parseInt(getStyle(document.movingOne,'height'))))
		{
			div.parentNode.insertBefore(document.movingOne, div);
			document.wasDown = true;
			return;
		}
	}
}
function moveThingsUp()
{
	document.movingOne.parentNode.insertBefore(document.movingOne, document.movingOne.parentNode.firstChild);
	moveThingsDown();
}
function letsMoveThat()
{
	var scrollTopPosition = getScrollTopPosition();
	if(scrollTopPosition != document.backScrollTopPosition)
	{
		if(document.movingOne==null) document.movingOne = document.getElementById('theadThing');

		if(scrollTopPosition>getTopPosition(document.movingOne))	moveThingsDown();
		else if(document.wasDown)									moveThingsUp();
		document.backScrollTopPosition = scrollTopPosition;
	}
}

document.viewedId = null;
document.viewedPanel = 'trkr_releases';
function showPanel(panel)
{
	var projectList = document.getElementById(panel);
	if(projectList!=null)
	{
		if(getStyle(projectList,'display')=='none')
		{
			projectList.style.display='block';
			document.viewedPanel = panel;
		}
	}
}
function hidePanel()
{
	if(document.viewedId!=null)
	{
		var projectDiv = document.getElementById('projet_'+document.viewedId);
		projectDiv.style.display='none';
		document.viewedId = null;
	}
	if(document.viewedPanel!=null)
	{
		if(document.viewedPanel=='all1')
		{
			var projectList = document.getElementsByTagName('div');
			var l = projectList.length;
			var i;
			for(i=0;i<l;i++)
			{
				var project = projectList[i];
				if(project.id.substr(0,7)=='projet_') project.style.display='none';
			}
			var theadThing = document.getElementById('theadThing');
			if(theadThing!=null)
			{
				theadThing.style.display='none';
				window.onscroll = null;
			}
		}
		else if(document.viewedPanel=='all2')
		{
			var optionThing = document.getElementById('optionThing');
			if(optionThing!=null)
			{
				optionThing.style.display='none';
			}
			var trkrHide = document.getElementById('trkr_hide');
			trkrHide.style.display='none';
			document.viewedPanel = 'trkr_releases';
			hidePanel();
		}
		else
		{
			var PanelDiv = document.getElementById(document.viewedPanel);
			PanelDiv.style.display='none';
		}
		document.viewedPanel = null;
	}
}
function prnameMouseOver(obj)
{
	obj.originalBgColor=getStyle(obj,'backgroundColor');
	obj.style.backgroundColor='Black';
}
function prnameMouseOut(obj)
{
	obj.style.backgroundColor=obj.originalBgColor;
}
function prnameClick(obj)
{
	if(document.viewedPanel=='all1')
	{
		var table = getNextNode(obj.parentNode);
		var title = 'Cliquez pour cacher la liste des torrents de ce projet';
	}
	else
	{
		var table = getNextNode(getNextNode(obj));
		var title = 'Cliquez pour cacher les détails de ce torrent';
	}
	if(getStyle(table,'display')=='none')
	{
		try{ table.style.display='table'; } catch(e) {  table.style.display='block'; }
		obj.backTitle = obj.getAttribute('title');
		obj.setAttribute('title', title);
		obj.originalBgImage=getStyle(obj,'backgroundImage');
		if(obj.originalBgImage!='none') obj.style.backgroundImage=obj.originalBgImage.substring(0, obj.originalBgImage.length-6) + '_up.gif")';
	}
	else
	{
		table.style.display='none';
		obj.setAttribute('title', obj.backTitle);
		obj.style.backgroundImage=obj.originalBgImage;
	}
}
function showLast()
{
	hidePanel()
	showPanel('trkr_releases');
}
function showList()
{
	hidePanel();
	showPanel('trkr_projets');
}
function showAll(mode)
{
	hidePanel();
	var optionThing = document.getElementById('optionThing');
	if(optionThing!=null)
	{
		try{ optionThing.style.display='table-row'; } catch(e) { optionThing.style.display='block'; }
	}
	if(mode)
	{
		var trkrHide = document.getElementById('trkr_hide');
		trkrHide.style.display = 'block';
		showLast();
		document.viewedPanel = 'all2';
	}
	else
	{
		var projectList = document.getElementsByTagName('div');
		var l = projectList.length;
		var i;
		for(i=0;i<l;i++)
		{
			var project = projectList[i];
			if(project.id.substr(0,7)=='projet_' && getStyle(project,'display')=='none')
			{
				var thead;
				if((thead = project.getElementsByTagName('thead')[0])!=null)
				{
					thead.style.display='none';
					project.style.display='block';
	
					var prname;
					if((prname = document.getElementById('prname_'+project.id.substr(7)))!=null)
					{
						prname.style.cursor = 'pointer';
						prname.onmouseover = function() { prnameMouseOver(this); };
						prname.onmouseout = function() { prnameMouseOut(this); };
						prname.onclick = function() { prnameClick(this); };
						prname.setAttribute('title','Cliquez pour voir la liste des torrents de ce projet');
					}
				}
			}
		}
		var theadThing = document.getElementById('theadThing');
		if(theadThing!=null)
		{
			theadThing.style.display='block';
			window.onscroll = letsMoveThat;
		}
		document.viewedPanel = 'all1';
	}
}
function showProject(id)
{
	var projectList = document.getElementById('trkr_projets');
	if(projectList!=null) projectList.style.display='none';
	hidePanel();
	var projectDiv = document.getElementById('projet_'+id);
	if(projectDiv!=null)
	{
		var thead;
		if((thead = projectDiv.getElementsByTagName('thead')[0])!=null) try { thead.style.display='table-header-group'; } catch(e) { thead.style.display='block'; }
		var table;
		if((table = projectDiv.getElementsByTagName('table')[0])!=null) try { table.style.display='table'; } catch(e) { table.style.display='block'; }
		var prname;
		if((prname = document.getElementById('prname_'+id))!=null)
		{
			prname.style.cursor = 'auto';
			prname.onmouseover = null;
			prname.onmouseout = null;
			prname.onclick = null;
			prname.setAttribute('title','');
		}
		projectDiv.style.display='block';
		document.viewedId = id;
	}
}
function showProjectName(newName, imgObj)
{
	var projectName = document.getElementById('projectName');
	if(projectName!=null)
	{
		if(newName=='')
		{
			projectName.innerHTML = projectName.firstInnerHTML;
			imgObj.style.borderColor = '#CC9966';
		}
		else
		{
			projectName.firstInnerHTML = projectName.innerHTML;
			projectName.innerHTML = newName;
			imgObj.style.borderColor = '#F2F0EF';
		}
	}
}