var ScreenWidth = screen.width;
var ScreenHeight = screen.height;

var PopWindow;
var url
var winwidth
var winheight


function signin(add, winwidth, winheight) {

  var user = document.iscrizione_nl.email.value;
  var ScreenWidth  = screen.width;
  var ScreenHeight = screen.height;
  var topheight = (ScreenHeight/2)-(winheight/2);
  var leftwidth = (ScreenWidth/2)-(winwidth/2);
  add = add + '&email=' + user;

  PopWindow = window.open(add,"PopWindow","width=" + winwidth + ",height=" + winheight + ",top="+topheight+",left=" + leftwidth +",resizable=no,scrollbars=no,toolbar=no,location=no,status=no");
}

function apri(str, winwidth, winheight) {
  PopWindow = window.open(str,"PopWindow","width=" + winwidth + ",height=" + winheight + ",top=0,left=0,toolbar=no,location=no,status=no");
}

function apri_scroll(str, winwidth, winheight) {
  PopWindow = window.open(str,"PopWindow","width=" + winwidth + ",height=" + winheight + ",top=0,left=0,resizable=no,scrollbars=yes,toolbar=no,location=no,status=no");
}

function mostra_opzione(nome1, nome2, nome_controllo) {

  window.alert(nome_controllo.length);
  window.alert(nome_controllo.selectedIndex);

  if (document.all)  docLayer = document.all.item(nome1);
  else if (document.layers) docLayer = document.layers[nome1];
  else if (document.getElementById){docLayer = document.getElementById(nome1); NN6 = 1;}
  else alert("The document object model is not recognized");
  if (document.layers && document.layers[nome1] != null) {
    docLayer.visibility = Value;
  }
  // IE
  else if (document.all) {
     eval('docLayer.style.visibility ="'+ Value +'"');
  }
  // Netscape 6.0
  else if (document.getElementById) {
    docLayer.style.visibility = Value;
  }

  if (document.all)  docLayer = document.all.item(nome2);
  else if (document.layers) docLayer = document.layers[nome2];
  else if (document.getElementById){docLayer = document.getElementById(nome2); NN6 = 1;}
  else alert("The document object model is not recognized");
  if (document.layers && document.layers[nome2] != null) {
    docLayer.visibility = Value;
  }
  // IE
  else if (document.all) {
     eval('docLayer.style.visibility ="'+ Value +'"');
  }
  // Netscape 6.0
  else if (document.getElementById) {
    docLayer.style.visibility = Value;
  }
}

function show(id) {
   var obj = document.getElementById(id);

   if(obj.style.display =='' || obj.style.display == 'none') {
     obj.style.display='block';
   }else {
     obj.style.display='none';
   }
}

function IsNumeric(sText) {
  var ValidChars = "0123456789.";
  var IsNumber   = true;
  var Char;

  for (i = 0; i < sText.length && IsNumber == true; i++) {
    Char = sText.charAt(i);
    if (ValidChars.indexOf(Char) == -1) {
        IsNumber = false;
    }
  }
  if (IsNumber == false) window.document.form_filtro.quanto.value = '';

  return IsNumber;
}

///////////////////////////////////////

function Prova(stringa) {
  alert(stringa);
}

function Menu(num) {
  switch (num) {
    // VISUALIZZA ANALISI
    case 1:
      //alert(num);
      //document.forms['form_dati'].filtro_AUA.selectedIndex = 0;
      document.forms['form_dati'].flag.value = num + '';
      document.forms['form_dati'].FiltroData.value = '';
      break;

    // MODIFICA DATI
    case 8:
      //alert(num);
      document.forms['form_dati'].filtro_AUA = ''
      document.forms['form_dati'].flag.value = num + '';
      break;
    case 9:
      document.forms['form_dati'].flag.value = num + '';
      break;

    // CONTATTI
    case 10:
      //alert(num);
      document.forms['form_dati'].filtro_AUA = ''
      document.forms['form_dati'].flag.value = num + '';
      break;
    case 11:
      document.forms['form_dati'].flag.value = num + '';
      break;

    // INVIA ANALISI
    case 3:
      document.forms['form_dati'].filtro_AUA = '';
      document.forms['form_dati'].flag.value = num +'';
      break;
    case 4:
      document.forms['form_dati'].flag.value = num + '';
      break;

    // VISUALIZZA SMS INVIATI
    case 7:
      document.forms['form_dati'].filtro_AUA = '';
      document.forms['form_dati'].flag.value = num + '';
      break;

    // ESPORTA ANALISI
    case 5:
      document.forms['form_dati'].filtro_AUA = '';
      document.forms['form_dati'].flag.value = num + '';
    case 6:
      document.forms['form_dati'].flag.value = num + '';
      break;

    // VISUALIZZAZIONE CAPI VENDUTI
    case 12:
      //alert(num);
      //document.forms['form_dati'].filtro_AUA.selectedIndex = 0;
      document.forms['form_dati'].flag.value = num + '';
      document.forms['form_dati'].FiltroData.value = '';
      break;

    // INVIO SMS VARI
    case 13:
      //alert(num);
      //document.forms['form_dati'].filtro_AUA.selectedIndex = 0;
      document.forms['form_dati'].flag.value = num + '';
      document.forms['form_dati'].FiltroData.value = '';
      break;
    case 14:
      document.forms['form_dati'].flag.value = num + '';
      break;

    // INVIO SMS VARI
    case 15:
      //alert(num);
      //document.forms['form_dati'].filtro_AUA.selectedIndex = 0;
      document.forms['form_dati'].flag.value = num + '';
      document.forms['form_dati'].FiltroData.value = '';
      break;
  }
  document.forms['form_dati'].submit();
}

function calend_av(mm, aa) {
//   alert('Prima ' + mm + ' ' + aa);
  if (mm == 12) {
    mm = 1;
    aa = aa + 1;
  }
  else mm = mm + 1;

//   alert('Dopo ' + mm + ' ' + aa);
  window.document.form_dati.data_calendario.value= mm + '|' + aa;
}

function calend_ind(mm, aa) {
//   alert('Prima ' + mm + ' ' + aa);
  if (mm == 1) {
    mm = 12;
    aa = aa - 1;
  }
  else mm = mm - 1;

//   alert('Dopo ' + mm + ' ' + aa);
  window.document.form_dati.data_calendario.value= mm + '|' + aa;
}

function Select_Deselect_All() {
  var i;
  var d;

//   alert(document.forms['form_dati'].MasterChk.checked);
  d = document.forms['form_dati'];
  for (i = 1; i < d.elements.length; i++) {
    if (d.elements[i].type == "checkbox") {
      if (d.MasterChk.checked) d.elements[i].checked = true;
      else d.elements[i].checked = false;
    }
  }
}
