/*///////////////////////////////////////////////////////////////////
Funzione per contare i caratteri di una text area
//////////////////////////////////////////////////////////////////*/
   var submitcount=0;
   function checkSubmit() {

      if (submitcount == 0)
      {
      submitcount++;
      document.Surv.submit();
      }
   }


function wordCounter(field, countfield, maxlimit) {
wordcounter=0;
for (x=0;x<field.value.length;x++) {
      if (field.value.charAt(x) == " " && field.value.charAt(x-1) != " ")  {wordcounter++}  // Counts the spaces while ignoring double spaces, usually one in between each word.
      if (wordcounter > 250) {field.value = field.value.substring(0, x);}
      else {countfield.value = maxlimit - wordcounter;}
      }
   }

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit)
      {field.value = field.value.substring(0, maxlimit);}
      else
      {countfield.value = maxlimit - field.value.length;}
  }
  

// JavaScript Document

//controllo form ricerca
function controllaFormRicerca()
{
	if (window.document.formSearch.chiave.value=='')
		{
				alert("Attenzione! Devi inserire una parola chiave!!"); 
			
			window.document.formSearch.chiave.focus();
			return false;
		}
	
		else 
		return true;
}

//controllo form newsletter
function controllanewsletter()
		{
			var email = document.formnewsletter.email.value;
			var email_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
			
			if (!email_reg_exp.test(email) || (email == "") || (email == "undefined")) 
			{
				document.formnewsletter.email.select();
				alert("Inserire un indirizzo email corretto.");
				return false;
			}
			else
			return true;
		}

function rasetMail(){
document.formnewsletter.email.value = '';
}
function valorizeMail()
{

if (document.formnewsletter.email.value == 'la tua e-mail' || document.formnewsletter.email.value == ''){alert('Inserire una email valida');document.formnewsletter.email.focus();return false;}
}

/*********************************************************************************************
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
FUNZIONI DATAGRID DIV DISLAY INLINE e NONE
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
*********************************************************************************************/
///////////////////////////////////////////////////////////////////
// Funzioni per controllare la visualizzazione delle tabelle o div
// basta passare come valore l'oggetto che si deve visualizzare
// esempio: <a href="javascript:openObject('lista');">test</a>
// lista è ID="lista"
/////////////////////////////////////////////////////////////////// 
function openObject(openObject){
	
obj=document.getElementById(openObject);
obj.style.display="inline";}
		
function closeObject(closeObject){
obj=document.getElementById(closeObject);
obj.style.display="none";}		


function openObjectVisibility(openObject){
	
obj=document.getElementById(openObject);
obj.style.visibility="visible";}
		
function closeObjectVisibility(closeObject){
obj=document.getElementById(closeObject);
obj.style.visibility="hidden";}	


/*********************************************************************************************
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
RISOLUZIONE MONITOR UTENTE
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
*********************************************************************************************/
function getBrowserWidth(){
		if (window.innerWidth)
		{
			return window.innerWidth;
		}	
		else if (document.documentElement && document.documentElement.clientWidth != 0)
		{
			return document.documentElement.clientWidth;
		}
		else if (document.body)
		{
			return document.body.clientWidth;
		}		
			return 0;
	}
	
	
/*********************************************************************************************
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
POP UP
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
*********************************************************************************************/
function newWindowSpot() 
	{
		mywindow=open('../../_popup/popup_cerca_spot.php','myname','resizable=no,scrollbars=yes,width=500,height=300');
		mywindow.location.href = '../../_popup/popup_cerca_spot.php';
		if (mywindow.opener == null) mywindow.opener = self;
	}


//trova user
function newWindowUser() 
	{
		mywindow=open('../../_popup/popup_user.php','myname','resizable=no,scrollbars=yes,width=500,height=300');
		mywindow.location.href = '../../popup_user.php';
		if (mywindow.opener == null) mywindow.opener = self;
	}


//trova localita
function newWindow1() 
	{
		mywindow=open('../../_popup/popup_localita.php','myname','resizable=no,scrollbars=yes,width=500,height=300');
		mywindow.location.href = '../../_popup/popup_localita.php';
		if (mywindow.opener == null) mywindow.opener = self;
	}
	
	
