$(document).ready(function(){
	initSlide();
	var gal6 = new gallery({
		hold: 'div.visual',
		autoRotation: 20000,
		duration: 1200,
		slideElement: 1,
		switcher: 'div.navbar ul > li',
		listOfSlides: ' div.mask ul > li'
	});
});
function initSlide(){
	var _duration = 400;
	var gal4 = new gallery({
		hold: 'div.gallery-welcome',
		autoRotation: 15000,
		duration: 800,
		listOfSlides: 'ul > li',
		nextBtn: 'div.next > a',
		prevBtn: 'div.prev > a'
	});
	var gal5 = new gallery({
		hold: 'div.gallery-sponsors',
		autoRotation: 10000,
		duration: 1000,
		listOfSlides: 'ul > li',
		nextBtn: 'div.next > a',
		prevBtn: 'div.prev > a'
	});
	$('div.open-hold').each(function(){
		var _hold = $(this);
		var _box = _hold.find('div.slide');
		var _btn = _hold.find('a.opener');
		var _h = _box.height();
		if(_hold.hasClass('opened')) _box.show();
		else _box.hide();
		
		_btn.click(function(){
			if(_hold.hasClass('opened')){
				_hold.removeClass('opened');
				_box.stop().animate({height:0}, _duration, function(){
					$(this).css({display:'none', height:'auto'});
				});
				gal4.stop();
				gal5.stop();
			}
			else{
				_hold.addClass('opened');
				if(_box.is(':hidden')){
					_box.show();
					_h = _box.height();
					_box.height(0);
				}
				_box.stop().animate({height: _h}, _duration, function(){ 
					$(this).height('auto');
				})
				gal4.play();
				gal5.play();
			}
			return false;
		});
		
	});
}

