<?php

/**
 *
 * Default view
 *
 * @version             1.0.0
 * @package             Gavern Framework
 * @copyright			Copyright (C) 2010 - 2011 GavickPro. All rights reserved.
 *               
 */
 
// No direct access.
defined('_JEXEC') or die;
//
$app = JFactory::getApplication();
$menu = $app->getMenu();
$user = JFactory::getUser();
// getting User ID
$userID = $user->get('id');
// getting params
$option = JRequest::getCmd('option', '');
$view = JRequest::getCmd('view', '');
// defines if com_users
define('GK_COM_USERS', $option == 'com_users' && ($view == 'login' || $view == 'registration'));
// other variables
$btn_login_text = ($userID == 0) ? JText::_('TPL_GK_LANG_LOGIN') : JText::_('TPL_GK_LANG_LOGOUT');
// make sure that the modal will be loaded
JHTML::_('behavior.modal');
//
$page_suffix_output .= $this->page_suffix;
$page_suffix_table = explode(' ', $page_suffix_output);
$tpl_page_suffix = $page_suffix_output != '' ? ' class="'.$page_suffix_output.'" ' : '';
$logo_image = $this->API->get('logo_image', '');
$logo_gravatar = $this->API->get('logo_gravatar', '');
$logo_two_lines = $this->API->get('logo_two_lines', '0');
$logo_indent = $this->API->get('logo_indent', '74');
$logo_text = $this->API->get('logo_text', '');

?>
<!DOCTYPE html>
<html lang="<?php echo $this->APITPL->language; ?>">
<head>
	<?php $this->layout->addTouchIcon(); ?>
	<?php if(
			$this->browser->get('browser') == 'ie6' || 
			$this->browser->get('browser') == 'ie7' || 
			$this->browser->get('browser') == 'ie8' || 
			$this->browser->get('browser') == 'ie9'
		) : ?>
	<meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" />
	
	<?php endif; ?>
    <?php if($this->API->get('rwd', 1)) : ?>
    	<meta name="viewport" content="initial-scale = 1.0, user-scalable = no">
	<?php else : ?>
		<meta name="viewport" content="width=<?php echo $this->API->get('template_width', 1020)+80; ?>">
	<?php endif; ?>
    <jdoc:include type="head" />
    <?php $this->layout->loadBlock('head'); ?>
	<?php $this->layout->loadBlock('cookielaw'); ?>
