$(document).ready( function() {
  //hides all the toggle boxes
  $('.togglebox').hide();

  //Finds the link that you push, and triggers the click functions
  $('ul.interactive').find('a').click(function() {
    //$('.toggle_container').height(scrollLength);

    //collecting some needed variables

/*	finds the href attribute of the <a> element you click
    and substract it, from '#something' to 'something'		*/
    var href = $(this).attr('href').substr(1);

/*	$path1/$path2 is used to check if the box is open or not
    if a box is open, we dont want it to reopen when we click
    on the same link again		*/

    //have to do a check to examine if the comment functionality is open or not
    var $path1 = $(this).parents('.interactive_container').find('div.togglebox.'+href);
    if ($path1.length > 0) {
      var $path2 = $path1.attr('class').split(' ');
    } else {
      alert('Kommentering av denne artikkelen er ikke tilgjengelig!');
      return false;
    }

    //removes any divs with the class .expanded, so we cant open multiple divs
    $('div.togglebox').hide().removeClass('expanded');

    //If the link we push isnt the same as the one we got open
    if($path2[2] !== 'expanded') {
      //show the box, and add class '.expanded'
       $('div.togglebox.'+href).show().addClass('expanded');
     };

     //sets the options for the scroll effect
    /*var scrollOptions = {
      axis: 'y', 			//we only want it to scroll on the y axis
      duration: 1500, 	//the duration of the scroll effect, 1000 = 1 sec
      easing: 'swing'		//animation type
    };*/

    //scrolls to the bottom
    /*$.scrollTo('99999', scrollOptions );*/

    //return false, so the link wont activate
    return false;
  });
});
