<?php

if ( ! defined( 'ABSPATH' ) ) {
	exit;
} // Exit if accessed directly

?>
<style type="text/css">
    .nav-tabcontent-active {
        display: block;
    }

    .nav-tabcontent-inactive {
        display: none;
    }
</style>
<script type="text/javascript">
    jQuery(document).ready(function () {
        var sHash = window.location.hash.substr(1);
		<?php
		if ( isset( $_GET['jumpTo'] ) && ! empty( $_GET['jumpTo'] ) ) {
			echo '	sHash = "' . urlencode( $_GET['jumpTo'] ) . '";' . "\n";
		}
		?>
        if (sHash != '') {
            amazilonToTab(sHash);
        }
    });

    amazilonToTab = function (activate) {
        jQuery('.amazilon-tabs .nav-tab-active').removeClass('nav-tab-active');
        jQuery('.amazilon-tabs #amazilon-tab-' + activate).addClass('nav-tab-active').blur();

        jQuery('.amazilon-tabcontent.nav-tabcontent-active').removeClass('nav-tabcontent-active').addClass('nav-tabcontent-inactive');
        jQuery('.amazilon-tabcontent#amazilon-tabcontent-' + activate).addClass('nav-tabcontent-active').removeClass('nav-tabcontent-inactive');

        window.location.hash = '#' + activate;
        return false;
    }
</script>
<div class="block">
    <h2 class="nav-tab-wrapper">
        <p class="amazilon-tabs">
            <a class="nav-tab nav-tab-active" id="amazilon-tab-generator-3" href="#generator-3"
               onclick="return amazilonToTab('generator-3');"><span
                        class="dashicons dashicons-format-aside"></span> <?php _e( 'Templates', 'amazilon' ); ?></a>
			<?php if ( ! isset( $_GET['fieldId'] ) || substr( $_GET['fieldId'], 0, 6 ) != 'widget' ) { ?>
                <a class="nav-tab" id="amazilon-tab-generator-2" href="#generator-2"
                   onclick="return amazilonToTab('generator-2');"><span
                            class="dashicons dashicons-format-gallery"></span> <?php _e( 'Buttons', 'amazilon' ); ?></a>
                <a class="nav-tab" id="amazilon-tab-generator-1" href="#generator-1"
                   onclick="return amazilonToTab('generator-1');"><span
                            class="dashicons dashicons-admin-settings"></span> <?php _e( 'ShortCodes', 'amazilon' ); ?>
                </a>
                <a class="nav-tab" id="amazilon-tab-generator-4" href="#generator-4"
                   onclick="return amazilonToTab('generator-4');"><span
                            class="dashicons dashicons-chart-area"></span> <?php _e( 'Bestsellers', 'amazilon' ); ?></a>
			<?php } ?>
        </p>
    </h2>
    <div class="amazilon-tabcontent nav-tabcontent-active"
         id="amazilon-tabcontent-generator-3"><?php require dirname( __FILE__ ) . '/../generator3.php'; ?></div>
	<?php if ( ! isset( $_GET['fieldId'] ) || substr( $_GET['fieldId'], 0, 6 ) != 'widget' ) { ?>
        <div class="amazilon-tabcontent nav-tabcontent-inactive"
             id="amazilon-tabcontent-generator-2"><?php require dirname( __FILE__ ) . '/../generator2.php'; ?></div>
        <div class="amazilon-tabcontent nav-tabcontent-inactive"
             id="amazilon-tabcontent-generator-1"><?php require dirname( __FILE__ ) . '/../generator.php'; ?></div>
        <div class="amazilon-tabcontent nav-tabcontent-inactive"
             id="amazilon-tabcontent-generator-4"><?php require dirname( __FILE__ ) . '/../generator4.php'; ?></div>
	<?php } ?>
</div>
