/*
 * menuExpandable2.js - implements an expandable menu based on a HTML list
 * Author: Dave Lindquist (http://www.gazingus.org)
 */

if (!document.getElementById)
    document.getElementById = function() { return null; }

function initializeMenu(menuId, actuatorId) {
    var menu = document.getElementById(menuId);
    var actuator = document.getElementById(actuatorId);

    if (menu == null || actuator == null) return;

    //if (window.opera) return; // I'm too tired

    actuator.onclick = function() {
        var display = menu.style.display;
        menu.style.display = (display == "block") ? "none" : "block";

        return false;
    }
}

function openMenu(menuId, actuatorId) {
  var menu = document.getElementById(menuId);
  var actuator = document.getElementById(actuatorId);

  var display = menu.style.display;
  menu.style.display = "block";
}

function addSearchEngine(engineURL, iconURL, suggestedTitle, suggestedCategory)
{
	var msg = "Přidání vyhledávacího pluginu selhalo - ";

	if((typeof window.sidebar == "object") && (typeof window.sidebar.addSearchEngine == "function"))
	{
		if(engineURL == null || engineURL == "")
		{
			alert(msg + "nebyla zadána jeho URL.");
			return false;
		}
		if(iconURL == null || iconURL == "")
		{
			alert(msg + "nebyla zadána URL ikony.");
			return false;
		}
		if(engineURL.search(/^http:\/\//i) == -1 || engineURL.search(/\.src$/i) == -1)
		{
			alert(msg + "nebyla zadána platná URL.");
			return false;
		}
		if(iconURL.search(/^http:\/\//i) == -1 || iconURL.search(/\.(gif|jpg|jpeg|png)$/i) == -1)
		{
			alert(msg + " nebyla platná URL ikony.");
			return false;
		}
		
		if(suggestedTitle == null)
			suggestedTitle = "";
		if(suggestedCategory == null)
			suggestedCategory = "";
			
		window.sidebar.addSearchEngine(engineURL, iconURL, suggestedTitle, suggestedCategory);
	}
	else
	{
		alert("Váą prohlíľeč nepodporuje tuto funkci. Zkuste Mozillu.");
	}
	return false;
}







function showSubmenu(id){

	for (var c = 1; c<=5;c++){
		pashead = document.getElementById("topmenuhead"+c);
		
		if(pashead.className.indexOf(" active") > 0){
			pashead.className = pashead.className.substr(0,pashead.className.indexOf(" active"));
		}
		
		off = document.getElementById("submenu"+c);
		off.style.display = "none";
		
	}
		

		
	var activehead = document.getElementById("topmenuhead"+id);
	activehead.className = activehead.className + " active";

	var active = document.getElementById("submenu"+id);
	active.style.display = "block";
}

