//-----------------------
//--CONTROLLO DEL FORM DI 
//--RICERCA
//-----------------------

function checkFormArticoli(which){
	var msg_alert = "Attenzione!";
	var pass = true;
	var checkTitle = 0;
	var checkTitleLength = 0
	var checkAuthorLength = 0
	var checkAuthor = 0;
	var checkDay = 0;
	var checkMonth = 0;
	var checkInt = 0;
	for(i=0;i<which.length;i++){
		if((which.elements[i].name=="TXT_titolo")&&(which.elements[i].value=="")){
			checkTitle++;
		}
		if((which.elements[i].name=="TXT_titolo")&&(which.elements[i].value.length < 3)&&(which.elements[i].value!="")){
			checkTitleLength++;
		}
		if((which.elements[i].name=="TXT_autore")&&(which.elements[i].value=="")){
			checkAuthor++;
		}
		if((which.elements[i].name=="TXT_autore")&&(which.elements[i].value.length < 3)&&(which.elements[i].value!="")){
			checkAuthorLength++;
		}
	}
	if((checkTitle!=0)&&(checkAuthor!=0)){
		msg_alert += "\nE\' necessario compilare almeno un campo tra \"titolo\" e \"autore\".";
		pass = false;
	}
	if((checkTitleLength!=0)||(checkAuthorLength!=0)){
		msg_alert += "\nLa ricerca per il campo \"titolo\" o \"autore\" richiede l\'inserimento di un minimo di tre caratteri.";
		pass = false;
	}
	if(!pass){
		alert(msg_alert);
		return false
	}
}
function controlloSegnalaDoc(){
	var msg_alert = "Attenzione! I seguenti campi sono obbligatori:";
	var pass = true;
	
	if(document.getElementById('note_segnalazione').value == ""){
			msg_alert += "\n -Motivo della segnalazione";
			pass = false;
	}
	
	if(document.getElementById('email').value == ""){
			msg_alert += "\n -Email";
			pass = false;
	}
	
	if(document.getElementById('recaptcha_response_field').value == ""){
			msg_alert += "\n -Codice anti spam";
			pass = false;
	}
	
	if(!pass){
		alert(msg_alert);
		return false;
	}
}

/*function checkFormFascicoli(which){
	var msg_alert = "Attenzione! E\' necessario compilare i campi:";
	var pass = true;
	for(i=0;i<which.length;i++){
		if((which.elements[i].name=="search_anno")&&(which.elements[i].value=="")){
			//alert("Attenzione!\nE\' necessario compliare almeno il campo relativo all'anno");
			msg_alert += "\n -Anno";
			pass = false;
		}
		if((which.elements[i].name=="search_testata")&&(which.elements[i].value=="#")){
			msg_alert += "\n -Testata";
			pass = false;
		}
	}
	if(!pass){
		alert(msg_alert);
		return false
	}
}*/

function checkFormFascicoli(which){
	for(i=0;i<which.length;i++){
		if((which.elements[i].name=="search_anno")&&(which.elements[i].value=="")){
			alert("Attenzione!\nE\' necessario compliare almeno il campo relativo all'anno");
			return false;
		}
	}
}

function checkFormTestate(which){
	for(i=0;i<which.length;i++){
		if((which.elements[i].name=="TXT_posseduto")&&(which.elements[i].value=="")){
			alert("Attenzione!\nE\' necessario compliare almeno il campo relativo all'annata posseduta");
			return false;
		}
	}
}

function checkForm(which){
	for(i=0;i<which.length;i++){
		if((which.elements[i].name=="SearchString")&&(which.elements[i].value=="")){
			alert("Attenzione!\nE\' necessario compliare il campo titolo");
			return false;
		}
	}
}

function FullScreen(theURL) {
  myWin=window.open(theURL,'FullScreen','width=750,height=540,resizable=yes,scrollbars=no');
  myWin.focus();
}

function FullScreenJv(theURL) {
  myWin=window.open(theURL,'FullScreen','width=750,height=540,resizable=yes,scrollbars=no');
  myWin.focus();
}

function annulla_ricerca(dest,form_name){
	document.getElementById('SearchString').value = "";
	document[form_name].action = dest;
	document[form_name].submit();
	return true;
}
