var _menu = {
	timer: null,
	delay: 500,
	init: function() {
		$("#menu li").mouseover(function() {
			_menu.display(this);
		});
		$("#menu li").mouseleave(function() {
			_menu.hide(this);
		});
	},
	display: function(entry) {
		this.clearTimer();
		this.timer = window.setTimeout(function() {_menu.show(entry)}, this.delay);
	},
	show: function(entry) {
		$(entry).find(".submenu").show();
		$(entry).addClass("active");
	},
	hide: function(entry) {
		this.clearTimer();
		$(entry).find(".submenu").hide();
		$(entry).removeClass("active");
	},
	clearTimer: function() {
		if(this.timer != null)
			clearTimeout(this.timer);
		this.timer = null;
	}
};

var _olb = {
	id: "#olbanner",
	showSpeed: 750,
	hideSpeed: 750,
	showOffset: 1500,
	hideAfter: 20000,
	init: function() {
		if(!this.isAppeared()) {
			window.setTimeout(function() {
				$(_olb.id).slideDown(_olb.showSpeed, function() {
					$(this).effect("bounce", {}, 500);
					window.setTimeout(function() {
						_olb.hide();
					}, _olb.hideAfter);
					_olb.setAppeared();
				});
			}, _olb.showOffset);

			$(_olb.id + " .olclose").click(function() {
				_olb.hide();
			});
		}
	},
	hide: function() {
		$(_olb.id).fadeOut(_olb.hideSpeed);
	},
	setAppeared: function() {
		$.cookie("_olb", "true", { expires: 90 });
	},
	isAppeared: function() {
		if($.cookie("_olb") != null)
			return true;
		return false;
	}
};

$(document).ready(function() {
	// drop down menu
	_menu.init();

	// overlay banner
	_olb.init();

	// scrollable
	$("#slideshow").scrollable({circular: true, speed: 1000}).autoscroll(12000).navigator();
	$("#slideshow .navi a").click(function() {
		var _sapi = $("#slideshow").data("scrollable");
		_sapi.stop();
	});
});
