function isEmail(email)
{
    if(-1 == email.indexOf("@")
    	||(-1 != email.indexOf(","))
    	||(-1 != email.indexOf("#"))
    	||(-1 != email.indexOf("!"))
    	||(-1 != email.indexOf(" "))
    	||(-1 != email.indexOf(":"))
    	||(-1 != email.indexOf("("))
    	||(-1 != email.indexOf(")"))
    	//||(-1 != email.indexOf('"'))
    	//||(-1 != email.indexOf("\\"))
    	||(-1 != email.indexOf("/"))
    	||(email.length == (email.indexOf("@")+1) )
    	||(email.length == 0) )
	   return false;

  return true;
}
function isEmpty(theValue)
{
	if (theValue.toString().length==0)
		return true;
	else
		return false;
}
function newsLetterAddMail(url)
{
  advAJAX.post(
  {
	url : url,
	parameters : {
		'ne_email' : document.getElementById('ne_email').value
	},
	onInitialization : function() {
	  document.getElementById('contactFormSending').style.display='block';
		  document.getElementById('contactFormSendingSuccess').style.display='none';
		  document.getElementById('contactFormSendingFailed').style.display='none';
	},
	onError : function() {
		 alert('Problem z wysłaniem zapytania. Spróbuj jeszcze raz.');
	},
	onSuccess : function(obj) {
		document.getElementById('contactFormSending').style.display='none';
		if (obj.responseText == "<br />") {
			document.getElementById('ne_email').value = '';
			document.getElementById('contactFormSendingSuccess').style.display='block';
		}
		else {
			alert(obj.responseText);
			document.getElementById('contactFormSendingFailed').style.display='block';
			//document.getElementById('contactFormSendingFailed').innerHTML = obj.responseText;
		}
	}
  });
}
function newsLetterAddMailFormCheck()
{
    errorMsg = '';
    if (isEmpty(document.getElementById('ne_email').value)) {
        errorMsg = 'Proszę wpisać adres e-mail';
    }
    if (!isEmail(document.getElementById('ne_email').value)) {
        errorMsg = 'Proszę wpisać poprawny adres e-mail';
    }
    

    if (errorMsg!='') {
        alert(errorMsg);
        return false;
    }

    return true;
}
