// script to fade in text on homepage
// adapted from this site: http://www.webdeveloper.com/forum/showthread.php?t=193657 by Kenrick Jorus, programmer extraordinaire!
//6-20-09
hex1=255 // Initial color value.
hex2=255 // Initial color value.
hex3=255 // Initial color value.
hex4=255 // Initial color value.
hex5=255 // Initial color value.


function fadetext(){ 
	if(hex1 > 0) { //If color is not black yet
		hex1-=10; // increase color darkness
		document.getElementById("sample1").style.color="rgb("+hex1+","+hex1+","+hex1+")";
	}
	else	if(hex2 > 0) { //If color is not black yet
		hex2-=10; // increase color darkness
		document.getElementById("sample2").style.color="rgb("+hex2+","+hex2+","+hex2+")";
	}
	else	if(hex3 > 0) { //If color is not black yet
		hex3-=10; // increase color darkness
		document.getElementById("sample3").style.color="rgb("+hex3+","+hex3+","+hex3+")";
	}
	else	if(hex4 > 0) { //If color is not black yet
		hex4-=10; // increase color darkness
		document.getElementById("sample4").style.color="rgb("+hex4+","+hex4+","+hex4+")";
	}
	else	if(hex5 > 0) { //If color is not black yet
		hex5-=10; // increase color darkness
		document.getElementById("sample5").style.color="rgb("+hex5+","+hex5+","+hex5+")";
	}
	setTimeout("fadetext()",50); 
}

	/*
	function name: checkForm()
	purpose: To validate the contact information on the appointment form
	author: Lisa Bradley
	date: 3/19/09
	parameters: none
	*/
	function checkForm() {
			
		// declare variable for email
		var email = document.forms[0].elements[3].value;
		// more variables for check email
		var AtPos = email.indexOf("@");
		var StopPos = email.lastIndexOf(".");
		var form;
						
		//check to make sure name is filled in
		if (document.forms[0].elements[2].value == ""){
			alert("Please enter your name.");
			document.forms[0].elements[2].select();
			document.forms[0].elements[2].focus();
			return false; //stops processing of form
		} //end if
				
		// check to make sure email address is filled in
		if (document.forms[0].elements[3].value == ""){
			alert("You must enter your email address to use this form.");
			document.forms[0].elements[3].select();
			document.forms[0].elements[3].focus();
			return false; //stops processing of form
		} //end if
		
		// check that email address is valid, if filled in
		if (document.forms[0].elements[3].value != "") {
			if (AtPos == -1 || StopPos == -1) {
				alert ("Please enter a valid email address.");
				document.forms[0].elements[3].select();
				document.forms[0].elements[3].focus();
				return false;
			}// end if
		} // end if
									
		
		if (document.forms[0].elements[4].value == "") {
			alert("Please let us know when you are available for an appointment.");
			document.forms[0].elements[4].select();
			document.forms[0].elements[4].focus();
			return false; //stops processing of form
		} // end if
		
		return true;	
	} // end checkForm function
	

/* 
used to correct drop-down menu for IE 6, got at http://htmldog.com/articles/suckerfish/dropdowns/
*/
sfHover = function() {
	var sfEls = document.getElementById("navbar").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" hover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" hover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);