/*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="/fi/business/profiles/virtualaviation/"><img src="http://images.apple.com/fi/business/images/index_hero7.jpg" width="483" height="245" border="0" alt="Virtual Aviation"></a>',
	'<a href="/fi/business/profiles/cityinn/"><img src="http://images.apple.com/fi/business/images/index_hero6.jpg" width="483" height="245" border="0" alt="City Inn"></a>',
	'<a href="/fi/business/profiles/nymphestrandhotel/"><img src="http://images.apple.com/fi/business/images/index_hero5.jpg" width="483" height="245" border="0" alt="nymphe strand hotel"></a>', 
	'<a href="/fi/business/profiles/carrouxcoffee/"><img src="http://images.apple.com/fi/business/images/index_hero4.jpg" width="483" height="245" border="0" alt="Carroux Coffee"></a>', 
	'<a href="/fi/business/profiles/mymuesli/"><img src="http://images.apple.com/fi/business/images/index_hero3.jpg" width="483" height="245" border="0" alt="mymuesli"></a>', 
	'<a href="/fi/business/profiles/booksandlivres/"><img src="http://images.apple.com/fi/business/images/index_hero2.jpg" width="483" height="245" border="0" alt="Books &amp; Livres"></a>', 
	'<a href="/fi/business/profiles/guidogebhardt/"><img src="http://images.apple.com/fi/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/fi/business/images/index_macatwork_leopard20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Syy 1: Ty&ouml;skentele tehokkaammin.</h4>\r<p>Toteat nopeasti, ett&auml; sin&auml; ja ty&ouml;ntekij&auml;si ty&ouml;skentelette tyytyv&auml;isempin&auml; ja tehokkaammin kuin koskaan ennen. <a href="http://www.apple.com/fi/business/macatwork/" class="more">Lis&auml;tietoja</a></p>',	
	'<img src="http://images.apple.com/fi/business/images/index_macatwork_iwork_20090210.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Syy 2: Vapauta luovuutesi.</h4>\r<p>&Auml;l&auml; j&auml;t&auml; kaikkea hauskuutta vain suunnittelijoille. L&ouml;yd&auml; oma luova puolesi iLifella ja iWorkilla. <a href="http://www.apple.com/fi/business/macatwork/#creativity" class="more">Lis&auml;tietoja</a></p>',
	'<img src="http://images.apple.com/fi/business/images/index_macatwork_edit20090210.png" width="100" height="114" alt="Leopard" class="right">\r<h4>Syy 3: Ekstrat eiv&auml;t maksa ylim&auml;&auml;r&auml;ist&auml;.</h4>\r<p>Macit ovat virtaviivaisia ja yksinkertaisia, mutta pystyv&auml;t heti k&auml;ttelyss&auml; enemp&auml;&auml;n kuin ehk&auml; osasit odottaakaan. <a href="http://www.apple.com/fi/business/macatwork/#extras" class="more">Lis&auml;tietoja</a></p>', 
	'<img src="http://images.apple.com/fi/business/images/index_macatwork_office20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Syy 4:  Mac on n&auml;pp&auml;r&auml; ja nopea.</h4>\r<p>Voit tehd&auml; kaiken yrityksess&auml;si tarvittavan Macilla. <a href="http://www.apple.com/fi/business/macatwork/#nimble" class="more">Lis&auml;tietoja</a></p>', 
	'<img src="http://images.apple.com/fi/business/images/index_macatwork_print20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Syy 5: Mac toimii kiltisti muiden kanssa.</h4>\r<p>Mac-k&auml;ytt&auml;j&auml;n&auml; PC-maailmassa? Ei h&auml;t&auml;&auml;. Useimmat Mac- ja PC-ohjelmat k&auml;ytt&auml;v&auml;t samoja tiedostomuotoja. <a href="http://www.apple.com/fi/business/macatwork/#playwell" class="more">Lis&auml;tietoja</a></p>',
	'<img src="http://images.apple.com/fi/business/images/index_macatwork_applecare20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Syy 6: Kunnon apu l&ouml;ytyy helposti.</h4>\r<p>Intuitiivisen j&auml;rjestelm&auml;n kanssa et joudu usein etsim&auml;&auml;n apua. <a href="http://www.apple.com/fi/business/macatwork/#help" class="more">Lis&auml;tietoja</a></p>',
	'<img src="http://images.apple.com/fi/business/images/index_macatwork_imac20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Syy 7: Lis&auml;&auml; nopeutta Mac-tyylill&auml;.</h4>\r<p>Maceissa on kaksi salaista asetta nopeuden ja turvallisuuden takaamiseksi. <a href="http://www.apple.com/fi/business/macatwork/#pace" class="more">Lis&auml;tietoja</a></p>'
];
var randomizePromoTop = [
	'<a href="http://www.apple.com/fi/macbookair/"><img src="http://images.apple.com/fi/business/images/index_heropromo_macbookair.gif" width="73" height="60" border="0" alt="MacBook air"></a>\r<h3><a href="http://www.apple.com/fi/macbookair/">Esittelyss&auml; MacBook Air.</a></h3>\r<p>Maailman ohuin kannettava. <a href="http://www.apple.com/fi/macbookair/" class="more">Lis&auml;tietoja</a></p>',				 
	'<a href="http://www.apple.com/fi/macosx/"><img src="http://images.apple.com/fi/business/images/index_heropromo_leopard.gif" width="73" height="60" border="0" alt="Leopard"></a>\r<h3><a href="http://www.apple.com/fi/macosx/">Leopard.</a></h3>\r<p>Tutustu kaikkien aikojen vaikuttavimpaan OS X -versioon. <a href="http://www.apple.com/fi/macosx/" class="more">Lis&auml;tietoja</a></p>', 
	'<a href="http://www.apple.com/fi/iwork/"><img src="http://images.apple.com/fi/business/images/index_heropromo_iwork.gif" width="73" height="60" border="0" alt="iWork"></a>\r<h3><a href="http://www.apple.com/fi/iwork/">Uusi iWork \'08.</a></h3>\r<p>Virtaviivaistettua tekstink&auml;sittely&auml;, upeita esityksi&auml; ja nyt my&ouml;s laskentataulukoita. <a href="http://www.apple.com/fi/iwork/" class="more">Lis&auml;tietoja</a></p>'
];
var randomizePromoBottom = [
	'<a href="http://www.apple.com/fi/macosx/applications/office/"><img src="http://images.apple.com/fi/business/images/index_heropromo_office.gif" width="68" height="60" border="0" alt="Office 2008 for Mac"></a>\r<h3><a href="http://www.apple.com/fi/macosx/applications/office/">Office 2008 for Mac.</a></h3>\r<p>Enemm&auml;n ty&ouml;kaluja ja parempi yhteensopivuus Windosin MS Office 2007:n kanssa. <a href="http://www.apple.com/fi/macosx/applications/office/" class="more">Lis&auml;tietoja</a></p>',
	'<a href="http://www.apple.com/fi/timecapsule/"><img style="margin-top:8px;" src="http://images.apple.com/fi/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/fi/timecapsule/">Time Capsule.</a></h3>\r<p>Suuri askel varmuuskopioinnille <a href="http://www.apple.com/fi/timecapsule/" class="more">Lis&auml;tietoja</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'));
});
