var fillerWidth=1020;

window.onload=function()
{
	preloadImage('bg.gif');
	$('hellip').onclick=function()
	{
		toggle('input');
		toggle('input-bg');
		
		if ($('input').offsetWidth)
		{
			$('input-bg').style.borderWidth='0px';	
			cssTransform('input-bg', null, null, $('input').offsetWidth, $('input').offsetHeight);
			
			focus('message');
			var x1=new Changer('input-bg', 'backgroundX', -fillerWidth, -fillerWidth+$('input').offsetWidth+$('input').offsetHeight, false);
			x1.v=3;
			x1.a=1;
			x1.timer=20;
			x1.onEnd=function()
			{
				$('input-bg').style.borderWidth='1px';
			
			};
			x1.start();
		}
		
		$('key').value='111';
	}
	
	var t=500;
	
	setTimeout('visible("w1")', t);
	setTimeout('visible("w2")', 2*t);
	setTimeout('visible("w3")', 3*t);
	setTimeout('visible("w4")', 4*t);
	setTimeout('visible("w5")', 5*t);
	
	var message=$('message');
	message.onkeypress=message.onkeyup=message.onblur=checkForm;
	
	checkForm();
	
	$('container').style.height=''+($('volg').offsetHeight+$('messages').offsetHeight)+'px';
	
	if (window.location.hash == '#first')
	{
		var li = document.getElementsByTagName('li', $('messages'));
		
		if (li && li.length) {
			li[0].className='selected';
		}
		
		//window.scrollTo(0, 100000);
	}	
}

function checkForm()
{
	var disabled=false;
	if (stripSpaces($('message').value)=='')	disabled=true;
	
	$('submit').disabled=disabled;
}

function stripSpaces(text)
{
	return text.replace(/[ \t\r\n]/g, '');
}

function toggle(id)
{
	var el=$(id);
	
	if (el)
	{
		if (el.style.display=='none')	el.style.display='block';
		else	el.style.display='none';
	}
}

function visible(id)
{
	var el=$(id);
	if (el)	el.style.visibility='visible';
}

function focus(id)
{
	var el=$(id);
	if (el && el.offsetWidth)	$(id).focus();
}