// show dialog anket content
function showAnket(url, fullscreen) {
    var $container = $('#dialog');

    //url = url + "?sid=" + ClientData.userInfo_sid();

    $container.html('');
    $container.addClass('anket-dialog');

    var canvas = document.getElementById('main');

    var width = fullscreen == true ? canvas.width : 340;

    if (fullscreen == true) {
        $container.attr('style', 'width:' + width + 'px; left:10px;right:auto;');
    }
    else {
        $container.attr('style', 'width:' + width + 'px; right:10px;left:auto;'); // !important
    }
    
    $container.draggable({ handle: "h1" });
    $container.html(
      '<h1>'+i18nText('txtEnqueteTitle')
    + '<img src="img/viewer/x.png" style="margin:3px 3px 0px 21px" id="btnClose" class="align_right" ></img>'
    + '</h1>'
    + '<div class="anket-container"><iframe width="'+width+'" height="100%" frameborder="0" scrolling="auto" src="' + url + '">'
    + '</iframe></div>'
    + '<div class="anket-commands"><input type="button" value="' + i18nText('txtTransparent') + '" id="btnFullOpacity"/> <input type="button" value="' + i18nText('txtSemiTransparent') + '" id="btnApartOpacity"/> <input type="button" value="' + i18nText('txtNoTransparent') + '" id="btnNoOpacity"/></div><div style="clear:both;"></div>'
    );
    $('#dialog h1 img').click(function(){
        $container.removeAttr('style');
        hideDialog();
    });

    var avwUserEnvObj = new UserEnvironment();

    // set overflow for container iframe
    if (avwUserEnvObj.isIpad()) {
        $('#dialog .anket-container').css('overflow', 'auto');
        if (fullscreen == true) {
            $container.attr('style', 'width:' + width + 'px; left:10px;right:auto;'); // !important on ipad can't move dialog
        }
        else {
            $container.attr('style', 'width:' + width + 'px; right:20px;left:auto;');
        }
    }

    // click on button change transparent
    $('#dialog .anket-commands input').click(
        function () {
            var opacity = 1;

            if ($(this).index() == 0) {
                opacity = 0.2;
            }
            else if($(this).index()==1)
            {
                opacity = 0.7;
            }
            $('#dialog,#dialog iframe,#dialog .anket-commands,#dialog .anket-commands input').css('opacity', opacity);
        }
    );
        // resize anket
        resizeAnket();

    };

    // resize dialog anket
    function resizeAnket() {
        
        // get canvas main
        var canvas = document.getElementById('main');
        var height = canvas.height;

        var top = (isFullScreen?0:$('#header_toolbar').height()) + 4; // get top position for dialog 4 for space

        // set top dialog
        $('#dialog').height(height).css('top', top);

        var iframeHeight = height - $('#dialog h1').height() - $('#dialog .anket-commands').height() - 8;  // 8 for 2xspace

        // set height for iframe
        $('#dialog iframe').attr('height', iframeHeight);

        // set height for anket container
        $('#dialog .anket-container').css('height', iframeHeight);
    };