function showStatsClan(alt)
{
	var altrace = alt + "_race";
	var altloc = alt + "_loc";
	var altrank = alt + "_rank";
	var altdate = alt + "_date";
	document.getElementById(altrace).style.visibility = "visible";
	document.getElementById(altrace).style.display = "table-row";
	document.getElementById(altloc).style.visibility = "visible";
	document.getElementById(altloc).style.display = "table-row";
	document.getElementById(altrank).style.visibility = "visible";
	document.getElementById(altrank).style.display = "table-row";
	document.getElementById(altdate).style.visibility = "visible";
	document.getElementById(altdate).style.display = "table-row";
}

function hideStatsClan(alt)
{
	var altrace = alt + "_race";
	var altloc = alt + "_loc";
	var altrank = alt + "_rank";
	var altdate = alt + "_date";
	document.getElementById(altrace).style.visibility = "hidden";
	document.getElementById(altrace).style.display = "none";
	document.getElementById(altloc).style.visibility = "hidden";
	document.getElementById(altloc).style.display = "none";
	document.getElementById(altrank).style.visibility = "hidden";
	document.getElementById(altrank).style.display = "none";
	document.getElementById(altdate).style.visibility = "hidden";
	document.getElementById(altdate).style.display = "none";
}

function showStatsNorm(alt)
{
	var altrace = alt + "_race";
	var altloc = alt + "_loc";
	var altdate = alt + "_date";
	document.getElementById(altrace).style.visibility = "visible";
	document.getElementById(altrace).style.display = "table-row";
	document.getElementById(altloc).style.visibility = "visible";
	document.getElementById(altloc).style.display = "table-row";
	document.getElementById(altdate).style.visibility = "visible";
	document.getElementById(altdate).style.display = "table-row";
}

function hideStatsNorm(alt)
{
	var altrace = alt + "_race";
	var altloc = alt + "_loc";
	var altdate = alt + "_date";
	document.getElementById(altrace).style.visibility = "hidden";
	document.getElementById(altrace).style.display = "none";
	document.getElementById(altloc).style.visibility = "hidden";
	document.getElementById(altloc).style.display = "none";
	document.getElementById(altdate).style.visibility = "hidden";
	document.getElementById(altdate).style.display = "none";
}

function showSpawnInfo(spawnid)
{
	var spawnloc = "spawn_" + spawnid + "_loc";
	var spawnwho = "spawn_" + spawnid + "_who";
	var spawntime = "spawn_" + spawnid + "_asttime";
	var spawnupd = "spawn_" + spawnid + "_update";
	var spawnupdt = "spawn_" + spawnid + "_update_time";
	var spawnupdp = "spawn_" + spawnid + "_update_password";
	var spawnupdf = "spawn_" + spawnid + "_update_form";
	document.getElementById(spawnloc).style.visibility = "visible";
	document.getElementById(spawnloc).style.display = "table-row";
	document.getElementById(spawnwho).style.visibility = "visible";
	document.getElementById(spawnwho).style.display = "table-row";
	document.getElementById(spawntime).style.visibility = "visible";
	document.getElementById(spawntime).style.display = "table-row";
	document.getElementById(spawnupd).style.visibility = "visible";
	document.getElementById(spawnupd).style.display = "table-row";
	document.getElementById(spawnupdt).style.visibility = "visible";
	document.getElementById(spawnupdt).style.display = "table-row";
	document.getElementById(spawnupdp).style.visibility = "visible";
	document.getElementById(spawnupdp).style.display = "table-row";
	document.getElementById(spawnupdf).style.visibility = "visible";
	document.getElementById(spawnupdf).style.display = "table-row";
}

