/**
 *	@ Script : gallery.js
 *
 *	@ Licensed under the MIT License: http://www.opensource.org/licenses/mit-license.php
 *	
 */

$(function() {

	
	/**
	 *	@ for Main Gallery
	 *	
	 */
	function slideshow() {
		// DELETE
		$('#mainGallery').css({
			'position':'relative',
			'height':280,
			'marginBottom':25
			
		});
		$('#topGallery').css({
			'position':'relative',
			'height':517,
			'marginBottom':0
			
		});
		$('#mainGallery img,#topGallery img').css({
			'position':'absolute',
			'top':0,
			'left':0
		});
		
		//
		_this = $('#mainGallery img,#topGallery img');
			var _current = 0,
			_time = 2500,
			_delay = 4500,
			_total = _this.size() - 1;
			
	
		function loop() {
			getCurrent();
			_this.eq(_current).delay(_delay).fadeIn(_time, function() {
				_this.eq(_current - 1).css('display','none');
				loop();
			});
		}
		function getCurrent() {
			if (_current >= _total) _current = -1;
			_current++;
			_this.eq(_current - 1).css('z-index','0');
			_this.eq(_current).css('z-index','10');
		}
	
		_this.css("display", "none");
		_this.eq(_current).css("display", "block");
		_this.eq(_current).delay(_delay).fadeIn(_time, loop);
	}
	slideshow();

});
