function sslMessage() {
   	if (confirm('NOTICE: You may see a warning about our Secure Certificate.\r\nPlease be assured that your transaction is secure.\r\nIt is safe to go ahead and access the upload page.\r\nIf you do not wish to proceed, click Cancel.')) {
		window.location = "https://69.213.194.20/ubr_file_upload.php"
	} else {
		return false;
	}
}

function checkGOFields(thisform){
	with(thisform){
		// check for required fields
		if (fp_order[0].checked == true && fp_no.value == ""){
			alert("You must enter the number of different floorplans you will be ordering today (not the quantity, the variety).");
			fp_no.focus();
			return false;
		}
	}
}

function checkGO1Fields(thisform){
	with(thisform){
		// check for required fields
		var NB = NeedBy.value;
		if (SiteCode.value == ""){
			alert("You must select a site code.");
			SiteCode.focus();
			return false;
		} else if (OrderBy.value == ""){
			alert("You must enter the email address of the area director.");
			SiteCode.focus();
			return false;
		} else if (submittedBy.value == ""){
			alert("You must enter the YOUR email address.");
			SiteCode.focus();
			return false;
		} else if (NeedBy.value == ""){
			alert("You must enter the date needed by (mm/dd/yyyy).");
			SiteCode.focus();
			return false;
		} else if (poNo.value == ""){
			alert("You must enter a purchase order number.");
			SiteCode.focus();
			return false;
		} else {
			if (isGODate(NeedBy.value) == false) {
				SiteCode.focus();
				return false;
			}
		}
	}
}

function isGODate(dateStr) {

	// prep date for array match
	var myDate; // set date
	myDate = dateStr.replace(/-/g,"/"); // replace - with / if need be
	myDate = dateStr.split("/"); // split into date elements
	myMonth = myDate[0]; // define month
	myDay = myDate[1]; // define day
	myYear = myDate[2]; // define year
	
	if (myMonth.length == 1) {
		myMonth = "0" + myMonth;
	}

	if (myDay.length == 1) {
		myDay = "0" + myDay;
	}

	if (myYear.length == 1) {
		myYear = "200" + myYear;
	} else if (myYear.length == 2) {
		myYear = "20" + myYear;
	}
	
	dateStr = myMonth + "/" + myDay + "/" + myYear;

var datePat = /^(\d{1,2})(\/|-)(\d{1,2})(\/|-)(\d{4})$/;
var matchArray = dateStr.match(datePat); // is the format ok?

if (matchArray == null) {
	alert("Please enter date as either mm/dd/yyyy or mm-dd-yyyy.");
	return false;
}

month = matchArray[1]; // p@rse date into variables
day = matchArray[3];
year = matchArray[5];

if (month < 1 || month > 12) { // check month range
alert("Month must be between 1 and 12.");
return false;
}

if (day < 1 || day > 31) {
alert("Day must be between 1 and 31.");
return false;
}

if ((month==4 || month==6 || month==9 || month==11) && day==31) {
alert("Month "+month+" doesn`t have 31 days!")
return false;
}

if (month == 2) { // check for february 29th
var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
if (day > 29 || (day==29 && !isleap)) {
alert("February " + year + " doesn`t have " + day + " days!");
return false;
}
}
return true; // date is valid
}


function checkGO3Fields(thisform){
	with(thisform){
		// check for required fields
		if (SiteCode.value == "" | OrderBy.value == "" | NeedBy.value == ""){
			alert("You must enter the name of the person placing the order, the date the order is needed by, and you must select a site code.");
			SiteCode.focus();
			return false;
		}
	}
}

function checkGO4Fields(thisform){
	with(thisform){
		// check for required fields
		if (fp_order[0].checked == true && fp_no.value == ""){
			alert("You must enter the number of different floorplans you will be ordering today (not the quantity, the variety).");
			fp_no.focus();
			return false;
		}
	}
}
