function addGETParam (qs, key, value) {
  key = escape(key);
  value = escape(value);
  var kvp =  qs.substr(1).split('&');
  var i=kvp.length;
  var x;
  while (i--) {
    x = kvp[i].split('=');
    if (x[0]==key) {
      x[1] = value;
      kvp[i] = x.join('=');
      break;
    }
  }
  if(i<0) {kvp[kvp.length] = [key,value].join('=');}
  return kvp.join('&'); 
}

jQuery(function() {
  
  $("#webarchiv[title]").tooltip({
    tip: '.tooltip',
    effect: 'slide',
    direction: 'left',
    fadeOutSpeed: 100,
    predelay: 200,
    position: "center left",
    offset: [0, 5]
  });
  $("#langmenu a[title]").tooltip({
    tip: '.tooltip',
    effect: 'slide',
    direction: 'right',
    fadeOutSpeed: 100,
    predelay: 200,
    position: "center right",
    offset: [0, 0]
  });  

  $("a[title]").tooltip({
    tip: '.tooltip',
    effect: 'slide',
    direction: 'down',
    fadeOutSpeed: 100,
    predelay: 200,
    position: "bottom center",
    offset: [-5, 0]
  });
  
  $("a.lightbox, a.thickbox").fancybox({
    'transitionIn': 'elastic',
    'transitionOut': 'elastic',
    'speedIn': 400, 
    'speedOut': 300, 
    'overlayShow': true,
    'overlayOpacity': 0.6,
    'overlayColor': '#fff',
    'titlePosition': 'over',
    'centerOnScroll': true
  });
  
  $("a.lightframe").click(function() {
    $.fancybox({
      'href': $(this).attr('href') + '?template=content',
      'type': 'iframe',
      'width': '75%',
      'height': '95%',
      'padding': '15px',
      'autoScale': false,
      'transitionIn': 'elastic',
      'transitionOut': 'elastic',
      'speedIn': 400,
      'speedOut': 300,
      'overlayShow': true,
      'overlayOpacity': 0.6,
      'overlayColor': '#fff',
      'centerOnScroll': true
    });
    return false;
  });
  
  $("#webarchiv").click(function() {
    $.fancybox({
      'href': $(this).attr('href'),
      'type': 'iframe',
      'width': 600,
      'height': 420,      
      'autoScale': false,
      'transitionIn': 'elastic',
      'transitionOut': 'elastic',
      'speedIn': 400,
      'speedOut': 300,
      'overlayShow': true,
      'overlayOpacity': 0.6,
      'overlayColor': '#fff',
      'centerOnScroll': true
    });
    return false;
  });
  
  $("#errorbox").hide();
  $("#errorbox").each (function() {
    $.fancybox(
      $("#errorbox").html(), {
        "autoScale": true,
        "transitionIn": "none",
        "transitionOut": "none",
        "speedIn": 400, 
        "speedOut": 300, 
        "overlayShow": true,
        "overlayOpacity": 0.6,
        "overlayColor": "#fff",
        "centerOnScroll": true
      }
    );
  });

  //$(".toggler-content").hide();
  $(".toggler").each(function() {
    if (!$(this).hasClass('active')) {
      $( '#' + $(this).attr('id') + "-content").hide('fast');
    }
  }).click(function() {
    if (!$(this).hasClass('active')) {
      $(".toggler").removeClass('active');      
      $(".toggler-content").hide('fast');
    }
    $( '#' + $(this).attr('id') + "-content").toggle('fast');
    $(this).toggleClass('active');
    return false;
  });

});



