<?php
require_once('conn.php');
checkLogin("");

$iframe = $_GET['iframe'] ?? '';

// Common HTML header
$html_header = <<<HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="css/common.css" type="text/css" />
HTML;

switch($iframe) {
    case 'top':
        echo $html_header;
        ?>
        <title><?php echo $webname; ?> - 网站后台管理</title>
        </head>
        <body>
        <h1 style="padding:0;margin:0;height:50px;line-height:50px;text-indent:20px;font-size:20px;font-family:Arial;color:#0099CC"><?php echo $webname; ?></h1>
        </body>
        <?php
        break;

    case 'left':
        echo $html_header;
        ?>
        <title>左侧导航栏</title>
        </head>
        <script type="text/javascript">
        var preClassName = ""; 
        function list_sub_detail(Id, item) 
        { 
            if(preClassName != "") 
            { 
                getObject(preClassName).className = "left_back" 
            } 
            if(getObject(Id).className == "left_back") 
            { 
                getObject(Id).className = "left_back_onclick"; 
                outlookbar.getbyitem(item); 
                preClassName = Id 
            } 
        } 

        function getObject(objectId) 
        { 
            if(document.getElementById && document.getElementById(objectId)) 
            { 
                return document.getElementById(objectId) 
            } 
            else if(document.all && document.all(objectId)) 
            { 
                return document.all(objectId) 
            } 
            else if(document.layers && document.layers[objectId]) 
            { 
                return document.layers[objectId] 
            } 
            else 
            { 
                return false 
            } 
        } 

        function outlook() 
        { 
            this.titlelist = new Array(); 
            this.itemlist = new Array(); 
            this.addtitle = addtitle; 
            this.additem = additem; 
            this.getbytitle = getbytitle; 
            this.getbyitem = getbyitem; 
            this.getdefaultnav = getdefaultnav 
        } 

        function theitem(intitle, insort, inkey, inisdefault) 
        { 
            this.sortname = insort; 
            this.key = inkey; 
            this.title = intitle; 
            this.isdefault = inisdefault 
        } 

        function addtitle(intitle, sortname, inisdefault) 
        { 
            outlookbar.itemlist[outlookbar.titlelist.length] = new Array(); 
            outlookbar.titlelist[outlookbar.titlelist.length] = new theitem(intitle, sortname, 0, inisdefault); 
            return(outlookbar.titlelist.length - 1) 
        } 

        function additem(intitle, parentid, inkey) 
        { 
            if(parentid >= 0 && parentid <= outlookbar.titlelist.length) 
            { 
                insort = "item_" + parentid; 
                outlookbar.itemlist[parentid][outlookbar.itemlist[parentid].length] = new theitem(intitle, insort, inkey, 0); 
                return(outlookbar.itemlist[parentid].length - 1) 
            } 
            else additem = - 1 
        } 

        function getdefaultnav(sortname) 
        { 
            var output = ""; 
            for(i = 0; i < outlookbar.titlelist.length; i ++ ) 
            { 
                if(outlookbar.titlelist[i].isdefault == 1 && outlookbar.titlelist[i].sortname == sortname) 
                { 
                    output += "<div class=list_tilte id=sub_sort_" + i + " onclick=\"hideorshow('sub_detail_"+i+"')\">"; 
                    output += "<span>" + outlookbar.titlelist[i].title + "</span>"; 
                    output += "</div>"; 
                    output += "<div class=list_detail id=sub_detail_" + i + "><ul>"; 
                    for(j = 0; j < outlookbar.itemlist[i].length; j ++ ) 
                    { 
                        output += "<li id=" + outlookbar.itemlist[i][j].sortname + j + " onclick=\"changeframe('"+outlookbar.itemlist[i][j].title+"', '"+outlookbar.titlelist[i].title+"', '"+outlookbar.itemlist[i][j].key+"')\"><a href=#>" + outlookbar.itemlist[i][j].title + "</a></li>" 
                    } 
                    output += "</ul></div>" 
                } 
            } 
            getObject('right_main_nav').innerHTML = output 
        } 

        function getbytitle(sortname) 
        { 
            var output = "<ul>"; 
            for(i = 0; i < outlookbar.titlelist.length; i ++ ) 
            { 
                if(outlookbar.titlelist[i].sortname == sortname) 
                { 
                    output += "<li id=left_nav_" + i + " onclick=\"list_sub_detail(id, '"+outlookbar.titlelist[i].title+"')\" class=left_back>" + outlookbar.titlelist[i].title + "</li>" 
                } 
            } 
            output += "</ul>"; 
            getObject('left_main_nav').innerHTML = output 
        } 

        function getbyitem(item) 
        { 
            var output = ""; 
            for(i = 0; i < outlookbar.titlelist.length; i ++ ) 
            { 
                if(outlookbar.titlelist[i].title == item) 
                { 
                    output = "<div class=list_tilte id=sub_sort_" + i + " onclick=\"hideorshow('sub_detail_"+i+"')\">"; 
                    output += "<span>" + outlookbar.titlelist[i].title + "</span>"; 
                    output += "</div>"; 
                    output += "<div class=list_detail id=sub_detail_" + i + " style='display:block;'><ul>"; 
                    for(j = 0; j < outlookbar.itemlist[i].length; j ++ ) 
                    { 
                        output += "<li id=" + outlookbar.itemlist[i][j].sortname + "_" + j + " onclick=\"changeframe('"+outlookbar.itemlist[i][j].title+"', '"+outlookbar.titlelist[i].title+"', '"+outlookbar.itemlist[i][j].key+"')\"><a href=#>" + outlookbar.itemlist[i][j].title + "</a></li>" 
                    } 
                    output += "</ul></div>" 
                } 
            } 
            getObject('right_main_nav').innerHTML = output 
        } 

        function changeframe(item, sortname, src) 
        { 
            if(item != "" && sortname != "") 
            { 
                window.top.frames['mainFrame'].getObject('show_text').innerHTML = sortname + "  <img src=images/slide.gif broder=0 />  " + item 
            } 
            if(src != "") 
            { 
                window.top.frames['manFrame'].location = src 
            } 
        } 

        function hideorshow(divid) 
        { 
            subsortid = "sub_sort_" + divid.substring(11); 
            if(getObject(divid).style.display == "none") 
            { 
                getObject(divid).style.display = "block"; 
                getObject(subsortid).className = "list_tilte" 
            } 
            else 
            { 
                getObject(divid).style.display = "none"; 
                getObject(subsortid).className = "list_tilte_onclick" 
            } 
        } 

        function initinav(sortname) 
        { 
            outlookbar.getdefaultnav(sortname); 
            outlookbar.getbytitle(sortname); 
        }

        var outlookbar = new outlook();
        var t;

        t = outlookbar.addtitle('信息管理','信息管理',1);
        <?php if(chkLogin("信息管理")): ?>
        outlookbar.additem('来源管理',t,'qudao.php');
        outlookbar.additem('客户列表',t,'customers.php');
        outlookbar.additem('登录日志',t,'log.php');
        <?php endif; ?>

        t = outlookbar.addtitle('报价管理','信息管理',1);
        <?php if(chkLogin("信息管理")): ?>
        outlookbar.additem('产品列表',t,'products.php');
        outlookbar.additem('报价管理',t,'country.php');
        outlookbar.additem('产品分类',t,'product_category.php');
        <?php endif; ?>

        t = outlookbar.addtitle('系统管理','其它管理',1);
        <?php if(chkLogin("系统管理")): ?>
        outlookbar.additem('查看系统设置',t,'inc.php');
        <?php endif; ?>

        t = outlookbar.addtitle('权限管理','其它管理',1);
        <?php if(chkLogin("权限管理")): ?>
        outlookbar.additem('用户管理',t,'employee.php');
        <?php endif; ?>
        </script>
        <body onload="initinav('信息管理')">
        <div id="left_content">
            <div id="user_info">欢迎您,<strong><?php echo loadSession("loginname"); ?></strong><br />[<a href="pwd.php" target="manFrame">个人中心</a>,<a href="login.php?act=logout" target="_top" onClick="if(!confirm('确认要退出吗?'))return false;">退出管理</a>]</div>
            <div id="main_nav">
                <div id="left_main_nav"></div>
                <div id="right_main_nav"></div>
            </div>
        </div>
        </body>
        <?php
        break;

    case 'switch':
        echo $html_header;
        ?>
        <title>显示/隐藏左侧导航栏</title>
        </head>
        <script language="JavaScript">
        function Submit_onclick(){
            if(parent.myFrame.cols == "199,7,*") {
                parent.myFrame.cols="0,7,*";
                document.getElementById("ImgArrow").src="images/switch_right.gif";
                document.getElementById("ImgArrow").alt="打开左侧导航栏";
            } else {
                parent.myFrame.cols="199,7,*";
                document.getElementById("ImgArrow").src="images/switch_left.gif";
                document.getElementById("ImgArrow").alt="隐藏左侧导航栏";
            }
        }

        function MyLoad() {
            if(window.parent.location.href.indexOf("MainUrl")>0) {
                window.top.midFrame.document.getElementById("ImgArrow").src="images/switch_right.gif";
            }
        }
        </script>
        <body onload="MyLoad()">
        <div id="switchpic"><a href="javascript:Submit_onclick()"><img src="images/switch_left.gif" alt="隐藏左侧导航栏" id="ImgArrow" /></a></div>
        </body>
        <?php
        break;

    case 'main':
        echo $html_header;
        ?>
        <title>管理导航区域</title>
        <script type="text/javascript">
        var preClassName = "man_nav_1";

        function list_sub_nav(Id,sortname){
            if(preClassName != ""){
                getObject(preClassName).className="bg_image";
            }
            if(getObject(Id).className == "bg_image"){
                getObject(Id).className="bg_image_onclick";
                preClassName = Id;
                showInnerText(Id);
                window.top.frames['leftFrame'].outlookbar.getbytitle(sortname);
                window.top.frames['leftFrame'].outlookbar.getdefaultnav(sortname);
            }
        }

        function showInnerText(Id){
            var switchId = parseInt(Id.substring(8));
            var showText = "对不起没有信息!";
            switch(switchId){
                case 1:
                    showText =  "请点击左侧菜单进行网站信息管理";
                    break;
                case 2:
                    showText =  "请点击左侧菜单进行其它信息管理";
                    break;
            }
            getObject('show_text').innerHTML = showText;
        }

        function getObject(objectId) {
            if(document.getElementById && document.getElementById(objectId)) {
                return document.getElementById(objectId);
            } else if (document.all && document.all(objectId)) {
                return document.all(objectId);
            } else if (document.layers && document.layers[objectId]) {
                return document.layers[objectId];
            } else {
                return false;
            }
        }
        </script>
        </head>
        <body>
        <div id="nav">
            <ul>
                <li id="man_nav_1" onclick="list_sub_nav(id,'信息管理')" class="bg_image_onclick">信息管理</li>
                <li id="man_nav_2" onclick="list_sub_nav(id,'其它管理')"  class="bg_image">其它管理</li>
                <li class="bg_image"><a href="index.php?iframe=man" target="manFrame">回到桌面</a></li>
                <li class="bg_image"><a href="../index.html" target="_blank">打开前台</a></li>
            </ul>
        </div>
        <div id="sub_info">&nbsp;&nbsp;<img src="images/hi.gif" />&nbsp;<span id="show_text">请点击左侧或下面菜单进行网站信息管理</span></div>
        </body>
        <?php
        break;

    case 'man':
        echo $html_header;
        ?>
        <title>管理区域</title>
        <script type="text/javascript">
        function golink(t){
            window.top.frames['mainFrame'].getObject('show_text').innerHTML = t;
        }

        function getObject(objectId) {
            if(document.getElementById && document.getElementById(objectId)) {
                return document.getElementById(objectId);
            } else if (document.all && document.all(objectId)) {
                return document.all(objectId);
            } else if (document.layers && document.layers[objectId]) {
                return document.layers[objectId);
            } else {
                return false;
            }
        }
        </script>
        <style>
        .menulist li{float:left;width:92px;height:132px;}
        .menulist li a{display:block;padding:10px 0;padding-top:50px;width:80px;height:15px;color:#A1B5B3;border:1px solid #B4C9C6;margin:5px;text-align:center}
        .menulist li a img{margin-bottom:5px}
        .menulist li a:hover{border:2px solid #B4C9C6;width:78px;height:13px;color:#A1B5B3}

        .png01{background:url(menu/01.png) center 8px no-repeat}
        .png02{background:url(menu/02.png) center 8px no-repeat}
        .png03{background:url(menu/03.png) center 8px no-repeat}
        .png04{background:url(menu/04.png) center 8px no-repeat}
        .png05{background:url(menu/05.png) center 8px no-repeat}
        .png06{background:url(menu/06.png) center 8px no-repeat}
        </style>
        </head>
        <body>
        <div id="man_zone">
        <ul class="menulist">
            <li><a href="customers.php" onClick="golink('打开信息列表')" class="png03">客户管理</a></li>
        </ul>
        </div>
        </body>
        <?php
        break;

    default:
        echo $html_header;
        ?>
        <title><?php echo $webname; ?> - 网站后台管理</title>
        </head>
        <frameset rows="50,*" cols="*" frameborder="no" border="0" framespacing="0">
            <frame src="?iframe=top" name="topFrame" frameborder="no" scrolling="No" noresize="noresize" id="topFrame" title="topFrame" />
            <frameset name="myFrame" cols="199,7,*" frameborder="no" border="0" framespacing="0">
                <frame src="?iframe=left" name="leftFrame" frameborder="no" scrolling="No" noresize="noresize" id="leftFrame" title="leftFrame" />
                <frame src="?iframe=switch" name="midFrame" frameborder="no" scrolling="No" noresize="noresize" id="midFrame" title="midFrame" />
                <frameset rows="59,*" cols="*" frameborder="no" border="0" framespacing="0">
                    <frame src="?iframe=main" name="mainFrame" frameborder="no" scrolling="No"  noresize="noresize" id="mainFrame" title="mainFrame" />
                    <frame src="?iframe=man" name="manFrame" frameborder="no" id="manFrame" title="manFrame" />
                </frameset>
            </frameset>
        </frameset>
        <noframes><body></body></noframes>
        <?php
}
?>