﻿/*---------------------------------------------
 Libreria di base.

 Mall4Net E-Solution?? un prodotto realizzato
 da Valerio Maurizio - www.icio.it
 Tutti i diritti riservati?.

----------------------------------------------*/

var NS;
var OP;
var IE4;
var IE5;
var SOWIN;
var IE5WIN;
getAgent();

function getAgent() {
SOWIN = (navigator.userAgent.toLowerCase().indexOf("win") > -1) ? 1 : 0; 
OP = (window.opera) ? 1:0; 
IE4 = (document.all && !OP) ? 1:0; 
IE5 = (IE4 && document.getElementById) ? 1:0; 
IE5WIN = ((IE5) && SOWIN);
NS = (IE4 || IE5 || OP) ? 0:1;
}

function apriWin(sName,sTop,sLeft,sWidth,sHeight,sUrl) {
	wf =  "top="+ sTop + ",left=" + sLeft + ",width=" + sWidth + ",height=" + sHeight +",resizable=yes,scrollbars=yes,menubar=no,toolbar=no,directories=no,location=no,status=no";
	window.open(sUrl,sName,wf);
}

function chiudiWin() {
	self.opener = self;
	self.close();
}

function CheckForm() { //v3.1
  var i,p,p1,q,nm,test,num,min,max,errors='',args=CheckForm.arguments,theForm=args[0];
  for (i=1; i<(args.length-2); i+=3) { test=args[i+2]; val=theForm.elements[args[i]];
    if (val) { nm=args[i+1]; if (nm=='') nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isCheck')!=-1) { if (!theForm.elements[args[i]].checked) errors+='- '+nm+' obbligatorio.\n';
      } else if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');p1=val.lastIndexOf('.');
        if (p<2 || p==(val.length-1) || p1<p || p<0) errors+='- '+nm+' deve essere un indirizzo e-mail.\n';
      } else if (test.indexOf('isNum') != -1) { (NS) ? val = val.replace(",","."):val = val.replace("\.","").replace(",","");
 	for(x=0;x<val.length;x++) { if (val.substring(x,1)!="0") {val=val.substring(x); break;} }
        num = parseFloat(val);  if (val!=''+num) errors+='- '+nm+' deve essere un numero. (' + val + ')\n';  
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' deve essere un numero compreso tra '+min+' e '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' obbligatorio.\n'; }
  } if (errors) {alert('Attenzione:\n'+errors);return false} else {return true}
}

function DocFindElement(n) {
	var elem = document.getElementById(n);
	//if (!elem) elem = document.all(n,0);
	//if (!elem) elem = document[n];
	return elem;
}

function CenterWindow(Base,Altezza)
{
	var Top = (screen.height) ? (screen.height-Altezza)/2 - 26: 0;
	Top = (Top<0) ? 0 : Top;
	var Left = (screen.width) ? (screen.width-Base)/2 : 0;
	Left = (Left<0) ? 0 : Left;
	window.moveTo(Left,Top);
	window.resizeTo(Base,Altezza);
}

function ResizeWin(elem) {
	var Base = window.offsetWidth;
	var Altezza = window.offsetHeight;
	if (elem) {
		Base = elem.width + 100;
		Altezza = window.document.body.scrollHeight + 35;
	} else {
		Base = window.document.body.scrollWidth + 100;
		Altezza = window.document.body.scrollHeight + 35;
	}
	Base = (Base>screen.width) ? screen.width : Base;
	Altezza = (Altezza>screen.height) ? screen.height : Altezza;
	CenterWindow(Base,Altezza)
	self.focus();
}

function SetPopmenu(Elem,Value) {
	var pm = DocFindElement(Elem);
	if (pm) {
		if (Value!='') pm.selectedIndex=pm.options.length-1;
		for (var i=0; i< pm.options.length; i++)
		{
		    if (pm.options[i].value==Value)
			{
				pm.selectedIndex=i;
				break;
			}
		}
	}
}

/**************************************
	Controllo del Codice Fiscale
	Linguaggio: JavaScript
***************************************/

