( function( $ ) {
$('body').on('click', '#accordion-panel-gf_stla_panel',function(){
if($('#customize-control-gf_stla_hidden_field_for_form_id').length){
    $('#accordion-section-gf_stla_form_id_my_themes').hide();

    }});


//Apply Theme and refresh the page
$('body').on('click', '.gf-stla-apply-theme-button', function(){

alert('Applying Theme !!!');
$('form #customize-header-actions #save').click();
$('#customize-preview').removeClass('iframe-ready');
$('#customize-preview iframe').hide();
 waitforformsubmit = setInterval(check_button_disabled, 2000);
 
});

//Delete Theme and refresh
$('body').on('click', '.gf-stla-delete-theme-button', function(){

alert(' Deleting Theme !!!');
$('form #customize-header-actions #save').click();
$('#customize-preview').removeClass('iframe-ready');
$('#customize-preview iframe').hide();
 waitforformsubmit = setInterval(check_button_disabled, 2000);
 
});

//Save new theme and refresh
$('body').on('click', '.gf-stla-save-theme-button', function(){

alert('Saving Theme !!!');
$('form #customize-header-actions #save').click();
$('#customize-preview').removeClass('iframe-ready');
$('#customize-preview iframe').hide();
 waitforformsubmit = setInterval(check_button_disabled, 2000);
 
});

function check_button_disabled(){
    if($('form #customize-header-actions #save').prop('disabled')){
    	location.reload();
    	}
    }
    } )( jQuery );