function initNewPhotogalleries() {
	loaded = 0;
	total = $('.new_photogalleries_thumbnail').length;
	
	$('.new_photogalleries_thumbnail').each(function(){
		if ($(this).attr('complete') == true) loaded++;
		
	});
	if (loaded == total) {
		$('#imageSlider1').imageSlider({
			captionElement: '#caption1'
		});
	} else {
		setTimeout(function() {initNewPhotogalleries();}, 30);
	}
	
}


$(document).ready(function(){
	$('.tabNav li a').hover(function(){
		var _parent = $(this).parent().parent(); 
		_parent.find('.active').removeClass('active');
		_parent.siblings('.activeTab').removeClass('activeTab');
		_parent.siblings('.box').eq($(this).parent().index()).addClass('activeTab');
		$(this).addClass('active');
	});
	
	$('#cycle').parent().prev('h2').append('<div id="cyclePager"/>');
	$('#cycle').cycle({
		pager: '#cyclePager',
		pause: 1,
		before: function(curr, next, opts){
			// console.log(opts.currSlide);
			$('#cycleCounter').html(opts.currSlide+1 + '/' + $('#cycle div').length);
		}
	});
	$('#no_use').hover(function(){
		$('#cycleNav').stop().fadeTo(500, 1);
	}, function(){
		$('#cycleNav').stop().fadeTo(500, 0);
	});
	
	initNewPhotogalleries();
});	

