<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
	<div class="container">
    	<div class="navbar-header">
			<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
				<span class="sr-only">Toggle navigation</span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
				<span class="icon-bar"></span>
			</button>
      		<div class="visible-xs">
				<form id="searchForm" method="get" action="$url.search" class="form-inline" onsubmit="return validateSearch(this)">
					<input type="text" class="form-control input-sm" id="q" name="q" maxlength="255" placeholder="Search..." value="">
					<button type="submit" id="search-btn" class="btn"><i class="icon-search"></i></button>
			  	</form>
      		</div>
    	</div>

		<!-- Collect the nav links, forms, and other content for toggling -->
		<div class="collapse navbar-collapse navbar-ex1-collapse">
			<ul class="nav navbar-nav">
				<li><a href="$url.home">Home</a></li>
				#set($cats = $model.weblog.getWeblogCategories())
				#if ($cats.size() > 1)
				    <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">Categories <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            #if ($model.weblogCategory || $model.permalink)
                                <li><a href="$url.home">$text.get("generic.all")</a></li>
                            #else
                                <li class="selected"><a href="$url.home">$text.get("generic.all")</a></li>
                            #end
                            #foreach($cat in $cats)
                                #if ($model.weblogCategory && $model.weblogCategory.name == $cat.name || ($model.permalink && $model.weblogEntry.category.name == $cat.name))
                                    <li class="selected"><a href="$url.category($cat.name)">$cat.name</a></li>
                                #else
                                    <li><a href="$url.category($cat.name)">$cat.name</a></li>
                                #end
                            #end
                        </ul>
                    </li>
                #end
				#foreach($iPage in $weblog.pages)
				    #if (!$iPage.hidden && $iPage.navbar && $iPage.link != "Weblog")
				        #set($isSelected = false)
				        #if ($model.weblogPage && $iPage.Id == $model.weblogPage.Id) #set($isSelected = true) #end
				        #if (!$isSelected)
				            <li><a href="$url.page($iPage.link)">$iPage.name</a></li>
				        #else
				            <li class="active"><a href="$url.page($iPage.link)">$iPage.name</a></li>
				        #end
				    #end
				#end
				#if ($utils.isUserAuthorizedToAuthor($weblog))
				    <li>
				       <a href="$url.createEntry">$text.get("navigationBar.newEntry")</a>
				    </li>
				    #if($utils.isUserAuthorizedToAdmin($weblog))
				       <li>
				           <a href="$url.editSettings">$text.get("navigationBar.settings")</a>
				       </li>
				    #end
				        <li>
				            <a href="$url.logout">$text.get("navigationBar.logout")</a>
				        </li>
				#else
				    #if ($utils.isUserAuthenticated())
				        <li>
				            <a href="$url.logout">$text.get("navigationBar.logout")</a>
				        </li>
				    #else
				        <li>
				            <a href="$url.login">$text.get("navigationBar.login")</a>
				        </li>
				    #end
				#end
			</ul>
			<ul class="nav navbar-nav navbar-right hidden-xs">
				<li>
					<form id="searchForm" method="get" action="$url.search" class="form-inline" onsubmit="return validateSearch(this)">
						<input type="text" class="form-control input-sm" id="q" name="q" maxlength="255" placeholder="Search..." value="">	  		   <button type="submit" id="search-btn" class="btn"><i class="icon-search"></i></button>
					</form>
					<script>
				    	function validateSearch(form) {
				            if (form.q.value == "") {
				                alert("$text.get("macro.weblog.searchalert")");
				                form.q.focus();
				                return false;
				            }
				            return true;
				        }
				    </script>
				</li>
			</ul>
    	</div><!-- /.navbar-collapse -->
	</div><!-- /.container -->
</nav>


