// All rights reserved (c) Mykola Dihtyar
var start=0xffffff, step=0x010101, x=0, y=0, a=0x3f3f3f, b=0x0f0f0f;
var states=new Array(0,0,0,0,0,0,0);
var maspos=new Array(0,0,0,0,0,0,0);

// --------------------Hexadecimal Conversion---------------------

// convert a single digit (0 - 16) into hex
function enHex(aDigit)
{
    return("0123456789ABCDEF".substring(aDigit, aDigit+1))
}
function toHex(n)
{
    return (enHex((0xf00000 & n) >> 20) +
            enHex((0x0f0000 & n) >> 16) +
            enHex((0x00f000 & n) >> 12) +
            enHex((0x000f00 & n) >>  8) +
            enHex((0x0000f0 & n) >>  4) +
            enHex((0x00000f & n) >>  0))
}
function Convert(state)
{
	var buffer;
	buffer='#'+toHex(state);
	return buffer;
}
function SetItemState(ind,state)
{
	if (state==1)
	{ states[ind-1]=1; }
	else { states[ind-1]=0; }
	if ((maspos[ind-1]>=a)||(maspos[ind-1]<=b))
	{
		if (maspos[ind-1]>=a) { maspos[ind-1]=a; }
		if (maspos[ind-1]<=b) { maspos[ind-1]=b; }		
		ActiveItem(ind,maspos[ind-1]);
	}
}
function ActiveItem(ind,pos)
{
 		 var ptr, ptr1;
		 ptr=document.getElementById('td'+ind);
		 ptr.style['backgroundColor']=Convert(start-pos);
		 ptr1=document.getElementById('td'+ind+ind);
		 ptr1.style['backgroundColor']=Convert(start-pos);
			if ( (!(pos>=a))&&(states[ind-1]==1))
		 		{
		 				maspos[ind-1]=maspos[ind-1]+step;
		 				var s="ActiveItem("+ind+","+maspos[ind-1]+");";
				 		if (states[ind-1]==1) 
				 			{ 
				 				window.setTimeout(s,10); 
				 			}				 	
				}
			else
				if ((!(pos<=b))&&(states[ind-1]==0))
				{
						maspos[ind-1]=maspos[ind-1]-step;
		 				var s="ActiveItem("+ind+","+maspos[ind-1]+");";
				 		if (states[ind-1]==0) 
				 			{ 
				 				window.setTimeout(s,10); 
				 			}	
				}
		if (pos<=b) 
			{
			 	 ptr.style['backgroundColor']=''; ptr1.style['backgroundColor']='';
			}				
}

//Відправка SMS-повідомлень за допомогою мобільного телефону, використовуючи GPRS/" -->
function show_content()
{
	var el;
	el = document.getElementById("agree");
	el.style.visibility = "visible";
}
//Статистика температури в КДПУ ім. В.Винниченка/"
var arg=0;
void function ReloadPage()
{
	if (arg==0)
	{
	    arg=1;
	    window.setTimeout('ReloadPage()',300000);
	}
	else 
	    { location.reload(true); }		 
}
