//create a pop-up window

function popup(url,wname,wide,high,scroll)
         {
           if (url != "X") 
           {
             self.name = "main"; // names current window as "main"
             pop_window=window.open(url,wname,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars='+scroll+',resizable=1,width='+wide+',height='+high+'');
             var bname=navigator.appName;
             var bver=parseInt(navigator.appVersion);
             if ((bname == "Microsoft Internet Explorer" && bver >= 4) || (bname == "Netscape" && bver >= 3))
             {
                  pop_window.focus();
             }
           }
}

// check on delete

function ConfirmDelete(){
         if (confirm("Are you sure you want to delete selected item?"))
         {
	    return true;
	 }
	 return false;
}

// enable or disable checkboxes according to dropdown selection

function Enable(form) {
         var i = form.post_type.selectedIndex;
         var length = document.post_form.elements.length;
  
         if (i==2)
         {
             for (var i=0; i<length; i++) 
	     { 
               if (document.post_form.elements[i].name.indexOf("o_notify[]") != -1) 
               document.post_form.elements[i].disabled = false 
             } 
         }
         else
         {
             for (var i=0; i<length; i++) 
	     { 
               if (document.post_form.elements[i].name.indexOf("o_notify[]") != -1) 
               document.post_form.elements[i].disabled = true 
             } 
         }
}

// function for expandable menus

function initMenus() {
	if (!document.getElementsByTagName) return;
	
	var aMenus = document.getElementsByTagName("LI");
	for (var i = 0; i < aMenus.length; i++) {
		var mclass = aMenus[i].className;
		if (mclass.indexOf("treenode") > -1) {
			var submenu = aMenus[i].childNodes;
			for (var j = 0; j < submenu.length; j++) {
				if (submenu[j].tagName == "A") {
					
					submenu[j].onclick = function() {
						var node = this.nextSibling;
											
						while (1) {
							if (node != null) {
								if (node.tagName == "UL") {
									var d = (node.style.display == "none")
									node.style.display = (d) ? "block" : "none";
									this.className = (d) ? "treeopen" : "treeclosed";
									return false;
								}
								node = node.nextSibling;
							} else {
								return false;
							}
						}
						return false;
					}
					
					submenu[j].className = (mclass.indexOf("open") > -1) ? "treeopen" : "treeclosed";
				}
				
				if (submenu[j].tagName == "UL")
					submenu[j].style.display = (mclass.indexOf("open") > -1) ? "block" : "none";
			}
		}
	}
}

window.onload = initMenus;
