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

$config = get_option( 'bowsxWpApn' );
global $__amazilonSearchindexes;
?>
    <script type="text/javascript">

        oAjaxRequest = false;
        jQuery(document).ready(function () {
            jQuery('#amazilon-tabcontent-generator-4 .apn[type="checkbox"]').each(function (index, value) {
                jQuery(this).change(loadPreview4);
            });
            jQuery('#amazilon-tabcontent-generator-4 select.apn').each(function (index, value) {
                jQuery(this).change(loadPreview4);
            });
            jQuery('#amazilon-tabcontent-generator-4 .apn[type="text"]').each(function (index, value) {
                jQuery(this).keyup(loadPreview4);
            });
            loadPreview4();

            jQuery('#amazilon-tabcontent-generator-4 .amazilon-search-button').click(function () {
                apnSearchCategories4();
                return false;
            });
            jQuery('#amazilon-tabcontent-generator-4 .amazilon-shorten-button').click(apnShorten4);
        });
        apnSearchCategories4 = function () {
            jQuery('#amazilon-tabcontent-generator-4 .amazilon-search-results').show();
            jQuery('#amazilon-tabcontent-generator-4 .amazilon-search-results-inner').html('<img src="<?php echo admin_url( 'images/spinner.gif' );  ?>">');
            var data = {
                'action': 'amazilonSearchCategories',
                'security': '<?php echo wp_create_nonce( 'amazilonCC' . date( 'Ym' ) ); ?>',
                'q': jQuery('#amazilon-tabcontent-generator-4 .amazilon-search').val(),
                'sIndex': jQuery('#amazilon-tabcontent-generator-4 .amazilon-search-sindex').val()
            };

            jQuery.post(ajaxurl, data, function (response) {
                jQuery('#amazilon-tabcontent-generator-4 .amazilon-search-results-inner').html(response);
                jQuery('#amazilon-tabcontent-generator-4 .amazilon-search-result-entry .browsenode').each(function (index, value) {
                    jQuery(this).click(apnSelectCategory4).click(function () {
                        return false;
                    });
                });
                jQuery('#amazilon-tabcontent-generator-4 .amazilon-search-results-inner').fadeIn();
            });
        }
        apnSelectCategory4 = function () {
            getBestsellersPathAjax4(jQuery(this).data('browsenodeid'));
            jQuery('#amazilon-tabcontent-generator-4 .selectedBrowseNodeId').val(jQuery(this).data('browsenodeid'));
            amazilonToTab4(0, 'category');
            loadPreview4();
        }
        amazilonIsertShortCode4 = function (sStr, fieldId) {
            if (fieldId === undefined) {
                fieldId = '_mce';
            }
            if (fieldId == '_mce') {
                window.parent.tinyMCE.activeEditor.execCommand('mceInsertContent', 0, sStr);
            } else if (fieldId == '_qtags') {
                window.parent.QTags.insertContent(sStr);
            } else {
                jQuery(window.parent.jQuery('#' + fieldId)).val(JSON.stringify(oAmazilonTag));
            }
            window.parent.tb_remove();
        }

        apnShorten4 = function () {
            var data = {
                'action': 'amazilonShorten',
                'security': '<?php echo wp_create_nonce( 'amazilonCC' . date( 'Ym' ) ); ?>',
                'scode': jQuery('#amazilon-tabcontent-generator-4 .apnAusgabe').val()
            };

            jQuery.post(ajaxurl, data, function (response) {
                var j = jQuery.parseJSON(response);
                if (j.status == 'ok') {
                    jQuery('#amazilon-tabcontent-generator-4 input.amazilon-shortened-input').val(j.data);
                    jQuery('#amazilon-tabcontent-generator-4 label.amazilon-shortened-label').show();
                } else {
                    alert(j.msg);
                }
            });
        }

        loadPreview4 = function (showPreview) {
            if (showPreview === undefined) {
                showPreview = false;
            }
            jQuery('#amazilon-tabcontent-generator-4 .amazilon-vorschaubox').html('<img src="<?php echo admin_url( 'images/spinner.gif' );  ?>">');
            var sNode = jQuery('#amazilon-tabcontent-generator-4 .selectedBrowseNodeId').val();
            var sTemplate = jQuery('#amazilon-tabcontent-generator-4 .template').val();
            var sTag = jQuery('#amazilon-tabcontent-generator-4 .tracking').val();
            var sTplLabel = jQuery('#amazilon-tabcontent-generator-4 .tpl-label').val();
            var sTplButtontext = jQuery('#amazilon-tabcontent-generator-4 .tpl-buttontext').val();
            var sTplButtonTpl = jQuery('#amazilon-tabcontent-generator-4 .tpl-buttontpl').val();
            var bSchatten = jQuery('#amazilon-tabcontent-generator-4 input.schatten').prop('checked');
            var bSavings = jQuery('#amazilon-tabcontent-generator-4 input.savings').prop('checked');
            var bPrime = jQuery('#amazilon-tabcontent-generator-4 input.prime').prop('checked');
            var bInfobox = jQuery('#amazilon-tabcontent-generator-4 input.infobox').prop('checked');
            var bHidelegend = jQuery('#amazilon-tabcontent-generator-4 input.hidelegend').prop('checked');
            var sTplHeaderlegend = jQuery('#amazilon-tabcontent-generator-4 .tpl-headerlegend').val();
            var sTplImagelegend = jQuery('#amazilon-tabcontent-generator-4 .tpl-imagelegend').val();
            var sTplProductlegend = jQuery('#amazilon-tabcontent-generator-4 .tpl-productlegend').val();
            var sTplPricelegend = jQuery('#amazilon-tabcontent-generator-4 .tpl-pricelegend').val();
            var sTplSavingslegend = jQuery('#amazilon-tabcontent-generator-4 .tpl-savingslegend').val();
            var sTplRatingslegend = jQuery('#amazilon-tabcontent-generator-4 .tpl-ratingslegend').val();
            var sTplPrimelegend = jQuery('#amazilon-tabcontent-generator-4 .tpl-primelegend').val();
            var sTplButtonlegend = jQuery('#amazilon-tabcontent-generator-4 .tpl-buttonlegend').val();
            var sTplStatelegend = jQuery('#amazilon-tabcontent-generator-4 .tpl-statelegend').val();
            var bStars = (jQuery('#amazilon-tabcontent-generator-4 input.stars') ? jQuery('#amazilon-tabcontent-generator-4 .stars').prop('checked') : false);
            var iMax = jQuery('#amazilon-tabcontent-generator-4 .max').val();

            if (sTemplate == 'vergleich') {
                jQuery('#amazilon-tabcontent-generator-4 .schattenl').hide();
                jQuery('#amazilon-tabcontent-generator-4 .savingsl').hide();
                jQuery('#amazilon-tabcontent-generator-4 .primel').hide();
                jQuery('#amazilon-tabcontent-generator-4 .hidelegendl').hide();
                jQuery('#amazilon-tabcontent-generator-4 .divergentlegend').hide();
                sTplHeaderlegend = '';
                sTplImagelegend = '';
                sTplProductlegend = '';
                sTplPricelegend = '';
                sTplSavingslegend = '';
                sTplRatingslegend = '';
                sTplPrimelegend = '';
                sTplButtonlegend = '';
                sTplStatelegend = '';
            } else if (sTemplate == 'vergleich2') {
                jQuery('#amazilon-tabcontent-generator-4 .schattenl').hide();
                jQuery('#amazilon-tabcontent-generator-4 .savingsl').show();
                jQuery('#amazilon-tabcontent-generator-4 .primel').show();
                jQuery('#amazilon-tabcontent-generator-4 .hidelegendl').show();
                jQuery('#amazilon-tabcontent-generator-4 .divergentlegend').show();
            } else {
                jQuery('#amazilon-tabcontent-generator-4 .schattenl').show();
                jQuery('#amazilon-tabcontent-generator-4 .savingsl').hide();
                jQuery('#amazilon-tabcontent-generator-4 .primel').hide();
                jQuery('#amazilon-tabcontent-generator-4 .hidelegendl').hide();
                jQuery('#amazilon-tabcontent-generator-4 .divergentlegend').hide();
                sTplHeaderlegend = '';
                sTplImagelegend = '';
                sTplProductlegend = '';
                sTplPricelegend = '';
                sTplSavingslegend = '';
                sTplRatingslegend = '';
                sTplPrimelegend = '';
                sTplButtonlegend = '';
                sTplStatelegend = '';
            }

            if (bHidelegend) {
                jQuery('#amazilon-tabcontent-generator-4 .divergentlegend input').attr('disabled', 'disabled');
                jQuery('#amazilon-tabcontent-generator-4 .divergentlegend').css('opacity', .5);
                sTplHeaderlegend = '';
                sTplImagelegend = '';
                sTplProductlegend = '';
                sTplPricelegend = '';
                sTplSavingslegend = '';
                sTplRatingslegend = '';
                sTplPrimelegend = '';
                sTplButtonlegend = '';
                sTplStatelegend = '';
            } else {
                jQuery('#amazilon-tabcontent-generator-4 .divergentlegend input').removeAttr('disabled');
                jQuery('#amazilon-tabcontent-generator-4 .divergentlegend').css('opacity', 1);
            }


            if (showPreview == true) {
                var data = {
                    'action': 'amazilonBestsellersPreview',
                    'security': '<?php echo wp_create_nonce( 'amazilonCC' . date( 'Ym' ) ); ?>',
                    'sTemplate': sTemplate + (sTemplate != 'vergleich' && sTemplate != 'vergleich2' && bSchatten ? 's' : ''),
                    'bInfobox': (bInfobox ? 1 : 0),
                    'bHidelegend': (bHidelegend ? 1 : ''),
                    'bStars': (bStars ? 1 : 0),
                    'sTplPrime': (bPrime ? 'false' : 'true'),
                    'sTplSavings': (bSavings ? 'false' : 'true'),
                    'sNode': sNode,
                    'iMax': iMax,
                    'sTag': sTag,
                    'sTplLabel': sTplLabel,
                    'sTplButtontext': sTplButtontext,
                    'sTplButtonTpl': sTplButtonTpl,
                    'sTplHeaderlegend': sTplHeaderlegend,
                    'sTplImagelegend': sTplImagelegend,
                    'sTplProductlegend': sTplProductlegend,
                    'sTplPricelegend': sTplPricelegend,
                    'sTplSavingslegend': sTplSavingslegend,
                    'sTplRatingslegend': sTplRatingslegend,
                    'sTplPrimelegend': sTplPrimelegend,
                    'sTplButtonlegend': sTplButtonlegend,
                    'sTplStatelegend': sTplStatelegend
                };
                if (oAjaxRequest !== false) {
                    oAjaxRequest.abort();
                }
                oAjaxRequest = jQuery.post(ajaxurl, data, function (response) {
                    jQuery('#amazilon-tabcontent-generator-4 .amazilon-vorschaubox').html(response);
                    jQuery('#amazilon-tabcontent-generator-4 .amazilon-tooltip').each(function (idx, el) {
                        jQuery(el).tooltip();
                    });
                });
                jQuery('#amazilon-tabcontent-generator-4 .amazilon-vorschau').show();
                jQuery('#amazilon-tabcontent-generator-4 .apnAusgabe').val('');
            } else {
                jQuery('#amazilon-tabcontent-generator-4 .amazilon-vorschau').hide();
            }

            sHtml = '[apn typ="bestsellers" node="' + sNode + '" template="' + sTemplate + (sTemplate != 'vergleich' && sTemplate != 'vergleich2' && bSchatten ? 's' : '') + '" max="' + iMax + '"';
            if (sTag.length > 0) {
                sHtml += ' tag="' + sTag + '"';
            }
            if (sTplLabel.length > 0) {
                sHtml += ' tpl-label="' + sTplLabel + '"';
            }
            if (sTplButtontext.length > 0) {
                sHtml += ' tpl-buttontext="' + sTplButtontext + '"';
            }
            if (sTplButtonTpl.length > 0 && !bHidelegend) {
                sHtml += ' tpl-buttontpl="' + sTplButtonTpl + '"';
            }
            if (sTplHeaderlegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-headerlegend="' + sTplHeaderlegend + '"';
            }
            if (sTplImagelegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-imagelegend="' + sTplImagelegend + '"';
            }
            if (sTplProductlegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-productlegend="' + sTplProductlegend + '"';
            }
            if (sTplPricelegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-pricelegend="' + sTplPricelegend + '"';
            }
            if (sTplSavingslegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-savingslegend="' + sTplSavingslegend + '"';
            }
            if (sTplRatingslegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-ratingslegend="' + sTplRatingslegend + '"';
            }
            if (sTplRatingslegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-ratingslegend="' + sTplRatingslegend + '"';
            }
            if (sTplPrimelegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-primelegend="' + sTplPrimelegend + '"';
            }
            if (sTplButtonlegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-buttonlegend="' + sTplButtonlegend + '"';
            }
            if (sTplStatelegend.length > 0 && !bHidelegend) {
                sHtml += ' tpl-statelegend="' + sTplStatelegend + '"';
            }
            sHtml += ' tpl-infobox="' + (bInfobox ? 1 : 0) + '"';
            sHtml += ' tpl-stars="' + (bStars ? 1 : 0) + '"';
            if (bPrime) {
                sHtml += ' tpl-prime="' + (bPrime ? 'false' : 'true') + '"';
            }
            if (sTemplate == 'vergleich2' && bHidelegend) {
                sHtml += ' tpl-hidelegend="1"';
            }
            if (bSavings) {
                sHtml += ' tpl-savings="' + (bSavings ? 'false' : 'true') + '"';
            }
            sHtml += ']';

            jQuery('#amazilon-tabcontent-generator-4 .apnAusgabe').val(sHtml + "\n");
            jQuery('#amazilon-tabcontent-generator-4 .apnInsert').show();
        }

        getBestsellersPathAjax4 = function (iBrowseNodeId) {
            var data = {
                'action': 'amazilonBestsellers',
                'security': '<?php echo wp_create_nonce( 'amazilonCC' . date( 'Ym' ) ); ?>',
                'BrowseNodeId': iBrowseNodeId
            };
            jQuery('#amazilon-tabcontent-generator-4 .bestsellersPathContainer').hide();

            jQuery.post(ajaxurl, data, function (response) {
                jQuery('#amazilon-tabcontent-generator-4 .ancestors').html('');
                jQuery('#amazilon-tabcontent-generator-4 .childs').html('');
                oResponse = jQuery.parseJSON(response);
                if (oResponse == false) {
                    jQuery('#amazilon-tabcontent-generator-4 .ancestors').html('<b style="color: #D00"><?php _e( 'Connection error',
						'amazilon' ); ?></b>');
                    jQuery('#amazilon-tabcontent-generator-4 .bestsellersPathContainer').show();
                    return;
                } else if (!oResponse.success) {
                    jQuery('#amazilon-tabcontent-generator-4 .ancestors').html('<b style="color: #D00">' + oResponse.msg + '</b>');
                    jQuery('#amazilon-tabcontent-generator-4 .bestsellersPathContainer').show();
                    return;
                }

                jQuery.each(oResponse.data.breadcrumb, function (idx, oEntry) {
                    sEntry = '&raquo;&nbsp;<a href="#" onclick="getBestsellersPathAjax4( ' + oEntry.id + ' ); jQuery( \'#amazilon-tabcontent-generator-4 .selectedBrowseNodeId\' ).val( \'' + oEntry.id + '\' ); loadPreview4(); return false;">' + oEntry.name + '</a> ';
                    jQuery('#amazilon-tabcontent-generator-4 .ancestors').append(sEntry);
                });

                if (oResponse.data.childs.length == 0) {
                    jQuery('#amazilon-tabcontent-generator-4 .childs').append('<?php _e( '- None -', 'amazilon' ); ?>');
                } else {
                    jQuery.each(oResponse.data.childs, function (idx, oChild) {
                        sEntry = '&raquo;&nbsp;<a href="#" onclick="getBestsellersPathAjax4( ' + oChild.id + ' ); jQuery( \'#amazilon-tabcontent-generator-4 .selectedBrowseNodeId\' ).val( \'' + oChild.id + '\' ); loadPreview4(); return false;">' + oChild.name + '</a><br />';
                        jQuery('#amazilon-tabcontent-generator-4 .childs').append(sEntry);
                    });
                }

                jQuery('#amazilon-tabcontent-generator-4 .bestsellersPathContainer').show();
            });
        }

        amazilonToTab4 = function (idx, activate) {
            jQuery('#amazilon-tabcontent-generator-4 .amazilon-tabs' + idx + ' .nav-tab.nav-tab-active').removeClass('nav-tab-active');
            jQuery('#amazilon-tabcontent-generator-4 .amazilon-tabs' + idx + ' .nav-tab.amazilon-' + activate + '-tab').addClass('nav-tab-active');

            jQuery('#amazilon-tabcontent-generator-4 .amazilon-tabcontent' + idx).each(function (idx) {
                if (jQuery(this).attr('name') == 'amazilon-' + activate + '-content') {
                    jQuery(this).show();
                } else {
                    jQuery(this).hide();
                }
            });
        }

    </script>

    <h1><?php _e( 'Bestsellers Shortcode generator', 'amazilon' ); ?> - <?php _e( 'Amazilon', 'amazilon' ); ?></h1>
    <div class="block">
		<p style="color: #F00;font-weight: bold;"><?php _e( 'This feature is currently deactivated by Amazons API-Systems. <a href="https://amazilon.com/faq/#Bestseller-Listen" target="_blank">More details</a>', 'amazilon' ); ?></p>
        <!--h2 class="nav-tab-wrapper">
            <p class="amazilon-tabs0">
                <a class="nav-tab nav-tab-active amazilon-category-tab" href="#"
                   onclick="amazilonToTab4(0, 'category'); return false;"><?php _e( 'Browse Categories',
						'amazilon' ); ?></a>
                <a class="nav-tab amazilon-product-tab" href="#"
                   onclick="amazilonToTab4(0, 'product'); return false;"><?php _e( 'Find by Product Search',
						'amazilon' ); ?></a>
            </p>
        </h2>
        <div class="amazilon-tabcontent0 amazilon-category-content" name="amazilon-category-content">
            <p><b><?php _e( 'Select Category', 'amazilon' ); ?></b><br/>
				<?php _e( 'Select a Category (Amazon calls them "BrowseNode") and select a template. You will receive a finished ShortCode. Mark, copy and insert the ShortCode into your article. ',
					'amazilon' ); ?></p>
            <p>
				<?php
				echo '<b>' . __( 'Main Category',
						'amazilon' ) . '</b><br /><select name="BrowseNodeId" onchange="getBestsellersPathAjax4( this.value ); jQuery(\'#amazilon-tabcontent-generator-4 .selectedBrowseNodeId\').val( this.value ); loadPreview4(); return false;"><option value="-1">- ' . __( 'Select one',
						'amazilon' ) . ' -';
				foreach ( $__amazilonSearchindexes['de'] AS $sKey => $aNode ) {
					if ( $aNode['id'] != - 1 ) {
						echo '<option value="' . $aNode['id'] . '">' . $aNode['title'] . '</option>';
					}
				}
				echo '</select></p>';

				echo '<div class="bestsellersPathContainer" style="display: none;">';
				echo '<p><b>' . __( 'Selected Category Path',
						'amazilon' ) . ':</b><br /><span class="ancestors"></span><br /></p>';
				echo '<p><b>' . __( 'Further Sub-Categories',
						'amazilon' ) . ':</b><br /><span class="childs"></span></p>';
				echo '</div>';
				?>
            </p>
        </div>
        <div class="amazilon-tabcontent0 amazilon-product-content" name="amazilon-product-content"
             style="display: none;">
            <p><b><?php _e( 'Search on Amazon', 'amazilon' ); ?></b><br/>
                <label for="amazilon-search" style="display: inline-block; width: 150px;"><?php _e( 'Searchterm',
						'amazilon' ); ?>: </label><input type="text" name="amazilon-search" class="amazilon-search"
                                                         value="" size="35" maxlength=""
                                                         style="width: 350px;"><br/><label for="sIndex"
                                                                                           style="width: 150px; display: inline-block;"><?php _e( 'Area',
						'amazilon' ); ?>: </label><select name="amazilon-search-sindex" class="amazilon-search-sindex"
                                                          style="width: 350px;"><?php
					$sIndexes = amazilonGetSearchindexes( 'de' );
					foreach ( $sIndexes AS $sIndex => $aEntry ) {
						echo '<option value="' . esc_attr( $sIndex ) . '">' . esc_attr( $aEntry['title'] ) . '</option>';
					}

					?></select><br/>
                <label style="display: inline-block; width: 150px;">&nbsp;</label><a
                        class="amazilon-search-button amazilon-button-3" href="#"
                        style="width: initial;"><?php _e( 'Search on Amazon', 'amazilon' ); ?></a></p>
            <div class="amazilon-search-results block" style="display: none; position: relative;"><a href="#"
                                                                                                     onclick="jQuery('#amazilon-tabcontent-generator-4 .amazilon-search-results').fadeOut();"><span
                            class="tb-close-icon"></span></a>
                <p><b><?php _e( 'Search results', 'amazilon' ); ?></b></p>
                <p><?php _e( 'Just click to select', 'amazilon' ); ?>:</p>
                <p class="amazilon-search-results-inner"></p></div>
        </div>
    </div>

    <div class="block">
        <p><?php _e( 'Use an alternate Tracking-ID (Alternate-21) ', 'amazilon' ); ?>: <input type="text"
                                                                                              class="apn tracking"
                                                                                              name="tracking" value=""
                                                                                              size="35" maxlength="">
        </p>
        <p><label for="max" class="maxl" name="maxl"><?php _e( 'Show the top', 'amazilon' ); ?> <select name="max"
                                                                                                        class="apn max"><?php
					for ( $i = 1; $i < 11; $i ++ ) {
						echo '<option value="' . (int) $i . '"';
						if ( $i == 3 ) {
							echo ' selected="selected"';
						}
						echo '>' . $i . '</option>';
					}
					?></select> <?php _e( 'Products', 'amazilon' ); ?></label></p>
        <p class="noma"><b><?php _e( 'Select a layout', 'amazilon' ); ?></b></p>
        <p><select name="template" class="apn template"
                   onchange="if ( this.value == 'vergleich' || this.value == 'vergleich2' ) { jQuery('#amazilon-tabcontent-generator-4 .schattenl').hide(); } else { jQuery('#amazilon-tabcontent-generator-4 .schattenl').show(); }">
                <option value="tpl-1"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '1' ); ?></option>
                <option value="tpl-2"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '2' ); ?>*</option>
                <option value="tpl-3"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '3' ); ?></option>
                <option value="tpl-4"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '4' ); ?></option>
                <option value="tpl-5"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '5' ); ?>*</option>
                <option value="tpl-6"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '6' ); ?>*</option>
                <option value="tpl-7"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '7' ); ?>*</option>
                <option value="vergleich"><?php _e( 'Comparison box', 'amazilon' ); ?>*</option>
                <option value="vergleich2"><?php _e( 'Comparison table', 'amazilon' ); ?>*</option>
            </select><br/>
            <small><?php echo __( 'Layouts with a star (*) expand to full width.', 'amazilon' ); ?></small>
            <br/>
            <label for="tpl-buttontpl" class="tpl-buttontpll" name="tpl-buttontpll"><span
                        style="display: inline-block; width: 10em;"><?php _e( 'Button Design', 'amazilon' ); ?>: </span><select
                        name="tpl-buttontpl" class="apn tpl-buttontpl">
                    <option value=""><?php echo sprintf( __( 'default Layout', 'amazilon' ), '1' ); ?></option>
                    <option value="0"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '1' ); ?></option>
                    <option value="1"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '2' ); ?></option>
                    <option value="2"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '3' ); ?></option>
                    <option value="3"><?php echo sprintf( __( 'Layout %s', 'amazilon' ), '4' ); ?></option>
                </select><br/></label>
            <label for="tpl-label" style="display: inline-block; width: 10em;"><?php _e( 'Label', 'amazilon' ); ?>
                : </label><input type="text" class="apn tpl-label" name="tpl-label" value=""
                                 placeholder="<?php _e( 'e.g. BESTSELLER', 'amazilon' ); ?>" size="35"
                                 maxlength=""><br/>
            <label for="tpl-buttontext" style="display: inline-block; width: 10em;"><?php _e( 'Button Label',
					'amazilon' ); ?>: </label><input type="text" class="apn tpl-buttontext" name="tpl-buttontext"
                                                     value="" placeholder="- automatisch -" size="35" maxlength=""><br/>
            <label for="schatten" class="schattenl" name="schattenl"><input type="checkbox" class="apn schatten"
                                                                            name="schatten" value="1">
                - <?php _e( 'Shows the layout with a shadow', 'amazilon' ); ?><br/></label>
            <label for="savings" class="savingsl" name="savingsl"><input type="checkbox" class="apn savings"
                                                                         name="savings" value="false">
                - <?php _e( 'Hide Savings', 'amazilon' ); ?><br/></label>
            <label for="prime" class="primel" name="primel"><input type="checkbox" class="apn prime" name="prime"
                                                                   value="false"> - <?php _e( 'Hide Prime status',
					'amazilon' ); ?><br/></label>
            <label for="hidelegend" class="hidelegendl" name="hidelegendl"><input type="checkbox" class="apn hidelegend"
                                                                                  name="hidelegend" value="1">
                - <?php _e( 'Hide legend', 'amazilon' ); ?><br/></label>
            <span class="divergentlegend" name="divergentlegend"><b><?php _e( 'Divergend legend labels:',
						'amazilon' ); ?></b><br/>
