/* THESE FUNCTION ARE FOR CHECKING THE VALUES OF FORM FIELDS */
function loginCheck(){
with (document.submitForm) {
	if (username.value == ""){
		alert("You must enter a username.");
		username.focus();
	}
	else if (password.value == ""){
		alert("You must enter a password.");
		password.focus();
	}
	else return true;
}
return false;
}

function youthCheck(){
with (document.editform) {
	if (lastname.value == ""){
		alert("You must enter your last name.");
		lastname.focus();
	}
	else if (firstname.value == ""){
		alert("You must enter your first name.");
		firstname.focus();
	}
	else if (age.value == ""){
		alert("You must enter your age.");
		age.focus();
	}	
	else if (address.value == ""){
		alert("You must enter your address.");
		address.focus();
	}		
	else if (city.value == ""){
		alert("You must enter your city.");
		city.focus();
	}
	else if (zip.value == ""){
		alert("You must enter your zip code.");
		zip.focus();
	}	
	else if (county.value == ""){
		alert("You must enter your county.");
		county.focus();
	}	
	else if (emailaddress.value == ""){
		alert("You must enter your email address.");
		emailaddress.focus();
	}		
	else if (homephone.value == ""){
		alert("You must enter your home phone number.");
		homephone.focus();
	}	
	else if (cellphone.value == ""){
		alert("You must enter your cell phone number.");
		cellphone.focus();
	}
	else if (contact1name.value == ""){
		alert("You must enter your contact name.");
		contact1name.focus();
	}
	else if (contact1relationship.value == ""){
		alert("You must enter your contact relationship.");
		contact1relationship.focus();
	}
	else if (contact1phone.value == ""){
		alert("You must enter your contact phone.");
		contact1phone.focus();
	}	
	else if (contact2name.value == ""){
		alert("You must enter your contact name.");
		contact2name.focus();
	}	
	else if (contact2relationship.value == ""){
		alert("You must enter your contact relationship.");
		contact2relationship.focus();
	}	
	else if (contact2phone.value == ""){
		alert("You must enter your contact phone.");
		contact2phone.focus();
	}
	else if (schoolgrade.value == ""){
		alert("You must enter your school grade.");
		schoolgrade.focus();
	}
	else if (schooladdress.value == ""){
		alert("You must enter your school address.");
		schooladdress.focus();
	}
	else if (schoolcity.value == ""){
		alert("You must enter your school city.");
		schoolcity.focus();
	}
	else if (schoolphone.value == ""){
		alert("You must enter your school phone.");
		schoolphone.focus();
	}
	else if (extracurricular.value == ""){
		alert("You must enter your extracurricular activities.");
		extracurricular.focus();
	}
	else if (honors.value == ""){
		alert("You must enter your school honors.");
		honors.focus();
	}
	else if (principal.value == ""){
		alert("You must enter your school principal.");
		principal.focus();
	}
	else if (guidancecounselor.value == ""){
		alert("You must enter your school guidance counselor.");
		guidancecounselor.focus();
	}
	else if (hometownnewspaper.value == ""){
		alert("You must enter your hometown newspaper.");
		hometownnewspaper.focus();
	}
	else if (tshirtsize.value == ""){
		alert("You must enter your t-shirt size.");
		tshirtsize.focus();
	}
	else if (sex.value == ""){
		alert("You must enter your sex.");
		sex.focus();
	}
	else if (delinquent.value == ""){
		alert("You must enter whether you ever been found deliquent by a juvenile court.");
		delinquent.focus();
	}	
	else if (why.value == ""){
		alert("You must enter why you want to be a part of the Meth Destroys Youth Leadership Council.");
		why.focus();
	}
	else if (actions.value == ""){
		alert("You must enter what actions can youth take toward fighting the meth problem in Tennessee.");
		actions.focus();
	}
	else if (consentpictures.checked == false){
		alert("You must give your consent to allow us to use your pictures.");
		consentpictures.focus();
	}
	else if (consentname.checked == false){
		alert("You must give your consent to allow us to use your name.");
		consentname.focus();
	}
	else if (consentstatements.checked == false){
		alert("You must give your consent to allow us to use your statements.");
		consentstatements.focus();
	}	
	else return true;
}
return false;
}

function UPLOADFile(){
with (document.submitForm) {
	if (title.value == ""){
		alert("You must enter a title for the document.");
		title.focus();
	}
	else if (cat.value == ""){
		alert("You must choose a category to assign this document to.");
		cat.focus();
	}
	else if (videoFile.value == ""){
		alert("You must choose a document to upload.");
		videoFile.focus();
	}
	else if (description.value == ""){
		alert("You must enter a description of the document.");
		description.focus();
	}
	else return true;
}
return false;
}

function EDITFile(){
with (document.submitForm) {
	if (title.value == ""){
		alert("You must enter a title for the document.");
		title.focus();
	}
	else if (cat.value == ""){
		alert("You must choose a category to assign this document to.");
		cat.focus();
	}
	else if (description.value == ""){
		alert("You must enter a description of the document.");
		description.focus();
	}
	else return true;
}
return false;
}

