	/*
 * jQuery Carousel Plugin v1.0
 * http://richardscarrott.co.uk/posts/view/jquery-carousel-plugin
 *
 * Copyright (c) 2010 Richard Scarrott
 *
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 * Requires jQuery v1.3+
 *
 */


// alert($().jquery);

// Also returns string Ex: "1.3.1"
// alert(jQuery.fn.jquery);

jQuery(document).ready(function($){


  // prototypal inheritance
  if (typeof Object.create !== 'function') {
    Object.create = function (o) {
      function F() {}
      F.prototype = o;
      return new F();
    };
  }


(function($) {
// ie alias
var headache = $.browser.msie && $.browser.version.substr(0,1)<9;

// carousel
var Carousel = {
settings: {
itemsPerPage: 1,
itemsPerTransition: 1,
noOfRows: 1,
pagination: true,
nextPrevLinks: true,
speed: 'normal',
easing: 'swing'
},
init: function(el, options) {
if (!el.length) {return false;}
this.options = $.extend({}, this.settings, options);
this.itemIndex = 0;
this.container = el;
this.runner = this.container.find('ul');
this.items = this.runner.children('li');
this.noOfItems = this.items.length;
this.setRunnerWidth();
if (this.noOfItems <= this.options.itemsPerPage) {return false;} // bail if there are too few items to paginate
this.insertMask();
this.noOfPages = Math.ceil((this.noOfItems - this.options.itemsPerPage) / this.options.itemsPerTransition) + 1;
if (this.options.pagination) {this.insertPagination();}
if (this.options.nextPrevLinks) {this.insertNextPrevLinks();}
this.updateBtnStyles();
},
insertMask: function() {
this.runner.wrap('<div class="mask" />');
this.mask = this.container.find('div.mask');

// set mask height so items can be of varying height
var maskHeight = this.runner.outerHeight(true);
this.mask = this.container.find('div.mask');
this.mask.height(maskHeight);
},
setRunnerWidth: function() {
this.noOfItems = Math.round(this.noOfItems / this.options.noOfRows);
var width = this.items.outerWidth(true) * this.noOfItems;
this.runner.width(width);
},
insertPagination: function() {
var i, links = [];
this.paginationLinks = $('<ol class="pagination-links" />');
for (i = 0; i < this.noOfPages; i++) {
links[i] = '<li><a href="#item-' + i + '">' + (i + 1) + '</a></li>';
}
this.paginationLinks
.append(links.join(''))
.appendTo(this.container)
.find('a')
.bind('click.carousel', $.proxy(this, 'paginationHandler'));
},
paginationHandler: function(e) {
this.itemIndex = e.target.hash.substr(1).split('-')[1] * this.options.itemsPerTransition;
this.animate();
return false;
},
insertNextPrevLinks: function() {
this.prevLink = $('<a href="#" class="prev_ask"><</a>').bind('click.carousel', $.proxy(this, 'prevItem')).prependTo(this.container);
this.nextLink = $('<a href="#" class="next_ask">></a>').bind('click.carousel', $.proxy(this, 'nextItem')).appendTo(this.container);
},
nextItem: function() {
this.itemIndex = this.itemIndex + this.options.itemsPerTransition;
this.animate();
return false;
},
prevItem: function() {
this.itemIndex = this.itemIndex - this.options.itemsPerTransition;
this.animate();
return false;
},
updateBtnStyles: function() {
      return false;
if (this.options.pagination) {
this.paginationLinks
.children('li')
.removeClass('current')
.eq(Math.ceil(this.itemIndex / this.options.itemsPerTransition))
.addClass('current');
}

if (this.options.nextPrevLinks) {
this.nextLink
.add(this.prevLink)
.removeClass('disabled');
if (this.itemIndex === (this.noOfItems - this.options.itemsPerPage)) {
this.nextLink.addClass('disabled');
}
else if (this.itemIndex === 0) {
this.prevLink.addClass('disabled');
}
}
},
animate: function() {
var nextItem, pos;
// check whether there are enough items to animate to
if (this.itemIndex > (this.noOfItems - this.options.itemsPerPage)) {
        this.itemIndex = 0;
// this.itemIndex = this.noOfItems - this.options.itemsPerPage; // go to last panel - items per transition
}
if (this.itemIndex < 0) {
this.itemIndex = this.noOfItems - this.options.itemsPerPage; // go to last panel - items per transition
// this.itemIndex = 0; // go to first
}
nextItem = this.items.eq(this.itemIndex);
pos = nextItem.position();

if (headache) {
this.runner
.stop()
.animate({left: -pos.left}, this.options.speed, this.options.easing);
}
else {
this.mask
.stop()
.animate({scrollLeft: pos.left}, this.options.speed, this.options.easing);
}
this.updateBtnStyles();
},
move_to: function(i) {
      this.itemIndex = i;
var nextItem, pos;
// check whether there are enough items to animate to
if (this.itemIndex > (this.noOfItems - this.options.itemsPerPage)) {
this.itemIndex = this.noOfItems - this.options.itemsPerPage; // go to last panel - items per transition
}
if (this.itemIndex < 0) {
this.itemIndex = 0; // go to first
}
nextItem = this.items.eq(this.itemIndex);
pos = nextItem.position();

if (headache) {
this.runner
.stop()
.animate({left: -pos.left}, this.options.speed, this.options.easing);
}
else {
this.mask
.stop()
.animate({scrollLeft: pos.left}, this.options.speed, this.options.easing);
}
this.updateBtnStyles();
},
    select_link: function() {
      url = document.URL.match(/(http:\/\/)?([a-zA-Z0=9\.\-\_]*)/)[2];
      // url = "www.ginajaqueline.com"
      var carou = this;
      this.container.find("ul li a").each(function(i,t){
        if(t.href.match(url) != null){
          $(t).addClass("active");
          carou.move_to(parseInt(i/9))
        }
      });
    }

  };

// bridge
$.fn.carousel = function(options) {
return this.each(function() {
var obj = Object.create(Carousel);
obj.init($(this), options);
$.data(this, 'carousel', obj);
});
};
})(jQuery);

 $("#carousel").append("<div id='topmenu'></div>");
  $("#carousel #topmenu").append(
      '<ul>' +
      ' <li id="group1">' +
      ' <a href="http://www.askhybel.dk" onclick="_gaq.push([\'_link\', \'http://www.askhybel.dk\']); ">Ask Hybel</a>' +
      ' <a href="http://www.jesperbalslev.dk" onclick="_gaq.push([\'_link\', \'http://www.jesperbalslev.dk\']); ">Jesper Balslev</a>' +
      ' <a href="http://www.boab.dk/blog" onclick="_gaq.push([\'_link\', \'http://www.boab.dk/blog\']); ">Boab</a>' +
      ' <a href="http://www.jonassmith.dk/weblog" onclick="_gaq.push([\'_link\', \'http://www.jonassmith.dk/weblog\']); ">Jonas Heide Smith</a>' +
      ' <a href="http://www.fiskeben.dk" onclick="_gaq.push([\'_link\', \'http://www.fiskeben.dk\']); ">Fiskeben</a>' +
      ' <a href="http://www.lemberg.dk/blog" onclick="_gaq.push([\'_link\', \'http://www.lemberg.dk/blog\']); ">Mikael Lemberg</a>' +
      ' <a href="http://www.webfronten.dk" onclick="_gaq.push([\'_link\', \'http://www.webfronten.dk\']); ">Webfronten</a>' +
      ' <a href="http://www.mandenfrakommunen.dk" onclick="_gaq.push([\'_link\', \'http://www.mandenfrakommunen.dk\']); ">Manden fra kommunen</a>' +
      ' <a href="http://www.astridmaria.dk/" onclick="_gaq.push([\'_link\', \'http://astridmaria.dk/\']); ">Webpower</a>' +
      ' </li>' +
      ' <li id="group2">' +
      ' <a href="http://www.digitaletanker.dk" onclick="_gaq.push([\'_link\', \'http://www.digitaletanker.dk\']); ">Digitale tanker</a>' +
      ' <a href="http://www.shevy.dk/noerderi" onclick="_gaq.push([\'_link\', \'http://www.shevy.dk/noerderi\']); ">Shevy</a>' +
      ' <a href="http://www.emme.dk" onclick="_gaq.push([\'_link\', \'http://www.emme.dk\']); ">Emme</a>' +
      ' <a href="http://www.thildevesterby.dk" onclick="_gaq.push([\'_link\', \'http://www.thildevesterby.dk\']); ">Thilde Vesterby</a>' +
      ' <a href="http://www.hovedetpaabloggen.dk" onclick="_gaq.push([\'_link\', \'http://www.hovedetpaabloggen.dk\']); ">Hovedet på bloggen</a>' +
      ' <a href="http://www.virkeligheden.dk" onclick="_gaq.push([\'_link\', \'http://www.virkeligheden.dk\']); ">Virkeligheden</a>' +
      ' <a href="http://www.jon-lund.com/main/?m=recent" onclick="_gaq.push([\'_link\', \'http://www.jon-lund.com/main/?m=recent\']); ">Jon Lund</a>' +
      ' <a href="http://www.latenights.dk" onclick="_gaq.push([\'_link\', \'http://www.latenights.dk\']); ">Late Nights</a>' +
      ' </li>' +
      '</ul>' 
  );




  carou=$('#topmenu').carousel({pagination: false});
  setTimeout("carou.data('carousel').select_link()", 500);


});



