function reg()
{
	document.getElementById('registration').style.display = '';
	document.getElementById('search').style.display = 'none';
}

function edit()
{
	document.getElementById('edit').style.display = '';
	document.getElementById('search').style.display = 'none';
	document.getElementById('registration').style.display = 'none';
}

function sr()
{
	document.getElementById('registration').style.display = 'none';
	document.getElementById('search').style.display = '';
}

function closeMe()
{
	window.opener.location.reload();
	if (window.opener.progressWindow)
	{
		window.opener.progressWindow.close();
	}
	window.close();	
}

function go404()
{
	window.opener.location = '/404';
	if (window.opener.progressWindow)
	{
		window.opener.progressWindow.close();
	}
	window.close();	
}

function vote(id, v)
{
	window.open('/vote.html?id='+id+'&vote='+v, '', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width=300,height=300');
}

function message(to)
{
	window.open('/message.html?to='+to, '', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width=400,height=500');
}

function auth()
{
	window.open('/auth.html?to='+to, '', 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=yes,resizable=yes,width=400,height=500');
}

function checkTextarea(field)
{
	var btn = document.getElementById('sbMessage'); 
	if(field.value.length > 0) btn.disabled = false;
	else btn.disabled = true;
}

function checkLetterForm()
{
	var btn = document.getElementById('btLetter');
	var name = document.getElementById('name');
	var email = document.getElementById('email');
	var header = document.getElementById('subj');
	var body = document.getElementById('body');
	if(name.value.length > 0 && email.value.length > 0 && header.value.length > 0 && body.value.length > 0) btn.disabled = false;
	else btn.disabled = true;
}

function checkLetterForm1()
{
	var btn = document.getElementById('btLetter');
	var name = document.getElementById('name');
	var email = document.getElementById('email');
	var body = document.getElementById('body');
	if(name.value.length > 0 && email.value.length > 0 && body.value.length > 0) btn.disabled = false;
	else btn.disabled = true;
}

function li()
{
	document.write('<a href="http://www.liveinternet.ru/click" target="_blank"><img src="http://counter.yadro.ru/hit?t26.6;r'+escape(document.referrer)+((typeof(screen)=='undefined')?'':';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+';u'+escape(document.URL)+';'+Math.random()+'" alt="" title="LiveInternet: показано число посетителей за сегодня" border="0" width="88" height="15"><\/a>');
	
}

function confirmDelete(url, text)
{
	if(confirm(text))
	{
		document.location = url;
	}
}

function selectAll(base)
{
	var boxes = document.getElementsByTagName('input');
	for(var i = 0; i < boxes.length; i++)
	{
		var box = boxes[i];
		if(box.type != 'checkbox' || box.id == 'base')
		{
			continue;
		}
		box.checked = base.checked;
	}
}

function setWinSize(w, h)
{
	if(typeof(window.innerWidth) == 'number')
	{
		//Non-IE
		window.innerWidth = w+40;
		window.innerHeight = h+60;
	}
	else if(typeof(document.body.offsetWidth) == 'number')
	{
		//IE 6+ in 'standards compliant mode'
		document.body.offsetWidth = w+40;
		document.body.offsetHeight = h+60;
	}
	else if(document.body && (document.body.clientWidth || document.body.clientHeight))
	{
		//IE 4 compatible
		document.body.clientWidth = w+40;
		document.body.clientHeight = h+60;
	}
}

function more_foto()
{
	var d = document.getElementById('foto');
	var c = d.getElementsByTagName('td').length; 
	var td = document.createElement('td');
	td.innerHTML = '<input type="file" name="sfoto'+c+'" /><a href="#bt" style="padding-left:10px;" onclick="remove_tr('+c+');"><img src="/images/delete.png" width="16" height="16" /></a>';
	var tr = document.createElement('tr');
	tr.setAttribute('id', ''+c);
	d.appendChild(tr);
	tr.appendChild(td);
	c++;
	document.getElementById('count').value=''+c;
}

function remove_tr(tr)
{
	var d = document.getElementById('foto');
	var tre = document.getElementById(tr);
	d.removeChild(tre);
}

function more_rfoto()
{
	var d = document.getElementById('rfoto');
	var c = d.getElementsByTagName('td').length; 
	var td = document.createElement('td');
	td.innerHTML = '<input type="file" name="rfoto'+c+'" /><a href="#" style="padding-left:10px;" onclick="remove_rtr(\'r'+c+'\');"><img src="/images/delete.png" width="16" height="16" /></a>';
	var tr = document.createElement('tr');
	tr.setAttribute('id', 'r'+c);
	d.appendChild(tr);
	tr.appendChild(td);
	c++;
	document.getElementById('rcount').value=''+c;
}

function remove_rtr(tr)
{
	var d = document.getElementById('rfoto');
	var tre = document.getElementById(tr);
	d.removeChild(tre);
}
