var divtot;
var play_1;

function set_background(page) {

	if(page=='results'){
		
		document.getElementById('bg').style.display='none';

	}
	else if(page=='home') {
		
		carica_home();

	}

}


function carica_home(){

	document.getElementById('bg').style.display='';
	var random_num=Math.floor(Math.random()*3);
	var img_num=document.getElementById('bg').getElementsByTagName('img').length;
	
	for(i=0;i<img_num;i++){
		
		if(i==random_num){
			document.getElementById('bg').getElementsByTagName('img')[i].style.display='';
		}
		else{
		
			document.getElementById('bg').getElementsByTagName('img')[i].style.display='none';
		}
		
	}

}



function load_home(){

if(document.getElementById('bg')){
	divtot=3-1;
	corrente = 0;
	vuoto = 0; 
	
	var whichImage = 0;
	if (divtot > 0)
		$('image-1_'+whichImage).appear({duration: 1.0});
		
	x = whichImage;
	y = 0;
	
	if (divtot > 0)
		play_1 = setInterval('load_play()',4000);

}
}


function load_play() {
	
	y = x+1;
		
	if (x > divtot) {
		x = 0;
		y = x+1;
	}
	if (y > divtot) {
		y = 0;
	} else {
		x = x;
		y = x+1;
	}
	$('image-1_'+x).fade({duration: 1.0});
	$('image-1_'+y).appear({duration: 1.0});
	x++;
}

