jQuery.extend($, {
      forumprofi: {
            baseUrl:          '/',
            imageURL:         '/',
            sessionName:      null,
            sessionID:        null,
            setBaseUrl:       function(url) {
                                    $.forumprofi.baseUrl = url.replace(/[\/\\]+$/, '');
                                    $.forumprofi.baseUrl = $.forumprofi.baseUrl + '/';
                              },
            setImageUrl:      function(url) {
                                    $.forumprofi.imageUrl = url.replace(/[\/\\]+$/, '');
                                    $.forumprofi.imageUrl = $.forumprofi.imageUrl + '/';
                              },
            setSession:       function(name, id) {
                                    $.forumprofi.sessionName = name;
                                    $.forumprofi.sessionID   = id;
                              },
            url:              function(url, session) {
                                    url = $.forumprofi.baseUrl + url.replace(/^[\/\\]+/, '');
                                    url = url.replace(/[\/\\]+$/, '');
                                    url = url + '/';
                                    if(session == 'query' && $.forumprofi.sessionName.length && $.forumprofi.sessionID.length) {
                                          url = url + '?' + $.forumprofi.sessionName + '=' + $.forumprofi.sessionID;
                                    }
                                    else if(session == 'none') {
                                    }
                                    else {
                                          if($.forumprofi.sessionName.length && $.forumprofi.sessionID.length) {
                                                url = url + $.forumprofi.sessionName + '/' + $.forumprofi.sessionID + '/';
                                          }
                                    }
                                    
                                    return url;
                              },
            image:            function(url) {
                                    return $.forumprofi.imageUrl + url.replace(/^[\/\\]+/, '');
                              },
            htmlentities:     function(input, type) {
                                    if(typeof input == 'undefined') {
                                          input = '';
                                    }
                                    
                                    if(typeof type != 'number') {
                                          type = 2;
                                    }
                                    
                                    type = Math.max(0, Math.min(3, parseInt(type)));
                                    var html = new Array();
                                    html[38] = '&amp;';
                                    html[60] = '&lt;';
                                    html[62] = '&gt;';
                                    
                                    if(type == 1 || type == 3) {
                                          html[39] = '&#039;';
                                    }
                                    if(type == 2 || type == 3) {
                                          html[34] = '&quot;';
                                    }
                                    for(var i in html) {
                                          eval('input = input.replace(/' + String.fromCharCode(i) + '/g, "' + html[i] + '");');
                                    }
                                    
                                    var entity = new Array('&nbsp;', '&iexcl;', '&cent;', '&pound;', '&curren;', '&yen;', '&brvbar;', '&sect;', '&uml;', '&copy;', '&ordf;', '&laquo;',
                                                           '&not;', '&shy;', '&reg;', '&macr;', '&deg;', '&plusmn;', '&sup2;', '&sup3;', '&acute;', '&micro;', '&para;', '&middot;',
                                                           '&cedil;', '&sup1;', '&ordm;', '&raquo;', '&frac14;', '&frac12;', '&frac34;', '&iquest;', '&Agrave;', '&Aacute;', '&Acirc;',
                                                           '&Atilde;', '&Auml;', '&Aring;', '&AElig;', '&Ccedil;', '&Egrave;', '&Eacute;', '&Ecirc;', '&Euml;', '&Igrave;', '&Iacute;',
                                                           '&Icirc;', '&Iuml;', '&ETH;', '&Ntilde;', '&Ograve;', '&Oacute;', '&Ocirc;', '&Otilde;', '&Ouml;', '&times;', '&Oslash;',
                                                           '&Ugrave;', '&Uacute;', '&Ucirc;', '&Uuml;', '&Yacute;', '&THORN;', '&szlig;', '&agrave;', '&aacute;', '&acirc;', '&atilde;',
                                                           '&auml;', '&aring;', '&aelig;', '&ccedil;', '&egrave;', '&eacute;', '&ecirc;', '&euml;', '&igrave;', '&iacute;', '&icirc;',
                                                           '&iuml;', '&eth;', '&ntilde;', '&ograve;', '&oacute;', '&ocirc;', '&otilde;', '&ouml;', '&divide;', '&oslash;', '&ugrave;',
                                                           '&uacute;', '&ucirc;', '&uuml;', '&yacute;', '&thorn;', '&yuml;');
                                    for(var i in entity) {
                                          eval('input = input.replace(/' + String.fromCharCode(i * 1 + 160) + '/g, "' + entity[i] + '");');
                                    }
                                    
                                    return input;
                              }
      }
});
