<!--
/**
 * Raccolta di funzioni per il check dei contenuti forms 
 */

/**
 * Verifica l'integrita  di un indirizzo email
 * @param string str
 */
function emailok(str)
{
	var filter=/^.+@.+\..{2,3}$/
	return (filter.test(str));
};

/**
 * Fa il check integrita dati form
 */
function formcheck(which){

/* inizio check elementi obbligatori */
	var pass=true;
	var primo=0;

	for (i=0;i<which.length;i++){
		var tempobj=which.elements[i];
		if (tempobj.name.substring(0,3)=="req"){
			if (((tempobj.type=="text"||tempobj.type=="textarea")&&tempobj.value=='')||(tempobj.type.toString().charAt(0)=="s"&&tempobj.selectedIndex==-1)){
				pass=false;
				tempobj.style.background="#FF0000";
				tempobj.style.color="#FFFFFF";
			}else{
				tempobj.style.background="#FFFFFF";
				tempobj.style.color="#000000";
			}
		}
	}
/* fine check elementi obbligatori */


	if(which.reqemail.value!='') /* check mail */
	{
		if(!emailok(which.reqemail.value))
		{
			which.reqemail.focus();
			which.reqemail.style.background="#FF0000";
			which.reqemail.style.color="#FFFFFF";
			return false;	
		}else{
			which.reqemail.style.background="#FFFFFF";
			which.reqemail.style.color="#000000";
		}
	}

	if (!pass){ /* se mancano dei parametri obbligatori */
		return false;
	}

	
	return true;
}



//-->

