/*
# ------------------------------------------------------------------------
# JA Content Scroll module for Joomla 1.5
# ------------------------------------------------------------------------
# Copyright (C) 2004-2010 JoomlArt.com. All Rights Reserved.
# @license - PHP files are GNU/GPL V2. CSS / JS are Copyrighted Commercial,
# bound by Proprietary License of JoomlArt. For details on licensing, 
# Please Read Terms of Use at http://www.joomlart.com/terms_of_use.html.
# Author: JoomlArt.com
# Websites:  http://www.joomlart.com -  http://www.joomlancers.com
# Redistribution, Modification or Re-licensing of this file in part of full, 
# is bound by the License applied. 
# ------------------------------------------------------------------------
*/ 

window.addEvent('domready', function() {
	var fx = new Fx.Style($('ja-contentslider-nav-knob'), 'left', {duration: 300, wait: false});
	var myScrollFx = new Fx.Scroll($('ja-contentslider-center'), {
		wait: false
	});

	var x = $('ja-contentslider-center').scrollWidth - $('ja-contentslider-center').offsetWidth;
	var mySlide = new Slider($('ja-contentslider-nav-slider'), $('ja-contentslider-nav-knob'), {	
		steps: x,

		onTick: function(pos){
			fx.start(pos);
			myScrollFx.scrollTo(this.toStep(pos), 0);
		}

	}).set(0);

	mySlide.drag.addEvent('onDrag', function() {
		mySlide.step = mySlide.toStep(mySlide.drag.value.now[mySlide.z]);
		myScrollFx.set([mySlide.step, 0]);
	});

	$('ja-contentslider-nav-left').addEvent ('click', function() {
		mySlide.step -= 100;
		mySlide.step = mySlide.step.limit(0, mySlide.options.steps);
		fx.start(mySlide.toPosition(mySlide.step));
		myScrollFx.scrollTo(mySlide.step, 0);
	});

	$('ja-contentslider-nav-right').addEvent ('click', function() {
		mySlide.step += 100;
		mySlide.step = mySlide.step.limit(0, mySlide.options.steps);
		fx.start(mySlide.toPosition(mySlide.step));
		myScrollFx.scrollTo(mySlide.step, 0);
	});

});
