
// This script is driven by the ID of the containing DIV tag, and also the IDs of the individual images.
//
// ID Structure as follows:
//
//	id="img1a" - Image number 1, Set a
//	id="img2a" - Image number 2, Set a
//	id="img3a" - Image number 3, Set a
//	id="img4a" - Image number 4, Set a
//
//	id="img1b" - Image number 1, Set b
//	id="img2b" - Image number 2, Set b
//	id="img3b" - Image number 3, Set b
//	id="img4b" - Image number 4, Set b
//
//	Images 1 to 4 reading from left to right
//	Image set a is the first set shown, Image set b is the second.

window.addEvent('domready', function(){ // OPEN 01 ==

	var use_mouseover_links = true ;

	var all_links = $$('#horizontalpix a') ;
	all_links.setStyles({'opacity':'0.000001'}) ;

// Animation Setup

	var time_start_delay = 1000 ; // Initial Pause
	var time_initial_delay = 500 ; // Delay between inital appearance (first images : 1, 2, 3, 4)
	var time_offsetter = 5000 ; // Mllisecconds 1000 = 1 sec. delay before next set of 4 images
	var img_index = 0 ;
	var switcher = 1 ;
	var first_run = true ;
	var current_lap = 0 ;
	var maximum_laps = 1800 ;

	var time_keeper = time_start_delay ;

	var all_images = $$('#horizontalpix img') ;
	all_images.setStyles({'opacity':'0.0'}) ;

	function fireself(fire_set){

//			alert(which_set) ;

			setTimeout("$$('#horizontalpix #img1"+fire_set+"').morph({'opacity':"+switcher+".0})",time_keeper) ;
			time_keeper = time_keeper + time_initial_delay ;
			setTimeout("$$('#horizontalpix #img2"+fire_set+"').morph({'opacity':"+switcher+".0})",time_keeper) ;
			time_keeper = time_keeper + time_initial_delay ;
			setTimeout("$$('#horizontalpix #img3"+fire_set+"').morph({'opacity':"+switcher+".0})",time_keeper) ;
			time_keeper = time_keeper + time_initial_delay ;
			setTimeout("$$('#horizontalpix #img4"+fire_set+"').morph({'opacity':"+switcher+".0})",time_keeper) ;
		
		time_keeper = time_keeper + time_offsetter ;
		current_lap = current_lap + 1 ;

//		document.getElementById('debug').innerHTML = 'Lap : ' + current_lap ;

	// Checnge the opacity switch
		if(first_run!=true){
			if(switcher==0){
				switcher = 1 ;
			} else {
				switcher = 0 ;
			}
		} else {
			first_run = false ;
		}

		if(current_lap<maximum_laps){
			fireself('b') ;
		}

	}
	fireself('a') ;

}); // OPEN 01 ==
