﻿if (!window.MouseEnter_ToolTip)
	window.MouseEnter_ToolTip = {};

MouseEnter_ToolTip.Page = function() 
{
}

MouseEnter_ToolTip.Page.prototype =
{
	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;
		
		// event handlers for buttons	
		this.Btn1 = control.content.findName("cvsBtn1");
		this.Btn1.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleButtonMouseEnter));
		this.Btn1.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleButtonMouseLeave));
		this.Btn2 = control.content.findName("cvsBtn2");
		this.Btn2.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleButtonMouseEnter));
		this.Btn2.addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleButtonMouseLeave));
		
		this.dl = control.content.findName("cvsDownload");
		this.dl.addEventListener("MouseLeftButtonUp", Silverlight.createDelegate(this, this.handleDownload));
		
	},
	handleDownload: function(sender, eventArgs) 
	{
		window.location = "MouseEnter_ToolTip.zip";
	},
	// Sample event handler
	handleButtonMouseEnter: function(sender, eventArgs) 
	{
		// shows the tooltip
		// gets the sender's name which will be the canvas that holds the button
		var BtnID = sender.Name;
		// gets the corresponding tooltip textblock
		BtnID = BtnID.replace("cvsBtn", "txtToolTip");
		// sets the text dynamically (optional)
		sender.findName(BtnID)["Text"] = "Tool Tip Text Goes Here for " + BtnID;
		// show the tooltip textblock
		this.control.content.findName(BtnID).Visibility = "Visible";
	},
	handleButtonMouseLeave: function(sender, eventArgs) 
	{
		// hides the tooltip
		// gets the sender's name which will be the canvas that holds the button
		var BtnID = sender.Name;
		// gets the corresponding tooltip textblock
		BtnID = BtnID.replace("cvsBtn", "txtToolTip");
		// clears the text
		sender.findName(BtnID)["Text"].clear;
		// hide the tooltip textblock
		this.control.content.findName(BtnID).Visibility = "Collapsed";
	}
}