
function lunchboxOpen(lunchID)
{
	document.getElementById('lunch_' + lunchID).style.display = "block";
	document.getElementById('clasp_' + lunchID).innerHTML="<a href=\"javascript:lunchboxClose('" + lunchID + "');\"><strong>"+mess2+"</strong> " +"</a>";
}
function lunchboxClose(lunchID)
{
	document.getElementById('lunch_' + lunchID).style.display = "none";
	document.getElementById('clasp_' + lunchID).innerHTML="<a href=\"javascript:lunchboxOpen('" + lunchID + "');\"><strong>"+mess1+"</strong> " +"</a>";
} 


function changeFontSize(inc)
{
	var p=document.getElementsByTagName('p');
	for(n=0;n<p.length;n++)
	{
		if(p[n].style.fontSize)
		{
			var size=parseInt(p[n].style.fontSize.replace("px",""))
		}
		else
		{
			var size=12
		}
		p[n].style.fontSize=size+inc+'px';
	}
}


function inviaRichiesta()
{
	var contatti_nome=document.getElementById("contatti_nome").value;
	var contatti_email=document.getElementById("contatti_email").value;
	var contatti_messaggio=document.getElementById("contatti_messaggio").value;
	
	if(controlloMail2(contatti_email) && contatti_nome!="" && contatti_messaggio!="")
	{
		document.contactform.submit();
	}
	else
	{
		alert("Indicare tutti i dati in maniera corretta")
		return;
	}
	
}


function openInformativa(path)
{
	var w = 300;
	var h = 250;
	var l = Math.floor((screen.width-w)/2);
	var t = Math.floor((screen.height-h)/2);
	window.open(path+"/informativa.html","","width=" + w + ",height=" + h + ",top=" + t + ",left=" + l+",scrollbars=no,toolbar=no,status=no,location=no,menubar=no");
	
}

function verificaDati()
{
	var flag=true;
	if(!controlloCampo("nomecognome_richiesta"))
	{
       alert("Indicare il Nome e Cognome");
       flag=false;	
	}
	if(!controlloCampo("email_richiesta"))
	{
       alert("Indicare l'indirizzo e-mail");	
       flag=false;
    }
    if(!controlloMail("email_richiesta"))
    {
    	flag=false;
    }
	if(!controlloCampo("richiesta_hotel"))
	{
       alert("Indicare la richiesta");
       flag=false;	
    }
    if(!document.getElementById("check_informativa").checked)
    {
       alert("E' necessario accettare l'informativa sulla privacy");
       flag=false;
    }  
    var nosp=document.getElementById("nosp").value;
    if(flag && nosp=="")
		document.disponibilitaform.submit();
	else
		return;	
}


function controlloCampo(campo)
{
   if(document.getElementById(campo).value=='')
	{
		return false;	
    }
 return true;
 }
 
function settaComboValue(campo,valore)
{
	if(valore!="")
	   document.getElementById(campo).options.value=valore;
}

function controlloMail(campo)
{
  var valCampo=document.getElementById(campo).value;
  if(valCampo != "")
  {
		if(valCampo.indexOf("@") == -1)
		{
			if(valCampo.indexOf(".") == -1)
			{
            	alert("Inserire correttamente l'indirizzo e-mail");
                document.getElementById(campo).value = "";
                document.getElementById(campo).focus();
                return false;
            }
        }
   } 
return true;
}



function setComboValue(document,comboName,param)
{
	if(param!='')
	{
		var comboLength = document.getElementById(comboName).length;
	
		for(var i = 0; i < comboLength; i++) 
		{
			if(document.getElementById(comboName).options[i].value==param) 
			   document.getElementById(comboName).options.selectedIndex=i;
			
		}
	}
}

function txtFileUpdate(inputtext,file)
{
   var filename=document.getElementById(file).value;
   var estensione=filename.substr(filename.length-3,3); 		
  
   if((estensione.toUpperCase() =='JPG')|| (estensione.toUpperCase() =='GIF')|| (estensione.toUpperCase() =='PNG')|| (estensione.toUpperCase() =='BMP'))
   {
      var filepath=document.getElementById(file).value;
      filepath=filepath.replace("fakepath","FILEPATH") 
      document.getElementById(inputtext).value=filepath;
   }
   else
   {
   	  alert(uploadmess);
   }
   return true;
}


function checkNumImporti()
{

	var ie = (navigator.appName.indexOf('Microsoft Internet Explorer')>-1); 
	if(ie) 
	{
    		key = event.keyCode; 
  	} 
	else key = e.which;
  	  
  	
	if((event.ctrlKey && key==86) || key==188 || key == 110 || key == 37 || key== 39 || key==9) return true;
  		
  		  		
  	if((key < 48 || key > 58) && (key != 8 && key != 13 && key != 46 )) 
   	{
        	if(key < 96 || key > 105)		
        	return false;                	
        }
  		
	return true;
}


function checkNumData()
{

	var ie = (navigator.appName.indexOf('Microsoft Internet Explorer')>-1); 
	if(ie) 
	{
    		key = event.keyCode; 
  	} 
	else key = e.which;
  	  
  	
	if((event.ctrlKey && key==86) || key==16 || key == 37 || key== 39 || key==9) return true;
  		
  		  		
  	if((key < 48 || key > 58) && (key != 8 && key != 13 && key != 46 )) 
   	{
        	if(key < 96 || key > 105)		
        	return false;                	
        }
  		
	return true;
}
function controlloMail2(valCampo)
{
  if(valCampo != "")
  {
		if(valCampo.indexOf("@") == -1)
		{
			if(valCampo.indexOf(".") == -1)
			{
            	return false;
            }
        }
   } 
return true;
}



