var timeId;

function insert(id, act)
{
	this.id = id;
	this.act = act;
	clearTimeout(timeId);
	timeId = setTimeout("ins(this.id, 'ins', this.act)", 33);
}

function saveIt() {
	clearTimeout(timeId);
}

function cleare()
{
	clearTimeout(timeId);
	setTimeout("ins('', '', '')", 33);
}

function ins(id, act, same) {
	var arrow;
	if(same != 'self') {
		var i=1;
		for (i=1; i <= 7; i++) {
			document.getElementById('insertNum'+i).innerHTML = '&nbsp;';
			document.getElementById('insertText'+i).innerHTML = '&nbsp;';
			arrow = document.getElementById('arrow'+i);
			if(arrow) arrow.style.display = "none";
			document.getElementById('empty'+i).style.display = "block";
		}
		if(act == 'ins') {
			arrow = document.getElementById('arrow'+id);
			document.getElementById('empty'+id).style.display = "none";
			if(arrow) arrow.style.display = "block";
				
			var i=1;
			for (i=1; i <= 7; i++) {
				var inserttext = document.getElementById('insertText'+i);
				var insertnum = document.getElementById('insertNum'+i);
				var innerNum = document.getElementById('Num'+id+'.'+i);
				var innerText = document.getElementById('Text'+id+'.'+i);
								
				if(innerText != null) {
					var a = innerText.getElementsByTagName('a')[0];
				}
				insertnum.onmouseover = a.onmouseover;
				insertnum.onmouseout = a.onmouseout;
				inserttext.onmouseover = a.onmouseover;
				inserttext.onmouseout = a.onmouseout;

				if(innerNum != null) {
					insertnum.innerHTML = innerNum.innerHTML;
				}
				if(innerText != null) {
					inserttext.innerHTML = innerText.innerHTML;
					inserttext.className = innerText.className;
				}
			}
		}
	}

}


function defPosition(event) {
	var x = y = 0;
	if (document.attachEvent != null) { // Internet Explorer & Opera
		x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
		y = window.event.clientY + document.documentElement.scrollTop + document.body.scrollTop;
	}
	if (!document.attachEvent && document.addEventListener) { // Gecko
		x = event.clientX + window.scrollX;
		y = event.clientY + window.scrollY;
	}
	return {x:x, y:y};
}

function ShowProject(id, event) {

	if (tim) clearTimeout(tim);
	if (l2 != id) {
		HideL2();
	}
	var e = document.getElementById(id);
	if (!e) return;
	l2 = id;
	e.style.visibility = "visible";
	e.style.left = defPosition(event).x+15;
	e.style.top = defPosition(event).y+20;
}
// Назначает скрытие меню второго уровня
function HideProject() {
	if (tim) clearTimeout(tim);
	tim = setTimeout(HideL2, hideTime);
}

(function(){
	var show = false;
	window.ShowLinksOnMain = function(id, element, event) {
		this.id = id;
		this.element = element;
		this.x = defPosition(event).x
		this.y = defPosition(event).y
		setTimeout('ShowLinks()', 340);


	};

	window.ShowLinks = function() {
		if(document.getElementById('Text'+this.id+'.1') != null) {
			if(show == false){
				//if(element != this.element){

				var i = 1;
				//this.origHref = this.element.href;
				this.general = this.element.parentNode;
				this.generalDiv = document.createElement("div");
				this.generalDiv.className = 'GeneralMainMenu';

				this.generalDiv.style.left = this.x;
				this.generalDiv.style.top = this.y;
				//this.element.href = 'javascript:void(0)';

				for(i=1; i < 7; i++){
					var menudocument = document.getElementById('Text'+this.id+'.'+i);
					if(menudocument != null) {

						var div = document.createElement("div");
						div.className = 'MainMenu';

						//var nobr = document.createElement("nobr");
						div.innerHTML = menudocument.innerHTML;

						//div.appendChild(nobr);

						this.generalDiv.appendChild(div);
					}
				}

				this.general.appendChild(this.generalDiv);
				show = true;
			}
		} else {
			document.location.href = this.element.href;
		}
	}

	window.HideLinks = function(){
		//if(this.element.href == 'javascript:void(0)') this.element.href = this.origHref;
		this.general.removeChild(this.generalDiv);
		show = false;
	};
	window.HideLinksOnMain = function() {
		//if(show == true){
		if(this.element){
			setTimeout('HideLinks()', 333);
		}
	}



})();



function openCommentWindow(url, dt, id) {
	$pos = (window.opera) ? ", left=100, top=100" : "";
	nw = window.open(url, "enia-design_" + dt + id, "status=no, toolbar=no, menubar=no, scrollbars=yes, resizable=yes, location=no, width=450, height=475" + $pos);
	nw.focus();
	return false;
}