<label for="tpl-headerlegend" style="margin-left: 1em; display: inline-block; width: 10em;"><?php _e( 'Product',
		'amazilon' ); ?>: </label><input type="text" class="apn tpl-headerlegend" name="tpl-headerlegend" value=""
                                         placeholder="<?php echo esc_attr( __( 'Product', 'amazilon' ) ); ?>"><br/>
<label for="tpl-productlegend" style="margin-left: 1em; display: inline-block; width: 10em;"><small>(<?php _e( 'Header row',
			'amazilon' ); ?>)</small>: </label><input type="text" class="apn tpl-productlegend" name="tpl-productlegend"
                                                      value="" placeholder="<?php echo esc_attr( __( '- empty -',
					'amazilon' ) ); ?>"><br/>
<label for="tpl-imagelegend" style="margin-left: 1em; display: inline-block; width: 10em;"><small>(<?php _e( 'Image row',
			'amazilon' ); ?></small>: </label><input type="text" class="apn tpl-imagelegend" name="tpl-imagelegend"
                                                     value="" placeholder="<?php echo esc_attr( __( '- empty -',
					'amazilon' ) ); ?>"><br/>
<label for="tpl-pricelegend" style="margin-left: 1em; display: inline-block; width: 10em;"><?php _e( 'Price',
		'amazilon' ); ?>: </label><input type="text" class="apn tpl-pricelegend" name="tpl-pricelegend" value=""
                                         placeholder="<?php echo esc_attr( __( 'Price', 'amazilon' ) ); ?>"><br/>
