﻿function showVideo(videoId) {
    $.ajax({
        type: "POST",
        cache: false,
        dataType: 'text/html',
        url: "Shop/GetVideoPreview/" + videoId + "/",
        success: function (data) {
            jQuery('#video-popup').html(data);

            var dialog = jQuery('#video-popup').jqm({
                onHide: function (h) {
                        var video = document.getElementsByTagName("video")[0];

                        if (video != undefined || video != null) {
                            video.pause();
                        }

                        h.o.remove();
                        h.w.fadeOut(1);
                    }
                });

            dialog.click(function () { dialog.jqmHide(); });
            dialog.keypress(function () { dialog.jqmHide(); });

            dialog.jqmShow();
        }
    })
}

function showVideoForPackage(packageId) {
    $.ajax({
        type: "POST",
        cache: false,
        dataType: 'text/html',
        url: "Shop/GetVideoForPackage/" + packageId + "/",
        success: function (data) {
            jQuery('#video-popup').html(data);

            var dialog = jQuery('#video-popup').jqm({
                onHide: function (h) {
                    var video = document.getElementsByTagName("video")[0];

                    if (video != undefined || video != null) {
                        video.pause();
                    }

                    h.o.remove();
                    h.w.fadeOut(1);
                }
            });

            dialog.click(function () { dialog.jqmHide(); });
            dialog.keypress(function () { dialog.jqmHide(); });

            dialog.jqmShow();
        }
    })
}
