﻿if (!window.UntitledProject1)
	UntitledProject1 = {};

UntitledProject1.Page = function() 
{

}

UntitledProject1.Page.prototype =
{
	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;
		nextStory = null;
		wmvstate = "p";
		
		
		// Sample event hookup:	
		//AnimaÃƒÂ§ÃƒÂ£o BotÃƒÂ£o Mouse Entrando
		this.control.content.findName("btn_wiki").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_time").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_ineta").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_mvps").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_grupos").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_parceiros").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_foruns").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_blogs").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_magazine").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_codeplex").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_msdn").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_technet").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_eventos").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_social").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleMouseEnter));
		this.control.content.findName("btn_msdn_inteiro").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("btn_technet_inteiro").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("btn_video").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));

		// AnimaÃƒÂ§ÃƒÂ£o BotÃƒÂ£o Mouse Saindo
		this.control.content.findName("btn_wiki").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_time").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_ineta").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_mvps").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_grupos").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_foruns").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_parceiros").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_blogs").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_magazine").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_codeplex").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_msdn").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_technet").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_eventos").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		this.control.content.findName("btn_social").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleMouseLeave));
		
		//Eventos Saida
		this.control.content.findName("balao_wiki").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_time").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_ineta").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_mvps").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_grupos").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_foruns").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_parceiros").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_blogs").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_magazine").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_codeplex").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_msdn").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_eventos").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("balao_social").addEventListener("MouseLeave", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));
		this.control.content.findName("gray_area").addEventListener("MouseEnter", Silverlight.createDelegate(this, this.handleDesligaUltimoBalao));

		//links
		this.control.content.findName("link_wiki").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_time").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_ineta").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_mvps").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_grupos").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_foruns").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_parceiros").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_blogs").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_magazine").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_codeplex").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_msdn").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_technet").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_tortato").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLink));
		this.control.content.findName("link_eventos").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("link_social").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));


		this.control.content.findName("btn_wiki").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_time").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_ineta").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_mvps").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_grupos").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_foruns").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_parceiros").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_blogs").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_magazine").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_codeplex").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_msdn").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_technet_inteiro").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_technet").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_eventos").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));
		this.control.content.findName("btn_social").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleFireLinkSelf));

		this.control.content.findName("play").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handlePlay));
		this.control.content.findName("pause").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handlePause));
		this.control.content.findName("previous").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.handleBegin));
		
		this.control.content.findName("balao_time").Visibility = "Collapsed";
		this.control.content.findName("btn_time").Visibility = "Collapsed";

	},
	
	// Sample event handler
	handleBegin: 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("wmv").Stop();
		this.control.content.findName("wmv").Play();

	},

	// Sample event handler
	handlePause: 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("wmv").Pause();
	},

	// Sample event handler
	handlePlay: 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("wmv").Play();
	},

	// Sample event handler
	handleMouseEnter: function(sender, eventArgs) 
	{
		// The following line of code shows how to find an element by name and call a method on it.
		nextStory = AtivaHexagono(sender, this.control);
	},
	
	handleMouseLeave: function(sender, eventArgs) 
	{
		// The following line of code shows how to find an element by name and call a method on it.
		DesativaHexagono(sender, this.control);
	},
	
	handleBalaoMouseLeave: function(sender, eventArgs) 
	{
	    //Some BalÃƒÂ£o
	    b = "anime_out_" + sender.Name.substr(6);
	    this.control.content.findName(b).Begin();
	},

	handleDesligaUltimoBalao: function(sender, eventArgs) 
	{
	    //Some BalÃƒÂ£o
		if(nextStory != null){
		    this.control.content.findName(nextStory).Begin();
			nextStory = null;
		}
	},
	
	handleFireLink: function(sender, eventArgs) 
	{
	    //Some BalÃƒÂ£o
		openNewWindow(sender.Tag);
	},
	
	handleFireLinkSelf: function(sender, eventArgs) 
	{
	    //Some BalÃƒÂ£o
		openWindow(sender.Tag);
	}
	
}

function AtivaHexagono(sender, control)
{
	s = "hex_" + sender.Name.substr(4);
	control.content.findName(s).Stroke =  "#FFFFFF";
	control.content.findName(s).StrokeThickness =  "2";

	//Tras BalÃƒÂ£o
	b = "anime_in_" + sender.Name.substr(4);
   
    if(control.content.findName(b)!= null)
        control.content.findName(b).Begin();
		
	if(nextStory != null){
		control.content.findName(nextStory).Begin();
		nextStory = null;
	}

	return "anime_out_" + sender.Name.substr(4);
}

function DesativaHexagono(sender, control)
{
	s = "hex_" + sender.Name.substr(4);
	control.content.findName(s).StrokeThickness =  "0";
}

function openNewWindow(url) {
  popupWin = window.open(url,
  'open_window',
  'menubar, toolbar, location, directories, status, scrollbars, resizable, dependent, width=700, height=500, left=0, top=0')
}

function openWindow(url) {
  popupWin = window.location(url);
  //window.open(url,
  //'open_window_same',
  //'')
}