<?php
/*
 * This file is part of a larger software package. Please read the License file 
 * in the root of this installation for terms of usage and distribution.
 * 
 * @author The Web Pro Miami, Inc. <info@thewebpro.com>
 * @copyright The Web Pro Miami, Inc. <info@thewebpro.com>, http://www.thewebpro.com/
 * 
 * FILE: manage/inc/nav/header.php
*/

// Build navigation
$nThisPath = $_SERVER["PHP_SELF"]; $nPathParts = explode('/', $nThisPath); $nThisPath = $nPathParts[count($nPathParts)-1];
$nNavARRAY = array();

// Dashboard
$nNavARRAY[] = array(_("Dashboard").",home.php","");
/* Sections
$nNavARRAY[] = array(_("Sections").",sections.php",
	array(
		_("View &amp; Edit Sections").",sections.php",
		_("Edit Section").",section_edit.php,1"
	)
);
*/
// Pages
if(isset($nAccessPages) && $nAccessPages){
	if(isset($nAdminAccess) && $nAdminAccess){
		$nNavARRAY[] = array(_("Pages").",pages.php",
			array(
				_("View &amp; Edit Pages").",pages.php",
				_("Page Templates").",page_templates.php",
				_("Edit Page").",page_edit.php,1"
			)
		);
	} else {
		$nNavARRAY[] = array(_("Pages").",pages.php",
			array(
				_("View &amp; Edit Pages").",pages.php",
				_("Edit Page").",page_edit.php,1"
			)
		);
	}
}
// Library
if(isset($nAccessLibrary) && $nAccessLibrary){
	if(isset($nAdminAccess) && $nAdminAccess){
		$nNavARRAY[] = array(_("Library").",library_images.php",
			array(
				_("Images").",library_images.php",
				_("Documents").",library_docs.php",
				_("Plugins").",plugins.php",
				_("Plugin Settings").",plugin_settings.php,1",
				_("Components").",components.php",
				_("Themes").",library_theme.php"
			)
		);
	} else {
		$nNavARRAY[] = array(_("Library").",library_images.php",
			array(
				_("Images").",library_images.php",
				_("Documents").",library_docs.php"
			)
		);
	}
}
// Users
if(isset($nAdminAccess) && $nAdminAccess){
	$nNavARRAY[] = array(_("Users").",users.php",
		array(
			_("View &amp; Edit Users").",users.php",
			_("Edit User").",user_modify.php,1"
		)
	);
} else {
	$nUserLink = nGetUserLinkFromName($ValidUser);
	$nNavARRAY[] = array(_("Account").",$nUserLink",
		array(
			_("Edit My Account").",$nUserLink"
		)
	);
}
// Settings
if(isset($nAccessSettings) && $nAccessSettings){
	$nNavARRAY[] = array(_("Settings").",site_settings.php",
		array(
			_("Site Settings").",site_settings.php",
			_("System Settings").",system_settings.php"
		)
	);
}
// Log
if(isset($nAdminAccess) && $nAdminAccess){
	$nNavARRAY[] = array(_("System Log").",system_log.php","");
}

