function validate_email(field,alerttxt)
{
  with (field)
  {
    apos=value.indexOf("@");
    dotpos=value.lastIndexOf(".");
    if (apos<1||dotpos-apos<2) 
      { alert(alerttxt);return false; }
    else {return true;}
  }
}
function validate_form(thisform)
{
    
    if (document.getElementById('comanda_nume').value == '')
        { alert('Va rugam completati toate informatiile din formular.');
          document.getElementById('comanda_nume').focus();
          return false;
        }
    if (validate_email(document.getElementById('comanda_mail'),"Adresa de e-mail nu este valida!")==false)
        { document.getElementById('comanda_mail').focus();
          return false;
        }
    if (document.getElementById('comanda_adresa').value == '')
        { alert('Va rugam completati toate informatiile din formular.');
          document.getElementById('comanda_adresa').focus();
          return false;
        }
    if (document.getElementById('comanda_tel').value == '')
        { alert('Va rugam completati toate informatiile din formular.');
          document.getElementById('comanda_tel').focus();
          return false;
        }
    q1 = document.getElementById('comanda_q1').options[document.getElementById('comanda_q1').selectedIndex].value;
    q2 = document.getElementById('comanda_q2').options[document.getElementById('comanda_q2').selectedIndex].value;
    q3 = document.getElementById('comanda_q3').options[document.getElementById('comanda_q3').selectedIndex].value;
    q4 = document.getElementById('comanda_q4').options[document.getElementById('comanda_q4').selectedIndex].value;
    q5 = document.getElementById('comanda_q5').options[document.getElementById('comanda_q5').selectedIndex].value;
    
    if(q1>0) return true;
    if(q2>0) return true;
    if(q3>0) return true;
    if(q4>0) return true;
    if(q5>0) return true;
    alert('Va rugam selectati cantitatea pentru produsele pe care doriti sa le comandati.');
    return false;
}
function calculeaza()
{
  var prices_p1 = new Array(42.35, 24.20, 42.35, 42.35, 53.90, 27.17, 53.90, 53.90, 31.68, 38.17, 27.17, 27.17, 27.17, 38.17, 34.76, 53.90, 53.90, 38.17, 38.17, 34.76, 34.76, 34.76, 38.17, 27.17, 69.30, 69.30, 69.30, 27.17, 24.20, 27.17, 34.76, 34.76, 34.76);
  var color_codes = new Array('#FCFFF5', '#EDEAE8', '#F7F7F7', '#FCFCFC', '#00145C', '#0099CC', '#0033AD', '#0034B1', '#00679F', '#5790A0', '#0491DA', '#7C90B1', '#E5E5BF', '#E5C29F', '#FFB200', '#FFA600', '#FFB203', '#F3B02B', '#727F7F', '#A7A188', '#A61818', '#7C0035', '#CF4600', '#A50325', '#B00109', '#C72802', '#B50B06', '#AF2432', '#043D15', '#1D7248', '#000000', '#61994F', '#CCC863');
  price_p2 = 17.69;
  price_p3 = 10.06;
  price_p4 = 19.01;
  price_p5 = 9.72;
  
  q1 = document.getElementById('comanda_q1').options[document.getElementById('comanda_q1').selectedIndex].value;
  q2 = document.getElementById('comanda_q2').options[document.getElementById('comanda_q2').selectedIndex].value;
  q3 = document.getElementById('comanda_q3').options[document.getElementById('comanda_q3').selectedIndex].value;
  q4 = document.getElementById('comanda_q4').options[document.getElementById('comanda_q4').selectedIndex].value;
  q5 = document.getElementById('comanda_q5').options[document.getElementById('comanda_q5').selectedIndex].value;
  culoare = document.getElementById('comanda_culoare').value;
  
  document.getElementById('comanda_p1').value = prices_p1[culoare];
  document.getElementById('show_color').style.backgroundColor = color_codes[culoare];
  document.getElementById('comanda_total1').value = (prices_p1[culoare]*q1).toFixed(2);
  document.getElementById('comanda_total2').value = (price_p2 * q2).toFixed(2);
  document.getElementById('comanda_total3').value = (price_p3 * q3).toFixed(2);
  document.getElementById('comanda_total4').value = (price_p4 * q4).toFixed(2);
  document.getElementById('comanda_total5').value = (price_p5 * q5).toFixed(2);
  document.getElementById('comanda_total').value = (prices_p1[culoare]*q1 + price_p2*q2 + price_p3*q3 + price_p4*q4 + price_p5*q5).toFixed(2);
  
}
