﻿if (!window.TesteSalvattore)
	TesteSalvattore = {};

TesteSalvattore.Page = function() 
{
}

TesteSalvattore.Page.prototype =
{
	ctrlFndName: function(a){ return this.control.content.findName(a); },

	handleLoad: function(control, userContext, rootElement) 
	{
		this.control = control;
		
		pgN = 5;
		pgA = 1;	
		
		pg1 = this.ctrlFndName("pg1");
		pg2 = this.ctrlFndName("pg2");
		pg3 = this.ctrlFndName("pg3");
		pg4 = this.ctrlFndName("pg4");
		pg5 = this.ctrlFndName("pg5");

		p2_q1 = this.ctrlFndName("p2_q1");
		b2_q1 = this.ctrlFndName("b2_q1");
		b2_q1_x = this.ctrlFndName("b2_q1_x");
		p2_q2 = this.ctrlFndName("p2_q2");
		b2_q2 = this.ctrlFndName("b2_q2");
		b2_q2_x = this.ctrlFndName("b2_q2_x");
		
		p3_q1 = this.ctrlFndName("p3_q1");
		b3_q1 = this.ctrlFndName("b3_q1");
		b3_q1_x = this.ctrlFndName("b3_q1_x");
		p3_q2 = this.ctrlFndName("p3_q2");
		b3_q2 = this.ctrlFndName("b3_q2");
		b3_q2_x = this.ctrlFndName("b3_q2_x");
		p3_q3 = this.ctrlFndName("p3_q3");
		b3_q3 = this.ctrlFndName("b3_q3");
		b3_q3_x = this.ctrlFndName("b3_q3_x");
		p3_q4 = this.ctrlFndName("p3_q4");
		b3_q4 = this.ctrlFndName("b3_q4");
		b3_q4_x = this.ctrlFndName("b3_q4_x");




		b2_q1.Opacity = '0';
		b2_q2.Opacity = '0';
        
		b3_q1.Opacity = '0';
		b3_q2.Opacity = '0';
		b3_q3.Opacity = '0';
		b3_q4.Opacity = '0';

		
		
		pgNum = this.ctrlFndName("pgNum");
		
		pgAnt = this.ctrlFndName("pgAnt");
		pgProx = this.ctrlFndName("pgProx");
		
		this.definePg(1);
		

		// Eventos Paginação/Balões
		pgAnt.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.antPg));
		pgProx.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.proxPg));

		p2_q1.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.showBal));
		b2_q1_x.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.hideBal));
		p2_q2.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.showBal));
		b2_q2_x.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.hideBal));
		
		p3_q1.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.showBal));
		b3_q1_x.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.hideBal));
		p3_q2.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.showBal));
		b3_q2_x.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.hideBal));
		p3_q3.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.showBal));
		b3_q3_x.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.hideBal));
		p3_q4.addEventListener("MouseEnter", Silverlight.createDelegate(this, this.showBal));
		b3_q4_x.addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.hideBal));
		

		
			
		// Links | Texto e URLS
		/* */


	    // Página 2

		this.ctrlFndName("b2_q2_lnk1").Text = "Plataforma Microsoft - A virtualização como aliada";
		this.ctrlFndName("b2_q2_lnk1").Tag = "../virtualizacao/vtCenario.aspx";
		this.ctrlFndName("b2_q2_lnk2").Text = "Virtualização e Consolidação Com o Hyper-V";
		this.ctrlFndName("b2_q2_lnk2").Tag = "http://www.microsoft.com/brasil/servidores/windowsserver2008/virtualization/default.mspx";
		this.ctrlFndName("b2_q2_lnk3").Text = "Microsoft Hyper-V Server 2008";
		this.ctrlFndName("b2_q2_lnk3").Tag = "http://www.microsoft.com/brasil/servidores/hyper-v-server/default.mspx";

		this.ctrlFndName("b2_q1_lnk1").Text = "Otimize Sua Infraestrutura de TI";
		this.ctrlFndName("b2_q1_lnk1").Tag = "http://www.microsoft.com/brasil/servidores/optimization.mspx";
		this.ctrlFndName("b2_q1_lnk2").Text = "Plataforma Microsoft - Os benefícios da virtualização";
		this.ctrlFndName("b2_q1_lnk2").Tag = "../virtualizacao/vtBenef.aspx";
	
	
		// Página 3

		this.ctrlFndName("b3_q1_lnk1").Text = "Plataforma Microsoft - Novo Windows Server 2008";
		this.ctrlFndName("b3_q1_lnk1").Tag = "../otimizacaoIF/oiWindows.aspx";	
		this.ctrlFndName("b3_q1_lnk2").Text = "Windows Server 2008 R2";
		this.ctrlFndName("b3_q1_lnk2").Tag = "http://www.microsoft.com/brasil/servidores/windowsserver2008/default.mspx";
		this.ctrlFndName("b3_q1_lnk3").Text = "Plataforma Microsoft - Otimização de redes e segurança";
		this.ctrlFndName("b3_q1_lnk3").Tag = "../otimizacaoIF/oiRedes.aspx";

		this.ctrlFndName("b3_q2_lnk1").Text = "Plataforma Microsoft - Modelo de Otimização";
		this.ctrlFndName("b3_q2_lnk1").Tag = "../otimizacaoIF/oiOtim.aspx";
		this.ctrlFndName("b3_q2_lnk2").Text = "Plataforma Microsoft - Otimização de redes e segurança";
		this.ctrlFndName("b3_q2_lnk2").Tag = "../otimizacaoIF/oiRedes.aspx";
		this.ctrlFndName("b3_q2_lnk3").Text = "Plataforma Microsoft - Comunicações Unificadas";
		this.ctrlFndName("b3_q2_lnk3").Tag = "../comUnif/";

		this.ctrlFndName("b3_q3_lnk1").Text = "Plataforma Microsoft - Otimização de infra-estrutura";
		this.ctrlFndName("b3_q3_lnk1").Tag = "otimizacaoIF/oiCenario.aspx";

		this.ctrlFndName("b3_q4_lnk1").Text = "Windows Server 2008 R2";
		this.ctrlFndName("b3_q4_lnk1").Tag = "http://www.microsoft.com/brasil/servidores/windowsserver2008/default.mspx"
		this.ctrlFndName("b3_q4_lnk2").Text = "Plataforma Microsoft - Novo Windows Server 2008";
		this.ctrlFndName("b3_q4_lnk2").Tag = "../otimizacaoIF/oiWindows.aspx";
		this.ctrlFndName("b3_q4_lnk3").Text = "Plataforma Microsoft - Gerenciamento de Estações";
		this.ctrlFndName("b3_q4_lnk3").Tag = "../otimizacaoIF/oiGerBase.aspx";
		this.ctrlFndName("b3_q4_lnk4").Text = "Microsoft System Center";
		this.ctrlFndName("b3_q4_lnk4").Tag = "http://www.microsoft.com/brasil/servidores/systemcenter/default.mspx";	
		this.ctrlFndName("b3_q4_lnk5").Text = "Microsoft System Center - Visão geral";
		this.ctrlFndName("b3_q4_lnk5").Tag = "http://www.microsoft.com/brasil/servidores/systemcenter/overview/default.mspx";

		this.ctrlFndName("lnkAnterior_1").Tag = "Salvattore_01.aspx";
		this.ctrlFndName("lnkAnterior_2").Tag = "Salvattore_02.aspx";
		this.ctrlFndName("lnkAnterior_3").Tag = "Salvattore_03.aspx";
		this.ctrlFndName("lnkAnterior_4").Tag = "Salvattore_04.aspx";
		this.ctrlFndName("lnkAnterior_5").Tag = "Salvattore_05.aspx";
		this.ctrlFndName("lnkAnterior_6").Tag = "Salvattore_06.aspx";
		this.ctrlFndName("lnkAnterior_7").Tag = "Salvattore_07.aspx";

		// Links | Eventos
		this.ctrlFndName("b2_q2_lnk1").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b2_q2_lnk2").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b2_q2_lnk3").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));

		this.ctrlFndName("b2_q1_lnk1").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b2_q1_lnk2").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
          
		this.ctrlFndName("b3_q1_lnk1").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b3_q1_lnk2").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b3_q1_lnk3").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));

		this.ctrlFndName("b3_q2_lnk1").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b3_q2_lnk2").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b3_q2_lnk3").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));

		this.ctrlFndName("b3_q3_lnk1").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));

		this.ctrlFndName("b3_q4_lnk1").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b3_q4_lnk2").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b3_q4_lnk3").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b3_q4_lnk4").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("b3_q4_lnk5").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
    
		this.ctrlFndName("lnkAnterior_1").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("lnkAnterior_2").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("lnkAnterior_3").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("lnkAnterior_4").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("lnkAnterior_5").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("lnkAnterior_6").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));
		this.ctrlFndName("lnkAnterior_7").addEventListener("MouseLeftButtonDown", Silverlight.createDelegate(this, this.getURL));


	},
	// Get URL
	getURL: function(sender, eventArgs){
		//window.location = sender.Tag;
		if(sender.Tag.substr(0,4) == "http") window.open(sender.Tag);
		else window.location = sender.Tag;
	},

	// Define página
	definePg: function(x){
		for(i=0; i < pgN; i++){
			this.control.content.findName("pg"+(i+1)).Opacity = "0";
			this.control.content.findName("pg"+(i+1))["Canvas.ZIndex"] = 0;
		}
		this.control.content.findName("pg"+x).Opacity = "1";
		this.control.content.findName("pg"+x)["Canvas.ZIndex"] = 1;
		pgA = x;
		if(pgA == 1) pgAnt.Opacity = "0.4";
		if(pgA == pgN) pgProx.Opacity = "0.4";

	},
	proxPg: function(sender, eventArgs){
		pgAnt.Opacity = "1";
		if (pgA < pgN){
			for(i=0; i < pgN; i++){
				this.control.content.findName("pg"+(i+1)).Opacity = "0";
				this.control.content.findName("pg"+(i+1))["Canvas.ZIndex"] = 0;
			}
			this.control.content.findName("pg"+(++pgA)).Opacity = "1";
			this.control.content.findName("pg"+pgA)["Canvas.ZIndex"] = 1;
			pgNum.Text = pgA + "";
			if(pgA == pgN) pgProx.Opacity = "0.4";
			else pgProx.Opacity = "1";
		}
	},
	antPg: function(sender, eventArgs){
		pgProx.Opacity = "1";
		if (pgA > 1){
			for(i=0; i < pgN; i++){
				this.control.content.findName("pg"+(i+1)).Opacity = "0";
				this.control.content.findName("pg"+(i+1))["Canvas.ZIndex"] = 0;
			}
			this.control.content.findName("pg"+(--pgA)).Opacity = "1";
			this.control.content.findName("pg"+pgA)["Canvas.ZIndex"] = 1;
			pgNum.Text = pgA + "";
			if(pgA == 1) pgAnt.Opacity = "0.4";
			else pgAnt.Opacity = "1";
		}
	},
	
	// Esconde/mostra balão
	hideBal: function(sender, eventArgs){
		this.control.content.findName(sender.Name.substr(0,5)).Opacity = 0;
	},
	showBal: function(sender, eventArgs){
		eds = "b" + sender.Name.substr(1,4);
		JSTweener.addTween(this.control.content.findName(eds), {
		      time: 0.3,
		      transition: 'easeoutexpo',
		      Opacity: 0.9
		  });

	}
	

}