﻿if (!window.windows_red) window.lazarus = {};

lazarus.Base = function() {
    this.control = null;
    this.rootCanvas = null;
    this.root = null;
}

lazarus.Base.prototype = {
    dispose : function() { this.root = null; },
    initialize : function(control, userContext, rootElement) {
		this.control = control;
		this.data = null;
		this.root = this.control.content;
		this.rootCanvas = this.root.findName("rootCanvas");
        this.lazVid = this.rootCanvas.findName("lazarusvideo");
        
        this.registerButton(this.rootCanvas.findName("play_button"), this.rOverPlay, this.rOutPlay, this.videoPlay);
        
        

		this.lazVid.addEventListener("MediaEnded", Silverlight.createDelegate(this,this.playFadeIn));
		
		

        
    },
    
    registerButton : function(button, overAction, outAction, clickAction) {
        if (overAction != null)
            button.addEventListener("MouseEnter", Silverlight.createDelegate(this, overAction));
        if (outAction != null)
            button.addEventListener("MouseLeave", Silverlight.createDelegate(this, outAction));
        if (clickAction != null)
	        button.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, clickAction));          
    },
    
    rOverPlay : function(sender, eventArgs) { this.rootCanvas.findName("play_video_mouseover").begin(); },
    rOutPlay: function(sender, eventArgs) { this.rootCanvas.findName("play_video_mouseout").begin(); },
    
    videoPlay: function(sender, eventArgs)
        {
            this.rootCanvas.findName("play_video_fadeout").begin();
            this.lazVid.play();
        },
    playFadeIn: function(sender, eventArgs) { 
        this.lazVid.stop();
        this.rootCanvas.findName("play_video_fadein").begin(); 
        }

}
