<!-- routine generali in javascript -->
var effetti=new Array(
"progid:DXImageTransform.Microsoft.Iris(irisStyle=SQUARE,motion=out,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Iris(irisStyle=SQUARE,motion=in,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Iris(irisStyle=star,motion=in,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Iris(irisStyle=star,motion=out,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Blinds(bands=8,direction=up,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Blinds(bands=8,direction=down,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Slide(slideStyle=swap,bands=15,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Wheel(spokes=16,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Strips(Motion=leftup,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0,wipeStyle=1,motion=forward,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0,wipeStyle=1,motion=reverse,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0,wipeStyle=0,motion=forward,enabled=0,Duration=3.0) ",
"progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0,wipeStyle=0,motion=reverse,enabled=0,Duration=3.0) ",
"progid:DXImageTransform.Microsoft.Fade(overlap=.5,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Checkerboard(squaresX=16,squaresY=16,direction=down,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.Checkerboard(squaresX=16,squaresY=16,direction=up,enabled=0,Duration=1.50) ",
"progid:DXImageTransform.Microsoft.RandomDissolve(,enabled=0,Duration=1.50) ",
"revealTrans(duration=2,transition=4);"
);
function hide_wait(obj){
document.getElementById(obj).style.display='none';
}
function show_wait(obj){
var scrw=get_screenx();
var scrh=get_screeny();
document.getElementById(obj).style.width=scrw-5;
document.getElementById(obj).style.height=scrh-5;
document.getElementById(obj).style.display='block';
}
/*---------------------------------------------------------
controllo tasto premuto:
f1=112, f2=113, f3=114, f4=115, f5=116, f6=117, f7=118, f8=119, f9=120, f10=121, f11=122, f12=123
---------------------------------------------------------*/
function tastopremuto(e){
	if(e && e.keyCode){
	var ordk      = e.keyCode;    // ascii order of key pressed
	var ctrlKey   = e.ctrlKey;
	var altKey    = e.altKey;
	var shiftKey  = e.shiftKey;
		if(altKey && ordk==115){
		location.reload();
		alert('benenuto - welcome !');
		}
		if(ctrlKey && ordk==114){
		open_wx('datiphp.php',600,280,'datiphp',50,50);
		}
/*
		if(ctrlKey && ordk==118){
		window.location="open.php?f=dump_data_base";
		}
		if(ctrlKey && ordk==118){
		frames['multiuser_iframe'].window.location="multiagenzia_onoff.php";
		}
		if(ctrlKey && ordk==114){
		open_wx('datiphp.php',600,280,'datiphp',50,50);
		}
		if(ctrlKey && ordk==120){
		open_wx('manuale.php',600,300,'manuale',50,50);
		}
*/
	}
}
//---------------------------------------------------------
// per status bar
//---------------------------------------------------------
function cloc(){
d=new Date();
segundos=d.getSeconds();
minutos=d.getMinutes();
horas=d.getHours();
if(segundos<10) segundos="0"+segundos;
if(minutos<10) minutos="0"+minutos;
if(horas<10) horas="0"+horas;
var weekday=new Array("Domenica","Lunedi","Martedi","Mercoledi","Giovedi","Venerdi","Sabato");
var monthname=new Array("Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre");
var oggi="oggi "+weekday[d.getDay()] + ", "+d.getDate() + " "+monthname[d.getMonth()] + " "+d.getFullYear();
if(document.getElementById('oggig')) document.getElementById('oggig').innerHTML = oggi;
window.status=horas+":"+minutos+":"+segundos+" di "+weekday[d.getDay()] + ", "+d.getDate() + " "+monthname[d.getMonth()] + " "+d.getFullYear()+" - by Italiacase";
setTimeout("cloc()",1000);
}
// data e ora
var gg = new Array('Domenica','Lunedì','Martedì','Mercoledì','Giovedì','Venerdì','Sabato');
var ms = new Array('Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre');
function vediclock(){
var ora = new Date();
var aa = ora.getDate();
var mm = ora.getMonth();
var yy = ora.getFullYear();
var oo = ora.getHours();
var mn = ora.getMinutes();
var sec = ora.getSeconds();
var dd = ora.getDay();
var aa2  = ((aa < 10) ? "0" : "");
var oo2  = ((oo < 10) ? "0" : "");
var mn2  = ((mn < 10) ? ":0" : ":");
var sec2  = ((sec < 10) ? ":0" : ":");
var Data = aa2 + aa +" "+ ms[mm]  + " " + yy;
var hh = oo2 + oo + mn2 + mn + sec2 + sec;
document.getElementById('perclock').innerHTML  = gg[dd] + ", " + Data + " - " + hh;
window.setTimeout("vediclock()",1000);
}

