function autoComplete (field, select, property, forcematch) {
	var found = false;
	for (var i = 0; i < select.options.length; i++) {
	if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
		found=true; break;
		}
	}
	if (found) { select.selectedIndex = i; }
	else { select.selectedIndex = 0; }
	if (field.createTextRange) {
		if (forcematch && !found) {
			field.value=field.value.substring(0,field.value.length-1); 
			return;
			}
		var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
		if (cursorKeys.indexOf(event.keyCode+";") == -1) {
			var r1 = field.createTextRange();
			var oldValue = r1.text;
			var newValue = found ? select.options[i][property] : oldValue;
			if (newValue != field.value) {
				field.value = newValue;
				var rNew = field.createTextRange();
				rNew.moveStart('character', oldValue.length) ;
				rNew.select();
				}
			}
		}
	}


function popWin(url, name, w, h, scroll, resizable) {
			var winl = (screen.width - w) / 2;
			var wint = (screen.height - h) / 2;
			
			scroll = (scroll) ? scroll:"auto"
			resizable = (resizable) ? resizable:"yes"
			
			if(wint > 70 ) wint -= 50;
			
			var winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable=no';
			
			var win = window.open(url, name, winprops);
		 	win.window.focus(); 
		}
		
function CheckForm(AForm)
 {
 if ( trim(AForm.autore.value) == ""  )
 {
  alert("Errore: manca il nome");
  AForm.autore.focus();
  return false;
 }
 if (trim(AForm.email.value) == "")
 {
  alert("Errore: manca l'indirizzo di email");
  AForm.email.focus();
  return false;
 }
  if (trim(AForm.messaggio.value) == "" )
 {
  alert("Errore: inserire un messaggio");
  AForm.messaggio.focus();
  return false;
 }
}

function CheckLogin(AForm)
{
	if (trim(AForm.nick.value) == "" )
	{
		alert("Errore: manca il nickname");
		AForm.nick.focus();
		return false;
	}
	if (trim(AForm.pswd.value) == "" )
	{
		alert("Errore: manca la password");
		AForm.pswd.focus();
		return false;
	}
}

function toggleAvanzata() {
   var div = document.getElementById('ricerca-avanzata');
   if(div.style.display == "block")
   	div.style.display = "none";
   else
   	div.style.display = "block";
}

var myimages=new Array();
function preloadimages(){
	for (i=0;i<preloadimages.arguments.length;i++){
		myimages[i]=new Image()
		myimages[i].src=preloadimages.arguments[i]
	}
}