/**
 * generate netz98 objects namespace
 */

window._netz98 = {};

/**
 * on document ready, generate js dynamic objects
 */
jQuery(document).ready(function() {

   window._netz98.SocialWidget = new socials('.socials-area');
   window._netz98.SidebarCategories = new Sidebar.Categories('li.widget_nav_menu');
   window._netz98.SidebarLastAuthor = new Sidebar.LastAuthor('ul.last-authors');
   window._netz98.SearchSuggest = new Suggest('#searchform');

   // fix last comments content
   jQuery('#recentcomments li').each(function() {
       var replaceText = jQuery(this).html().replace('bei', ' |&nbsp;');
       jQuery(this)
        .html('')
        .html(replaceText);
   });

   // replace comment forms requiered
   if (jQuery('#commentform').length) {
       jQuery('#commentform p').each(function() {
           if (jQuery(this).children('span.required').length || jQuery(this).find('label').attr('for') == 'comment') {
               jQuery(this)
                    .find('label')
                    .html(jQuery(this).find('label').text() + ' <span>(benötigt)</span>')
                        .siblings('span.required').remove();
           }
       });
   }

   // add custom class to comments form, if user is logged in
   if (jQuery('p.logged-in-as').length) {
       jQuery('#commentform').addClass('logged-in');
   }

});
