	$(document).ready(function () {
		$.ajaxSetup ({  
			cache: false  
		});  		
		$(window).load(function() {
			$('#imgSlider').nivoSlider({
				effect: 'fade',
				controlNav: false,
				pauseTime: 3000,
				directionNav: false
			});
		});
		$('.thumbImage a').lightBox();
		jQuery.fn.showError = function(strMessage){
			return this.each(function(){
				$(this).html(strMessage).fadeIn('slow');
			});
		};
		$("#frmContact").submit(function (event) {
			//Check form validation
			formValid = true;
			$(":input",$(this)).not(':button, :submit, :reset, :hidden').each(function () {
				if($(this).val() == '') {
					formValid = false;
				}
			});
			if(formValid){
				$.ajax({
					   url: $(this).attr('action'),
					   data: $(this).serialize(),
					   success: function() {
							alert("Message sent to LostPlaces successfully!");
							$(':input','#frmContact').not(':button, :submit, :reset, :hidden').val('');
							d = new Date();
							$("#imgCaptcha").attr("src", "/img/captcha.jpg?"+d.getTime());		
							$(".errorMsg").fadeOut("fast");
					   },
					   error: function(xhr) {
						   if(xhr.status == 403){
								$(".errorMsg").showError('Security Image has been entered incorrectly.');
						   }
						   else {
								$(".errorMsg").showError('An error has occured when trying to send the message. Please try again later.');
						   }
					   }
				});
			}
			else {
				$(".errorMsg").showError('Please ensure all fields are completed correctly.');
			}
			event.preventDefault(); 
		});
		$(".thumbImage").mouseover(function() {
			$(this).css('background-color','#DDD')
		}).mouseout(function(){
			$(this).css('background-color','')
		});
		jQuery.fn.vAlign = function() {
			return this.each(function(){
				var ah = $(this).height();
				var ph = $(this).parent().height();
				var mh = (ph - ah) / 2;
				$(this).css('padding-top', mh);
			});
		};
		$(window).load(function () {
		  $('.thumbImage a').vAlign();
		  
		});		
	});