function ControllaCF(cf)
{
	var validi, i, s, set1, set2, setpari, setdisp;
	if( cf == '' )  return '';
	cf = cf.toUpperCase();
	if( cf.length != 16 )
		return "Lunghezza del codice fiscale non\n"
		+"corretta: il codice fiscale dovrebbe essere lungo\n"
		+"esattamente 16 caratteri.\n";
	validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
	for( i = 0; i < 16; i++ ){
		if( validi.indexOf( cf.charAt(i) ) == -1 )
			return "Il codice fiscale contiene un carattere non valido `" +
				cf.charAt(i) +
				"'.\nI caratteri validi sono le lettere e le cifre.\n";
	}
	set1 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	set2 = "ABCDEFGHIJABCDEFGHIJKLMNOPQRSTUVWXYZ";
	setpari = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	setdisp = "BAKPLCQDREVOSFTGUHMINJWZYX";
	s = 0;
	for( i = 1; i <= 13; i += 2 )
		s += setpari.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
	for( i = 0; i <= 14; i += 2 )
		s += setdisp.indexOf( set2.charAt( set1.indexOf( cf.charAt(i) )));
	if( s%26 != cf.charCodeAt(15)-'A'.charCodeAt(0) )
		return "Codice fiscale non corretto:\n"+
			"il codice di controllo non corrisponde.\n";
	return "";
}
/*****************************************
	Controllo della Partita I.V.A.
	Linguaggio: JavaScript
******************************************/

function ControllaPIVA(pi)
{
	if( pi == '' )  return '';
	if( pi.length != 11 )
		return "Lunghezza della partita IVA non\n" +
			"corretta: la partita IVA dovrebbe essere lunga\n" +
			"esattamente 11 caratteri.\n";
	validi = "0123456789";
	for( i = 0; i < 11; i++ ){
		if( validi.indexOf( pi.charAt(i) ) == -1 )
			return "La partita IVA contiene un carattere non valido `" +
				pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n";
	}
	s = 0;
	for( i = 0; i <= 9; i += 2 )
		s += pi.charCodeAt(i) - '0'.charCodeAt(0);
	for( i = 1; i <= 9; i += 2 ){
		c = 2*( pi.charCodeAt(i) - '0'.charCodeAt(0) );
		if( c > 9 )  c = c - 9;
		s += c;
	}
	if( ( 10 - s%10 )%10 != pi.charCodeAt(10) - '0'.charCodeAt(0) )
		return "Partita IVA non valida:\n" +
			"il codice di controllo non corrisponde.\n";
	return '';
}


<!-- Debut script
/* BeOS window par E.D Prod 1998
   etiennedeb@ifrance.com
   
*/
var navigateur=navigator.appName;var abrege=navigateur.substring(0,2);
var ftx=450;var fty=380;
var fpx=0;var fpy=0;var fpxf=0;var fpxc=0;var tempobe=0;var toclose=0;var decax=0;var decay=0;var deplace=0;

/*
function Mouvement() {
	Xpos = event.clientX+document.body.scrollLeft;
	Ypos = event.clientY+document.body.scrollTop;
  if (deplace!=0) {
  	if (deplace==1) {
  		decax=Xpos-fpx;
  		decay=Ypos-fpy;
  		deplace=2;
  	}
 	  fpx=Xpos-decax;
 	  fpy=Ypos-decay;
 	  document.all.fenetre.style.top=fpy;
 	  document.all.fenetre.style.left=fpx;
 	  return false;
  }	
}

document.onmousemove = Mouvement;
*/

function cliquer(flag) {
	deplace=flag;
	return false;
}

