$(document).ready(function(){
						   
	// Preload images
	

	$('img#bgimg').fadeIn(3000);
	
	$('#realBody').before('<div class="mask"></div>');
	$('.mask').animate({opacity: 1.0}, 500)
	.fadeOut('slow');
	
	
	// About Us Drop downs
	
	$('div.drop-container').hide();
	$('div.first').show();
	$('a.dropdown').click(function(){
		$(this).next('.drop-container').slideToggle('slow');
		$(this).toggleClass("up");
	});
	
	
	// Team Drop downs
	
	$('div.toggle').hide();
	$('a.showhide').click(function() {
		$(this).prev('.toggle').slideToggle('slow');
		$(this).text($(this).text() == 'Show Less...' ? 'Show More...' : 'Show Less...');
    	return false;
	});
	
	
	item_count = $("div.slideshow-item").size();

	$("div.slideshow-item").each(function(i) {
    	$(this).hide();
	});

	$("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");

	item_interval = setInterval(item_rotate, interval_time); // time in milliseconds
	
	$('#slideshow-container').hover(function() {
		clearInterval(item_interval);
	}, function() {
		item_interval = setInterval(item_rotate, interval_time); //time in milliseconds
		item_rotate();
	});
	
});

var interval_time = 10000; // 3 seconds between changes
var item_count;
var item_interval;
var old_item = 0;
var current_item = 0;

function item_rotate() {
	current_item = (old_item + 1) % item_count;
	$("div.slideshow-item:eq(" + old_item + ")").fadeOut("slow", function() {
		$("div.slideshow-item:eq(" + current_item + ")").fadeIn("slow");
	});
	old_item = current_item;
};
