	
	var timer = 0;
	var canvas;
	var crossfade;
	var transition_duration = 2000;

	var path = 'images/headers/';
	var url_path = '';
	
	// Paths contains the full url to the rotator images
	var paths = [
		path + 'header_1.jpg',
		path + 'header_2.jpg',
		path + 'header_3.jpg',
		path + 'header_4.jpg'
	];
	// urls contains the link for each image (to the search page)
	var urls = [
		url_path + 'pages-our-services/advantages-business.html',
		url_path + 'pages-our-services/provisioning.html',
		url_path + 'pages-reseller-opportunity/pricing-scenarios.html',
		url_path + 'pages-reseller-opportunity/advantages-partners.html'
	];

	window.addEvent('load', function(){
		
		var loadedImages = [];
		var links = [];
		
		canvas = $('crossfade_header_canvas');
		// Start preloading all images

		new Asset.images(paths,{
			
			onProgress: function() {
				if (!loadedImages.contains(this)) {		
					// Store the image inside the loadedImages array
					loadedImages[loadedImages.length] = this;
					// Create a new link
					var a = new Element('a',{
						href	:	urls[loadedImages.length - 1],
						styles	:	{
							'position'	:	'absolute',
							'display'	:	'block',
							'width'		:	'752px',
							'height'	:	'258px',
							'z-index'	:	1000 - loadedImages.length
						}
					});
					this.injectInside(a);
					// ...and inject the final link + img to the crossdade_canvas
					a.injectInside(canvas);
					// Keep a note of the newly injected link
					links[links.length] = a;
				}
			},
			
			onComplete: function(){
				//console.log(loadedImages);
				//console.log(loadedImages.length);
				crossfade = function() {
					// Reset all opacities to 100
					$$('#crossfade_header_canvas a').setStyles({'opacity':1});
					timer = 0;
					links.each(function(current_link, i) {
												
						timer += transition_duration;
						
						fx = function() {
							if (i == links.length - 1) {
								links[0].effect('opacity',{duration:transition_duration}).start(0,1).chain(function(){
									crossfade();
								});
							} else {
								current_link.effect('opacity',{duration:transition_duration}).start(1,0);
							}
						}.delay(timer * 3);

					});			
				}
				crossfade.delay(500);
			}
			
		});

	});
