/*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="/es/business/profiles/virtualaviation/"><img src="http://images.apple.com/es/business/images/index_hero7.jpg" width="483" height="245" border="0" alt="Virtual Aviation"></a>',
	'<a href="/es/business/profiles/cityinn/"><img src="http://images.apple.com/es/business/images/index_hero6.jpg" width="483" height="245" border="0" alt="City Inn"></a>',
	'<a href="/es/business/profiles/nymphestrandhotel/"><img src="http://images.apple.com/es/business/images/index_hero5.jpg" width="483" height="245" border="0" alt="nymphe strand hotel"></a>', 
	'<a href="/es/business/profiles/carrouxcoffee/"><img src="http://images.apple.com/es/business/images/index_hero4.jpg" width="483" height="245" border="0" alt="Carroux Coffee"></a>', 
	'<a href="/es/business/profiles/mymuesli/"><img src="http://images.apple.com/es/business/images/index_hero3.jpg" width="483" height="245" border="0" alt="mymuesli"></a>', 
	'<a href="/es/business/profiles/booksandlivres/"><img src="http://images.apple.com/es/business/images/index_hero2.jpg" width="483" height="245" border="0" alt="Books &amp; Livres"></a>', 
	'<a href="/es/business/profiles/guidogebhardt/"><img src="http://images.apple.com/es/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/es/business/images/index_macatwork_leopard20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Raz&oacute;n n.&deg; 1: trabaja menos, aumenta tu productividad.</h4>\r<p>Notar&aacute;s enseguida que t&uacute; y tus compa&ntilde;eros, trabaj&aacute;is m&aacute;s y mejor. <a href="/es/business/macatwork/" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>',	
	'<img src="http://images.apple.com/es/business/images/index_macatwork_iwork_20090210.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Raz&oacute;n n.&deg; 2: da rienda suelta a tu creatividad.</h4>\r<p>No le dejes toda la parte divertida a los dise&ntilde;adores. Descubre tu faceta creativa con iLife e iWork. <a href="/es/business/macatwork/#creativity" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>',
	'<img src="http://images.apple.com/es/business/images/index_macatwork_edit20090210.png" width="100" height="114" alt="Leopard" class="right">\r<h4>Raz&oacute;n n.&deg; 3: un mont&oacute;n de extras, sin coste adicional.</h4>\r<p>Los Mac son compactos y sencillos. Nada m&aacute;s sacarlos de la caja, podr&aacute;s hacer mucho m&aacute;s de lo que te imaginas. <a href="/es/business/macatwork/#extras" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>', 
	'<img src="http://images.apple.com/es/business/images/index_macatwork_office20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Raz&oacute;n n.&deg; 4: el Mac es raudo y veloz.</h4>\r<p>Todo lo que necesites hacer para tu empresa, puedes llevarlo a cabo con un Mac. <a href="/es/business/macatwork/#nimble" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>', 
	'<img src="http://images.apple.com/es/business/images/index_macatwork_print20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Raz&oacute;n n.&deg; 5: el Mac se lleva bien con los dem&aacute;s.</h4>\r<p>&iquest;Eres usuario de Mac en un mundo dominado por PC? No te preocupes. Las aplicaciones m&aacute;s frecuentes de Mac y PC usan los mismos formatos de archivo. <a href="/es/business/macatwork/#playwell" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>',
	'<img src="http://images.apple.com/es/business/images/index_macatwork_applecare20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Raz&oacute;n n.&deg; 6: ayuda &uacute;til y accesible.</h4>\r<p>Cuando utilizas un sistema intuitivo, haces poco uso de la asistencia t&eacute;cnica. <a href="/es/business/macatwork/#help" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>',
	'<img src="http://images.apple.com/es/business/images/index_macatwork_imac20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Raz&oacute;n n.&deg; 7: agiliza las cosas, al estilo Mac.</h4>\r<p>Todos los Mac encierran dos armas secretas que les aportan velocidad y seguridad.  <a href="/es/business/macatwork/#pace" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>'
];
var randomizePromoTop = [
	'<a href="/es/macbookair/"><img src="http://images.apple.com/es/business/images/index_heropromo_macbookair.gif" width="73" height="60" border="0" alt="MacBook air"></a>\r<h3><a href="/es/macbookair/">Presentamos al MacBook Air.</a></h3>\r<p>El port&aacute;til m&aacute;s fino del mundo. <a href="/es/macbookair/" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>',				 
	'<a href="/es/macosx/"><img src="http://images.apple.com/es/business/images/index_heropromo_leopard.gif" width="73" height="60" border="0" alt="Leopard"></a>\r<h3><a href="/es/macosx/">Leopard.</a></h3>\r<p>Descubre la versi&oacute;n m&aacute;s impresionante de Mac OS X hasta la fecha. <a href="/es/macosx/" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>', 
	'<a href="/es/iwork/"><img src="http://images.apple.com/es/business/images/index_heropromo_iwork.gif" width="73" height="60" border="0" alt="iWork"></a>\r<h3><a href="/es/iwork/">El nuevo iWork \'08.</a></h3>\r<p>Tratamiento de texto optimizado, presentaciones deslumbrantes y, ahora, hojas de c&aacute;lculo. <a href="/es/iwork/" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>'
];
var randomizePromoBottom = [
	'<a href="/es/macosx/applications/office/"><img src="http://images.apple.com/es/business/images/index_heropromo_office.gif" width="68" height="60" border="0" alt="Office 2008 para Mac."></a>\r<h3><a href="/es/macosx/applications/office/">Office 2008 para Mac.</a></h3>\r<p>M&aacute;s herramientas y mayor compatibilidad con Office 2007 para Windows. <a href="/es/macosx/applications/office/" class="more">M&aacute;s&nbsp;informaci&oacute;n</a></p>',
	'<a href="/es/timecapsule/"><img style="margin-top:8px;" src="http://images.apple.com/es/business/images/index_heropromo_timecapsule.gif" width="73" height="60" border="0" alt="Time Capsule"></a>\r<h3 style="padding-top:12px;"><a href="/es/timecapsule/">Time Capsule:</a></h3>\r<p>un gran paso adelante en las copias de seguridad. <a href="/es/timecapsule/" class="more">M&aacute;s&nbsp;informaci&oacute;n</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'));
});
