$(document).ready(function(){
	
	$('a.colorbox').colorbox({
		maxWidth : '90%',
		maxHeight : '90%',
		minWidth : 630,
		minHeight : 660
	});
	
	$('a.youtube').colorbox({
		width : 700,
		height : 550,
		iframe : true
	});
	
	$('a.legalbox').colorbox({
		width : 700,
		height : 550,
		iframe : true
	});
	
	slideshowSet = function(n) {
		var activeSlide = $('#slideshow img.active');
		var nextSlide = $('#slideshow img[rel=' + n + ']');
		activeSlide.addClass('last-active');
		$('#SSHOW_CURRENT').val(n);
		nextSlide.css({ opacity : 0.0 }).addClass('active').animate(
			{ opacity : 1.0 }, 1000, function(){
			activeSlide.removeClass('active last-active');
		});
	}
	
	if (parseInt($('#SSHOW_TOTAL').val()) > 1) {
		var slideInterval = setInterval(function(){
			var currentSlide = parseInt($('#SSHOW_CURRENT').val());
			var nextSlide = (1 + currentSlide);
			if ($('#slideshow img[rel=' + nextSlide + ']').length > 0) {
				slideshowSet(nextSlide);
			} else {
				slideshowSet(1);
			}
		}, $('#SSHOW_SECS').val());
	}
	
});
