﻿if (!window.ArtsAndArchitecture)
    window.ArtsAndArchitecture = {};
     
ArtsAndArchitecture.HotSpot = function(control, target, x, y, detailIndex)
{
    this.control = control;
    this.target = target;
    this._detailIndex = detailIndex;
     
    this._hotSpotIcon = this.target.findName("HotSpotIcon");
   
    this._hotSpotIcon.cursor = "Hand";

    //this._timer.addEventListener("Completed", Silverlight.createDelegate(this, this.onMainViewTick));
    this._hotSpotIcon.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleIconMouseEnter));
    this._hotSpotIcon.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleIconMouseLeave));
    this._hotSpotIcon.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleIconMouseLeftButtonDown));
    
    this.target["Canvas.Left"] = x;
    this.target["Canvas.Top"] = y;
}

ArtsAndArchitecture.HotSpot.prototype = 
{

    handleIconMouseEnter: function(sender, args)
    {
        sender.source = "Content/icons/hotspot_active.png";
    },
    
    handleIconMouseLeave: function(sender, args)
    {
        sender.source = "Content/icons/hotspot.png";
    },
    
    handleIconMouseLeftButtonDown: function(sender, args)
    {
        sender.source = "Content/icons/hotspot.png";
        AADetailView.showDetails(this._detailIndex, args.GetPosition(null).x, args.GetPosition(null).y);
    },
    
    getDetailIndex: function()
    {
        return this._detailIndex;
    }

}