/*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="/in/business/profiles/muzyq/"><img src="http://images.apple.com/in/business/images/index_hero8.jpg" width="483" height="245" border="0" alt="muzyQ"></a>', 
	'<a href="/in/business/profiles/virtualaviation/"><img src="http://images.apple.com/in/business/images/index_hero7.jpg" width="483" height="245" border="0" alt="Virtual Aviation"></a>',
	'<a href="/in/business/profiles/cityinn/"><img src="http://images.apple.com/in/business/images/index_hero6.jpg" width="483" height="245" border="0" alt="City Inn"></a>',
	'<a href="/in/business/profiles/nymphestrandhotel/"><img src="http://images.apple.com/in/business/images/index_hero5.jpg" width="483" height="245" border="0" alt="nymphe strand hotel"></a>', 
	'<a href="/in/business/profiles/carrouxcoffee/"><img src="http://images.apple.com/in/business/images/index_hero4.jpg" width="483" height="245" border="0" alt="Carroux Coffee"></a>', 
	'<a href="/in/business/profiles/mymuesli/"><img src="http://images.apple.com/in/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/in/business/images/index_macatwork_leopard20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Reason #1: Work more, labour&nbsp;less.</h4>\r<p>In no time, you’ll find you and your employees are working more happily and efficiently than ever before. <a href="/in/business/macatwork/" class="more">Learn&nbsp;More</a></p>',	
	'<img src="http://images.apple.com/euro/business/images/index_macatwork_ilife20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Reason #2: Unleash your creativity.</h4>\r<p>Don’t let the designers have all the fun. Discover your creative side with iLife and iWork. <a href="/in/business/macatwork/#creativity" class="more">Learn&nbsp;More</a></p>',
	'<img src="http://images.apple.com/in/business/images/index_macatwork_photos20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Reason #3: The extras don’t cost any extra.</h4>\r<p>Macs are streamlined and simple – yet right out of the box, they do more than you might expect. <a href="/in/business/macatwork/#extras" class="more">Learn&nbsp;More</a></p>', 
	'<img src="http://images.apple.com/in/business/images/index_macatwork_office20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Reason #4:  Mac be nimble, Mac be quick.</h4>\r<p>Anything you need to do for your business, you can do on a Mac. <a href="/in/business/macatwork/#nimble" class="more">Learn&nbsp;More</a></p>', 
	'<img src="http://images.apple.com/in/business/images/index_macatwork_print20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Reason #5: Macs play well with others.</h4>\r<p>Mac user in a PC world? Don’t worry. Most popular applications for Mac and PC use the same file formats. <a href="/in/business/macatwork/#playwell" class="more">Learn&nbsp;More</a></p>',
	'<img src="http://images.apple.com/in/business/images/index_macatwork_applecare20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Reason #6: Good help is easy to find.</h4>\r<p>With an intuitive system, it isn’t often that you’ll be looking for assistance. <a href="/in/business/macatwork/#help" class="more">Learn&nbsp;More</a></p>',
	'<img src="http://images.apple.com/in/business/images/index_macatwork_imac20071031.jpg" width="100" height="114" alt="Leopard" class="right">\r<h4>Reason #7: Pick up the pace, Mac style.</h4>\r<p>Macs come with two secret weapons for speed and security. <a href="/in/business/macatwork/#pace" class="more">Learn&nbsp;More</a></p>'
];
var randomizePromoTop = [
	'<a href="/in/macbookair/"><img src="http://images.apple.com/in/business/images/index_heropromo_macbookair.gif" width="73" height="60" border="0" alt="MacBook air"></a>\r<h3><a href="/in/macbookair/">Introducing MacBook Air.</a></h3>\r<p>The world\'s thinnest notebook. <a href="/in/macbookair/" class="more">Learn&nbsp;More</a></p>',				 
	'<a href="/in/macosx/"><img src="http://images.apple.com/in/business/images/index_heropromo_leopard.gif" width="73" height="60" border="0" alt="Leopard"></a>\r<h3><a href="/in/macosx/">Leopard.</a></h3>\r<p>See the most impressive Mac OS X version yet. <a href="/in/macosx/" class="more">Learn&nbsp;More</a></p>', 
	'<a href="/in/iwork/"><img src="http://images.apple.com/in/business/images/index_heropromo_iwork.gif" width="73" height="60" border="0" alt="iWork"></a>\r<h3><a href="/in/iwork/">The new iWork \'08.</a></h3>\r<p>Streamlined word processing, stunning presentations and now spreadsheets. <a href="/in/iwork/" class="more">Learn&nbsp;More</a></p>'
];
var randomizePromoBottom = [
	'<a href="/in/macosx/applications/office/"><img src="http://images.apple.com/in/business/images/index_heropromo_office.gif" width="68" height="60" border="0" alt="Office 2008 for Mac"></a>\r<h3><a href="/in/macosx/applications/office/">Office 2008 for Mac.</a></h3>\r<p>More tools and greater compatibility with MS Office 2007 for Windows. <a href="/in/macosx/applications/office/" class="more">Learn&nbsp;More</a></p>',
	'<a href="/in/timecapsule/"><img style="margin-top:8px;" src="http://images.apple.com/in/business/images/index_heropromo_timecapsule.gif" width="73" height="60" border="0" alt="Time Capsule"></a>\r<h3 style="padding-top:12px;"><a href="/in/timecapsule/">Time Capsule.</a></h3>\r<p>A leap forward for backup. <a href="/in/timecapsule/" class="more">Learn&nbsp;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'));
});