<label for="tpl-savingslegend" style="margin-left: 1em; display: inline-block; width: 10em;"><?php _e( 'You save',
		'amazilon' ); ?>: </label><input type="text" class="apn tpl-savingslegend" name="tpl-savingslegend" value=""
                                         placeholder="<?php echo esc_attr( __( 'You save', 'amazilon' ) ); ?>"><br/>
<label for="tpl-ratingslegend"
       style="margin-left: 1em; display: inline-block; width: 10em;"><?php _e( 'Customers Rating',
		'amazilon' ); ?>: </label><input type="text" class="apn tpl-ratingslegend" name="tpl-ratingslegend" value=""
                                         placeholder="<?php echo esc_attr( __( 'Customers Rating',
	                                         'amazilon' ) ); ?>"><br/>
<label for="tpl-primelegend" style="margin-left: 1em; display: inline-block; width: 10em;"><?php _e( 'Shipping',
		'amazilon' ); ?>: </label><input type="text" class="apn tpl-primelegend" name="tpl-primelegend" value=""
                                         placeholder="<?php echo esc_attr( __( 'Shipping', 'amazilon' ) ); ?>"><br/>
<label for="tpl-buttonlegend" style="margin-left: 1em; display: inline-block; width: 10em;"><?php _e( 'Trader',
		'amazilon' ); ?>: </label><input type="text" class="apn tpl-buttonlegend" name="tpl-buttonlegend" value=""
                                         placeholder="<?php echo esc_attr( __( 'Trader', 'amazilon' ) ); ?>"><br/>
