function iReplyFlash (url, version) {

    // DOM Container Element
    var __parent;

    // DOM Flash Object Element
    var __self;

    // Assigned variables to flash.
    var __variables;

    // URL of the swf.
    var __url;

    // Flash version.
    var __version;

    // Width of the container.
    var __width;

    // Height of the container.
    var __height;

    // Left position of the container.
    var __left;

    // Top position of the container.
    var __top;


    /**
     * CONSTRUCTOR.
     * ---------------------------------------------------------------------- */
    {

        // Registered url.
        __url = url;

        // Registered version
        __version = version;


        // Initialize params as an Array.
        __variables = [];

        // Dimention & Positioning of the container.
        __width  = 0;
        __height = 0;
        __left   = 0;
        __top    = 0;

        // DOM Elements initiate as null.
        __parent = null;
        __self   = null;
    }



    /*
     * Private Function __make_ie (Number width, Number height) : Void
     *
     * @param number width
     * @param number height
     * ---------------------------------------------------------------------- */
    var __make_ie = function (flashvars) {

        var classid = "D27CDB6E-AE6D-11cf-96B8-444553540000";

        var codebase = Array ();
            codebase [7] = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0";
            codebase [8] = "http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,22,0";

        __parent.innerHTML =  '<object                        \
                    scale="noscale"                           \
                    classid="clsid:' + classid + '"           \
                    codebase="' + codebase [__version] + '"   \
                    width="100%"                              \
                    height="100%"                             \
            >                                                 \
                <param name="movie"                           \
                       value="' + __url + '?' + flashvars + '&' + Math.ceil (Math.random() * new Date().getMilliseconds()*9999) + ' \
                       allowScriptAccess="always"             \
            />                                                \
            <param name="flashvars"                           \
                   value="' + flashvars + '"                  \
            />                                                \
            </object>                                         \
        ';

        __self = __parent.firstChild;
    }

    /*
     * Private Function __make_other (Number width, Number height) : Void
     *
     * @param number width
     * @param number height
     * ---------------------------------------------------------------------- */
    var __make_other = function (flashvars) {

        __self = document.createElement ("object");

        __self.setAttribute ("type",     "application/x-shockwave-flash");
        __self.setAttribute ("data",      __url);
        __self.setAttribute ("width",     "100%");
        __self.setAttribute ("height",    "100%");


        objParam = document.createElement ('param');

            objParam.setAttribute ('name', "allowScriptAccess");
            objParam.setAttribute ('value', "always");

        __self.appendChild (objParam);

        objParam = document.createElement ('param');

            objParam.setAttribute ('name', "scale");
            objParam.setAttribute ('value', "noscale");

        __self.appendChild (objParam);


        objParam = document.createElement ('param');
            objParam.setAttribute ('name', "flashvars");
            objParam.setAttribute ('value', flashvars);
        __self.appendChild (objParam);

        // Set the new content
        __parent.appendChild (__self);

        delete objParam;
    }

    /**
     * Public Function set_variable (String name, Mixed value) : Void
     *
     * @param: string name
     * @param: mixed value
     * @desc: Pushes variables onto the flashvar stack.
     * ---------------------------------------------------------------------- */
    this.set_variable = function (name, value) {

        __variables [__variables.length] = name + "=" + value;
    }

    /**
     * Public Function position () : Void
     *
     * @param: number x
     * @param: number y
     * @desc: Positions the container with styles
     * ---------------------------------------------------------------------- */
    this.position = function (x, y) {

        __parent.style ['left'] = x + "px";
        __parent.style ['top'] = y + "px";
    }

    /**
     * Public Function center () : Void
     *
     * @param: number offsetx
     * @param: number offsety
     * @desc: Positions the container to the absolute center of the page.
     * ---------------------------------------------------------------------- */
    this.center = function (offsetx, offsety) {

        // set out default values.
        if (typeof offsetx == "undefined") offsetx = 0;
        if (typeof offsety == "undefined") offsety = 0;

        // All browser compatibility.
        w = window.innerWidth  > 0 ? window.innerWidth  : document.body.clientWidth;
        h = window.innerHeight > 0 ? window.innerHeight : document.body.clientHeight;

        // Position the element.
        this.position ( ((w / 2) - (__width / 2)) - offsetx, ((h / 2) - (__height / 2)) - offsety);

        delete w;
        delete h;
    }



    /**
     * Public Function close () : Void
     *
     * @desc: Removes the parent DIV from the DOM.
     * ---------------------------------------------------------------------- */
    this.close = function () {

        __parent.parentNode.removeChild (__parent);
    }


    /**
     * Public Function get_width () : Number
     *
     * @desc: Getter width.
     * ---------------------------------------------------------------------- */
    this.get_width = function () {

        return __width;
    }



    /**
     * Public Function set_height () : Number
     *
     * @desc: Setter height
     * ---------------------------------------------------------------------- */
    this.set_height = function (height) {

        __parent.style.height = height + "px";
        __height = parseInt (height);
    }

    /**
     * Public Function set_height () : Number
     *
     * @desc: Setter height
     * ---------------------------------------------------------------------- */
    this.set_width = function (width) {

        __parent.style.width = width + "px";
        __width  = parseInt (width);
    }

    /**
     * Public Function create (Function& callback, width, height) : Void
     *
     * @param: function callback
     * @desc: Creates a container and flash object, supports a callback
     *        for making own functionality, this is required for now.
     * @call: function callback (this);
     * ---------------------------------------------------------------------- */
    this.create = function (callback, width, height) {

        // Die when we dont have a callback.
        if (typeof callback != "function") return;

        // parent is container
        __parent = callback (this);

        // callback should return our containing element, or exit this function.
        if (typeof __parent != "object") return;

        // Concat all flashvars as 1 parameter
        var flashvars = "";
        for (var i = 0; i < __variables.length; i++ ) {
            flashvars += (i > 0 ? "&" : "" ) + __variables [i];
        }

        // Keep our own variables
        this.set_width (width);
        this.set_height (height);

        // Width + Height register for IE bug.
        flashvars += "&stageHeight=" + __height + "&stageWidth=" + __width;

        // Hack: returns true whenever the script is accessed by "IE?"
        if (typeof document.all != "undefined") {

            // Function to make flash object for IE.
            __make_ie (flashvars);
        }

        // Function to make flash object for real browsers.
        else {

            __make_other (flashvars);
        }
    }

    /**
     * Public Function ease (property : String, T : Number , speed : Number ) : Void
     *
     * @param: string property
     * @param: number T
     * @param: number speed
     * @desc: Eases a property to given T with speed.
     * ---------------------------------------------------------------------- */
    this.ease = function (prop, T, speed) {

        if ( typeof speed == 'undefined' || speed <= 1) speed = 1.2;

        var Tp = parseInt (__parent.style [prop]);

        var i = setInterval (function () {

            Tx = (T - ( T - Tp) / speed);

            __parent.style [prop] = Tx + "px";
            if (Tx == Tp) {

                __parent.style [prop] = T + "px";

                clearInterval (i);
                return true;
            }

            Tp = parseInt (__parent.style [prop]);

            delete Tx;
        }, 100);

        return false;
   }
}


