/* 
 * PGi Video API
 * 
 */
var bcExp;
var modVP;
var modExp;
var modCon;
var modSocial;

// called when template loads, this function stores a reference to the player and modules.
// Then event listeners will be added for when the template is ready and when a user
// clicks on a video.
function onTemplateLoaded(experienceID) {
    //alert("EVENT: TEMPLATE_LOAD");

    bcExp = brightcove.getExperience(experienceID);

    modVP = bcExp.getModule(APIModules.VIDEO_PLAYER);
    modExp = bcExp.getModule(APIModules.EXPERIENCE);
    modCon = bcExp.getModule(APIModules.CONTENT);
	modSocial = bcExp.getModule(APIModules.SOCIAL);

    modExp.addEventListener(BCExperienceEvent.TEMPLATE_READY, onTemplateReady);
    modExp.addEventListener(BCExperienceEvent.CONTENT_LOAD, onContentLoad);
    modCon.addEventListener(BCContentEvent.VIDEO_LOAD, onVideoLoad);

    //PLAYER EVENT LISTENERS
    modVP.addEventListener(BCMediaEvent.BEGIN, onMediaBegin);
    modVP.addEventListener(BCMediaEvent.COMPLETE, onMediaComplete);
    modVP.addEventListener(BCMediaEvent.BUFFER_BEGIN, onBufferBegin);
    modVP.addEventListener(BCMediaEvent.BUFFER_COMPLETE, onBufferComplete);
    modVP.addEventListener(BCMediaEvent.CHANGE, onMediaChange);
    modVP.addEventListener(BCMediaEvent.ERROR, onMediaError);
    modVP.addEventListener(BCMediaEvent.MUTE_CHANGE, onMediaMuteChange);
    modVP.addEventListener(BCMediaEvent.PLAY, onMediaPlay);
    modVP.addEventListener(BCMediaEvent.PROGRESS, onMediaProgress);
    modVP.addEventListener(BCMediaEvent.SEEK, onMediaSeek);
    modVP.addEventListener(BCMediaEvent.STOP, onMediaStop);
    modVP.addEventListener(BCMediaEvent.VOLUME_CHANGE, onMediaVolumeChange);

}
function onTemplateReady(evt) {
	modSocial.setLink(window.location.href);
    //alert("EVENT: TEMPLATE_READY");
}
function onVideoLoad(evt) {
    //alert("EVENT: VIDEO_LOAD");

    // Play video that was just loaded
    modVP.loadVideo(evt.video.id);
}
function onMediaBegin(evt) {
    //alert("EVENT: onMediaBegin");
}
function onMediaComplete(evt) {
    //alert("EVENT: onMediaComplete");
}
function onBufferBegin(evt) {
    //alert("EVENT: onBufferBegin");
}
function onBufferComplete(evt) {
    //alert("EVENT: onBufferComplete");
}
function onMediaChange(evt) {
    //alert("EVENT: onMediaChange");
}
function onMediaError(evt) {
    //alert("EVENT: onMediaError");
}
function onMediaMuteChange(evt) {
    //alert("EVENT: onMediaMuteChange");
}
function onMediaPlay(evt) {
    //alert("EVENT: onMediaPlay");
}
function onMediaProgress(evt) {
    //alert("EVENT: onMediaProgress");
}
function onMediaSeek(evt) {
    //alert("EVENT: onMediaSeek");
}
function onMediaStop(evt) {
    //alert("EVENT: onMediaStop");
}
function onMediaVolumeChange(evt) {
    //alert("EVENT: onMediaVolumeChange");
}

 