<label for="tpl-statelegend" style="margin-left: 1em; display: inline-block; width: 10em;"><?php _e( 'State',
		'amazilon' ); ?>: </label><input type="text" class="apn tpl-statelegend" name="tpl-statelegend" value=""
                                         placeholder="<?php echo esc_attr( __( 'State', 'amazilon' ) ); ?>"><br/>
</span>
            <label for="infobox"><input type="checkbox" class="apn infobox" name="infobox" value="1">
                - <?php _e( 'Display the infobox', 'amazilon' ); ?>
            </label><?php if ( isset( $config['bRetrieveStars'] ) && (int) $config['bRetrieveStars'] == 1 ) {
				echo '<br /><label for="stars"><input type="checkbox" class="apn stars" name="stars" value="1"> - ' . __( 'Show Reviews',
						'amazilon' ) . '</label>';
			}
			?>
            <input type="hidden" name="selectedBrowseNodeId" class="selectedBrowseNodeId" value=""/>
        </p>
        <p><input type="button" value="<?php _e( 'load Preview', 'amazilon' ); ?>"
                  onclick="loadPreview4(true); return false;"/><br/>
            <small><?php _e( 'Watch out: If you load too many products in a short period, Amazon Webservices may block your requests for a short time and preview may not load all resulting products!',
					'amazilon' ); ?></small>
        </p>
        <div class="amazilon-vorschau" style="display: none;"><p><b><?php _e( 'Preview', 'amazilon' ); ?>:</b><br
                        style="clear: both;"/><span class="amazilon-vorschaubox"></span></p></div>
        <br style="clear: both;"/>
    </div>
