/*var QuickTip = Class.create();
QuickTip.prototype = {
	initialize: function(qtPanel, qtControlPanel, qtTrigger, qtEndstate) {
		this.qtPanel = $(qtPanel);
		this.qtControlPanel = $(qtControlPanel);
		this.qtTrigger = $(qtTrigger);
		this.qtEndstate = $(qtEndstate);
		this.movieUrl = this.qtTrigger.href;
		this.qtController = null;
		Event.observe(qtTrigger, 'click', this.setupMovie.bindAsEventListener(this));
	},
	
	setupMovie: function(evt) {
		Event.stop(evt);
		var movie = AC.Quicktime.packageMovie('qt-movie', this.movieUrl, {
			width: 640,
			height: 400,
			autoplay: true,
			controller: false,
			cache: true,
			poster: ''
		});
		this.qtEndstate.hide();
		this.qtPanel.innerHTML = '';
		this.qtPanel.appendChild(movie);
		this.qtController = new AC.QuicktimeController(movie, {
			onMoviePlayable: function() {
				this.qtController.monitorMovie();
				this.qtController.Play();
				setTimeout(function() {
					this.qtController.options.onMovieFinished = this.resetMovie.bind(this);
				}.bind(this),1000);
			}.bind(this)
		});
		this.qtController.render(this.qtControlPanel);
		movie = null;
	},
	
	resetMovie: function() {
		this.qtController.options.onMovieFinished = null;
		this.qtController.Stop();
		this.qtControlPanel.innerHTML = '';
		this.qtPanel.innerHTML = '';
		this.qtEndstate.down('.text').innerHTML = 'Watch Again';
		var replay = Builder.node('p', { className:'pillbutton replay' }, [
			Builder.node('a', { href:'/business/theater/'}, [
				Builder.node('span', 'View more Quick Tips'),
				Builder.node('b', '&gt;')
			])
		]);
		this.qtEndstate.appendChild(replay);
		this.qtEndstate.show();
	}
}*/
var heroPromos = [
	'<a href="/pt/business/profiles/virtualaviation/"><img src="http://images.apple.com/pt/business/images/index_hero7.jpg" width="483" height="245" border="0" alt="Virtual Aviation"></a>',
	'<a href="/pt/business/profiles/cityinn/"><img src="http://images.apple.com/pt/business/images/index_hero6.jpg" width="483" height="245" border="0" alt="City Inn"></a>',
	'<a href="/pt/business/profiles/nymphestrandhotel/"><img src="http://images.apple.com/pt/business/images/index_hero5.jpg" width="483" height="245" border="0" alt="nymphe strand hotel"></a>', 
	'<a href="/pt/business/profiles/carrouxcoffee/"><img src="http://images.apple.com/pt/business/images/index_hero4.jpg" width="483" height="245" border="0" alt="Carroux Coffee"></a>', 
	'<a href="/pt/business/profiles/mymuesli/"><img src="http://images.apple.com/pt/business/images/index_hero3.jpg" width="483" height="245" border="0" alt="mymuesli"></a>', 
	'<a href="/pt/business/profiles/booksandlivres/"><img src="http://images.apple.com/pt/business/images/index_hero2.jpg" width="483" height="245" border="0" alt="Books &amp; Livres"></a>', 
	'<a href="/pt/business/profiles/guidogebhardt/"><img src="http://images.apple.com/pt/business/images/index_hero1.jpg" width="483" height="245" border="0" alt="Guido Gebhardt"></a>'

	
];
var imgLoader = new Image();
for(i=0; i<heroPromos.length; i++) {
	imgLoader.src = heroPromos[i].substring(heroPromos[i].indexOf('images/index_hero'), heroPromos[i].indexOf('index_hero')+25);
}

