// refresha sulla status bar sempre questo messaggio
function Rstatus()
{
	defaultStatus = "- - -"
	setTimeout(Rstatus,5);
}

//Rstatus();

// richiamata per visualizzare una pop-up
function wnd(id)
{
	window.open('/foto.php?id='+id,'Foto'+id,'scrollbars=no,resizable=no,width=500,height=400,status=no,location=no,toolbar=no');
}
function foto_admin(id)
{
	window.open('../foto.php?id='+id,'Foto'+id,'scrollbars=no,resizable=no,width=500,height=400,status=no,location=no,toolbar=no');
}
// richiamata per visualizzare l'annuncio dalla home page
function view_annuncio(id)
{
	window.open('/view_annuncio.php?id='+id,'View_Annuncio','scrollbars=no,resizable=no,width=440,height=600,status=no,location=no,toolbar=no');
}
function view(param)
{
	window.open('./view.php?id='+param,'Annuncio','scrollbars=yes,resizable=no,width=500,height=550,status=no,location=no,toolbar=no');
}

function mod_annuncio(id)
{
	window.open('./mod_annuncio.php?id='+id,'Mod_Annuncio','scrollbars=yes,resizable=no,width=640,height=510,status=no,location=no,toolbar=no');
}
// carica la provincia selezionata
function carica_prov(Form,op,id_ann) 
{
	//	op opzione per tornare nella sezione in cui si sta lavorando (Es. 'new_ann', 'mod_ann')
	// id_ann per passare l'id dell'annuncio che si sta modificando
	var str='',str1='',str2='';
	if(id_ann != '')
	{
		str="&id="+id_ann;
	} 
	
	if(Form.id_tipo_ann.value != '')
	{
		str1="&id_tipo_ann="+Form.id_tipo_ann.value;
	}
	if(op != '')
	{
	
		str2="&op="+op;
	}
	location = "?prov=" + Form.prov.value + str2 + str + str1; 
}


// carica il comune selezionato 
function carica_comune(Form,op,id_ann) 
{
	//	op opzione per tornare nella sezione in cui si sta lavorando (Es. 'new_ann', 'mod_ann')
	// id_ann per passare l'id dell'annuncio che si sta modificando
	var str='',str1='',str2='';
	
	if(id_ann != '')
	{
		str="&id="+id_ann;
	} 
	if(Form.id_tipo_ann.value != '')
	{
		str1="&id_tipo_ann="+Form.id_tipo_ann.value;
	}
	if(op != '')
	{
	
		str2="&op="+op;
	}
	location = "?prov=" + Form.prov.value + "&com=" + Form.com.value+str2+str1+str;
}

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 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)
{

	localita = form.localita.value;
	testo_ann = form.testo_ann.value;
	
	if (localita == '' || 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;
		}
}


	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('XFormField_mar').selectedIndex = provincia;
		SelectFilter('com', document.getElementById('XFormField_mar'), provincia,comune);
	}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}