function capitaliseFirstLetter(string)
{
    return string.charAt(0).toUpperCase() + string.slice(1);
}


var formSubmitted = false;
$(document).ready(function() {
	
	$('#contentWrapper').hide();
	$('#contentWrapper').show("drop", { direction: "right" }, 900); 
	$('#bg1').prepend("<img class='old bg' src='images/home.jpg' alt='BG2' width='916' height='597' />");
	var newDiv;
	var oldDiv = $('#leftcolumn a:last').attr("href");
	var oldHeight = $(oldDiv).height();
	var newHeight = $(oldDiv).height();
	var oldLinkText = "Home";
	var oldLink;
	if (formSubmitted == true){
		newDiv = $('#thanks');
		$(oldDiv).hide();
		$(newDiv).show();
		oldDiv = $(newDiv);
	}
	
	$('.confirmation').submit( function(){
		$('#thanks').hide("puff", {}, 500);
		$('#leftcolumn a:last').click();
		return false;
	});

	$('#leftcolumn a, #header a, #footer a').click(function(event) {
		if ($(this).attr('href') != $(oldLink).attr('href')) {
			

			
			
			$(this).addClass("active");
			$(this).children().show();

			newDiv = $(this).attr("href");
			newHeight = $(newDiv).height();
			$(oldDiv).fadeOut(200);
			
			
		
			$('#contentWrapper').animate({height: newHeight}, 400, function(){
				$(newDiv).fadeIn(300);
	  		});
 	
			var image = newDiv.replace('#', "");
			$('#bg1').prepend("<img class='bg' src='images/" +image+ ".jpg' alt='BG2' width='916' height='597' />");
		
			$('#bg1 img.old').fadeOut(1000, function(){
				$('#bg1 img.old').remove();
				$('#bg1 img').addClass('old');
			});
			
			//$('title').text("Loan Logistics - " + image.charAt(0).toUpperCase() + image.slice(1));
			document.title = "Loan Logistics - " + image.charAt(0).toUpperCase() + image.slice(1);
			
			$(oldLink).removeClass("active"); 
			$(oldLink).not('#header a, #footer a').children().hide();
			oldDiv = newDiv;
			oldHeight = newHeight;
			oldLink = $(this);
			oldLinkText = image;
			event.preventDefault();
			//return false;
		}else{}
	});
		
	
});