﻿if (!window.windows_red) window.windows_red = {};

windows_red.Base = function() {
    this.control = null;
    this.rootCanvas = null;
    this.root = null;
}

windows_red.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.registerButton(this.rootCanvas.findName("skip_intro_click"), this.rOverSkip, this.rOutSkip, this.clickSkip);
		this.rootCanvas.findName("africa_map_image_load").addEventListener("Completed", Silverlight.createDelegate(this, this.heartBeat));
		this.rootCanvas.findName("africa_heartbeat").addEventListener("Completed", Silverlight.createDelegate(this, this.redStart));
		this.rootCanvas.findName("red_start").addEventListener("Completed", Silverlight.createDelegate(this, this.scrollStart));
        this.rootCanvas.findName("scrolling_text_move").addEventListener("Completed", Silverlight.createDelegate(this, this.logoSwap));
        this.rootCanvas.findName("logo_color_swap").addEventListener("Completed", Silverlight.createDelegate(this, this.logoMove));
        this.rootCanvas.findName("logo_move").addEventListener("Completed", Silverlight.createDelegate(this, this.redRedirect));
    },
    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));
    },
    
    rOverSkip : function(sender, eventArgs) { this.rootCanvas.findName("skip_over").begin(); },
    rOutSkip: function(sender, eventArgs) { this.rootCanvas.findName("skip_out").begin(); },
    clickSkip: function(sender, eventArgs) { window.location = ('/danmark/windows/products/windowsvista/joinred/home.aspx'); },
    
    heartBeat : function(sender, eventArgs) {
        this.rootCanvas.findName("africa_heartbeat").begin();
    }, 
       
    redStart : function(sender, eventArgs) {
        this.rootCanvas.findName("red_start").begin(); 		    
    },
    
    scrollStart : function(sender, eventArgs) {
        this.rootCanvas.findName("scrolling_text_move").begin(); 
    },
    
    logoSwap : function(sender, eventArgs) {
        this.rootCanvas.findName("logo_color_swap").begin();
    }, 
    
    logoMove : function(sender, eventArgs) {
        this.rootCanvas.findName("map_fade").begin();
        this.rootCanvas.findName("logo_move").begin();
    },
        
    redRedirect : function(sender, eventArgs) {
        window.location = ('/danmark/windows/products/windowsvista/joinred/home.aspx');		    
    }

}
