﻿
function CreateImage(imagePath, destination) {

    var imgPrint = new Image();
    imgPrint.src = imagePath;
    document.getElementById(destination).appendChild(imgPrint);
    $('.applyJob').show();
}

function PlayFlash(videoPath, destination, height, width,jobID) {
var y = document.getElementById(destination);
var flashvars = { flvPath: videoPath, jobRole: jobID };
    var params = {
        menu: "false",
        allowScriptAccess: "always",
        scale: "noscale",
        wmode: "transparent"
    };
    var attributes = { id: "BMF" };
    swfobject.embedSWF(videoPath,destination,height,width, "9.0.115", "../Images/media/expressInstall.swf", flashvars, params, attributes);
    SWFID = destination;
}



//Once the video has finished playing the flash will call this function
function videoFinished() {
    videoPlayed = true;
    $("#btnApplyPre").remove();
}


//Set a flag saying video hasnt been played yet
var videoPlayed = false;
//flag to see wether the button applied has been already pressed before viewing the whole video
var applyPreAdded = false;


$(document).ready(function() {
    //button apply click function
    $("#btnApply").click(function() {
    
        //if video hasnt been played show "Please finish watching the video" and set applyPreAdded flag to true; so in case of clicking again it wont add it again
        if (videoPlayed === false) 
        {
            if (applyPreAdded === false) 
            {
                $(this).after("<p id='btnApplyPre' style='color:red;'>Please finish watching the video</p>");
                applyPreAdded = true;
            }
            return false;
        }
    });
});





