//FUNZIONE PER LA DISABILITAZIONE DEL TASTO DESTRO



var messaggio_tasto_destro="Tasto destro disabilitato.\n\n Copyright © 2004 - S.I.I.S. Soft srl ";

window.status ="S.I.I.S. Soft  Studio Italia Soluzioni Informatiche";
//window.setTimeout('functionName()');


                  function scrollerObj(name,initH,initW,paddingB,widthB,content,initBg,Bg,speed,initFl){

                  //**data**//

                  this.name=name;

                  this.initH=initH;

                  this.initW=initW;

                  this.paddingB=paddingB;

                  this.widthB=widthB;

                  this.content=content;

                  this.initBg=initBg;

                  this.Bg=Bg;

                  this.iniFl=initFl;

                  this.speed=parseInt(speed);

                  this.timer = name + "Timer";

                  this.elem;





                  //**methods**//

                  this.getElement = getElement;

                  this.createLayer=createLayer;

                  this.scrollLayer = scrollLayer; 

                  this.scrollLoop=scrollLoop;



                  //**initiate methods**//

                  this.createLayer();

                  this.getElement();

                  this.scrollLayer();

                  }



                  //**call this method to stop scrolling**//

                  function scrollLoop(s){

                  this.speed = s;

                  }



                  //**pretty obvious**//

                  function scrollLayer(){

                  if(parseInt(this.elem.style.top)>(this.elem.offsetHeight*(-1))){

                      this.elem.style.top = parseInt(this.elem.style.top)-this.speed;

                      //alert(parseInt(this.elem.style.top)+"\n"+this.elem.id);

                  }

                  else {this.elem.style.top = this.initH;}

                  }



                  //**get the specific dom-expression**//

                  function getElement(){

                  if(document.getElementById){

                      this.elem = document.getElementById(this.name);

                      }

                  else if (document.all){

                  this.elem = document.all[name];

                      }

                  else if (document.layers){

                  this.elem = document.layers[name];

                      }

                  }



                  //**pretty obvious - if NS4 - please upgrade to a standard compliant browser**//

                  function createLayer(){

                  if(document.getElementById || document.all){

                  document.write('<div id="layer'+this.name+'" style="position:relative;overflow:hidden;float:'+this.initFl+';border:0px;width:'+this.initW+'px;height:'+this.initH+'px;" onMouseover="'+this.name+'.scrollLoop(0)" onMouseout="'+this.name+'.scrollLoop('+this.speed+')">');

                  document.write('<div id="'+this.name+'" style="position:absolute;top:'+this.initH+'px;left:0px;border:0px solid black;width:'+this.widthB+'px;padding:'+this.paddingB+'px;">');

                  document.write(this.content);
                  document.write('<\/div><\/div>');}

                  else if(document.layers){

                      document.write('<ilayer name="'+this.name+'"  width="'+this.widthB+'" height="'+this.heightB+'">'+this.content+'<\/ilayer>');

                      return;

                  }

                  if(this.scrollLayer){

                    this.timer = setInterval(this.name+'.scrollLayer()','30');

                  }

                  }




function click(e) {
    
    if (document.all) {
        if (event.button == 2) {
            //alert(messaggio_tasto_destro);
            //return false;
        }
    }
    if (document.layers) {
        if (e.which == 3) {
        alert(messaggio_tasto_destro);
        //return false;
    }
    
    return true;
}

}

if (document.layers) {
document.captureEvents(Event.MOUSEDOWN);
}

document.onmousedown=click;
//FUNZIONE PER L'ISTANZIAMENTO DELLE FINESTRE DI POPUP
function popup_window(contenuto,larghezza,altezza) {
     window.open(contenuto,"","top=130,left=240,status=no,menubar=no,scrollbars=no,resizable=no,width=" + larghezza + ",height=" + altezza);
     return false;

}

//FUNZIONE CHE STAMPA LA DATA ODIERNA

