window.addEvent('domready', function(){
	var busy = false, timer, loadedImages = [], maps = $('maps'), progress = $('progress'), bar = $E('#progress .bar'); 
	var path = 'images/';
	var images = [
			path + 'map1.jpg',
			path + 'map2.jpg',
			path + 'map3.jpg'
	];
	var td = [
		'The term &quot;rice&quot; comes from the Tamil (an ancient language of India and Sri Lanka) word &quot;Arisi.&quot; Archeological evidence of rice dates to 10,000 B.C. In fact, rice plays a role in the creation stories of several Asian cultures. Evidence from the Hunan province of China suggests that Early Neolithic groups may have cultivated rice. Cultivation of rice is believed to have begun almost simultaneously in many countries more than 6,500 years ago.<br><br>Whatever its beginnings, the domestication of rice is one of the most important developments in history. No other food has fed more people over a longer period of time.',
		'The first record of rice in North America dates from about 1685, when rice was produced in the coastal lowlands of what is now South Carolina. According to the legend, a ship arrived in Charleston in need of repairs. After repairs were completed, the captain presented a local planter with a packet of rice from Madagascar. This “Golden Seede” produced a white long-grain rice that became an important export from South Carolina to England.',
		'Thomas Jefferson is thought to have brought shorter-grain rice to America. While serving as ambassador to France, he observed the French preference for Italy\'s short-grain rice over the rice grown in South Carolina. The Italians were fiercely protective of the rice seed and would not allow it out of the country. Risking death, Jefferson smuggled the rice in the pocket of his jacket. The rice seeds were sent to the Carolinas for planting.<br><br>At first, rice was milled by hand with wooden paddles. The invention of the rice mill greatly increased its profitability as did the addition of water power for the mills in 1787.<br><br>The Carolinas dominated rice growing until the Civil War, although the rice crop spread to Louisiana in the early 1800s. It was not until the 20th Century, however, that rice was produced in all of today\'s major rice growing states: Arkansas, California, Louisiana, Missouri, Mississippi and Texas.<br><br>Today, more than 40,000 varieties of rice are grown worldwide. Rice is the largest food crop worldwide and is the most valuable cereal grain. It is the dietary staple of two-thirds of the world\'s population.'
	];
	//gallery.setStyles({'opacity': 0, 'display': 'none'});
	//progress.setStyle('visibility', 'hidden');
	var hasseen = false;
	if (!busy) {		
		var mapsImgs = $$('#maps img');
		if (mapsImgs.length > 0) mapsImgs.each(function(image) {	image.remove();	});
		busy = true;
		progress.setStyle('visibility', 'visible');
		maps.setStyle('display', 'block');
		new Asset.images(images, {
			onProgress: function(i) {
				var ii = parseInt(this.src.substr(this.src.length-5,1))-1;
				loadedImages[ii] = this;
				var percent = ((ii + 1) * progress.getStyle('width').toInt()) / images.length;
				bar.setStyle('width', percent).setHTML(ii + 1 + ' / ' + images.length);
			},
			onComplete: function() {
				progress.setStyle('display', 'none');
				var mySlide = new Slider($('area'), $('knob'), {
					steps:2,
					onChange: function(step){
						for (var j=0; j <= 2; j++) {
							try{loadedImages[j].remove();}catch(e){}
							$('box'+j.toString()).className='box';
						}
						$('box'+step.toString()).className='selected';
						var image = loadedImages[step];
						image.inject(maps);
						$('tidbit').innerHTML = td[step];
					}
				}).set(0);
			}
		});
	}
});