//resize window esatta
function setClientSize(W, H){
// it is important to resize the window to the
// wanted values first, even if we won't get them.
window.resizeTo(W, H);
// create the checkpoint element
var cp = document.createElement("div");
cp.style.position = "absolute";
cp.style.width = "0px";
cp.style.height = "0px";
cp.style.right = "0px";
cp.style.bottom = "0px";
// we can only read it's position after we
// insert it into the document
document.body.appendChild(div);
// here we get the actual client size
var current_width = cp.offsetLeft;
var current_height = cp.offsetTop;
// here we find out how much more we need
// in order to get to the needed W x H size
// (or in other words, we compute the size of
// window decorations: border, scroll bars, title)
var dw = W - current_width;
var dh = H - current_height;
// and _finally_ we get what we need
window.resizeBy(dw, dh);
// we can safely delete the checkpoint now
document.body.removeChild(cp);
// for the curious, return to see how much
// did IE miss it
//return { missed_width: dw, missed_height: dh };
}

//---------------------------------------------------------
// popup standard
//---------------------------------------------------------
var winwx = null;
function open_wx(wxurl,wxwid,wxhig,wxnom,wxtop,wxleft){
wxwid=(wxwid=='0' ? 620 : wxwid);
wxhig=(wxhig=='0' ? 500 : wxhig);
wxtop=(wxtop=='0' ? 1 : wxtop);
wxleft=(wxleft=='0' ? 1 : wxleft);
winwx = window.open ("", wxnom, "toolbar=no,width="+wxwid+",height="+wxhig+",top="+wxtop+",left="+wxleft+",directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no");
winwx.location=wxurl;
winwx.focus();
}
//---------------------------------------------------------
// varie
//---------------------------------------------------------
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
//get y position object; parm obj=document.getElementById("...")
function get_y(obj){
	var ypos=obj.offsetTop;
	tempEl=obj.offsetParent;
	while(tempEl!=null) {ypos+=tempEl.offsetTop;tempEl=tempEl.offsetParent}
	return ypos;
}
//get x position object; parm obj=document.getElementById("...")
function get_x(obj){
	var xpos=obj.offsetLeft;
	tempEl=obj.offsetParent;
	while(tempEl!=null) {xpos+=tempEl.offsetLeft;tempEl=tempEl.offsetParent}
	return xpos;
}

//---------------------------------------------------------
// apre popup fullscreen
//---------------------------------------------------------
var newmain = null;
function open_main(url,wid,hig){
wid=(!wid ? 800 : wid);
hig=(!hig ? 600 : hig);
//attivare dopo test finali
//newmain = window.open (url, "radice", "fullscreen,scrollbars=yes");
// disattivare dopo test finali
newmain=window.open (url, "radice", "toolbar=no,width="+wid+",height="+hig+",directories=no,status=yes,scrollbars=yes,resizable=yes,menubar=no");
newmain.moveTo(0,0);
newmain.resizeTo(screen.width,screen.height);
newmain.focus();
}

//---------------------------------------------------------
// controllo email
//---------------------------------------------------------
function check_email(email){
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
return filter.test(email);
}

function tutti(ilform){
List1 = document.forms[1].elements['qualeute[]'];
	for(i=0;i<List1.length;i++){
	List1.options[i].selected =true;
	}
document.forms[''+ilform+''].submit();
}

function nessuno(){
List1 = document.forms[1].elements['qualeute[]'];
	for(i=0;i<List1.length;i++){
	List1.options[i].selected =false;
	}
}

function open_calcolatrice(){
if(!document.all) var largow=(parseInt(window.innerWidth)-280);
else var largow=(parseInt(document.body.clientWidth)-280);
document.getElementById('calcolatrice').style.visibility='visible';
document.getElementById('calcolatrice').style.left=largow;
}

function close_calcolatrice() {
document.getElementById('calcolatrice').style.visibility='hidden';
}

function open_help(){
if(!document.all) var largow=(parseInt(window.innerWidth)-400);
else var largow=(parseInt(document.body.clientWidth)-400);
window.open ("help_on_line.htm","helponline", "toolbar=no,width=390,height=350,top=10,left="+largow+",directories=no,status=no,scrollbars=yes,resizable=no,menubar=no");
}

function loading_show(w,h){if(!document.all){var largow=(parseInt(window.innerWidth)-w)/2;var altoh=(parseInt(window.innerHeight)-h)/2;}else{var largow=(parseInt(document.body.clientWidth)-w)/2;var altoh=(parseInt(document.body.clientHeight)-h)/2;}document.getElementById('subdivload').innerHTML='<img src=\"imag/loading.jpg\" border=\"0\">';document.getElementById('load').style.left=largow;document.getElementById('load').style.top=altoh;document.getElementById('load').style.display='block';}

function loading_hide(){document.getElementById('load').style.display='none';}

