function saveComment()
{
    $('.error').hide();
    $('.succes').hide();
    var nume = $('#txtNume').val();
    var email = $('#txtEmail').val();
    var captcha = $('#txtCaptcha').val();
    var comments = $('#txtComments').val();
    var id = $('#postStiriID').val();
    if (nume.length == 0)
    {
        show_error('Va rog sa introduceti un nume');
        return false;
    }
    else if(email.length == 0)
    {
            show_error('Va rog sa introduceti o adresa de e-mail');
            return false;
    }
    else if (!validEmail(email)) {
		show_error('Adresa de e-mail este invalida');
		return false;
    }
    else if (comments.length == 0)
    {
        show_error('Va rog sa introduceti un comment');
        return false;
    }
    else if (captcha.length == 0)
    {
        show_error('Va rog sa introduceti codul de verificare');
        return false;
    }
    $.ajax({
            type: "POST",
            url: "news.ajax.php",
            dataType: "text",
            data: ({
                    action: 'save_comment',
                    id:id,
                    nume:nume,
                    email:email,
                    comment:comments,
                    captcha:captcha
            }),
            success: function(html){
                  $('#imgCaptcha').attr("src","show_captcha.php?id="+Math.random());
                  var error = false;
                  if (html == 'banned')
                  {
                      show_error('IP-ul tau este banat. Daca esti de parere ca s-a comis o greseala, te rugam sa ne trimiti un email la: webmaster@ftr.ro');
                      error = true;
                  }
                  if (html == 'captchaError')
                  {
                      show_error('Codul de verificare nu este corect.');
                      error = true;
                  }
                  if (html == 'obscenError')
                  {
                      show_error('Textul contine expresii obscene.');
                      error = true;
                  }
                  if (!error)
                  {
                      $('#comments').html(html);
                      $('#txtNume').val('');
                      $('#txtEmail').val('');
                      $('#txtComments').val('');
                      $('#txtCaptcha').val('');
                      show_message('Multumim pentru comentariu.<br />Acesta va aparea pe site imediat dupa ce va fi aprobat.');
                  }
            },
            complete: function(){
            },
            error: function(XMLHttpRequest, textStatus, errorThrown){
                    show_error('Am intalnit o eroare. Incercati mai tarziu.');
                    return false;
            }
    });

}
function validEmail(email) {


    invalidChars = " /:,;"

    if (email == "") {						// camp obligatoriu de completat
        return false
    }
    for (i=0; i<invalidChars.length; i++) {	// contine caractere invalide
        badChar = invalidChars.charAt(i)
        if (email.indexOf(badChar,0) > -1) {
            return false
        }
    }
    atPos = email.indexOf("@",1)			// tb sa existe simbolul "@"
    if (atPos == -1) {
        return false
    }
    if (email.indexOf("@",atPos+1) != -1) {	// un singur simbol "@"
        return false
    }
    periodPos = email.indexOf(".",atPos)
    if (periodPos == -1) {					// si cel putin un "." dupa "@"
        return false
    }
    if (periodPos+3 > email.length)	{		// cel putin 2 caractere dupa "."
        return false
    }
    return true
}