<?php
if ( isset( $_GET['fieldId'] ) && ! empty( $_GET['fieldId'] ) ) {
	?>
    <textarea name="apnAusgabe" class="apnAusgabe" cols="104" rows="10" style="display: none;"></textarea>
    <input name="apnInsert" class="apnInsert" style="display: none;" type="button"
           value="<?php _e( 'Insert the template', 'amazilon' ); ?>"
           onclick="amazilonIsertShortCode4(jQuery('#amazilon-tabcontent-generator-4 .apnAusgabe').val(),'<?php echo esc_attr( $_GET['fieldId'] ); ?>');"/>
	<?php
} else {
	?>
    <h2><?php _e( 'Copy the ShortCode and insert wherever needed.', 'amazilon' ); ?></h2>
    <p style="position: relative; max-width: 50em;">
        <label style="display: none;" class="amazilon-shortened-label"><?php _e( 'Shortened', 'amazilon' ); ?>: <input
                    type="text" class="amazilon-shortened-input" style="width: 10em;" value=""/>
            <button class="amazilon-copy-button button button-primary button-clipboard"
                    data-clipboard-target="#amazilon-tabcontent-generator-4 .amazilon-shortened-input"><span
                        class="dashicons dashicons-clipboard"
                        style="margin-top: .2em;"></span> <?php _e( 'Copy to clipboard', 'amazilon' ); ?></button>
        </label>
        <span style="position: absolute; bottom: 2em; right: 1.5em; margin-right: 5%;">
    	<button class="button button-primary button-clipboard"
                data-clipboard-target="#amazilon-tabcontent-generator-4 .apnAusgabe"><span
                    class="dashicons dashicons-clipboard"
                    style="margin-top: .2em;"></span> <?php _e( 'Copy to clipboard', 'amazilon' ); ?></button>
    </span>
        <textarea class="apnAusgabe" rows="15" style="width: 95%;" spellcheck="false"></textarea>
    </p>
	<?php
}
?>
-->