window.onload = function(){
	init_submenu_title();
};

/* SUBMENU VARS */
var submenu_timeout = 500;//milliseconds
var title_offset_x = 5;
var title_offset_y = 5;
//////////////////////////////////////////

var global_x = 0;
var global_y = 0;
function init_submenu_title(){
	var root = $("submenu");
	if(!root){
		return false;
	}

	var items = $C("item", root, "DIV");
	items.each(function(item){
		item.link = $T("A", item, 1);
		if ( item.link.title != '' ){
			item._title = create_submenu_title(item.link.title);
			item.link.title = "";
			item.link.onmousemove = get_global_coords;
			item.link.onmouseover = function(e){
				get_global_coords(e);
				this.t_out = setTimeout(function(){
					this._title.style.left = global_x + title_offset_x +"px";
					this._title.style.top = global_y + title_offset_y + "px";
					this.className += " over";			
				}.bind(this), submenu_timeout);
			}.bind(item);
			item.link.onmouseout = function(){
				if(this.t_out){
					clearTimeout(this.t_out);
					this.t_out = null;
				}
				this.className = this.className.replace("over", "");
			}.bind(item);
			item.appendChild(item._title);
		}
	});
}
function create_submenu_title(text){
	var d = document.createElement("DIV");
	d.className = "title";
	d.appendChild(document.createTextNode(text));
	return d;
}
function get_global_coords(e){
	var ev = window.event || e;
	global_x = ev.offsetX || ev.layerX;
	global_y = ev.offsetY || ev.layerY;
}
function SubmitSearchForm() {
	if ( document.searchform.searchtext.value.length > 0 ) {
		document.searchform.submit( );
	}
}

function LoadYears( url, year, rubricId, themeId ) {
	var postVars = new Array( );
	postVars[0] = year.toString();
	postVars[1] = rubricId.toString();
	if ( themeId != '' ) {
		postVars[2] = themeId.toString();
	}

	return ajaxLoad.loadUrl( url, postVars );
}

function showHideBlockOtraslej( ) {

	if ( $("themesList") ) {
		if ( $("themesList").style.display == 'none' ) {
			$("themesList").style.display = "block";
		}
		else {
			$("themesList").style.display = "none";
		}
	}

	return false;

}

function showHideBlockAsk( ) {

	if ( $("askQuestion") ) {
		if ( $("askQuestion").style.display == 'none' ) {
			$("askQuestion").style.display = "block";
		}
		else {
			$("askQuestion").style.display = "none";
		}
	}

	return false;

}

function woDFile( link ) {

	w=window.open(link,'','width=450, height=200,toolbar=0,scrollbars=0,resizable=0');
	if (link.indexOf('.html')==-1) {
		if (document.layers) title='';
		w.document.open();
		w.document.write('<html><head><title>1235</title><meta http-equiv=Content-Type content="text/html; charset=windows-1251"></head>');
		w.document.write('<body bgcolor=white marginwidth=0 marginheight=0 topmargin=0 leftmargin=0>'+content+'</body></html>');
		w.document.close();
	}
	w.focus();
	return false;

}

