	function menuPopup(url, windowName, winOptions) {		
		windowReference = window.open(url, windowName, winOptions);				
		windowReference.focus();
		if (!windowReference.opener) {
			windowReference.opener = self;
		}
	}
	
	function IEpopup(url, windowName, options){		
		if (options==null)
			options = 'help:no;dialogLeft:100px;dialogTop:40px;scroll:no;dialogHeight:500px;dialogWidth:600px';		
			windowReference = window.showModalDialog(url, windowName, options);
		//windowReference.focus();
		/*if (!windowReference.opener)
			windowReference.opener = self;
		*/
	}

	// kuvab klikitud kohta popup menüü
	function showRightClickMenu(id, menuID) {
		if (document.menuForm.menu_id) {
		  document.menuForm.menu_id.value = id;
		}
		if (document.menuForm.content_id) {
			document.menuForm.content_id = id;
		}
    // If the browser doesn't support the event object, return
    // (This will only work in Explorer).
    if (typeof event == "undefined")
    	return;
		// Retrieve the element.       
		var e = document.getElementById(menuID);// 
		//e.innerHTML = sText;
		e.style.visibility = "visible";
		// Reposition the element, with a bit of an offset.
		e.style.left = event.x + 5;
		e.style.top = event.y + 5;        
	}
      
  // peideb menüü ära
	function hideRightClickMenu() {
	  if (document.getElementById("rightClickMenu"))
		document.getElementById("rightClickMenu").style.visibility = "hidden";
		if (document.getElementById("rightClickMenu_mainMenu"))
		document.getElementById("rightClickMenu_mainMenu").style.visibility = "hidden";
  }	
	
	// muudab aktiive lingi stiili
	function activeItem() {
		if (event.srcElement.className == "rightClickMenuItem") {
			event.srcElement.style.backgroundColor = "highlight";
			event.srcElement.style.color = "white";			
  	}
	}
	
	// muudab mitteaktiivse lingi stiili
	function lowItem() {
		if (event.srcElement.className == "rightClickMenuItem") {
			event.srcElement.style.backgroundColor = "";
			event.srcElement.style.color = "black";
			window.status = "";
		}
	}
	
	/*
	// läheb käima siis, kui kasutaja klikib lingi (tabeli veeru) peale
	function action(act) {
		id = document.vorm.node_id.value;
		if (act == 'editContent') {
			IEpopup('?action_id=15&windowType=popup&id='+id+'&content_id='+document.vorm.content_id.value, 'popupWindow', 'help:no;status:no;dialogLeft:200px;dialogTop:100px;scroll:yes;dialogHeight:530px;dialogWidth:560px');
			//openPopup('?action_id=15&windowType=popup&id='+id+'&content_id='+document.vorm.content_id.value, 'popupWindow')
		}
		else if(act == 'add') {
			IEpopup('index.php?action_id=4&windowType=popup&id='+id, 'popupWindow', 'help:yes;status:no;dialogLeft:400px;dialogTop:300px;scroll:no;dialogHeight:335px;dialogWidth:335px');
			//openPopup('?action_id=4&windowType=popup&id='+id, 'popupWindow', 'left=400,top=300,scrolling=no,toolbars=no,menubar=no,HEIGHT=160,WIDTH=260')
		}
		else if(act == 'edit') {			
			IEpopup('index.php?action_id=5&windowType=popup&id='+id, 'popupWindow', 'help:no;status:no;dialogLeft:400px;dialogTop:300px;scroll:yes;dialogHeight:335px;dialogWidth:335px');
			//openPopup('?action_id=5&windowType=popup&id='+id, 'popupWindow','left=400,top=300,scrolling=no,toolbars=no,menubar=no,HEIGHT=160,WIDTH=260')
		}
		else {
			document.menuForm.action.value = act;	
			document.menuForm.node_id.value = document.vorm.node_id.value;
			document.menuForm.submit();
		}
	}
	*/
	
	// menüüpunkti lisamine, muutmine, kustutamine
	function menuAction(act, id) {
		menu_id = 0;
		if (document.menuForm.menu_id) {
		  menu_id = document.menuForm.menu_id.value;
		}
		popupWindowOptions = 'resizable=1,left=100,top=40,scrollbars=1,status=0,toolbars=0,menubar=0,HEIGHT=584,WIDTH=642';
		url = 'index.php?action='+act+'_node&windowType=popup&id='+id+'&menu_id='+menu_id;
		if (act=='delete') {
			ok = confirm('Oled kindlel?');
			if (!ok) return;
		}		
		menuPopup(url, 'menuEdit', popupWindowOptions);		
	}
	
	function menuAction2(act, id, menu_id) {
		popupWindowOptions = 'resizable=1,left=100,top=40,scrollbars=1,status=0,toolbars=0,menubar=0,HEIGHT=584,WIDTH=642';
		url = 'index.php?action='+act+'_node&windowType=popup&id='+id+'&menu_id='+menu_id;
		if (act=='delete') {
			ok = confirm('Oled kindlel?');
			if (!ok) return;
		}		
		menuPopup(url, 'menuEdit', popupWindowOptions);		
	}
	
	document.onclick = hideRightClickMenu;