//MooTools More, <http://mootools.net/more>. Copyright (c) 2006-2009 Aaron Newton <http://clientcide.com/>, Valerio Proietti <http://mad4milk.net> & the MooTools team <http://mootools.net/developers>, MIT Style License.
MooTools.More={version:"1.2.4.4",build:"6f6057dc645fdb7547689183b2311063bd653ddf"};Fx.Elements=new Class({Extends:Fx.CSS,initialize:function(b,a){this.elements=this.subject=$$(b);
this.parent(a);},compute:function(g,h,j){var c={};for(var d in g){var a=g[d],e=h[d],f=c[d]={};for(var b in a){f[b]=this.parent(a[b],e[b],j);}}return c;
},set:function(b){for(var c in b){var a=b[c];for(var d in a){this.render(this.elements[c],d,a[d],this.options.unit);}}return this;},start:function(c){if(!this.check(c)){return this;
}var h={},j={};for(var d in c){var f=c[d],a=h[d]={},g=j[d]={};for(var b in f){var e=this.prepare(this.elements[d],b,f[b]);a[b]=e.from;g[b]=e.to;}}return this.parent(h,j);
}});Fx.Scroll=new Class({Extends:Fx,options:{offset:{x:0,y:0},wheelStops:true},initialize:function(b,a){this.element=this.subject=document.id(b);this.parent(a);
var d=this.cancel.bind(this,false);if($type(this.element)!="element"){this.element=document.id(this.element.getDocument().body);}var c=this.element;if(this.options.wheelStops){this.addEvent("start",function(){c.addEvent("mousewheel",d);
},true);this.addEvent("complete",function(){c.removeEvent("mousewheel",d);},true);}},set:function(){var a=Array.flatten(arguments);if(Browser.Engine.gecko){a=[Math.round(a[0]),Math.round(a[1])];
}this.element.scrollTo(a[0],a[1]);},compute:function(c,b,a){return[0,1].map(function(d){return Fx.compute(c[d],b[d],a);});},start:function(c,g){if(!this.check(c,g)){return this;
}var e=this.element.getScrollSize(),b=this.element.getScroll(),d={x:c,y:g};for(var f in d){var a=e[f];if($chk(d[f])){d[f]=($type(d[f])=="number")?d[f]:a;
}else{d[f]=b[f];}d[f]+=this.options.offset[f];}return this.parent([b.x,b.y],[d.x,d.y]);},toTop:function(){return this.start(false,0);},toLeft:function(){return this.start(0,false);
},toRight:function(){return this.start("right",false);},toBottom:function(){return this.start(false,"bottom");},toElement:function(b){var a=document.id(b).getPosition(this.element);
return this.start(a.x,a.y);},scrollIntoView:function(c,e,d){e=e?$splat(e):["x","y"];var h={};c=document.id(c);var f=c.getPosition(this.element);var i=c.getSize();
var g=this.element.getScroll();var a=this.element.getSize();var b={x:f.x+i.x,y:f.y+i.y};["x","y"].each(function(j){if(e.contains(j)){if(b[j]>g[j]+a[j]){h[j]=b[j]-a[j];
}if(f[j]<g[j]){h[j]=f[j];}}if(h[j]==null){h[j]=g[j];}if(d&&d[j]){h[j]=h[j]+d[j];}},this);if(h.x!=g.x||h.y!=g.y){this.start(h.x,h.y);}return this;},scrollToCenter:function(c,e,d){e=e?$splat(e):["x","y"];
c=$(c);var h={},f=c.getPosition(this.element),i=c.getSize(),g=this.element.getScroll(),a=this.element.getSize(),b={x:f.x+i.x,y:f.y+i.y};["x","y"].each(function(j){if(e.contains(j)){h[j]=f[j]-(a[j]-i[j])/2;
}if(h[j]==null){h[j]=g[j];}if(d&&d[j]){h[j]=h[j]+d[j];}},this);if(h.x!=g.x||h.y!=g.y){this.start(h.x,h.y);}return this;}});var SmoothScroll=Fx.SmoothScroll=new Class({Extends:Fx.Scroll,initialize:function(b,c){c=c||document;
this.doc=c.getDocument();var d=c.getWindow();this.parent(this.doc,b);this.links=$$(this.options.links||this.doc.links);var a=d.location.href.match(/^[^#]*/)[0]+"#";
this.links.each(function(f){if(f.href.indexOf(a)!=0){return;}var e=f.href.substr(a.length);if(e){this.useLink(f,e);}},this);if(!Browser.Engine.webkit419){this.addEvent("complete",function(){d.location.hash=this.anchor;
},true);}},useLink:function(c,a){var b;c.addEvent("click",function(d){if(b!==false&&!b){b=document.id(a)||this.doc.getElement("a[name="+a+"]");}if(b){d.preventDefault();
this.anchor=a;this.toElement(b).chain(function(){this.fireEvent("scrolledTo",[c,b]);}.bind(this));c.blur();}}.bind(this));}});Request.Queue=new Class({Implements:[Options,Events],Binds:["attach","request","complete","cancel","success","failure","exception"],options:{stopOnFailure:true,autoAdvance:true,concurrent:1,requests:{}},initialize:function(a){if(a){var b=a.requests;
delete a.requests;}this.setOptions(a);this.requests=new Hash;this.queue=[];this.reqBinders={};if(b){this.addRequests(b);}},addRequest:function(a,b){this.requests.set(a,b);
this.attach(a,b);return this;},addRequests:function(a){$each(a,function(c,b){this.addRequest(b,c);},this);return this;},getName:function(a){return this.requests.keyOf(a);
},attach:function(a,b){if(b._groupSend){return this;}["request","complete","cancel","success","failure","exception"].each(function(c){if(!this.reqBinders[a]){this.reqBinders[a]={};
}this.reqBinders[a][c]=function(){this["on"+c.capitalize()].apply(this,[a,b].extend(arguments));}.bind(this);b.addEvent(c,this.reqBinders[a][c]);},this);
b._groupSend=b.send;b.send=function(c){this.send(a,c);return b;}.bind(this);return this;},removeRequest:function(b){var a=$type(b)=="object"?this.getName(b):b;
if(!a&&$type(a)!="string"){return this;}b=this.requests.get(a);if(!b){return this;}["request","complete","cancel","success","failure","exception"].each(function(c){b.removeEvent(c,this.reqBinders[a][c]);
},this);b.send=b._groupSend;delete b._groupSend;return this;},getRunning:function(){return this.requests.filter(function(a){return a.running;});},isRunning:function(){return !!(this.getRunning().getKeys().length);
},send:function(b,a){var c=function(){this.requests.get(b)._groupSend(a);this.queue.erase(c);}.bind(this);c.name=b;if(this.getRunning().getKeys().length>=this.options.concurrent||(this.error&&this.options.stopOnFailure)){this.queue.push(c);
}else{c();}return this;},hasNext:function(a){return(!a)?!!this.queue.length:!!this.queue.filter(function(b){return b.name==a;}).length;},resume:function(){this.error=false;
(this.options.concurrent-this.getRunning().getKeys().length).times(this.runNext,this);return this;},runNext:function(a){if(!this.queue.length){return this;
}if(!a){this.queue[0]();}else{var b;this.queue.each(function(c){if(!b&&c.name==a){b=true;c();}});}return this;},runAll:function(){this.queue.each(function(a){a();
});return this;},clear:function(a){if(!a){this.queue.empty();}else{this.queue=this.queue.map(function(b){if(b.name!=a){return b;}else{return false;}}).filter(function(b){return b;
});}return this;},cancel:function(a){this.requests.get(a).cancel();return this;},onRequest:function(){this.fireEvent("request",arguments);},onComplete:function(){this.fireEvent("complete",arguments);
if(!this.queue.length){this.fireEvent("end");}},onCancel:function(){if(this.options.autoAdvance&&!this.error){this.runNext();}this.fireEvent("cancel",arguments);
},onSuccess:function(){if(this.options.autoAdvance&&!this.error){this.runNext();}this.fireEvent("success",arguments);},onFailure:function(){this.error=true;
if(!this.options.stopOnFailure&&this.options.autoAdvance){this.runNext();}this.fireEvent("failure",arguments);},onException:function(){this.error=true;
if(!this.options.stopOnFailure&&this.options.autoAdvance){this.runNext();}this.fireEvent("exception",arguments);}});var Asset={javascript:function(f,d){d=$extend({onload:$empty,document:document,check:$lambda(true)},d);
if(d.onLoad){d.onload=d.onLoad;}var b=new Element("script",{src:f,type:"text/javascript"});var e=d.onload.bind(b),a=d.check,g=d.document;delete d.onload;
delete d.check;delete d.document;b.addEvents({load:e,readystatechange:function(){if(["loaded","complete"].contains(this.readyState)){e();}}}).set(d);if(Browser.Engine.webkit419){var c=(function(){if(!$try(a)){return;
}$clear(c);e();}).periodical(50);}return b.inject(g.head);},css:function(b,a){return new Element("link",$merge({rel:"stylesheet",media:"screen",type:"text/css",href:b},a)).inject(document.head);
},image:function(c,b){b=$merge({onload:$empty,onabort:$empty,onerror:$empty},b);var d=new Image();var a=document.id(d)||new Element("img");["load","abort","error"].each(function(e){var g="on"+e;
var f=e.capitalize();if(b["on"+f]){b[g]=b["on"+f];}var h=b[g];delete b[g];d[g]=function(){if(!d){return;}if(!a.parentNode){a.width=d.width;a.height=d.height;
}d=d.onload=d.onabort=d.onerror=null;h.delay(1,a,a);a.fireEvent(e,a,1);};});d.src=a.src=c;if(d&&d.complete){d.onload.delay(1);}return a.set(b);},images:function(d,c){c=$merge({onComplete:$empty,onProgress:$empty,onError:$empty,properties:{}},c);
d=$splat(d);var a=[];var b=0;return new Elements(d.map(function(e){return Asset.image(e,$extend(c.properties,{onload:function(){c.onProgress.call(this,b,d.indexOf(e));
b++;if(b==d.length){c.onComplete();}},onerror:function(){c.onError.call(this,b,d.indexOf(e));b++;if(b==d.length){c.onComplete();}}}));}));}};

/*
---
description: This provides a simple Drop Down menu with infinit levels

license: MIT-style

authors:
- Arian Stolwijk

requires:
  core/1.2.4: [Class.Extras,Element.Style,Element.Event]

provides: [MooDropMenu,Element.MooDropMenu]

...
*/
var MooDropMenu=new Class({Implements:[Options,Events],options:{onOpen:function(el){el.set('opacity',1);},onClose:function(el){el.set('opacity',0);},onInitialize:function(el){el.set('opacity',0);},mouseoutDelay:200,mouseoverDelay:0},initialize:function(menu,options,level){this.setOptions(options);if($type(level)=='number'){this.menu=document.id(menu);this.fireEvent('initialize',menu);this.menu.pel.addEvents({'mouseover':function(){this.menu.pel.mel.store('DropDownOpen',true);$clear(this.timer);this.timer=(function(){this.fireEvent('open',this.menu.pel.mel);}).delay(this.options.mouseoverDelay,this);}.bind(this),'mouseout':function(){this.menu.pel.mel.store('DropDownOpen',false);$clear(this.timer);this.timer=(function(){if(!this.menu.pel.mel.retrieve('DropDownOpen')){this.fireEvent('close',this.menu.pel.mel);}}).delay(this.options.mouseoutDelay,this);}.bind(this)});}
else{level=0;this.menu=document.id(menu);}
this.menu.getChildren('li').each(function(item,index){var list=item.getFirst('ul');if($type(list)=='element'){item.mel=list;list.pel=item;new MooDropMenu(list,options,level+1);}});},toElement:function(){return this.menu}});Element.implement({MooDropMenu:function(options){this.store('MooDropMenu',new MooDropMenu(this,options));return this;}});

var $E = function(selector)
{
	return $$(selector)[0];
};

// Info Bubble

var infoBubble = new Class({

	Implements: Options,
	
	activeEl: null,
	bubble: null,
	delay: null,
	elements: null,
	linkType: null,
	tipHeight: 10,
	visible: false,

	options: {
		contentMargin: 10,
		fade: true,
		fxDuration: 250,
		hideDelay: 2500,
		marginBottom: 10,
		marginTop: -20,
		size: {
			height: 200,
			width: 250
		},
		stopOnClick: true
	},
	
	initialize: function(selector, options)
	{
		this.setOptions(options);

		this.elements = $$(selector);

		this.attach();
		this.createBubble();
	},
	
	attach: function()
	{
		this.elements.each(function(el){
			el.addEvents({
				'click': function(e){
					if(this.options.stopOnClick)
					{
						e.stop();
					}
				}.bind(this),
				'mouseleave': function(){
					this.hideBubble();
				}.bind(this),
				'mouseover': function(){
					this.setLinkType(el);
					this.showBubble(el);
				}.bind(this)
			});
		}, this);
	},
	
	clearDelay: function()
	{
		$clear(this.delay);
	},
	
	createBubble: function()
	{
		this.bubbleContainer = new Element('div', {
			'class': 'infoBubble',
			styles: {
				height: this.options.size.height + this.tipHeight + (this.options.contentMargin * 2),
				marginTop: this.options.marginTop,
				opacity: 0,
				top: -1000,
				width: this.options.size.width + (this.options.contentMargin * 2)
			}
		}).inject(document.body);;
		
		this.bubble = new Element('div', {
			'class': 'infoBubble-Bubble',
			events: {
				'mouseleave': function(){
					this.hideBubble();
				}.bind(this),
				'mouseover': function(){
					this.clearDelay();
				}.bind(this)
			},
			styles: {
				height: this.options.size.height + (this.options.contentMargin * 2)
			}
		}).inject(this.bubbleContainer);
		
		if(this.options.fade)
		{
			this.bubbleContainer.store('fxInstance', new Fx.Morph(this.bubbleContainer, {
				duration: this.options.fxDuration
			}));
		}
		
		this.bubbleContent = new Element('div', {
			'class': 'infoBubble-Content',
			styles: {
				height: this.options.size.height
			}
		}).inject(this.bubble);
	},
	
	getContent: function(el)
	{
		this.bubbleContent.addClass('loading');

		var href = el.get('href');

		if(this.linkType == 'inline')
		{
			this.resetBubble();

			var id = href.substr(1);

			if($(id))
			{
				this.setContent($(id).get('html'));
			}
		}
		else if(this.linkType == 'image')
		{
			var image = el.retrieve('image');

			if(!image)
			{
				image = new Asset.image(href, {
					onload: function(){
						el.store('image', image);
						this.insertImage(el, image);
					}.bind(this)
				});
			}
			else
			{
				this.insertImage(el, image);
			}
		}
		else
		{
			this.resetBubble(true);

			if(el.retrieve('responseHTML'))
			{
				this.setContent(el.retrieve('responseHTML'));
			}
			else
			{
				new Request.HTML({
					onSuccess: function(responseTree, responseElements, responseHTML){
						el.store('responseHTML', responseHTML);
						this.bubbleContent.removeClass('loading')
					}.bind(this),
					update: this.bubbleContent,
					url: href	
				}).send();
			}
		}
	},
	
	setLinkType: function(el)
	{
		var href = el.get('href');

		if(href.substr(0, 1) == '#')
		{
			this.linkType = 'inline';
		}
		else if(href.test('.gif|.jpeg|.jpg|.png|.png'))
		{
			this.linkType = 'image';
		}
		else
		{
			this.linkType = 'ajax';
		}
	},
	
	hideBubble: function()
	{
		this.delay = (function(){
			var fx = this.bubbleContainer.retrieve('fxInstance');
			fx.start({
				marginTop: this.options.marginTop,
				opacity: 0
			}).chain(function(){
				this.activeEl = null;
				this.resetBubble();
				this.visible = false;
			}.bind(this));
		}.bind(this)).delay(this.options.hideDelay);
	},
	
	insertImage: function(el, image)
	{
		image.set('opacity', 0);
		this.bubbleContent.empty().adopt(image);
	
		var imageSize = image.getSize();

		var fn = function(){
			image.fade(0, 1);
		};

		this.resizeBubble(el, imageSize.y, imageSize.x, fn);	
	},
	
	setContent: function(html)
	{
		this.resetBubble();

		this.bubbleContent.removeClass('loading').set('html', html);
	},
	
	resetBubble: function()
	{
		this.bubbleContainer.setStyles({
			height: this.options.size.height + this.tipHeight + (this.options.contentMargin * 2),
			width: this.options.size.width + (this.options.contentMargin * 2)
		});

		this.bubble.setStyle('height', this.options.size.height + (this.options.contentMargin * 2));

		this.bubbleContent.setStyle('height', this.options.size.height).empty().addClass('loading');
	},
	
	resizeBubble: function(el, height, width, fn)
	{
		var bubbleSize = this.bubbleContent.getSize();

		if(height == bubbleSize.y && width == bubbleSize.x)
		{
			if($defined(fn))
			{
				fn();
			}
			return;
		}
		var coordinates = el.getCoordinates();

		// TODO add method to calculate the position
		var left = (coordinates.left + (coordinates.width/2).round() - (width/2).round()) - this.options.contentMargin ;
		var top = (coordinates.top - height - this.tipHeight - this.options.marginBottom) - (this.options.contentMargin * 2);
		
		new Fx.Elements($$(this.bubbleContainer, this.bubble, this.bubbleContent), {
			onComplete: function(){
				this.bubble.setStyle('height', height + (this.options.contentMargin * 2));
				this.bubbleContent.setStyle('height', height).removeClass('loading');

				if($defined(fn))
				{
					fn();
				}
			}.bind(this)
		}).start({
			'0': {
				height: height + this.tipHeight + (this.options.contentMargin * 2),
				left: left,
				top: top,
				width: width + (this.options.contentMargin * 2)
			},
			'1': {
				height: height + (this.options.contentMargin * 2)
			},
			'2': {
				height: height
			}
		});
	},
	
	setBubbleContent: function(content)
	{
		this.bubbleContent.removeClass('loading').adopt(content);	
	},
	
	showBubble: function(el)
	{
		this.clearDelay();
		
		if(this.activeEl == el)
		{
			return;
		}
		this.activeEl = el;

		var coordinates = el.getCoordinates();

		// TODO limit left 0, window.width

		var size = {
			y: this.options.size.height,
			x: this.options.size.width
		};
		
		if(this.visible && this.linkType == 'image')
		{
			size = this.bubbleContent.getSize();
		}
		
		var left = (coordinates.left + (coordinates.width/2).round() - (size.x/2).round()) - this.options.contentMargin;
		var top = (coordinates.top - size.y - this.tipHeight - this.options.marginBottom) - (this.options.contentMargin * 2);

		this.bubbleContainer.setStyles({
			left: left,
			top: top
		});

		this.getContent(el);

		if(this.visible)
		{
			return;
		}

		if(this.options.fade)
		{
			var fx = this.bubbleContainer.retrieve('fxInstance');
			fx.start({
				marginTop: [this.options.marginTop, 0],
				opacity: [0, 1]
			});
			this.visible = true;
		}
		else
		{
			this.bubbleContainer.fade('show');	
		}
	}
	
});

// RICH CONTENT BOX :D

var cwRichContentBox  = new Class({

	initialize: function(container)
	{
		this.container = $(container);

		this.busy = false;
		this.current = 0;
		this.images = this.container.getElements('img');
		
		this.initImages();
		this.createButtons();
	},
	
	initImages: function()
	{
		this.images.each(function(image,i){
			if(i == 0)
			{
				image.setStyle('z-index', 2);
			}
			else
			{
				image.setStyle('opacity', 0);
			}
		}, this);
	},
	
	createButtons: function()
	{
		new Element('a', {
			'class': 'slide-teaser-prev',
			events: {
				'click': function(e){
					e.stop();
					this.prev();
				}.bind(this)
			},
			href: '#'
		}).inject(this.container);
		
		new Element('a', {
			'class': 'slide-teaser-next',
			events: {
				'click': function(e){
					e.stop();
					this.next();
				}.bind(this)
			},
			href: '#'
		}).inject(this.container);
	},
	
	prev: function()
	{
		var to = this.current - 1 < 0 ? this.images.length -1 : this.current - 1;
		this.fade(to);
	},
	
	next: function()
	{
		var to = this.current + 1 > this.images.length -1 ? 0 : this.current + 1;
		this.fade(to);
	},
	
	fade: function(to)
	{
		if(this.busy)
		{
			return;
		}

		this.images[to].setStyles({
			opacity: 0,
			zIndex: 3
		});

		new Fx.Tween(this.images[to], {
			duration: 750
		}).start('opacity', 1).chain(function(){
			this.images[to].setStyle('zIndex', 2);

			this.images[this.current].setStyles({
				opacity: 0,
				zIndex: 1
			});
			this.busy = false;
			this.current = to;
		}.bind(this));
	}
});


// SIMPLETABS

var SimpleTabs = new Class({
    
	Implements: Options,
	
	options: {
		contentContainerSelector: '.content'	
	},
	
    initialize: function(container, links, options)
    {
        this.container = $(container);
        this.links = $$(links);

		this.setOptions(options);        
		
		var cssClasses = this.container.get('class').split(' ');

		this.start = 0;

		cssClasses.each(function(item){
			if(item.test('tab-'))
			{
				this.start = item.split('-')[1];
			}
		},this);		
		
		this.attach();
		
		this.load(this.start);
    },
    
    attach: function()
    {
        this.links.each(function(link, i){
            if(i == this.start)
			{
				link.addClass('active');
			}

            link.addEvent('click', function(event){
                event.stop();
                this.load(i);
				this.container.getElement('.active').removeClass('active');
				link.addClass('active');}.bind(this));
        }, this);
    },
	
	load: function(n)
	{
		this.container.getElements(this.options.contentContainerSelector).each(function(el, i){
			el.setStyle('display', i == n ? 'block' : 'none');
		});
	}
    
});

var zebraTable = function(t)
{
	t.select('tbody tr').each(function(tr, i){
		tr.addClass((i+1) % 2 == 0 ? 'even' : 'odd');	
	});
	// Usage: $$('table.zebra').each(function(t){zebraTable(t);});
}

// Cover preview product pages
function change_cover_preview(thumbnail,imgsrc,imgtxt)
{
    $('cover_preview').set('src', imgsrc).set('title', imgtxt);
}

var initHomePage = function(){
	// Tab Container
	$$('#HomeJSContent .simple-tabs').each(function(el){
		if(!el.hasClass('smart-edit'))
		{
			new SimpleTabs(el, el.getElements('ul.tabs li'));
		}
	});

	// HPS Teaser Box
	$$('#HomeJSContent .slide-teaser').each(function(el){
		new cwRichContentBox(el);
	});
};

// AJAX TABS

var AjaxTabs = new Class({
    
    Implements: Options,
	
	options: {
		startTab: 0
	},
    
    initialize: function(container, links, options)
    {
        this.container = $(container);
        this.links = $$(links);

		this.setOptions(options);

		this.container.getParent('.ajax-tabs').get('class').split(' ').each(function(el){
			if(el.test('tab-'))
			{
				this.options.startTab = el.split('-')[1];
			}
		},this);	
		
        this.attach();
		this.load(this.options.startTab);
    },
    
    attach: function()
    {
        this.links.each(function(link, i){
			var li = link.getParent().getParent(); //link.getParent('li');
            if(i == this.options.startTab)
			{			
				li.addClass('active');
			}
			
			this.createContainer();
			
            link.addEvent('click', function(event){
                event.stop();     
				this.load(i);				
				//this.container.getElement('.active').removeClass('active');
				li.getParent().getElement('.active').removeClass('active');
				li.addClass('active');
            }.bind(this));
        }, this);
    },
	
	createContainer: function()
	{
		new Element('div', {
			'class': 'content-holder content-loading',
			styles: {
				display: 'none'
			}
		}).inject(this.container);
	},
	
	load: function(i)
	{
		this.container.getElements('div.content-holder').setStyle('display', 'none');
		var container = this.container.getElements('div.content-holder')[i];
		if(container.getChildren().length == 0)
		{
			new Request.HTML({
				append: container,
				onSuccess: function(){
					container.removeClass('content-loading');	
				},
				url: this.links[i].get('href')
			}).send();
		}
		container.setStyle('display', 'block');
	}
    
});


/**
 * Partner-Scroller 
 */

var partnerScroller = new Class({

	page: 1,
	options: {
		interval: 3000,
		perPage: 3,
		startPage: 1
	},

	initialize: function(container, json)
	{
		this.container = $(container);
		if(!json || json.length == 0)
		{
			return;
		}
		this.json = json;
		this.partnerCount =  json.partner.length; //x+1
		this.partnerPages = Math.ceil(this.partnerCount/this.options.perPage);

		new Element('div',{
			styles: {position:'absolute',top:0,widht:485,'text-align':'center'}
		}).adopt(
		new Element('img', {
			'src': this.json.partner[0].image
		}),
		new Element('img', {
			'src': this.json.partner[1].image
		}),
		new Element('img', {
			'src': this.json.partner[2].image
		})
		).inject(this.container);

		this.start();
	},

	loadImages: function()
	{
		var start = this.options.perPage * this.page;
		var ende = ((start+this.options.perPage)<this.partnerCount)?start+this.options.perPage:this.partnerCount;

		var sources = [];

		for(var i = start; i < ende; i++)
		{
			//console.log(start,i,ende);
			sources.push(this.json.partner[i].image);
		}

		var images = new Asset.images(sources, {
			onComplete: function(){
			this.injectImages(images);
		}.bind(this)
		});
	},

	injectImages: function(images)
	{
		/* neuen Container anlegen und Bilder implementieren */
		new Element('div',{                        
			styles: {position:'absolute',top:this.container.getHeight(),widht:485,'text-align':'center'}
		}).adopt(images).inject(this.container);

		/* neuen Container einblenden durch verschieben des Alten */
		var myElementsEffects = new Fx.Elements($$(this.container.getElements('div')),{
			onComplete: function(){this.container.getElement('div').dispose()}.bind(this)
		});
		myElementsEffects.start({
			'0': {                            
				'top': [0,-80]
			},
			'1': {                            
				'top': [80,0]
			}
		});                   

		this.page++;
		//console.log(this.page,this.partnerPages);
		if(this.page==this.partnerPages)
		{
			this.page = 0;
		}

		this.start();
	},

	start: function()
	{
		/* verzögertes Vorladen der neuen Bilder */
		this.loadImages.delay(this.options.interval, this);
	}

});
 
 
/**
 * DomReady
 */

window.addEvent('domready', function(){

	// Navigation
	if($('navi_level2'))
	{
		if($('navi_level2').getElement('ul'))
		{
			$('navi_level2').getElement('ul').MooDropMenu({
				onOpen: function(el){
					$$(el, el.getPrevious('.navi_tip')).fade(!Browser.Engine.trident ? 'in' : 'show');
				},
				onClose: function(el){
					$$(el, el.getPrevious('.navi_tip')).fade(!Browser.Engine.trident ? 'out' : 'hide');
				},
				onInitialize: function(el){
					$$(el, el.getPrevious('.navi_tip')).setStyle('display', 'block').fade('hide').set('tween',{duration:250});
				}
			});	
		}
	}

	// Tab Container
	$$('.simple-tabs').each(function(el){
		if(!el.hasClass('smart-edit'))
		{
			new SimpleTabs(el, el.getElements('ul.tabs li'));
		}
	});
	
	// HPS Teaser Box
	$$('.slide-teaser').each(function(el){
		new cwRichContentBox(el);
	});
	
	// Info Bubble
	$$('.info-bubble').each(function(el){
		new infoBubble(el,{
			size: {
				height: 200,
				width: 250
			}
		});	
	});

	// Product Galleries
	$$('.product-gallery').each(function(el){
        new ProductGallery(el, {
            fadeOutDisabledButtons: true,
            slideOpacity: .75
        });
    });
	
	// Price List
	var priceListContainer = $E('.PriceList');
	
	if(priceListContainer)
	{
		var links = $$(
			priceListContainer.getElement('ul').getElements('a'),
			priceListContainer.getElements('a.to-top')
		);
		
		new Fx.SmoothScroll({
			links: links
		});
	}

	// Partner Listing
	var partnerListingEl = $$('.partner-listing')[0];
	
	if(partnerListingEl)
	{
		new SimpleTabs(partnerListingEl, partnerListingEl.getElement('ul').getElements('li'), {
			contentContainerSelector: '.partner-listing-container'	
		});
	}
	
	// Partner Scroller
	if($('partnerScroller'))
	{
		new partnerScroller($('partnerScroller'), partnerList);
	}
	
	// Product Image Gallery	
	if($('cwpGallery'))
	{
		new cwpGallery('cwpGallery');
	}
	
	// Ajax Tabs
	$$('.ajax-tabs').each ( function (el) { 
		new AjaxTabs(el.getElement('.holder'), el.getElements('ul a'));
	});
	
	// Quick Service Select
	if($('service_select'))
	{
		$('service_select').addEvent('change', function(){
			if(this.get('value') != 'null')
			{
				window.location.href = this.get('value');
			}
		});
	}	
});


