/*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="/se/business/profiles/virtualaviation/"><img src="http://images.apple.com/se/business/images/index_hero7.jpg" width="483" height="245" border="0" alt="Virtual Aviation"></a>',
	'<a href="/se/business/profiles/cityinn/"><img src="http://images.apple.com/se/business/images/index_hero6.jpg" width="483" height="245" border="0" alt="City Inn"></a>',
	'<a href="/se/business/profiles/nymphestrandhotel/"><img src="http://images.apple.com/se/business/images/index_hero5.jpg" width="483" height="245" border="0" alt="nymphe strand hotel"></a>', 
	'<a href="/se/business/profiles/carrouxcoffee/"><img src="http://images.apple.com/se/business/images/index_hero4.jpg" width="483" height="245" border="0" alt="Carroux Coffee"></a>', 
	'<a href="/se/business/profiles/mymuesli/"><img src="http://images.apple.com/se/business/images/index_hero3.jpg" width="483" height="245" border="0" alt="mymuesli"></a>', 
	'<a href="/se/business/profiles/booksandlivres/"><img src="http://images.apple.com/se/business/images/index_hero2.jpg" width="483" height="245" border="0" alt="Books &amp; Livres"></a>', 
	'<a href="/se/business/profiles/guidogebhardt/"><img src="http://images.apple.com/se/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/se/business/images/index_macatwork_leopard20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Sk&auml;l 1: Mer jobb, mindre slit.</h4>\r<p>Du och dina kollegor kommer att bli b&aring;de gladare och effektivare p&aring; nolltid. <a href="http://www.apple.com/se/business/macatwork/" class="more">L&auml;s&nbsp;mer</a></p>',	
	'<img src="http://images.apple.com/se/business/images/index_macatwork_iwork_20090210.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Sk&auml;l 2: Sl&auml;pp ut kreativiteten.</h4>\r<p>L&aring;t inte bara formgivarna ha roligt. Uppt&auml;ck din kreativa sida med iLife och iWork. <a href="http://www.apple.com/se/business/macatwork/#creativity" class="more">L&auml;s&nbsp;mer</a></p>',
	'<img src="http://images.apple.com/se/business/images/index_macatwork_edit20090210.png" width="100" height="114" alt="Leopard" class="right">\r<h4>Sk&auml;l 3: Det lilla extra kostar inget extra.</h4>\r<p>Mac-datorerna &auml;r b&aring;de snygga och enkla &ndash; &auml;nd&aring; g&ouml;r de mer &auml;n du kan ana n&auml;r du packar upp dem. <a href="http://www.apple.com/se/business/macatwork/#extras" class="more">L&auml;s&nbsp;mer</a></p>', 
	'<img src="http://images.apple.com/se/business/images/index_macatwork_office20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Sk&auml;l 4:  En Mac &auml;r smart och snabb.</h4>\r<p>Allt du beh&ouml;ver g&ouml;ra &ndash; jobb eller n&ouml;je &ndash; kan du g&ouml;ra p&aring; en Mac. <a href="http://www.apple.com/se/business/macatwork/#nimble" class="more">L&auml;s&nbsp;mer</a></p>', 
	'<img src="http://images.apple.com/se/business/images/index_macatwork_print20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Sk&auml;l 5: Mac-datorer funkar &ouml;verallt.</h4>\r<p>&Auml;r du Mac-anv&auml;ndare i en PC-v&auml;rld? Oroa dig inte. De vanliga programmen f&ouml;r Mac och PC anv&auml;nder samma filformat. <a href="http://www.apple.com/se/business/macatwork/#playwell" class="more">L&auml;s&nbsp;mer</a></p>',
	'<img src="http://images.apple.com/se/business/images/index_macatwork_applecare20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Sk&auml;l 6: R&auml;tt hj&auml;lp &ndash; snabbt och enkelt.</h4>\r<p>Med ett intuitivt system &auml;r det inte ofta du beh&ouml;ver hj&auml;lp, men om det beh&ouml;vs &auml;r hj&auml;lpen alltid n&auml;ra. <a href="http://www.apple.com/se/business/macatwork/#help" class="more">L&auml;s&nbsp;mer</a></p>',
	'<img src="http://images.apple.com/se/business/images/index_macatwork_imac20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Sk&auml;l 7: Bli effektiv med Mac.</h4>\r<p>Mac-datorerna &auml;r b&aring;de snabba, enkla och oerh&ouml;rt s&auml;kra. <a href="http://www.apple.com/se/business/macatwork/#pace" class="more">L&auml;s&nbsp;mer</a></p>'
];
var randomizePromoTop = [
	'<a href="http://www.apple.com/se/macbookair/"><img src="http://images.apple.com/se/business/images/index_heropromo_macbookair.gif" width="73" height="60" border="0" alt="MacBook air"></a>\r<h3><a href="http://www.apple.com/se/macbookair/">Vi presenterar MacBook Air.</a></h3>\r<p>V&auml;rldens tunnaste b&auml;rbara. <a href="http://www.apple.com/se/macbookair/" class="more">L&auml;s&nbsp;mer</a></p>',				 
	'<a href="http://www.apple.com/se/macosx/"><img src="http://images.apple.com/se/business/images/index_heropromo_leopard.gif" width="73" height="60" border="0" alt="Leopard"></a>\r<h3><a href="http://www.apple.com/se/macosx/">Leopard.</a></h3>\r<p>Se den mest imponerande Mac OS X-versionen hittills. <a href="http://www.apple.com/se/macosx/" class="more">L&auml;s&nbsp;mer</a></p>', 
	'<a href="http://www.apple.com/se/iwork/"><img src="http://images.apple.com/se/business/images/index_heropromo_iwork.gif" width="73" height="60" border="0" alt="iWork"></a>\r<h3><a href="http://www.apple.com/se/iwork/">Nya iWork &lsquo;08.</a></h3>\r<p>Smidig ordbehandling, imponerande presentationer och nu kalkylblad. <a href="http://www.apple.com/se/iwork/" class="more">L&auml;s&nbsp;mer</a></p>'
];
var randomizePromoBottom = [
	'<a href="http://www.apple.com/se/macosx/applications/office/"><img src="http://images.apple.com/se/business/images/index_heropromo_office.gif" width="68" height="60" border="0" alt="Office 2008 f&ouml;r Mac"></a>\r<h3><a href="http://www.apple.com/se/macosx/applications/office/">Office 2008 f&ouml;r Mac.</a></h3>\r<p>Fler verktyg och b&auml;ttre kompatibilitet med MS Office 2007 f&ouml;r Windows. <a href="http://www.apple.com/se/macosx/applications/office/" class="more">L&auml;s&nbsp;mer</a></p>',
	'<a href="http://www.apple.com/se/timecapsule/"><img style="margin-top:8px;" src="http://images.apple.com/se/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/se/timecapsule/">Time Capsule.</a></h3>\r<p>Ett framsteg inom s&auml;kerhetskopiering. <a href="http://www.apple.com/se/timecapsule/" class="more">L&auml;s&nbsp;mer</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'));
});
