var auto = true;
var count = 1;
var countLast = 1;	
var totalBanner;

$(document).ready(function() {
	// Carousel
	totalBanner = $('.preview').length;
	fadeInOutAuto();

	// Fancybox
	$("a.fancybox").fancybox({
		'hideOnContentClick': true,
		'overlayShow': true,
		'overlayOpacity': 0.85,
		'padding': 0
	});

	// Transparent PNG in IE 5.5 and 6.
	$(document).pngFix();
});

function show(ref) {
	if (ref != count) {
		$('.belt ul li a').removeClass('active');
		imageLast = ".list"+countLast;
		$(imageLast).fadeOut(1000);	
		count = ref;	
		countLast = count;	
		activecurrentli = ".listli" + ref;
		$(activecurrentli).addClass('active');
		imageShow = ".list"+count;
		$(imageShow).fadeIn(500);	
	}
}

function fadeInOutAuto() {	
	if(count == (totalBanner+1)) {
		count = 1; 
	}

	if(countLast != count) {
		imageLast = ".list" + countLast;	
		$(imageLast).fadeOut(100);
	}

	$('ul li a').removeClass('active');
	imageShow = ".list" + count;
	$(imageShow).fadeIn(500);
	activecurrentli = ".listli" + count;
	$(activecurrentli).addClass('active');
	countLast = count;	
	count++;
	auto = setTimeout("fadeInOutAuto();", 3000);
}
