(function () {
    var jQuery;
    var serverFQDN = 'http://localhost/widget/server';
    var timeoutId, options, container;
    var this_username;
    if (!window.BaltJS)
        window.BaltJS = {};
    BaltJS.Widget = function (opts) {
        options = opts;
        if (!options.buttonText) {
            options.buttonText = 'This text is configurable';
        }
        this_username = options.userName;
        container = '.widget-body';
    };
    function init() {
        if (window.jQuery === undefined || window.jQuery.fn.jquery !== '1.11.2') {
            console.log('we need to load jQuery');
            var script_tag = document.createElement('script');
            script_tag.setAttribute("type", "text/javascript");
            script_tag.setAttribute("src", "https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js");
            (document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
            if (script_tag.attachEvent) {
                //console.log('oh cool, this is IE');
                script_tag.onreadystatechange = function () { // for IE
                    if (this.readyState == 'complete' || this.readyState == 'loaded') {
                        this.onreadystatechange = null;
                        scriptLoadHandler();
                    }
                };
            } else {
                script_tag.onload = scriptLoadHandler;
            }
        } else {
            jQuery = window.jQuery;
            console.log('jQuery already exists on page');
            main();
        }
    }

    function scriptLoadHandler() {
        jQuery = window.jQuery.noConflict();
        console.log('jQuery is now loaded');
        main();
    }

    function main() {
        jQuery(document).ready(function () {
            jQuery('head').append('<link href="' + serverFQDN + '/vendor/cleanslate.css" rel="stylesheet" type="text/css">');

            jQuery.getScript(serverFQDN + '/vendor/json2.js');
            var bootstrap_enabled = (typeof (jQuery.fn.modal) === 'undefined');
//            var bootstrap_enabled2 = (typeof (jQuery.fn.popover) === 'undefined');

            console.log(bootstrap_enabled );
            if (bootstrap_enabled ) {
                 //jQuery('head').append('<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" type="text/css">');
                // jQuery('head').append('<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">');
                 jQuery.getScript('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js');
//                 jQuery('head').append('<link href="' + serverFQDN + '/vendor/bootstrap.min.css" rel="stylesheet" type="text/css">');
                // jQuery.getScript(serverFQDN + '/vendor/bootstrap.min.js');
//                jQuery('head').append('<script src="' + serverFQDN + '/vendor/bootstrap.min.js" type="text/javascript"></script>');
            }


            // jQuery('head').append('<link href="' + serverFQDN + '/slickModal/css/sm-minified.css" rel="stylesheet" type="text/css">');
//            jQuery('head').append('<script src="' + serverFQDN + '/slickModal/js/jquery.slick-modals.min.js" type="text/javascript"></script>');
            // jQuery.getScript(serverFQDN + '/slickModal/js/jquery.slick-modals.min.js');

//cc ultra player
//            jQuery('head').append('<link rel="stylesheet" href="' + serverFQDN + '/CCUltra_Video_Player/css/flat_DarkRedTheme.css" type="text/css" media="screen"/>');
//            jQuery('head').append('<link rel="stylesheet" href="' + serverFQDN + '/CCUltra_Video_Player/css/font-awesome.css" type="text/css">');
////  jQuery('head').append('<script src="../../../ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.js"></script>');
//            jQuery('head').append('<script src="' + serverFQDN + '/CCUltra_Video_Player/js/froogaloop.js" type="text/javascript"></script>');
//            jQuery('head').append('<script src="' + serverFQDN + '/CCUltra_Video_Player/js/IScroll4Custom.js" type="text/javascript"></script>');
//            jQuery('head').append('<script src="' + serverFQDN + '/CCUltra_Video_Player/js/THREEx.FullScreen.js"></script>');
//            jQuery('head').append('<script src="' + serverFQDN + '/CCUltra_Video_Player/js/videoPlayer.js" type="text/javascript"></script>');
//            jQuery('head').append('<script src="' + serverFQDN + '/CCUltra_Video_Player/js/Playlist.js" type="text/javascript"></script>');
//            jQuery('head').append('<script type="text/javascript" src="' + serverFQDN + '/CCUltra_Video_Player/js/ZeroClipboard.js"></script>');

//cc elite player
//            jQuery('head').append(' <link rel="stylesheet" href="' + serverFQDN + '/CCElite_Video_Player/css/elite.css" type="text/css" media="screen"/>');
            // jQuery('head').append(' <link rel="stylesheet" href="' + serverFQDN + '/CCElite_Video_Player/css/elite-font-awesome.css" type="text/css">');
//            jQuery('head').append(' <link rel="stylesheet" href="' + serverFQDN + '/CCElite_Video_Player/css/jquery.mCustomScrollbar.css" type="text/css">');
//            jQuery('body').append(' <script src="' + serverFQDN + '/CCElite_Video_Player/js/froogaloop.js" type="text/javascript"></script>');
//            jQuery('body').append(' <script src="' + serverFQDN + '/CCElite_Video_Player/js/jquery.mCustomScrollbar.js" type="text/javascript"></script> ');
//            jQuery('body').append(' <script src="' + serverFQDN + '/CCElite_Video_Player/js/THREEx.FullScreen.js"></script>');
//            jQuery('body').append(' <script src="' + serverFQDN + '/CCElite_Video_Player/js/videoPlayer.js" type="text/javascript"></script>');
//            jQuery('body').append(' <script src="' + serverFQDN + '/CCElite_Video_Player/js/Playlist.js" type="text/javascript"></script>');
//            jQuery('body').append(' <script type="text/javascript" src="' + serverFQDN + '/CCElite_Video_Player/js/ZeroClipboard.js"></script>');

//elite player
            jQuery('head').append('<link href="' + serverFQDN + '/Elite-video-player/css/elite-font-awesome.min7888.css" rel="stylesheet" type="text/css"/>');
            jQuery('head').append('<link href="' + serverFQDN + '/Elite-video-player/css/elite.min7888.css" rel="stylesheet" type="text/css"/>');
            jQuery('head').append('<link href="' + serverFQDN + '/Elite-video-player/css/jquery.mCustomScrollbar.min7888.css" rel="stylesheet" type="text/css"/>');
            jQuery('head').append('<script src="' + serverFQDN + '/Elite-video-player/js/Playlist.min7888.js" type="text/javascript"></script>');
            jQuery('head').append('<script src="' + serverFQDN + '/Elite-video-player/js/THREEx.FullScreen.min7888.js" type="text/javascript"></script>');
            jQuery('head').append('<script src="' + serverFQDN + '/Elite-video-player/js/ZeroClipboard.min7888.js" type="text/javascript"></script>');
            jQuery('head').append('<script src="' + serverFQDN + '/Elite-video-player/js/embed7888.js" type="text/javascript"></script>');
            jQuery('head').append('<script src="' + serverFQDN + '/Elite-video-player/js/froogaloop.min7888.js" type="text/javascript"></script>');
            jQuery('head').append('<script src="' + serverFQDN + '/Elite-video-player/js/jquery.mCustomScrollbar.min7888.js" type="text/javascript"></script>');
            jQuery('head').append('<script src="' + serverFQDN + '/Elite-video-player/js/videoPlayer.min7888.js" type="text/javascript"></script>');

            jQuery('head').append('<link href="' + serverFQDN + '/widget.css" rel="stylesheet" type="text/css">');
            if (jQuery(container).size() === 0) {
//                jQuery('body').append('<div class="widget-body"></div>');
                jQuery('.mjogger_wid').html('<a id="btnmo" class="float-btn"><i class="fa fa-video-camera my-float-btn"></i><span class="my-float-btn">Video space</span></a>');
                //alert();
              

                jQuery('.mjogger_wid').append('<div id="myModalMediajogger" class="modal fade" role="dialog">' +
                        '<style scoped> body{margin:0}article,aside,details,figcaption,figure,footer,header,hgroup,main,menu,nav,section,summary{display:block}audio,canvas,progress,video{display:inline-block;vertical-align:baseline}audio:not([controls]){display:none;height:0}[hidden],template{display:none}a{background-color:transparent}a:active,a:hover{outline:0}abbr[title]{border-bottom:1px dotted}b,strong{font-weight:bold}dfn{font-style:italic}h1{font-size:2em;margin:0.67em 0}mark{background:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sup{top:-0.5em}sub{bottom:-0.25em}img{border:0}svg:not(:root){overflow:hidden}figure{margin:1em 40px}hr{-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;height:0}pre{overflow:auto}code,kbd,pre,samp{font-family:monospace, monospace;font-size:1em}button,input,optgroup,select,textarea{color:inherit;font:inherit;margin:0}button{overflow:visible}button,select{text-transform:none}button,html input[type="button"],input[type="reset"],input[type="submit"]{-webkit-appearance:button;cursor:pointer}button[disabled],html input[disabled]{cursor:default}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}input{line-height:normal}input[type="checkbox"],input[type="radio"]{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;padding:0}input[type="number"]::-webkit-inner-spin-button,input[type="number"]::-webkit-outer-spin-button{height:auto}input[type="search"]{-webkit-appearance:textfield;-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box}input[type="search"]::-webkit-search-cancel-button,input[type="search"]::-webkit-search-decoration{-webkit-appearance:none}fieldset{border:1px solid #c0c0c0;margin:0 2px;padding:0.35em 0.625em 0.75em}legend{border:0;padding:0}textarea{overflow:auto}optgroup{font-weight:bold}table{border-collapse:collapse;border-spacing:0}td,th{padding:0}*{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}*:before,*:after{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box}input,button,select,textarea{font-family:inherit;font-size:inherit;line-height:inherit}a{color:#337ab7;text-decoration:none}a:hover,a:focus{color:#23527c;text-decoration:underline}a:focus{outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}figure{margin:0}img{vertical-align:middle}.img-responsive{display:block;max-width:100%;height:auto}.img-rounded{border-radius:6px}.img-thumbnail{padding:4px;line-height:1.42857143;background-color:#fff;border:1px solid #ddd;border-radius:4px;-webkit-transition:all .2s ease-in-out;-o-transition:all .2s ease-in-out;transition:all .2s ease-in-out;display:inline-block;max-width:100%;height:auto}.img-circle{border-radius:50%}hr{margin-top:20px;margin-bottom:20px;border:0;border-top:1px solid #eee}.sr-only{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0, 0, 0, 0);border:0}.sr-only-focusable:active,.sr-only-focusable:focus{position:static;width:auto;height:auto;margin:0;overflow:visible;clip:auto}[role="button"]{cursor:pointer}.container{margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px}@media (min-width:768px){.container{width:750px}}@media (min-width:992px){.container{width:970px}}@media (min-width:1200px){.container{width:1170px}}.container-fluid{margin-right:auto;margin-left:auto;padding-left:15px;padding-right:15px}.row{margin-left:-15px;margin-right:-15px}.col-xs-1, .col-sm-1, .col-md-1, .col-lg-1, .col-xs-2, .col-sm-2, .col-md-2, .col-lg-2, .col-xs-3, .col-sm-3, .col-md-3, .col-lg-3, .col-xs-4, .col-sm-4, .col-md-4, .col-lg-4, .col-xs-5, .col-sm-5, .col-md-5, .col-lg-5, .col-xs-6, .col-sm-6, .col-md-6, .col-lg-6, .col-xs-7, .col-sm-7, .col-md-7, .col-lg-7, .col-xs-8, .col-sm-8, .col-md-8, .col-lg-8, .col-xs-9, .col-sm-9, .col-md-9, .col-lg-9, .col-xs-10, .col-sm-10, .col-md-10, .col-lg-10, .col-xs-11, .col-sm-11, .col-md-11, .col-lg-11, .col-xs-12, .col-sm-12, .col-md-12, .col-lg-12{position:relative;min-height:1px;padding-left:15px;padding-right:15px}.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12{float:left}.col-xs-12{width:100%}.col-xs-11{width:91.66666667%}.col-xs-10{width:83.33333333%}.col-xs-9{width:75%}.col-xs-8{width:66.66666667%}.col-xs-7{width:58.33333333%}.col-xs-6{width:50%}.col-xs-5{width:41.66666667%}.col-xs-4{width:33.33333333%}.col-xs-3{width:25%}.col-xs-2{width:16.66666667%}.col-xs-1{width:8.33333333%}.col-xs-pull-12{right:100%}.col-xs-pull-11{right:91.66666667%}.col-xs-pull-10{right:83.33333333%}.col-xs-pull-9{right:75%}.col-xs-pull-8{right:66.66666667%}.col-xs-pull-7{right:58.33333333%}.col-xs-pull-6{right:50%}.col-xs-pull-5{right:41.66666667%}.col-xs-pull-4{right:33.33333333%}.col-xs-pull-3{right:25%}.col-xs-pull-2{right:16.66666667%}.col-xs-pull-1{right:8.33333333%}.col-xs-pull-0{right:auto}.col-xs-push-12{left:100%}.col-xs-push-11{left:91.66666667%}.col-xs-push-10{left:83.33333333%}.col-xs-push-9{left:75%}.col-xs-push-8{left:66.66666667%}.col-xs-push-7{left:58.33333333%}.col-xs-push-6{left:50%}.col-xs-push-5{left:41.66666667%}.col-xs-push-4{left:33.33333333%}.col-xs-push-3{left:25%}.col-xs-push-2{left:16.66666667%}.col-xs-push-1{left:8.33333333%}.col-xs-push-0{left:auto}.col-xs-offset-12{margin-left:100%}.col-xs-offset-11{margin-left:91.66666667%}.col-xs-offset-10{margin-left:83.33333333%}.col-xs-offset-9{margin-left:75%}.col-xs-offset-8{margin-left:66.66666667%}.col-xs-offset-7{margin-left:58.33333333%}.col-xs-offset-6{margin-left:50%}.col-xs-offset-5{margin-left:41.66666667%}.col-xs-offset-4{margin-left:33.33333333%}.col-xs-offset-3{margin-left:25%}.col-xs-offset-2{margin-left:16.66666667%}.col-xs-offset-1{margin-left:8.33333333%}.col-xs-offset-0{margin-left:0}@media (min-width:768px){.col-sm-1, .col-sm-2, .col-sm-3, .col-sm-4, .col-sm-5, .col-sm-6, .col-sm-7, .col-sm-8, .col-sm-9, .col-sm-10, .col-sm-11, .col-sm-12{float:left}.col-sm-12{width:100%}.col-sm-11{width:91.66666667%}.col-sm-10{width:83.33333333%}.col-sm-9{width:75%}.col-sm-8{width:66.66666667%}.col-sm-7{width:58.33333333%}.col-sm-6{width:50%}.col-sm-5{width:41.66666667%}.col-sm-4{width:33.33333333%}.col-sm-3{width:25%}.col-sm-2{width:16.66666667%}.col-sm-1{width:8.33333333%}.col-sm-pull-12{right:100%}.col-sm-pull-11{right:91.66666667%}.col-sm-pull-10{right:83.33333333%}.col-sm-pull-9{right:75%}.col-sm-pull-8{right:66.66666667%}.col-sm-pull-7{right:58.33333333%}.col-sm-pull-6{right:50%}.col-sm-pull-5{right:41.66666667%}.col-sm-pull-4{right:33.33333333%}.col-sm-pull-3{right:25%}.col-sm-pull-2{right:16.66666667%}.col-sm-pull-1{right:8.33333333%}.col-sm-pull-0{right:auto}.col-sm-push-12{left:100%}.col-sm-push-11{left:91.66666667%}.col-sm-push-10{left:83.33333333%}.col-sm-push-9{left:75%}.col-sm-push-8{left:66.66666667%}.col-sm-push-7{left:58.33333333%}.col-sm-push-6{left:50%}.col-sm-push-5{left:41.66666667%}.col-sm-push-4{left:33.33333333%}.col-sm-push-3{left:25%}.col-sm-push-2{left:16.66666667%}.col-sm-push-1{left:8.33333333%}.col-sm-push-0{left:auto}.col-sm-offset-12{margin-left:100%}.col-sm-offset-11{margin-left:91.66666667%}.col-sm-offset-10{margin-left:83.33333333%}.col-sm-offset-9{margin-left:75%}.col-sm-offset-8{margin-left:66.66666667%}.col-sm-offset-7{margin-left:58.33333333%}.col-sm-offset-6{margin-left:50%}.col-sm-offset-5{margin-left:41.66666667%}.col-sm-offset-4{margin-left:33.33333333%}.col-sm-offset-3{margin-left:25%}.col-sm-offset-2{margin-left:16.66666667%}.col-sm-offset-1{margin-left:8.33333333%}.col-sm-offset-0{margin-left:0}}@media (min-width:992px){.col-md-1, .col-md-2, .col-md-3, .col-md-4, .col-md-5, .col-md-6, .col-md-7, .col-md-8, .col-md-9, .col-md-10, .col-md-11, .col-md-12{float:left}.col-md-12{width:100%}.col-md-11{width:91.66666667%}.col-md-10{width:83.33333333%}.col-md-9{width:75%}.col-md-8{width:66.66666667%}.col-md-7{width:58.33333333%}.col-md-6{width:50%}.col-md-5{width:41.66666667%}.col-md-4{width:33.33333333%}.col-md-3{width:25%}.col-md-2{width:16.66666667%}.col-md-1{width:8.33333333%}.col-md-pull-12{right:100%}.col-md-pull-11{right:91.66666667%}.col-md-pull-10{right:83.33333333%}.col-md-pull-9{right:75%}.col-md-pull-8{right:66.66666667%}.col-md-pull-7{right:58.33333333%}.col-md-pull-6{right:50%}.col-md-pull-5{right:41.66666667%}.col-md-pull-4{right:33.33333333%}.col-md-pull-3{right:25%}.col-md-pull-2{right:16.66666667%}.col-md-pull-1{right:8.33333333%}.col-md-pull-0{right:auto}.col-md-push-12{left:100%}.col-md-push-11{left:91.66666667%}.col-md-push-10{left:83.33333333%}.col-md-push-9{left:75%}.col-md-push-8{left:66.66666667%}.col-md-push-7{left:58.33333333%}.col-md-push-6{left:50%}.col-md-push-5{left:41.66666667%}.col-md-push-4{left:33.33333333%}.col-md-push-3{left:25%}.col-md-push-2{left:16.66666667%}.col-md-push-1{left:8.33333333%}.col-md-push-0{left:auto}.col-md-offset-12{margin-left:100%}.col-md-offset-11{margin-left:91.66666667%}.col-md-offset-10{margin-left:83.33333333%}.col-md-offset-9{margin-left:75%}.col-md-offset-8{margin-left:66.66666667%}.col-md-offset-7{margin-left:58.33333333%}.col-md-offset-6{margin-left:50%}.col-md-offset-5{margin-left:41.66666667%}.col-md-offset-4{margin-left:33.33333333%}.col-md-offset-3{margin-left:25%}.col-md-offset-2{margin-left:16.66666667%}.col-md-offset-1{margin-left:8.33333333%}.col-md-offset-0{margin-left:0}}@media (min-width:1200px){.col-lg-1, .col-lg-2, .col-lg-3, .col-lg-4, .col-lg-5, .col-lg-6, .col-lg-7, .col-lg-8, .col-lg-9, .col-lg-10, .col-lg-11, .col-lg-12{float:left}.col-lg-12{width:100%}.col-lg-11{width:91.66666667%}.col-lg-10{width:83.33333333%}.col-lg-9{width:75%}.col-lg-8{width:66.66666667%}.col-lg-7{width:58.33333333%}.col-lg-6{width:50%}.col-lg-5{width:41.66666667%}.col-lg-4{width:33.33333333%}.col-lg-3{width:25%}.col-lg-2{width:16.66666667%}.col-lg-1{width:8.33333333%}.col-lg-pull-12{right:100%}.col-lg-pull-11{right:91.66666667%}.col-lg-pull-10{right:83.33333333%}.col-lg-pull-9{right:75%}.col-lg-pull-8{right:66.66666667%}.col-lg-pull-7{right:58.33333333%}.col-lg-pull-6{right:50%}.col-lg-pull-5{right:41.66666667%}.col-lg-pull-4{right:33.33333333%}.col-lg-pull-3{right:25%}.col-lg-pull-2{right:16.66666667%}.col-lg-pull-1{right:8.33333333%}.col-lg-pull-0{right:auto}.col-lg-push-12{left:100%}.col-lg-push-11{left:91.66666667%}.col-lg-push-10{left:83.33333333%}.col-lg-push-9{left:75%}.col-lg-push-8{left:66.66666667%}.col-lg-push-7{left:58.33333333%}.col-lg-push-6{left:50%}.col-lg-push-5{left:41.66666667%}.col-lg-push-4{left:33.33333333%}.col-lg-push-3{left:25%}.col-lg-push-2{left:16.66666667%}.col-lg-push-1{left:8.33333333%}.col-lg-push-0{left:auto}.col-lg-offset-12{margin-left:100%}.col-lg-offset-11{margin-left:91.66666667%}.col-lg-offset-10{margin-left:83.33333333%}.col-lg-offset-9{margin-left:75%}.col-lg-offset-8{margin-left:66.66666667%}.col-lg-offset-7{margin-left:58.33333333%}.col-lg-offset-6{margin-left:50%}.col-lg-offset-5{margin-left:41.66666667%}.col-lg-offset-4{margin-left:33.33333333%}.col-lg-offset-3{margin-left:25%}.col-lg-offset-2{margin-left:16.66666667%}.col-lg-offset-1{margin-left:8.33333333%}.col-lg-offset-0{margin-left:0}}.fade{opacity:0;-webkit-transition:opacity .15s linear;-o-transition:opacity .15s linear;transition:opacity .15s linear}.fade.in{opacity:1}.collapse{display:none}.collapse.in{display:block}tr.collapse.in{display:table-row}tbody.collapse.in{display:table-row-group}.collapsing{position:relative;height:0;overflow:hidden;-webkit-transition-property:height, visibility;-o-transition-property:height, visibility;transition-property:height, visibility;-webkit-transition-duration:.35s;-o-transition-duration:.35s;transition-duration:.35s;-webkit-transition-timing-function:ease;-o-transition-timing-function:ease;transition-timing-function:ease}.modal-open{overflow:hidden}.modal{display:none;overflow:hidden;position:fixed;top:0;right:0;bottom:0;left:0;z-index:1050;-webkit-overflow-scrolling:touch;outline:0}.modal.fade .modal-dialog{-webkit-transform:translate(0, -25%);-ms-transform:translate(0, -25%);-o-transform:translate(0, -25%);transform:translate(0, -25%);-webkit-transition:-webkit-transform 0.3s ease-out;-o-transition:-o-transform 0.3s ease-out;transition:transform 0.3s ease-out}.modal.in .modal-dialog{-webkit-transform:translate(0, 0);-ms-transform:translate(0, 0);-o-transform:translate(0, 0);transform:translate(0, 0)}.modal-open .modal{overflow-x:hidden;overflow-y:auto}.modal-dialog{position:relative;width:auto;margin:10px}.modal-content{position:relative;background-color:#fff;border:1px solid #999;border:1px solid rgba(0,0,0,0.2);border-radius:6px;-webkit-box-shadow:0 3px 9px rgba(0,0,0,0.5);box-shadow:0 3px 9px rgba(0,0,0,0.5);-webkit-background-clip:padding-box;background-clip:padding-box;outline:0}.modal-backdrop{position:fixed;top:0;right:0;bottom:0;left:0;z-index:1040;background-color:#000}.modal-backdrop.fade{opacity:0;filter:alpha(opacity=0)}.modal-backdrop.in{opacity:.5;filter:alpha(opacity=50)}.modal-header{padding:15px;border-bottom:1px solid #e5e5e5}.modal-header .close{margin-top:-2px}.modal-title{margin:0;line-height:1.42857143}.modal-body{position:relative;padding:15px}.modal-footer{padding:15px;text-align:right;border-top:1px solid #e5e5e5}.modal-footer .btn+.btn{margin-left:5px;margin-bottom:0}.modal-footer .btn-group .btn+.btn{margin-left:-1px}.modal-footer .btn-block+.btn-block{margin-left:0}.modal-scrollbar-measure{position:absolute;top:-9999px;width:50px;height:50px;overflow:scroll}@media (min-width:768px){.modal-dialog{width:600px;margin:30px auto}.modal-content{-webkit-box-shadow:0 5px 15px rgba(0,0,0,0.5);box-shadow:0 5px 15px rgba(0,0,0,0.5)}.modal-sm{width:300px}}@media (min-width:992px){.modal-lg{width:900px}}.popover{position:absolute;top:0;left:0;z-index:1060;display:none;max-width:276px;padding:1px;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-style:normal;font-weight:normal;letter-spacing:normal;line-break:auto;line-height:1.42857143;text-align:left;text-align:start;text-decoration:none;text-shadow:none;text-transform:none;white-space:normal;word-break:normal;word-spacing:normal;word-wrap:normal;font-size:14px;background-color:#fff;-webkit-background-clip:padding-box;background-clip:padding-box;border:1px solid #ccc;border:1px solid rgba(0,0,0,0.2);border-radius:6px;-webkit-box-shadow:0 5px 10px rgba(0,0,0,0.2);box-shadow:0 5px 10px rgba(0,0,0,0.2)}.popover.top{margin-top:-10px}.popover.right{margin-left:10px}.popover.bottom{margin-top:10px}.popover.left{margin-left:-10px}.popover-title{margin:0;padding:8px 14px;font-size:14px;background-color:#f7f7f7;border-bottom:1px solid #ebebeb;border-radius:5px 5px 0 0}.popover-content{padding:9px 14px}.popover>.arrow,.popover>.arrow:after{position:absolute;display:block;width:0;height:0;border-color:transparent;border-style:solid}.popover>.arrow{border-width:11px}.popover>.arrow:after{border-width:10px;content:""}.popover.top>.arrow{left:50%;margin-left:-11px;border-bottom-width:0;border-top-color:#999;border-top-color:rgba(0,0,0,0.25);bottom:-11px}.popover.top>.arrow:after{content:" ";bottom:1px;margin-left:-10px;border-bottom-width:0;border-top-color:#fff}.popover.right>.arrow{top:50%;left:-11px;margin-top:-11px;border-left-width:0;border-right-color:#999;border-right-color:rgba(0,0,0,0.25)}.popover.right>.arrow:after{content:" ";left:1px;bottom:-10px;border-left-width:0;border-right-color:#fff}.popover.bottom>.arrow{left:50%;margin-left:-11px;border-top-width:0;border-bottom-color:#999;border-bottom-color:rgba(0,0,0,0.25);top:-11px}.popover.bottom>.arrow:after{content:" ";top:1px;margin-left:-10px;border-top-width:0;border-bottom-color:#fff}.popover.left>.arrow{top:50%;right:-11px;margin-top:-11px;border-right-width:0;border-left-color:#999;border-left-color:rgba(0,0,0,0.25)}.popover.left>.arrow:after{content:" ";right:1px;border-right-width:0;border-left-color:#fff;bottom:-10px}.clearfix:before,.clearfix:after,.container:before,.container:after,.container-fluid:before,.container-fluid:after,.row:before,.row:after,.modal-header:before,.modal-header:after,.modal-footer:before,.modal-footer:after{content:" ";display:table}.clearfix:after,.container:after,.container-fluid:after,.row:after,.modal-header:after,.modal-footer:after{clear:both}.center-block{display:block;margin-left:auto;margin-right:auto}.pull-right{float:right !important}.pull-left{float:left !important}.hide{display:none !important}.show{display:block !important}.invisible{visibility:hidden}.text-hide{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.hidden{display:none !important}.affix{position:fixed}</style>'+
                        '<div class="modal-dialog modal-lg" style="width:100%;">' +
                        '<div class="modal-content">' +
                        '<div class="modal-header">' +
                        '<button type="button" class="close" data-dismiss="modal">&times;</button>' +
                        '<h4 class="modal-title">Modal Header</h4>' +
                        '</div>' +
                        '<div class="modal-body">' +
                        '<div class="row">' +
                        '<div class="col-md-6">' +
                        '<h3>Heading goes here</h3>' +
                        '<p>This is a blank, cluster free modal popup so you can put any HTML, iframe or other element inside it and get going fast.This is a blank, cluster free modal popup so you can put any HTML, iframe or other element inside it and get going fast.</p>' +
                        '</div>' +
                        '<div class="col-md-6">' +
                        '<div id="Elite_video_player2"></div>' +
                        '</div>' +
                        ' </div>' +
                        '</div>' +
                        '<div class="modal-footer">' +
                        '<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>' +
                        '</div>' +
                        '</div>' +
                        '</div>' +
                        '</div>'
                        );
            }


            jQuery(container).addClass('cleanslate');

            //render();

            // addModal();
            render();
            jQuery('#btnmo').on('click',showModal);
            

        });
    }

   

    function addplayer(vdo_data) {
        videoPlayer = jQuery("#Elite_video_player2").Video({//ALL PLUGIN OPTIONS
            instanceName: "Elite_video_player", //name of the player instance
            autohideControls: 3, //autohide HTML5 player controls
            hideControlsOnMouseOut: "No", //hide HTML5 player controls on mouse out of the player: "Yes","No"
            playerLayout: "fitToContainer", //Select player layout: "fitToContainer", "fixedSize", "fitToBrowser"
            responsive: false, //this option will overwrite above videoPlayerWidth/videoPlayerHeight and set player to fit your div (parent) container: tru   
            videoPlayerWidth: 950, //fixed total player width
            videoPlayerHeight: 420, //fixed total player height
            lightBox: false, //lightbox mode :true/false
            lightBoxAutoplay: false, //autoplay video when lightbox opens: true/false
            lightBoxThumbnail: "http://placehold.it/200x60", //lightbox thumbnail image
            lightBoxThumbnailWidth: 200, //lightbox thumbnail image width
            lightBoxThumbnailHeight: 60, //lightbox thumbnail image height
            lightBoxCloseOnOutsideClick: true, //close lightbox when clicked outside of player area

            playlist: "Right playlist", //choose playlist type: "Right playlist", "Off"
            playlistScrollType: "light", //choose scrollbar type: "light","minimal","light-2","light-3","light-thick","light-thin","inset","inset-2","inset-3","rounded","rounded-dots","3d"
            playlistBehaviourOnPageload: "opened", //choose playlist behaviour when webpage loads: "closed", "opened" (not apply to Vimeo player)
            autoplay: false, //autoplay when webpage loads: true/false
            colorAccent: "#cc181e", //plugin colors accent (hexadecimal or RGB value - http://www.colorpicker.com/)
            vimeoColor: "00adef", //set "hexadecimal value", default vimeo color is "00adef"
            youtubeControls: "custom controls", //choose youtube player controls: "custom controls", "default controls"
            youtubeSkin: "dark", //youtube theme: light,dark
            youtubeColor: "red", //youtube color: red, white
            youtubeQuality: "default", //choose youtube quality: "small", "medium", "large", "hd720", "hd1080", "highres", "default"
            youtubeShowRelatedVideos: "No", //choose to show youtube related videos when video finish
            videoPlayerShadow: "off", //choose player shadow:  "effect1" , "effect2", "effect3", "effect4", "effect5", "effect6", "off"
            loadRandomVideoOnStart: "No", //choose to load random video when webpage loads: "Yes", "No"
            shuffle: "No", //choose to shuffle videos when playing one after another: "Yes", "No" (shuffle button enabled/disabled on start)
            posterImg: "", //player poster image
            onFinish: "Play next video", //"Play next video","Restart video", "Stop video",
            nowPlayingText: "Yes", //enable disable now playing title: "Yes","No"
            fullscreen: "Fullscreen native", //choose fullscreen type: "Fullscreen native","Fullscreen browser"
            rightClickMenu: true, //enable/disable right click over player: true/false
            hideVideoSource: false, //option to hide self hosted video sources (to prevent users from download/steal your videos): true/false
            showAllControls: true, //enable/disable all HTML5 player controls: true/false
            allowSkipAd: true, //enable/disable "Skip advertisement" option: true/false
            infoShow: "Yes", //enable/disable info option: "Yes","No"
            shareShow: "Yes", //enable/disable all share options: "Yes","No"
            facebookShow: "Yes", //enable/disable facebook option individually: "Yes","No"
            twitterShow: "Yes", //enable/disable twitter option individually: "Yes","No"
            mailShow: "Yes", //enable/disable mail option individually: "Yes","No"
            facebookShareName: "Elite video player", //first parametar of facebook share in facebook feed dialog is title
            facebookShareLink: "http://codecanyon.net/item/elite-video-player-wordpress-plugin/10496434", //second parametar of facebook share in facebook feed dialog is link below title
            facebookShareDescription: "Elite Video Player is stunning, modern, responsive, fully customisable high-end video player for WordPress that support advertising and the most popular video platforms like YouTube, Vimeo or self-hosting videos (mp4).", //third parametar of facebook share in facebook feed dialog is description below link
            facebookSharePicture: "https://0.s3.envato.com/files/123866118/preview.jpg", //fourth parametar in facebook feed dialog is picture on left side
            twitterText: "Elite video player", //first parametar of twitter share in twitter feed dialog is text
            twitterLink: "http://codecanyon.net/item/elite-video-player-wordpress-plugin/10496434", //second parametar of twitter share in twitter feed dialog is link
            twitterHashtags: "wordpressvideoplayer", //third parametar of twitter share in twitter feed dialog is hashtag
            twitterVia: "Creative media", //fourth parametar of twitter share in twitter feed dialog is via (@)
            googlePlus: "http://codecanyon.net/item/elite-video-player-wordpress-plugin/10496434", //share link over Google +
            logoShow: "Yes", //"Yes","No"
            logoClickable: "Yes", //"Yes","No"
            logoPath: "images/logo/logo.png", //path to logo image
            logoGoToLink: "http://codecanyon.net/", //redirect to page when logo clicked
            logoPosition: "bottom-left", //choose logo position: "bottom-right","bottom-left"
            embedShow: "Yes", //enable/disable embed option: "Yes","No"
            embedCodeSrc: "www.yourwebsite.com/videoplayer/index.html", //path to your video player on server
            embedCodeW: "746", //embed player code width
            embedCodeH: "420", //embed player code height
            embedShareLink: "www.yourwebsite.com/videoplayer/index.html", //direct link to your site (or any other URL) you want to be "shared"
            youtubePlaylistID: "", //automatic youtube playlist ID (leave blank "" if you want to use manual playlist) LL4qbSRobYCjvwo4FCQFrJ4g
            youtubeChannelID: "", //automatic youtube channel ID (leave blank "" if you want to use manual playlist)

//manual playlist
            videos: vdo_data
        });

    }


    function render() {
        // build the widget
//        var markup = '';
//        markup = markup + '<input type="text" id="user_text" placeholder="type something"></input>';
//        markup = markup + '<button>' + options.buttonText + '</button>';
//        jQuery(container).append(markup);
//        // handle events
//        jQuery(container + ' button').click(handleClick);
        //jQuery('.mjogger_wid').on('click',getModal);
        
        getMyVideoData();

    }

function getMyVideoData(){
//    var data =jQuery.getJSON(serverFQDN + '/widget_submit.php?callback=?');
    //console.log(data);
    
    jQuery.ajax({
        url:'http://localhost/widget/server/widget_submit.php',
        method:'GET',
        dataType:'json',
        success:function(data2){
            console.log(data2);
            alert();
            addplayer(data2);
            
            //data-toggle="modal" data-target="#myModalMediajogger"
        }
    });
}

function showModal(){
    jQuery('#myModalMediajogger').modal('show');
}

    function handleClick() {
        jQuery(this).attr('disabled', 'disabled');
        // JSONP request to server
        jQuery.getJSON(serverFQDN + '/widget_submit.php?callback=?', {
            install_url: window.location.href,
            text: jQuery(container + ' #user_text').val()
        }, serverResponse);
    }

    function serverResponse(data) {
        jQuery(container + ' button').removeAttr('disabled');
        updateStatus(data.message + ' Your ip is ' + data.ip + '. Host site is ' + data.site + '. UA is ' + data.ua);
    }

    function updateStatus(msg) {
        if (jQuery(container + ' p.message').length === 0) {
            jQuery(container).append('<p class="message"></p>');
        }
        jQuery(container + ' p.message').html(msg);
    }

    init();

})();
