<!doctype html>

<!--[if IE 8]><html class="no-js oldie ie8 ie" lang="{$site->language}"><![endif]-->
<!--[if gte IE 9]><!--><html class="no-js" lang="{$site->language}"><!--<![endif]-->

	<head>
		<meta charset="{$site->charset}">
		{mobileDetectionScript}
		<meta name="Author" content="AitThemes.com, http://www.ait-themes.com">

		<title>{title}</title>
		<link rel="profile" href="http://gmpg.org/xfn/11">
		<link rel="pingback" href="{$site->pingbackUrl}">

		{if $themeOptions->fonts->fancyFont->type == 'google'}
		<link href="http://fonts.googleapis.com/css?family={$themeOptions->fonts->fancyFont->font}" rel="stylesheet" type="text/css">
		{/if}

		{head}

		<link id="ait-style" rel="stylesheet" type="text/css" media="all" href="{less}">

		<script>
		  'article aside footer header nav section time'.replace(/\w+/g,function(n){ document.createElement(n) })
		</script>

		<script type="text/javascript">
			jQuery(document).ready(function($) {
				var categories = [
				{foreach $categories as $cat}
					{ value: {$cat->term_id}, label: {$cat->name} }{if !($iterator->last)},{/if}
				{/foreach}
				];
				var locations = [
				{foreach $locations as $loc}
					{ value: {$loc->term_id}, label: {$loc->name} }{if !($iterator->last)},{/if}
				{/foreach}
				];
				var catInput = $( "#dir-searchinput-category" ),
					catInputID = $( "#dir-searchinput-category-id" ),
					locInput = $( "#dir-searchinput-location" ),
					locInputID = $( "#dir-searchinput-location-id" );

				if(catInput.length > 0) {
					catInput.autocomplete({
						minLength: 0,
						source: categories,
						focus: function( event, ui ) {
							catInput.val( ui.item.label.replace(/&amp;/g, "&") );
							return false;
						},
						select: function( event, ui ) {
							catInput.val( ui.item.label.replace(/&amp;/g, "&") );
							catInputID.val( ui.item.value );
							return false;
						}
					}).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
						return $( "<li>" )
							.data( "item.autocomplete", item )
							.append( "<a>" + item.label + "</a>" )
							.appendTo( ul );
					};
					var catList = catInput.autocomplete( "widget" );
					catList.niceScroll({ autohidemode: false });

					catInput.click(function(){
						catInput.val('');
						catInputID.val('0');
						catInput.autocomplete( "search", "" );
					});
				}

				if (locInput.length > 0) {
					locInput.autocomplete({
						minLength: 0,
						source: locations,
						focus: function( event, ui ) {
							locInput.val( ui.item.label.replace(/&amp;/g, "&") );
							return false;
						},
						select: function( event, ui ) {
							locInput.val( ui.item.label.replace(/&amp;/g, "&") );
							locInputID.val( ui.item.value );
							return false;
						},
						open: function(event, ui) {

						}
					}).data( "ui-autocomplete" )._renderItem = function( ul, item ) {
						return $( "<li>" )
							.data( "item.autocomplete", item )
							.append( "<a>" + item.label + "</a>" )
							.appendTo( ul );
					};
					var locList = locInput.autocomplete( "widget" );
					locList.niceScroll({ autohidemode: false });

					locInput.click(function(){
						locInput.val('');
						locInputID.val('0');
						locInput.autocomplete( "search", "" );
					});
				}

				{ifset $_GET['dir-search']}
				// fill inputs with search parameters
				$('#dir-searchinput-text').val({$searchTerm});
				catInputID.val({$_GET["categories"]});
				for(var i=0;i<categories.length;i++){
					if(categories[i].value == {$_GET["categories"]}) catInput.val(categories[i].label);
				}
				locInputID.val({$_GET["locations"]});
				for(var i=0;i<locations.length;i++){
					if(locations[i].value == {$_GET["locations"]}) locInput.val(locations[i].label);
				}
				{/ifset}

			});
			</script>

	</head>

	<body <?php if(isset($themeOptions->general->layoutStyle) && $themeOptions->general->layoutStyle == 'narrow') { body_class('ait-directory'); } else { body_class('ait-directory wide'); } ?> data-themeurl="{$themeUrl}">

		{ifset $themeOptions->advertising->showBox1}
			<div id="advertising-box-1" class="advertising-box">
				<div class="defaultContentWidth clearfix">
					<div>{!$themeOptions->advertising->box1Content}</div>
				 </div>
			</div>
		{/ifset}

		<div id="page" class="hfeed{if (isset($themeOptions->general->layoutStyle) && $themeOptions->general->layoutStyle == 'narrow')} narrow{else} wide{/if}" >
			
			{include 'snippets/branding-header.php'}			
			
			<div id="directory-main-bar-wrapper">
				<div id="directory-main-bar"{if $headerType == 'image'} style="background: url({$headerImage}) no-repeat center top; height: {!$headerImageSize[1]}px;"{/if} data-category="{$mapCategory}" data-location="{$mapLocation}" data-search="{$mapSearch}" data-geolocation="{ifset $isGeolocation}true{else}false{/ifset}">
				{if $headerType == 'slider'}
					{if function_exists('putRevSlider')}
						{? putRevSlider($headerSlider)}
					{/if}
				{/if}
				</div>

				{ifset $isDirSingle}

					{if isset($themeOptions->search->searchPosition) && isset($themeOptions->search->searchPosition) && $themeOptions->search->searchPosition == 'inMap'}
					{include 'snippets/tour-search.php'}
					{/if}

					{include 'snippets/map-single-javascript.php'}

				{else}
					{if $headerType == 'map'}
					
						{if isset($themeOptions->search->searchPosition) && isset($themeOptions->search->searchPosition) && $themeOptions->search->searchPosition == 'inMap'}
						{include 'snippets/tour-search.php'}
						{/if}

						{include 'snippets/map-javascript.php'}

					{/if}
				{/ifset}
			</div> <!-- #directory-main-bar-wrapper -->