function risult_form(ilform,campo,tuttook,error_msg){
	if(!tuttook){
	alert(error_msg);
	MM_findObj(campo).focus();
	return;
	}
document.forms[''+ilform+''].submit();
}

var divmsg,divmsg_x,divmsg_y,divmsg_maxy,msg_posiz;
function show_msg(testo,campo,msg_posiz){
var myre=/[|]/gi;
var newtesto=testo.replace(myre, "<br>");
if(typeof msg_posiz != "undefined") msg_posiz=0;//0=bottom 1=top
divmsg=document.getElementById('msg');
divmsg_x=(!document.all) ? (parseInt(window.innerWidth)-parseInt(divmsg.style.width))/2 : (parseInt(document.body.clientWidth)-parseInt(divmsg.style.width))/2;
if(msg_posiz) divmsg_y=(parseInt(divmsg.style.height)*-1);
else if(!msg_posiz) divmsg_y=(!document.all) ? parseInt(window.innerHeight)+10 : parseInt(document.body.clientHeight)+10;
divmsg.style.backgroundColor='#e0e0e0';
document.getElementById('subdivmsg').innerHTML=newtesto;
divmsg.style.display='block';
if(msg_posiz) divmsg_maxy=15;
else if(!msg_posiz) divmsg_maxy=divmsg_y-parseInt(divmsg.style.height)-10;
setTimeout('movedivup_msg()',100);
if(typeof campo != "undefined") MM_findObj(campo).style.backgroundColor='#e0e0e0';
}

function movedivup_msg(){
if(!document.all) divmsg.moveTo(divmsg_x,divmsg_y);
else{
divmsg.style.left=divmsg_x;
divmsg.style.top=divmsg_y;
}
if(msg_posiz) divmsg_y+=10;
else if(!msg_posiz) divmsg_y-=10;
	if(msg_posiz){
		if(divmsg_y<divmsg_maxy) setTimeout('movedivup_msg()',100);
		else setTimeout('movedivdown_msg()',4500);
	}
	else if(!msg_posiz){
		if(divmsg_y>divmsg_maxy) setTimeout('movedivup_msg()',100);
		else setTimeout('movedivdown_msg()',4500);
	}
}

function movedivdown_msg(){
if(msg_posiz) divmsg_y-=10;
else if(!msg_posiz) divmsg_y+=10;
if(!document.all) divmsg.moveTo(divmsg_x,divmsg_y);
else{
divmsg.style.left=divmsg_x;
divmsg.style.top=divmsg_y;
}
	if(msg_posiz){
		if(divmsg_y>(parseInt(divmsg.style.height)*-1)) setTimeout('movedivdown_msg()',100);
		else divmsg.style.display='none';
	}
	else if(!msg_posiz){
		if(divmsg_y<(divmsg_maxy+parseInt(divmsg.style.height)+10)) setTimeout('movedivdown_msg()',100);
		else divmsg.style.display='none';
	}
}

//---------------------------------------------------------
//controllo campo alfanumerico o numerico
//---------------------------------------------------------
function checkcampo(questo,elemento,tipocampo){
// tipocampo= 0 alfanumerico 1 numerico
	if(tipocampo=='0'){
		var myre=/[^\w \.\*,-\?:;]/gi;
		return myre.test(elemento);
	}
	else if(tipocampo=='1'){
		var myre=/[^\d,]/g;
		return myre.test(elemento);
	}
return;
}

function checkc(questo,elemento,tipocampo){
		if(checkcampo(questo,elemento,tipocampo)){
		alert("...carattere non valido...!");
		questo.value=elemento.substr(0,elemento.length-1);
		questo.focus();
		return false;
		}
}

function svuotanote(campo){
MM_findObj(campo).value="";
}

// LTrim(string) : Returns a copy of a string without leading spaces.
function ltrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(0)) != -1) {
      var j=0, i = s.length;
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
         j++;
      s = s.substring(j, i);
   }
   return s;
}

//RTrim(string) : Returns a copy of a string without trailing spaces.
function rtrim(str)
{
   var whitespace = new String(" \t\n\r");
   var s = new String(str);
   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
      var i = s.length - 1;       // Get length of string
      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
         i--;
      s = s.substring(0, i+1);
   }
   return s;
}

// Trim(string) : Returns a copy of a string without leading or trailing spaces
function trim(str) {
   return rtrim(ltrim(str));
}

function controllo(thefield,maxl){
if(!maxl) maxl=500;
var myre=/[<>@#ç\[\]\^'"£$%&\/\\=°]/gi;
if(myre.test(thefield.value)){
alert("...carattere non valido...!");
thefield.value=thefield.value.substr(0,thefield.value.length-1);
thefield.focus();
return;
}
else if(thefield.value.length>maxl){
alert('massimo '+maxl+' caratteri...!');
thefield.value=thefield.value.substring(0,maxl);
return;
}
}

