
ratio = 80                 ;
nb_max_negatif = 36        ;
current_serie  = 1         ;
current_photo  = 0         ;

neg_vide_src   = "./images/negatif_vide.jpg" ;


my_images    = new Array() ;
_loaded      = new Array() ;
th_loaded    = new Array() ;
th_img       = new Array() ;
accueil      = new Array() ; 

img_accueil = new Array() ;  

img_accueil[1] = ''
img_accueil[2] = ''
img_accueil[3] = ''
img_accueil[4] = ''


max_photo = 0
flag_diap = 0
timer_load_ID = 0
timer_DIAPO_ID = 0
flag_refresh = 0


// ==============================================================================
function load_accueil ()
{
   
   for( i = 1 ; i < 5 ; i++ )
   {
	  accueil[i] = new Image
      accueil[i].src = img_accueil[i]
   }
}


//
// sur selection dans le html
//
function start_serie ( i_s)
{
		show_info('')
	    $('loading' ).setStyles({ visibility: 'visible' })
	    $("serie_" + current_serie).className = 'style1' ;
	    current_serie = i_s
	    $("serie_" + current_serie).className = 'actif' ;

        $("viewer").style.display = 'none'  ; 
        $("view_negatif").style.display = 'block'  ; 
	    $('view_negatif').innerHTML = '' 
		max_photo = a_nb_img_max[i_s]
		$('album').innerHTML = a_titre[i_s] ;
		create_negatif (i_s) 
}

function create_negatif ( i_s ) 
{	
  $('view_negatif' ).innerHTML = ''  
  output = ''
  cur_img    = 0 ;
  th_cur_img = 0 ;
  var item1 = '  '
  
  for ( var i = 1; i <= nb_max_negatif ; i++) {	
	   _loaded[i]     = false
	   th_loaded[i]   = false
       my_images[i]   = new Image()
       th_img[i]      = new Image()	
       th_img[i].src  = neg_vide_src
       item1 = ' href="#" rel="#" title="" '
	   if ( i <= max_photo  )
	   {
          my_images[i].src = a_path[i_s] + "/images/"    + a_photo_name[i_s]  + i + ".jpg"
          th_img[i].src    = a_path[current_serie] + "/thumbails/" + a_thumb_name[current_serie]  + i + ".jpg" 
		  item1 = ' href=" ' +  my_images[i].src + '" rel="lyteshow[slideshow]" title="" '
	   }  
	   output += '<div id="neg_' + i +'"> <a id="a_' + i + '"' + item1 + '><img id="i_neg_' + i + '" src="' + neg_vide_src + '" width="110" height="100"></a></div>'
  }
  $('view_negatif' ).innerHTML = output 
  initLytebox()
  checkLoad()
  checkLoad_th()
}









function checkLoad(  ) {	
	if ( cur_img >= max_photo  ) { 
		clearTimeout(timer_load_ID)
		$('loading' ).setStyles({ visibility: 'hidden' })
	}	
	for (var i = 1 ; i <=  max_photo ; i++) {
		if (_loaded[i] == false && my_images[i].complete) {
			 cur_img++
			 _loaded[i] = true
			 _info = cur_img + " photos chargees sur " + max_photo 
			 show_info ( _info )
		}
	}
	timer_load_ID = setTimeout("checkLoad(  )",10) 
} 

function checkLoad_th (  ) {	
	if ( th_cur_img >= max_photo  ) { 
		clearTimeout(timer_load_th)
	}	
	for (var i = 1 ; i <=  max_photo ; i++) {
		if ( th_loaded[i] == false && th_img[i].complete && _loaded[i]  ) {
			 th_cur_img++
			 th_loaded[i] = true
			 $('i_neg_' + i).src =  th_img[i].src      
		}
	}
	timer_load_th = setTimeout("checkLoad_th(  )",10) 
}



function show_info ( _info )
{
  $('info').innerHTML = _info ; 
}


function show_accueil( i_n ) 
{
            document.getElementById("viewer").style.display = 'block'  ; 
            document.getElementById("view_negatif").style.display = 'none'  ; 
	        document.getElementById('img_viewer').setAttribute('src', accueil[i_n].src) ;
            real_width  = accueil[i_n].width;
            real_height = accueil[i_n].height;
            zoom(ratio) ;
}
