$(document).ready(function() {
	$('#slideshow').cycle({
		fx: 'fade', // choose your transition type, ex: fade, scrollUp, shuffle, etc...
		speed: 1000,
		timeout: 4000
	});
	$('.newsItems').jCarouselLite({
		auto: 4000,
		speed: 500,
		vertical: 'true',
		circular: 'true',
		visible: 1
	});
});

function checkContactForm(that) {
	var errmsg = '';
	if (that.name.value.length < 1) {
		errmsg += '-> Name cannot be blank\n';
	}
	if (that.email.value.length < 1) {
		errmsg += '-> E-mail cannot be blank\n';
	} else {
		if (!isValidEmail(that.email.value)) {
			errmsg += '-> E-mail address is invalid\n';
		}
	}
	if (that.comments.value.length < 1) {
		errmsg += '-> Comments cannot be blank\n';
	}
	if (errmsg.length > 1) {
		alert('Please fix the following errors:\n\n'+errmsg);
		return false;
	} else {
		return true;
	}
}

function isValidEmail(address) {
	if (address != '' && address.search) {
		if (address.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1) {
			return true;
		} else {
			return false;
		}
	} else {
		return true;
	}
}

