	(function($) {
	  var cache = [];
	  // Arguments are image paths relative to the current page.
	  $.preLoadImages = function() {
		var args_len = arguments.length;
		for (var i = args_len; i--;) {
		  var cacheImage = document.createElement('img');
		  cacheImage.src = arguments[i];
		  cache.push(cacheImage);
		}
	  }
	})(jQuery)
	
	var flashObject = null;
	//Sends back the flashObject
	function getFlashMovieObject(movieName)
	{
		if (window.document[movieName])
		{
			return window.document[movieName];
		}
		if (navigator.appName.indexOf("Microsoft Internet")==-1)
		{
			if (document.embeds && document.embeds[movieName])
				return document.embeds[movieName];
		}
		else // if (navigator.appName.indexOf("Microsoft Internet")!=-1)
		{
			return document.getElementById(movieName);
		}
	}

	var isLoaded = false;
	//Sets the flash object.
	function flashLoaded(loaded)
	{
		isLoaded = loaded;
		flashObject = getFlashMovieObject("SlideShow");
	
		if(flashObject == null)
		{
			alert("ERROR");
		}
	}

	//Call this function to stop the movie.
	function stopVideo()
	{
		if(isLoaded)
			flashObject.stopVideo();
	}

	//Call this function to stop the movie.
	function playVideo()
	{
		if(isLoaded)
			flashObject.playVideo();
	}
	
	
	
	$(document).ready(function(){
		$("#mainPage").show();
		$(".navButton").bind('mouseover', function()
		{
			$(".navButton").each(function()
			{
				$(this).css('color', 'white');
				$(this).css('background-image', 'url("assets/images/ButtonBackground.png")');
			});
			$(".mainContent").each(function()
			{
				$(this).hide();
			});
			switch($(this).attr('id'))
			{
				case 'mainButton': $("#mainPage").show();break;
				case 'softwareButton': $("#ourSoftware").show();break;
				case 'wisdomButton': $("#wisdom").show();break;	
				case 'demoButton': $("#demo").show();break;	
				case 'tourButton': $("#tour").show();break;	
				case 'tutorialButton': $("#tutorial").show();break;	
				case 'goalsButton': $("#goals").show();break;	
				case 'whereButton': $("#where").show();break;	
				case 'whatButton': $("#what").show();break;	
				case 'periodButton': $("#period").show();break;	
				case 'dashboardButton': $("#dashboard").show();break;	
				case 'trendsButton': $("#trends").show();break;	
				case 'whatIfButton': $("#whatIf").show();break;	
				case 'actualButton': $("#actual").show();break;	
			}
			
			$(this).css('color', 'green');
			$(this).css('background-image', 'url("assets/images/buttonHighlight.png")');
			
		});
		
		$(".wisdomNumber").bind('mouseover', function()
		{
			$(".wisdomNumber").each(function()
			{
				$(this).css('background-image', 'url("assets/images/wisdomBackground.png")');
			});
			
			$(this).css('background-image', 'url("assets/images/wisdomBackgroundHighlight.png")');
			
			switch($(this).attr('id'))
			{
				case '1': $('#wisdomHolder').html('Know Where You Are Spending Your Money');break;
				case '2': $('#wisdomHolder').html('Stop Wasting Money On Stuff You Don\'t Need');break;
				case '3': $('#wisdomHolder').html('Spend Less Than You Need To');break;
				case '4': $('#wisdomHolder').html('Create a Plan to Eliminate Debt');break;
				case '5': $('#wisdomHolder').html('Build Up an Emergency Fund');break;
				case '6': $('#wisdomHolder').html('Get Ready for Retirement');break;
				case '7': $('#wisdomHolder').html('Save, Save, Save!');break;	
			}
		});
		
		$('#tourVideoButton').bind('mouseover', function()
		{
			$(this).attr('src', 'assets/images/tourButtonHighlight.png');
		});
		$('#tourVideoButton').bind('mouseleave', function()
		{
			$(this).attr('src', 'assets/images/tourButton.png');
		});
		$('#tourVideoButton').bind('click', function()
		{
			$("#divOverlay").show();$("#tourMovie").show();playVideo();
		});
		
		$("#closeButton").bind('click', function()
		{
			$("#divOverlay").hide();$("#tourMovie").hide();stopVideo();
		});
		
		$.preLoadImages("assets/images/buttonHighlight.png", "assets/images/wisdomBackgroundHighlight.png", "assets/images/tourButtonHighlight.png");
	});