// Build nav
$nNavCODE = $nDDNavCode = "";
foreach($nNavARRAY AS $nNavItemARRAY){
	$nChildSelected=0;
	$nSubNavCODE="";
	$nNamePathARRAY = explode(",",$nNavItemARRAY[0]);
	$nParentName = $nNamePathARRAY[0];
	$nParentPath = $nNamePathARRAY[1];
	if($nNavItemARRAY[1]){
		$nChildARRAY = $nNavItemARRAY[1];
		$nSubNavCODE.= "\t<ul>\n";
		foreach($nChildARRAY AS $nChildItem){
			$nChildNamePathARRAY = explode(",",$nChildItem);
			if(isset($nChildNamePathARRAY[0])){ $nChildName = $nChildNamePathARRAY[0]; } else { $nChildName = ""; }
			if(isset($nChildNamePathARRAY[1])){ $nChildPath = $nChildNamePathARRAY[1]; } else { $nChildPath = ""; }
			if(isset($nChildNamePathARRAY[2])){ $nHide = $nChildNamePathARRAY[2]; } else { $nHide = ""; }
			if($nThisPath==parse_url($nChildPath)){ $nChildClass=" class=\"active\""; $nChildSelected=1; } else { $nChildClass=""; } // updated from "parse_url($nChildPath,PHP_URL_PATH)" for PHP 4 compatibablity
			if(!$nHide){ $nSubNavCODE.= "\t\t<li$nChildClass><a href=\"$nChildPath\"><span>$nChildName</span></a></li>\n"; }
		}
		$nSubNavCODE.= "\t</ul>\n";
	}
	if($nThisPath==parse_url($nParentPath) || $nChildSelected){ $nParentClass=" class=\"active\""; $nDDSelected = "selected"; } else { $nParentClass=""; $nDDSelected = ""; } // updated from "parse_url($nParentPath,PHP_URL_PATH)" for PHP 4 compatibablity
	
	$nNavCODE.= "<li$nParentClass>\n\t<a href=\"$nParentPath\"><span>$nParentName</span></a>\n";
	$nDDNavCode.= "<option value=\"$nParentPath\" $nDDSelected>$nParentName</option>";
	if($nSubNavCODE){ $nNavCODE.=$nSubNavCODE."</li>\n"; } else { $nNavCODE.="</li>\n"; }
	// if($nSubNavCODE && ($nThisPath==$nParentPath || $nChildSelected)){ $nNavCODE.=$nSubNavCODE."</li>\n"; } else { $nNavCODE.="</li>\n"; } // hide subnav until parent is active
}
?>
<html lang="en-us">
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge;chrome=1" >
	<meta charset="utf-8" />
	<meta http-equiv="content-type" content="text/html; charset=UTF-8">
	<link rel="apple-touch-con" href="" />
	<title><?php echo _("Web Pro Manager"); ?></title>
	<meta name="viewport" content="width=device-width, minimum-scale=1.0, maximum-scale=1.0">
	<link rel="stylesheet" href="assets/styles/columnal/columnal.css" type="text/css" media="screen" />
	<!--[if lt IE 9]>
            <link rel="stylesheet" href="assets/styles/columnal/ie.css" type="text/css" media="screen" />
            <link rel="stylesheet" href="assets/styles/ie8.css" type="text/css" media="screen" />
            <script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE9.js"></script>
            <script type="text/javascript" src="assets/scripts/flot/excanvas.min.js"></script>
	<![endif]-->        
	<link rel="stylesheet" href="assets/scripts/jqueryui/jqueryui.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="assets/styles/style.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="assets/styles/global.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="assets/styles/config.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="assets/styles/form.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="assets/styles/drag_drop.css" type="text/css" media="screen" />
    <script src="assets/scripts/jquery-1.6.4.min.js"></script>
    <script src="assets/scripts/jqueryui/jquery-ui-1.8.16.custom.min.js"></script>
	<!-- Adds HTML5 Placeholder attributes to those lesser browsers (i.e. IE) -->
	<script type="text/javascript" src="assets/scripts/jquery.placeholder.1.2.min.shrink.js"></script>
	<!-- Menu -->
	<link rel="stylesheet" href="assets/scripts/superfish/superfish.css" type="text/css" media="screen" />
	<script src="assets/scripts/superfish/superfish.js"></script>
	<!-- Adds charts -->
	<script type="text/javascript" src="assets/scripts/flot/jquery.flot.min.js"></script>
	<script type="text/javascript" src="assets/scripts/flot/jquery.flot.pie.min.js"></script>
	<script type="text/javascript" src="assets/scripts/flot/jquery.flot.stack.min.js"></script>
	<!-- Form Validation Engine -->
	<script src="assets/scripts/formvalidator/jquery.validationEngine.js"></script>
	<script src="assets/scripts/formvalidator/jquery.validationEngine-en.js"></script>
	<link rel="stylesheet" href="assets/scripts/formvalidator/validationEngine.jquery.css" type="text/css" media="screen" />
	<!-- Sortable, searchable DataTable -->
	<script src="assets/scripts/jquery.dataTables.min.js"></script>
	<script src="assets/scripts/jquery.dataTables.currency.js"></script>
	<script src="assets/scripts/jquery.dataTables.datetime.js"></script>
	<script src="assets/scripts/jquery.dataTables.grouping.js"></script>
	<script src="assets/scripts/list_utility.js"></script>
	<!-- Custom Tooltips -->
	<script src="assets/scripts/twipsy/twipsy.js"></script>
	<link rel="stylesheet" href="assets/scripts/twipsy/twipsy.css" type="text/css" media="screen" />
	<!-- News Ticker -->
	<script src="assets/scripts/ticker/jquery.ticker.js"></script>
	<link rel="stylesheet" href="assets/scripts/ticker/ticker.css" type="text/css" media="screen" />
	<!-- WYSIWYG Editor -->
	<script src="assets/scripts/cleditor/jquery.cleditor.min.js"></script>
	<link rel="stylesheet" href="assets/scripts/cleditor/jquery.cleditor.css" type="text/css" media="screen" />
	<script type="text/javascript" src="rte/fckeditor.js"></script>
	<!-- Fullsized calendars -->
	<link rel="stylesheet" href="assets/scripts/fullcalendar/fullcalendar.css" type="text/css" media="screen" />
	<link rel="stylesheet" href="assets/scripts/fullcalendar/fullcalendar.print.css" type="text/css" media="print" />
	<script src="assets/scripts/fullcalendar/fullcalendar.min.js"></script>
	<script src="assets/scripts/fullcalendar/gcal.js"></script>
	<!-- Colorbox is a lightbox alternative-->
	<script src="assets/scripts/colorbox/jquery.colorbox-min.js"></script>
	<link rel="stylesheet" href="assets/scripts/colorbox/colorbox.css" type="text/css" media="screen" />
	<!-- Colorpicker -->
	<script src="assets/scripts/colorpicker/colorpicker.js"></script>
	<script src="assets/scripts/muse.js"></script>
	<link rel="stylesheet" href="assets/scripts/colorpicker/colorpicker.css" type="text/css" media="screen" />
	<!-- Uploadify -->
	<script type="text/javascript" src="assets/scripts/uploadify/jquery.uploadify.v2.1.4.min.js"></script>
	<script type="text/javascript" src="assets/scripts/uploadify/swfobject.js"></script>
	<link rel="stylesheet" href="assets/scripts/uploadify/uploadify.css" type="text/css" media="screen" />
	<!-- Timepicker //-->
	<script src="assets/scripts/timepicker.js"></script>
	<!-- All the other js used -->
	<script src="assets/scripts/demo.js"></script>
	<script src="assets/scripts/jquery_processor.js"></script>
	<script src="assets/scripts/jquery.inlineEdit.js" type="text/javascript"></script>
	<link rel="stylesheet" href="assets/styles/print.css" type="text/css" media="print" />
