// 27.05.2008 - vyhodeny ifixpng - vpolak
/* Setup global settings for AJAX requests for selected URL */
jQuery.ajaxSetup({
  url: "/@ajax.php/",
  type: "POST",
  async: true,
  timeout: 30000,
  error: function (XMLHttpRequest, textStatus, errorThrown) {
     //alert(XMLHttpRequest+' - '+textStatus+' - '+errorThrown);
     if (textStatus == "timeout")
     {
        alert("We are sorry but there was a problem. Please try again in a few minutes.");
     }
     /*else
     {
        alert(textStatus);
    }*/
  }
});

/* Show Message Callback */
function showMsg(data, place) {

   $('#comment'+place).html(data);
   
   $('.comment').removeClass('db');
   
   $('#comment'+place).addClass('db');
   
   $('#msgCont'+place).addClass('on');
   
   $('#comment'+place).show();
    
//   $('.delete-message .fixpng').ifixpng();
	
}

/* Dummy function used if third param of doAjax id set on NULL */
function dummy() {
   return 'dummy function';
}

function rusure(){
 var v = confirm ("Are your sure?");
 if (v) return true;
 return false;
}

function msgToFriendSent(data, place) {

    var elem = document.createElement( 'DIV' );
   
    $(elem).append(data);

    var isError;

    $(elem).find('.error-msg').each(function(){

        isError = 1;
    });

    if (!isError)
    {
        $(place).fadeOut();
        //$('#friend-message').val("Your message...");
        //$('#emails').val("E-mail addresses");
        refreshInvitationForm();
    }
    
    
   $('#msgToFriend').show();
   $('#msgToFriend').html(data);
   //$('#msgToFriend .default-msg').ifixpng();
   hideMsg('#msgToFriend');

}

/* Add Tags Callback */
function addTags(data, place)
{
   $('#browse-by-tags').html(data);
   $('#browse-by-tags .default-msg').ifixpng();
   $(place).fadeOut('slow');
   setTimeout("$('#browse-by-tags .default-msg').fadeOut('slow')", 2000);
}


/* Message after deleting the User Message */
function msgDel(data, place)
{
    var err = data[0];
    
    if (err == 'deleteOne')
    {
        // Ok
        
        var deletedId    = data[1]
        var nextMessages = data[2];
        var noNew        = data[3];
        var noTotal      = data[4];
        var paging       = data[5];
        var offset       = data[6];



                    var el = '#msgCont'+deletedId;
                    
                    // Fade out and remove upon completion of fade
                    $(el).fadeOut('slow', function(){$(el).remove()
            
                        // Place the next messages
                        $(place).append(nextMessages);
                        
                    });
                    
                
                
                // Update number of "new" messages
                $('#noMessages,#noMessagesHead').html(noNew.toString());
                
                // Update total number of messages
                $('#noMessagesTotal').html(noTotal.toString());
                
                // Update paging
                $('#messages .paging').replaceWith(paging);


                // Update offset
                $('#messages_offset').val(offset);






    }
    else
    {
        alert('Could not delete this message.   Please try again later.');
    }

/*
$(place).fadeOut("normal", function(){
    $(place).html(data);
    $(place).slideDown('normal');
    hideMsg('#delMessage');
});
*/
/*
   var child;
   var elem = document.createElement( 'DIV' );

   $(elem).append(data);

   var innerDivs = elem.getElementsByTagName("div");
   
   for (var i=0; i <= (innerDivs.length-1); i++)
    {
      if(innerDivs[i].className.match(/default\-msg/i)) {
         
         $('#delMessage').append(innerDivs[i]);
         $('.msg-placeholder .fixpng').ifixpng();
         hideMsg('#delMessage');
      }
	}
	$('#my-glog-messages').html(elem);
*/
}

/* Message Reply Callback */
function msgSent(data, place) {

   $('#comment'+place).removeClass('db');
   $('#msgCont'+place).removeClass('on');
   $('#comment'+place).html('');

   $('#sentMessage'+place).html(data);
   $('#sentMessage'+place).show();
   //$('.msg-placeholder .fixpng').ifixpng();
   hideMsg('#sentMessage'+place);
}

/* Send message to user Callback */
function msgFormSent(data, place) {

    $('#commentform').hide('slow',function(){

    $(place).html(data);
    
    //$('.msg-placeholder .fixpng').ifixpng();
    
    $(place).fadeIn('slow', function(){ hideMsg(place); });
   
    
   
    //jQuery('#message-has-been-sent').animate( {opacity: 1.0}, 2000).fadeOut('slow');
   });
}


