
//--------------------------------------------------------------------------------
// sito       : beckerpipes.it
// nome       : pubblico.js
// autore     : CS
// modificato : 18/11/2007 12.53
// descrizione: controllo sintattico per pagine sito pubblico
//--------------------------------------------------------------------------------

//------------------------------------------------------------------------------

function apri_news(url, w, h)
{
  var parametri = "toolbar=no,location=no,directories=no,status=no"
                 +",menubar=no"
                 +",resizable=yes"
                 +",copyhistory=no"
                 +",titlebar=no"
                 +",scrollbars=yes"
                 +",dependent=yes"
                 +",left=20"
                 +",top=20"
                 +",width=" + (w+20)
                 +",height=" + (h+20);
  var finestra = window.open(url, 'news', parametri);
  finestra.focus();
}

//------------------------------------------------------------------------------

function on_fax_order()
{
  document.forms[0].action = "http://www.beckerpipes.com/php/ordine_fax.php";
  document.forms[0].submit();
  return true;
}

//------------------------------------------------------------------------------

function on_login()
{
  var f = document.forms['login'];
  if(f.p_username.value == "") {
    alert("insert username");
    f.p_username.focus();
  } else if(f.p_password.value == "") {
    alert("insert password");
    f.p_password.focus();
  } else {
    return true;
  }
  return false;
}

//------------------------------------------------------------------------------

function on_ordine(msg_errore, msg_telefono)
{
  var f = document.forms['ordine'];
  if(f.p_nome.value      == "") { alert(msg_errore); f.p_nome.focus()     ; return false; }
  if(f.p_indirizzo.value == "") { alert(msg_errore); f.p_indirizzo.focus(); return false; }
  if(f.p_citta.value     == "") { alert(msg_errore); f.p_citta.focus()    ; return false; }
  if(f.p_cap.value       == "") { alert(msg_errore); f.p_cap.focus()      ; return false; }
  if(f.p_provincia.value == "") { alert(msg_errore); f.p_provincia.focus(); return false; }
  if(f.p_nazione.value   == "") { alert(msg_errore); f.p_nazione.focus()  ; return false; }
  if((f.p_mail.value.length < 5)
  || (f.p_mail.value == "")
  || (!f.p_mail.value.match("@.+[.]+"))) {
    alert("e-mail address is not valid");
    f.p_mail.focus();
    return false;
  }
  if(f.p_telefono.value == "") {
    if(confirm(msg_telefono)) {
      f.p_telefono.focus();
      return false;
    }
  }
  return true;
}

//------------------------------------------------------------------------------

function on_popup_subscribe()
{
  // apre la pagina delle notizie e chiude il popup
  var uri = 'http://test.beckerpipes.com/pubblico/notizia.php'
  window.opener.location = uri;
  close();
}

//------------------------------------------------------------------------------

function on_subscribe(msg_errore)
{
  var f = document.forms['subscribe'];
  var e_mail = f.p_mail.value;
  if((e_mail == "")||(e_mail.length < 5)||(!e_mail.match("@.+[.]+"))) {
    alert(msg_errore);
    f.p_mail.select();
    return false;
  }
  return true;
}

//--------------------------------------------------------------------------------
