iddiv = new Array();

function toggleArea(id) {
	if(!iddiv[id]) {
		iddiv[id] = document.getElementById(id).innerHTML;
		document.getElementById(id).innerHTML = '';
		document.getElementById(id).style.display = "none";
		//it's collapsed now
	}
	else {
		document.getElementById(id).innerHTML = iddiv[id];
		document.getElementById(id).style.display = "block";
		//it's expanded now
		iddiv[id] = false;
	}
}

		

function getElementByClass(classname){ 
	var temparray=new Array() 
	var rootobj=document.getElementsByTagName("*")
	var inc=0 
	var rootlength=rootobj.length 
	for (i=0; i < rootlength; i++){ 
		if (rootobj[i].className==classname) temparray[inc++]=rootobj[i] 
	} 
	return temparray 
}

function getWhatIfuckingWant(idname, classname){
	var iWant=new String();
	var rootobj=document.getElementById(idname).getElementsByTagName("*");
	var inc=0;
	var rootlength=rootobj.length;
	for (i=0; i < rootlength; i++){ 
		if (rootobj[i].className==classname) iWant=rootobj[i];
	}

	return iWant;
}

function load()
{
	if (document.getElementsByTagName('input')[0])
	{
		document.getElementsByTagName('input')[0].focus();
	}
	boxLeft = 10;
	boxRight = 20;
	reverseSpin = false;
	inc=0;
	var ElementByClass=getElementByClass('sign2');
	while (ElementByClass[inc]) 
	{
		ElementByClass[inc].style.display = "none";
		inc++;
	}
	inc=0;

	var theBoxes=getElementByClass('spinner');
	timeout=50;
	while (theBoxes[inc])
	{
		var areachange="area"+theBoxes[inc].id;
		toggleArea(areachange);
		spins = 0;
		setTimeout(dudrenov(change, theBoxes[inc].id), timeout);
		timeout = timeout + 650;
		inc++;
	}
}

function dudrenov(funcToCall, param) 
{ 
	return function() {funcToCall(param); }
}


function change(param)
{
	sendthis=param;
	spins = 0;
	go=window.setInterval("if (spins < 10) {spin(sendthis); spins++} else { go=clearInterval(go)}",50);
	var areachange="area"+sendthis;
	toggleArea(areachange);
}

function spin(idname)
{
	if (reverseSpin == false)
	{
		boxLeft++;
		boxRight--;


		if (boxLeft == 15)
		{
			reverseSpin = true;
			if (getWhatIfuckingWant(idname, 'sign2').style.display == "none")
			{
				getWhatIfuckingWant(idname, 'sign1').style.display = "none";
				getWhatIfuckingWant(idname, 'sign2').style.display = "";
			}
			else
			{
				getWhatIfuckingWant(idname, 'sign2').style.display = "none";
				getWhatIfuckingWant(idname, 'sign1').style.display = "";
			}
		}
	}
	else
	{
		boxLeft--;
		boxRight++;

		if (boxLeft == 10)
		{
			reverseSpin = false;
		}
	}

	getWhatIfuckingWant(idname, 'left').style.left = boxLeft + "px";
	getWhatIfuckingWant(idname, 'right').style.left = boxRight + "px";
}







function showSide(target)
{
	document.getElementById('nav-window').style.display = 'block';
	readFile('/files/description.php', target);
}

function hideSide()
{
	document.getElementById('nav-window').style.display = 'none';
	document.getElementById('nav-window').innerHTML="";

}

function clearSide()
{
	document.getElementById('nav-window').innerHTML="";
}



var theFile

function readFile(url, post)
{
	theFile=null
	// Real browser
	if (window.XMLHttpRequest)
	{
		theFile=new XMLHttpRequest()
	}
	// IE
	else if (window.ActiveXObject)
	{
		theFile=new ActiveXObject("Microsoft.XMLHTTP")
	}
	if (theFile!=null)
	{
		theFile.onreadystatechange=state_Change
		theFile.open("POST",url,true);
		theFile.setRequestHeader('Content-type', 'application/x-www-form-urlencoded;charset=UTF-8;');
		theFile.send('id='+post);
	}
	else
	{
		document.getElementById('nav-window').innerHTML="<h2>Your Browser does not support the XMLHTTP feature.</h2>";
	}
}

function state_Change()
{
	// if theFile shows "loaded"
	if (theFile.readyState==4)
	{
		// if "OK"
		if (theFile.status==200)
		{
			document.getElementById('nav-window').innerHTML=theFile.responseText
		}
		else
		{
			document.getElementById('nav-window').innerHTML="<h2>Problem retrieving data:</h2><h4>" + theFile.statusText + "</h4>";
		}
	}
}