jQuery(document).ready(function() {

//////////////   HOMEPAGE GALLERY ////////////
	// show the gallery holder as images have loaded into the page
	$('.gallery-holder .stgslide').css({"display": "block"});


// home top stage
    $('.gallery-holder .stgslide').cycle({
        fx: 'fade',
		timeout: 8000,
		speed: 1000,
        before: onBefore,
        next:   '#next', 
    	prev:   '#prev'
    });

/*	$('.gallery-holder .stgbtngrp .stgbtnoff').click(function(){
		$('.gallery-holder .stgslide').cycle('stop');
	});*/
	
	
	$('.gallery-holder #next').click(function(){
		$('.gallery-holder .stgslide').cycle('stop');
	});
	
	$('.gallery-holder #prev2').click(function(){
		$('.gallery-holder .stgslide').cycle('stop');
	});

});





$.fn.cycle.updateActivePagerLink = function(pager, currSlideIndex) {
    $(pager).find('div').removeClass('stgbtnon')
        .filter('div:eq(' + currSlideIndex + ')').addClass('stgbtnon');
};




jQuery(document).ready(function() {

	var _tips = $('div.map-tooltop');
	
	$('ul.map-list a').each(function(){
		var _pos = $(this).offset();
		var _id = this.href.substr(this.href.indexOf('#'));
		var _timer;
		$(_id).css({
			top:_pos.top-50,
			left:_pos.left
		})
		$(this).mouseenter(function(){
			if (_timer) clearTimeout(_timer);
			_tips.hide();
			$(_id).fadeIn(0);
		}).mouseleave(function(){
			_timer = setTimeout(function(){
				hideTip();
			},0);
		});
		$(_id).mouseenter(function(){
			if (_timer) clearTimeout(_timer);
		}).mouseleave(function(){
			_timer = setTimeout(function(){	hideTip();},100);
		});
		function hideTip(){
			$(_id).hide();
		}
	});

});



function onBefore() {
	$('.stghrimg').html($('.stgslideheading', this).html());
	$('.stghrtxt').html($('.stgslidecontent', this).html());
	$('.stgcredit').html($('.stgslidecredit', this).html());
}



