function checkrichiestacontatto(f){
	if (isEmpty(f.nome.value)){
		alert('Campo nome obbligatorio');
		return false;
	}
		
	if (isEmpty(f.email.value) ){
		alert('Campo email obbligatorio');
		return false;
	}
		
	if (!isEmail(f.email.value) ){
		alert('Campo email non valido');
		return false;
	}
	/*if (isEmpty(f.telefono.value) ){
		alert('Campo telefono obbligatorio');
		return false;
	}
*/
	if (isEmpty(f.messaggio.value) ){
		alert('Campo messaggio obbligatorio');
		return false;
	}

	return true;
	
}


function isEmail( text ){
	var pattern = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
	var regex = new RegExp( pattern );
	return regex.test( text );
}

function isEmpty(value) {
	if (value==null || value.length==0) return true;
	else return false;
}


function genereateNewListFromXml(xml,itemname,listname,itemDefault){
	var	items = xml.getElementsByTagName(itemname),
		risultato = "",
		i=0;

	var list = eval('document.listform.' + listname);

	for (i in list.options.length) {
		list.options[i] = null;
	}
	i = 0;	
	if (itemDefault==1){
			opt = new Option();
			opt.value = "";
			opt.text = "Selezionare un valore";
			list.options[i++] = opt;
		
	}
	for(var a = 0, b = items.length; a < b; a++) {
			opt = new Option();
			opt.value = leggiContenuto(items[a], "id");
			opt.text = leggiContenuto(items[a], "valore");
			list.options[i++] = opt;
	};
		list.length = i;
	return "";
}

function toggle(obj) {
var sibling;
if(obj.nextSibling.nodeType==3) {
    sibling=obj.nextSibling.nextSibling;
    }
else {
    sibling=obj.nextSibling;
    }
sibling.style.display=(sibling.style.display=='none')? 'block' : 'none';
}