function storyCheck(){
with (document.editform) {
	if (isEmail(email.value) == false){
		alert("You must provide a valid email.");
		email.focus();
	}
	else if (county.value == ""){
		alert("You must provide a county.");
		county.focus();
	}
	else if (story.value == ""){
		alert("Please share your story before posting.");
		story.focus();
	}
	else return true;
}
return false;
}

function emailCheck(){
with (document.editform) {
	if (name.value == ""){
		alert("You must provide your name.");
		name.focus();
	}
	else if (isEmail(email.value) == false){
		alert("You must provide a valid email.");
		email.focus();
	}
	else if (phone.value == ""){
		alert("You must provide a phone number in case we need to contact you directly.");
		phone.focus();
	}
	else if (county.value == ""){
		alert("You must provide a county.");
		county.focus();
	}
	else if (request.value == ""){
		alert("Please let us know what your request is so we can properly serve you.");
		request.focus();
	}
	else return true;
}
return false;
}

function partnerCheck(){
with (document.editform) {
	if (name.value == ""){
		alert("You must provide your name.");
		name.focus();
	}
	else if (isEmail(email.value) == false){
		alert("You must provide a valid email.");
		email.focus();
	}
	else if (company.value == ""){
		alert("Please provide us with the name of your company or organization.");
		company.focus();
	}
	else if (phone.value == ""){
		alert("You must provide a phone number in case we need to contact you directly.");
		phone.focus();
	}
	else if (request.value == ""){
		alert("Please let us know what your request is so we can properly serve you.");
		request.focus();
	}
	else return true;
}
return false;
}

function contactCheck(){
with (document.editform) {
	if (name.value == ""){
		alert("You must provide your name.");
		name.focus();
	}
	else if (isEmail(email.value) == false){
		alert("You must provide a valid email.");
		email.focus();
	}
	else if (phone.value == ""){
		alert("You must provide a phone number in case we need to contact you directly.");
		phone.focus();
	}
	else if (request.value == ""){
		alert("Please let us know what your request is so we can properly serve you.");
		request.focus();
	}
	else return true;
}
return false;
}

function materialCheck(){
with (document.editform) {
	if (name.value == ""){
		alert("You must provide your name.");
		name.focus();
	}
	else if (isEmail(email.value) == false){
		alert("You must provide a valid email.");
		email.focus();
	}
	else if (phone.value == ""){
		alert("You must provide a phone number in case we need to contact you directly.");
		phone.focus();
	}
	else if (county.value == ""){
		alert("You must provide your county.");
		county.focus();
	}
	else if (brochuresCount.value == 0 && posters.value == 0 && bumperStickers.value == 0 && booklet.value == 0 && dvd.checked == false){
		alert("You must choose at one item for your material request.");
		brochuresCount.focus();
	}
	else return true;
}
return false;
}

function materialCheckOS(){
with (document.editform) {
	if (name.value == ""){
		alert("You must provide your name.");
		name.focus();
	}
	else if (isEmail(email.value) == false){
		alert("You must provide a valid email.");
		email.focus();
	}
	else if (phone.value == ""){
		alert("You must provide a phone number in case we need to contact you directly.");
		phone.focus();
	}
	else if (state.value == ""){
		alert("You must provide your state.");
		state.focus();
	}
	else if (brochuresCount.value == 0 && posters.value == 0 && bumperStickers.value == 0 && booklet.value == 0 && dvd.checked == false){
		alert("You must choose at one item for your material request.");
		brochuresCount.focus();
	}
	else return true;
}
return false;
}

function taskCheck(){
with (document.editform) {
	if (name.value == ""){
		alert("You must provide your name.");
		name.focus();
	}
	else if (isEmail(email.value) == false){
		alert("You must provide a valid email.");
		email.focus();
	}
	else if (county.value == ""){
		alert("You must provide a county.");
		county.focus();
	}
	else return true;
}
return false;
}

/* THESE FUNCTIONS ARE CHANGING PAGES AND CHECKING VALUES OF A STRING */
function updateLocation(path){
	parent.window.location=path;
}
function confirmMove(path){
	confirm("Are you sure you want to delete this item? If you continue, there is no way to recover the information.");
	parent.window.location=path;
}
function downLoadFile(file){
	path = "pushd.php?md5604=" + file;
	$var = window.open(path,'askquestion','width=20,height=20');
}
function isEmail(str) {
	var supported = 0;
	if (window.RegExp) {
		var tempStr = "a";
		var tempReg = new RegExp(tempStr);
		if (tempReg.test(tempStr)) supported = 1;
		}
	if (!supported)
		return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
		var r1 = new RegExp("(@.*@)|(\\.\\.)|(@\\.)|(^\\.)");
		var r2 = new RegExp("^.+\\@(\\[?)[a-zA-Z0-9\\-\\.]+\\.([a-zA-Z]{2,3}|[0-9]{1,3})(\\]?)$");
	return (!r1.test(str) && r2.test(str));
}

