
// This function generates a windows to display the disclaimer text

function openDisclaimer() {
	popupWin = window.open('disclaimer.html', 'disclaimerWin', 'width=600,height=400,status=0,scrollbars=yes,toolbar=no,resizable=yes');
	popupWin.focus();
}


// ------------------------------------------------------------------------------------------------ 
// These functions validate the form after submit and while the user is filling elements out
// ------------------------------------------------------------------------------------------------ 


filename, firstName1, firstName2, phone, email, description


function validateFilename() {
	var strValue = document.uploadForm.filename.value;
	if (strValue == '') { return false; }
	else { return true;}	
}

function validateFirstName1() {
	var strValue = document.uploadForm.firstName1.value;
	if (strValue == '') { return false; }
	else { return true;}	
}

function validateFirstName2() {
	var strValue = document.uploadForm.firstName2.value;
	if (strValue == '') { return false; }
	else { return true;}	
}

function validatePhone() {
	var strValue = document.uploadForm.phone.value;
	if (strValue == '') { return false; }
	else { return true;}	
}

function validateEmail() {
	var objRegExp  = /^[a-z0-9]([a-z0-9_\-\.]*)@([a-z0-9_\-\.]*)(\.[a-z]{2,3}(\.[a-z]{2}){0,2})$/i;
	var strValue = document.uploadForm.email.value;
	if (strValue == '')    { return false; }
	else if (!(objRegExp.test(strValue)))   { return false; }
	else if (objRegExp.test(strValue))   { return true; }	
}

function validateDescription() {
	var strValue = document.uploadForm.description.value;
	if (strValue == '') { return false; }
	else { return true;}	
}

function validateDisclaimer() {
	var strValue = document.uploadForm.disclaimer.checked;
	if (strValue == '') { return false; }
	else { return true;}	
}

// if(document.getElementById("ORDER_" + elementNum + "_GIFTWRAP").checked == true)  {wrapCost = 10;}
// if(document.getElementById("ORDER_" + elementNum + "_GIFTWRAP").checked == false)  {wrapCost = 0;}


function validateForm() {
	
	// Set variable up here. If one or more of the form elements isn't set correctly, 'passValidation' will be set to 'false'
	var passValidation = true;
	
	if (!(validateFilename()))		{passValidation = false;}	
	if (!(validateFirstName1()))	{passValidation = false;}
	if (!(validateFirstName2()))	{passValidation = false;}
	if (!(validatePhone()))		{passValidation = false;}
	if (!(validateEmail()))		{passValidation = false;}
	if (!(validateDescription()))	{passValidation = false;}
	if (!(validateDisclaimer()))	{passValidation = false;}
	
	//alert("passValidation:" + passValidation);
	
	// If one or more of the form elements isn't set correctly, 'passValidation' will be set to 'false', alert the user
	if (!(passValidation)) {
		alert("Please go back and check your information");
	}	

	// If 'passValidation' is 'true' go ahead and submit the form...
	return passValidation;

}
