function showComment(hide, show) {
	document.getElementById(hide).style.display = 'none';
	document.getElementById(show).style.display = 'block';
	document.getElementById('LT').value = parseInt(document.getElementById('LT').value) + 1;
}

function switchsearchOption() {
	var coll = document.getElementById('searchOption').childNodes;
	collLength = coll.length;
	for (var i = 0; i < collLength; i+=2) {
		coll[i].onclick = activateOpt;
	}
	window.activeOptSearch = coll[collLength-1];
	coll[collLength-1].className = 'active';
	document.getElementById('opt').value = coll[collLength-1].title;
}
function activateOpt() {
	if (window.activeOptSearch) {
		window.activeOptSearch.className = '';
	}
	window.activeOptSearch = this;
	this.className = 'active';
	document.getElementById('opt').value = window.activeOptSearch.title;
}

// функция открытия/скрытия списка марок авто
window.openedList = false;
function openList(listContainer, arrowContainer) {
	var list = document.getElementById(listContainer);
	var darr = document.getElementById(arrowContainer);
	list.style.display = (window.openedList) ? 'none' : 'block';
	darr.innerHTML = (window.openedList) ? '&darr;' : '&uarr;';
	window.openedList = !window.openedList;
}

// проверим обязательные поля:
function chkForm(what)
{
	var frm=what;
	var sign = 0;
	var num = 64;
	var fields=[{name:'unreg_login',msg:'Представьтесь, пожалуйста',errId:'unreg_loginErr'},{name:'comment_body',msg:'Ну скажите же что-нибудь!',errId:'comment_bodyErr'}];
	for(var i=0;i<fields.length;i++) {
		document.getElementById(fields[i].errId).innerHTML = '';
		var elm=frm.elements[fields[i].name];
		if (elm && !elm.value) {
			document.getElementById(fields[i].errId).innerHTML = fields[i].msg;
			sign ++;
		}
	}

	if (frm.elements[fields[0].name].value.length >= num) {
		document.getElementById('unreg_loginErr').innerHTML = 'Не более 64 символов, пожалуйста';
        return false;
	}
	if (sign > 0) {
		return false
	}
	else {
		return true
	}
}

	function psevdoSelectInit() {
		expanded_option = null;
		if ( document.addEventListener ) {
			document.addEventListener("click", onClick, false);
		} else if ( document.attachEvent ) {
			document.attachEvent("onclick", onClick);
		}
	}
	function onClick(e) {
		var el = window.event ? window.event.srcElement : e.target;
		//alert(el.name)
		if (!el.id || el.id == "") {
			hideDivs();
		}
	}

	function menuChange(what) {

		hideDivs();
		var id = what.id+"_";
		var target = document.getElementById(id);

		if (target.style.display = "none")
		{
			expanded_option = id;
			target.style.display = "block"
		}
		else
		{
			expanded_option = null;
			target.style.display = "none";
		}
	}

	function hideDivs() {
		if (expanded_option)
		{
			document.getElementById(expanded_option).style.display = "none";
			expanded_option = null;
		}
	}

	function menuSelect(what, value) {
		var colls = what.parentNode.getElementsByTagName('A');
		for (i = 0; i < colls.length; i++) {
			colls[i].className = "";
		}
		what.className = "active";
		var id = what.parentNode.parentNode.id.split("_")[0];
		var target = document.getElementById(id);
		target.value = what.innerHTML;
		var target = document.getElementById(id+"_options");
		target.value = value;
		hideDivs();
	}