/* Gallery (auto-slide-top) */
jQuery.fn.gallSlide = function(_options){
	// defaults options	
	var _options = jQuery.extend({
		duration: 700,
		autoSlide: 5000
	},_options);

	return this.each(function(){
		var _hold = $(this);
		var _speed = _options.duration;
		var _timer = _options.autoSlide;
		var _wrap = _hold.find('ul');
		var _el = _hold.find('ul > li');
		var _count = _el.index(_el.filter(':last'));
		var _h = _el.outerHeight();
		var _wrapHolderW = 1;
		var _t;
		var _active = 0;
		
		var temp = _el.clone();
		_wrap.append(temp);
		
		function scrollEl(){
			_wrap.eq(0).animate({
				marginTop: -(_h * _active) + "px"
			}, _speed, function(){
				if (_count+1 == _active) {
					_active = 0;
					_wrap.eq(0).css({marginTop: -(_h * _active) + "px"});
				}
			});
		}
		function runTimer(){
			_t = setInterval(function(){
				_active++;
				scrollEl();
			}, _timer);
		}
		runTimer();
	});
}

$(document).ready(function(){
	$('.image-list a').lightBox();

	$('div.fade-gallery').gallery({
		duration: 500,
		autoRotation: 5000,
		listOfSlides: 'img',
		effect: 'fade'
	});

	$('div.newsbox').gallSlide({
		duration: 700,
		autoSlide: 6000
	});

}); 