

	function rotatePhoto() {	
		//Get the first image
		var current = ($('div#rotator ul li.show')?  $('div#rotator ul li.show') : $('div#rotator ul li:first'));
	
		//Get next image, when it reaches the end, rotate it back to the first image
		var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotator ul li:first') :current.next()) : $('div#rotator ul li:first'));	
		
		//Set the fade in effect for the next image, the show class has higher z-index
		next.css({opacity: 0.0})
		.addClass('show')
		.animate({opacity: 1.0}, 1000);
	
		//Hide the current image
		current.animate({opacity: 0.0}, 1000)
		.removeClass('show');
		
	}
	
	function theRotator() {
		//Set the opacity of all images to 0
		$('div#rotator ul li').css({opacity: 0.0});
		
		//Get the first image and display it (gets set to full opacity)
		$('div#rotator ul li:first').css({opacity: 1.0});
			
		//Call the rotator function to run the slideshow, 6000 = change to next image after 6 seconds
		setInterval('rotatePhoto()',4500);
	}
	
	$(document).ready(function() {
	
	
	var height = $('#blog-wrapper').height() + 20;
	if (height > 700) {
		$('#blog-side').css({height: height + 'px'});
	}
	
	function formSuccess() {
		$('#ajaxMessage').css({
				 display: 'none',
				 color: '#31474e',
				 backgroundColor: '#abeaed'
				 });
		$('#ajaxMessage').fadeIn();
	}
	
	function formFail() {
		$('#ajaxMessage').css({
				 display: 'none',
				 color: '#ff0000',
				 backgroundColor: '#820000'
				 });
		$('#ajaxMessage').fadeIn();
	}
	
	$('#contact-form').submit(function() {
	  var ajax = $('#ajaxMessage');
		var name = $('input[name="name"]').val();
		var email = $('input[name="email"]').val();
		var phone = $('input[name="phone"]').val();
		var info = $('textarea=[name="info"]').val();
		validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
		if (name.length > 1 && email.length > 4 && phone.length > 8 && email.search(validRegExp) != -1) {
			$.ajax({
				type: "POST",
				url: "contact-process.php",
				data: "name=" + name + "&email=" + email + "&phone=" + phone + "&info=" + info,
				success: function(data){
					formSuccess();
					ajax.html(data);
					return false;
				}
			});
			return false;
		} else {
			formFail();
			ajax.html('You have not completed the form correctly. Please make sure you have filled out all fields and that they are in the proper format.');
			return false;	
		}
	});
	
	
	
	
		//Load the slideshow
		theRotator();
	

});