/* Add/Remove blog to/from Favourities Callback */
function favOperation(data, place)
{
    var elem = document.createElement( 'DIV' );
   
    $(elem).append(data);

    var op = $(elem).find('li');

    $('#favMsg').empty();

    $(elem).find('.default-msg').each(function () {
        $('#favMsg').append(this);
        //hideMsg(this);
    });
    
    $('#favMsg').fadeIn('fast');
    hideMsg('#favMsg');

    $(place).replaceWith($(op));



/*

   var child;
   var elem = document.createElement( 'DIV' );
   $(elem).append(data);

   var innerDivs = elem.getElementsByTagName("div");

   for (var i=0; i <= (innerDivs.length-1); i++)
	{
      if(innerDivs[i].className.match(/fav\-anchors/i)) {
        $('#'+place+' #fav-placeholder').html(innerDivs[i].innerHTML);
        elem.removeChild(innerDivs[i]);
      }
      if(innerDivs[i].className.match(/default\-msg/i)) {

         $('#favMsg').html(elem.innerHTML);
         $('.msg-placeholder .fixpng').ifixpng();
         hideMsg('#favMsg');
      }
	}
   $('#add-to-favs .fixpng').ifixpng();
*/
}



function alertFrOperation(data, place) {

$('#alert-friend-msg').show();
   $('#alert-friend-msg').html(data);
   //$('#alert-friend-msg .fixpng').ifixpng();
   hideMsg('#alert-friend-msg');
}

/* Blog Rating Callback */
function rated(data, place)
{
    $(place).replaceWith(data);
    $(place).find($('.default-msg')).each(function(){hideMsg(this);});
    return;
    //$(place)

    //alert(place);
   var child;
   var elem = document.createElement( 'DIV' );
   $(elem).append(data);

   var innerDivs = elem.getElementsByTagName("div");

   for (var i=0; i <= (innerDivs.length-1); i++)
	{
      if(innerDivs[i].className.match(/default\-msg/i)) {
         $('#rating-msg'+place).html(innerDivs[i].innerHTML);
         elem.removeChild(innerDivs[i]);
      }
	}

    $('#rate-the-glog'+place).html(data);
    //$('#rate-the-glog'+place+' .default-msg').ifixpng();
   setTimeout("$('#rate-the-glog"+place+" .default-msg').hide()", 3000);
    
   /*$('#rate-the-glog').html(data);
   $('#rate-the-glog .default-msg').ifixpng();
   setTimeout("$('#rate-the-glog .default-msg').hide()", 3000);*/
}


/* Send Blog Comment Callback */
function sendComment(data, place){

$(place).fadeOut("normal", function(){
    $(place).html(data);
    
    $(place).fadeIn('slow', function() {
    
    $(place).find('.default-msg').each(function () {
    
    hideMsg(this);
    
    });
    
    //hideMsg('#message-has-been-sent')
    });
});




/*
alert(data);
   var child;
   var elem = document.createElement( 'DIV' );

   $(elem).append(data);

   var innerDivs = elem.getElementsByTagName("div");

//get messages from data
   for (var i=0; i <= (innerDivs.length-1); i++)
	{

      if(innerDivs[i].className.match(/default\-msg/i)) {
         $('#sendCommentMsg').html(innerDivs[i]);
         $('.msg-placeholder .fixpng').ifixpng();
         hideMsg('#sendCommentMsg');
      }
      
	}

	//insert remaining parts to place
	 $('#comments-placeholder').html(elem);
  	*/
    
    
    $('#commentform textarea').val($('#commentform textarea').attrib('rel'));
}


function deleteGlogComment(data, place)
{
    pagerOper(data, place);
}


/* Messages Pager Callback */
function pagerOper(data, place) {
   $('#'+place).html(data);
}


/* Hide message */
function hideMsg(place)
{
    // Fade after delay
    $(place).animate( {opacity: 1.0}, 2000).fadeOut('slow');
}

/* Same as hideMsg but also removes the element afterwards */
function removeMsg(place)
{
    // Fade after delay
    $(place).animate( {opacity: 1.0}, 2000).fadeOut('slow', function(){$(place).remove()});
}


function dfAjaxopenSure(t){
 if (rusure()) return dfAjaxopen(t);
 return false;
}
/*
dfAjaxopen - hack for <a href...> to call URL
*/

