/* remove class name from a list of elements */
var site_loc = "http://www.volta.be/hoskensNieuwpoort/";
var picture_huidig = 1;
var picture_max = 3;
var picture_locatie = '';
var root_position = 0;

function removeClassNameFrom(list, className) {
	for(var i = 0; element = list[i]; i++) element.removeClassName(className);
}

var execution = false ;

function trigger_big_picture_replace_crossfade( picture_url, trigger )
{

	// set this method to busy
	if( execution ){ return; }
	execution = true ;
	
	// gather actors
	var container	= $('center_picture') ;
	var image		= $('center_picture_img') ;
	// remove border arround previous element and add it to the new
	removeClassNameFrom($$('.link_img'), 'current');
	trigger.addClassName('current');
	
	// fix container element dimensions
	Element.setStyle( container, { height: Element.getHeight( image ) + 'px' } ) ;
	Element.setStyle( container, { width: Element.getDimensions( image ).width + 'px' } ) ;

		
	var fade_in = .3 ; var previous_bgnd = '' ;

	Element.setStyle( container, { background: 'url(' + picture_url + ') no-repeat'} ) ;
	fade_in = .6 ;
	
	// fade current image
	new Effect.Fade( image, { duration: fade_in,
		afterFinish: function(e)
		{
			// load the image
			image.src = picture_url ; 
			image.style.display = 'block' ;
			// fade in
			new Effect.Appear( image, { duration: .3, afterFinish: function(e){ Element.setStyle( container, { background: 'no-repeat center center url(../assets/img/progress_indicator.gif)'} ) } }) ; // end of appear effect
			
			execution = false;
		}
	} ) ;
}

function big_picture_replace_crossfade( picture_loc) //, trigger )
{
	//alert(root_position);
	//alert (picture_locatie);
	if (root_position  == 1){
		picture_url = 'img_content/' + picture_locatie + '/' + picture_loc +'.jpg';
	}else{
		picture_url = '../img_content/' + picture_locatie + '/' + picture_loc +'.jpg';
	}
	//alert(picture_url);
	// set this method to busy
	if( execution ){ return; }
	execution = true ;
	
	// gather actors
	var container	= $('introimg') ;
	var image		= $('big_picture_img') ;
	// remove border arround previous element and add it to the new
	//removeClassNameFrom($$('.link_img'), 'current');
	//trigger.addClassName('current');
	
	// fix container element dimensions
	//Element.setStyle( container, { height: Element.getHeight( image ) + 'px' } ) ;
	//Element.setStyle( container, { width: Element.getDimensions( image ).width + 'px' } ) ;

		
	var fade_in = .3 ; var previous_bgnd = '' ;

	Element.setStyle( container, { background: 'url(' + picture_url + ') no-repeat'} ) ;
	fade_in = .7 ;
	
	// fade current image
	new Effect.Fade( image, { duration: fade_in,
		afterFinish: function(e)
		{
			// load the image
			image.src = picture_url ; 
			// fade in
			new Effect.Appear( image, { duration: .3, afterFinish: function(e){ 
					Element.setStyle( container, { background: 'no-repeat center center url(../assets/img/progress_indicator.gif)'} );
					//call on next image
					automatic_picture_replace(picture_locatie, picture_max);
			} }) ; // end of appear effect
			
			execution = false;
		}
	} ) ;
	
	
	
}

function picture_preload (locatie, max){
	for (var i = 1; i<=max; i++)
   {
  		picture_url = site_loc + 'images/' + locatie + '/' + i +'.jpg';
  		pic = new Image(425,425); 
  		pic.src= picture_url;
   }
 }
 
function start_picture_replace (locatie, max){
	for (var i = 1; i<=max; i++)
   {
  		picture_url = site_loc + 'images/' + locatie + '/' + i +'.jpg';
  		pic = new Image(901,142); 
  		pic.src= picture_url;
   }
    
	root_position = 0;
	automatic_picture_replace(locatie, max)
}
function google_picture_replace (locatie, max){
	googleMap();
	start_picture_replace(locatie, max);
}
function h_start_picture_replace (locatie, max){
	for (var i = 1; i<=max; i++)
   {
  		picture_url = site_loc + 'img_content/' + locatie + '/' + i +'.jpg';
  		pic = new Image(901,142); 
  		pic.src= picture_url;
   }
	root_position = 1;
	automatic_picture_replace(locatie, max)
}

function automatic_picture_replace(locatie, max){

	picture_locatie = locatie;
	picture_max = max;
	picture_huidig += 1;	
	if (picture_huidig > picture_max){ picture_huidig = 1;}
	//alert(picture_huidig);
	setTimeout("big_picture_replace_crossfade(picture_huidig)",3000);
	
}

function big_picture_replace_crossfade_home( picture_loc) //, trigger )
{
	picture_url = 'images/footer/' + picture_loc +'.jpg';
	// set this method to busy
	if( execution ){ return; }
	execution = true ;
	
	// gather actors
	var container	= $('big_picture') ;
	var image		= $('big_picture_img') ;
	// remove border arround previous element and add it to the new
	//removeClassNameFrom($$('.link_img'), 'current');
	//trigger.addClassName('current');
	
	// fix container element dimensions
	Element.setStyle( container, { height: Element.getHeight( image ) + 'px' } ) ;
	Element.setStyle( container, { width: Element.getDimensions( image ).width + 'px' } ) ;

		
	var fade_in = .3 ; var previous_bgnd = '' ;

	Element.setStyle( container, { background: 'url(' + picture_url + ') no-repeat'} ) ;
	fade_in = .7 ;
	
	// fade current image
	new Effect.Fade( image, { duration: fade_in,
		afterFinish: function(e)
		{
			// load the image
			image.src = picture_url ; image.style.display = 'block' ;
			// fade in
			new Effect.Appear( image, { duration: .3, afterFinish: function(e){ 
					Element.setStyle( container, { background: 'no-repeat center center url(assets/img/progress_indicator.gif)'} );
					//call on next image
					automatic_picture_replace_home();
			} }) ; // end of appear effect
			
			execution = false;
		}
	} ) ;
	
	
	
}

function automatic_picture_replace_home(){
	picture_huidig += 1;	
	if (picture_huidig > picture_max){ picture_huidig = 1;}
	//alert(picture_huidig);
	setTimeout("big_picture_replace_crossfade_home(picture_huidig)",3000);
	
}

/*window.onload = function() {
	automatic_picture_replace();
}*/

