var addThis = function() {    
    addthis_language = "no"; 
    addthis_options  = "facebook, twitter, delicious, digg, linkedin, plaxo, more";
    addthis_exclude = "email, print";
     $('a.share').mouseover(
      function(){
          return addthis_open(this, '', '[URL]', '[TITLE]');
      }).mouseout(
      function(){
          addthis_close();
      }).click(
      function(){
          return addthis_sendto();
      });  
}

$(document).ready(function() {

	// Søkeknapp
	$('form#search .input_button').click(function() {$(this).closest("form").submit();})

    // kun aktivt i test...
//    $.getScript("/scripts/status.js", function() {
//        showStatus('teststatus');
//    })

	//hide all desicriptions when page loads
	$(".jQueryExpr .description").hide();
	$(".jQueryFaq .description").hide();

	//EXPRESSIONS
	//toggle the description
	$(".jQueryExpr li a").click(function() {
		$(this).parent().parent().find("li a.selected").not(this).removeClass("selected");	//removes 'selected' class from previous item selected
		$(this).toggleClass("selected");	//toggles 'selected' class on the current clicked link
		$(this).parent().parent().parent().children(".description").toggle();	//toggles the description
		$(this).parent().find(".selected").parent().parent().parent().children(".description").show();	//shows the description if any selected
	});
	//hide description when clicking the close button (image)
	$(".jQueryExpr .description .close").click(function() {
		$(this).parent().parent().parent().hide();
		$(this).parent().parent().parent().parent().find("li a.selected").removeClass("selected");
	});

	//FAQ
	$(".jQueryFaq .faq li a").click(function() {
		$(this).parent().children("div.description").toggle();
		$(this).toggleClass("selected");
	});
	//hide description when clicking the close button (image)
	$(".jQueryFaq .description .close").click(function() {
		$(this).parent().parent().parent().hide();
		$(this).parent().parent().parent().parent().find("a.selected").removeClass("selected");
	});

	//Click-tooltip
	$('.clickme').cluetip({activation: 'click', width: 400});

	$('a.load-local').cluetip({local:true, mouseOutClose: true, activation: 'hover', width: 250, showTitle:false, hoverIntent: {
	    sensitivity:  1,
	    interval:     750,
	    timeout:      750    
	  }
	});
	$('a.load-local-fixed').cluetip({local:true, mouseOutClose: true, activation: 'hover', width: 250, positionBy: 'mouse', showTitle:false, hoverIntent: {
	    sensitivity:  1,
	    interval:     750,
	    timeout:      750    
	  }
	});
	
	$('a.load-local-help').cluetip({local:true, width: 550, showTitle:true});
	$('a.tipafriend').cluetip({local:true, width: 200, showTitle:true});
    $('a.load-remote').cluetip({local:false, width: 400, showTitle:true});

	/* mouseover-effect for rows in tables */
	$(".crosstripeMe tr").mouseover(function() {$(this).addClass("over");}).mouseout(function() {$(this).removeClass("over");});

	/* mouseover-effect for columns in tables */
	$(".crosstripeMe td").mouseover(function() {$(this).addClass("current");}).mouseout(function() {$(this).removeClass("current");});

	/* mouseover-effect for current cell moused over */
	$(".crosstripeMe").columnHover({eachCell:true, hoverClass:'over'});


	/* show-hide leseweb */
	var showLeseweb = getCookie('LESEWEB');
	if(showLeseweb == 'show') {
	  $("#leseweb").removeClass("invisible");
	}

    $(".leseweb").click( function() {
 	  if($("#leseweb").is(':hidden')) {
 	    $("#leseweb").removeClass("invisible");
 	    setCookie('LESEWEB', 'show', null, "/");
 	  }
 	  else {
 	    $("#leseweb").addClass("invisible");
 	    deleteCookie('LESEWEB', "/");
 	  }
    });

    $(".close_leseweb").click( function() {
 	  $("#leseweb").addClass("invisible");
 	  deleteCookie('LESEWEB', "/");
    });

	$.getScript("http://s7.addthis.com/js/250/addthis_widget.js?pub=xa-4a3589ab1d4715d3", addThis);
});

