// DA FILE JAVASCRIPT ESTERNI >>>>>>>>>>>>>>>>>
//	var stage_totale_immagini ;
//	var ch1_totale_immagini ;
//	var ch2_totale_immagini ;
//	var ch3_totale_immagini ;
//	var ch3_titolo ;
// ch3_intervallo  = 1000;


// <<<<<<<<<<<<<<<<<
	var stage_count = Math.floor(Math.random()*(stage_totale_immagini+1));
 	var ch1_count = Math.floor(Math.random()*(ch1_totale_immagini+1));		
 	var ch2_count = Math.floor(Math.random()*(ch2_totale_immagini+1));	
 	var ch3_count = Math.floor(Math.random()*(ch3_totale_immagini+1));	

	var z = 1; 
	var stage_sto, ch3_sto;	// VARS INTERVALLI
	
	jQuery.noConflict();	
// <<<<<<<<<<<<<<<<< DOC READY	
	jQuery(document).ready(function(){
		
		stage_chfoto (z, stage_count, stage_totale_immagini);
  		ch1_chfoto (ch1_count, ch1_totale_immagini);
  		ch2_chfoto (ch2_count, ch2_totale_immagini);
 		ch3_chfoto (z, ch3_count, ch3_totale_immagini);	
		
		//---- CH3 TITOLO				
 		jQuery('#ch3 div').html(ch3_titolo);		
					
		//---- MONITOR RESET
		jQuery('#contastage, #contach3').empty();

		//----STAGE MENU EFFECTS
		jQuery('#stage_menu  li a').mouseover(function() {
 				jQuery(this).animate({opacity:0.2}, 'slow');
//  				jQuery(this).fadeOut('slow');				
		});
		jQuery('#stage_menu  li a').mouseout(function() {
 				jQuery(this).animate({opacity:0.9}, 'slow');
//  				jQuery(this).fadeIn('slow');				
		});		
		
	}); 
// <<<<<<<<<<<<<<<<< END DOC READY	<<<<<<<<<<<<<<<<<<<

function stage_chfoto(_z, _count, _ctot){
		//--------	CEDLARE VARSarch, timer, 
		var _archivio = 'HP11_stage/'; 
		var _target = 'stage'; 
		var _targetZ = "#"+_target+" img.z";			
		var _tarcount = '#contastage';
		var _intervallo = 7000;
		var _fadeSpeed = 1200;		
		var _ext;
		var _count_strg;
		var _URL;
		var _znum1, _znum2;
		var _monitor_1;
				
		//--------	COUNTER MANAGER
		_count++; 
		if (_count > _ctot) _count=1; 
		if (_count < 10) {_count_strg = "0"+_count} else {_count_strg = _count}
		
		
		/*--------	COUNTER MONITOR */  jQuery(_tarcount).html(_count +"/"+_ctot);	
			
		//--------	EXTENTION MANAGER
		switch (_count) {default: _ext = ".jpg";}
				
		//--------	URL IMG
		_URL = _archivio+_count_strg+_ext;
		
		(_z == 1) ? _z = 2 : _z = 1; 
		_znum1 = _z; 
		(_znum1 == 1) ? _znum2 = 2 : _znum2 = 1;
		
 		/*--------	COUNTER MONITOR */ 
		// _monitor_1 = _count +'/'+ _ctot+' - loaded '+_target+' - znum = '+_znum1+' - ';
		  _monitor_1 = 'intervallo = '+_intervallo+' IMG loaded > znum1 = '+_znum1+' - znum2 = '+_znum2+' - _z = '+_z+' - '+_count +'/'+ _ctot;
		/*--------	FINE COUNTER MONITOR */ 


		
		jQuery(_targetZ+_znum1).bind("load", function(event){
					
			jQuery(_tarcount).html(_monitor_1); 
			
			if(_znum1 == 1){
				jQuery(_targetZ+'1').fadeIn(_fadeSpeed, function() {
						stage_sto = setTimeout("stage_chfoto ("+_z+","+_count+","+_ctot+")", _intervallo);
						jQuery(_targetZ+_znum1).unbind('load');// UNBIND!!	
					});
			}
			if(_znum1 == 2){
			jQuery(_targetZ+'1').fadeOut(_fadeSpeed, function() {
			   		stage_sto = setTimeout("stage_chfoto ("+_z+","+_count+","+_ctot+")", _intervallo);
					jQuery(_targetZ+_znum1).unbind('load');// UNBIND!!	
			 	});
 			}
			
		});
		
		
		
		
		jQuery(_targetZ+_znum1).attr("src", _URL);
		//--------	
		
		
		  	
} 

