function reply(id) {
  (function($) {
  
    $("#parent_id").attr("value", id);
    $("#commentlabel").text("Reply");
    $("#submit").attr("value", 'Submit reply');
    
  })(jQuery);
}

function deleteFromFavourite(id,typ){
    (function($) {
      $.post(baseUrl + '/favourite/delete' ,{"id": id,'typ':typ}, function(response) {
         if(response ==""){
            $('#page-'+id).replaceWith("<div id='deleted' style='background-color:#FFFF00;'>Item was removed</div>");
            setTimeout("hide('deleted')",3250);
         } else {
            alert(response);
         }
      });
   
   })(jQuery);    
}

function hide(text){
   $('#'+text).fadeOut(1000);
}

/*
$(document).ready(function(){
   $('.replyLink').parent().parent().click(function() {
      $("#leaveComment").show().prependTo(this);
      $("#leaveComment textarea").focus();
   });
});
*/
function openArticleGroup(group){
   (function($) {
    $("#group_" + group).slideToggle('slow');   $('.replyLink').parent().parent().click(function() {
      $("#leaveComment").show().prependTo(this);
      $("#leaveComment textarea").focus();
   });
    $("#open_group_" + group).css("display","none");
    $("#close_group_" + group).css("display","inline");

    return true;
    })(jQuery);
}

function closeArticleGroup(group){
   (function($) {
    $("#group_" + group).slideToggle('slow');
    $("#open_group_" + group).css("display","inline");
    $("#close_group_" + group).css("display","none");

    return true;
    })(jQuery);
}

function categoryAjax(link){
   (function($) {
      //$("#ajaximg").replaceWith("<img src='" + baseUrl +"/images/ajax-loader.gif" +"' />");
      $("#ajaximg").html("<img src='" + baseUrl +"/images/ajax-loader.gif" +"' />")
                   .center()
                   .fadeIn("slow");
      $("#articlesList").css({"opacity" : "0.5"})
                        .fadeIn("slow");
      var search = $('#searchValue').val();
      var order = $('#orderValue').val();
      if(search){
         link = link+"&amp;search=" +search;
      }
      if(order) {
         link = link + "&amp;order=" + order;
      }
      $.get(link ,null, function(response) {
         $("#categoryContent").replaceWith(response);         
      });
      
      

  
      return false;
   })(jQuery);
   return false;
}




jQuery.fn.center = function () {
        this.css("position","absolute");
        this.css("top", ( $(window).height() - this.height() ) / 2+$(window).scrollTop() + "px");
        this.css("left", ( $(window).width() - this.width() ) / 2+$(window).scrollLeft() + "px");
        return this;
}



$(document).ready(function() {

  $('.refine_button').live('click', function() {
  
    $("#refine_categories").slideToggle();
  
  });

});






// ADDED by Michal Kobelka 9. 12. 2010
$(document).ready(function () {

  // Show brand new comment form
  $(".leaveNewComment a").click(function() {

    $(".tr_leave").hide();
    $(".tr_form").show();
    
  });

  // Hide brand new comment form
  $("#brandNewCancel").click(function() {

    $(".tr_form").hide()
    $(".tr_leave").show();;

  });

  // Show reply comment form
   $('.replyLink').click(function() {

     $(".commentToolbox").show();   // Show all commentboxes
     $(this).parent().hide();       // Hid current one
     $("#leaveComment").show();     // Show form
     $(this).parent().parent().append($("#leaveComment"));

  });

  // Hide reply form
   $('#replyCancel').click(function() {

     $(".commentToolbox").show();
     $("#leaveComment").hide();

  });

});




// ADDED by Michal Kobelka 23. 5. 2010
// Tabs
function decorateTabs(tabNumber) {
  
  // Order of active tab
  tabNumber = tabNumber + 1;
  
  $(".whiteBackground").removeClass("whiteBackground");
  $(".whiteBackgroundLast").removeClass("whiteBackgroundLast");
  $(".whiteBackgroundBorder").removeClass("whiteBackgroundBorder");
  
  if(tabNumber == 1) {
    
    $(".tabOrder2").addClass("whiteBackground");
    $(".tabOrder3").addClass("whiteBackgroundLast");
    
  } else if(tabNumber == 2) {
    
    $(".tabOrder3").addClass("whiteBackground");
    
  } else if(tabNumber == 3) {
    
    $(".tabOrder2").addClass("whiteBackgroundBorder");
    
  }
  
  
}

