// JavaScript Document

function newPopup(url) {
	popupWindow = window.open(
		url,'popUpWindow','height=500,width=400,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=yes')
}

function checkStoryFields() {
	var objectRef = document.stories;
	var submitForm = true;
	var missingFieldList = "Please correct the following errors and resubmit the form." + "\n" + "\n";
	//var submitForm = true;
	
	if (objectRef.title.value == "") {
		missingFieldList = missingFieldList + "- Title is missing" + "\n";
	 	//alert("Please provide your last name");
		//objectRef.last_name.focus();
		//return false;
		submitForm = false;
	}
	
	if (objectRef.subtitle.value == "") {
		missingFieldList = missingFieldList + "- Subtitle is missing" + "\n";
	 	//alert("Please provide your last name");
		//objectRef.last_name.focus();
		//return false;
		submitForm = false;
	}
	
	if (objectRef.content.value == "") {
		missingFieldList = missingFieldList + "- Story content is missing" + "\n";
	 	//alert("Please provide your last name");
		//objectRef.last_name.focus();
		//return false;
		submitForm = false;
	}
	
	if (submitForm) {
		return true; 
	} else {
		alert(missingFieldList);
		return false;
	} 

}

function checkIdeasEventsFields(type) {
	
	if(type == "ideas") {
		var objectRef = document.ideas;
	} else {
		var objectRef = document.events;
	}
	var submitForm = true;
	var missingFieldList = "Please correct the following errors and resubmit the form." + "\n" + "\n";
	
	if (objectRef.title.value == "") {
		missingFieldList = missingFieldList + "- Title is missing" + "\n";
		submitForm = false;
	}
	
	if (objectRef.subtitle.value == "") {
		missingFieldList = missingFieldList + "- Subtitle is missing" + "\n";
		submitForm = false;
	}
	
	if (objectRef.content.value == "") {
		missingFieldList = missingFieldList + "- Idea content is missing" + "\n";
		submitForm = false;
	}
	if(type == "ideas") {
		if (objectRef.video_link.value.length > 0) {
			if (objectRef.video_link.value.indexOf("youtube.com") == -1) { 
				missingFieldList = missingFieldList + "- Video link is not valid" + "\n";
				submitForm = false;
			}
		
		}
	}
	
	if (objectRef.uploadForm.value.length > 0) {
		if (objectRef.uploadForm_desc.value == "") {
			missingFieldList = missingFieldList + "- Description for the form is missing" + "\n";
			submitForm = false;
		}
		correctExtention = 0;
		if (objectRef.uploadForm.value.lastIndexOf(".pdf") > 0 ) {
			correctExtention = 1;
		}
		if(correctExtention == 1) {
		} else {
			if (objectRef.uploadForm.value.lastIndexOf(".jpg") > 0 ) {
				correctExtention = 1;
			}
		}
		if(correctExtention == 1) {
		} else {
			if (objectRef.uploadForm.value.lastIndexOf(".txt") > 0 ) {
				correctExtention = 1;
			}
		}
		if(correctExtention == 1) {
		} else {
			if (objectRef.uploadForm.value.lastIndexOf(".doc") > 0 ) {
				correctExtention = 1;
			}
		}
		if(correctExtention == 1) {
		} else {
			if (objectRef.uploadForm.value.lastIndexOf(".xls") > 0 ) {
				correctExtention = 1;
			}
		}
		if(correctExtention == 0) {
			missingFieldList = missingFieldList + "- Only upload .pdf, .jpg, .txt, .doc, or .xls files for forms" + "\n";
			submitForm = false;
		}
		
	}
	
	if (objectRef.uploadPresentation.value.length > 0) {
		if (objectRef.uploadPresentation_desc.value == "") {
			missingFieldList = missingFieldList + "- Description for the presentation is missing" + "\n";
			submitForm = false;
		}
		correctExtention = 0;
		if (objectRef.uploadPresentation.value.lastIndexOf(".pdf") > 0 ) {
			correctExtention = 1;
		}
		if(correctExtention == 1) {
		} else {
			if (objectRef.uploadPresentation.value.lastIndexOf(".pps") > 0 ) {
				correctExtention = 1;
			}
		}
		if(correctExtention == 1) {
		} else {
			if (objectRef.uploadPresentation.value.lastIndexOf(".ppt") > 0 ) {
				correctExtention = 1;
			}
		}
		if(correctExtention == 1) {
		} else {
			if (objectRef.uploadPresentation.value.lastIndexOf(".pptx") > 0 ) {
				correctExtention = 1;
			}
		}
		if(correctExtention == 0) {
			missingFieldList = missingFieldList + "- Only upload .pdf, .pps, .ppt, or .pptx files for presentations" + "\n";
			submitForm = false;
		}
		
	}
	
	
	
	
	
	
	if (submitForm) {
		return true; 
	} else {
		alert(missingFieldList);
		return false;
	} 

}

function checkAskFields() {
	var objectRef = document.ask;
	var submitForm = true;
	var missingFieldList = "Please correct the following errors and resubmit the form." + "\n" + "\n";
	//var submitForm = true;
	
	if (objectRef.name.value == "") {
		missingFieldList = missingFieldList + "- Name is missing" + "\n";
	 	//alert("Please provide your last name");
		//objectRef.last_name.focus();
		//return false;
		submitForm = false;
	}
	
	if (objectRef.email.value == "") {
		missingFieldList = missingFieldList + "- Email is missing" + "\n";
	 	//alert("Please provide your last name");
		//objectRef.last_name.focus();
		//return false;
		submitForm = false;
	}
	
	if (objectRef.message.value == "") {
		missingFieldList = missingFieldList + "- Message content is missing" + "\n";
	 	//alert("Please provide your last name");
		//objectRef.last_name.focus();
		//return false;
		submitForm = false;
	}
	
	if (submitForm) {
		return true; 
	} else {
		alert(missingFieldList);
		return false;
	} 

}


