(function(_$){
	if (typeof _12ALL != 'object')
		_12ALL = {};
	
	_12ALL.get = function(obj,key,def) {
		if ((obj==null) || (typeof obj != 'object') || (obj[key]==null) || (typeof obj[key] == 'undefined'))
			return def;
		else
			return obj[key];
	};
	
	_12ALL.subscribe = function(email,nl,func,name,onSuccess,onError) {
		_$.getJSON('http://newsletter.happyclients.eu/wrapper/NewsletterJSONWrapper.php?email='+encodeURIComponent(email)+'&nlbox='+encodeURIComponent(nl)+'&funcml='+encodeURIComponent(func)+'&name='+encodeURIComponent(name)+'&jsoncallback=?',
			function(data){
				var err = _12ALL.get(data,'error','Unknown error');
				if (err!='') {
					if (_$.isFunction(onError))
						onError(err);
					else
						alert(err);
				} else {
					if (_$.isFunction(onSuccess)) {
						onSuccess(_12ALL.get(data,'codes',null));
					}
				}
		});
	};
	
	_12ALL.DICTIONARY = {
		'hu'	:	{
						'1'	:	'A listára feliratkozás nem támogatott',
						'2'	:	'Nem adtál meg minden adatot',
						'3'	:	'A megadott e-mail cím már szerepel a listán',
						'4'	:	'A korábbi feliratkozásodat nem hagytad jóvá',
						'5'	:	'Az e-mail cím nem adható a listához',
						'6'	:	'A megadott e-mail cím feldolgozás alatt áll',
						'7'	:	'Sikeresen feliratkoztál a hírlevelünkre',
						'8'	:	'Elírtad az e-mail címet',
						'9'	:	'Nem választottál hírlevelet',
						'10':	'A megadott e-mail cím feldolgozás alatt áll',
						'11':	'Sikeresen leiratkoztál hirlevelünkről',
						'12':	'Korábban nem iratkoztál még fel hírlevelünkre',
						'13':	'Sikeresen jóváhagytad feliratkozásodat',
						'14':	'Sikeresen leiratkoztál hírlevelünkről',
						'15':	'Beállításaidat mentettük',
						'16':	'Feliratkozáshoz meg kell adnod a nevedet is',
						'17':	'A megadott e-mail cím tiltólistán van'
				},
		'en'	:	{
						'1'  	  : 'This list is currently not accepting subscribers.  This list has met its top number of allowed subscribers.',
						'2'    	  : 'Your subscription request for this list could not be processed as you are missing required fields.',
						'3'       : 'This e-mail address is already subscribed to this mailing list.',
						'4'       : 'This e-mail address has been processed in the past to be subscribed, however your subscription was never confirmed.',
						'5'       : 'This e-mail address cannot be added to list.',
						'6'       : 'This e-mail address has been processed.  Please check your email to confirm your subscription.',
						'7'       : 'This e-mail address has subscribed to the list.',
						'8'       : 'E-mail address is invalid.',
						'9'       : 'Subscription could not be processed since you did not select a list.  Please select a list and try again.',
						'10'      : 'This e-mail address has been processed.  Please check your email to confirm your unsubscription.',
						'11'      : 'This e-mail address has been unsubscribed from the list.',
						'12'      : 'This e-mail address was not subscribed to the list',
						'13'      : 'Thank you for confirming your subscription.',
						'14'      : 'Thank you for confirming your unsubscription.',
						'15'      : 'Your changes have been saved.',
						'16'      : 'Your subscription request for this list could not be processed as you must type your name.',
						'17'      : 'This e-mail address is on the global exclusion list.',
						'18'      : 'Please type the correct text that appears in the image.'
				},
		'ru'	:	{
						'1'  	  : 'This list is currently not accepting subscribers.  This list has met its top number of allowed subscribers.',
						'2'    	  : 'Your subscription request for this list could not be processed as you are missing required fields.',
						'3'       : 'Вы уже подписались',
						'4'       : 'This e-mail address has been processed in the past to be subscribed, however your subscription was never confirmed.',
						'5'       : 'Вы неудачно записались',
						'6'       : 'This e-mail address has been processed.  Please check your email to confirm your subscription.',
						'7'       : 'Вы удачно подписались]',
						'8'       : 'Неправильный адрес электронной почты',
						'9'       : 'Subscription could not be processed since you did not select a list.  Please select a list and try again.',
						'10'      : 'This e-mail address has been processed.  Please check your email to confirm your unsubscription.',
						'11'      : 'This e-mail address has been unsubscribed from the list.',
						'12'      : 'Вы неудачно записались',
						'13'      : 'Thank you for confirming your subscription.',
						'14'      : 'Thank you for confirming your unsubscription.',
						'15'      : 'Your changes have been saved.',
						'16'      : 'Your subscription request for this list could not be processed as you must type your name.',
						'17'      : 'This e-mail address is on the global exclusion list.',
						'18'      : 'Please type the correct text that appears in the image.'
		
		},
    'de' : {
						'1'  	  : 'This list is currently not accepting subscribers.  This list has met its top number of allowed subscribers.',
						'2'    	  : 'Your subscription request for this list could not be processed as you are missing required fields.',
						'3'       : 'Diese E-Mail Adresse ist bereits für den Animax Online Newsletter angemeldet.',
						'4'       : 'This e-mail address has been processed in the past to be subscribed, however your subscription was never confirmed.',
						'5'       : 'Diese E-Mail Adresse konnte leider nicht für den Animax Online Newsletter registriert werden.',
						'6'       : 'This e-mail address has been processed.  Please check your email to confirm your subscription.',
						'7'       : 'Ihre E-Mail Adresse wurde erfolgreich für den Animax Online Newsletter registriert.',
						'8'       : 'Diese E-Mail Adresse ist leider ungültig.',
						'9'       : 'Subscription could not be processed since you did not select a list.  Please select a list and try again.',
						'10'      : 'This e-mail address has been processed.  Please check your email to confirm your unsubscription.',
						'11'      : 'This e-mail address has been unsubscribed from the list.',
						'12'      : 'Diese E-Mail Adresse konnte leider nicht für den Animax Online Newsletter registriert werden.',
						'13'      : 'Thank you for confirming your subscription.',
						'14'      : 'Thank you for confirming your unsubscription.',
						'15'      : 'Your changes have been saved.',
						'16'      : 'Your subscription request for this list could not be processed as you must type your name.',
						'17'      : 'This e-mail address is on the global exclusion list.',
						'18'      : 'Please type the correct text that appears in the image.'
    }								
	};
	
	_12ALL.getMessage = function(codes,dict,delim) {
		var dictionary = _12ALL.get(_12ALL.DICTIONARY,dict,{});
		delim = "\n";
		message = '';
		for (var i=0; i<codes.length; i++) {
			var code = codes[i];
			message += (i==0?"":delim)+_12ALL.get(dictionary,code,'Response code: '+code);
		}
		return message;
	};
})($);