function beWindow(fpx,fpy,ftx,fty,ftitre,fichier) {
var ftxb=130;var hide="hidden";

fchaine=''
+'<div id="fenetre" style="position:absolute;visibility:hidden;z-index:50;top:'+fpy+'px;left:'+fpx+'px;width:'+ftx+'px;height:'+fty+'px;bgcolor:#0000ff;">'
+'<div id="window" style="position:absolute;z-index:50;top:21px;left:0px;width:'+(ftx)+'px;height:'+(fty)+'px;">'
+'<div id="hg" style="position:absolute;z-index:50;top:0px;left:0px;width:6px;height:6px;"><img src="images/hg.gif" width="6" height="6"></div>'
+'<div id="hd" style="position:absolute;z-index:50;top:0px;left:'+(ftx-6)+'px;width:6px;height:6px;"><img src="images/hd.gif" width="6" height="6"></div>'
+'<div id="bg" style="position:absolute;z-index:50;top:'+(fty-6)+'px;left:0px;width:6px;height:6px;"><img src="images/bg.gif" width="6" height="6"></div>'
+'<div id="bd" style="position:absolute;z-index:50;top:'+(fty-6)+'px;left:'+(ftx-6)+'px;width:6px;height:6px;"><img src="images/bd.gif" width="6" height="6"></div>'
+'<div id="h" style="position:absolute;z-index:50;top:0px;left:6px;width:1px;height:6px;"><img src="images/h.gif" width="'+(ftx-10)+'" height="6"></div>'
+'<div id="b" style="position:absolute;z-index:50;top:'+(fty-6)+'px;left:6px;width:1px;height:6px;"><img src="images/b.gif" width="'+(ftx-10)+'" height="6"></div>'
+'<div id="g" style="position:absolute;z-index:50;top:6px;left:0px;width:6px;height:1px;"><img src="images/g.gif" width="6" height="'+(fty-10)+'"></div>'
+'<div id="d" style="position:absolute;z-index:50;top:6px;left:'+(ftx-6)+'px;width:6px;height:1px;"><img src="images/d.gif" width="6" height="'+(fty-10)+'"></div>'
+'</div>'
+'<div id="titre" style="position:absolute;z-index:50;top:1px;left:0px;width:'+(ftx)+'px;height:21px;" onmousedown="return cliquer(1);" onmouseup="return cliquer(0);">'
+'<table CELLPADDING=0 CELLSPACING=0 border=0 width="'+(ftxb)+'" height="21"><tr><td background="images/tm.gif"><FONT FACE="verdana" SIZE=1><B>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+ftitre+'</B></FONT></td></tr></table>'
+'<div style="position:absolute;z-index:50;top:0px;left:0px;"><a href="#" onclick="javascript:return closebe();"><IMG src="images/tg.gif" BORDER=0 WIDTH=21 HEIGHT=21></A></div>'
+'<div style="position:absolute;z-index:50;top:0px;left:'+(ftxb-4)+'px;"><IMG src="images/td.gif" BORDER=0 WIDTH=4 HEIGHT=21></div>'
+'</div>'
+'<div id="interieur" style="position:absolute;z-index:50;top:27px;left:6px;width:'+(ftx-12)+'px;height:'+(fty-12)+'px;">'
+'<iframe name="inbeos" TOP=0 LEFT=0 WIDTH='+(ftx-12)+' HEIGHT='+(fty-12)+' border=0 FRAMEBORDER=0 scrolling=AUTO src="'+fichier+'"></iframe>'
+'</DIV>'
+'</div>'
+'</div>'
document.write(fchaine);
}
function slidebe() {
	if (toclose!=3) {
    fpx+=fpxc;
    if ((fpx>fpxf) && (toclose==0)) {fpx=fpxf;fpxc=0;toclose=3;}
    if (toclose==1) {fpxc=fpxc-20;}
    document.all.fenetre.style.left=fpx;
    if (fpx<-700) {
      fpxc=0;fpx=700;toclose=3;
      inbeos.location.href="attesa.htm";
      document.all.fenetre.style.visibility="hidden";
    }  
  }
  tempobe=setTimeout('slidebe();',5);
}
function apercu(fichier) {
if (abrege=="Mi"){
self.clearTimeout();self.clearInterval();
//fpy=document.body.scrollTop+(document.body.clientHeight/2)-220;
fpy=document.body.scrollTop+10;
document.all.fenetre.style.top=fpy;
document.all.fenetre.style.left=-700;fpx=-700;fpxf=(document.body.clientWidth/2)-200;fpxc=100;toclose=0;
document.all.fenetre.style.visibility="visible";
inbeos.location.href=fichier;
}
else {myWindow=open(fichier, "newWindow", "width=450,height=380,menubar=no,resizable=no,scrollbars=YES,status=no,toolbar=no");}
return false;
}
function closebe() {
fpxc=0;fpx=700;toclose=3;
inbeos.location.href="attesa.htm";
document.all.fenetre.style.visibility="hidden";
return false;
}
function CreerFenetreBe() {
  if (abrege=="Mi"){beWindow(0,0,450,300,"AVVISO","attesa.htm");slidebe();}
}