﻿var player;

function deselectClipsExcept(element) {
    $(".selectable").removeClass("selectedrow");
    if (element != null) {
        element.addClass("selectedrow");
    }
}

function loadRemoteClipAndDownload(html, status) {
    loadRemoteClip(html, status);
    showDownloads();
}

function loadRemoteClipAndPlay(html, status) {
    loadRemoteClip(html, status);
    showPreview();
}

function loadRemoteClip(html, status) {
    if (status == "success") {
        boxyDownloads.unload();
        $("#clip").html(html);
        position = $("#clip").position();
        window.scrollTo(0, position.top);
        boxyDownloads = new Boxy($("#downloads_ucDownloads"), { show: false, modal: false, title: "Clip Downloads", closeable: true });
    }
}

function showPreview() {
    var path = "/ViewMedia.aspx?idMedia=" + $("#fldMediaId").val() + "%26idClip=" + $("#fldClipId").val() + ".flv";
    boxyDownloads.hide();
    $("[id$='imgClip']").hide();
    $("#player").show();
    var flashvars = { file: path, autostart: "true", controlbar: "bottom" };
    var params = { allowfullscreen: "true" };
    var attributes = {};
    swfobject.embedSWF("/FlashPlayer/player.swf", "player", "320", "260", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
    
}

function stopPreview() {
    var flashvars = { file: "", autostart: "true", controlbar: "bottom" };
    var params = { allowfullscreen: "true" };
    var attributes = {};
    swfobject.embedSWF("/FlashPlayer/player.swf", "player", "320", "260", "9.0.0", "expressInstall.swf", flashvars, params, attributes);
}

function showDownloads() {
    var contentId = $("#fldClipId").val();
    stopPreview();
    boxyDownloads.show();
    $("#player").hide();
    $("[id$='imgClip']").show();
}

