function dEI(obj){
	return document.getElementById(obj);
}

function validateform(form){
	var fname = dEI('f_name').value;
	var lname = dEI('l_name').value;
	var email = dEI('email').value;
	var schooltype = dEI('school_select').value;
	//
	var err = false;
	var errs = '';
	//
	if(fname == ''){
		err = true;
		errs = errs + "Missing First Name\n";
	}
	if(lname == ''){
		err = true;
		errs = errs + "Missing Last Name\n";
	}
	if(email == ''){
		err = true;
		errs = errs + "Missing Email Address\n"
	}
	if(email.indexOf('@') == -1 || email.indexOf('.') == -1 || email.charAt(1) == '.' || email.charAt(0) == '@' || email.length < 7 || email.charAt(email.length -1) == '.'){
		err = true;
		errs = errs + "Email Isn't In Real Format\n";
	}
	if(err == true){
		alert("Problems In the Form:\n" + errs);
	} else {
		dEI(form).submit();
	}
}

function validateform2(form){
	var uaddress = dEI('u_address').value;
	var ucity = dEI('u_city').value;
	var ustate = dEI('u_state').value;
	var uzip = dEI('u_zip').value;
	var hphone = dEI('h_phone').value;
	//
	var err = false;
	var errs = '';
	//
	if(uaddress == ''){
		err = true;
		errs = errs + "Missing Street Address\n";
	}
	if(ucity == ''){
		err = true;
		errs = errs + "Missing City Name\n";
	}
	if(ustate == ''){
		err = true;
		errs = errs + "Missing State Name\n"
	}
	if(uzip == ''){
		err = true;
		errs = errs + "Missing Zip Code\n"
	}
	if(hphone == ''){
		err = true;
		errs = errs + "Missing Home Phone Number\n"
	}
	if(err == true){
		alert("Problems In the Form:\n" + errs);
	} else {
		dEI(form).submit();
	}
}

function updateschool(val){
	dEI('schooltype').value = val;
}

function check(val){
	if(val == 'other'){
		// span_other (wraps u_other)
		// input u_other
		if(dEI('span_other').style.display == "none"){
			dEI('span_other').style.display = "block";
		} else {
			if(dEI('u_other').value != ''){
				dEI('checkgo').value = 'yes';
				dEI('selectedyear').value = dEI('u_other').value;
				dEI('checkform').submit();
			}
		}
	} else {
		if(dEI('span_other')){
			if(dEI('span_other').style.display == "block"){
				dEI('span_other').style.display == "none";
				dEI('u_other').innerHTML = '';
			}
			/*Optional values of val in U case - f,s,j, se, other */
			if(val == 'f' || val == 's' || val == 'j' || val == 'se'){
				// we have a normal University Type (four year system)
				/*checkgo, selectedyear*/
				dEI('checkgo').value = 'yes';
				dEI('selectedyear').value = val;
				dEI('checkform').submit();
			} else {
				if(val != 'other' || val == 'default'){
					dEI('checkgo').value = 'no';
					dEI('selectedyear').value = val;
					dEI('checkform').submit();
				}
			}
		} else {
			//what is possible? (hs, cc)
			if(val == 'yes'){
				dEI('checkgo').value = 'yes';
				dEI('checkform').submit();
			} else if(val == 'no'){
				dEI('checkgo').value = 'no';
				dEI('checkform').submit();
			} else if(val == 'default'){
				alert("Please Select an Option.");
			}
		}
	}
}