/*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="/pl/business/profiles/virtualaviation/"><img src="http://images.apple.com/pl/business/images/index_hero7.jpg" width="483" height="245" border="0" alt="Virtual Aviation"></a>',
	'<a href="/pl/business/profiles/cityinn/"><img src="http://images.apple.com/pl/business/images/index_hero6.jpg" width="483" height="245" border="0" alt="City Inn"></a>',
	'<a href="/pl/business/profiles/nymphestrandhotel/"><img src="http://images.apple.com/pl/business/images/index_hero5.jpg" width="483" height="245" border="0" alt="nymphe strand hotel"></a>', 
	'<a href="/pl/business/profiles/carrouxcoffee/"><img src="http://images.apple.com/pl/business/images/index_hero4.jpg" width="483" height="245" border="0" alt="Carroux Coffee"></a>', 
	'<a href="/pl/business/profiles/mymuesli/"><img src="http://images.apple.com/pl/business/images/index_hero3.jpg" width="483" height="245" border="0" alt="mymuesli"></a>', 
	'<a href="/pl/business/profiles/booksandlivres/"><img src="http://images.apple.com/pl/business/images/index_hero2.jpg" width="483" height="245" border="0" alt="Books &amp; Livres"></a>', 
	'<a href="/pl/business/profiles/guidogebhardt/"><img src="http://images.apple.com/pl/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/pl/business/images/index_macatwork_leopard20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Pow&oacute;d 1: Zr&oacute;b wi&#281;cej, pracuj mniej.</h4>\r<p>Ani si&#281; obejrzysz, jak Ty i Twoi pracownicy b&#281;dziecie pracowa&#263; szybciej i z wi&#281;ksz&#261; satysfakcj&#261; ni&#380; dot&#261;d. <a href="/pl/business/macatwork/" class="more">Wi&#281;cej informacji</a></p>',	
	'<img src="http://images.apple.com/pl/business/images/index_macatwork_iwork_20090210.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Pow&oacute;d 2: Uwolnij swoj&#261; kreatywno&#347;&#263;.</h4>\r<p>Nie zostawiaj wszystkich atrakcji grafikom. Odkryj kreatywn&#261; stron&#281; swojej osobowo&#347;ci dzi&#281;ki iLife oraz iWork. <a href="/pl/business/macatwork/#creativity" class="more">Wi&#281;cej informacji</a></p>',
	'<img src="http://images.apple.com/pl/business/images/index_macatwork_edit20090210.png" width="100" height="114" alt="Leopard" class="right">\r<h4>Pow&oacute;d 3: Nie p&#322;acisz dodatkowo za dodatki.</h4>\r<p>Komputery Mac s&#261; proste &mdash; ale zaraz po wyj&#281;ciu z pude&#322;ka okazuje si&#281;, &#380;e potrafi&#261; wi&#281;cej, ni&#380; si&#281; spodziewasz. <a href="/pl/business/macatwork/#extras" class="more">Wi&#281;cej informacji</a></p>', 
	'<img src="http://images.apple.com/pl/business/images/index_macatwork_office20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Pow&oacute;d 4:  Tak czy siak, zawsze Mac. Na ka&#380;d&#261; okazj&#281;.</h4>\r<p>Cokolwiek musisz zrobi&#263; dla swojej firmy, zrobisz to na Macintoshu. <a href="/pl/business/macatwork/#nimble" class="more">Wi&#281;cej informacji</a></p>', 
	'<img src="http://images.apple.com/pl/business/images/index_macatwork_print20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Pow&oacute;d 5: Macintoshe s&#261; otwarte na wsp&oacute;&#322;prac&#281;.</h4>\r<p>U&#380;ytkownik komputera Mac w &#347;wiecie PC? Bez obaw. Najpopularniejsze programy dla komputer&oacute;w Mac i PC korzystaj&#261; z tych samych format&oacute;w plik&oacute;w. <a href="/pl/business/macatwork/#playwell" class="more">Wi&#281;cej informacji</a></p>',
	'<img src="http://images.apple.com/pl/business/images/index_macatwork_imac20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Pow&oacute;d 6: Nie zostawaj w tyle.</h4>\r<p>Mac jest wyposa&#380;ony w dwa rodzaje tajnej broni, dzi&#281;ki kt&oacute;rym jest szybki i bezpieczny. <a href="/pl/business/macatwork/#pace" class="more">Wi&#281;cej informacji</a></p>'
];
var randomizePromoTop = [
	'<a href="/pl/macbookair/"><img src="http://images.apple.com/pl/business/images/index_heropromo_macbookair.gif" width="73" height="60" border="0" alt="MacBook air"></a>\r<h3><a href="/pl/macbookair/">Przedstawiamy MacBooka Air.</a></h3>\r<p>Najcienszego notebooka na swiecie. <a href="/pl/macbookair/" class="more">Wi&#281;cej informacji</a></p>',				 
	'<a href="/pl/macosx/"><img src="http://images.apple.com/pl/business/images/index_heropromo_leopard.gif" width="73" height="60" border="0" alt="Leopard"></a>\r<h3><a href="/pl/macosx/">Leopard.</a></h3>\r<p>Poznaj najbardziej imponuj&#261;c&#261; wersj&#281; systemu Mac OS X. <a href="/pl/macosx/" class="more">Wi&#281;cej informacji</a></p>', 
	'<a href="/pl/iwork/"><img src="http://images.apple.com/pl/business/images/index_heropromo_iwork.gif" width="73" height="60" border="0" alt="iWork"></a>\r<h3><a href="/pl/iwork/">Nowy iWork \'08.</a></h3>\r<p>Sprawna i wygodna praca z tekstem, porywaj&#261;ce prezentacje, a teraz tak&#380;e arkusze kalkulacyjne. <a href="/pl/iwork/" class="more">Wi&#281;cej informacji</a></p>'
];
var randomizePromoBottom = [
	'<a href="/pl/macosx/applications/office/"><img src="http://images.apple.com/pl/business/images/index_heropromo_office.gif" width="68" height="60" border="0" alt="Office 2008 for Mac"></a>\r<h3><a href="/pl/macosx/applications/office/">Office 2008 for Mac.</a></h3>\r<p>Wi&#281;cej narz&#281;dzi i wi&#281;ksza zgodno&#347;&#263; z pakietem MS Office 2007 for Windows. <a href="/pl/macosx/applications/office/" class="more">Wi&#281;cej informacji</a></p>',
	'<a href="/pl/timecapsule/"><img style="margin-top:8px;" src="http://images.apple.com/pl/business/images/index_heropromo_timecapsule.gif" width="73" height="60" border="0" alt="Time Capsule"></a>\r<h3 style="padding-top:12px;"><a href="/pl/timecapsule/">Time Capsule.</a></h3>\r<p>Nowy spos&oacute;b na kopie zapasowe. <a href="/pl/timecapsule/" class="more">Wi&#281;cej informacji</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'));
});
