$(document).ready(

    function(){
        jQuery('#legal_eagel_main').addClass('closed');
        jQuery(".collapsible").click(function(e)
        {
            e.preventDefault();
            jQuery("#legal_eagel_main .content").slideUp();
            if(jQuery(this).attr('data-info') == 'true')
            {
                jQuery('.collapsible').attr('data-info', 'false');
                jQuery(this).next().slideUp("slow"); 
                jQuery(this).find('.arrow-close').css('display','none');
                jQuery(this).find('.arrow-open').css('display','block');
            }
            else{
                jQuery(this).next().slideDown("slow"); 
                jQuery(this).find('.arrow-close').css('display','block');
                jQuery(this).find('.arrow-open').css('display','none');
                jQuery('.collapsible').attr('data-info', 'false');
                jQuery(this).attr('data-info', 'true');
            }
        });

        $('[data-toggle="tooltip"]').tooltip();

        $('#lp-is_adult').change(
            function(){
                if (this.checked) {
                     $('#exit_url_section').show();
                }else {
                    $('#exit_url_section').hide();
                }
            }
        );

        /* ----------------- LEGEL EAGLE short code js start --------------------- */
        /*if(jQuery("#custom_legel_eagel_select_box").length > 0)
        {
            jQuery(document).on('change' , "#custom_legel_eagel_select_box" , function(){
                var selectedvalue = $(this).children("option:selected").val();
                jQuery(".editor-inserter__toggle").click();
                jQuery(".editor-inserter__results > div:nth-child(5) button").click();
                jQuery('.is-opened button[aria-label="Shortcode"]').click();
                var count = jQuery(".editor-plain-text").length;
                if(count == 1)
                {
                    jQuery("#blocks-shortcode-input-0").val(selectedvalue);
                }else{
                    count = count - 1;
                    jQuery("#blocks-shortcode-input-"+count).val(selectedvalue);
                }
            });
        }*/
        /* ----------------- LEGEL EAGLE short code js end --------------------- */

        /* ----------------- LEGEL EAGLE General short code js start --------------------- */
        /*if(jQuery("#custom_legel_eagel_general_select_box").length > 0)
        {
            jQuery(document).on('change' , "#custom_legel_eagel_general_select_box" , function(){
                var selectedvalue = $(this).children("option:selected").val();
                jQuery(".editor-inserter__toggle").click();
                jQuery(".editor-inserter__results > div:nth-child(5) button").click();
                jQuery('.is-opened button[aria-label="Shortcode"]').click();
                var count = jQuery(".editor-plain-text").length;
                if(count == 1)
                {
                    jQuery("#blocks-shortcode-input-0").val(selectedvalue);
                }else{
                    count = count - 1;
                    jQuery("#blocks-shortcode-input-"+count).val(selectedvalue);
                }
            });
        }*/
        /* ----------------- LEGEL EAGLE General short code js end --------------------- */

        /* ----------------- LEGEL EAGLE short code js start --------------------- */
        
        if(jQuery("#custom_legel_eagel_select_box").length > 0)
        {
            jQuery(document).on('change' , "#custom_legel_eagel_select_box" , function(){ 
                var selectedvalue = $(this).children("option:selected").val(); 
                jQuery("#legel_eagel_shortcode_input").val(selectedvalue);
                jQuery(".le-shortcode-area").css('display','block');
            }); 
            function copy() {
                var copyText = document.querySelector("#legel_eagel_shortcode_input");
                copyText.select();
                document.execCommand("copy");
                jQuery(".copied").text("Copied to clipboard").show().fadeOut(2200);
                jQuery(".le-shortcode-area").css('display','none');

            }               
            var authButton= document.getElementById('legel_eagel_CpyBtn');
            authButton.addEventListener('click', copy);
            //document.getElementById('legel_eagel_shortcode_input').addEventListener('click', copy);
        }
        /* ----------------- LEGEL EAGLE short code js end --------------------- */

        /* ----------------- LEGEL EAGLE General short code js start --------------------- */
        if(jQuery("#custom_legel_eagel_general_select_box").length > 0)
        {
            jQuery(document).on('change' , "#custom_legel_eagel_general_select_box" , function(){
                var selectedvalue = $(this).children("option:selected").val();
                jQuery("#legel_eagel_general_shortcode_input").val(selectedvalue);
                jQuery(".le-general-shortcode-area").css('display','block');
            });
            function copy() {
                var copyText = document.querySelector("#legel_eagel_general_shortcode_input");
                copyText.select();
                document.execCommand("copy");
                jQuery(".copied1").text("Copied to clipboard").show().fadeOut(2200);
                jQuery(".le-general-shortcode-area").css('display','none');
            }               
            var authButton= document.getElementById('legel_eagel_general_CpyBtn');
            authButton.addEventListener('click', copy);
            
            //document.getElementById('legel_eagel_general_shortcode_input').addEventListener('click', copy);
        }
        /* ----------------- LEGEL EAGLE General short code js end --------------------- */


        
    }
);
