/**
 * Mootools horizontal glider
 *
 * (c) Copyright 2008 Avot Media BV
 */
var Glider = new Class({
	glideHolder: null,
	glideSize: 0,
	transitionTime: 0,
	items: null,
	itemCount: null,
	currentItem: 0,
	initialize: function(GH, GS, TT, IC)
	{
		this.glideHolder = $(GH||'portfolio');
		this.glideSize = GS||800;
		this.transitionTime = TT||1250;
		this.items = $$(IC||'.portfolioitem');
		this.itemCount = this.items.length;
	},
	showItem: function(itemID)
	{
		if (this.items[(itemID - 1)]) {
			this.glide(-(this.glideSize * (itemID - 1)));
			this.currentItem = (itemID - 1);
		}
	},
	previousItem: function()
	{
		this.currentItem--;
		if (this.currentItem < 0) this.currentItem = (this.itemCount - 1);
		this.glide(-(this.glideSize * this.currentItem));
	},
	nextItem: function()
	{
		this.currentItem++;
		if (this.currentItem > (this.itemCount - 1)) {
			this.currentItem = 0;
			this.glide(0);
		} else {
			this.glide(-(this.glideSize * this.currentItem));
		}
	},
	glide: function(yPosition)
	{
		if (typeof yPosition === undefined) yPosition = 0;
		var glideEffect = new Fx.Morph(this.glideHolder, {duration: this.transitionTime, transition: Fx.Transitions.Quad.easeInOut, wait: false});
		glideEffect.start({
			left: yPosition
		});
	}
});