$(document).ready(function(){
	var hoverS = 500;
	var btnFlag = false;
	var openFlag = true;
	var menuFlag = false;

	
	//ipad
	if ($.os.name == "iphone" || $.os.name == "ipad" || $.os.name == "ipod") {
		$('#menuList a').addClass('closed').click(function(){
			if ($(this).hasClass("closed")) {
				$(this).addClass('opened');
				$('#menuList a').not($(this)).each(function(){
					$(this).removeClass('opend');
					$(this).removeClass('closed');
					$(this).addClass('closed');
				})
				$(this).removeClass('closed');
				$(this).parent().stop().animate({
					'height': '297px'
				}, {
					duration: hoverS,
					easing: 'swing',
					complete: function(){
						$(this).find('.logo').fadeIn(hoverS);
					}
				});
				$(this).parent().find('h2').stop().fadeTo(hoverS, 1);
				
				$('#menuList li').not($(this).parent()).each(function(){
					$(this).find('h2').stop().fadeTo(hoverS, 0);
					$(this).stop().animate({
						'height': '87px'
					}, {
						duration: hoverS * 1.2,
						easing: 'swing'
					});
					$(this).find('.logo').fadeOut(hoverS);
				});
				return false;
			}
		});
	} else {

		var hoverID;
		$('#menuList li').hover(function(){
			clearTimeout(hoverID);
			$(this).stop().animate({
				'height': '297px'
			}, {
				duration: hoverS,
				easing: 'swing',
				complete: function(){
					$(this).find('.logo').fadeIn(hoverS);
				}
			});
			if (jQuery.support.opacity) {
				$(this).find('h2').stop().fadeTo(hoverS, 1);
			} else {
				$(this).find('h2').show();
			}
			
			$('#menuList li').not(this).each(function(){
				if (jQuery.support.opacity) {
					$(this).find('h2').stop().fadeTo(hoverS, 0);
				} else {
					$(this).find('h2').hide();
				}
				$(this).stop().animate({
					'height': '87px'
				}, {
					duration: hoverS * 1.05,
					easing: 'swing'
				});
			});
		}, function(){
			clearTimeout(hoverID);
			$(this).stop().animate({
				'height': '129px'
			}, {
				duration: hoverS * 1.05,
				easing: 'swing'
			});
			
			$(this).find('.logo').fadeOut(hoverS);
			
			$('#menuList li').not(this).each(function(){
				$(this).stop().animate({
					'height': '129px'
				}, {
					duration: hoverS,
					easing: 'swing'
				});
				if (jQuery.support.opacity) {
					$(this).find('h2').stop().fadeTo(hoverS, 1);
				}
			});
			if (!jQuery.support.opacity) {
				hoverID = setTimeout(function(){
					$('#menuList li').find('h2').show();
				}, hoverS / 2);
			}
		});
	}
	

});

