/* Clever stuff here done by Patrick Beser - go check out his awesome work at http://wizzninetynine.de */

if($('showcase')) {

	var distance = 0;
	var prevX = 0;

	new Draggable('showcase', {

		constraint:'horizontal',
		starteffect:function() { if(this.ismoving) { this.ismoving.cancel(); } },
		endeffect:function() {
			var to = parseInt($('showcase').getStyle('left')) + distance * 10;
			var dur = (500 + Math.abs(distance * 10))/1000;
			
			// Magnet?
			if(to > 0) { to = 0; dur = 3; }
			if(to < -(imgcontentwidth - 760)) { to = -(imgcontentwidth - 760); dur = 3; }
			
			this.ismoving = new Effect.Morph('showcase', { style:'left:'+to+'px', duration:dur, transition:Effect.Transitions.Cubic });
		},
		change:function() {
			distance = parseInt($('showcase').getStyle('left')) - prevX;
			prevX = parseInt($('showcase').getStyle('left'));
		}


	});
	
	Event.observe('showcase', 'mousedown', function() { $('showcase').style.cursor = '-moz-grabbing'; });
	Event.observe('showcase', 'mouseup', function() { $('showcase').style.cursor = '-moz-grab'; });
	

	imgcontentwidth = parseInt($('showcase').getStyle('width'));
	

}


	