// MOSTRA/NASCONDI DIV function getElement(id){ return (typeof document.getElementById != "undefined")?document.getElementById(id):document.all[id]; } function mostra_nascondi(id){ var classe=document.getElementById(id).className; var classe2=classe.replace("nascosto","visibile"); if(classe==classe2){ classe2=classe.replace("visibile","nascosto"); } document.getElementById(id).className=classe2; } function mostra_nascondi2(id,azione){ var classe=document.getElementById(id).className; var classe2 =classe.replace("visibile","nascosto"); if(azione=="mostra"){ classe2 =classe.replace("nascosto","visibile"); } document.getElementById(id).className=classe2; } // LOADER function loader(id){ var classe=document.getElementById(id).className; var classe2 =classe.replace("nascosto","visibile"); document.getElementById(id).className=classe2; document.getElementById(id).innerHTML = ''; } // oggetto XMLHttpRequest function newXMLHttpRequest(){ var xmlreq = false; if(window.XMLHttpRequest){//Per browser non Microsoft xmlreq = new XMLHttpRequest(); }else if(window.ActiveXObject){//Cerco di creare l'oggetto via MS ActiveX try{//Nuove versioni per browser IE xmlreq = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e1){ //Errore riscontrato durante la creazione dell'oggetto try{//Precedenti versioni per browser IE xmlreq = new ActiveXObject("Microsoft.XMLHTTP"); }catch(e2){ //Nuovo errore durante la creazione dell'oggetto xmlreq = false; } } } return xmlreq; } function check_elementi(tipo,inizio_id){ if(inizio_id!=''){ var caratteri=inizio_id.length; } var selezionato=""; var azione=false; for(i=0; i < document.getElementsByTagName("input").length; i++){ var elemento = document.getElementsByTagName("input")[i]; if(elemento.getAttribute('type')==tipo){ if(inizio_id=='' || (inizio_id!='' && elemento.id.substr(0,caratteri)==inizio_id)){ if(selezionato==""){ selezionato=elemento.checked; } if(selezionato==false){ azione=true; } elemento.checked=azione; } } } } function trim(str){ return str.replace(/^\s+|\s+$/g,""); } document.getElementsByClassName = function(cl) { var retnode = []; var myclass = new RegExp('\\b'+cl+'\\b'); var elem = this.getElementsByTagName('*'); for (var i = 0; i < elem.length; i++) { var classes = elem[i].className; if (myclass.test(classes)) retnode.push(elem[i]); } return retnode; }; function cancella_div(div){ if(document.getElementById(div)){ div=document.getElementById(div); if(div && div.parentNode){ div.parentNode.removeChild(div); } } } function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } function is_integer(input){ return !isNaN(input)&&parseInt(input)==input; } function checkdate (m,g,a) { return m > 0 && m < 13 && a > 0 && a < 32768 && g > 0 && g <= (new Date(a, m, 0)).getDate(); } function quale_radio(nome){ var radio = document.getElementsByName(nome); var risultato=''; for(i = 0; i < radio.length; i++ ){ if(radio[i].checked== true){ //return radio[i].value; risultato=radio[i].value; break ; } } return risultato; } function stringa_checked(tipo,inizio_id){ if(inizio_id!=''){ var caratteri=inizio_id.length; } var selezionato=""; var stringa=""; for(i=0; i < document.getElementsByTagName("input").length; i++){ var elemento = document.getElementsByTagName("input")[i]; if(elemento.getAttribute('type')==tipo){ if(inizio_id=='' || (inizio_id!='' && elemento.id.substr(0,caratteri)==inizio_id)){ if(elemento.checked==true){ if(stringa!=""){ stringa=stringa+"@"; } stringa=stringa+elemento.id.substr(caratteri)+"="+elemento.value; } } } } return stringa; } function stringa_checked(tipo,inizio_id){ if(inizio_id!=''){ var caratteri=inizio_id.length; } var selezionato=""; var stringa=""; for(i=0; i < document.getElementsByTagName("input").length; i++){ var elemento = document.getElementsByTagName("input")[i]; if(elemento.getAttribute('type')==tipo){ if(inizio_id=='' || (inizio_id!='' && elemento.id.substr(0,caratteri)==inizio_id)){ if(elemento.checked==true){ if(stringa!=""){ stringa=stringa+"@"; } stringa=stringa+elemento.id.substr(caratteri)+"="+elemento.value; } } } } return stringa; } function dim_schermo(){ var viewportwidth; var viewportheight; // mozilla/netscape/opera/IE7 if(typeof window.innerWidth != 'undefined'){ viewportwidth = window.innerWidth, viewportheight = window.innerHeight }else if(typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0){ // IE6 in standards compliant mode (i.e. with a valid doctype as the first line in the document) viewportwidth = document.documentElement.clientWidth, viewportheight = document.documentElement.clientHeight }else{ // older versions of IE viewportwidth = document.getElementsByTagName('body')[0].clientWidth, viewportheight = document.getElementsByTagName('body')[0].clientHeight } return [viewportwidth, viewportheight]; } function getScrollXY() { var scrOfX = 0, scrOfY = 0; if( typeof( window.pageYOffset ) == 'number' ) { //Netscape compliant scrOfY = window.pageYOffset; scrOfX = window.pageXOffset; } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) { //DOM compliant scrOfY = document.body.scrollTop; scrOfX = document.body.scrollLeft; } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) { //IE6 standards compliant mode scrOfY = document.documentElement.scrollTop; scrOfX = document.documentElement.scrollLeft; } return [ scrOfX, scrOfY ]; } function getDocHeight() { var D = document; return Math.max( Math.max(D.body.scrollHeight, D.documentElement.scrollHeight), Math.max(D.body.offsetHeight, D.documentElement.offsetHeight), Math.max(D.body.clientHeight, D.documentElement.clientHeight) ); } function getScrollBarWidth () { var inner = document.createElement('p'); inner.style.width = "100%"; inner.style.height = "200px"; var outer = document.createElement('div'); outer.style.position = "absolute"; outer.style.top = "0px"; outer.style.left = "0px"; outer.style.visibility = "hidden"; outer.style.width = "200px"; outer.style.height = "150px"; outer.style.overflow = "hidden"; outer.appendChild (inner); document.body.appendChild (outer); var w1 = inner.offsetWidth; outer.style.overflow = 'scroll'; var w2 = inner.offsetWidth; if (w1 == w2) w2 = outer.clientWidth; document.body.removeChild (outer); return (w1 - w2); }; function checkdate (m,g,a) { return m > 0 && m < 13 && a > 0 && a < 32768 && g > 0 && g <= (new Date(a, m, 0)).getDate(); } function is_numeric(input){ return !isNaN(input); } function arrotonda(numero, decimali) { var risultato = Math.round(numero*Math.pow(10,decimali))/Math.pow(10,decimali); return risultato; // Output the result to the form field (change for your purposes) } function apri_opaco(){ var schermo=dim_schermo(); if(!getElement('div_opaco')){ var newdiv = document.createElement('div'); newdiv.setAttribute('id', 'div_opaco'); /*if(schermo[0] < getElement('contenitore').offsetWidth){ newdiv.style.width = (getElement('contenitore').offsetWidth-getScrollBarWidth())+'px'; }else{ newdiv.style.width = (schermo[0]-getScrollBarWidth())+'px'; }*/ newdiv.style.width="100%"; newdiv.style.height=(getDocHeight())+'px';//schermo[1]+; document.body.appendChild(newdiv); } } function pari(numero){ return (numero%2 == 0) ? true : false; } function EnterPressed(e){//lo uso in rinomina_desktop // Code adapted from Jennifer Madden // http://jennifermadden.com/162/examples/stringEnterKeyDetector.html var characterCode if(e && e.which){ // NN4 specific code e = e characterCode = e.which }else{ e = event characterCode = e.keyCode // IE specific code } if(characterCode==13){ return true // Enter key is 13 }else{ return false } } function ctr_data(nome,prefisso,nulla){ var risultato=""; var g=getElement(prefisso+'giorno_'+nome).value; var m=getElement(prefisso+'mese_'+nome).value; var a=getElement(prefisso+'anno_'+nome).value; if(g=="" && m=="" && a=="" && nulla!='si'){ risultato="nulla"; }else if((g=="" || m=="" || a=="") && (g!="" || m!="" || a!="")){ risultato='incompleta'; }else{ if(!checkdate(m,g,a)){ risultato="inesistente"; }else{ risultato="ok"; } } return [risultato,g,m,a]; } function non_propagare(event){ if(event.stopPropagation){ event.stopPropagation(); }else if(window.event){ window.event.cancelBubble=true; } } function is_child_of(parent, child) { if( child != null ) { while( child.parentNode ) { if( (child = child.parentNode) == parent ) { return true; } } } return false; }