var fuenteTitulo = "Verdana"
var fuente = "Verdana"
var margen="20";
var margenArriba="5";
var tamanioTitulo="10";
var tamanio="10";
var colorTitulo="404040";
var colorEnlace="404040";
var distanciaLinea="12";
var Imagen=new Image();
Imagen.src="imagenes/closed.gif";
var ImagenDesp=new Image();
ImagenDesp.src="imagenes/open.gif";

function generaEstilos() {
    document.writeln("<style>");
    document.writeln("ol.menus {");
    document.writeln("  list-style-type:none;");
    document.writeln("  margin-left:"+margen+"px;");
    document.writeln("  margin-top:"+margenArriba+"px;");
    document.writeln("  line-height:"+distanciaLinea+"px;");
    document.writeln("  list-style-position: outside;");
    document.writeln("}");
    document.writeln(".menuses {");
    document.writeln("  font-size:"+tamanioTitulo+"px;");
    document.writeln("  color:"+colorTitulo+";");
    document.writeln("  font-family:"+fuenteTitulo+";");
    document.writeln("  text-decoration:none;");
    document.writeln("}");
    document.writeln("a.menuses {");
    document.writeln("  font-size:"+tamanio+"px;");
    document.writeln("  color:"+colorEnlace+";");
    document.writeln("  font-family:"+fuente+";");
    document.writeln("  text-decoration:none;");
    document.writeln("}");
    document.writeln("<\/style>");

}function Menu(texto) {
    this.item=new Array();
    this.nroItems=0;
    this.texto=texto;

    this.addItem=AddItem;
    this.addSubmenu=AddSubmenu;
    this.construyeMenu = ConstruyeMenu;
    return this;
}

function AddItem (texto,enlace,target) {
    this.item[this.nroItems]=new Object();
    this.item[this.nroItems].texto=texto;
    this.item[this.nroItems].target="pantalla";
    this.item[this.nroItems].enlace=enlace;
    this.nroItems++;
}

function AddSubmenu(nombre,texto,enlace,target) {
    this.item[this.nroItems]=new Object();
    this.item[this.nroItems].menu=new Menu(texto);
    this.item[this.nroItems].menu.imagen=Imagen;
    this.item[this.nroItems].menu.imagenDesp=ImagenDesp;

        this.item[this.nroItems].target="pantalla";
        this.item[this.nroItems].enlace=enlace;
    this.item[this.nroItems].menu.nombre=nombre;
    eval ("this." +nombre + " = this.item[this.nroItems].menu");

    this.nroItems++;
}

function expande(obj) {
    var sigNodo = document.getElementById("SPAN_" + obj)
    var img = document.getElementById("IMG_" + obj)
    sigNodo.style.display=(sigNodo.style.display=="")?"none":"";
    img.src=(sigNodo.style.display=="")?ImagenDesp.src:Imagen.src;
}
function Hover(cual,sw) {
    cual.style.backgroundColor=sw?BGColorMO:BGColor;
}

function ConstruyeMenu() {
   document.writeln("<ol class=\"menus\">");
    for (var i=0; i<this.item.length; i++) {
        if (!this.item[i].menu) {
            document.writeln("<li><a href=\""+this.item[i].enlace+"\" target=\""+this.item[i].target+"\" class=\"menuses\">"+this.item[i].texto+"</a></li>");
        } else {
             document.writeln ("<li ");
             document.writeln (" CLASS=\"menuses\"><img src=\""+Imagen.src+"\" name='IMG_"+this.item[i].menu.nombre+"'> ");
             if (this.item[i].enlace) {
                document.writeln ("<a href=\""+this.item[i].enlace+"\" target=\""+this.item[i].target+"\" ");
             } else {
    document.writeln ("<span style=\"cursor:hand\" ");
             }
                if (this.item[i].menu.item.length>0) {
                    document.writeln ("onclick=\"expande('"+this.item[i].menu.nombre+"')\"");
    }
             document.writeln (" class=\"menuses\"><strong>");
             document.writeln (this.item[i].menu.texto+"</strong>")
            if (this.item[i].enlace) document.writeln ("</a>");
            else document.writeln ("</span>");
            document.writeln("</li>");
             if (this.item[i].menu.item.length>0) {
                document.writeln("<SPAN ID=\"SPAN_"+this.item[i].menu.nombre+"\" CLASS=\"menusex\">")
                this.item[i].menu.construyeMenu();
                document.writeln ("</SPAN>")
                document.getElementById("SPAN_"+this.item[i].menu.nombre).style.display="none";
            }
        }
    }
document.writeln("</ol>");
}

