﻿// Handle all the the FSCommand messages in a Flash movie
function free_element_DoFSCommand(command, args) {
    alert('free_element_DoFSCommand called');
    var fargs = args.split(",");

    // Calls a javascript method, named with same as command sent from flash
    this[command].apply(null, fargs);
}

// Get a handle to the flash movie
function getFlashMovieObject(movieName) {
    if (window.document[movieName]) {
        return window.document[movieName];
    }
    if (navigator.appName.indexOf("Microsoft Internet") == -1) {
        if (document.embeds && document.embeds[movieName])
            return document.embeds[movieName];
    }
    else {
        return document.getElementById(movieName);
    }
}

// Called by flash to trigger pixel display in iframe
function callPixel(pixelType) {
    var pixelFrame = document.getElementById("pixelFrame");

    // The variables pixelPage and pixelParam are defined on the LP entry page
    var redirectUrl = pixelPage + "?" + pixelParam + "=" + pixelType;

    pixelFrame.src = redirectUrl;
}

// Sends response to flash after pixel load
function sendPixelResponse() {
    var flashMovie = getFlashMovieObject("free_element");

    var pixelFrame = document.getElementById("pixelFrame");

    if (pixelFrame.src.indexOf("CallPixel.aspx") != -1) {
        var pixelFrameResult = pixelFrame.complete;
        //ToDo: Fix pixel status tracking
        flashMovie.pixelFeedback(true);
    }
}

		

