var $j = jQuery.noConflict();

$j(document).ready(function() {
	var loc = window.location.href;

	if(loc.indexOf('#comments') == -1 && loc.indexOf('#respond') == -1) {
		Comments.hide();
	}
	else {
		Comments.show();
	}
	
	$j(".comment_switch").click(function () {
			if(Comments.hidden) {
				Comments.showSmooth();
			}
			else {
				Comments.hideSmooth();
			}
	});
});

var Comments = new function() {
	this.hidden = false;
	
	this.hide = function() {
  	$j('.commentwrapper').hide();
		Comments.setHiddenInformation();
  }
  
   this.show = function() {
    $j('.commentwrapper').show();
		Comments.setVisibleInformation();
  }

	this.hideSmooth = function() {
  	$j('.commentwrapper').hide('fast');
		Comments.setHiddenInformation();
  }
  
   this.showSmooth = function() {
    $j('.commentwrapper').show('fast');
		Comments.setVisibleInformation();
  }
  
  this.setVisibleInformation = function() {
     this.hidden = false;
    $j('.comment_switch').html('Skjul kommentarer');
  }
  
  this.setHiddenInformation = function () {
    this.hidden = true;
  	$j('.comment_switch').html('Vis kommentarer');
  }

}
