jQuery( document ).ready(function( $ ) {
	$( '.dashnex-frame-header' ).scrollToFixed();
	
	$( "body" ).on( "click", function() {
	    $( '.dashnex-frame-popover' ).fadeOut( 'fast' );
	    $( '.dashnex-frame-popover' ).removeClass( 'dashnex-frame-popover-show' );
	});

	$( ".dashnex-frame-popover" ).click(function( event ){
	    event.stopImmediatePropagation();
	});

	$( ".dashnex-frame-popover-btn" ).click(function( event ){
	    event.stopImmediatePropagation();
	    var topOff = $( this ).offset().top - $( "#wpbody" ).offset().top;
	    var leftOff = $( this ).offset().left - 300 - $( "#wpbody" ).offset().left;;
	    $( '.dashnex-frame-popover' ).css({
	      'top' : topOff,
	      'left' : leftOff
	    });
	    $( '.dashnex-frame-popover' ).fadeIn();
	    $( '.dashnex-frame-popover' ).addClass( 'dashnex-frame-popover-show' );
	});

	$( window ).scroll(function(){
	    if ( $( ".dashnex-frame-popover" ).hasClass( "dashnex-frame-popover-show" ) ){
	        var topOff = $( '.dashnex-frame-popover-btn').offset().top - $( "#wpbody" ).offset().top;
	        $( '.dashnex-frame-popover' ).css( 'top', topOff );
	    }
	});
	
	$( '#show-support-modal-btn' ).click(function() {
		$( '#dashnex-support-modal' ).modal( 'show' );
	});

});
