

function validateForm2(){
  	thisForm=document.formmail;
	thisForm.submit();
}

function eliminaSposi(nomeForm) {
				if (confirm("Sei sicuro di voler cancellare queste coppie?				")) {
				thisForm=document.forms[nomeForm];	
				thisForm.submit();
				}
			}
			
			
function applica_color(colore){ //Deve ricevere il tag da inserire
  var SelectedString = document.selection.createRange().text;
  var ReplaceString = '<font color="'+colore+'">'+SelectedString+'</font>';
  if (SelectedString!='') document.selection.createRange().text = ReplaceString;
}

function validateForm(){
	thisForm=document.formmail;
	for(var i=0; i<thisForm.elements.length; i++){
		if(thisForm.elements[i].value==""){
			alert("E' necessario riempire tutti i campi");
			thisForm.elements[i].focus();
			return;
		}
	}
	thisForm.submit();
}

function operazione(op, id, nomeForm){
	thisForm=document.forms[nomeForm];
	switch(op){
		case "modifyCat":
			document.location.href='categorie.php?id='+id;
		break;
		
		case "deleteCat":
			var cliccato=false;
			for(var i=0; i<thisForm.elements.length; i++){
				if(thisForm.elements[i].type=="checkbox"){
					if(thisForm.elements[i].checked) cliccato=true;
				}
			}
			if(!cliccato){
				alert("Selezionare almeno una categoria");
				return;
			}
			thisForm.action.value="deleteCat";
			thisForm.submit();
		break;
		
		case "update":
			if(thisForm.titolo==''){
				alert("Inserire un titolo");
				thisForm.titolo.focus();
				return;
			}
			if(thisForm.testo==''){
				alert("Inserire un testo");
				thisForm.testo.focus();
				return;
			}
			thisForm.submit();
		break;
		case "insert":
			if(thisForm.titolo==''){
				alert("Inserire un titolo");
				thisForm.titolo.focus();
				return;
			}
			if(thisForm.testo==''){
				alert("Inserire un testo");
				thisForm.testo.focus();
				return;
			}
			thisForm.submit();
		break;
		
		case "insertCat":
			if(thisForm.nome==''){
				alert("Inserire un nome");
				thisForm.nome.focus();
				return;
			}
			thisForm.submit();
		break;
		
		case "reset":
			thisForm.clear();
		break;
		
		case "public":
			var cliccato=false;
			for(var i=0; i<thisForm.elements.length; i++){
				if(thisForm.elements[i].type=="checkbox"){
					if(thisForm.elements[i].checked) cliccato=true;
				}
			}
			if(!cliccato){
				alert("Selezionare almeno un oggetto");
				return;
			}
			thisForm.action.value="public";
			thisForm.submit();
		break;
		
		case "private":
			var cliccato=false;
			for(var i=0; i<thisForm.elements.length; i++){
				if(thisForm.elements[i].type=="checkbox"){
					if(thisForm.elements[i].checked) cliccato=true;
				}
			}
			if(!cliccato){
				alert("Selezionare almeno un oggetto");
				return;
			}
			thisForm.action.value="private";
			thisForm.submit();
		break;
		
		case "delete":
			var cliccato=false;
			for(var i=0; i<thisForm.elements.length; i++){
				if(thisForm.elements[i].type=="checkbox"){
					if(thisForm.elements[i].checked) cliccato=true;
				}
			}
			if(!cliccato){
				alert("Selezionare almeno un oggetto");
				return;
			}
			thisForm.action.value="delete";
			thisForm.submit();
		break;
	}
}

 function PopupCentrata(lang,struttura) {
   var w = 680;
   var h = 600;
   var l = Math.floor((screen.width-w)/2);
   var t = Math.floor((screen.height-h)/2);
      window.open('http://www.inumbriabandb.it/form/inserimento.php?lang='+lang+'&struttura='+struttura,"","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l+",scrollbars=yes");
      }





