var xmlHttp;

function GetXmlHttpObject() 
{
	var xmlHttp=null;
	try
	{
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		//Internet Explorer
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

function frmsubmit(func) {
	frm = document.entryform;
	frm.func.value = func;
	frm.submit();
}	

function cambio_pagina(p) {
	document.forms['entryform'].npagina.value = p;
	document.forms['entryform'].submit();
}

function apri_finestra(pagina) { 
	var id=window.open(pagina,'AP-GPM','height=300,width=550,status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes'); 
	id.focus();
}

function apri_evento(pagina,w,h) {
	var idw=window.open(pagina,'evento','status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes, height='+h+',width='+w );
	idw.focus();
}

function Archivio (data,m){
	var iw=window.open('popuparchivionews.php?date=' + data + '&m=' + m,'Archivio','toolbar=0,location=0,directories=0,menuBar=0,scrollbars=1,resizable=0,width=620,height=450,left=0,top=0');
    	iw.focus();
}

function apri_faq(idd) {
	var iw=window.open('risposta.php?id=' + idd,'FAQ','height=300,width=680,status=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=yes');
	iw.focus();
}

function cambio_paginafoto(p) {
	document.forms['paginafoto'].npagina.value = p;
	document.forms['paginafoto'].submit();
}

function aggiungi_cart(nomeform) {
	document.forms[nomeform].submit();
}
function apri_cartina(pagina,w,h) {
	var idw=window.open(pagina,'cartina','status=no,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes, height='+h+',width='+w );
	idw.focus();
}
function apri_credits(pagina,w,h) {
	var idw=window.open(pagina,'cartina','status=no,statusbar=no,toolbar=no,menubar=no,location=no,scrollbars=no,resizable=no, height='+h+',width='+w );
	idw.focus();
}
function apri_videonews(p) {
	document.forms['frm' + p].submit();
}
function apri_videonews_gc(p) {
	document.forms['frmgc' + p].submit();
}

function inviaFormCopia(v,m,f)
{
	tot = f.totale;
	n = 0;
	i = 1;
	pr = 7;

	mess = "";
	for (i=1;i<=tot;i++)
	{
		if (f['c'+i])
		{
			mess+=i+": "+f['c'+i]+"#";
		}
	}
	alert(mess);

}

function copiaPalinsestoOLD(dataPal)
{
	errore = 0;
	msg = "";

	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) 
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	dt = document.getElementById("dataCopia"+dataPal).value;
	var url="/ajax/copiaPalinsesto.php";
	url+="?d="+dt;
	url+="&dp="+dataPal;
	url+="&sid="+Math.random();
	xmlHttp.onreadystatechange = function () 
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") 
		{ 
			if (xmlHttp.responseText != "") 
			{
				$.prompt(xmlHttp.responseText, {callback: inviaFormCopia});
			}
		} 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function copiaPalinsesto(dataPal, i)
{
	errore = 0;
	msg = "";

	xmlHttp = GetXmlHttpObject();
	if (xmlHttp==null) 
	{
		alert ("Browser does not support HTTP Request");
		return;
	}
	for (j=1; j<8;j++)
	{
		document.getElementById("dCopia"+j).innerHTML = "";
		document.getElementById("dCopia"+j).className = "invisibile";
	}
	dt = document.getElementById("dataCopia"+dataPal).value;
	var url="/ajax/copiaPalinsesto.php";
	url+="?d="+dt;
	url+="&dp="+dataPal;
	url+="&sid="+Math.random();
	xmlHttp.onreadystatechange = function () 
	{
		if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete") 
		{ 
			if (xmlHttp.responseText != "") 
			{
				document.getElementById("dCopia"+i).innerHTML = xmlHttp.responseText;
				document.getElementById("dCopia"+i).className = "visibile";
			}
		} 
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function selezionaTuttiPalinsesto()
{
	errore = 0;
	msg = "";
	
	tot = document.getElementById("totale").value;
		
	for (j=1; j<=tot;j++)
	{
		document.getElementById("c"+j).checked = true;
	}
	
}

function deselezionaTuttiPalinsesto()
{
	errore = 0;
	msg = "";
	
	tot = document.getElementById("totale").value;
		
	for (j=1; j<=tot;j++)
	{
		document.getElementById("c"+j).checked = false;
	}
	
}
