// -------------------------------------------------------------
// File     : globals.js
// Author   : F. Nembrini
// Company  : (C) 2010 Quarcom Teleinformatics
// Date     : uAgust 03, 2010
// Modified : August 04, 2010
// Aim      : Manage ETM scripts
// -------------------------------------------------------------

// ################################################### Novita ###################################################
function showDetNovita(id, type)
{
  var winNov = window.open("novita_dett.php?id=" + id + "&type=" + type + "","News","width=650,height=500,scrollbars=1,resizable=1,menubar=0,location=0,alwaysRaised=0");
} // End showDetNovita()

// ################################################### Prodotti ###################################################
function showDetProd(id)
{
  var winDP = window.open("prod_det.php?id=" + id + "","Product","width=650,height=500,scrollbars=1,resizable=1,menubar=0,location=0,alwaysRaised=0");
} // End showDetProd()


// ################################################### Attachments ###################################################
function attachDocManifestazione(id)
{
  var winAttach = window.open("attach_doc_manif.php?id=" + id + "","AddAttachment","width=500,height=300,scrollbars=1,resizable=1,menubar=0,location=0,alwaysRaised=0");
} // End attachDocManifestazione()

// ################################################### Foto ###################################################
function showFotoDet(id,width,height)
{
  var winFot = window.open("regione_foto_dett.php?id=" + id + "","Fotogallery","width="+ width +",height="+ height +",scrollbars=0,resizable=1,menubar=0,status=0,location=0,alwaysRaised=0");
} // End showFotoDet()


// ################################################### Credits ###################################################
function showCredits()
{
  var winCredits = window.open("credits.html","Credits","width=353,height=72,scrollbars=0,resizable=1,menubar=0,location=0,alwaysRaised=0,status=0,statusbar=0");
} // End showCredits()

// ################################################### Disclaimer ###################################################
function showDisclaimer(lang)
{
  var winDisc = window.open("disclaimer.php?lang=" + lang + "","Disclaimer","width=650,height=450,scrollbars=0,resizable=1,menubar=0,location=0,alwaysRaised=0");
} // End showDisclaimer()

// ################################################### Links ###################################################
function openLink(lnk)
{
  var winLink = window.open(lnk,"Link");
  return false;
} // End openLink()

// ################################################### Form ###################################################

var checkArray = new Array(false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false);
var isChecked = false;

function checkIt(index)
{
  if(checkArray[index])
  {
    checkArray[index] = false;
  }
  else
  {
    checkArray[index] = true;
  }
} // End checkIt()


function sendInfo(form,m,s)
{
  var error = true;
  var msg   = "";
  
  msg = "Completate i campi obbligatori (grassetto) per favore";
  
  form.richiesta.setAttribute("class", "fvalid2");
  form.email.setAttribute("class", "fvalid");
  form.cognome.setAttribute("class", "fvalid");
  form.nome.setAttribute("class", "fvalid");
  
  if(form.nome.value.length != 0 && form.cognome.value.length != 0 && form.email.value.length != 0 && form.richiesta.value.length != 0 )
  {
    if(form.email.value.indexOf("@") == -1  || form.email.value.indexOf(".") == -1)
    {
      form.email.setAttribute("class", "ferror");
      form.email.focus();
      error = true;
      alert("Formato e-mail non valido!");
    }
    else
    {
      error = false;
    }
  }
  else
  {
    if(form.richiesta.value.length == 0)
    {
      form.richiesta.setAttribute("class", "ferror2");
      form.richiesta.focus();
    }
    
    if(form.email.value.length == 0)
    {
      form.email.setAttribute("class", "ferror");
      form.email.focus();
    }
    
    if(form.cognome.value.length == 0)
    {
      form.cognome.setAttribute("class", "ferror");
      form.cognome.focus();
    }
    
    if(form.nome.value.length == 0)
    {
      form.nome.setAttribute("class", "ferror");
      form.nome.focus();
    }
    
    alert(msg);
	error = true;
  }
  
  if(!error)
  {
    form.action = "index.php?snd=1&m=" + m + "&s=" + s + "";
	form.method = "post";
	form.submit();
  }
} // end sendInfo()


// ################################################### Sorting ###################################################
function sortBy(column)
{
  form = document.forms['rslist'];
  
  if(form.sorting.value == "ASC")
    form.sorting.value = "DESC";
  else
    form.sorting.value = "ASC";
  
  form.order_by.value = column;
  form.submit();
}

function setRowsPage(rows)
{
  form = document.forms['rslist'];
  form.rows.value = rows;
  form.submit();
}

function highLightRow(el, cl_name)
{
  el.className = cl_name;
}
