// Javascript Functions

$(document).ready(function() {
	

	
	// Hide secondary div
	$("#secondary").hide();

	
	// bind click to secondary show button
	$("#secondaryShow").bind("click", function(e) {
		$("#secondaryShow").fadeOut("slow", function(){
			$('#secondary').slideDown("normal");
			
		});
		return false;
		
		
	});
	
	// Set the navigation rollover
    $("#NavigationContainer ul li img").hover(function(event) {
        MM_swapImage(event.target.id, '', 'resources/images/navigation/over/' + event.target.id + '.png', 1);
    },
    function(e) {
        MM_swapImgRestore(e);
    });

	// Set the headline button's rollover
    $("#try-it-free-button, #see-more-button").hover(function(event) {
        MM_swapImage(event.target.id, '', 'resources/images/' + event.target.id + '-down.jpg', 1);
    },
    function(e) {
        MM_swapImgRestore(e);
    });
	
	// Begin preloading navigation images
	MM_preloadImages('resources/images/navigation/over/home.png',
	'resources/images/navigation/over/products.png',
	'resources/images/news.png',
	'resources/images/navigation/over/support.png');
	
	// Start rotating banner
	if ($('#rotatingImage').length == 1) {
		setInterval(rotateNext, 6500);
	}
	
	
	// Show the first banner image
	$('#rotatingImage').fadeIn("show");
	
	// Set up any rollover and preloading on classes marked, preload
	$('.preload img').each(function(event) {
		preload('resources/images/' + this.id + '-down.jpg');
	})
	$('.preload img').hover(function(event) {
        MM_swapImage(event.target.id, '', 'resources/images/' + event.target.id + '-down.jpg', 1);
    },
    function(e) {
        MM_swapImgRestore(e);
    });
	
	
});

// Function used to preload images
function preload(url) 

{

heavyImage = new Image(); 
heavyImage.src = url;

}