﻿if (!window.SilverlightSite1)
	SilverlightSite1 = {};

SilverlightSite1.Page = function() 
{
}

SilverlightSite1.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("Storyboard1").Begin();
	}
}


//Cria objeto Silverlight
function createSilverlightImageRotate()
		{
			var scene = new SilverlightSite1.Page();
			Silverlight.createObjectEx({
				source: "Silverlight/imageRotate.xaml",
				parentElement: document.getElementById("silverlightControlHostImageRotate"),
				id: "SilverlightControl",
				properties: {
					width: "115px",
					height: "172px",
					version: "1.0",
					isWindowless:'true'
				},
				events: {
					onLoad: Silverlight.createDelegate(scene, scene.handleLoad),
					onError: function(sender, args) {
						var errorDiv = document.getElementById("errorLocation");
						if (errorDiv != null) {
							var errorText = args.errorType + "- " + args.errorMessage;
									
							if (args.ErrorType == "ParserError") {
								errorText += "<br>File: " + args.xamlFile;
								errorText += ", line " + args.lineNumber;
								errorText += " character " + args.charPosition;
							}
							else if (args.ErrorType == "RuntimeError") {
								errorText += "<br>line " + args.lineNumber;
								errorText += " character " +  args.charPosition;
							}
							errorDiv.innerHTML = errorText;
						}	
					}
				}
			});
		}

if (!window.Silverlight) 
	Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}
///Cria objeto Silverlight

//Função que chama o Canvas do Silverlight (StoryBoard)
function playScene(sender,eventArgs)
{
	//AdRotator	
	var rand=Math.round(Math.random()*6);
	var img=new Array(7);
    img[0]="0";
	img[1]="1";
	img[2]="2";
	img[3]="3";
	img[4]="4";
	img[5]="5";
	img[6]="6";
	///AdRotator
	
	var myStoryBoard = sender.findName("StoryboardAlpha")
	var mainCanvas = sender.findName("canvasImage");
			
	mainCanvas.findName("Image").Source = "Imagens/dmweb-home_" + img[rand] + ".jpg";
	myStoryBoard.Begin();
}
///Função que chama o Canvas do Silverlight (StoryBoard)