<?php
/**
 * @version    $Id$
 * @package    IT_Theme_Framework
 * @author     InnoThemes Team <support@innothemes.com>
 * @copyright  Copyright (C) 2012 InnoThemes.com. All Rights Reserved.
 * @license    GNU/GPL v2 or later http://www.gnu.org/licenses/gpl-2.0.html
 *
 * Websites: http://www.innothemes.com
 */

// Define assets to be loaded
$assets = array( 'jquery-js', 'it-theme-style-css', 'it-air-style-css' );
$inline = array( 'css' => '', 'js' => '' );

if ( 'advanced' == $it_options['responsive_menu_type'] ) {
	// Load advanced responsive menu script
	$assets[] = 'it-menu-advance-js';
}

if ( $it_options['sticky_header'] ) {
	// Load sticky menu script
	$assets[] = 'it-menu-sticky-js';

	// Add inline style declaration
	$inline['css'] .= '
		body.admin-bar .on-top {
			top: 32px;
		}
		.on-top {
			background: #fff;
			top: 0;
			position: fixed;
			z-index: 9999;
		}
		.it-layout-boxed #it-mainmenu.on-top {
			width: 958px;
		}
		.it-layout-fullwidth #it-mainmenu.on-top {
			width: 100%;
		}';
}

if ( $it_options['google_analytics_id'] ) {
	// Add inline Google Analytics tracking code
	$inline['js'] .= '
	var _gaq = _gaq || [];
	_gaq.push(["_setAccount", "' . $it_options['google_analytics_id'] . '"]);
	_gaq.push(["_trackPageview"]);
	(function() {
		var ga = document.createElement("script");
		ga.type = "text/javascript";
		ga.async = true;
		ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
		var s = document.getElementsByTagName("script")[0];
		s.parentNode.insertBefore(ga, s);
	})();';
}

if ( in_array( 'smartphone', $it_options['responsive_layout'] ) ) {
	// Load smartphone stylesheet
	$assets[] = 'it-theme-smartphone-css';
}

if ( in_array( 'tablet', $it_options['responsive_layout'] ) ) {
	// Load tablet stylesheet
	$assets[] = 'it-theme-tablet-css';
}

if ( in_array( 'narrow_desktop', $it_options['responsive_layout'] ) && in_array( 'wide_desktop', $it_options['responsive_layout'] ) ) {
	// Load desktop stylesheet
	$assets[] = 'it-theme-desktop-css';
}

if ( is_singular() && comments_open() ) {
	// Load comment reply script
	$assets[] = 'comment-reply-js';
}

// Load required assets
IT_Init_Assets::load( $assets );

foreach ( $inline as $type => $text ) {
	if ( ! empty( $text ) ) {
		IT_Init_Assets::inline( $type, $text );
	}
}