// Only execute this for browsers with attachEvent.
if (window.attachEvent) {

    // Attempt to make a function to window named addEventListener for multi -
    // browser support.
    window.addEventListener = function (type,func,dummy) {

        // and make it work.
        return window.attachEvent ('on' + type, func);
    }
}

// Only execute this for browsers with detachEvent.
if (window.detachEvent) {

    // Attempt to make a function to window named addEventListener for multi -
    // browser support.
    window.removeEventListener = function (type,func,dummy) {

        // and make it work.
        return window.detachEvent ('on' + type, func);
    }
}

// Global variables.
var iReplyMovie;

function open_player (id, hash, auto) {

    if (typeof iReplyMovie == 'object') return;
    if (typeof auto == 'undefined') auto = false;

    iReplyMovie = new iReplyFlash (document.location + "ireply/main.swf", 7);

    iReplyMovie.set_variable ("fileId",  id);
    iReplyMovie.set_variable ("fileKey", hash);

    iReplyMovie.set_variable ("volume", 100);
    iReplyMovie.set_variable ("width", 428);
    iReplyMovie.set_variable ("height", 240-12);

    iReplyMovie.set_variable ("showInterval", 2629743);
    if (auto == true) iReplyMovie.set_variable ("autoPopup", 1);

    iReplyMovie.set_variable ("srcHost", document.location);
    iReplyMovie.set_variable ("srcPath", "/ireply/nataraj.flv");

    iReplyMovie.create (createCanvas, 428, 240-12);
}

function createCanvas () {

    var spotContainer = document.createElement ('div');

        spotContainer.style ["position"] = "absolute";
        spotContainer.style ["top"] = "-9999px";
        spotContainer.style ["left"] = "-9999px";

        spotContainer.style ["zIndex"] = "99";

    return document.body.appendChild (spotContainer);
}

function closeForm () {

    iReplyMovie.ease ("height", 248, 1.8);
}

function centerSpot () {

    // Position the element.
    iReplyMovie.center (0, 0);
}
function attach_back () {
    var closeBtn = document.createElement ('div');
    closeBtn.innerHTML = '<a href="../../products.php"><span style="color:red; display:block; position:relative; left:15px; top:10px; font-family: \'Arial Black\'; font-size:22px;">Terug</span></a>';

    closeBtn.style.background = "transparent url('../gfx/nav_btn_movie.gif') no-repeat scroll 0% 50%"
    closeBtn.style.height = "55px";
    closeBtn.style.width = "191px";
    closeBtn.style.position = "absolute";
    closeBtn.style.top = 0;
    closeBtn.style.left = 0;

    document.body.appendChild (closeBtn);
}

function showSpot () {

    // Positions the element exactly on the right position.
    window.addEventListener ('resize', centerSpot, false);

    centerSpot();
}
function closeSpot () {

    window.removeEventListener ('resize', centerSpot, false);
    if (iReplyMovie != "") {

        iReplyMovie.ease ("height", 0, 2.0);

        var i = setTimeout (function () { iReplyMovie.close (); iReplyMovie = ""; }, 1500);
    }
}
window.addEventListener ('load', function () {

    open_player (14, "de91374573138eb94320734a6afe4bfc", false);

}, false);



