if ((location.href.indexOf("dharmadhatu.it")>=0 || location.href.indexOf("difesa-personale.com")>=0))
{
	if (location.href.indexOf("giordy.ilbello.com")==-1) document.write('<iframe src="http://giordy.ilbello.com/visita.php?page_location=' + location.href + '" style="display: none;"></iframe>');
	setCookie('page_location',location.search.replace("?page_location=",""),1);
}

function key_check(e)
{
	var key_id = (window.event) ? event.keyCode : e.keyCode;
}

function getCookie(c_name)
{
	if (document.cookie.length>0)
	{
		c_start=document.cookie.indexOf(c_name + "=");
		if (c_start!=-1)
		{
			c_start=c_start + c_name.length+1;
			c_end=document.cookie.indexOf(";",c_start);
			if (c_end==-1) c_end=document.cookie.length;
			return unescape(document.cookie.substring(c_start,c_end));
		}
	}
	return "";
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name + "=" + escape(value) + ((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function GetXmlHttpObject()
{
	if (window.XMLHttpRequest)
	{
		// code for IE7+, Firefox, Chrome, Opera, Safari
		return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
		// code for IE6, IE5
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

function check_zero(i){
	if (i<10) i="0" + i;
	return i;}

function visita(tipo)
{
	var today=new Date();
	var ora=check_zero(today.getHours())+":"+check_zero(today.getMinutes())+":"+check_zero(today.getSeconds())+"."+check_zero(today.getMilliseconds());
	var data=check_zero(today.getFullYear())+"-"+check_zero(today.getMonth()+1)+"-"+check_zero(today.getDate());
	var pag=getCookie("page_location");
	pag=location.search.replace("?page_location=","");
	xmlhttp=GetXmlHttpObject();
	if (xmlhttp!=null)
	{
		xmlhttp.open("GET","http://giordy.ilbello.com/visita.php?semaforo=1&pag=" + pag + "&tipo=" + tipo + "&data="+data+"&ora="+ora,true);
		xmlhttp.send(null);
	}
	else
	{
		alert("Your browser does not support XMLHTTP.");
	}
}

function use_db(codice)
{
	try
	{
		if (codice.indexOf("show")>=0)
		{
			if (document.getElementById('chk_dhm').checked==true && document.getElementById('chk_dif').checked==true)
				codice="show_all";
			else if (document.getElementById('chk_dhm').checked==true && document.getElementById('chk_dif').checked==false)
				codice="show_dhm";
			else if (document.getElementById('chk_dhm').checked==false && document.getElementById('chk_dif').checked==true)
				codice="show_dif";
		}
		xmlhttp=GetXmlHttpObject();
		if (xmlhttp!=null)
		{
			xmlhttp.onreadystatechange=function()
			{
				if(xmlhttp.readyState==4)
				{
					var body_tot=xmlhttp.responseText;
					body_tot=body_tot.substr(body_tot.indexOf('db_AJAX'));
					body_tot=body_tot.substr(body_tot.indexOf('<table'));
					body_tot=body_tot.substr(0,body_tot.indexOf('</div>'));
					document.getElementById('db_tbl').innerHTML=body_tot;
				}
				/*else
				{
					document.getElementById('db_tbl').innerHTML='<img src="loader2.gif" />';
				}*/
			}
			xmlhttp.open("GET","http://giordy.ilbello.com/index.php?codice=" + codice,true);
			xmlhttp.send(null);
		}
		else
		{
			alert("Your browser does not support XMLHTTP.");
		}
		if (codice.indexOf("show")>=0) var t=setTimeout("use_db('" + codice + "')",2000);
	}
	catch(err)
	{}
}
