
function checkpass() {
	var obj = document.getElementById('passchecker');
	if (document.forms['register'].pass_q.value==document.forms['register'].pass.value) {
		if (document.forms['register'].pass.value!='') {
			if (document.forms['register'].pass.value.length<4) {
				obj.innerHTML = 'длина пароля должна быть не менее 4-х символов';
			} else {
				obj.innerHTML = 'пароли совпадают';
			}
		} else {
			obj.innerHTML = 'пароль не должен быть пустым!';
		}
	} else {
		obj.innerHTML = 'пароли не совпадают';
	}
}

function add() {
	if(navigator.appName == 'Netscape') {
		window.sidebar.addPanel (top.document.title, top.location.href, ' ' )
	}
	else {
		window.external.AddFavorite (top.location.href,top.document.title);
	}
}

function showHelp(id) {
	var obj = document.getElementById(id);
	var preobj = document.getElementById(id+'_link');
	if (obj&&preobj) {
		if (obj.style.display=='none') {
			obj.style.display = 'block';
			preobj.style.backgroundImage = "url('http://gromkogovoriteli.ru/zakaz/img/question_a.jpg')";

		} else {
			obj.style.display = 'none';
			preobj.style.backgroundImage = "url('http://gromkogovoriteli.ru/zakaz/img/question.jpg')";
		}
	}
}

function addToTrash(tid)
{
	var col = document.getElementById('count');

	if (col)
	{
		col = col.value;
	}
	else
	{
		col = 0;
	}

	if (col)
	{
		var req = new JsHttpRequest();
		req.onreadystatechange = function()
		{
			if (req.readyState == 4)
			{
				alert(req.responseJS.res);

				showTrash();
			}
		}
		req.open(null, '/trash.php', true);
		req.send( { id: tid, action: 'add', data: col } );
	}
}

function clearTrash()
{
	var req = new JsHttpRequest();
	req.onreadystatechange = function()
	{
		if (req.readyState == 4)
		{
			showTrash(true);
		}
	}
	req.open(null, '/trash.php', true);
	req.send( { id: 0, action: 'clear', data: '' } );

}

function showTrash(need_reload)
{
	var td = document.getElementById('trash_right');

	if (td)
	{
		var req = new JsHttpRequest();
		req.onreadystatechange = function()
		{
			if (req.readyState == 4)
			{
				td.innerHTML = req.responseJS.res;

				if (need_reload)
				{
					window.location.reload();
				}
			}
		}
		req.open(null, '/trash_right.php', true);
		req.send( { } );
	}
}

