/**
 * params
 *	elemCarousel
 *	perMove
 */
function wdm_slide( objParams ) {
	objParams = objParams || {};
	var _iterator;
	for (_iterator in objParams) {
		this[_iterator] = objParams[_iterator];
	}
	
	var _countChild = this.elemCarousel.find('> div').length - 1;
	this.maxMove = ( _countChild * objParams.perMove) * -1;
	this.perMove = this.perMove * -1;
	this.currentMove = 0;
	this.timer = null;
	var _self = this;
	
	this.move = function(moveTo) {
			
		if ( moveTo < this.maxMove) moveTo = 0;
		else if ( moveTo > 0 ) moveTo = this.maxMove;

		this.elemCarousel.animate({
				left : moveTo
			}, 'slow', 'linear', function() { if (!_self.timer) _self.start(); });
		//this.elemCarousel.css('top', moveTo)
		this.currentMove = moveTo;
	};
	
	this.start = function() {
		_self.timer = setInterval(function() {
			var _moveTo = _self.currentMove + _self.perMove;
			_self.move(_moveTo);
		}, _self.speed);
	};
	
	
	this.stop = function() {
		clearInterval(_self.timer);
		_self.timer = null;
	};
	
	this.start();
	
	this.next.click( function() {
		var _moveTo = _self.currentMove + _self.perMove;
		_self.move(_moveTo);
		_self.stop();
		return false;
	});
	
	this.prev.click( function() {
		var _moveTo = _self.currentMove - _self.perMove;
		_self.move(_moveTo);
		_self.stop();
		return false;
	});
}

$(function() {
	// vertical slide news
	var _parent = $('div.leftcolumn div.about')
	
	var _slide = new wdm_slide({
		'elemCarousel' : _parent.find('div.about-wrap').css('position', 'relative'),
		'prev' : _parent.find('a.prev'),
		'next' : _parent.find('a.next'),
		'perMove' :538,
		'speed' : 5000
		});
});


$(document).ready(function(){

	var sHeight = $(document).height();
	$('.inner-wrapper').css('height', sHeight);
	
	// carousel
	if ( $('div.carousel').length > 0 )
		( new wdm_carousel($('div.carousel > div'), 3000) );


});
