var divtot=0;
var fermaSlides = 0;


function load_home(){		
	
	corrente = 0;
	vuoto = 0; 
	while ( vuoto < 10 ) {
		if ( document.getElementById('imageA_' + corrente) ) {
			divtot = divtot + 1;
			corrente = corrente + 1;
			vuoto = 0;
		} else {
			vuoto = vuoto + 1;
			corrente = corrente + 1;
		}		
	}	
	
	divtot = divtot - 1;
	//alert (divtot);
		
	corrente = 0;
	vuoto = 0; 

	var whichImage = 0;
	if (divtot > 0) {
		//$('imageA_nero').fade({duration: 1.0});
		$('imageA_' + whichImage).appear({duration: 1.0});
		$('skip').appear({duration: 1.0});
	}
		
	x = whichImage;
	y = 0;
	
	if (divtot > 0)
		play_1 = setInterval('load_play()',4000); //QUI SETTARE IL TEMPO PER L'INTERVALLO

}


function load_play() {

	if ( fermaSlides != 1) {
	
		y = x+1;
		
		if (y > divtot-1) {
			fermaSlides = 1;
			$('skip').fade({duration: 1.0});
			$('imageA_nero').fade({duration: 1.0});			
		}
		
		y = x+1;
		$('imageA_' + x).fade({duration: 1.0});
		$('imageA_' + y).appear({duration: 1.0});
		x++;
	
	}	
}


function skip_play() {
	
	clearInterval (play_1);
	fermaSlides = 1;
	y = divtot;
	$('skip').fade({duration: 1.0});
	$('imageA_nero').style.display="none";
	$('imageA_' + x).fade({duration: 1.0});
	$('imageA_' + y).appear({duration: 1.0});

}


function requirements_match() {
	
	cookieName = "requirements_match";
	cookieTime = 24;
	//eraseCookie(cookieName);
	if (readCookie(cookieName) != "1") {
		var ua = window.navigator.userAgent;
		var msie = ua.indexOf ( "MSIE " ); // Determino la versione di IE; se 0 è un browser diverso da IE
		if ( msie <= 0 || parseInt (ua.substring (msie+5, ua.indexOf (".", msie ))) > 6  ) { //parseInt ecc. mi restituisce la versione di IE
			createCookie(cookieName,"1",cookieTime)
		}
		else {
			$("alert_ie6_id").style.display = "";
			createCookie(cookieName,"1",cookieTime)
		}
	}	
}


function createCookie(name,value,hours) {
	if (hours) {
		var date = new Date();
		date.setTime(date.getTime()+(hours*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
	}

	
function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function eraseCookie(name) {
	createCookie(name,"",-1);
}
