<?php
require('startinclude.php');
$ventanan=parametro('ventanan', 0);
$ultimo=parametro('ultimo', 0);
$links=array();
$links['normal']="wnormal.php?ventanan=".$ventanan;
$links['sensor']="wsensor.php?ventanan=".$ventanan;
$links['off']="winicial.php?ventanan=".$ventanan;
$links['grafico']="wgrafico.php?ventanan=".$ventanan;
$links['procesotablahistorico']="wprocesotablahistorico.php?ventanan=".$ventanan;
$links['whistorico_procesos']="whistorico_procesos.php?ventanan=".$ventanan;
$links['']="winicial.php?ventanan=".$ventanan;
$menu=array();
obtener_login_nivel($nivel_usuario);
leer_menu($menu, $nivel_usuario);
$_SESSION["refreshpage"]=0;
?>
<head>
    <script type = 'text/javascript' src = 'ajaxlib/utils/southprojects.js'>
    </script>
    <script type = "text/javascript" src = "ajaxlib/spmenu/src/spmenu.js">
    </script>
    <script type = 'text/javascript' src = 'cookies.js'>
    </script>
    <script type = 'text/javascript' src = 'ajaxlib/utils/stylesheet.js'>
    </script>
    <script type = 'text/javascript' src = 'ajaxlib/utils/preloadimages.js'>
    </script>
    <link href = "ajaxlib/spmenu/themes/winxp1.css" rel = "stylesheet" type = "text/css">
    <link href = "ajaxlib/spmenu/themes/layout/basic.css" rel = "stylesheet" type = "text/css">
    <link rel = "stylesheet" type = "text/css" href = "chrometheme/chromestyle.css" />
    <script type = "text/javascript" src = "chromejs/chrome.js">
        /***********************************************
        * Chrome CSS Drop Down Menu- � Dynamic Drive DHTML code library (www.dynamicdrive.com)
        * This notice MUST stay intact for legal use
        * Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
        ***********************************************/
    </script>
    <style type = "text/css">
        body
            {
            margin: 0px;
            background: #FFCC66;
            }
    </style>
</head>
<body>
    <div style = "width: 100%">
    <!--<ul class='zpHideOnLoad' id="myMenu">-->
        <?php
        // encabezado..
        echo "<div class='chromestyle' id='chromemenu' style='width:800px;'>\n";
        echo "<ul>\n";
        for ($i=0; $i<count($menu); $i++) {
            $id=floor($menu[$i]["id_menu"]/100);
            if (trim($menu[$i]["paginaphp"])=="") {
                $titulo=trim($menu[$i]["nombre_menu"]);
                echo "<li><a href='#' rel='dropmenu$id'>$titulo</a></li>\n";
            }
        }
        echo "</ul>\n";
        echo "</div>\n";
        $id_anterior=-1;
        for ($i=0; $i<count($menu); $i++) {
            $id=floor($menu[$i]["id_menu"]/100);
            if (trim($menu[$i]["paginaphp"])!="") {
                if ($id_anterior!=$id) {
                    if ($id_anterior!=-1) {
                        echo "</div>\n";                                 // cerramos el div anterior.
                    }
                    echo "<div id='dropmenu$id' class='dropmenudiv'>\n"; // creamos un div nuevo.
                    $id_anterior=$id;
                }
                echo "<a href='#' onclick=\"javascript:modiframe('".$menu[$i]["paginaphp"]."?ventanan=$ventanan');\">";
                echo "<img border='0' src='images/miniicon/".$menu[$i]["icon"]."'>".$menu[$i]["nombre_menu"];
                echo "</a>\n";
            }
        }
        echo "</div>\n"; // cerramos el ultimo div anterior.
        ?>
    <!--</ul>-->
    <!--</li>-->
    <!--</ul>-->
    </div>
    <script type = "text/javascript">
        cssdropdown.startchrome("chromemenu")
        var funcOnInit = function()
            {
            parent.win[<? echo $ventanan ?>].hide();
            //alert("ok");
            }
        parent.win[<? echo $ventanan ?>].hide();
        function modiframe(destino)
            {
            setCookie("estado_ventanan<? echo $ventanan; ?>",
                "off"); // desconectamos la pantalla hasta que no se carguen los datos.
            <?
if (strpos ($_SERVER['HTTP_USER_AGENT'],"Safari")) {
	echo "var bodyIframe = self.frames.iframe2; // safari ";
} else {
	echo "if(document.frames) \n";
	echo "	var bodyIframe = document.frames.iframe2 // iexplorer\n";
	echo "else \n";
	echo "	var bodyIframe = iframe2.contentDocument; // firefox\n";	
}	
?>
            //parent.reactivar();
            bodyIframe.location = destino;
            }
        <?php
		if ($ultimo) {
			echo "parent.ocultarespere();";
		}
		?>
    </script>
    <?php
    if (isset($_COOKIE["estado_ventanan".$ventanan])) {
        $estado_ventanan=$_COOKIE["estado_ventanan".$ventanan];
    } else {
        $estado_ventanan="off";
    }
    $pagina=$links[$estado_ventanan];
    //ECHO "sesion expira ".$_SESSION["tipo"];
    if ($pagina) {
        echo "<iframe src='$pagina' id='iframe2' name='iframe3' width=98% height=90% ></iframe>";
    } else {
        $pagina=$links[''];
        echo "<iframe src='$pagina' id='iframe2' name='iframe3' width=98% height=90% ></iframe>";
    }
    ?>
</body>