function createSilverlight()
{
	var scene = new DEVELOAD_SV.Page();
	Silverlight.createObjectEx({
		source: "Page.xaml",
		parentElement: document.getElementById("DEVELOAD_Host"),
		id: "DEVELOAD_Host",
		properties: {
			width: "100%",
			height: "100%",
			version: "1.0",
			isWindowless: "True"
		},
		events: {
			onLoad: Silverlight.createDelegate(scene, scene.handleLoad)
		}
	});
}

if (!window.Silverlight) 
	window.Silverlight = {};

Silverlight.createDelegate = function(instance, method) {
	return function() {
		return method.apply(instance, arguments);
	}
}

var MyRoot;
var MainControl;
var VideoGoster;
var YokEdiliyor = false;

if (!window.DEVELOAD_SV)
	window.DEVELOAD_SV = {};

DEVELOAD_SV.Page = function() 
{
}

DEVELOAD_SV.Page.prototype =
{
	handleLoad: function(control, userContext, rootElement) 
	{
		if (window.innerHeight) 
		{          
			$get('DEVELOAD_Host').style.height = window.innerHeight + "px";
		}
		var ScreenWidth = document.getElementById("DEVELOAD_Host").offsetWidth;
		rootElement["Canvas.Left"] = (ScreenWidth - rootElement.width) / 2;
		rootElement.findName('Logos')["Canvas.Top"] = document.getElementById("DEVELOAD_Host").offsetHeight-rootElement.findName('Logos')["Height"]-5;
		document.body.onresize = function (){
			var ScreenWidth = document.getElementById("DEVELOAD_Host").offsetWidth;
			rootElement["Canvas.Left"] = (ScreenWidth - rootElement.width) / 2;
			$get("container").style.left = rootElement["Canvas.Left"] + 30;
			rootElement.findName('Logos')["Canvas.Top"] = document.getElementById("DEVELOAD_Host").offsetHeight-rootElement.findName('Logos')["Height"]-5;
		}
		MyRoot = rootElement;
		MainControl = control;
		selectPage("ANASAYFA");
		PlayStar1();
		PlayStar2();
		VideoKontrolu();
	}
}
function PlayStar1()
{
	MyRoot.findName('Yildiz1').stop();
	MyRoot.findName("Yildiz1").begin();
	setTimeout("PlayStar1();", Math.floor(Math.random()*4000) + 1000);
}
function PlayStar2()
{
	MyRoot.findName('Yildiz2').stop();
	MyRoot.findName("Yildiz2").begin();
	setTimeout("PlayStar2();", Math.floor(Math.random()*3000) + 1000);
}
function  VideoKontrolu()
{
	if (VideoGoster==true)
		{
			if (MyRoot.findName('Video')["Visibility"] != "Visible")
			{
				MyRoot.findName('YanaCekil').begin();
			}
		}
	setTimeout("VideoKontrolu();",4000);
	VideoGoster=true;
}
function YanaCekil_Done()
{
	MyRoot.findName('Video')["Visibility"] = "Visible";
	MyRoot.findName('DemoVideo').stop();
	MyRoot.findName('DemoVideo').play();
	MyRoot.findName('VideoGoster').begin();
}
function MenuOut(sender, args)
{
	var Target = sender.children.getItem(0);
	if (sender.findName(sender.Name + 'MenuOut') == null)
		{
			var SL = sender.getHost();
			var XAMLCode = '<Storyboard xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="' + sender.Name + 'MenuOut"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="' + Target.Name + '" BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)"><SplineDoubleKeyFrame KeyTime="00:00:00" Value="1"/><SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="0.5"/></DoubleAnimationUsingKeyFrames></Storyboard>';
			var Anime = SL.content.createFromXaml(XAMLCode);
			sender.Resources.Add(Anime); 
		}
	sender.findName(sender.Name + 'MenuOut').stop();
	sender.findName(sender.Name + 'MenuOut').begin();
}
function MenuHover(sender, args)
{
	VideoGoster=false;
	var Target = sender.children.getItem(0);
	if (sender.findName(sender.Name + 'MenuHover') == null)
		{
			var SL = sender.getHost();
			var XAMLCode = '<Storyboard xmlns="http://schemas.microsoft.com/client/2007" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Name="' + sender.Name + 'MenuHover"><DoubleAnimationUsingKeyFrames Storyboard.TargetName="' + Target.Name + '" BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Opacity)"><SplineDoubleKeyFrame KeyTime="00:00:00" Value="0.5"/><SplineDoubleKeyFrame KeyTime="00:00:00.5000000" Value="1"/></DoubleAnimationUsingKeyFrames></Storyboard>';
			var Anime = SL.content.createFromXaml(XAMLCode);
			sender.Resources.Add(Anime); 
		}
	sender.findName(sender.Name + 'MenuHover').stop();
	sender.findName(sender.Name + 'MenuHover').begin();
	VideoYoket(sender);
}
function VideoYoket(sender)
{
	if (YokEdiliyor==false)
	{
		if(sender.findName('Video')["Visibility"] == "Visible")
		{
			YokEdiliyor=true;
			sender.findName('VideoSakla').begin();
		}
	}
}
function VideoSaklandi(sender)
{
	sender.findName('Video')["Visibility"] = "Collapsed";
	sender.findName('Buyu').begin();
	sender.findName('DemoVideo').stop();
	YokEdiliyor=false;
}
function PlayAgain(sender)
{
	sender.stop();
	sender.play();
}
function selectPage(ID)
{
	MyRoot.findName('Loading')["Visibility"] = "Visible";
	MyRoot.findName("Yukleniyor").begin();
	PageMethods.GetPage(ID, Tamamlandi)
}
function Tamamlandi(sender)
{
	$get('icerik').innerHTML = sender;
	MyRoot.findName("Yuklendi").begin();
}
function YuklendiAnimTamam(sender)
{
	MyRoot.findName('Loading')["Visibility"] = "Collapsed";
}
function GetSome(sender)
{
	if (sender.Name == "ANASAYFA")
	{
		window.navigate('default.aspx')
	}
	else
	{
		selectPage(sender.Name)	
	}
}
function DemoDone(sender)
{
	VideoYoket(sender);
}
