
	var rotateTime = 10000;
	var features = ['allinone', 'qualitydesign', 'contentediting', 'webhosting', 'statistics'];
	
	function autoRotate() {
		if (window.location.hash == '') {
			// figure out what section is currently selected...
			var num = $('#features-content').find('.selected').attr('id').replace(/feature-/ig, '');
			$('#feature-' + num + '-nav').parents('ul:first').find('li').removeClass('selected');
			$('.feature').removeClass('selected').hide();
			// reset if we've reached the last feature
			if (num >= features.length)
				num = 0;
			// increment so we can choose the next feature
			num++;
			// then rotate to the next one
			$('#feature-' + num).addClass('selected').hide().fadeIn(500, function() {
				$('#feature-' + num + '-nav').addClass('selected');
			});
			// setTimeout to run autorotate again in 5 seconds
			setTimeout(autoRotate, rotateTime);
		}
	}
	
	function selectFeature(num) {
		$('#feature-' + num + '-nav').parents('ul:first').find('li').removeClass('selected');
		$('.feature').removeClass('selected').hide();
		$('#feature-' + num).addClass('selected').hide().fadeIn(500, function() {
			$('#feature-' + num + '-nav').addClass('selected');
		});
		window.location.hash = "#" + features[num-1];
	} // selectFeature
	
	function validateForm() {
		var errors = false;
		$('form').find('label, input').removeClass('required');
		
		if ($('#contact_name').get(0).value == '') {
			errors = true;
			$('#contact_name').addClass('required').parent().find('label').addClass('required');
		}
		if ($('#contact_email').get(0).value == '') {
			errors = true;
			$('#contact_email').addClass('required').parent().find('label').addClass('required');
		}
		if ($('#contact_message').get(0).value == '') {
			errors = true;
			$('#contact_message').addClass('required').parent().find('label').addClass('required');
		}
		
		return !errors;
	} // validateForm
	
	$(function() {
		/*if (window.location.hash == '#' + features[0]) {
			window.location.hash = '#';
		} else */if (window.location.hash != '') {
			for (num in features) {
				if (('#' + features[num]) == window.location.hash) {
					num++;
					$('#feature-' + num + '-nav').parents('ul:first').find('li').removeClass('selected');
					$('.feature').removeClass('selected').hide();
					$('#feature-' + num).addClass('selected');
					$('#feature-' + num + '-nav').addClass('selected');
				}
			}
		} else {
			setTimeout(autoRotate, rotateTime);
		}
	});