</head>
<body<?php echo $tpl_page_suffix; ?><?php if($this->browser->get("tablet") == true) echo ' data-tablet="true"'; ?><?php if($this->browser->get("mobile") == true) echo ' data-mobile="true"'; ?><?php $this->layout->generateLayoutWidths(); ?>>	
	<?php
	     // put Google Analytics code
	     echo $this->social->googleAnalyticsParser();
	?>
	
	<?php if ($this->browser->get('browser') == 'ie8' || $this->browser->get('browser') == 'ie7' || $this->browser->get('browser') == 'ie6') : ?>
	<!--[if lte IE 8]>
	<div id="ie-toolbar"><div><?php echo JText::_('TPL_GK_LANG_IE_TOOLBAR'); ?></div></div>
	<![endif]-->
	<?php endif; ?>

	<div id="gk-bg" class="gk-clearfix">
	    <div id="gk-bg-wrap">
			<div id="gk-content">
				<?php if(count($app->getMessageQueue())) : ?>
				<jdoc:include type="message" />
				<?php endif; ?>
				
				<?php if($this->API->modules('top')) : ?>
				<section id="gk-top"<?php if($this->API->modules('top') > 1) : ?> class="gk-cols3"<?php endif; ?>>
					<div <?php if(isset($this->module_ids['top'])) echo ' id="'.$this->module_ids['top'].'"'; ?>>
						<jdoc:include type="modules" name="top" style="gk_style" modnum="<?php echo $this->API->modules('top'); ?>" />
					</div>
				</section>
				<?php endif; ?>
				
				<section id="gk-mainbody">
					<div<?php if(isset($this->module_ids['mainbody'])) echo ' id="'.$this->module_ids['mainbody'].'"'; ?>>
					<?php if(!$this->API->modules('mainbody')) : ?>
						<jdoc:include type="component" />
					<?php else : ?>
						<jdoc:include type="modules" name="mainbody" style="gk_style" />
					<?php endif; ?>
					</div>
				</section>
				
				<?php if($this->API->modules('bottom')) : ?>
				<section id="gk-bottom"<?php if($this->API->modules('bottom') > 1) : ?> class="gkCols3 gkPage"<?php endif; ?>>
					<div <?php if(isset($this->module_ids['bottom'])) echo ' id="'.$this->module_ids['bottom'].'"'; ?>>
						<jdoc:include type="modules" name="bottom" style="gk_style" modnum="<?php echo $this->API->modules('bottom'); ?>" />
					</div>
				</section>
				<?php endif; ?>
			</div>
			
			<?php if(!in_array('no-sidebar', $page_suffix_table)) : ?>
			<div id="gk-right"<?php if(
				$this->API->modules('social') ||
				$this->API->modules('search') ||
				$this->API->modules('login')
			) : ?> class="has-top-area"<?php endif; ?>>
				<?php if(
					$this->API->modules('social') ||
					$this->API->modules('search') ||
					$this->API->modules('login')
				) : ?>
				<div id="gk-right-top">				
					<?php if($this->API->modules('login')) : ?>
					<a href="<?php echo $this->API->get('login_url', 'index.php?option=com_users&view=login'); ?>" id="gk-login-btn" class="gk-icon-user"><?php echo ($userID == 0) ? JText::_('TPL_GK_LANG_LOGIN') : JText::_('TPL_GK_LANG_MY_ACCOUNT'); ?></a>
					<?php endif; ?>	
					
					<?php if($this->API->modules('search')) : ?>
					<div id="gk-search">
						<jdoc:include type="modules" name="search" style="none" />
					</div>
					<?php endif; ?>	
					
					<?php if($this->API->modules('social')) : ?>
					<div id="gk-social">
						<jdoc:include type="modules" name="social" style="none" />
					</div>
					<?php endif; ?>	
				</div>
				<?php endif; ?>
				
				<?php if($this->API->modules('breadcrumb')) : ?>
				<div id="gk-breadcrumb">
					<jdoc:include type="modules" name="breadcrumb" style="none" />
				</div>
				<?php endif; ?>
				
				<?php if($this->API->modules('sidebar')) : ?>
				<aside id="gk-sidebar">
					<div>
						<jdoc:include type="modules" name="sidebar" style="gk_style" />
					</div>
				</aside>
				<?php endif; ?>
				
				<?php if($this->API->modules('footer_nav')) : ?>
				<footer id="gk-footer">
					<div id="gk-footer-nav">
						<jdoc:include type="modules" name="footer_nav" style="none" />
					</div>
				</footer>
				<?php endif; ?>
			    
			    <?php $this->layout->loadBlock('tools/login'); ?>
		    </div>
		    <?php endif; ?>
		</div>
    </div>
    
    <?php $this->layout->loadBlock('social'); ?>
   	
   	<nav id="aside-menu">
   		<div id="gk-header">
   		    <?php if($logo_image != '') : ?>
   		    <a href="<?php echo JURI::root(); ?>" id="gk-logo">
   		    	<img src="<?php echo $logo_image; ?>" alt="<?php echo JText::_('TPL_GK_LANG_HOMEPAGE'); ?>" />
   		    </a>
   		    <?php endif; ?>
   		    
   		    <?php if($logo_image == '' && $logo_gravatar != '') : ?>
   		    <a href="<?php echo JURI::root(); ?>" id="gk-logo">
   		    	<img src="//www.gravatar.com/avatar/<?php echo md5(strtolower(trim($logo_gravatar))); ?>.jpg?s=120";" alt="<?php echo JText::_('TPL_GK_LANG_HOMEPAGE'); ?>" />
   		    </a>
   		    <?php endif; ?>
   			
   			<?php if($logo_text != '') : ?>
   			<a href="<?php echo JURI::root(); ?>" class="inverse<?php if($logo_two_lines == '1') echo ' two-lines'; ?>" id="gk-logo-text" ><span style="margin-left: -<?php echo $logo_indent; ?>px;"><?php echo str_replace('[br]', '<br />', $this->API->get('logo_text', '')); ?></span></a>
   			<?php endif; ?>
   			
   			<span id="gk-menu-button"><span><?php echo JText::_('TPL_GK_LANG_OPEN_MENU'); ?></span></span>
   			
   			<?php if(!in_array('no-sidebar', $page_suffix_table)) : ?>   
   			   	<?php if($this->API->modules('social') || $this->API->modules('search') || $this->API->modules('login')) : ?>
   			   	<a href="#gk-right" id="gk-right-helper" class="inverse" title="<?php echo JText::_('TPL_GK_LANG_SHOW_SIDEBAR'); ?>"><i class="gk-icon-sidebar-solid"></i></a>
   			   	<?php endif; ?>
   			<?php endif; ?>
   		</div>
   		
   		<div class="overthrow">
   			<?php if($this->API->modules('menu_top')) : ?>
   			<div id="gk-menu-top">
   			     <jdoc:include type="modules" name="menu_top" style="gk_style" />
   			</div>
   			<?php endif; ?>
   			
   			<?php
   				$this->asidemenu->loadMenu($this->API->get('menu_name','mainmenu')); 
   				$this->asidemenu->genMenu($this->API->get('startlevel', 0), $this->API->get('endlevel',-1));
   			?>
   			
   			<?php if($this->API->modules('menu_bottom')) : ?>
   			<div id="gk-menu-bottom">
   			     <jdoc:include type="modules" name="menu_bottom" style="gk_style" />
   			</div>
   			<?php endif; ?>
   			
   			<?php if($this->API->modules('copyrigths')) : ?>
   			<div id="gk-copyrights">
   				<jdoc:include type="modules" name="copyrigths" style="none" />
   			</div>
   			<?php endif; ?>
   			
   			<?php if($this->API->modules('lang')) : ?>
   			<div id="gk-lang">
   				<jdoc:include type="modules" name="lang" style="gk_style" />
   			</div>
   			<?php endif; ?>
   			
   			<?php if(
   				$this->API->modules('copyrigths') &&
   				$this->API->get('stylearea', '0') == '1'
   			) : ?>
   			<div id="gk-style-area">
   				<a href="#" id="gk-color1"><?php echo JText::_('TPL_GK_LANG_COLOR_1'); ?></a>
   				<a href="#" id="gk-color2"><?php echo JText::_('TPL_GK_LANG_COLOR_2'); ?></a> 
   				<a href="#" id="gk-color3"><?php echo JText::_('TPL_GK_LANG_COLOR_3'); ?></a>
   			</div>
   			<?php endif; ?>
   			
   			<?php if(
   				$this->API->modules('copyrigths') &&
   				$this->API->get('framework_logo', '0') == '1'
   			) : ?>
   			<a href="//gavick.com" id="gk-framework-logo" title="Gavern Framework">Gavern Framework</a>
   			<?php endif; ?>
   		</div>
   	</nav>	
   	
    <?php if(!in_array('no-sidebar', $page_suffix_table)) : ?>   
	   	<?php if($this->API->modules('social') || $this->API->modules('search') || $this->API->modules('login')) : ?>
	   	<div id="gk-right-top-bg"></div>
	   	<?php endif; ?>
   	<?php endif; ?>
   		
	<script>
		if(window.getSize().x > 600) {
			document.getElements('.gkNspPM-GridNews figure').each(function(item, i) {
				if(item.hasClass('inverse')) {
					item.setProperty('data-scroll-reveal', 'enter right over .5s and wait '+(i * 0.25)+'s');
				} else {
					item.setProperty('data-scroll-reveal', 'enter left over .5s and wait '+(i * 0.25)+'s');
				}
			});
			
			window.scrollReveal = new scrollReveal();
		}
		
		jQuery(document).ready(function(){
		    // Target your .container, .wrapper, .post, etc.
		    jQuery("#gk-bg").fitVids();
		});
	</script>
	
	<jdoc:include type="modules" name="debug" />
</body>
</html>