function dfAjaxopen(t){
 var aurl=t.href;
 //alert(aurl);
 try {
 $.ajax({url: aurl+'&isajax=1', data:aurl, dataType: 'html', success: function(data){alert(data);}});
 } catch(err) { document.location.href=aurl; return true; }
 return false;
}

function doAjax(sentdata, callback, place, dataType) {

    dataType = typeof(dataType) == "undefined" ? 'html' : dataType;
    
	var loader = jQuery('<div class="ajax-loader"><img src="/images/loading.gif" alt="loading..." /></div>')
		.hide()
		.appendTo("#ajax-loader"+place);

	jQuery().ajaxStart(function() {
		loader.show();
	}).ajaxStop(function() {
		$("#ajax-loader"+place).html('');
	});

   // If form object is passed to var sentdata
   if(typeof(sentdata) == 'object') {
   
   
       var dataforscript = '';

       jQuery.each(sentdata, function() {

          if(this.type == 'checkbox' || this.type == 'radio') {
            if(this.checked == true) dataforscript += this.name+'='+encodeURIComponent(this.value)+'&'; //send just checked
          } else {
            dataforscript += this.name+'='+encodeURIComponent(this.value)+'&';
          }

       });
    } else {
    // If string is sent
      dataforscript = sentdata;
    }
    
   $.ajax({
      url: '/@ajax.php',
      data: dataforscript,
      dataType: dataType,
      success:  function(data){
        callback(data, place);
      }
   });
}

function doAjax_initMessages(sentdata, cb_ok, cb_fail)
{
   $.ajax({
      url: '/@ajax.php',
      data: sentdata,
      dataType: 'json',
      success:  function(data){
        cb_ok(data);
      },
      error: function (XMLHttpRequest, textStatus, errorThrown) {
        cb_fail(XMLHttpRequest, textStatus, errorThrown);
      }
   });
}


function gloggerOver( object, id_num) {

    if (object.className == 'friend')          { $(object).addClass('friend over friend-no-'+id_num); }
    else if (object.className == 'friend new') { $(object).addClass('friend new over friend-no-'+id_num); }
    else                                       { $(object).addClass('friend friend-no-'+id_num); }
    
   
}

function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });
    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

    jQuery('#mycarousel-next').bind('click', function() {
        //carousel.next();
        origScroll = carousel.options.scroll;
        carousel.options.scroll = 3;
        carousel.next();
        carousel.options.scroll = origScroll;
        return false;
    });

};

$(document).ready(function(){
    $("#menu-search").click(function(){
        $("#search-spot").slideDown();
        }
    );
    $("#sort-by").click(function(){
        $("#sort-by-options").toggle('fast');
        }
    );

   /* Set this just where needed; Now it is used only on HP */
   if ($("#scroller").length > 0)
   {
    jQuery('#scroller').jcarousel({
        auto: 3,
        scroll : 1,
        wrap: 'last',
        initCallback: mycarousel_initCallback
    });
    }

   //$.ifixpng('/images/blank.gif');
   //$('.fixpng').ifixpng();
   //$('#home .error-msg').ifixpng();
   //$('#home #content').ifixpng();
   //$('#useraccount .error-msg').ifixpng();
   //$('#useraccount .ok-msg').ifixpng();
   
    $("#notices span").click(function(){
    
        $('#notices').hide(0);
    });
    
    hideMsg('#notices');

});





/*
function response(response) {
   html = createElement('DIV').innnerHTML(response);
   foreach(key in html) {
      child = html[ key ];
      error = (child.style = 'default-msg');
      if(error) {
         error_placeholder.appendChild(child);
         html.removeChild(child);
      }
   }
   ok_placeholder.appendChild(html);
}
*/

/*

// this was Depreciated

   for(var key in elem) {

      child = elem[key];

      if(typeof (child)=='object') {

         if(child instanceof HTMLDivElement) {

            if(child.className.match(/error\-msg/i)) {
               $('#delMessage'+place).html(data);
               $('.msg-placeholder .fixpng').ifixpng();

            }
         }


      }

   }
*/

