resp = new Array();
callb = new Array();


function sendRequest(url, callback, async, meth, verb, clbkOnError)
{


    // Istanza XMLHttp
    var xmlhttp = false;

    // Se Mozilla, Firefox, Opera, Safari
    if (window.XMLHttpRequest)
    {
        xmlhttp = new XMLHttpRequest();

    }
    // Se IE
    else if (window.ActiveXObject)
    {
        try
        {
	  	    // Versione 5.5 o inferiore
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e)
        {
            try
            {
	  	        // Versione 5.5 o superiore
                xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
        }

    }

    if (!xmlhttp)
    {
			if (verb) alert("ERRORE: AJAX non supportato da questo browser!");
			if (callback && clbkOnError) callback('');
			return false;
    }

    // Apro la connessione verso il server in modo asincrono
    if (meth == "POST")
    	xmlhttp.open('POST', url, async);
    else
    	xmlhttp.open('GET', url, async);

    // Il ritorno viene intercettato da questa funzione
    xmlhttp.onreadystatechange = function ()
    {

		// 4 significa completato
		if (xmlhttp.readyState == 4)
		{
			// Codice di ritorno del server: 200 vuol dire OK
			if (xmlhttp.status == 200)
			{

				// Leggo il ritorno in formato XML/TXT
				if (callback  && async)
				{

					// Eseguo la funzione preposta
					//callback(xmlhttp.responseXML);
					resp.push(xmlhttp.responseText);
					callb.push(callback);

					if (resp.length == 1){
						//alert(resp.length);						
						execCallback();
					}
					//callback(xmlhttp.responseText);
				}
			}
			else if (xmlhttp.status == 404)
			{
				if (verb) alert("ERRORE: L'url " + url + " richiesto non esiste!");
				if (callback && clbkOnError) callback('');
			}
			else
			{
				if (verb) alert("ERRORE: Codice di ritorno=" + xmlhttp.status);
				if (verb) handleErr(xmlhttp.responseText);
				if (callback && clbkOnError) callback('');
			}
		}
	}

	// Codifica dei campi secondo il MIME type corretto
	xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');

	// Invio i parametri
  if (meth == "POST")
		xmlhttp.send(url);
	else
		xmlhttp.send(null);
		
	if (!async)
	{
		//callback(xmlhttp.responseXML);
		resp.push(xmlhttp.responseText);
		callb.push(callback);

		if (resp.length == 1)
		{
			execCallback();
		}
	}
	delete xmlhttp;
}

function execCallback()
{
	var respText;
	var fun;
//alert(resp.length);						
	while(resp.length > 0)
	{
		
		respText = resp.shift();
		fun = callb.shift();
//alert('eseguo');
		fun(respText);
	}
}

function handleErr(strIn)
{

        var errorWin;

        try
        {
                errorWin = window.open('', 'ERRORE');
                errorWin.document.body.innerHTML = strIn;
        }
        // Informo di popup bloccato
        catch(e)
        {
                alert("E' stato generato un errore ma non e' possibile\n"  +
                      "visualizzarlo perche' il tuo browser ha i popups disabilitati\n" +
                      "Per visualizzarlo abilita' i popups per questo sito.");
        }
}

/***********************************PARTE DEDICATA AL BLOCCO*************************************/

var timeInfo;

var user = '';

var activeUrl = location.href;
document.write('<div id="infodiv" style="z-index:99"></div>');

function setDivInfo(usrm)
{
	var page = '';

	page +='<html>';
	page +='<head>';
	page +='</head>';
	page +='<body>';
	page +='	<table border="0" width="100%" height="100%" bgcolor="#F4EF81" >';
	page +='		<tr>';
	page +='			<td valign="top" width="85px" height="85px"> <img src="http://fiordilotto.it/lifroccolotto/Immagini/TagBoard/Others/poliziabig.gif"></img></td>';
	page +='			<td valign="top" align="left"><span style="font-family:Verdana;">Ciao ' + usrm + '<br><br>Per accedere al forum richiesto bisogna <br>avere effettuato un post nelle ultime 24 ore</span></td>'; 
	page +='		</tr>';
	page +='		<tr>';
	page +='			<td>&nbsp</td>';
	page +='			<td height="40px" valign="top" align="left"><span style="font-family:Verdana;">Lascia un saluto nel forum e riprova ad accedere</span></td>';
	page +='		</tr>';
	page +='		<tr>';
	page +='			<td>&nbsp</td>';
	page +='			<td>I Forum in cui puoi postare sono i seguenti:';
	page +=         getFreeForum();
	page +='		  </td>';
	page +='		</tr>';
	page +='		<tr rowspan="2">';
	page +='			<td colspan="2" valign="bottom" align="center"><span style="cursor:pointer;font-weight:bold;" onClick="closeDivInfo();"><u>Chiudi</u></span>';
	page +='		</tr>';
	page +='	</table>';
	page +='</body>';
	page +='</html>';


	openDivInfo(page);
}

function setDivInfo2(usrm)
{
	var page = '';

	page +='<html>';
	page +='<head>';
	page +='</head>';
	page +='<body>';
	page +='	<table border="0" width="100%" height="100%" bgcolor="#F4EF81" >';
	page +='		<tr>';
	page +='			<td valign="top" width="85px" height="85px"> <img src="http://fiordilotto.it/lifroccolotto/Immagini/TagBoard/Others/sorrybig.gif"></img></td>';
	page +='			<td valign="top" align="left"><span style="font-family:Verdana;">Ciao ' + usrm + '<br><br>Ci scusiamo per questo inconveniente<br>ma è necessario svuotare la cache del tuo browser<br>per poter usufruire al meglio di tutte le funzioni</span></td>'; 
	page +='		</tr>';
	page +='		<tr>';
	page +='			<td>&nbsp</td>';
	page +='			<td height="40px" valign="top" align="left"><span style="font-family:Verdana;">Se non sai come fare vai <a href="http://lifroccolotto.forumup.it/viewtopic.php?t=254&mforum=lifroccolotto">qui</a> e troverai le istruzioni</span></td>';
	page +='		</tr>';
	page +='		<tr>';
	page +='			<td>&nbsp</td>';
	page +='			<td><img src="http://fiordilotto.it/lifroccolotto/Immagini/TagBoard/Others/thanxbig.gif"></img>';
	page +='		  </td>';
	page +='		</tr>';
	page +='		<tr rowspan="2">';
	page +='			<td colspan="2" valign="bottom" align="center"><span style="cursor:pointer;font-weight:bold;" onClick="closeDivInfo();"><u>Chiudi</u></span>';
	page +='		</tr>';
	page +='	</table>';
	page +='</body>';
	page +='</html>';


	openDivInfo(page);
}

function getFreeForum()
{
	
	var path='http://fiordilotto.it/lifroccolotto/Immagini/Forum/Sezioni/';

	var forums= '';
	
	forums+='<table>';
	forums+='  <tr>';
	forums+='   <td><img src="' + path + 'entrata_small.jpg"></td>';
	forums+='   <td><a href="http://lifroccolotto.forumup.it/viewforum.php?f=13&mforum=lifroccolotto" target="_blank">Benvenuti</a></td>';
	forums+='  </tr>';
	forums+='  <tr>';
	forums+='   <td><img src="' + path + 'neclord_rosik_small.gif.gif"></td>';
	forums+='   <td><a href="http://lifroccolotto.forumup.it/viewforum.php?f=1&mforum=lifroccolotto" target="_blank">Parole in Libertà</a></td>';
	forums+='  </tr>';
	forums+='  <tr>';
	forums+='   <td><img src="' + path + 'slider_like-it_small.gif"></td>';
	forums+='   <td><a href="http://lifroccolotto.forumup.it/viewforum.php?f=3&mforum=lifroccolotto" target="_blank">Notizie Fresche</a></td>';
	forums+='  </tr>';
	forums+='  <tr>';
	forums+='   <td><img src="' + path + 'LoScrigno_altalena_small.gif"></td>';
	forums+='   <td><a href="http://lifroccolotto.forumup.it/viewforum.php?f=6&mforum=lifroccolotto" target="_blank">ControInformazione</a></td>';
	forums+='  </tr>';
	forums+='  <tr>';
	forums+='   <td><img src="' + path + 'dante_small.jpg"></td>';
	forums+='   <td><a href="http://lifroccolotto.forumup.it/viewforum.php?f=18&mforum=lifroccolotto" target="_blank">Poesie, Parole, Riflessioni ed Altro</a></td>';
	forums+='  </tr>';
	forums+='  <tr>';
	forums+='   <td><img src="' + path + 'sogni_1_small.gif"></td>';
	forums+='   <td><a href="http://lifroccolotto.forumup.it/viewforum.php?f=9&mforum=lifroccolotto" target="_blank">Te lo Dico con le Rune</a></td>';
	forums+='  </tr>';
	forums+='  <tr>';
	forums+='   <td><img src="' + path + 'soldi_small.jpg"></td>';
	forums+='   <td><a href="http://lifroccolotto.forumup.it/viewforum.php?f=11&mforum=lifroccolotto" target="_blank">Vinciamo & Gioiamo</a></td>';
	forums+='  </tr>';
	forums+='  <tr>';
	forums+='   <td><img src="' + path + 'problemipc_small.jpg"></td>';
	forums+='   <td><a href="http://lifroccolotto.forumup.it/viewforum.php?f=12&mforum=lifroccolotto" target="_blank">Domande Risposte e Problemi</a></td>';
	forums+='  </tr>';
	forums+='</table>';
	
	return forums;
}

function closeDivInfo()
{
	clearTimeout(timeInfo);
	var mdiv = document.getElementById("infodiv");
	mdiv.innerHTML='';
  mdiv.style.display = "none";

	
}
function openDivInfo(strPage)
{
	var mdiv = document.getElementById("infodiv");
	mdiv.style.position='absolute';
	mdiv.style.background='black';
	mdiv.innerHTML=strPage;
	centerDiv(mdiv);
  mdiv.style.display = "block";
	timeInfo = setTimeout("checkScroll()", 500);

	
}
function checkScroll()
{
	var mdiv = document.getElementById("infodiv");
	centerDiv(mdiv);
	timeInfo = setTimeout("checkScroll()", 500);
}

function centerDiv(mdiv)
{
	var ww;
	var wh;
	var dw;
	var dh;
	if (window.innerWidth)
	{
	  ww = window.innerWidth;
	  wh = window.innerHeight;
  }
  else if (document.documentElement.clientWidth)
	{
	  ww = document.documentElement.clientWidth;
	  wh = document.documentElement.clientHeight;
  }
  else if (document.body.clientWidth)
	{
	  ww = document.body.clientWidth;
	  wh = document.body.clientHeight;
  }
  
  dw = ww/2;
  dh = wh/2;
  
  var t = (wh - dh)/2 + parseInt(document.body.scrollTop);
  var l = (ww - dw)/2 + parseInt(document.body.scrollLeft);
  
  mdiv.style.width =(ww / 2) + 'px';
  mdiv.style.height =(wh / 2) + 'px';
  mdiv.style.top = t  + 'px';
  mdiv.style.left = l + 'px';
  
	
}

function Get_Cookie( check_name ) {
	var a_all_cookies = document.cookie.split( ';' );
	var a_temp_cookie = '';
	var cookie_name = '';
	var cookie_value = '';
	var b_cookie_found = false; 
	
	for ( i = 0; i < a_all_cookies.length; i++ )
	{
		a_temp_cookie = a_all_cookies[i].split( '=' );
		
		
		cookie_name = a_temp_cookie[0].replace(/^\s+|\s+$/g, '');
	
		if ( cookie_name == check_name )
		{
			b_cookie_found = true;
			if ( a_temp_cookie.length > 1 )
			{
				cookie_value = unescape( a_temp_cookie[1].replace(/^\s+|\s+$/g, '') );
			}
			return cookie_value;
			break;
		}
		a_temp_cookie = null;
		cookie_name = '';
	}
	if ( !b_cookie_found ) 
	{
		return null;
	}
}

function Set_Cookie( name, value, expires, path, domain, secure ) {
	
	var today = new Date();
	today.setTime( today.getTime() );
	if ( expires )
	{
		//Giorni
		//expires = expires * 1000 * 60 * 60 * 24;
		
		//Ore
		//expires = expires * 1000 * 60 * 60
		
		//Minuti
		expires = expires * 1000 * 60
	}
	//alert( 'today ' + today.toGMTString() );
	var expires_date = new Date( today.getTime() + (expires) );
	//alert('expires ' + expires_date.toGMTString());

	document.cookie = name + "=" +escape( value ) +
		( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) + //expires.toGMTString()
		( ( path ) ? ";path=" + path : "" ) + 
		( ( domain ) ? ";domain=" + domain : "" ) +
		( ( secure ) ? ";secure" : "" );
}

function Delete_Cookie( name, path, domain ) 
{
	if ( Get_Cookie( name ) ) document.cookie = name + "=" +
			( ( path ) ? ";path=" + path : "") +
			( ( domain ) ? ";domain=" + domain : "" ) +
			";expires=Thu, 01-Jan-1970 00:00:01 GMT";
}




function randomString(sChrs,iLen) 
{
	var sRnd = '';
	for (var i=0; i<iLen;i++)
	{
		var randomPoz = Math.floor(Math.random() * sChrs.length);
		sRnd += sChrs.substring(randomPoz,randomPoz+1);
	}
	return sRnd;
}

function isForumToBlock(text)
{
	if( text.indexOf('Gionni consiglia</a>') > 0 || text.indexOf('Lifrocco Cosa giochiamo?</a>') > 0 ||
			text.indexOf('I Numeri di Papy</a>') > 0 || text.indexOf('volano i numeri</a>') > 0 ||
			text.indexOf('Rita ci prova!!!</a>') > 0 || text.indexOf('Diamo i Numeri</a>') > 0 || 
			text.indexOf('Proviamo cosi tecniche e idee x il lotto</a>') > 0 || text.indexOf('Se può essere utile... Applicazioni web</a>') > 0 ||
			text.indexOf("Alla Ombra dei Numeri</a>") > 0 || text.indexOf("Il Sommativo</a>") > 0 || text.indexOf("Goblin!!</a>") > 0 || location.href.indexOf('search.php?search_author=') > 0)
			return true;
			
	return false;		
	
}

function checkForum(text)
{
	
	
	//if( text.indexOf('notizie fresche</a>') > 0 || text.indexOf('Lifrocco Cosa giochiamo?</a>') > 0)
	if( isForumToBlock(text) )
	{
//alert('Forum to Block' + text);
		user = getUserFromText(text);
		if (user == 'Anita' || user == 'lifroccolotto' || user == 'romana' || user == 'LottoVice' )
			return; 
		var sid = Get_Cookie("lifroccolotto_sid");
//alert(sid);
		if (sid!=null)
		{
			Delete_Cookie('lifroccolotto_sid','/','');
			if (activeUrl.indexOf(sid) > 0)
				return
			else
				location.href='http://lifroccolotto.forumup.it/index.php?mod=noentry';	
			
				
		}
		else
		{	
		
			if ( (user=='gionni' && text.indexOf('Gionni consiglia</a>') > 0) || (user=='Lottovolante' && text.indexOf('volano i numeri</a>') > 0)	|| 
			     (user=='papy' && text.indexOf('I Numeri di Papy</a>') > 0) || (user=='RITA' && text.indexOf('Rita ci prova!!!</a>') > 0)	||
			     (user=='OMBRA' && text.indexOf("Alla Ombra dei Numeri</a>") > 0) || (user=='ilsommativo' && text.indexOf("Il Sommativo</a>") > 0) ||
			     (user=='Goblin' && text.indexOf("Goblin!!</a>") > 0) )
			     return;
			sid = randomString('qwertyuiopasdfghjklzxcvbnm1234567890',25);
			Set_Cookie('lifroccolotto_sid',sid,'2','/','','');
			Set_Cookie('lifroccolotto_user',user,'','/','','');
//var sid2 = Get_Cookie("lifroccolotto_sid");
//alert(sid2);
//alert('redirect');
//			var user = getUser();
			location.href='http://fiordilotto.it/lifroccolotto/javascript/Applicazioni/Counter/redirect.asp?usr=' + user + '&location=' + encodeURIComponent(activeUrl) + '&iid=' + sid;
		}
	}
	
}

/*if (activeUrl == 'http://lifroccolotto.forumup.it/' || activeUrl.indexOf('index.php') > 0)
{
	if (activeUrl.indexOf('kk=asdfghu') <= 0)
		location.href='http://lifroccolotto.forumup.it/index.php?mforum=lifroccolotto&kk=asdfghu';
}*/

if (activeUrl == 'http://lifroccolotto.forumup.it/' || activeUrl.indexOf('index.php') > 0 || activeUrl.indexOf('admin=1') > 0 || activeUrl.indexOf('kk') > 0 || activeUrl.indexOf('posting.php?mode=') > 0 || (activeUrl.indexOf('search.php') > 0 && location.href.indexOf('search.php?search_author=') < 0)  )
{
	user = Get_Cookie("lifroccolotto_user");
	Delete_Cookie('lifroccolotto_sid','/','');
	if (activeUrl.indexOf('index.php') > 0 && activeUrl.indexOf('mod=noentry') > 0)
	{
		setDivInfo(user);
	}
	if (activeUrl.indexOf('index.php') > 0 && activeUrl.indexOf('mod=nocache') > 0)
	{
		setDivInfo2(user);
	}
}
else
{
//alert(activeUrl);
	var callbackForum = checkForum;
	sendRequest(activeUrl,callbackForum, false, 'GET', false);
}



/*************************************************************************************************/

document.write('<META name="description" content="ciao ciao"> ');


document.write('<table><td><a href="http://lifroccolotto.forumup.it"><img src="http://fiordilotto.it/lifroccolotto/casalifrocco.jpg" style="border-style: none"></a><td></table>');

//document.write('<table><td><img src="http://fiordilotto.it/lifroccolotto/Immagini/Forum/Natale/natale22.gif" style="border-style: none"></td>');
//document.write('<td><a href="http://lifroccolotto.forumup.it"><img src="http://fiordilotto.it/lifroccolotto/casalifrocco.jpg" style="border-style: none"></a><td>');
//document.write('<td><img src="http://fiordilotto.it/lifroccolotto/Immagini/Forum/Natale/ghirlana1.gif" style="border-style: none"></td></table>');




//document.write("<font face='times new romans' size=2 color='white'><marquee bgcolor='green' behavior='alternate' scrollamount=5 scrolldelay=50 height=15>");
document.write("<font face='times new romans' size=2 color='white'><marquee bgcolor='green'  scrollamount=5 scrolldelay=50 height=15>");
document.write("<b>Se urli tutti ti sentono,se bisbigli solo chi è vicino,ma se stai in silenzio, solo chi ti AMA ti ascolta.(Mahatma Gandhi)</b></marquee></font>");





document.write('<div id="menuFroumDiv"></div>');


//document.write('<table><td><img src="http://fiordilotto.it/lifroccolotto/Immagini/Forum/Natale/gesubambino2.gif" style="border-style: none"></td>');
//document.write('<td><img src="http://fiordilotto.it/lifroccolotto/Immagini/Forum/Natale/stellacometa.gif" style="border-style: none"><td>');
//document.write('<td><img src="http://fiordilotto.it/lifroccolotto/Immagini/Forum/Natale/gesubambino2.gif" style="border-style: none"></td></table>');



document.write('<div id="provatb"></div>');


