function aboneaza(form, rootpath) {

	if (form.mail.value == '' ){
		alert('Va rugam introduceti adresa de e-mail!');
		form.mail.focus();
		return false;
	}

	if (!isMail(form.mail)){
		alert('Va rugam introduceti o adresa de e-mail valida (exemplu: nume@domeniu.com)!');
		form.mail.focus();
		if (form.mail.value.indexOf('adresa e-mail') == 0) {
			form.mail.value = '';
		}
		return false;
	}
	
	form.action.value="return aboneaza(this);"

	var width = 300;
	var height = 300;
	var left = Math.ceil((window.screen.availWidth - width) / 2);
	var top = Math.ceil((window.screen.availHeight - height) / 2);

	var wnd = window.open(rootpath+'/newsletter/aboneaza.php?mail=' + escape(form.mail.value), 'Abonare_Newsletter', "menubar=no,status=no,scrollbars=no,resizable=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);

	return false;
}


function dezabonare() {
	
	var form = document.getElementById('form_dezabonare');
	if (form + "" != "undefined" && form != null) {
		form.action.value="return dezaboneaza(this);"
		form.submit();
	}
}

function dezaboneaza(form, rootpath) {
	
	var width = 300;
	var height = 300;
	var left = Math.ceil((window.screen.availWidth - width) / 2);
	var top = Math.ceil((window.screen.availHeight - height) / 2);

	var wnd = window.open(rootpath+'/newsletter/dezaboneaza.php?mail=' + escape(form.mail.value), 'Dezabonare_Newsletter', "menubar=no,status=no,scrollbars=no,resizable=yes,width=" + width + ",height=" + height + ",top=" + top + ",left=" + left);

	return false;
}


function aboneaza2(form) {
	if (form.mail.value.length == 0) {
		alert('Va rugam introduceti o adresa de e-mail!');
		form.mail.focus();
		return false;
	}
	if (!isMail(form.mail)){
		alert('Va rugam introduceti o adresa de e-mail valida (exemplu: nume@domeniu.com)!');
		form.mail.focus();
		return false;
	}
	if (form.varsta.value.length != 0 && !isInteger(form.varsta)) {
		alert('Va rugam introduceti o varsta corecta!');
		form.varsta.focus();
		return false;
	}
	else{
		if (form.varsta.value.length != 0) {
			var v;
			eval('v='+form.varsta.value+';');
			if (v <= 0) {
				alert('Varsta nu poate fi un numar negativ sau zero!');
				form.varsta.focus();
				return false;
			}
		}		
	}
	
	return true;
}

function dezaboneaza2(form) {
	if (form.mail.value.length == 0) {
		alert('Va rugam introduceti adresa de e-mail!');
		form.mail.focus();
		return false;
	}
	if (!isMail(form.mail)){
		alert('Va rugam introduceti o adresa de e-mail valida (exemplu: nume@domeniu.com)!');
		form.mail.focus();
		return false;
	}
	
	return true;
}
