function clickClear(thisfield, defaulttext) {
	if (thisfield.value == defaulttext) {
		thisfield.value = "";
	}
}
function clickRecall(thisfield, defaulttext) {
	if (thisfield.value == "") {
		thisfield.value = defaulttext;
	}
}
function FormValidate() {
	//Validate 3-part phone number
	if(document.contactForm.contactPhone1.value.search(/^\d{3}$/) ==-1 ||
	   document.contactForm.contactPhone2.value.search(/^\d{3}$/) ==-1 ||
	   document.contactForm.contactPhone3.value.search(/^\d{4}$/) ==-1){
		alert("Please enter a valid phone number.");
		return false;
	}
}

var image_index = 0;
image_list = new Array();
image_list[image_index++] = new imageItem("http://ssdisabilityapplication.com/images/rotate1.jpg");
image_list[image_index++] = new imageItem("http://ssdisabilityapplication.com/images/rotate2.jpg");
image_list[image_index++] = new imageItem("http://ssdisabilityapplication.com/images/rotate3.jpg");
image_list[image_index++] = new imageItem("http://ssdisabilityapplication.com/images/rotate4.jpg");
image_list[image_index++] = new imageItem("http://ssdisabilityapplication.com/images/rotate5.jpg");
image_list[image_index++] = new imageItem("http://ssdisabilityapplication.com/images/rotate6.jpg");
var number_of_image = image_list.length;

function imageItem(image_location) {
	this.image_item = new Image();
	this.image_item.src = image_location;
}

function get_ImageItemLocation(imageObj) {
	return(imageObj.image_item.src)
}

function generate(x, y) {
	var range = y - x + 1;
	return Math.floor(Math.random() * range) + x;
}

function getNextImage() {
	image_index = (image_index+1) % number_of_image;
	var new_image = get_ImageItemLocation(image_list[image_index]);
	return(new_image);
}

function setOpacity(place, opacity) {
	opacity = (opacity == 100)?99.999:opacity;
	opacity = (opacity < 0)?0:opacity;
	document[place].style.filter = "alpha(opacity:"+opacity+")"; // IE/Win
	document[place].style.KHTMLOpacity = opacity/100; // Safari<1.2, Konqueror
	document[place].style.MozOpacity = opacity/100; // Older Mozilla and Firefox
	document[place].style.opacity = opacity/100; // Safari 1.2, newer Firefox and Mozilla, CSS3
}

function fadeIn(place,opacity) {
	if (opacity <= 100) {
		setOpacity(place, opacity);
		opacity += 5;
		window.setTimeout("fadeIn('"+place+"',"+opacity+")", 50);
	}
}

function fadeOut(place, opacity) {
	if (opacity > 0) {
		setOpacity(place, opacity);
		opacity -= 5;
		window.setTimeout("fadeOut('"+place+"',"+opacity+")", 25);
	} else {
		//Switch Images
		var new_image = getNextImage();
		document[place].src = new_image;
		//fade in new image
		fadeIn(place, 0);
		var recur_call = "rotateImage('"+place+"')";
		setTimeout("rotateImage('"+place+"')", 10000); //Time until next image rotation
	}
}		

function rotateImage(place) {
	//fade out current image
	//document[place].style.opacity = 1;
	fadeOut(place, 100);
}