var language='de';
var theme='roteberge';
var $j = jQuery.noConflict();

function social_bookmark_url(which) {
  var link = encodeURIComponent(location.href);
  var title = encodeURIComponent(document.title);
  switch(which) {
    case "wong": return 'http://www.mister-wong.de/index.php?action=addurl&bm_url='+link+'&bm_notice=&bm_description='+title+'&bm_tags='; break;
    case "delicious": return 'http://del.icio.us/post?v=2&url='+link+'&notes=&tags=&title='+title; break;
    case "jigg": return 'http://yigg.de/neu?exturl='+link; break;
    case "digg": return 'http://digg.com/submit?phase=2&url='+link+'&bodytext=&tags=&title='+title; break;
    case "yahoo": return 'http://myweb2.search.yahoo.com/myresults/bookmarklet?t='+title+'&d=&tag=&u='+link; break;
    case "google": return 'http://www.google.com/bookmarks/mark?op=add&hl=de&bkmk='+link+'&annotation=&labels=&title='+title; break;
    case "technorati": return 'http://technorati.com/faves?add='+link+'&tag='; break;
  }
  return false;
}

String.prototype.getanchor = function() {
  if (this.indexOf('#') > -1) {
    return this.substr(this.indexOf('#')+1);
  }
  return '';
}

function togglediv() {
  if ($j(this).hasClass('more')) {
    $j('div#'+$j(this).attr('href').getanchor()).removeClass('closed');
    $j('a.fewer[href$="#'+$j(this).attr('href').getanchor()+'"]').show();
    $j(this).hide();
  } else {
    $j('div#'+$j(this).attr('href').getanchor()).addClass('closed');
    $j('a.more[href$="#'+$j(this).attr('href').getanchor()+'"]').show();
    $j(this).hide();
  }
  return false;
}

$j(document).ready(function() {
  $j('a[rel="vidbox"]').click(function() {
    $j.post('/php/tools/getcounter.php', {videolink:$j(this).attr('href')}, function() {});
    return true;
  });
  $j('a[rel="external"]').click(function() {
    window.open($j(this).attr('href'));
    return false;
  });
  $j('a.zoom').lightbox({
    fileLoadingImage : '/img/'+theme+'/lb-loading.gif',
    fileBottomNavCloseImage : '/img/'+theme+'/lb-close.gif',
    strings : {
      help: ' \u2190 / P - vorheriges Bild\u00a0\u00a0\u00a0\u00a0\u2192 / N - nächstes Bild\u00a0\u00a0\u00a0\u00a0ESC / X - schließen',
      prevLinkTitle: 'vorheriges Bild',
      nextLinkTitle: 'nächstes Bild',
      prevLinkText:  '&laquo; zurück',
      nextLinkText:  'weiter &raquo;',
      closeTitle: 'schließen',
      image: 'Bild ',
      of: ' von '
    }
  });
  $j('a[rel="bookmark"]').click(function() {
    var link = social_bookmark_url($j(this).attr('class'));
    if (link) {
      window.open(link);
      return false;
    }
  });
  $j('form[method="get"].external').submit(function() {
    window.open($j(this).attr("action")+'?'+$j(this).serialize());
    return false;
  });
  $j('div.togglesize').each(function() {
    $j('a.more[href$="'+$j(this).attr('id')+'"]').click(togglediv).show();
    $j('a.fewer[href$="'+$j(this).attr('id')+'"]').click(togglediv).hide()
  });
});