// JavaScript Document

 function optiuni (radio) {
    if(radio.value == "luc1") {
    document.getElementById('optiune1').style.display = 'block';
    document.getElementById('optiune2').style.display = 'none';
    document.getElementById('optiune3').style.display = 'none';
    }
    if(radio.value == "luc2") {
    document.getElementById('optiune1').style.display = 'none';
    document.getElementById('optiune2').style.display = 'block';
    document.getElementById('optiune3').style.display = 'none';
    }
    if(radio.value == "luc3") {
    document.getElementById('optiune1').style.display = 'none';
    document.getElementById('optiune2').style.display = 'none';
    document.getElementById('optiune3').style.display = 'block';
    }
 }
 
 function numeralsOnly(evt) {
  // 0=48; 9=57
    evt = (evt) ? evt : event; 
    var charCode = (evt.charCode) ? evt.charCode : ((evt.keyCode) ? evt.keyCode : ((evt.which) ? evt.which : 0));         
    var str = evt.srcElement.value; 
    if (charCode < 48 || charCode > 57)
      return false;
    return true;
  }
  
  /////////////////////////////////////-------------------- 
  
  function hasLetters(edit){
    var str= edit.value; 
    var charCode;
    for(i= 0; i< str.length; i++)
    {
      charCode= str.charCodeAt(i);
      if (charCode < 48 || charCode > 57)
  	{
        edit.value= '';
        return false;
      }
    }
    return true;
  }
  
 
 function check_form(val) {
  var em = val.email.value;
  
    if (val.nume_prenume.value == "") {
    alert("Nu ati introdus numele si prenumele!"); 
    val.nume_prenume.focus();
    return false;
    }
    if (val.companie.value == "") {
    alert("Nu ati introdus compania!"); 
    val.companie.focus();
    return false;
    }
    if (val.adresa.value == "") {
    alert("Nu ati introdus adresa!"); 
    val.adresa.focus();
    return false;
    }
    if (val.tel.value.length < 6) {
    alert("Numarul de telefon trebuie sa aiba cel putin 6 numere!"); 
    //val.tel.value="";
    val.tel.focus();
    return false;
    }
	if (val.fax.value.length < 6) {
    alert("Numarul de fax trebuie sa aiba cel putin 6 numere!"); 
    //val.tel.value="";
    val.fax.focus();
    return false;
    }
    if (val.mobil.value.length < 10) {
    alert("Numarul de mobil trebuie sa aiba cel putin 10 numere!"); 
    val.mobil.focus();
    return false;
    }
    if ((em.indexOf('@', 0) == -1) || (em.indexOf('.', 0) == -1) || (em.lastIndexOf('@') == em.length-1) ||(em.lastIndexOf('.') == em.length-1) ||(em.indexOf('@', 0) != em.lastIndexOf('@'))) {
    alert("Nu ati introdus o adresa VALIDA de email!");
    val.email.value = "";
    val.email.focus();
    return false;
    }
    if (val.lucrare[0].checked == "" && val.lucrare[1].checked == "" && val.lucrare[2].checked == "") {
    alert("Nu ati slectat tipul de lucrare!"); 
    return false;
    }
    if (val.denumire.value == "") {
    alert("Nu ati introdus denumirea lucrarii!"); 
    val.denumire.focus();
    return false;
    }
    if (val.tiraj.value == "") {
    alert("Nu ati introdus tirajul!"); 
    val.tiraj.focus();
    return false;
    }
    
    //----- optiune1 --------------
    if(val.lucrare[0].checked != "") {
      if (val.format_i1.value == "") {
      alert("Nu ati introdus Format finit inchis!"); 
      val.format_i1.focus();
      return false;
      }
      if (val.format_d1.value == "") {
      alert("Nu ati introdus Format finit deschis!"); 
      val.format_d1.focus();
      return false;
      }
      if (val.culori_c.value == "") {
      alert("Nu ati introdus Nr. culori coperta!"); 
      val.culori_c.focus();
      return false;
      }
      if (val.culori_i.value == "") {
      alert("Nu ati introdus Nr. culori interior!"); 
      val.culori_i.focus();
      return false;
      }
      if (val.hartie_c.value == "") {
      alert("Nu ati introdus Hartie coperta!"); 
      val.hartie_c.focus();
      return false;
      }
      if (val.hartie_i.value == "") {
      alert("Nu ati introdus Hartie interior!"); 
      val.hartie_i.focus();
      return false;
      }
      if (val.nr_pg.value == "") {
      alert("Nu ati introdus numarul de pagini!"); 
      val.nr_pg.focus();
      return false;
      }
      if (val.finisare.value == "") {
      alert("Nu ati introdus modul de finisare!"); 
      val.finisare.focus();
      return false;
      }
      return true;
    }
    
    //----- optiune2 --------------
    if(val.lucrare[1].checked != "") {
      if (val.format.value == "") {
      alert("Nu ati introdus formatul!"); 
      val.format.focus();
      return false;
      }
      if (val.culori_f.value == "") {
      alert("Nu ati introdus Nr. culori fata!"); 
      val.culori_f.focus();
      return false;
      }
      if (val.culori_v.value == "") {
      alert("Nu ati introdus Nr. culori verso!"); 
      val.culori_v.focus();
      return false;
      }
      if (val.sortiment.value == "") {
      alert("Nu ati introdus sort!"); 
      val.sortiment.focus();
      return false;
      }
      return true;
    }
    
    //----- optiune3 --------------
    if(val.lucrare[2].checked != "") {
      if (val.format_i2.value == "") {
      alert("Nu ati introdus Format finit inchis!"); 
      val.format_i2.focus();
      return false;
      }
      if (val.format_d2.value == "") {
      alert("Nu ati introdus Format finit deschis!"); 
      val.format_d2.focus();
      return false;
      }
      if (val.nr_biguri.value == "") {
      alert("Nu ati introdus Nr. biguri!"); 
      val.nr_biguri.focus();
      return false;
      }
      if (val.lipire.value == "") {
      alert("Nu ati introdus Lipire pe latura!"); 
      val.lipire.focus();
      return false;
      }
      return true;
    }
    
  }
