jQuery(function() {
	$('#textcontainer').jScrollPane({showAllways: false, scrollbarOnLeft: true, showArrows: true, scrollbarMargin: 23, scrollbarWidth: 8});
	if (jQuery.browser.mozilla) jQuery('.gall_images a').unbind('focus');

	var cache = {};
	jQuery('a img.hover')
		// prepare cache images
		.each(function() {
			if (this.src.indexOf('-on.') == -1) {
				var src = this.src.replace('.png', '-on.png');
				var img = jQuery('<img />').attr('src', src)[0];
				cache[src] = img;
			}
		})
		// add mouse over handlers
		.mouseover(
			function() { 
				if (this.src.indexOf('-on.') == -1) {
					var src = this.src.replace('.png', '-on.png');
					if (cache[src]) {
						this.src = cache[src].src;
					}
					else {
						this.src = src;
					}
				}
			}
		)
		.mouseout(
			function() {
				if (this.src.indexOf('-on.') != -1) {
					this.src = this.src.replace('-on.', '.'); 
				}
			}
		);
		
});

// menu
var obj = null;

function checkHover() {
	if (obj) {
		obj.find('ul').fadeOut('fast');
	} //if
} //checkHover

$(document).ready(function() {
	$('#popup > li').hover(function() {
		if (obj) {
			obj.find('ul').fadeOut('fast');
			obj = null;
		} //if
		

		var offset = $(this).offset();
		var offset1 = $('#popup').offset();
		var offset2 = $('#popup > li').offset();

		var offsetLeft = jQuery.browser.msie ? 44: 0;
		$(this).find('ul')
			.css({})
			.fadeIn('fast');
	}, function() {
		obj = $(this);
		setTimeout(
			"checkHover()",
			400);
	});
});