function data_odierna() {
                            var obj = new Date();
                            var mese,giorno;
                            var nome="";
                            var stringa="";
                            
                            document.write();
                            
                            // Giorno della settimana
                            giorno = obj.getDay();
                            
                            switch(giorno) {
                            case 0: nome = "Domenica"; break;
                            case 1: nome = "Lunedi'"; break;
                            case 2: nome = "Martedi'"; break;
                            case 3: nome = "Mercoledi'"; break;
                            case 4: nome = "Giovedi'"; break;
                            case 5: nome = "Venerdi'"; break;
                            case 6: nome = "Sabato";
                            }
                            
                            stringa = nome+", "+obj.getDate();
                            document.write(stringa.fontcolor("darkred").toUpperCase());
                            
                            // Mese dell'anno
                            mese = obj.getMonth();
                            
                            switch(mese) {
                            case 0: nome = "Gennaio"; break;
                            case 1: nome = "Febbraio"; break;
                            case 2: nome = "Marzo"; break;
                            case 3: nome = "Aprile"; break;
                            case 4: nome = "Maggio"; break;
                            case 5: nome = "Giugno"; break;
                            case 6: nome = "Luglio"; break;
                            case 7: nome = "Agosto"; break;
                            case 8: nome = "Settembre"; break;
                            case 9: nome = "Ottobre"; break;
                            case 10: nome = "Novembre"; break;
                            case 11: nome = "Dicembre";
                            }
                            
                            stringa = " "+nome+" "+obj.getYear();
                            document.write(stringa.fontcolor("darkred").toUpperCase());
                            

}


//FUNZIONE PER IL CONTEGGIO DELLE PAROLE INSERITE IN UNA TEXTAREA



function textCounter(field, countfield, maxlimit) {
    if (field.value.length > maxlimit)
        field.value = field.value.substring(0, maxlimit);
    else
        countfield.value = maxlimit - field.value.length;
}

//FUNZIONE PER LA CONFERMA DEL NUMERO AUTORI INSERITO
function conferma_numero_autori(){
    var n_autori=document.cambia_numero_autori.numero_autori.value;
    if (n_autori>1){
        var conferma_autori=confirm('Hai scelto di inserire '+n_autori+' autori. Confermi?');
    }
    else {
        var conferma_autori=confirm('Hai scelto di inserire '+n_autori+' autore. Confermi?');
    }
    if (conferma_autori == true)
    {
        window.location='../manutenzione/eliminazione/elimina_db.asp?cod_documento=<%=$cod_documento%>';
    }
    else
    {
        return false;
    }
}

//FUNZIONE PER L'INCREMENTO DEL NUMERO DI AUTORI

function incrementa_autori(){
    window.document.cambia_numero_autori.numero_autori.value = parseInt(window.document.cambia_numero_autori.numero_autori.value)+1;
    window.document.cambia_numero_autori.ok.focus();
    return true;
}

//CONTROLLA LA VALIDITA'  DEL CODICE FISCALE
function ControllaCF(cf) 
{ 
  var validi, i, s, set1, set2, setpari, setdisp;
  if( cf == '' ) return true; 
  cf = cf.toUpperCase(); 
  if( cf.length != 16 )
  {
   alert("La lunghezza del codice fiscale non č\n" +"corretta: il codice fiscale dovrebbe essere lungo\n" +"esattamente 16 caratteri.\n");
   return false;
  }
  validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 
  for( i = 0; i < 16; i++ ){ 
   if( validi.indexOf( cf.charAt(i) ) == -1 )
    { 
    alert( "Il codice fiscale contiene un carattere non valido `" + cf.charAt(i) + "'.\nI caratteri validi sono le lettere e le cifre.\n"); 
    return false;
    }
  }
    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) ) 
      { 
    alert ("Il codice fiscale non č corretto:\n"+ "il codice di controllo non corrisponde.\n");  
    return false; 
      }
    return true;
}  
//CONTROLLA LA VALIDITA' DELLA PARTITA IVA
function ControllaPIVA(pi) { 
    if( pi == '' ) return true; 
    if( pi.length != 11 ) 
        {
        alert ("La lunghezza della partita IVA non č\n" + "corretta: la partita IVA dovrebbe essere lunga\n" + "esattamente 11 caratteri.\n");
        return false; 
        }
validi = "0123456789"; 
    for( i = 0; i < 11; i++ ){ 
            if( validi.indexOf( pi.charAt(i) ) == -1 ) 
                {
                alert ("La partita IVA contiene un carattere non valido `" + pi.charAt(i) + "'.\nI caratteri validi sono le cifre.\n");
                return false;
                }
    }
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) ) 
        {
        alert("La partita IVA non č valida:\n" + "il codice di controllo non corrisponde.\n");
        return false; 
        }
return true; 
}  

