/* -------------- menudrop -------------- */

(function($) {
	$.menudrop = function(o) {
		$.extend(this, {
			link: '', layer: '',
			dropEvent: 'mouseover', hideEvent: 'mouseout', stopEvent: 'mousemove',
			onBeforeDrop: function() {}, onAfterDrop: function() {}, onHide: function() {},
			timer: null, delay: 500
		}, o || {});
		this.init();
	}
	$.menudrop.prototype = {
		init: function() {
			var t = this;
			$(this.link).bind(this.dropEvent, function(e){ t.show(); e.preventDefault(); e.stopPropagation()});
			$(this.link).add(this.layer)
				.bind(this.hideEvent,function(){ t.timer=setTimeout(function(){t.hide()},t.delay) })
				.bind(this.stopEvent,function(){ clearTimeout(t.timer) });
		},
		show: function() { this.onBeforeDrop(); $(this.layer).show(); this.onAfterDrop(); },
		hide: function() { $(this.layer).hide(); this.onHide(); }
	}
	
	$.ladyIndex = function(o) {
		$.extend(this, { bg: '', list: '', cur: 'on', images: [], index: 0, timer: null, interval: 10000 }, o || {});
		var t = this;
		$(function() { t.init(); });
	}
	$.ladyIndex.prototype = {
		init: function() {
			var t = this;
			if ( !this.bg || !this.list || !this.images.length ) return;
			$('<div></div>')
				.css({ position: 'absolute', top:0, left:0, display:'none' })
				.html('<img src="' + this.images.join('"><br><img src="') + '">')
				.appendTo('body');
			$(this.list).each(function(i) {
				$(this)
					.mouseover(function() { t.set(i); })
					.mousemove(function() { clearTimeout(t.timer); })
					.mouseout(function() { t.timer = setTimeout(function() { t.next(); }, t.interval); })
			});
			t.timer = setTimeout(function() { t.next(); }, t.interval);
		},
		set: function(i) {
			var href;
			$(this.list)
				.removeClass(this.cur)
				.eq(i)
				.addClass(this.cur)
				.find('a')
				.each(function() { href = this.href });
			if ( this.images[i] ) $(this.bg).css('background-image', 'url('+this.images[i]+')');
			if (href) $(this.bg)
				.unbind('click')
				.click(function() { location.href = href; });
			this.index = i;
			clearTimeout(this.timer);
		},
		next: function() {
			var t = this;
			this.set( (this.index + 1) % this.images.length );
			t.timer = setTimeout(function() { t.next(); }, t.interval);
		}
	}
})(jQuery);

/* -------------- /menudrop -------------- */