var randomizeWhyMac = [
	'<img src="http://images.apple.com/pt/business/images/index_macatwork_leopard20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Razão nº1: Trabalhe mais, com menos&nbsp;esforço.</h4>\r<p>Rapidamente, irá aperceber-se de que você e os seus funcionários estão a trabalhar com a maior satisfação e eficiência de sempre. <a href="http://www.apple.com/pt/business/macatwork/" class="more">Saber&nbsp;mais</a></p>',	
	'<img src="http://images.apple.com/pt/business/images/index_macatwork_iwork_20090210.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Razão nº2: Liberte a sua criatividade.</h4>\r<p>Não deixe todo o divertimento para os designers. Descubra o seu lado criativo com o iLife e iWork. <a href="http://www.apple.com/pt/business/macatwork/#creativity" class="more">Saber&nbsp;mais</a></p>',
	'<img src="http://images.apple.com/pt/business/images/index_macatwork_edit20090210.png" width="100" height="114" alt="Leopard" class="right">\r<h4>Razão nº3: Os extras n&atilde;o custam nada.</h4>\r<p>Os Macs s&atilde;o integrados e simples &ndash; e mal saem da caixa, fazem ainda mais do que imagina. <a href="http://www.apple.com/pt/business/macatwork/#extras" class="more">Saber&nbsp;mais</a></p>', 
	'<img src="http://images.apple.com/pt/business/images/index_macatwork_office20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Razão nº4: Mac é leve, Mac é veloz.</h4>\r<p>Tudo o que tenha de fazer para a sua empresa, pode fazê-lo num Mac. <a href="http://www.apple.com/pt/business/macatwork/#nimble" class="more">Saber&nbsp;mais</a></p>', 
	'<img src="http://images.apple.com/pt/business/images/index_macatwork_print20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Razão nº5: Os Macs têm uma excelente compatibilidade.</h4>\r<p>Utilizador Mac num mundo PC? Não se preocupe. As aplicações mais populares para Mac e PC utilizam os mesmos formatos de ficheiro. <a href="http://www.apple.com/pt/business/macatwork/#playwell" class="more">Saber&nbsp;mais</a></p>',
	'<img src="http://images.apple.com/pt/business/images/index_macatwork_applecare20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Razão nº6: É fácil encontrar uma boa ajuda.</h4>\r<p>Com um sistema intuitivo, certamente não irá necessitar de assistência. <a href="http://www.apple.com/pt/business/macatwork/#help" class="more">Saber&nbsp;mais</a></p>',
	'<img src="http://images.apple.com/pt/business/images/index_macatwork_imac20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Razão nº7: Acelere o ritmo, ao estilo Mac.</h4>\r<p>Os Macs são fornecidos com duas armas secretas para velocidade e segurança. <a href="http://www.apple.com/pt/business/macatwork/#pace" class="more">Saber&nbsp;mais</a></p>'
];
var randomizePromoTop = [
	'<a href="http://www.apple.com/pt/macbookair/"><img src="http://images.apple.com/pt/business/images/index_heropromo_macbookair.gif" width="73" height="60" border="0" alt="MacBook air"></a>\r<h3><a href="http://www.apple.com/pt/macbookair/">Apresentamos o MacBook Air.</a></h3>\r<p>O computador port&aacute;til mais fino do mundo. <a href="http://www.apple.com/pt/macbookair/" class="more">Saber&nbsp;mais</a></p>',				 
	'<a href="http://www.apple.com/pt/macosx/"><img src="http://images.apple.com/pt/business/images/index_heropromo_leopard.gif" width="73" height="60" border="0" alt="Leopard"></a>\r<h3><a href="http://www.apple.com/pt/macosx/">Leopard.</a></h3>\r<p>Veja as versões do Mac OS X mais impressionantes até ao momento. <a href="http://www.apple.com/pt/macosx/" class="more">Saber&nbsp;mais</a></p>', 
	'<a href="http://www.apple.com/pt/iwork/"><img src="http://images.apple.com/pt/business/images/index_heropromo_iwork.gif" width="73" height="60" border="0" alt="iWork"></a>\r<h3><a href="http://www.apple.com/pt/iwork/">O novo iWork \'08.</a></h3>\r<p>Processamento de texto dinamizado, apresentações espantosas, e agora também folhas de cálculo. <a href="http://www.apple.com/pt/iwork/" class="more">Saber&nbsp;mais</a></p>'
];
var randomizePromoBottom = [
	'<a href="http://www.apple.com/pt/macosx/applications/office/"><img src="http://images.apple.com/pt/business/images/index_heropromo_office.gif" width="68" height="60" border="0" alt="Office 2008 para Mac"></a>\r<h3><a href="http://www.apple.com/pt/macosx/applications/office/">Office 2008 para Mac.</a></h3>\r<p>Mais ferramentas e uma maior compatibilidade com MS Office 2007 para Windows. <a href="http://www.apple.com/pt/macosx/applications/office/" class="more">Saber&nbsp;mais</a></p>',
	'<a href="http://www.apple.com/pt/timecapsule/"><img style="margin-top:8px;" src="http://images.apple.com/pt/business/images/index_heropromo_timecapsule.gif" width="73" height="60" border="0" alt="Time Capsule"></a>\r<h3 style="padding-top:12px;"><a href="http://www.apple.com/pt/timecapsule/">Time Capsule.</a></h3>\r<p>Revolução nas cópias de segurança <a href="http://www.apple.com/pt/timecapsule/" class="more">Saber&nbsp;mais</a></p>'			 
];

Event.onDOMReady(function() {
	new AC.CrossfadeQueue(heroPromos, 'hero-promo');
	// quicktip movie
	//new QuickTip('qt-movie', 'qt-controller', 'qt-trigger', 'qt-endstate');
	
	// solutions swqp
	new AC.ContentSwap('swapnav', 'swapcontent', 'click');

	
	// Why Mac and hero promo randomizers
	if ($('random-tips')) {
		var randNum = Math.floor(Math.random() * (randomizeWhyMac.length));
		$('random-tips').innerHTML = randomizeWhyMac[randNum];
	}
	// 	if ($('index-heropromo-top')) {
	// 		var randNum = Math.floor(Math.random() * (randomizePromoTop.length));
	// 		$('index-heropromo-top').innerHTML = randomizePromoTop[randNum];
	// 	}
	// if ($('index-heropromo-bottom')) {
	//	var randNum = Math.floor(Math.random() * (randomizePromoBottom.length));
	//	$('index-heropromo-bottom').innerHTML = randomizePromoBottom[randNum];
	//  }
	
	// insert profiles
	if($('profiles')) new ShowProfiles($('profiles'));
});