function showFriendContactForm(id, name, avatar)
{
    $('#commentform').fadeOut('slow', function(){
        $("#commentform_avatar").attr('src', avatar); 
        $("#comment_form_user_id").attr('value', id); 
        $("#commentform_header").html("Message to: <strong>"+name+"</strong>");
        $("#comment").attr('value', 'Enter text...');
        
        $('#commentform').unbind();
        //$('#commentform').bind('submit', function(){
        //$('#commentform').attr('submit', 'doAjax(this, msgFormSent, \'#sentFormMessage\''+id+'); return false;');
        $('#commentform').bind('submit', function(){
            doAjax(this, msgFormSent, '#sentFormMessage'+id, 'html'); 
            return false;
        });
        
        $('#commentform').fadeIn('slow');
});

}


function showStudentChangePasswordForm(id, name, avatar)
{
    $('#studentChangePasswordForm').fadeOut('slow', function(){
        $("#studentChangePasswordForm_avatar").attr('src', avatar); 
        $("#studentChangePasswordForm_user_id").attr('value', id); 
        $("#studentChangePasswordForm_password").attr('value', ""); 
        $("#studentChangePasswordForm_confirmation").attr('value', ""); 
        $("#studentChangePasswordForm_header").html("Change password for: <strong>"+name+"</strong>");
        
        $('#studentChangePasswordForm').fadeIn('slow');


    });

}

