/*
description: Homepage Init für abitare.lu

authors:
  - Oskar Kurz
*/

$(document).ready(function(){	
	$("#startseite_top").easySlider({
		auto: true,
		continuous: true,
                numeric: true,
                pause: 4000
	});
});

(function($){
  $.fn.brandSlider=function(options){
    return this.each(
      function(){
        function move(args){
          var direction=((args.direction||options.direction)=='left')?'-':'+';
          var child=obj.children(':first');
          child.stop().animate({'marginLeft':direction+'='+child.width()},args.speed,'linear',function(){
            if(direction=='-'){
              $(this).remove().clone().css('margin',0).appendTo(obj);
            }
            else
            {
              $(this).css('margin',0);
              obj.children(':last').remove().clone().css('margin',0).prependTo(obj);
            }
            if(args.repeat)
            {
              setTimeout(function(){
                move(args,true);
              },300);
            }
          });
        }
        function init(){
          $(options.next).live('click',function(){
            move({direction:'left',speed:options.speed});
          });
          $(options.prev).live('click',function(){
            move({direction:'right',speed:options.speed});
          });
          if(options.autostop){
            obj.children('a').mouseover(stop);
            obj.parent().mouseout(go);
          }
          go();
        }
        function go(){
          if(options.autoplay){
            move({direction:options.direction,repeat:options.repeat,speed:options.autoplay});
          }
        }
        function stop(){
          obj.children('a:first').stop();
        }
        obj=$(this).children('div:first');
        init();
      }
    );
  }
})(jQuery);

$(document).ready(function() {
  $('#marken').brandSlider(
    {
      direction:  'left',
      autoplay:   9000,
      autostop:   true,
      repeat:     true,
      speed:      500,
      next:       '.arrow.next',
      prev:       '.arrow.prev'
    }
  );
});