//Controlla la validitą dell'indirizzo email
function controlloEmail(field) {
    if (field.value==""){return true;}
    else{
    var goodEmail = field.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\.info)|(\.sex)|(\.biz)|(\.aero)|(\.coop)|(\.museum)|(\.name)|(\.pro)|(\..{2,2}))$)\b/gi);
    
    if (goodEmail) {
        return true;
    }
    else {
        alert('INSERIRE UN INDIRIZZO DI POSTA ELETTRONICA CORRETTO');
        field.focus();
        field.select();
        return false;
    }
    }
}

//UNZIONE PER IL DECREMENTO DEL NUMERO DI AUTORI

function decrementa_autori(){

    if (parseInt(window.document.cambia_numero_autori.numero_autori.value)>1){
        window.document.cambia_numero_autori.numero_autori.value = parseInt(window.document.cambia_numero_autori.numero_autori.value)-1;
        window.document.cambia_numero_autori.ok.focus();
        return true;
    }
    else window.document.cambia_numero_autori.ok.focus();
}


function controlloCampoNumerico(field, fine_messaggio){
    var controllo = null;
    var command;
    controllo = field.value;
    if(controllo == ""){
        controllo = 0;
        field.value = "0.000";
    }
    if ( isNaN(controllo) ){
        alert("INSERIRE UN VALORE NUMERICO PER "+fine_messaggio);
        command = field.style.background = '#FF0000';
        command = field.value = "0.000";            
        command = field.select();
        eval(command); 
        command = field.focus();
        eval(command);

        return false;
    }
    return true;
}
function controlloCampoNumericoIntero(field, fine_messaggio){
    var controllo = null;
    var command;
    controllo = field.value;
    if(controllo == ""){
        controllo = 0;
        field.value = "";
    }
    if ( isNaN(controllo) ){
        alert("INSERIRE UN VALORE NUMERICO PER "+fine_messaggio);
        command = field.style.background = '#FF0000';
        command = field.value = "";         
        command = field.select();
        eval(command); 
        command = field.focus();
        eval(command);

        return false;
    }
    return true;
}
function controlloCampoTestoObbligatorio(field, fine_messaggio){
    var controllo = null;
    var command;
    controllo = field.value;
    if(controllo == ""  || controllo.substring(0, 1) == " "){
        alert("INSERIRE UN VALORE PER "+fine_messaggio);
        
        command = field.style.background = '#FF0000';           
        command = field.select();
        eval(command); 
        command = field.focus();
        eval(command);

        return false;
    }
    return true;
}

/*
function ControllaCF(cf) { 
    var validi, i, s, set1, set2, setpari, setdisp;
    if( cf == '' ) return true; 
    cf = cf.toUpperCase(); 
    if( cf.length != 16 ) {
    alert("La lunghezza del codice fiscale non č\n" +"corretta: il codice fiscale dovrebbe essere lungo\n" +"esattamente 16 caratteri.\n");
    return false;
    }
    validi = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 
    for( i = 0; i < 16; i++ ){ 
    if( validi.indexOf( cf.charAt(i) ) == -1 ) alert( "Il codice fiscale contiene un carattere non valido `" + cf.charAt(i) + "'.\nI caratteri validi sono le lettere e le cifre.\n"); 
    return false;
    }
    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) ) {
    alert( "Il codice fiscale non č corretto:\n"+ "il codice di controllo non corrisponde.\n");
    return false;
    }
    return true; 
}  
*/
function maskKeyPress(objEvent, oggetto) {
        //var reValidChars=/[0-9][,-,]{1}[0-9]/;
        var reValidChars=/[0-9.]/;
        var iKeyCode, strKey;
        iKeyCode = objEvent.keyCode;
        strKey = String.fromCharCode(iKeyCode);

        if (!reValidChars.test(strKey)
           || oggetto.value.length > oggetto.size) {
                return false;
        }
}
function maskKeyPressNoPoint(objEvent, oggetto) {
        //var reValidChars=/[0-9][,-,]{1}[0-9]/;
        var reValidChars=/[0-9]/;
        var iKeyCode, strKey;
        iKeyCode = objEvent.keyCode;
        strKey = String.fromCharCode(iKeyCode);

        if (!reValidChars.test(strKey)
           || oggetto.value.length > oggetto.size) {
                return false;
        }
}
//Toglie gli spazi bianchi alla sinistra della stringa
  function LTrim(str){
     var whitespace = new String(" \t\n\r");
     var s = new String(str);

     if (whitespace.indexOf(s.charAt(0)) != -1) {
      // We have a string with leading blank(s)...
      var j=0, i = s.length;
      // Iterate from the far left of string until we
      // don't have any more whitespace...
      while (j < i && whitespace.indexOf(s.charAt(j)) != -1) 
         j++;
        // Get the substring from the first non-whitespace
        // character to the end of the string...
        s = s.substring(j, i);
      }
    return s;
}


