if (typeof Class == 'undefined')
	throw("eMail.js requires including prototype library!");

var eMail = Class.create({
	//
	//  Setup the Variables
	//
	crypted : '',
	options : {},

	//
	//  Initialize the accordions
	//
	initialize: function(crypted, options) {
	    this.crypted = crypted;

		this.options = Object.extend({
			subject : ''
		}, options || {});
	},

	showLink: function() {
	    var link = 'nbjmup;' + this.crypted;
	    var href =  this._uncrypt(link);

	    if (this.options.subject != '') {
	        href += '?subject=' + this.options.subject;
	    }

        location.href = href;
	},

	showAddress: function() {
        return this._uncrypt(this.crypted);
    },

	validate: function(email) {
        return (email.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1);
	},

    _uncrypt: function(str) {
        var n = 0;
        var r = "";

        for( var i = 0; i < str.length; i++)
        {
            n = str.charCodeAt( i );

            if( n >= 8364 )
            {
                n = 128;
            }

            r += String.fromCharCode( n - 1 );
        }

        return r;
    }
});

