function searchfilms(p)
{
	
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	catch (e)
	{
		alert("Your browser does not support AJAX!");
		return false;
	}
	}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
	
	document.getElementById('results').innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET", "/cerca.php?p=" + p,true);
xmlHttp.send(null);

}
function searchnews(p)
{
	
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	catch (e)
	{
		alert("Your browser does not support AJAX!");
		return false;
	}
	}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
	
	document.getElementById('results').innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET", "/cerca-news.php?p=" + p,true);
xmlHttp.send(null);

}

function inscommenti(commento,idfilm)
{
	var commento;
	var idfilm;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		// Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
	catch (e)
	{
		try
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	catch (e)
	{
		alert("Your browser does not support AJAX!");
		return false;
	}
	}
}
xmlHttp.onreadystatechange=function()
{
if(xmlHttp.readyState==4)
{
	
	document.getElementById('commenti' + idfilm).innerHTML = xmlHttp.responseText;
}
}
xmlHttp.open("GET", "commgen.php?commento=" + commento + "&idfilm=" + idfilm,true);
xmlHttp.send(null);

}


function compila(str)
{
	if (!str)
	{
		alert('Inserisci il tuo commento!!');
		return false;
	}
}

function programmazionecinema(str)
{
	var str;
	
	if (str)
	{
		window.location.href='/programmazione-cinema/'+str+'/';
	}	else	{
		window.location.href='/programmazione-cinema.php';	
	}
}

   
function ajaxLoader(url,id)
{
	if (document.getElementById) {
		var x = (window.ActiveXObject) ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest();
		}
		if (x)
			{
		x.onreadystatechange = function()
				{
			if (x.readyState == 4 && x.status == 200)
					{
					el = document.getElementById(id);
					
					el.innerHTML = x.responseText;
				}
				}
			x.open("GET", url, true);
			x.send(null);
			}
	}


// Validazione email javascript
function controllomail(mail){
	var espressione = /^[_a-z0-9+-]+(\.[_a-z0-9+-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)+$/;
	if (!espressione.test(mail))
	{
	    alert("La mail inserita non è valida!");
		return false;
	}
}
// Controllo campo testo non vuoto
function controllotesto(testo){
	if (!testo)
	{
	    alert("Inserisci il tuo nome per salvare la recensione e partecipare!");
		return false;
	}
}

// controllo textarea
function contatore(val)
{
  var max = 2000
  if (val.commento.value.length > max) {
    val.commento.value = val.commento.value.substring(0,max)
    rest = 0
  } 
  else
  {
    rest = max - val.commento.value.length
  }
  val.num.value = rest
}