function modul_new_captcha( modul, name, func ) {
	function fReadyState( sResponse ) {
		var item = document.getElementById( modul + '_' + name );
		item.innerHTML = sResponse;
	}
	
	message = "system_function=get_ajax&mod=" + modul + "&name=" + name + "&func=" + func ;
	sendPublicAJAXMessage( message, fReadyState );
}

function modul_newsletter_start() {
	/*proform.initForm( 'modul_newsletter_form' );
	proform.addGroup( { id : 'modul_newsletter_group', 
						elements : [ 'email', 'captcha_text' ],
						validate : true,
						processor : function ( oT ) {
								var aReturn = [];
								aReturn.push( proform.condition.required( oT.email.value == '', [oT.email] ) );
								aReturn.push( proform.condition.required( oT.captcha_text.value == '', [oT.captcha_text] ) );
								aReturn.push( proform.condition.warning( oT.captcha_text.value != '' && !/^\d{4}$/.test( oT.captcha_text.value ), [oT.captcha_text], ['Az ellenőrző kód hibás!'] ) );
								aReturn.push( proform.condition.warning( oT.email.value != '' && !proform.condition.checkFormat('email', oT.email.value ), [oT.email], ['Az e-mail formátuma nem megfelelő!'] ) );
								return proform.condition.totalize(aReturn);
							}
				} );
	proform.config.autoFocus = false;
	proform.init();*/
}


// email ellenőrzés [proform]
function check_email(email) {
	sAtom = '\[^\\s\\(\\)<>@,;:\\\\\\\"\\.\\[\\]\]+';
	sWord = '(' + sAtom + '|(\"[^\"]*\"))';
	// alapvető megfelelés
	aMatch = email.match( /^(.+)@(.+)$/ );
	if ( aMatch == null ) {
		return false;
	};
	// user megfelel-e?
	if ( aMatch[1].match( new RegExp("^" + sWord + "(\\." + sWord + ")*$" ) ) == null ){
		return false;
	};
	// a domain megfelel?
		if ( aMatch[2].match( new RegExp("^" + sAtom + "(\\." + sAtom +")*$") ) == null ) {
		return false;
	};
	aDom = aMatch[2].match( new RegExp( sAtom, "g" ) );
	if ( aDom[ aDom.length-1 ].length < 2 || aDom[ aDom.length-1 ].length > 3 ){
		return false;
	};
	if ( aDom.length < 2 ) {
		return false;
	};
	return true;
}

function modul_newsletter_subscribe(e) {
	var form = document.getElementById(e);
	
	
	// proform ellenőrzés
	//var res = form.onsubmit();
	//if (!res) return false;
	
	var email = form.newsletter_email.value;
	var captcha_text = form.newsletter_captcha_text.value;
	
	// form ellenőrzés 
	var errors = new Array();
	
	
	
	
	// ellenőrzés: email
	if (!email) {
		errors.push("Az e-mail cím megadása kötelező!");
	}
	else if ( !check_email(email) ) {
		errors.push("Érvénytelen e-mail cím!");
	}
	
	// ellenőrzés: captcha text
	if (!captcha_text) {
		errors.push("Az ellenőrző kód megadása kötelező!");
	} 
	else if (captcha_text.length!=4) {
		errors.push("Nem megfelelő az ellenőrző kód formátuma!");
	}
	
	for ( var i=0; i<errors.length; i++ ) {
		alert(errors[i]);
	}
	
	if (errors.length!=0) return false;
	
	var message = '&system_function=ajax_function&mod=modul_newsletter&func=subscribe';
	var content = 'email='+email+'&captcha='+captcha_text;	

	var fReadyState = function( sResponse ) {
		var respDiv = document.getElementById('response');
		// rendben
		if (sResponse==1) {
			alert('A hírlevélre sikeresen feliratkozott!');
			form.reset();
		}
		// hibás feliratkozás
		else {
			alert('Hiba történt a művelet során, az alábbiak valamelyike miatt:\n- létező felhasználó \n- rossz ellenőrző kód!');
		}
	}
	//alert(content);
	sendFunctionAJAXMessage( message, fReadyState, content );
}