function ch3_chfoto(_z, _count, _ctot){

		//--------	CEDLARE VARSarch, timer, 
		var _archivio = 'HP11_ch3/'; 
		var _target = 'ch3'; 
		var _targetZ = "#"+_target+" img.z";			
		var _tarcount = '#contach3';
		var _intervallo = 23000;
		var _ext;
		var _count_strg;
		var _URL;
		var _znum1, _znum2;
		var _monitor_1;
				
		//--------	COUNTER MANAGER
		_count++; if (_count > _ctot) _count=1; if(_count <10) {_count_strg = "0"+_count} else {_count_strg = _count}
		//--------	COUNTER MONITOR 
		jQuery(_tarcount).html(_count +"/"+_ctot);		
		//--------	EXTENTION MANAGER
		switch (_count) {default: _ext = ".jpg";}		

		_URL = _archivio+_count_strg+_ext;
		(_z == 1) ? _z = 2 : _z = 1; _znum1 = _z; (_znum1 == 1) ? _znum2 = 2 : _znum2 = 1;
		
 		//--------	COUNTER MONITOR 
		_monitor_1 = _count +'/'+ _ctot+' - loaded '+_target+'-'+_znum1+' - ';
		jQuery(_targetZ+_znum1).bind("load", function(event){jQuery(_tarcount).html(_monitor_1); });		
// UNBIND!!	
		jQuery(_targetZ+_znum1).attr("src", _URL);
		//--------	
		jQuery(_targetZ+_znum2).fadeOut('slow', function() {
					jQuery(_targetZ+_znum1).fadeIn('slow', function() {
					});
   		});	
		ch3_sto = setTimeout("ch3_chfoto ("+_z+","+_count+","+_ctot+")", _intervallo);  	
} 

function ch2_chfoto(_count, _ctot){

		//--------	CEDLARE VARSarch, timer, 
		var _archivio = 'HP11_ch2/'; 
		var _targetZ = "#ch2 img.z1";			
		var _ext;
		var _count_strg;
		var _URL;
		var _znum1, _znum2;
		var _monitor_1;
				
		//--------	COUNTER MANAGER
		_count++; if (_count > _ctot) _count=1; if(_count <10) {_count_strg = "0"+_count} else {_count_strg = _count}
		//--------	EXTENTION MANAGER
		switch (_count) {default: _ext = ".jpg";}		

		_URL = _archivio+_count_strg+_ext;

		jQuery(_targetZ).attr("src", _URL);
} 

function ch1_chfoto(_count, _ctot){

		//--------	CEDLARE VARSarch, timer, 
		var _archivio = 'HP11_ch1/'; 
		var _targetZ = "#ch1 img.z1";			
		var _ext;
		var _count_strg;
		var _URL;
		var _znum1, _znum2;
		var _monitor_1;
				
		//--------	COUNTER MANAGER
		_count++; if (_count > _ctot) _count=1; if(_count <10) {_count_strg = "0"+_count} else {_count_strg = _count}
		//--------	EXTENTION MANAGER
		switch (_count) {default: _ext = ".jpg";}		

		_URL = _archivio+_count_strg+_ext;

		jQuery(_targetZ).attr("src", _URL);
} 











