jQuery(function() {

	// Options for SuperBGImage
	jQuery.fn.superbgimage.options = {
		id: 'superbgimage', // id for the containter
		z_index: 0, // z-index for the container
		inlineMode: 0, // 0-resize to browser size, 1-do not resize to browser-size
		showimage: 1, // number of first image to display
		vertical_center: 1, // 0-align top, 1-center vertical
		transition: 6, // 0-none, 1-fade, 2-slide down, 3-slide left, 4-slide top, 5-slide right, 6-blind horizontal, 7-blind vertical, 90-slide right/left, 91-slide top/down
		transitionout: 1, // 0-no transition for previous image, 1-transition for previous image
		randomtransition: 0, // 0-none, 1-use random transition (0-7)
		showtitle: 0, // 0-none, 1-show title
		slideshow: 0, // 0-none, 1-autostart slideshow
		slide_interval: 5000, // interval for the slideshow
		randomimage: 0, // 0-none, 1-random image
		speed: 'slow', // animation speed
		preload: 1, // 0-none, 1-preload images
		onShow: superbgimage_show, // function-callback show image
		onClick: superbgimage_click, // function-callback click image
		onHide: superbgimage_hide, // function-callback hide image
		onMousemove: superbgimage_mousemove // function-callback mousemove
	};

	// initialize SuperBGImage
	jQuery('#thumbs1').superbgimage();

});

// function callback on hiding image
function superbgimage_hide(img) {
	jQuery('#showtitle').hide();
}

// function callback on showing image
// get title and display it
function superbgimage_show(img) {
	jQuery('#superbgimage').css('background', 'none');
	jQuery('#superbgimage').append(jQuery('#showtitle'));
	jQuery('#showtitle p.imagecount').html('image ' + img + ' of ' + jQuery.superbg_imgIndex);
	if (jQuery('#thumbs1').css('display') == 'block') {
		jQuery('#showtitle p.title').html(jQuery('#thumbs1 a' + "[rel='" + img + "']").attr('title'));
	} else {
		jQuery('#showtitle p.title').html(jQuery('#thumbs2 a' + "[rel='" + img + "']").attr('title'));
	}
	jQuery('#showtitle').fadeIn('fast');
}

// function callback on clicking image, show next slide
function superbgimage_click(img) {
	jQuery('#thumbs').nextSlide();
}

my_slideshowActive = false;

// function callback onmousemove, show and move pause-indicator
function superbgimage_mousemove(img, e) {
	if (my_slideshowActive && (jQuery('#pause').length > 0)) { 
		jQuery("#pause").css("top",(e.pageY + 20) + "px").css("left",(e.pageX + 20) + "px").show();
	}
}


jQuery(function() {

	function update_superbgOptions() {
		// speed
		var newspeed = 'slow';
		var newinterval = 4000;
		var newtransitionout = 0;
		var newrandomtransition = 0;
		var newrandomimage = 0;
	}

	// hide other sets except the 1st
	jQuery("#thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10").hide().addClass('hidden');

	// prev slide
	jQuery('a.prev').click(function() {
		return jQuery('#thumbs').prevSlide();
	});

	// next slide
	jQuery('a.next').click(function() {
		return jQuery('#thumbs').nextSlide();
	});

	// start slideshow
	jQuery('a.start').click(function() {
		update_superbgOptions();
		return jQuery('#thumbs').startSlideShow();
	});

	// stop slideshow
	jQuery('a.stop').click(function() {
		my_slideshowActive = false;
		return jQuery('#thumbs').stopSlideShow();
	});

	// load image set 1
	jQuery('a.loadset1').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs1').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').hide().addClass('hidden');
		return false;
	});

	// load image set 2
	jQuery('a.loadset2').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs2').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs1, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').hide().addClass('hidden');
		return false;
	});
	
	// load image set 3
	jQuery('a.loadset3').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs3').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs1, #thumbs2, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').hide().addClass('hidden');
		return false;
	});

	// load image set 4
	jQuery('a.loadset4').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs4').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').hide().addClass('hidden');
		return false;
	});

	// load image set 5
	jQuery('a.loadset5').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs5').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').hide().addClass('hidden');
		return false;
	});

	// load image set 6
	jQuery('a.loadset6').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs6').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs7, #thumbs8, #thumbs9, #thumbs10').hide().addClass('hidden');
		return false;
	});

	// load image set 7
	jQuery('a.loadset7').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs7').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs8, #thumbs9, #thumbs10').hide().addClass('hidden');
		return false;
	});

	// load image set 8
	jQuery('a.loadset8').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs8').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs9, #thumbs10').hide().addClass('hidden');
		return false;
	});

	// load image set 9
	jQuery('a.loadset9').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs9').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs10').hide().addClass('hidden');
		return false;
	});

	// load image set 10
	jQuery('a.loadset10').click(function(){
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9, #thumbs10').stopSlideShow();
		my_slideshowActive = false;
		jQuery('#showtitle').hide();
		jQuery('#thumbs10').superbgimage({ reload: true }).show().removeClass('hidden');
		jQuery('#thumbs1, #thumbs2, #thumbs3, #thumbs4, #thumbs5, #thumbs6, #thumbs7, #thumbs8, #thumbs9').hide().addClass('hidden');
		return false;
	});

	// toggle overlay
	jQuery("h1 a").click(function() {
		jQuery(this).blur();
		if (jQuery("#overlay").hasClass('hidden')) {
			jQuery("#overlay").css('height','auto').removeClass('hidden').children().show();
			if (jQuery('#thumbs1').hasClass('hidden')) {
				jQuery('#thumbs1').hide();
			}
			if (jQuery('#thumbs2').hasClass('hidden')) {
				jQuery('#thumbs2').hide();
			}
			if (jQuery('#thumbs3').hasClass('hidden')) {
				jQuery('#thumbs3').hide();
			}
			if (jQuery('#thumbs4').hasClass('hidden')) {
				jQuery('#thumbs4').hide();
			}
			if (jQuery('#thumbs5').hasClass('hidden')) {
				jQuery('#thumbs5').hide();
			}
			if (jQuery('#thumbs6').hasClass('hidden')) {
				jQuery('#thumbs6').hide();
			}
			if (jQuery('#thumbs7').hasClass('hidden')) {
				jQuery('#thumbs7').hide();
			}
			if (jQuery('#thumbs8').hasClass('hidden')) {
				jQuery('#thumbs8').hide();
			}
			if (jQuery('#thumbs9').hasClass('hidden')) {
				jQuery('#thumbs9').hide();
			}
			if (jQuery('#thumbs10').hasClass('hidden')) {
				jQuery('#thumbs10').hide();
			}
		} else {
			jQuery("#overlay").css('height','100px').addClass('hidden').children().hide();
			jQuery("h1").show();
		}
		return false;
	});	
	
});

// Update gallery menu

jQuery(document).ready(function(){
jQuery('.control ul li').find('a').click(menu);function menu(){jQuery(this).parents('ul:first').find('a').removeClass('activegallery').end().end().addClass('activegallery');}
function trigger(data){var el=jQuery('.control ul li').find('a[hrefjQuery="'+data.id+'"]').get(0);menu.call(el);}
if(!window.location.hash){jQuery('.control ul li a:first').click();}});

// Triggers

jQuery(document).ready(function(){
	jQuery(".trigger").click(function(){
		jQuery(".panel").toggle("fast");
		jQuery(this).toggleClass("active");
		return false;
	});
});
jQuery(document).ready(function(){
	jQuery(".trigger_right, .close").click(function(){
		jQuery(".panel_right").toggle();
		jQuery(this).toggleClass("active");
		return false;
	});
});

