
function ctrlMail() 
{
	var f = document.form1

	if (f.names.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"nome\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.surnames.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"cognome\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.society.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"societa\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.email.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"email\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.message.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"messaggio\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.privacy.checked == false)
	{
		msgboxJS("", "Autorizzare il trattamento dei dati personali.", _OKONLY, _CRITICAL);
		return (false);
	}
    if (f.email.value != "")
    {
		var s = f.email.value;
		var r1, r2, r;
		r1 = "@";
		r2 = ".";
		r = s.indexOf(r1);
		if ( r != -1 ) {
		    r = s.indexOf(r2);
			if ( r != -1 ) 
		         return true;
		} 
	    msgboxJS("", "Inserire un valore corretto per il campo \"email\".", _OKONLY, _CRITICAL);
	    return (false);
    }
return true;
}
function ctrlMailEng() 
{
	var f = document.form1

	if (f.names.value == "" ) {
		msgboxJS("", "Please, insert your name.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.surnames.value == "" ) {
		msgboxJS("", "Please, insert your username.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.society.value == "" ) {
		msgboxJS("", "Please, insert your society.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.email.value == "" ) {
		msgboxJS("", "Please, insert your email address.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.message.value == "" ) {
		msgboxJS("", "Please, insert your message.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.privacy.checked == false)
	{
		msgboxJS("", "Please, insert privacy authorization.", _OKONLY, _CRITICAL);
		return (false);
	}
    if (f.email.value != "")
    {
		var s = f.email.value;
		var r1, r2, r;
		r1 = "@";
		r2 = ".";
		r = s.indexOf(r1);
		if ( r != -1 ) {
		    r = s.indexOf(r2);
			if ( r != -1 ) 
		         return true;
		} 
	    msgboxJS("", "Please, insert your correct e-mail address.", _OKONLY, _CRITICAL);
	    return (false);
    }
return true;
}
function ctrlInfo() 
{
	var f = document.form1

	if (f.names.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"nome\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.surnames.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"cognome\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.town.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"cittą\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.tel.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"telefono\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.society.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"societa\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.role.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"ruolo\".", _OKONLY, _CRITICAL);
		return (false);
	}
	  var checkOK = "0123456789-";
	  var checkStr = f.tel.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
		allNum += ch;
	  }
	  if (!allValid)
  	{
	    msgboxJS("", "Inserire solo cifra caratteri per il campo \"telefono\".", _OKONLY, _CRITICAL);
	    return (false);
	} 
	if (f.email.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"email\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.message.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"messaggio\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.privacy.checked == false)
	{
		msgboxJS("", "Autorizzare il trattamento dei dati personali.", _OKONLY, _CRITICAL);
		return (false);
	}
    if (f.email.value != "")
    {
		var s = f.email.value;
		var r1, r2, r;
		r1 = "@";
		r2 = ".";
		r = s.indexOf(r1);
		if ( r != -1 ) {
		    r = s.indexOf(r2);
			if ( r != -1 ) 
		         return true;
		} 
	    msgboxJS("", "Inserire un valore corretto per il campo \"email\".", _OKONLY, _CRITICAL);
	    return (false);
    }
return true;
}
function ctrlNewsLetter() 
{
	var f = document.form1

	if (f.names.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"nome\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.surnames.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"cognome\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.society.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"societa\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.email.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"email\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.privacy.checked == false)
	{
		msgboxJS("", "Autorizzare il trattamento dei dati personali.", _OKONLY, _CRITICAL);
		return (false);
	}
    if (f.email.value != "")
    {
		var s = f.email.value;
		var r1, r2, r;
		r1 = "@";
		r2 = ".";
		r = s.indexOf(r1);
		if ( r != -1 ) {
		    r = s.indexOf(r2);
			if ( r != -1 ) 
		         return true;
		} 
	    msgboxJS("", "Inserire un valore corretto per il campo \"email\".", _OKONLY, _CRITICAL);
	    return (false);
    }
return true;
}
function ctrlIscri() 
{
	var f = document.form1

	if (f.names.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"nome\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.surnames.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"cognome\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.town.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"cittą\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.tel.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"telefono\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.society.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"societa\".", _OKONLY, _CRITICAL);
		return (false);
	}
	  var checkOK = "0123456789-";
	  var checkStr = f.tel.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
		allNum += ch;
	  }
	  if (!allValid)
  	{
	    msgboxJS("", "Inserire solo cifra caratteri per il campo \"telefono\".", _OKONLY, _CRITICAL);
	    return (false);
	} 
	if (f.email.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"email\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.message.value == "" ) {
		msgboxJS("", "Inserire un valore per il campo \"messaggio\".", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.privacy.checked == false)
	{
		msgboxJS("", "Autorizzare il trattamento dei dati personali.", _OKONLY, _CRITICAL);
		return (false);
	}
    if (f.email.value != "")
    {
		var s = f.email.value;
		var r1, r2, r;
		r1 = "@";
		r2 = ".";
		r = s.indexOf(r1);
		if ( r != -1 ) {
		    r = s.indexOf(r2);
			if ( r != -1 ) 
		         return true;
		} 
	    msgboxJS("", "Inserire un valore corretto per il campo \"email\".", _OKONLY, _CRITICAL);
	    return (false);
    }
return true;
}
function ctrlNewsLetterEng() 
{
	var f = document.form1

	if (f.names.value == "" ) {
		msgboxJS("", "Please, insert your name.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.surnames.value == "" ) {
		msgboxJS("", "Please, insert your username.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.society.value == "" ) {
		msgboxJS("", "Please, insert your society.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.email.value == "" ) {
		msgboxJS("", "Please, insert your email address.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.privacy.checked == false)
	{
		msgboxJS("", "Please, insert privacy authorization.", _OKONLY, _CRITICAL);
		return (false);
	}
    if (f.email.value != "")
    {
		var s = f.email.value;
		var r1, r2, r;
		r1 = "@";
		r2 = ".";
		r = s.indexOf(r1);
		if ( r != -1 ) {
		    r = s.indexOf(r2);
			if ( r != -1 ) 
		         return true;
		} 
	    msgboxJS("", "Please, insert your correct email address.", _OKONLY, _CRITICAL);
	    return (false);
    }
return true;
}
function ctrlInfoEng() 
{
	var f = document.form1

	if (f.names.value == "" ) {
		msgboxJS("", "Please, insert your name.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.surnames.value == "" ) {
		msgboxJS("", "Please, insert your username.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.town.value == "" ) {
		msgboxJS("", "Please, insert your town.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.tel.value == "" ) {
		msgboxJS("", "Please, insert your phone.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.society.value == "" ) {
		msgboxJS("", "Please, insert your society.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.role.value == "" ) {
		msgboxJS("", "Please, insert your role.", _OKONLY, _CRITICAL);
		return (false);
	}
	  var checkOK = "0123456789-";
	  var checkStr = f.tel.value;
	  var allValid = true;
	  var decPoints = 0;
	  var allNum = "";
	  for (i = 0;  i < checkStr.length;  i++)
	  {
		ch = checkStr.charAt(i);
		for (j = 0;  j < checkOK.length;  j++)
		  if (ch == checkOK.charAt(j))
			break;
		if (j == checkOK.length)
		{
		  allValid = false;
		  break;
		}
		allNum += ch;
	  }
	  if (!allValid)
  	{
	    msgboxJS("", "Please, insert your correct phone.", _OKONLY, _CRITICAL);
	    return (false);
	} 
	if (f.email.value == "" ) {
		msgboxJS("", "Please, insert your email address.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.message.value == "" ) {
		msgboxJS("", "Please, insert your message.", _OKONLY, _CRITICAL);
		return (false);
	}
	if (f.privacy.checked == false)
	{
		msgboxJS("", "Please, insert privacy authorization.", _OKONLY, _CRITICAL);
		return (false);
	}
    if (f.email.value != "")
    {
		var s = f.email.value;
		var r1, r2, r;
		r1 = "@";
		r2 = ".";
		r = s.indexOf(r1);
		if ( r != -1 ) {
		    r = s.indexOf(r2);
			if ( r != -1 ) 
		         return true;
		} 
	    msgboxJS("", "Please, insert your correct email address.", _OKONLY, _CRITICAL);
	    return (false);
    }
return true;
}
function url(PageName)
{
	window.document.location.href = PageName;
}
function urlPop(PageName)
{
	window.parent.opener.location.href = PageName;
	this.close();
}
function apri(imgVal, W, H) { 
	var H_Pos, V_Pos;
	
	// Calcolo delle coordinate per centrare la finestra
	H_Pos = (screen.width - (626 + 10) ) / 2;
	V_Pos = (screen.height - (470 + 10) ) / 2;
	
	newin = window.open('img.asp?imgVal=' + imgVal, '', 'scrollbars=no, resizable=no, width=' + W + ', height=' + H + ', status=no, top=' + V_Pos + ', left=' + H_Pos + ', location=no, toolbar=no, center=yes, menubar=no, resizable=no, scrollbars=no');
} 
function apriEng(imgVal, W, H) { 
	var H_Pos, V_Pos;
	
	// Calcolo delle coordinate per centrare la finestra
	H_Pos = (screen.width - (626 + 10) ) / 2;
	V_Pos = (screen.height - (470 + 10) ) / 2;
	
	newin = window.open('../img.asp?imgVal=' + imgVal, '', 'scrollbars=no, resizable=no, width=' + W + ', height=' + H + ', status=no, top=' + V_Pos + ', left=' + H_Pos + ', location=no, toolbar=no, center=yes, menubar=no, resizable=no, scrollbars=no');
} 
function apri1(docVal, width, height) { 
	
	newin = window.open(docVal, '', 'scrollbars=yes, resizable=yes, width=' + width + ', height=' + height + ', status=no, location=no, toolbar=no, center=yes, menubar=no, resizable=no, scrollbars=no');
}
function apri2(docVal) { 
	
	newin = window.open(docVal, '', 'scrollbars=no, resizable=yes, width=800px, height=600px, status=no, location=no, toolbar=no, center=yes, menubar=no, resizable=no, scrollbars=no');
}
function apri3(docVal) { 

	newin = window.open(docVal, '', 'scrollbars=no, resizable=no, width=325px, height=443px, status=no, location=no, toolbar=no, center=yes, menubar=no, resizable=no, scrollbars=no');
}

var slidingPanels = new Array();

function SlidingPanel(panelID)
{
	this.panel = sp_getObj(panelID);
	if (!this.panel)
		return;
	this.id = slidingPanels.length;

	if (uA.IE) { // hack to init IE's filter rendering engine
		var dummy = document.createElement('div');
		dummy.style.position = 'absolute';
		dummy.style.top = 0;
		dummy.style.left = 0;
		dummy.style.width = '1px';
		dummy.style.height = '1px';
		dummy.style.filter = 'alpha(opacity=50)';
		this.panel.appendChild(dummy);
	}

	this.icon = null;
	this.label = null;
	this.duration = 500;
	this.fade = true;
	this.restHeight = this.panel.style.height ? this.panel.style.height : 'auto';
	this.open = !(sp_getStyle(this.panel).display == 'none');
	this.animation = {now:(this.open ? 1.0 : 0.0), from:0.0, to:0.0, duration:0};
	if (this.open)
		this.height = this.panel.offsetHeight;
	else { // workaround to get panel height when hidden
		this.panel.style.display = 'block';
		this.height = this.panel.offsetHeight;
		this.panel.style.display = 'none';
	}

	this.slide = function() {
		if (this.open) {
			this.height = this.panel.offsetHeight;
			if (this.animation.timer != null) {
				clearInterval(this.animation.timer);
				this.animation.timer = null;
			}

			var starttime = (new Date).getTime() - 13;

			this.animation.duration = this.duration;
			this.animation.starttime = starttime;
			this.animation.timer = setInterval ("sp_slide('" + this.id + "')", 13);
			this.animation.from = this.animation.now;
			this.animation.to = 0.0;
			sp_slide(this.id);
		}
		else { // workaround to get panel height when hidden
			this.panel.style.display = 'block';
			this.panel.style.height = this.restHeight;
			this.height = this.panel.offsetHeight;
			this.panel.style.height = '1px';
			this.panel.style.display = 'none';
			
			if (this.animation.timer != null) {
				clearInterval (this.animation.timer);
				this.animation.timer  = null;
			}
	 
			var starttime = (new Date).getTime() - 13;
	 
			this.animation.duration = this.duration;
			this.animation.starttime = starttime;
			this.animation.timer = setInterval ("sp_slide('" + this.id + "')", 13);
			this.animation.from = this.animation.now;
			this.animation.to = 1.0;
			sp_slide(this.id);
		}
		this.open = !this.open;
	};
	
	this.setSlideDuration = function(duration) {
		this.duration = duration;
	};
	
	this.setLabel = function(labelID, textWhenOpen, textWhenClosed) {
		var label = sp_getObj(labelID);
		if (!label)
			return;
		this.label = {label:label, textWhenOpen:textWhenOpen, textWhenClosed:textWhenClosed};
	};

	this.setIcon = function(iconID, iconWhenOpen, iconWhenClosed) {
		var icon = sp_getObj(iconID);
		if (!icon)
			return;
		this.icon = {icon:icon, iconWhenOpen:iconWhenOpen, iconWhenClosed:iconWhenClosed};
	};

	this.setFade = function(fade) {
		this.fade = fade;
	};

	slidingPanels[this.id] = this;
	return this;
}

function sp_slide(id) { // visualizes a scrolling animation
	var T,
		ease,
		time = (new Date).getTime(),
		newHeight;

	T = sp_clampTo(time-slidingPanels[id].animation.starttime, 0, slidingPanels[id].animation.duration);
	if (T >= slidingPanels[id].animation.duration) {
		clearInterval (slidingPanels[id].animation.timer);
		slidingPanels[id].animation.timer = null;
		slidingPanels[id].animation.now = slidingPanels[id].animation.to;
		
		if (slidingPanels[id].label) {
			slidingPanels[id].label.label.innerHTML = slidingPanels[id].animation.now ? slidingPanels[id].label.textWhenOpen : slidingPanels[id].label.textWhenClosed;
		}
		if (slidingPanels[id].icon) {
			slidingPanels[id].icon.icon.src = slidingPanels[id].animation.now ? slidingPanels[id].icon.iconWhenOpen : slidingPanels[id].icon.iconWhenClosed;
		}
	}
	else {
		ease = 0.5 - (0.5 * Math.cos(Math.PI * T / slidingPanels[id].animation.duration));
		slidingPanels[id].animation.now = sp_computeNextFloat (slidingPanels[id].animation.from, slidingPanels[id].animation.to, ease);
	}
	
	var sPstyle = slidingPanels[id].panel.style;
	sPstyle.display = slidingPanels[id].animation.now ? 'block' : 'none';
	sPstyle.overflow = 'hidden';
	if (slidingPanels[id].fade) {
		if (uA.IE)
			sPstyle.filter = 'alpha(opacity=' + Math.round(slidingPanels[id].animation.now*100) + ')';
		else if (uA.Gecko)
			sPstyle.MozOpacity = slidingPanels[id].animation.now < 1 ? slidingPanels[id].animation.now : 0.99; // to avoid flickering
		else if (uA.Safari)
			sPstyle.opacity = slidingPanels[id].animation.now;
	}
	newHeight = Math.round(slidingPanels[id].animation.now*slidingPanels[id].height);
	sPstyle.height = (uA.IE ? sp_clampTo(newHeight, 1, newHeight) : newHeight) + 'px'; // IE dislikes a height of 0
	if (slidingPanels[id].animation.now == 1.0) {
		sPstyle.height = slidingPanels[id].restHeight;
	}
}

function sp_getStyle(obj)
{
	if ('getComputedStyle' in window && !uA.Safari)
		return getComputedStyle(obj, '');
	else if (document.body.currentStyle)
		return obj.currentStyle;
	else
		return obj.style;
}

function sp_getObj(id)
{
	return (document.getElementById ? document.getElementById(id) : document.all[id]);
}

function sp_clampTo(value, min, max) { // constrains a value between two limits
	return value < min ? min : value > max ? max : value;
}

function sp_computeNextFloat (from, to, ease) { // self explaining
	return from + (to - from) * ease;
}

uA = new Object();
uA.IE = navigator.appName.indexOf('Microsoft') != -1;
uA.Gecko = navigator.userAgent.indexOf('Gecko') != -1 && navigator.userAgent.indexOf('Safari') == -1;
uA.Safari = navigator.userAgent.indexOf('Safari') != -1;