var divtot=0;
var fermaSlides = 0;


function load_home(){		
	/*
	$('appstore_available').style.display='none';
	$('yt_link').style.display='none';
	$('fb_link').style.display='none';
	$('payoff_home').style.display='none';
	$('footer-menu').style.display='none'; 
	JQ('#contenitore_centrale').css('z-index','99'); 
	*/
	$('imageA_nero').style.display='none';
	$('imageA_0').style.display='none';
	JQ('#container').css('visibility','visible');
	
	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;

	corrente = 0;
	vuoto = 0; 

	var whichImage = 0;
	/*
	if (divtot > 0) {
		$('imageA_nero').fade({duration: 0.0});
		$('imageA_0').fade({duration: 0.0});
		$('imageA_' + whichImage).appear({duration: 1.0});
		$('skip').appear({duration: 1.0});
	}
	*/
		
	x = whichImage;
	y = 0;
	
	/*cookieName = "surveyFrauDone";
	cookieTime = 8760;
	if (readCookie(cookieName) != "1") {
		window.open('http://www.surveymonkey.com/jsPopInvite.aspx?sm=Du6B8zv81eXi0I0ui7Xusg%3d%3d', 'invitationwindow', 'height=350,width=500,scrollbars=yes,resizable=yes,status=yes');
		createCookie(cookieName,"1",cookieTime);
	}*/
	
	if (divtot > 0)
		play_1 = setInterval('load_play()',0); //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});	
			JQ('#news_home').css('visibility','visible');news_istanzia();		
			$('appstore_available').appear({duration: 1.0});
			$('yt_link').appear({duration: 1.0});
			$('fb_link').appear({duration: 1.0});
			$('payoff_home').appear({duration: 1.0});
			$('footer-menu').style.display='';
			JQ('#contenitore_centrale').css('z-index','1000'); 
		}
		
		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});
	JQ('#news_home').css('visibility','visible');news_istanzia();
	$('appstore_available').appear({duration: 1.0});
	$('yt_link').appear({duration: 1.0});
	$('fb_link').appear({duration: 1.0});
	$('payoff_home').appear({duration: 1.0});
	$('footer-menu').style.display='';
	JQ('#contenitore_centrale').css('z-index','1000'); 	

}


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);
}

