﻿if (!window.SilverlightHomePage)
	window.SilverlightHomePage = {};

SilverlightHomePage.Scene = function() 
{
}

SilverlightHomePage.Scene.prototype =
{
    handleLoad: function(plugIn, userContext, rootElement) {
        this.plugIn = plugIn;

        // Sample button event hookup: Find the button and then attach event handlers
        this.root = rootElement;

        //this.button.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
        this.root.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMouseDown));
        //this.button.addEventListener("MouseLeftButtonUp", Silverlight.createDelegate(this, this.handleMouseUp));
        //this.button.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
    },

    // Sample event handlers
    handleMouseEnter: function(sender, eventArgs) {
        // The following code shows how to find an element by name and call a method on it.
        var mouseEnterAnimation = sender.findName("mouseEnter");
        mouseEnterAnimation.begin();
    },

    handleMouseDown: function(sender, evt) {
        var e = evt || window.event;
        this.soccertransl = sender.findName('SoccerTransl');

        this.soccertransl.X = e.GetPosition(this.root).X; 
        this.soccertransl.Y = e.GetPosition(this.root).Y;

        //var posX = eventArgs.screenX;
        //var posY = eventArgs.screenY;
        //alert(posX);
        //alert(posY); 
        //this.soccertransl.X = posX;
        //this.soccertransl.Y = posY;
    },

    handleMouseUp: function(sender, eventArgs) {
        var mouseUpAnimation = sender.findName("mouseUp");
        mouseUpAnimation.begin();

        // Put clicked logic here
        alert("clicked");
    },

    handleMouseLeave: function(sender, eventArgs) {
        var mouseLeaveAnimation = sender.findName("mouseLeave");
        mouseLeaveAnimation.begin();
    }
}