/* project name */
var search_sample = function(){
	var forms = document.getElementsByTagName('FORM');
	var forms_quant = forms.length;
	for ( var i = 0 ; i < forms_quant ; i++ ) {
		if ( forms[i].className != 'site_search_vt' ) continue;
		var targ_form = forms[i];
		var samples = targ_form.getElementsByTagName('SPAN');
		var samples_quant = samples.length;
		for ( var j = 0 ; j < samples_quant ; j++ ) {
			if ( samples[j].className != 'example_vt' ) continue;
			samples[j].onclick = function() {
				targ_form.q.value = this.innerHTML;
			}
		}
	}
}
var W3CDOM = (document.createElement && document.getElementsByTagName);

if ( window.addEventListener ) {
	window.addEventListener('load', init, false);
} else {
	window.attachEvent('onload', init);
}

function init () {
	if (!W3CDOM) return;
	search_sample();
	thhover();
}

var thhover = function(){
	var table = document.getElementsByTagName('TABLE');
	var table_quant = table.length;
	for ( var i = 0; i < table_quant ; i++ ) {
		if(!table[i].className.match('end_pos_page_cat_vt')) continue;
		var trs = table[i].getElementsByTagName('TR');
		var trs_quant = trs.length;
		for ( var j = 0 ; j < trs_quant ; j++){
			if(trs[j].className.match('izvrat_vt')) continue;
			trs[j].onmouseover = function(){
				this.className +=' trhover';
			}
			trs[j].onmouseout = function(){
				this.className = this.className.replace(/trhover\b/,'');
			}
			if(j==trs_quant-2){
				trs[j].onmouseover = function(){
					this.className +=' trhover';
					trs[trs_quant-1].className += ' trhover';
				}
				trs[j].onmouseout = function(){
					this.className = this.className.replace(/trhover\b/,'');
					trs[trs_quant-1].className = trs[trs_quant-1].className.replace(/trhover\b/,'');
				}
			}
		}
	}
}

var catalog_show_subsection = function (id, elm, deeper)
{
	var ulList = document.getElementById(id);
	if(id)
	{
		var oList = ulList.getElementsByTagName("li");
		if(oList && 5 < oList.length)
		{
			for(var j=4; j<oList.length; j++)
			{
				oList[j].style.display = "list-item";
			}
			if (elm)
			{
				var parent = deeper ? elm.parentNode : elm;
				if (parent.style) parent.style.display = "none";
			}
		}
	}
}

var catalog_show_subsection_all = function(id, elm)
{
	var container = document.getElementById(id);
	if(container) {
		elm.style.display = "none";
		var ulList = container.getElementsByTagName("ul");
		if (ulList && ulList.length)
		{
			var ulParent;
			for(var i=0, oList=null; i<ulList.length; i++)
			{
				ulParent = ulList[i].parentNode;
				var oEm = ulParent.getElementsByTagName("em");
				
				if (oEm && oEm.length) oEm = oEm[0];
				
				window.catalog_show_subsection(ulList[i].id, oEm, false);
			}
		}
	}
}
