/*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="/uk/business/profiles/muzyq/"><img src="http://images.apple.com/uk/business/images/index_hero8.jpg" width="483" height="245" border="0" alt="muzyQ"></a>', 
	'<a href="/uk/business/profiles/virtualaviation/"><img src="http://images.apple.com/uk/business/images/index_hero7.jpg" width="483" height="245" border="0" alt="Virtual Aviation"></a>',
	'<a href="/uk/business/profiles/cityinn/"><img src="http://images.apple.com/uk/business/images/index_hero6.jpg" width="483" height="245" border="0" alt="City Inn"></a>',
	'<a href="/uk/business/profiles/nymphestrandhotel/"><img src="http://images.apple.com/uk/business/images/index_hero5.jpg" width="483" height="245" border="0" alt="nymphe strand hotel"></a>', 
	'<a href="/uk/business/profiles/carrouxcoffee/"><img src="http://images.apple.com/uk/business/images/index_hero4.jpg" width="483" height="245" border="0" alt="Carroux Coffee"></a>', 
	'<a href="/uk/business/profiles/mymuesli/"><img src="http://images.apple.com/uk/business/images/index_hero3.jpg" width="483" height="245" border="0" alt="mymuesli"></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/uk/business/images/index_macatwork_numbers20091029.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>You’ll feel right at home with iWork.</h4>\r<p>If you’re used to working with Microsoft Office applications like Word, Excel and PowerPoint, iWork will feel like home. <a href="/uk/business/macatwork/" class="more">Learn&nbsp;More</a></p>','<img src="http://images.apple.com/uk/business/images/index_macatwork_sharing20090828.jpg" width="100" height="114" alt="Leopard" class="right" style="margin-right:-15px;">\r<h4>Plays well with others.</h4>\r<p>Are you a Mac user in a PC world? Don’t worry. The Mac can open most popular files available on PCs like PDFs, JPGs and Word documents. <a href="/uk/business/macatwork/#three" class="more">Learn&nbsp;More</a></p>','<img src="http://images.apple.com/uk/business/images/index_macatwork_macbookair20090828.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Kiss clutter goodbye.</h4>\r<p>A Mac is designed to get work done. Fast. With one-of-a-kind features that keep you organised. Take a peek inside any document without having to open its application, using Quick Look. <a href="/uk/business/macatwork/#five" class="more">Learn&nbsp;More</a></p>','<img src="http://images.apple.com/uk/business/images/index_macatwork_timemachine20081103.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Because you can time&nbsp;travel.</h4>\r<p>Save your business time by travelling through it. With Mac OS X’s revolutionary new Time Machine, you can retrieve any document—no matter how long ago you deleted it. <a href="/uk/business/macatwork/#six" class="more">Learn&nbsp;More</a></p>','<img src="http://images.apple.com/uk/business/images/index_macatwork_vmware20090828.jpg" width="100" height="114" alt="Leopard" class="right" style="margin-right:-15px;">\r<h4>You can bring Windows&nbsp;with&nbsp;you.</h4>\r<p>Need to run the occasional Windows app? Your new Mac can run Windows XP or Vista natively thanks to Boot Camp software included with Mac OS X. <a href="/uk/business/macatwork/#seven" class="more">Learn&nbsp;More</a></p>','<img src="http://images.apple.com/uk/business/images/index_macatwork_macbookpro20090828.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>You don’t have to leave your Office.</h4>\r<p>Did you know that Word, PowerPoint and Excel are all made for the Mac too? There’s basically no learning curve, because the programs work the same. <a href="/uk/business/macatwork/#nine" class="more">Learn&nbsp;More</a></p>'
];
var randomizePromoTop = [
	'<a href="/uk/macbookair/"><img src="http://images.apple.com/uk/business/images/index_heropromo_macbookair.gif" width="73" height="60" border="0" alt="MacBook air"></a>\r<h3><a href="/uk/macbookair/">Introducing MacBook Air.</a></h3>\r<p>The world\'s thinnest notebook. <a href="/uk/macbookair/" class="more">Learn&nbsp;More</a></p>',				 
	'<a href="/uk/macosx/"><img src="http://images.apple.com/uk/business/images/index_heropromo_leopard.gif" width="73" height="60" border="0" alt="Leopard"></a>\r<h3><a href="/uk/macosx/">Leopard.</a></h3>\r<p>See the most impressive Mac OS X version yet. <a href="/uk/macosx/" class="more">Learn&nbsp;More</a></p>', 
	'<a href="/uk/iwork/"><img src="http://images.apple.com/uk/business/images/index_heropromo_iwork.gif" width="73" height="60" border="0" alt="iWork"></a>\r<h3><a href="/uk/iwork/">The new iWork \'08.</a></h3>\r<p>Streamlined word processing, stunning presentations and now spreadsheets. <a href="/uk/iwork/" class="more">Learn&nbsp;More</a></p>'
];
var randomizePromoBottom = [
	'<a href="/uk/business/leopard/"><img src="http://images.apple.com/uk/business/images/index_heropromo_leopard.png" width="55" height="64" border="0" alt="Leopard" class="right nudge"></a>					<h3><a href="/uk/business/leopard/">Snowleopard@work.</a></h3>							<p>Bring your business into the future with Snow Leopard – the most advanced OS ever. <a href="/uk/business/leopard/" class="more">Learn More</a></p>',
	'<a href="/uk/business/solutions/mobility/"><img src="http://images.apple.com/uk/business/images/index_heropromo_macbookair.gif" width="73" height="60" alt="Mobility"></a><h3><a href="/uk/business/solutions/mobility/">Mobility.</a></h3><p>Power Trip. Take your work anywhere. <a href="/uk/business/solutions/mobility/" class="more">Learn&nbsp;More</a></p>',
	'<a href="http://store.apple.com/uk-business/product/TX053?mco=MTM3NDgxNzM"><img src="http://images.apple.com/uk/business/images/index_heropromo_office.gif" width="73" height="60" alt="Office 2008"></a><h3><a href="http://store.apple.com/uk-business/product/TX053?mco=MTM3NDgxNzM">Office ‘08 for Mac.</a></h3><p>Greater tools and compatibility with MS Office 2007 for Windows. <a href="http://store.apple.com/uk-business/product/TX053?mco=MTM3NDgxNzM" class="more">Learn&nbsp;More</a></p>',
	'<a href="/uk/timecapsule/"><img style="margin-top:8px;" src="http://images.apple.com/uk/business/images/index_heropromo_timecapsule.gif" width="73" height="60" alt="Time Capsule"></a><h3 style="padding-top:12px;"><a href="/uk/timecapsule/">Time Capsule.</a></h3><p>A leap forward for backup. <a href="/uk/timecapsule/" class="more">Learn&nbsp;More</a></p>',
	'<a href="/uk/business/podcasting/"><img src="http://images.apple.com/uk/business/images/index_heropromo_podcasting.png" width="70" height="71" alt="Podcasting"></a><h3><a href="/uk/business/podcasting/">Podcasting.</a></h3><p>One of the most powerful tools to market your business. <a href="/uk/business/podcasting/" class="more">Learn More</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'));
});