function showDeleteStudentForm(id, name, avatar)
{
    $('#deleteStudentForm').fadeOut('slow', function(){
        $("#deleteStudentForm_avatar").attr('src', avatar); 
        $("#deleteStudentForm_user_id").attr('value', id); 
        $("#deleteStudentForm_name").html(name);
        
        $('#deleteStudentForm').fadeIn('slow');


    });

}

    
    function messagePopupBlacklistConfirmation(data, place)
    {
        // Check the box isn't already displayed
        var is = $(place).find('.areyousure');
        
        if (is.length == 0)
        {
            $(place).prepend(data);
        }
        
    }

    function domessages(data, place)
    {
        if (typeof(data) == 'object')
        {
            if (data[0] == 'delete')
            {
        
                var toDelete     = data[1];
                var nextMessages = data[2];
                var noDeleted    = data[3];
                var noNew        = data[4];
                var paging       = data[5];
                var offset       = data[6];
                var noTotal      = data[7];
                var notices      = data[8];
                
                var i = 0;
                
                for (key in toDelete)
                {
                    var el = '#msgCont'+toDelete[key];
                    
                    // Fade out and remove upon completion of fade
                    $(el).fadeOut('slow', function(){
                    
                        $(this).remove()
                    
                        i++;
                        
                        // See if we have just removed the last one
                        if (i == noDeleted)
                        {
                            // Yes, so place the next messages
                            $(place).append(nextMessages);
                            
                            
                            // Reset checkall box
                            //$('#checkall').attr('checked','');
                            setCheckall('');
                        }
                    
                    });
                    
                }
                
                // Display notice
                $('#messages').prepend(notices);
                
                $('#messages .default-msg').each(function(){
                    $(this).animate( {opacity: 1.0}, 2000).fadeOut('slow', function(){$(this).remove()});
                });
                
                // Update number of "new" messages
                $('#noMessages,#noMessagesHead').html(noNew.toString());
                
                // Update total number of messages
                $('#noMessagesTotal').html(noTotal.toString());
                
                // Update paging
                $('#messages .paging').replaceWith(paging);
                
                // Update offset
                $('#messages_offset').val(offset);
            }
            else if (data[0] == 'mark')
            {
                // Mark
                
                var toMark  = data[1];
                var notices = data[2];
                
                var i = 0;
                
                for (key in toMark)
                {
                    var el = '#newmessage' + toMark[key];
                    
                    // Fade out and remove upon completion of fade
                    $(el).fadeOut('slow', function(){
                        $(el).remove()
                        
                    });
                    
                    i++;
                }
                
                // Display notice
                $('#messages').prepend(notices);
                
                $('#messages .default-msg').each(function(){
                    $(this).animate( {opacity: 1.0}, 2000).fadeOut('slow', function(){$(this).remove()});
                });
                
                reduceNumberBy('#noMessages', i)
                
                setCheckall('');
                
                messagesSelectAll();
            }
            else if (data[0] == 'reply')
            {
                var result      = data[1];  // Result
                var notices     = data[2];  // HTML notice containing the result of the action
                var openMessage = data[3];  // ID of the message to which the user replied

                // If message sent ok, then close popup
                if (result == 'ok')
                {
                    $('#comment'+openMessage).fadeOut('slow', function(){
                        $('#comment'+openMessage).empty();
                    });
                }

                // Display notice
                $('#messages').prepend(notices);
                
                $('#messages .default-msg').each(function(){
                    $(this).animate( {opacity: 1.0}, 2000).fadeOut('slow', function(){$(this).remove()});
                });
            }
            else if (data[0] == 'blacklist')
            {
                var result      = data[1];
                var openMessage = data[2];
                var notices     = data[3];
                var blacklistedFriend = data[4];
                
                // See if blacklisted ok
                if (result == 'ok')
                {
                    // Blacklisted ok
                    
                    // See if a friend was blacklisted, in which case we must 
                    if (blacklistedFriend != undefined)
                    {
                        $('#my-friends-'+blacklistedFriend).fadeOut('slow', function(){
                            
                            // Remove the block
                            $('#my-friends-'+blacklistedFriend).remove();
                            
                            // Reduce number of friends
                            reduceNumber('#number-of-friends');
                        });
                    }
                    
                    // Close message popup
                    $('#comment'+openMessage).fadeOut('slow', function(){
                        $('#comment'+openMessage).empty();
                    });
                }
                
                // Display notice
                $('#messages').prepend(notices);
                
                $('#messages .default-msg').each(function(){
                    $(this).animate( {opacity: 1.0}, 2000).fadeOut('slow', function(){$(this).remove()});
                });
            }
            else
            {
                // Error: Display notice
                var notices = data[0];
                
                $('#messages').prepend(notices);
                
                $('#messages .default-msg').each(function(){
                    $(this).animate( {opacity: 1.0}, 2000).fadeOut('slow', function(){$(this).remove()});
                });
            }
        }
        else
        {
            // Nothing done
            //alert('Nothing done.');
            //alert(data);
        }
    }
    
    function setCheckall(val)
    {
        $('#checkall').attr('checked', val);
        $('#checkall_bottom').attr('checked', val);
        
    }

    function messageSelect()
    {
        // Find all checkboxes
        
        var noChecked=0;
        var noCheckboxes=0;
        
        //$('#message_block .messageSelector:checked').each(function(){
        $('#message_block .messageSelector').each(function(){
        
            if ( this.checked == true)
            {
                noChecked++;
            }
            
            noCheckboxes++;
        });
    
        // See if all boxes are selected
        if (noCheckboxes == noChecked)
        {
            if (!$('#checkall').attr('checked'))
            {
                //$('#checkall').attr('checked','checked');
                setCheckall('checked');
            }
        }
        else
        {
            if ($('#checkall').attr('checked'))
            {
                //$('#checkall').attr('checked','');
                setCheckall('');
            }
        }
    }
    
    function messagesSelectAll()
    {
        if ($('#checkall').attr('checked'))
        {
            $('#message_block .messageSelector').each(function(){
            
                if (this.checked != true)
                {
                    this.checked = true;
                }
            
            });
        }
        else
        {
            $('#message_block .messageSelector').each(function(){
            
                if (this.checked == true)
                {
                    this.checked = false;
                }
            
            });
        }
    }

    function messagesDraw(data, place)
    {
        // Get messages
        var messages = data[0];
    
        // Place new messages
        $('#messages').replaceWith(messages);
        
    }

    function messagesPaging(data, place)
    {
        // Get messages
        var messages = data[0];
        
        // Get paging
        var paging = data[1];
        
        // Get oggset
        var offset = data[2];
    
        // Remove existing messages
        var noMessages = $('#message_block .msg').length;
        var i=0;
        
        $('#message_block .msg').each(function(){
            $(this).fadeOut('slow', function(){$(this).remove()
            
                i++;
                
                // See if we are fading the last one
                if (i == noMessages)
                {
                    // Place new messages
                    $(place).html(messages);
                    
                    // Place paging
                    $('#messages .paging').replaceWith(paging);
                    
                    // Update offset
                    $('#messages_offset').val(offset);
                }
            
            });
        
        });
        
    }
    
    function blacklisted(data, place)
    {
        // Get notices
        var notices = data[0];
        
        // Get blacklisting result
        var result = data[1];
        
        // Get blacklisted user id
        var bluser_id = data[2];
    
    
        // Display notices
        $('#messages').prepend(notices);

        // Find all notices and remove them
        $('#messages').find('.default-msg').each(function(){
            
            // Fade out and remove upon completion of fade
            $(this).animate( {opacity: 1.0}, 2000).fadeOut('slow', function(){$(this).remove()});
        
            // Hide the message box
            $(place).removeClass('db');
            $(place).parent().parent().parent().parent().removeClass('on');
        });
        
        // See if a user was blacklisted
        if (result == 'ok')
        {
            // User was blacklisted, so remove friend block (if it exists)
            $('#my-friends-'+bluser_id).fadeOut('slow', function(){
                
                // Remove the block
                $('#my-friends-'+bluser_id).remove();
                
                // Reduce number of friends
                reduceNumber('#number-of-friends');
            });
        }
        
    }