</head>
<body>

<div id="spinner" class="spinner" style="display:none;">
    <img src="assets/images/loading.gif" alt="Loading" name="img-spinner" id="img-spinner" width="42" height="42" border="0">
</div>

<div id="wrap">
	<div id="main">
            <header class="container">
                <div class="row clearfix">
                    <div class="left">
                        <a href="home.php" id="logo"><img src="assets/images/logo_s.png" alt="<?php echo _("Web Pro Manager"); ?>" height="36" border="0"></a>
                    </div>
                    <div class="right">
                        <ul id="toolbar">
                            <li><span><?php echo _("Logged in as"); ?></span> <a class="user" href="user_modify.php?usr=<?=$UID;?>"><?=$ValidUser;?></a> <a id="loginarrow" href="#"></a></li>
							<!-- <li><a id="messages" href="#">Messages</a></li> //-->
                            <!-- <li><a id="settings" href="#">Settings</a></li> //-->
                            <!-- <li><a id="search" href="#">Search</a></li> //-->
							<li><a id="store" href="<?=$nFullSitePath?>" target="_blank"><?php echo _("View Website"); ?></a></li>
                        </ul>
                        <div id="logindrop">
                            <ul>
                                <li id="editprofile"><a href="user_modify.php?usr=<?=$UID;?>"><?php echo _("Edit Profile"); ?></a></li>
                                <li id="logoutprofile"><a href="process_logout.php"><?php echo _("Logout"); ?></a></li>
                            </ul>
                        </div>
                        <div id="searchdrop">
                            <input type="text" id="searchbox" placeholder="Search teams, anglers, boats...">

	<script>
	$(function() {
		$( "#searchbox" ).catcomplete({
			source: "process/json/globalsearch.php",
			minLength: 2,
			select: function( event, ui ) {
				var xItemID = ui.item.id;
				var xItemName = ui.item.value;
				switch(ui.item.category){
					case "Orders": document.location.href='order_modify.php?ord='+xItemID; break;
					case "Products": document.location.href='prod_modify.php?ord='+xItemID; break;
					case "Customers": openEditDialog("cust",xItemID,"Edit Customer: "+xItemName); break;
				}
			},
			change: function( event, ui ) {
				$('#searchbox').val("");
				$("#searchdrop").toggle("fast");
			}
		});
	});
	</script>

                        </div>
						
                    </div>  
                </div>
            </header>
            
            <nav class="container">
                <select class="mobile-only row" onchange="window.open(this.options[this.selectedIndex].value,'_top')">
                    <?php echo $nDDNavCode; ?>
                </select>

                <ul class="sf-menu mobile-hide row clearfix">
					<?php echo $nNavCODE; ?>
