if (!window.UntitledProject34)
window.UntitledProject34 = {};

UntitledProject34.Page = function()
{
}

UntitledProject34.Page.prototype =
{
handleLoad: function(control, userContext, rootElement)
{
this.control = control;

// Sample event hookup:
rootElement.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleMouseDown));
},

// Sample event handler
handleMouseDown: function(sender, eventArgs)
{
// The following line of code shows how to find an element by name and call a method on it.
// this.control.content.findName("Timeline1").Begin();
}
}

function rootCanvasLoaded(sender)
{
sender.findName("load_text").text="Put me on a pearch";

sender.findName("YouTubeToucanTwostep_wmv").stop();


}





// Define state variables for drag and drop operation.
var beginX;
var beginY;
var isMouseDown = false;

// Start drag and drop operation.
function onMouseDown(sender, mouseEventArgs)
{
// Set the beginning position of the mouse.
beginX = mouseEventArgs.getPosition(null).x;
beginY = mouseEventArgs.getPosition(null).y;
sender.findName("ouch").Visibility="collapsed";
sender.findName("shadow2").Visibility="collapsed";
sender.findName("shadow3").Visibility="collapsed";
sender.findName("load_text").Visibility="collapsed";
sender.findName("MOON").Visibility="collapsed";

isMouseDown = true;

// Ensure this object is the only one receiving mouse events.
sender.captureMouse();
}

// Reposition object during drag and drop operation.
function onMouseMove(sender, mouseEventArgs)
{
// Determine whether the mouse button is down.
// If so, move the object.
if (isMouseDown == true)
{
// Retrieve the current position of the mouse.
var currX = mouseEventArgs.getPosition(null).x;
var currY = mouseEventArgs.getPosition(null).y;
sender.findName("vid").Visibility="collapsed";
sender.findName("YouTubeToucanTwostep_wmv").stop();

// Reset the location of the object.
sender["Canvas.Left"] += currX - beginX;
sender["Canvas.Top"] += currY - beginY;

// Update the beginning position of the mouse.
beginX = currX;
beginY = currY;
}
}

// Stop drag and drop operation.
function onMouseUp(sender, mouseEventArgs)
{
var itemName = sender["name"];
//alert (itemName);


var currX = mouseEventArgs.getPosition(null).x;
var currY = mouseEventArgs.getPosition(null).y;



if(itemName == "toucan")
{
// targer zone logic for the pearch
if (currX >= 230 && currX < 315 && currY >= 275 && currY < 360)
{

sender.findName("shadow3").Visibility="Visible";

sender["Canvas.Top"]=267;
sender["Canvas.Left"]=253;
sender.findName("vid").Visibility="Visible";
sender.findName("YouTubeToucanTwostep_wmv").play();

}


//target zone logic for the ring
else if (currX >= 85 && currX < 210 && currY >= 134 && currY < 250)
{

sender.findName("shadow2").Visibility="Visible";
sender.findName("MOON").Visibility="Visible";
sender["Canvas.Top"]=151.977;
sender["Canvas.Left"]=121;

}

// targer zone logic for the wall stand
else if (currX >= 12 && currX < 81 && currY >= 200 && currY < 350)
{

//sender.findName("shadow3").Visibility="Visible";

sender.findName("balloontext").text="Food!";
sender.findName("ouch").Visibility="Visible";

sender["Canvas.Top"]=211.977;
sender["Canvas.Left"]=43;

}

else {

sender["Canvas.Top"]=378.977;


if (currY <= 355)
{
sender.findName("balloontext").text="OW!";
sender.findName("ouch").Visibility="Visible";
}



}



}



isMouseDown = false;

// Allow all objects to receive mouse events.
sender.releaseMouseCapture();
}



function BeginAni(sender, args)
{
sender.findName("Timeline2").begin();
sender.findName("MOON").Visibility="collapsed";
sender.findName("SUN").Visibility="Visible";
sender.findName("night").Visibility="Visible";
//sender.findName("Timeline2").duration=00:00:01;

}

function BeginAni2(sender, args)
{
sender.findName("Timeline3").begin();
sender.findName("SUN").Visibility="collapsed";
//sender.findName("Timeline3").duration=00:00:01;
sender.findName("night").Visibility="collapsed";
}