﻿var _player;

function vidPlayer_Show(MediaID, Player, Email, Postal) {
    _player = Player;
    ret = RecordMediaView.Record
               (MediaID, Email, Postal, vidPlayer_OnComplete, vidPlayer_OnError, vidPlayer_OnTimeOut);
}
function vidPlayer_OnComplete(arg) {
    if (arg.ResultCode == "Error") {
        alert(arg.ResultValue);
    }
    if (arg.ResultCode == "Success") {
        vidPlayer_Play(arg.ResultValue, _player);
        document.getElementById("vidPlayer_PlayerDiv").style.display = "block";
        document.getElementById("vidPlayer_InputDiv").style.display = "none";
    }
}
function vidPlayer_OnTimeOut(arg) {
    alert("The server failed to respond. Please try again.");
}
function vidPlayer_OnError(arg) {
    alert(arg._message);
}
function vidPlayer_Play(VName, Player) {
    playerSize = PlayerSize(VName);
    var s1 = new SWFObject(Player, 'vidPlayer_ID', playerSize[0], playerSize[1], '7');
    s1.addParam('allowfullscreen', 'false');
    s1.addVariable('file', escape(VName) + '&autoStart=true');
    s1.addVariable('width', playerSize[0]);
    s1.addVariable('height', playerSize[1]);
    s1.addVariable('backcolor', '#005EBB');
    s1.addVariable('frontcolor', '0xFFFFFF');
    s1.addVariable('autostart', 'true');
    s1.addVariable('type', 'flv');
    //s1.addVariable('wmode', 'opaque');
    s1.write('vidPlayer_PlayerDiv');
}
function vidPlayer_Help_Email() {
    var x = "Please enter your email address, even if you are not the celebrity in the video."
    x = x + " We will be implementing user accounts and your email address will be required for you to access the video in the future."
    x = x + "\n\n"
    x = x + "Your email address will never be provided to anyone other than the celeb of the video."
    x = x + "\n\n"
    x = x + "Thanks for your support."
    x = x + alert(x);
}
function vidPlayer_Help_PostalCode() {
    var x = "For postal codes not in USA, enter 99999."
    x = x + "\n\n"
    x = x + "We use your postal code as a non-intrusive way to track the geographic dispersal of our viewers."
    x = x + "\n\n"
    x = x + "Thanks for your support."
    x = x + alert(x);
}
function PlayerSize(VName) {
    if (VName.indexOf(escape("[A16x9]")) != -1) {
        return [480, 270];
    }
    else {
        return [320, 240];
    }
}