function hideSpawnInfo(spawnid)
{
	var spawnloc = "spawn_" + spawnid + "_loc";
	var spawnwho = "spawn_" + spawnid + "_who";
	var spawntime = "spawn_" + spawnid + "_asttime";
	var spawnupd = "spawn_" + spawnid + "_update";
	var spawnupdt = "spawn_" + spawnid + "_update_time";
	var spawnupdp = "spawn_" + spawnid + "_update_password";
	var spawnupdf = "spawn_" + spawnid + "_update_form";
	document.getElementById(spawnloc).style.visibility = "hidden";
	document.getElementById(spawnloc).style.display = "none";
	document.getElementById(spawnwho).style.visibility = "hidden";
	document.getElementById(spawnwho).style.display = "none";
	document.getElementById(spawntime).style.visibility = "hidden";
	document.getElementById(spawntime).style.display = "none";
	document.getElementById(spawnupd).style.visibility = "hidden";
	document.getElementById(spawnupd).style.display = "none";
	document.getElementById(spawnupdt).style.visibility = "hidden";
	document.getElementById(spawnupdt).style.display = "none";
	document.getElementById(spawnupdp).style.visibility = "hidden";
	document.getElementById(spawnupdp).style.display = "none";
	document.getElementById(spawnupdf).style.visibility = "hidden";
	document.getElementById(spawnupdf).style.display = "none";
}

var astHour;
var astMin;

function astonTimeHandler(hour, min, cellname)
{
	setAstonClock(hour, min, cellname);
	var astMinGap = 5000;
	astTimeProgress = setInterval("astonClock();", astMinGap);
}

function setAstonClock(hour, min, cellname)
{
	var setHour;
	var setMin;

	if (hour.length == 1)
	{
		setHour = "0" + hour;
	}
	else
	{
		setHour = hour;
	}
	if (min.length == 1)
	{
		setMin = "0" + min;
	}
	else
	{
		setMin = min;
	}
	var astonTime = setHour + ":" + setMin;
	astHour = hour;
	astMin = min;
	document.getElementById(cellname).innerHTML = astonTime;	
}

function astonClock()
{
	var cellname = "astonia_time";
	var setHour;
	var setMin;
	var difmin = parseInt(astMin)+1;
	if (difmin == 60)
		{
			setMin = "00";
			setHour = parseInt(astHour)+1;
			astMin = 0;
			astHour = parseInt(astHour)+1;
		}
	else
		{
			setMin = difmin;
			astMin = difmin;
			setHour = astHour;
		}
	if (astHour == 24)
		{
			astHour = 0;
			setHour = 0;
		}

	setMin = setMin+'';
	setHour = setHour+'';

	if (setHour.length == 1)
		{
			setHour = "0" + setHour;
		}
	if (setMin.length == 1)
		{
			setMin = "0" + setMin;
		}

	var astTime = setHour + ":" + setMin;
	document.getElementById(cellname).innerHTML = astTime;			
}

function timerCountdown(countid)
{
	var findcell = "spawn_" +countid+ "_timer";
	var str = document.getElementById(findcell).innerHTML;
	var hours;
	var minutes;
	var seconds;
	var minutesa;
	var secondsa;
	var formtime
	var isover = "false";

	if (str != "Spawn is over")
	{
		var timer_array = str.split(":");
		hours = timer_array[0];
		minutes = timer_array[1];
		seconds_array = timer_array[2].split(">");
		seconds_sub = seconds_array[1];
		seconds = seconds_sub.substr(0,2);

		secondsa = seconds.substr(0,1);

		if (secondsa == 0)
			{
				seconds = seconds.substr(1);
			}

		minutesa = minutes.substr(0,1);

		if (minutesa == 0)
			{
				minutes = minutes.substr(1);
			}

		hours = parseInt(hours);
		minutes = parseInt(minutes);
		seconds = parseInt(seconds);

		var minparse = minutes;
		var secparse = seconds;
		if (seconds == 0)
			{
				if (minutes == 0)
				{
					if (hours == 0)
					{
						seconds = 0;
						isover = "true";
					}
					else
					{
						hours = --hours;
						minutes = 59;
						seconds = 59;
					}
				}
				else
				{
					minutes = --minutes;
					seconds = 59;
				}
			}
		else
			{
				seconds = --seconds;
			}
		hours = hours+'';
		minutes = minutes+'';
		seconds = seconds+'';

		if (minutes.length == 1)
			{
				minutes = "0" + minutes;
			}
		else
			{
				minutes = minutes;
			}
		if (seconds.length == 1)
			{
				seconds = "0" + seconds;
			}
		else
			{
				seconds = seconds;
			}

		if (isover == "true")
		{
			formtime = "Spawn is over";
			window.clearInterval("st_"+countid);
		}
		else
		{
			formtime = hours+ ":" +minutes+ ":<span class=\"timer_time_small\">" +seconds+ "</span>";
		}

		document.getElementById(findcell).innerHTML = formtime;
	}
}