function  controllo_numero()
				{
					if (document.myForm.numeroimmagini.value == "" || document.myForm.numeroimmagini.value == "undefined") 
						{
							alert('ATTENZIONE: devi inserire il numero di immagini!');
							return false;
							window.document.myForm.numeroimmagini.focus();
						}
				}
				
				
var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height)
				{
				
				  if(popUpWin)
				  {
					if(!popUpWin.closed) popUpWin.close();
				  }
				  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=no,resizable=yes,copyhistory=yes,width='+width+',height='+height+',left='+left+', top='+top+',screenX='+left+',screenY='+top+'');
				}
				
/*********************************************************************************************
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
CONTROLLO ELIMINAZIONE RECORD
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
*********************************************************************************************/				
//onclick="return functionConferma();"
//<SCRIPT LANGUAGE=javascript  src="../../_js/comuni/comuni.js"></script>
			function functionConferma()
			{
			action = confirm ('Confermi eliminazione? Operazione non annullabile!')
			if(action==false){alert('operazione annullata');return false;}
			else{return true;}			
			}
			
			
			
/*********************************************************************************************
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
CONTROLLO ELIMINAZIONE RECORD
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
*********************************************************************************************/				
//onclick="return functionConferma();"
//<SCRIPT LANGUAGE=javascript  src="../../_js/comuni/comuni.js"></script>
			function functionConferma()
			{
			action = confirm ('Confermi eliminazione? Operazione non annullabile!')
			if(action==false){alert('operazione annullata');return false;}
			else{return true;}			
			}	

/*********************************************************************************************
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
DIV APERTURA
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
*********************************************************************************************/	
			
/***********************************************
* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

function getposOffset(overlay, offsettype){
var totaloffset=(offsettype=="left")? overlay.offsetLeft : overlay.offsetTop;
var parentEl=overlay.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function overlay(curobj, subobjstr, opt_position){
if (document.getElementById){
var subobj=document.getElementById(subobjstr)
subobj.style.display=(subobj.style.display!="block")? "block" : "none"
var xpos=getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("right")!=-1)? -(subobj.offsetWidth-curobj.offsetWidth) : 0) 
var ypos=getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1)? curobj.offsetHeight : 0)
subobj.style.left=xpos+"px";
subobj.style.top=ypos+"px";
window.location.replace('#viewTop');
return false
}
else
return true
}

function overlayclose(subobj){
document.getElementById(subobj).style.display="none"
}

//specifioco per globospotguide, chiude tutti i div prima di aprire quello selezionato (evita over dei div)
function chiudiAllDivLocalita(){
document.getElementById('descrizioneNazione').style.display="none";
document.getElementById('nazioneMeteo').style.display="none";
document.getElementById('nazioneMaps').style.display="none";
document.getElementById('nazioneNews').style.display="none";
document.getElementById('descrizioneRegione').style.display="none";
document.getElementById('regioneMeteo').style.display="none";
document.getElementById('regioneMaps').style.display="none";
document.getElementById('descrizioneCitta').style.display="none";
document.getElementById('cittaMeteo').style.display="none";
document.getElementById('cittaMaps').style.display="none";
document.getElementById('cittaMapsGoogle').style.display="none";
}


function controlLogin(username,password,form){
	var username;
	var password;
	var form;
	if(username == 'username' || username == '')
	{
		alert('Username errata!');
		document.forms[form].username.focus();
		return false;
	}
	if(password == 'password' || password == '')
	{
		alert('Password errata!');
		document.forms[form].password.focus();
		document.forms[form].password.value = '';
		return false;
	}
	return true;
}

/*********************************************************************************************
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
SELECT INVIO
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
*********************************************************************************************/	
			
/***********************************************
* Drop Down/ cliccando va nell'altro punto indicato
* This notice must stay intact for legal use.
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/
function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

/*********************************************************************************************
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
CONTROLLO IMMAGINI
**********************************************************************************************
**********************************************************************************************
**********************************************************************************************
*********************************************************************************************/	
function doBlink()
{
	//Vrifica che il testo sia visibile al caricamento della pagina
	
	//if (blink.style.color == "")
	//{
	//blink.style.color= "#F90";
	//}
	//Nasconde il testo
	//else
	//{
	//blink.style.color = "";
	//}
	//;
}

//Temporizza la funzione doBlink() creando un intervallo di mezzo secondo
//x = window.setInterval("doBlink()", 500)