function view(param)
{
	window.open('./view.php?id='+param,'Annuncio','scrollbars=yes,resizable=no,width=500,height=450,status=no,location=no,toolbar=no');
}
function foto(param)
{
	window.open('./foto.php?id='+param,'Foto','scrollbars=yes,resizable=no,width=500,height=450,status=no,location=no,toolbar=no');
}
function foto_admin(param)
{
	window.open('../foto.php?id='+param,'Foto','scrollbars=yes,resizable=no,width=500,height=450,status=no,location=no,toolbar=no');
}

function lettersOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 65 || charCode > 90) && 
        (charCode < 97 || charCode > 122)) {
        alert("Puoi inserire solo lettere!");
        return false;
    }
    return true;
}

function apri(par,num)
{
	if(par == 'res')
	{		
		if(document.getElementById("bott_res_1").className == "bott_vis")
		{
			for (i=1 ; i<=num; i++)
			{
				document.getElementById("bott_res_"+i).className = "bott_nasc";
			}
		}
		else
		{
			for (i=1 ; i<=num; i++)
			{
				document.getElementById("bott_res_"+i).className = "bott_vis";
			}
		}
	}
	else if(par == 'impr')
	{
		if(document.getElementById("bott_impr_1").className == "bott_vis")
		{
			for (i=1 ; i<=num; i++)
			{
				document.getElementById("bott_impr_"+i).className = "bott_nasc";
			}
		}
		else
		{
			for (i=1 ; i<=num; i++)
			{
				document.getElementById("bott_impr_"+i).className = "bott_vis";
			}
		}
	}
}

function numeralsOnly(evt) {
    evt = (evt) ? evt : event;
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : 
        ((evt.which) ? evt.which : 0));
    if (charCode > 31 && (charCode < 48 || charCode > 57)) {
        alert("Puoi inserire solo numeri!");
        return false;
    }
    return true;
}


// richiamata per verificare che abbia immesso i dati nel form codice cliente di cash.php per completare l'ordine
function cod_validate(form)
{
	if (form.cod_utente.value.length == 0)
		{
			alert('Nessun codice inserito!');
			return false;
		}
}

// richiamata per verificare che abbia immesso i dati nel form
function valid(form)
{

	titolo = form.titolo.value;
	testo_ann = form.testo_ann.value;
	
	if (titolo == '' || testo_ann=='')
		{
			alert('Attenzione, dati mancanti nella compilazione!');
			return false;
		}
}
// richiamata per verificare che abbia immesso i dati nel form
function valid2(form)
{

	tipo_ann = form.tipo_ann.value;
	
	if (tipo_ann=='')
		{
			alert('Attenzione, dati mancanti nella compilazione!');
			return false;
		}
}
// richiamata per verificare che abbia immesso i dati nel form
function valid3(form)
{

	nome = form.nome.value;
	msg = form.msg.value;
	email = form.email.value;
	
	if (nome=='' || msg=='' || email =='')
		{
			alert('Attenzione, dati mancanti nella compilazione!');
			return false;
		}
}
window.onload = function(){
/*	document.getElementById("bott_res_1").className = "bott_nasc";
	document.getElementById("bott_res_2").className = "bott_nasc";*/
	
}
window.onresize = function(){
	var uls = document.getElementById("bott_home").className;
	document.getElementById("bott_home").className = uls;	
}

function SelectFilter (theKind, theSelect, source, theSelIndex)
{
		//alert('Source: '+source);
	if (source)
	{
		if (theSelIndex == '')	theSelIndex = 0;
		theComList = (document.getElementById(theKind + 'data').value).match (new RegExp ('#' + source + '[^#]*'));
		
		if (theComList)
		{
			theComItems = theComList[0].split ('|');
			with (theSelect.form[theKind])
			{
				options.length = 0;
				options[0] = new Option( '', '')
				
				for ( theIndex = 1; theIndex < theComItems.length -1; theIndex++) 
				{
					options[theIndex] = new Option( theComItems[theIndex], theComItems[theIndex])
					if (theComItems[theIndex] == theSelIndex)	
					{
						options.selectedIndex=theIndex;
					}
				}
			}
		}
		else
			theSelect.form[theKind].options.length = 0;
	}
	else
		theSelect.form[theKind].options.length = 0;
}
	
function ca(provincia,comune)
{ 
	//alert("entrato"+provincia+ " "+ comune);
//	document.getElementById('provinc_ann').selectedIndex = provincia;
	SelectFilter('com', document.getElementById('provinc_ann'), provincia,comune);
}
function set_tipo(tipo,sez)
{ 
	//alert("entrato"+provincia+ " "+ comune);
//	document.getElementById('tipolo_ann').selectedIndex = tipo;
	SelectFilter('sub', document.getElementById('tipolo_ann'), tipo,sez);
}

function no_punto_virgo(valx){
		document.getElementById(valx).value = document.getElementById(valx).value.replace(".","");
		document.getElementById(valx).value = document.getElementById(valx).value.replace(",","");
		document.getElementById(valx).value = document.getElementById(valx).value.replace("t","");
		document.getElementById(valx).value = document.getElementById(valx).value.replace("n","");
		document.getElementById(valx).value = document.getElementById(valx).value.replace("€","");	
		document.getElementById(valx).value = document.getElementById(valx).value.replace("T","");
		document.getElementById(valx).value = document.getElementById(valx).value.replace("N","");
		document.getElementById(valx).value = document.getElementById(valx).value.replace("e","");		
		document.getElementById(valx).value = document.getElementById(valx).value.replace("E","");
}	