/**
 * Takes the contents of the element specifid, converts it to a number, reduces the number by one and replaces the contents with this new number
 *
 * @param string Handle to element, e.g. "#myNumber"
 * @author Nick Giles <nicholas.giles@wdf.cz>
 */
    function reduceNumber(container, headMessages)
    {
        var val = '';
        var num = 0;
        
        // Get the element contents
        if (val = $(container).text())
        {
            // Check control
            num = parseInt(val);
            
            num--;
            
            if (num < 0) num=0;
            
            $(container).text(num.toString());
            
            if (typeof(headMessages) != "undefined")
            {
                // Also reduce the number in the header
                //$('#noMessagesHead').text(num.toString());
                $('#user-messages strong').text(num.toString());
                $('#user-messages a').attr('title', num.toString());
            }
            
        }
    }


/**
 * Reduces the number in the element specified by the amount specified
 *
 * @param string Handle to element, e.g. "#myNumber"
 * @param integer Amount to reduce by
 * @author Nick Giles <nicholas.giles@wdf.cz>
 */
    function reduceNumberBy(container, no)
    {
        var val = '';
        var num = 0;
        
        // Get the element contents
        if (val = $(container).text())
        {
            // Convert numbers to integers
            val = parseInt(val);
            no = parseInt(no);
            
            // Reduce number
            num = val - no;
            
            if (num < 0) num=0;
            
            $(container).text(num.toString());

            // Also reduce the number in the header
            //$('#noMessagesHead').text(num.toString());
            $('#user-messages strong').text(num.toString());
            $('#user-messages a').attr('title', num.toString());
        }
    }
    
    function messagesFail(XMLHttpRequest, textStatus, errorThrown)
    {
        $('#messagesLoader_loading').fadeOut('normal', function(){
        
            $('#messagesLoader_fail').fadeIn();
        
        });
    }
    
    function countMessageElements()
    {
        var z=0;
        
        $('#message_block .msg').each(function(){
            z++;
        });
        
        $('#messages_onPage').val(z);
    
    }

    function makeCopyButton(button, source)
    {
        var url="/images/swf/CopyClipBoard.swf";
           
        var so = new SWFObject(url , "copy", "57", "20", "8", "#FFFFFF");
        
        so.addParam('wmode', 'transparent');
        
        so.addVariable("ct",escape($('#'+source).val()));
        
        so.write(button);
    }
    
    $(document).ready(function(){
        $(".copybutton").each(function(){
            makeCopyButton($(this).attr('id'), $(this).attr("rel"));
        });
    });


    function redrawProfileComments(data, place)
    {
    
        var obj = new Object(data);
        
        $(place).html(obj.html);
        
        profileCommentsDeleteButtons();
        profileCommentsBlockButtons();

        if (obj.notices)
        {
            $('#profileCommentsNotices').show();
            $('#profileCommentsNotices').html(obj.notices);
            
//    $(place).animate( {opacity: 1.0}, 2000).fadeOut('slow');
            $('#profileCommentsNotices').animate( {opacity: 1.0}, 2000).fadeOut('slow', function(){$('#profileCommentsNotices').empty()});
        }
    }
    
    function profileCommentsBlockButtons()
    {
        $(".profileCommentsBlock").each(function(){
            $(this).click(function(){
                doAjax('&show=profile_comments&action=profile_communicate_block&user_id='+$("#profileCommentsForm :hidden[name=user_id]").val()+'&block_id='+$(this).attr("rel"), redrawProfileComments, '#commentsContainer', 'json');
                return false;
            });
        });
    }

    function profileCommentsDeleteButtons()
    {
        $(".profileCommentsDelete").each(function(){
            $(this).click(function(){
                doAjax('&show=profile_comments&action=profile_communicate_delete&user_id='+$("#profileCommentsForm :hidden[name=user_id]").val()+'&comment_id='+$(this).attr("rel"), redrawProfileComments, '#commentsContainer', 'json');
                return false;
            });
        });
    }
