// JavaScript Document

//Image rotation
function imageRotate(time){
	$('.rotating_images1 img:gt(0)').hide();
	setInterval(function(){$('.rotating_images1 :first-child').fadeOut().next('img').fadeIn().end().appendTo('.rotating_images1');}, time);
	$('.rotating_images2 img:gt(0)').hide();
	setInterval(function(){$('.rotating_images2 :first-child').fadeOut().next('img').fadeIn().end().appendTo('.rotating_images2');}, time);
	$('.rotating_images3 img:gt(0)').hide();
	setInterval(function(){$('.rotating_images3 :first-child').fadeOut().next('img').fadeIn().end().appendTo('.rotating_images3');}, time);
}

//Mailing list validation
function validate_mlist(theForm){
	var error='';
	var message='';
	if(theForm.person.value.replace(/\s+/g, "")==''||theForm.person.value=='Name')error='Name\n';
	if(theForm.company.value.replace(/\s+/g, "")==''||theForm.company.value=='Company')error+='Company\n';
	if(theForm.email.value.replace(/\s+/g, "")==''||theForm.email.value=='Email Address')error+='Email\n';
	if(error!='')message='The following fields must be filled out:\n'+error+'\n';
	var emailcheck=/^[-!#\$%\*\+\/\?\|\^&{}`~\w]+(\.[-!#\$%\*\+\/\?\|\^&{}`~\w]+)*@[-\w]+(\.[-\w]+)+$/.test(theForm.email.value);
	if(!emailcheck)message+='Email address must be a well-formatted address'
	if(message!=''){alert(message);return false;}
	else{alert('Thanks for joining our list. We look forward to working with you.');return true;}
}
