﻿// contact form validation
window.onload = function(){
	if(document.getElementById('sender')){
		document.getElementById('sender').onsubmit = function(){
			var t = this.origin.value;
			if(t == ''){
				alert('We need your email so we can reply to your message.');
				this.origin.focus();
				return false;
			}else if(t.indexOf('@') == -1 || t.indexOf('.') == -1){
				alert('Invalid email format.');
				this.origin.focus();
				return false;
			}
			if(this.topic.value == ''){
				alert('Please enter a subject.');
				this.topic.focus();
				return false;
			}
			if(this.mbody.value.length < 20){
				alert('Message too short.');
				this.mbody.focus();
				return false;
			}
			return true;
		}
	}
}

var lim, cur;

function slideinit(){
	// Start it off clean.
	document.getElementById('intro').style.left = 0;
	window.setTimeout('slide(1)', 5000);
}

function slide(n){
	if(n<10){
		lim = -681 * n;
		prev = lim - 681;
		cur = parseInt(document.getElementById('intro').style.left);
		if(cur > lim){
			with(Math) incr = max(abs(floor((abs(cur)-abs(prev))/25)),4);
			//window.status = 'cur=' + cur + ' and testnew = ' + testnew;
			testnew = cur - incr;
			if(testnew < lim) testnew = lim;
			document.getElementById('intro').style.left = testnew + 'px';
			window.setTimeout('slide('+n+')', 20);
		}else{
			n++;
			window.setTimeout('slide('+n+')', 5000);
		}
	}else{
		
	}
}

// nothing to see here