<?php 
defined('ABSPATH') or die('I Don\'t allow You');

if(!defined("ajax_call")){
	
?>
				</content>
			</div>
		</div>
		<div class="content_loader"  style="display: none;">
			<div class="coloured-madness-cast">
				<div class="container">
					<div class="spacer-85"></div>
					<div class="cast-container">
						<div class="cast-tabs row">
							<h3 align="center"><?=__('Loading the page..... please Wait',tdomain)?></h3>
						</div>
					</div>
					<div class="cast-container">
						<div class="cast-tabs row">
							<div class="spinner">
							  <div class="rect1"></div>
							  <div class="rect2"></div>
							  <div class="rect3"></div>
							  <div class="rect4"></div>
							  <div class="rect5"></div>
							</div>	
						</div>
					</div>
				</div>
			</div>
		</div>
		<script>
		jQuery(document).ready(function($){
			$('body').on('click', '#the_real_deal a[data-action="ajax"], header a[mainimg], a[homebutton]', function(e){
			//$('#the_real_deal a[data-action="ajax"], header a[mainimg], a[homebutton]').live('click',function(e){
				e.preventDefault();
				$('content').parent().slideUp();
				$('.content_loader').slideDown();
				var t=$(this);
				$('#the_real_deal li.current-menu-item').removeClass('current-menu-item');
				if(t.attr('mainimg')==='1'){
					$('#the_real_deal a[data-action="ajax"][href=""]').parent().addClass('current-menu-item');
				}else{
					if (typeof t.attr('homebutton') !== typeof undefined && t.attr('homebutton') !== false) {
						$('#the_real_deal a[data-action="ajax"][href="'+t.attr('homebutton')+'"]').parent().addClass('current-menu-item');
					}else{
						t.parent().addClass('current-menu-item');
					}
				}
				$.ajax({
					data:{
						'nonce':'<?=wp_create_nonce("load_madness");?>',
						'type':'page',
						'value':t.attr('href'),
						'curl':window.location.href,
						'action':'load_madness'
						},
					url:'<?=site_url();?>/wp-admin/admin-ajax.php',
					success:function(r){
						var e=JSON.parse(r);
						console.log(e);
						window.history.pushState({"html":e.h,"pageTitle":''},"", e.curl);
						$('content').html(e.h);
						$('title').html(e.t);
						$('content').parent().slideDown();
						$('.content_loader').slideUp();
					}
				});
			});
		});
		</script>
		<footer class="footer_madness">
			<div class="container">
				<div class="row">
					<div class="col-xs-12 col-md-6">
						Copyright &copy; Tiago Dias
					</div>
					<div class="col-xs-12 col-md-6" align="right">
						<?=__('All Rights Reserved','portfolio_madness');?>
					</div>
				</div>
			</div>
		</footer>
		<?php wp_footer();?>
		<?php styles_as_script_load(true);?>
		<?php scripts_as_ajax_load(true);?>
	</body>
</head>
<?php
}
?>