function myOpenHelp( page, descrizione, tipo){
  var myurl = page ;
  this.windowHandle = window.open( page+"?daDescri="+descrizione+"&tipo="+tipo,'popup');
    if (!windowHandle.opener){
        windowHandle.opener = self;
    }
}

function myOpenHelpSpecial( page, id, tipo){
  var myurl = page ;
  this.windowHandle = window.open( page+"?daDescri=&id="+id+"&tipo="+tipo,'base');
    if (!windowHandle.opener){
        windowHandle.opener = self;
    }
}

function myOpenHelpDipendenti( page, descrizione,data, tipo){
  var myurl = page ;
  this.windowHandle = window.open( page+"?daDescri="+descrizione+"&data="+data+"&tipo="+tipo,'popup');
    if (!windowHandle.opener){
        windowHandle.opener = self;
    }
}


function maskKeyPress(objEvent, oggetto) {
        //var reValidChars=/[0-9][,-,]{1}[0-9]/;
        var reValidChars=/[0-9.]/;
        var iKeyCode, strKey;
        iKeyCode = objEvent.keyCode;
        strKey = String.fromCharCode(iKeyCode);

        if (!reValidChars.test(strKey)
           || oggetto.value.length > oggetto.size) {
                return false;
        }
}

function maskKeyPressApice(objEvent, oggetto) {
        //var reValidChars=/[0-9][,-,]{1}[0-9]/;
        var reValidChars=/[']/;
        var iKeyCode, strKey;
        iKeyCode = objEvent.keyCode;
        strKey = String.fromCharCode(iKeyCode);

        if (!reValidChars.test(strKey)
           || oggetto.value.length > oggetto.size) {
                return true;
        }else { return false;
        }       
}
/*
var init_msg = "S.I.I.S. Soft  Studio Italia Soluzioni Informatiche...               "
var str = ""
var msg= ""
var leftmsg = ""
function functionName(){

if (msg == "")
{
str = " "
msg = init_msg
leftmsg = ""
}
if (str.length == 1)
{
while (msg.substring(0, 1) == " ")
{
leftmsg = leftmsg + str
str = msg.substring(0, 1)
msg = msg.substring(1, msg.length)
}
leftmsg = leftmsg + str
str = msg.substring(0, 1)
msg = msg.substring(1, msg.length)
for (var ii = 0; ii < 10; ii++)
{str = " " + str}
}
else
{
str = str.substring(10, str.length)
}
window.status = leftmsg + str
JSCTimeOutID = window.setTimeout(' functionName()',100)
}
*/
function dataItalianaNumerica(data_italiana){
    var d = "01";
    var m = "01";
    var y = "2000";
    var i = 0;
    i = data_italiana.indexOf('/');
    d = data_italiana.substr (0 , i );
    data_italiana =  data_italiana.substr(i + 1 ,  data_italiana.length - ( i + 1) );
    i = data_italiana.indexOf('/');
    m = data_italiana.substr (0 , i );
    data_italiana =  data_italiana.substr(( i + 1) ,  data_italiana.length - ( i + 1)  );
    return data_italiana+""+m+""+d;
}

function trim(str)
{
   return str.replace(/^\s*|\s*$/g,"");
}

function expandCollapse() {            
    for (var i=0; i<expandCollapse.arguments.length; i++) {
      var element = document.getElementById(expandCollapse.arguments[i]);
      element.style.display = (element.style.display == "none") ? "block" : "none";
    }
}


function controllaCampotextNumerico(objEvent ,ogtipo){
       var v = parseFloat(objEvent.keyCode);
       
       if(v == 0){
           v =   parseFloat(objEvent.charCode);
       }

       if( isNaN(v) ){
          
          return false;

       }else{
          if(  v ==8  || v == 37  || v == 39  ||v == 46  || ( v >= 48 && v <= 57)  ){
          return true;
          }else{
          return false;
          }
       }
  }
