/*
	Collection IDs

	100014 : Shimmery Nights
	100016 : Set Me Up
	100018 : No Flakin' Way
	100020 : None of Your Frizzness
	100022 : Totally Twisted
	100026 : Tousle Me Softly
*/

var scroll = new Fx.Scroll('slider', {
	wait: false,
	duration: 500,
	offset: {'x': 0, 'y': 0},
	transition: Fx.Transitions.Quad.easeInOut
});

var _currentX = 0;

/* As promised, here's the comment: */
/* When adding a new collection, increase this by the width of your collection image */ 
var _maxX = 841;
var _scrollValue = 123 * 3;

$('arrowScrollLeft').setOpacity(0.5);

$('arrowScrollLeft').addEvent('click', function(event) {
	event = new Event(event).stop();
	scroll.scrollTo(currentX(-_scrollValue),0);
	$('arrowScrollRight').setOpacity(1);

	if (_currentX == 0) {
		$('arrowScrollLeft').setOpacity(0.5);
	}
});

$('arrowScrollRight').addEvent('click', function(event) {
	event = new Event(event).stop();
	scroll.scrollTo(currentX(_scrollValue),0);
	$('arrowScrollLeft').setOpacity(1);

	if (_currentX >= _maxX) {
		$('arrowScrollRight').setOpacity(0.5);
	}
});

function currentX(pushVal) {
	_currentX += pushVal;

	if (_currentX <= 0)  {
        _currentX = 0; 
    }

	if (_currentX >= _maxX) {
	    _currentX = _maxX;
    }
	return _currentX;
}

var pageId = $('initId').getAttribute('value');
if (pageId == 100010 || pageId == 100014 || pageId == 100016 || pageId == 100018 || pageId == 100020 || pageId == 100022 || pageId == 100026) {
	if (pageId == 100026) {
		// this is the last one, make sure it's shown
		// don't know why just adding it on to the big ol' || statement above doesn't cut it, 
		// but I'm under a time constraint and can't take time to figure it out right now.
		// This is why comments are important.
		_scrollValue = _maxX;
	}
	scroll.scrollTo(currentX(_scrollValue*2),0);
	$('arrowScrollLeft').setOpacity(1);

	if (_currentX >= _maxX) {
		$('arrowScrollRight').setOpacity(0.5);
	}
}
