<div class="container-fluid">
    <div>
        <h3>Manage Website Ads</h3>
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item">
                    <a href="#">Home</a>
                </li>
                <li class="breadcrumb-item">
                    <a href="#">Advertisements</a>
                </li>
                <li class="breadcrumb-item active" aria-current="page">Manage Website Ads</li>
            </ol>
        </nav>
    </div>
    <!-- Vertical Layout -->
    <div class="row">
        <div class="col-lg-12 col-md-12">
            <div class="card">
                <div class="card-body">
                    <h6 class="card-title">Manage Website Ads</h6>
                    <div class="ads-settings-alert"></div>
                    <form class="ads-settings" method="POST">
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Header </label>
                                <textarea name="header" id="header" class="form-control" cols="30" rows="5"><?php echo GetAd('header', true);?></textarea>
								<small class="admin-info">Appears on all pages right under the nav bar (HTML Allowed)</small>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Footer </label>
                                <textarea name="footer" id="footer" class="form-control" cols="30" rows="5"><?php echo GetAd('footer', true);?></textarea>
								<small class="admin-info">Appears on all pages right before the footer (HTML Allowed)</small>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Home Sidebar </label>
                                <textarea name="home_side_bar" id="home_side_bar" class="form-control" cols="30" rows="5"><?php echo GetAd('home_side_bar', true);?></textarea>
								<small class="admin-info">Appears home page under side bar (HTML Allowed)</small>
                            </div>
                        </div>
                        <div class="form-group form-float">
                            <div class="form-line">
                                <label class="form-label">Profile Sidebar </label>
                                <textarea name="profile_side_bar" id="profile_side_bar" class="form-control" cols="30" rows="5"><?php echo GetAd('profile_side_bar', true);?></textarea>
                                <small class="admin-info">Appears on profile page under side bar (HTML Allowed)</small>
                            </div>
                        </div>
                        <input type="hidden" name="hash_id" value="<?php echo Wo_CreateSession();?>">
                        <button type="submit" class="btn btn-primary m-t-15 waves-effect">Save</button>
                    </form>
                </div>
            </div>
        </div>
        <div class="clearfix"></div>
    </div>
    <!-- #END# Vertical Layout -->
<script>
$(function() {
    var form_ads_settings = $('form.ads-settings');
    form_ads_settings.ajaxForm({
        url: Wo_Ajax_Requests_File() + '?f=update-ads&p=manage-website-ads',
        beforeSend: function() {
            form_ads_settings.find('.waves-effect').text('Please wait..');
        },
        beforeSubmit : function(arr, $form, options){
            for (var i = 0; i < arr.length; i++) {
                if (arr[i].name == "header") {
                    arr[i].value = btoa(unescape(encodeURIComponent($('#header').val())));
                }
                if (arr[i].name == 'footer') {
                    arr[i].value = btoa(unescape(encodeURIComponent($('#footer').val())));
                }
                if (arr[i].name == 'home_side_bar') {
                    arr[i].value = btoa(unescape(encodeURIComponent($('#home_side_bar').val())));
                }
                if (arr[i].name == 'profile_side_bar') {
                    arr[i].value = btoa(unescape(encodeURIComponent($('#profile_side_bar').val())));
                }
            }
          // delete arr[0];
          // delete arr[1];
          // delete arr[2];
          // delete arr[3];
          // arr.push({name:'header', value:btoa(unescape(encodeURIComponent($('#header').val())))});  
          // arr.push({name:'footer', value:btoa(unescape(encodeURIComponent($('#footer').val())))});
          // arr.push({name:'home_side_bar', value:btoa(unescape(encodeURIComponent($('#home_side_bar').val())))});
          // arr.push({name:'profile_side_bar', value:btoa(unescape(encodeURIComponent($('#profile_side_bar').val())))});
        },
        success: function(data) {
            if (data.status == 200) {
                form_ads_settings.find('.waves-effect').text('Save');
                $("html, body").animate({ scrollTop: 0 }, "slow");
                $('.ads-settings-alert').html('<div class="alert alert-success"><i class="fa fa-check"></i> Ads updated successfully</div>');
                setTimeout(function () {
                    $('.ads-settings-alert').empty();
                }, 2000);
            }
        }
    });
});
</script>