var comEmailFalse = '<strong class="error">Podany adres email jest niepoprawny!</strong>';
var regEmail = /^(.[A-Za-z0-9\-\.]*\w)+@+([A-Za-z0-9\-]*\w)+(\.[A-Za-z]*\w)+$/;
var url = 'http://oia.krakow.pl/index.php';

function emailTest (email) {
	var testMail = ($("#email").val()).match(regEmail);
	if (testMail) {
		return true;
	} else {
		return false;
	}
}

function signin() {
	if (emailTest($("#email").val())) {
		$.post(url+"/index/subscribe", { email: $("#email").val() }, function(data){
			$("#newsletter_comm").html(data);
		});
	} else {
		$("#newsletter_comm").html(comEmailFalse);
	}
}

function signout() {
	if (emailTest($("#email").val())) {
		$.post(url+"/index/unsubscribe", { email: $("#email").val() }, function(data){
			$("#newsletter_comm").html(data);
		});
	} else {
		$("#newsletter_comm").html(comEmailFalse);
	}
}

