// Funzioni Javascript 

// Apre una nuova finestra per ingrandimento foto
	function OpenFoto( urlpagina, w, h )
	{
		var WindowObjectReference; // global variable
		var width = w + 38;
		var height = h + 30;
		WindowObjectReference = window.open( urlpagina, 'Finestra', 'left=50,top=50,width=' + width + ',height=' + height + ', menubar=no, scrollbars=yes, toolbar=no, screenX=0, screenY=0, status=0');
	}


// Blocca pulsante INVIO ed esegue la funzione xajax passata come parametro
	function SendAjaxForm(ajax_func)
	{
		document.getElementById('submit_send').disabled = true;
		eval(ajax_func);
	}

	// Conferma messaggio delle Finestre Javascript
	function MsgConferma(txt, conferma)
	{
		// Exp Reg per cercare  . o ?
		var regX = /\.|\?|!/gi ;
		var _ret="";
		var counter = 0;
		var _item = txt.split(" ");
		for(var i=0;i<_item.length;i++)
		{
			counter++;
			if( _item[i].match(regX) )
			{
				_item[i]=_item[i] + '\n';
				_ret+=_item[i];
				counter = 0;
			} else {
				if( counter == 6 )
				{
					_item[i]=_item[i] + '\n';
					_ret+=_item[i];
					counter = 0;
				} else {
					_ret+=_item[i] + ' ';
				}
			}
		}
		if(conferma == 1)
		{
			return confirm(_ret);
		} else {
			alert(_ret);
			return true;
		}
	}

// switch visualizzazione tra conenuti ( id e id_link) 
	function toggleDisplay(id)
	{
		if(document.getElementById(id).style.display=='none')
		{
			document.getElementById(id).style.display='block';
			document.getElementById(id+"_link").style.display='none';
		} else {
			document.getElementById(id).style.display='none';
			document.getElementById(id+"_link").style.display='block';
		}
	}

// Come sopra ma switch solo su un elemento (id)
	function Simple_toggleDisplay(id)
	{
		if(this.document.getElementById(id).style.display=='none'){
			this.document.getElementById(id).style.display='block';
		}else{
			this.document.getElementById(id).style.display='none';
		}
	}
	