<!--
<li class="active iconed">
	<a href="home.php"><span><img src="assets/images/header/icon_dashboard.png" /> Dashboard</span></a>
</li>
//-->
                </ul>
            </nav>


            <a class="trigger demo_4" href="javascript:;"><img src="assets/images/icons/color_swatch.png" alt="" width="32" height="32" border="0"></a>

            <div id="aurora_option" class="form panel">

                <div class="clearfix">
                    <label>Select Preset</label>
                    <div class="input">
                        <select id="preset" onchange="changePreset()">
                            <option value="#292929,#454545,#0774a7,header_blueprint.png,none">Default</option>
                            <option value="#16331f,#25781a,#216f47,11.png,none">Green Earth</option>
                            <option value="#4d1919,#702929,#662222,7.png,none">Royal Red</option>
                            <option value="#2d354d,#3b4966,#606060,2.png,brushed_alu.png">Ice Blue</option>
                            <option value="#29231b,#4d3d2c,#5e553d,header_blueprint.png,stucco.png">Chocolate Brown</option>
                            <option value="#291325,#322236,#382f38,2.png,diagonal-noise.png">King's Garment</option>
                        </select>
                    </div>
                </div>

                <span id="aurora_or">or <span>make your own!</span></span>

                <div class="clearfix">
                    <label>Header Color</label>
                    <div class="input">
                        <div id="in-header" class="picker"></div>
                    </div>
                </div>
                <div class="clearfix">
                    <label>Navigation Color</label>
                    <div class="input">
                        <div id="in-nav" class="picker"></div>
                    </div>
                </div>
                <div class="clearfix">
                    <label>Title Color</label>
                    <div class="input">
                        <div id="in-title" class="picker"></div>
                    </div>
                </div>
                <div class="clearfix">
                    <label>Title Pattern</label>
                    <div class="input">
                        <select id="titlepattern" onchange="changeTitlePattern()">
                            <option value="none">None</option>
                            <option value="header_blueprint.png">Blueprint</option>
                            <option value="1.png">Pattern 1</option>
                            <option value="2.png">Pattern 2</option>
                            <option value="3.png">Pattern 3</option>
                            <option value="4.png">Pattern 4</option>
                            <option value="5.png">Pattern 5</option>
                            <option value="6.png">Pattern 6</option>
                            <option value="7.png">Pattern 7</option>
                            <option value="8.png">Pattern 8</option>
                            <option value="9.png">Pattern 9</option>
                            <option value="10.png">Pattern 10</option>
                            <option value="11.png">Pattern 11</option>
                        </select>
                    </div>
                </div>
                <div class="clearfix">
                    <label>Background Pattern</label>
                    <div class="input">
                        <select id="backgroundpattern" onchange="changeBGPattern()">
                            <option value="none">None</option>
                            <option value="body_blueprint.png">Blueprint</option>
                            <option value="stucco.png">Stucco</option>
                            <option value="noise.png">Noise</option>
                            <option value="brushed_alu.png">Brushed Aluminium</option>
                            <option value="beige_paper.png">Beige Paper</option>
                            <option value="concrete_wall.png">Concrete Wall</option>
                            <option value="diagonal-noise.png">Diagonal Noise</option>
                            <option value="noisy.png">Noisy</option>
                        </select>
                    </div>
                </div>
            </div>
<?php
function nGetUserLinkFromName($nUserName){
	global $DBName,$Link;
	if(!$nUserName){ return; }
	$Query = "SELECT nID FROM nEditor WHERE nUser='$nUserName' LIMIT 1";
	mysql_select_db($DBName); $Result = mysql_query($Query,$Link);
	if($Row = mysql_fetch_array($Result)) {
		$nUserID = $Row["nID"];
	}
	if($nUserID){ $nUserLink = "user_modify.php?usr=$nUserID"; } else { $nUserLink = ""; }
	return $nUserLink;
}
?>