$(document).ready(function(){
	
	if (typeof $().slideShow == 'function') {
		$('#gallery').slideShow({	
			slideEl:'ul.list li',		
			linkNext:false,		
			linkPrev:false,		
			linkPause:false,		
			numElementLink:'ul.paging a',		
			duration:500
		});
	}
	if (typeof $().slideShow == 'function') {
		$('#bigimg').slideShow({	
			slideEl:'ul.list li',		
			linkNext:false,		
			linkPrev:false,		
			linkPause:false,		
			numElementLink:'ul.paging a',		
			duration:200
		});
	}
	
	
	
	// popups ******************************************************************
	$('div.text ul.list li:has(div.popup)').each(function () {
		var distance = 10;
		var time = 250;
		var hideDelay = 200;

		var hideDelayTimer = null;

		var shown = false;
		var trigger = $('a.link', this);
		var info = $('div.popup', this);
		
		info.show();
		var _height = info.outerHeight() - 15;
		info.hide();
		var _animate = {top: '-=' + distance + 'px'}
		var _animate2 = {top: '-=' + distance + 'px'}
		
		if (!$.browser.msie) {
			info.css('opacity', 0);
			_animate = {top: '-=' + distance + 'px', opacity: 1};
			_animate2 = {top: '-=' + distance + 'px', opacity: 0};
		}
		info.css({top: -_height});
		
		$([trigger.get(0), info.get(0)]).mouseover(function () {
			if (hideDelayTimer) clearTimeout(hideDelayTimer);
			if (!shown) {
				info.show().css({top: -_height}).animate(_animate, {duration:time, queue:false});
				shown = true;
			}
			
		}).mouseout(function () {
			hideDelayTimer = setTimeout(function () {
				info.animate(_animate2, {duration:time, queue:false, complete:function(){
					info.hide().css({top: -_height});
					shown = false;
				}});
			}, hideDelay);
		});
	});

});
