var y = 0;
var g = 0;
var q = 5;

function changeheight(){
 if(y>170&&g==0){g=1;return;}
 if(y<5&&g==1){g=0;return;}
 if(g)q=-5;if(!g)q=5;y=y+q;
 e=document.getElementById("u");
 e.style.height = y + 'px';
  t=setTimeout("changeheight();",0);
}
function wipe(){
	window.status="ReactImagery Contact Form";
}
//Email validation Start
function validEmail(email) {
invalidChars = " /:,;"
//checking for an empty text box
if (email =="") {
return false
}
//checks for invalid characters within the email
for (i=0; i<invalidChars.length; i++) {
 badChar = invalidChars.charAt(i)
  if (email.indexOf(badChar, 0) > -1) {
   return false
   }
}
//checking for "@" symbol
atPos = email.indexOf("@",1)
 if (atPos == -1) {
  return false
  }
  //checking for unnecessary "@" symbols
  if (email.indexOf("@", atPos+1) != -1) {
  return false
  }
//checking for a period
periodPos = email.indexOf(".",atPos)
 if(periodPos == -1) {
 return false
 }
 //checking for at least two characters after the period
 if (periodPos+3 > email.length) {
 return false;
 }
 return true;
}
//Email validation end

//onSubmit the form will be validated with the below function
// (re) is a regular expression for the phone validation and formatting

re = /^\(?(\d{3})\)?[\.\-\/ ]?(\d{3})[\.\-\/ ]?(\d{4})$/

function validator(work_form) {
var hidden_value = work_form.react_form.value;
var name = work_form.first_name.value;
var project = work_form.body_area.value;

//validation for name text box
if (name == "") {
alert ("Please enter your full name");
//place blinking cursor
work_form.first_name.focus();
work_form.first_name.select();
return false;
}

//validation for email address
  if (!validEmail(work_form.client_email.value)) {
  alert("Your email address is invalid...");
  work_form.client_email.focus();
  work_form.client_email.select();
  return false;
  }

//phone correction and validation
/*
validPhone = re.exec(work_form.phone.value)
if (validPhone) {
  work_form.phone.value = "(" + validPhone[1] + ") " + validPhone[2] + "-" + validPhone[3]
			}
			else {
				alert(work_form.phone.value + " isn't a valid US phone number")
				work_form.phone.focus()
				work_form.phone.select()
			return false;
			}
*/
//validation for Pull-down menu
theService = work_form.service_type.selectedIndex
  if (work_form.service_type.options[theService].value =="") {
  alert("You must select a type of service...");
  return false;
  }


//validation for project description
if (project == "") {
alert ("Describe the type of work you want done...");
work_form.body_area.select();
work_form.body_area.focus();
return false;
}
//Urgency level validation
/*
    urgencyOption = -1
			for (i=0; i<work_form.level.length; i++) {
				if (work_form.level[i].checked) {
					urgencyOption = i
				}
			}
			if (urgencyOption == -1) {
				alert("You must choose a level of urgency...")
				return false
			}
*/
//when form is correct this alert will come up, thanking the user
//alert ("Thank you " + work_form.first_name.value + ", now submitting...");
return true;
}
function validate() {
//example of directly calling form values
var hidden_value = document.work_form.react_form.value;
 }