// JScript source code

var address = "northscaping.com";
var subject = "Resend%20NetPS%20Account%20Number%20And%20Password";
var body = "Please%20send%20me%20my%20NetPS%20account%20number%20and%20password.%0D%0AMy%20full%20business%20name%20is:%20%0AMy%20exact%20primary%20email%20address%20is:%20";
	
function sendMail(name) {
	document.write('<a class=aa9tea-bu-dst href=mailto:' + name + '@' + address + '?subject=' + subject + '&body=' + body + '>');
}
	
function openWindow(url, name) {
	popupWin = window.open(url, name, 'width=420,height=330,left=125,top=125,scrollbars=1')
}

var address2 = "northscaping.com";
var subject2 = "Business%20Promotional%20Partnership%20Inquiry";
	
function sendMail2(name) {
	document.write('<a class=aa10wht-b-utan href=mailto:' + name + '@' + address2 + '?subject=' + subject2 + '>');
}

function validEmail(email) {
	return (email.indexOf(".") > 2) && (email.indexOf("@") > 0);
}
	
function validColor(color) {
	testStr = "0123456789abcdef";
	if (color.charAt(0) != "#") return false;
	for (i=1;i<color.length;i++) {
		if (testStr.indexOf(color.charAt(i)) == -1) return false;
		}
	return true;
}
	
function validDecimal(dec) {
	testStr = "0123456789.";
	for (i=0;i<dec.length;i++) {
		if (testStr.indexOf(dec.charAt(i)) == -1) return false;
		}
	return true;
}
	
function validFontSize(fontsize, minsize, maxsize) {
	if (fontsize != parseInt(fontsize)) return false;
	if ((fontsize < minsize) || (fontsize > maxsize)) return false;
	return true;
}
	
function validateCustForm() {

	test = document.CustForm.BusinessName.value;
	if (test.length < 2) {
		alert ("Please enter your company name");
		return false;
	}
		
	test = document.CustForm.Address.value;
	if (test.length < 2) {
		alert ("Please enter your business address");
		return false;
	}
		
	test = document.CustForm.City.value;
	if (test.length < 2) {
		alert ("Please enter your city");
		return false;
	}
		
	test = document.CustForm.State.value;
	if (test.length < 2) {
		alert ("Please enter your state or province");
		return false;
	}

	test = document.CustForm.Postal.value;
	if (test.length < 2) {
		alert ("Please enter your zip or postal code");
		return false;
	}

	test = document.CustForm.Country.value;
	if (test.length < 2) {
		alert ("Please enter your country");
		return false;
	}

	test = document.CustForm.Phone.value;
	if (test.length < 2) {
		alert ("Please enter your telephone number");
		return false;
	}

	test = document.CustForm.ContactName.value;
	if (test.length < 2) {
		alert ("Please enter the name of the contact person for your NetPS account");
		return false;
	}
		
	test = document.CustForm.ContactTitle.value;
	if (test.length < 2) {
		alert ("Please enter the title or position of the contact person for your NetPS account");
		return false;
	}
		
	test = document.CustForm.Website.value;
	if (test.length < 4) {
		alert ("Please enter your primary website address");
		return false;
	}

	if (validEmail(document.CustForm.ContactEmail.value) == false) {
		alert ("Please enter a valid e-mail address for your NetPS contact person");
		return false;
	}
	
	if (document.CustForm.AddEmail.length > 0) {
		if (validEmail(document.CustForm.AddEmail.value) == false) {
			alert ("Please enter a valid e-mail address for the additional notification contact");
			return false;
		}
	}
	
	test = document.CustForm.Password.value;
	if (test.length < 4) {
		alert ("Please enter a password with at least 4 characters");
		return false;
	}
	
	test = document.CustForm.PasswordConfirm.value;
	if (test.length < 4) {
		alert ("Please confirm your password");
		return false;
	}
		
	if ((document.CustForm.Password.value) != (document.CustForm.PasswordConfirm.value)) {
		alert ("Your password could not be confirmed; please retype your password and confirm it again");
		return false;
	}

	return true; 
}

function validateUnivForm() {
	
	test = document.UnivForm.TableWidth.value;
	if (test != parseInt(test)) {
		alert ("Main table width must be an integer value");
		return false;
	}
	
	test = document.UnivForm.TablePadding.value;
	if (test != parseInt(test)) {
		alert ("Main table padding must be an integer value");
		return false;
	}
	
	test = document.UnivForm.TableWidth.value;
	test1 = document.UnivForm.TablePadding.value;
	test2 = (360 + (2 * test1));
	if (test < test2) {
		alert ("Main table width must be greater than (360 + (2 * padding))");
		return false;
	}
	
	test = document.UnivForm.TableBGColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Main table background color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.UnivForm.FontType.value;
	if (test.length < 3) {
		alert ("Please enter a primary font type");
		return false;
	}
	
	if (validColor(document.UnivForm.TextFontColor.value) == false) {
		alert ("Primary text font color must be in proper hex RGB color format");
		return false;
	}
	
	if (validFontSize(document.UnivForm.PageTextFontSize.value, 4, 30) == false) {
		alert ("Primary text font size must be an integer value between 4 and 30");
		return false;
	}
	
	if (validFontSize(document.UnivForm.TitleFontSize.value, 4, 30) == false) {
		alert ("Main title font size must be an integer value between 4 and 30");
		return false;
	}
	
	if (validColor(document.UnivForm.TitleFontColor.value) == false) {
		alert ("Main title font color must be in proper hex RGB color format");
		return false;
	}
	
	test = document.UnivForm.TitleBGColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
		alert ("Main title background color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.UnivForm.TitleSBHeight.value;
	if (test != parseInt(test)) {
		alert ("Title sub-bar height must be an integer value");
		return false;
	}
	
	test = document.UnivForm.TitleSBColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Title sub-bar background color must be in proper hex RGB color format");
			return false;
		}
	}
	
	if (validFontSize(document.UnivForm.ButtonFontSize.value, 4, 30) == false) {
		alert ("Button font size must be an integer value between 4 and 30");
		return false;
	}
	
	if (validColor(document.UnivForm.ButtonFontColor.value) == false) {
		alert ("Button font color must be in proper hex RGB color format");
		return false;
	}
	
	if (validColor(document.UnivForm.DLinkColor.value) == false) {
		alert ("Default link color must be in proper hex RGB color format");
		return false;
	}
	
	if (validColor(document.UnivForm.DLinkHColor.value) == false) {
		alert ("Default link hover color must be in proper hex RGB color format");
		return false;
	}
	
	if (validColor(document.UnivForm.DLinkVColor.value) == false) {
		alert ("Default link visited color must be in proper hex RGB color format");
		return false;
	}
	
	test = document.UnivForm.PDFTemplateTopMargin.value;
	if (test.length > 0) {
		if ((validDecimal(test) == false) || (parseFloat(test) > 3.5) || (test.indexOf(".") > 1)) {
			alert ("PDF top margin must be in inches in the format 'X.XX', minimum 1 inch to maximum 3.5 inches, and up to 2 decimal places");
			return false;
		}
	}
	
	return true; 
}

function validatePageForm() {
	
	test = document.PageForm.SFormColumns.value;
	if ((test != 1) && (test != 2)) {
		alert ("Search form columns must be set to either 1 or 2");
		return false;
	}

	test = document.PageForm.SFormBorder.value;
	if (test != parseInt(test)) {
		alert ("Search form border must be an integer value");
		return false;
	}
	
	test = document.PageForm.SFormBGColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Search form background color must be in proper hex RGB color format");
			return false;
		}
	}
	
	if (validFontSize(document.PageForm.SHeaderFontSize.value, 4, 30) == false) {
		alert ("Search form header font size must be an integer value between 4 and 30");
		return false;
	}
	
	if (validColor(document.PageForm.SHeaderFontColor.value) == false) {
		alert ("Search form header font color must be in proper hex RGB color format");
		return false;
	}
	
	test = document.PageForm.SHeaderBGColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Search form header background color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.SBoxWidth.value;
	if (test != parseInt(test)) {
		alert ("Search box width must be an integer value");
		return false;
	}
	if ((test < 360) || (test > 999)) {
		alert ("Search box width must be greater than 360 and less than 999 pixels");
		return false;
	}
	test1 = document.PageForm.SFormColumns.value;
	if ((test1 == 2) && (test%2 != 0)) {
		alert ("Search box width must be an even number for a two-column search form layout");
		return false;
	}
	
	test = document.PageForm.SFBHValue.value;
	if (test.length > 0) {
		if (validDecimal(test) == false) {
			alert ("Search field block height value must be a number with either one or no decimal places");
			return false;
		}
		test1 = parseInt(document.PageForm.SFBHValue.value)
		if ((test1 < 1) || (test1 > 99.9)) {
			alert ("Search field block height value must be a number between 1.0 and 99.9");
			return false;
		}
	}
	
	test = document.PageForm.SBoxBarColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Search field spacer bar color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.SCatFontColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Search category sub-header font color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.SCatBGColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Search category sub-header background color must be in proper hex RGB color format");
			return false;
		}
	}
	
	if (validColor(document.PageForm.SHotButtonColor.value) == false) {
		alert ("Hot Button color must be in proper hex RGB color format");
		return false;
	}
	
	test = document.PageForm.CPOffsetX.value;
	if ((test < -999) || (test > 999)) {
		alert ("Color picker x-offset must be a value between -999 and 999 pixels");
		return false;
	}
		
	test = document.PageForm.CPOffsetY.value;
	if ((test < -999) || (test > 999)) {
		alert ("Color picker y-offset must be a value between -999 and 999 pixels");
		return false;
	}
		
	if (validFontSize(document.PageForm.RHeaderFontSize.value, 4, 30) == false) {
		alert ("Results page header font size must be an integer value between 4 and 30");
		return false;
	}
	
	if (validFontSize(document.PageForm.RPlantFontSize.value, 4, 30) == false) {
		alert ("Results page plant name font size must be an integer value between 4 and 30");
		return false;
	}
	
	test = document.PageForm.RSpacerBarColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Results form header spacer bar color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.RBorder.value;
	if (test != parseInt(test)) {
		alert ("Results block border must be an integer value");
		return false;
	}
	
	test = document.PageForm.RRowColors.value;
	if ((test != 1) && (test != 2)) {
		alert ("Number of results row colors must be set to either 1 or 2");
		return false;
	}

	test = document.PageForm.RRowBGColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Primary results block background color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.RRow2BGColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Alternate results block background color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.RRow2FontColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Alternate results block font color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.RP2LinkColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Alternate results block link color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.RP2LinkHColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Alternate results block link hover color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.RP2LinkVColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Alternate results block link visited color must be in proper hex RGB color format");
			return false;
		}
	}
	
	test = document.PageForm.PIconBarHeight.value;
	if (test != parseInt(test)) {
		alert ("Plant data page icon bar height must be an integer value");
		return false;
	}
	
	test = document.PageForm.PIconBarColor.value;
	if (test.length > 0) {
		if (validColor(test) == false) {
			alert ("Plant data page icon bar color must be in proper hex RGB color format");
			return false;
		}
	}
	
	if (validFontSize(document.PageForm.PCaptionFontSize.value, 4, 30) == false) {
		alert ("Photo caption font size must be an integer value between 4 and 30");
		return false;
	}
	
	if (validFontSize(document.PageForm.PCreditFontSize.value, 4, 30) == false) {
		alert ("Photo credit font size must be an integer value between 4 and 30");
		return false;
	}
	
	if (validFontSize(document.PageForm.mPHeaderFontSize.value, 4, 30) == false) {
		alert ("myPlants header font size must be an integer value between 4 and 30");
		return false;
	}
	
	if (validFontSize(document.PageForm.mPPlantFontSize.value, 4, 30) == false) {
		alert ("myPlants plant name font size must be an integer value between 4 and 30");
		return false;
	}
	
	if (validFontSize(document.PageForm.mPLinkFontSize.value, 4, 30) == false) {
		alert ("myPlants bottom-page links font size must be an integer value between 4 and 30");
		return false;
	}	
	return true; 
}

function validateHTMLForm() {
	
	test = document.HTMLForm.HTMLTitle.value;
	if (test.length < 2) {
		alert ("Please enter text for the HTML browser title");
		return false;
	}
	return true; 
}

function validatePDCForm() {

	if (document.pressed == "Save") {
	
		test = document.EntryForm.CommonName.value;
		if (test.length > 50) {
			alert ("Common Name must be 50 characters or less");
			return false;
		}
				
		test = document.EntryForm.OtherSpeciesNames.value;
		if (test.length > 50) {
			alert ("Other Species Names must be a total of 50 characters or less");
			return false;
		}
				
		test = document.EntryForm.Family.value;
		if (test.length > 20) {
			alert ("Family must be 20 characters or less");
			return false;
		}
		
		if ((document.EntryForm.LAAccent.checked == false) &&
			(document.EntryForm.LAShade.checked == false) &&
			(document.EntryForm.LAArticulation.checked == false) &&
			(document.EntryForm.LAMassing.checked == false) &&
			(document.EntryForm.LAScreening.checked == false) &&
			(document.EntryForm.LARock.checked == false) &&
			(document.EntryForm.LAEdging.checked == false) &&
			(document.EntryForm.LAGarden.checked == false) &&
			(document.EntryForm.LAWindbreak.checked == false) &&
			(document.EntryForm.LAGroundcover.checked == false) &&
			(document.EntryForm.LANaturalizing.checked == false) &&
			(document.EntryForm.LAOrchard.checked == false) &&
			(document.EntryForm.LATopiary.checked == false) &&
			(document.EntryForm.LAHerb.checked == false) &&
			(document.EntryForm.LAContainer.checked == false) &&
			(document.EntryForm.LABog.checked == false)) {
			alert ("You MUST select at least one Landscape Application!");
			return false;
		}
		var testStr = ""
		if (document.EntryForm.LAAccent.checked == true) (testStr = testStr + "Accent;");
		if (document.EntryForm.LAShade.checked == true) (testStr = testStr + "Shade;");
		if (document.EntryForm.LAArticulation.checked == true) (testStr = testStr + "Articulation;");
		if (document.EntryForm.LAMassing.checked == true) (testStr = testStr + "Massing;");
		if (document.EntryForm.LAScreening.checked == true) (testStr = testStr + "Screening;");
		if (document.EntryForm.LARock.checked == true) (testStr = testStr + "Rock;");
		if (document.EntryForm.LAEdging.checked == true) (testStr = testStr + "Edging;");
		if (document.EntryForm.LAGarden.checked == true) (testStr = testStr + "Garden;");
		if (document.EntryForm.LAWindbreak.checked == true) (testStr = testStr + "Windbreak;");
		if (document.EntryForm.LAGroundcover.checked == true) (testStr = testStr + "Groundcover;");
		if (document.EntryForm.LANaturalizing.checked == true) (testStr = testStr + "Naturalizing;");
		if (document.EntryForm.LAOrchard.checked == true) (testStr = testStr + "Orchard;");
		if (document.EntryForm.LATopiary.checked == true) (testStr = testStr + "Topiary;");
		if (document.EntryForm.LAHerb.checked == true) (testStr = testStr + "Herb;");
		if (document.EntryForm.LAContainer.checked == true) (testStr = testStr + "Container;");
		if (document.EntryForm.LABog.checked == true) (testStr = testStr + "Bog;");
		if (testStr.length - 1 > 64) {
			alert ("You have selected too many fields for 'Landscape Application' (database overflow)!");
			return false;
		}
				
		test1 = document.EntryForm.PlantHeight.value;
		if (test1 != parseInt(test1)) {
			alert ("Plant Height must be an integer value");
			return false;
		}
		test1 = parseInt(test1)
		if (test1 > 1199) {
			alert ("Plant Height must be less than 1200 inches");
			return false;
		}
		
		test2 = document.EntryForm.FloweringHeight.value;
		if (test2 != parseInt(test2)) {
			alert ("Flowering Height must be an integer value");
			return false;
		}
		test2 = parseInt(test2)
		if (test2 > 1199) {
			alert ("Flowering Height must be less than 1200 inches");
			return false;
		}
		
		if (test2 < test1) {
			alert ("Flowering Height MUST ALWAYS be greater than or equal to Plant Height!");
			return false;
		}
		
		test = document.EntryForm.Spread.value;
		if (test != parseInt(test)) {
			alert ("Spread must be an integer value");
			return false;
		}
		test = parseInt(test)
		if (test > 1199) {
			alert ("Spread must be less than 1200 inches");
			return false;
		}
		
		test = document.EntryForm.Lifespan.value;
		if (test != parseInt(test)) {
			alert ("Lifespan must be an integer value");
			return false;
		}
		test = parseInt(test)
		if (test > 499) {
			alert ("Lifespan must be less than 500 years");
			return false;
		}
		if (test < 1) {
			alert ("Lifespan must be greater than 0 years!");
			return false;
		}
		
	//test to see that Minimum Light isn't 'greater' than Maximum Light
		var minLight = document.EntryForm.MinimumLight.value;
		var maxLight = document.EntryForm.MaximumLight.value;
		checkLArray = new Array(3);
		for (i = 0; i < checkLArray.length; ++ i) checkLArray [i] = new Array(2);	
		checkLArray [0] [0] = "shade";
		checkLArray [0] [1] = 0;
		checkLArray [1] [0] = "partial shade";
		checkLArray [1] [1] = 1;
		checkLArray [2] [0] = "full sun";
		checkLArray [2] [1] = 2;
	//First score the lesser field
		var minTest = 0;
		for (i = 0; i < checkLArray.length; ++ i) {
			if (minLight == checkLArray [i] [0]) {
				minTest = checkLArray [i] [1];
			}
		}
	//Then score the greater field
		var maxTest = 0;
		for (i = 0; i < checkLArray.length; ++ i) {
			if (maxLight == checkLArray [i] [0]) {
				maxTest = checkLArray [i] [1];
			}
		}
	//Compare
		if (minTest > maxTest) {
			alert ("Maximum Light MUST ALWAYS be greater than or equal to Minimum Light!");
			return false;
		}
		
	//test to see that Minimum Moisture isn't 'greater' than Maximum Moisture
		var minMoisture = document.EntryForm.MinimumMoisture.value;
		var maxMoisture = document.EntryForm.MaximumMoisture.value;
		checkMArray = new Array(4);
		for (i = 0; i < checkMArray.length; ++ i) checkMArray [i] = new Array(2);	
		checkMArray [0] [0] = "dry";
		checkMArray [0] [1] = 0;
		checkMArray [1] [0] = "average";
		checkMArray [1] [1] = 1;
		checkMArray [2] [0] = "moist";
		checkMArray [2] [1] = 2;
		checkMArray [3] [0] = "wet";
		checkMArray [3] [1] = 3;
	//First score the lesser field
		var minTest = 0;
		for (i = 0; i < checkMArray.length; ++ i) {
			if (minMoisture == checkMArray [i] [0]) {
				minTest = checkMArray [i] [1];
			}
		}
	//Then score the greater field
		var maxTest = 0;
		for (i = 0; i < checkMArray.length; ++ i) {
			if (maxMoisture == checkMArray [i] [0]) {
				maxTest = checkMArray [i] [1];
			}
		}
	//Compare
		if (minTest > maxTest) {
			alert ("Maximum Moisture MUST ALWAYS be greater than or equal to Minimum Moisture!");
			return false;
		}

		test = document.EntryForm.Group.value;
		if (test.length > 30) {
			alert ("Plant Sub-Group must be 30 characters or less");
			return false;
		}
		
		test = document.EntryForm.Comments.value;
		if (test.length > 255) {
			alert ("Comments must be 255 characters or less");
			return false;
		}

		test = document.EntryForm.CFHeader.value;
		if (test.length > 50) {
			alert ("Custom Field Header must be 50 characters or less");
			return false;
		}
		
		test = document.EntryForm.CFText.value;
		if (test.length > 2000) {
			alert ("Custom Field Text must be 2000 characters or less");
			return false;
		}
	}
	document.EntryForm.formtype.value = "pdcdata";
	document.EntryForm.submitaction.value = document.pressed;
	return true; 
}
	
	
function validateExportForm() {

	if (validEmail(document.EntryForm.Email.value) == false) {
		alert ("Please enter a valid e-mail address for the additional notification contact");
		return false;
	}
	document.EntryForm.formtype.value = "send";
	return true; 
}
	
function directAlphaForm() {

	if (document.pressed == "Advanced Filter") {
		document.EntryForm.formtype.value = "icxfilter";
		document.EntryForm.submit();
	}
	return false; 
}
	
function directFilterForm() {

	if (document.pressed == "Set Filter") {
		document.EntryForm.filterFlag.value = "true";
		document.EntryForm.submit();
	}
	if (document.pressed == "Default") {
		document.EntryForm.filterFlag.value = "false";
		document.EntryForm.icxP1.value = "GEN";
		document.EntryForm.icxP2.value = "SPE";
		document.EntryForm.icxP3.value = "CUL";
		document.EntryForm.icxInventory.value = "";
		document.EntryForm.icxCategory.value = "";
		document.EntryForm.icxRecent.value = "";
		document.EntryForm.submit();
	}
	return false; 
}
	
function formTrigger(message) {
	
	if (message == "config") {
		document.EntryForm.action = "NetPS-Config.asp";
		document.EntryForm.submit();
	}
	else {
		document.EntryForm.formtype.value = message;
		document.EntryForm.submit();
	}
	return false;
}

function formTriggerAlpha(letter) {
	
	document.EntryForm.alpha.value = letter;
	document.EntryForm.formtype.value = "icxchar";
	document.EntryForm.submit();
	return false;
}

function formTriggerPDCAlpha(letter) {
	
	document.EntryForm.alpha.value = letter;
	document.EntryForm.formtype.value = "pdcchar";
	document.EntryForm.submit();
	return false;
}

function formTriggerPDC(plantID) {
	
	document.EntryForm.pid.value = plantID;
	document.EntryForm.formtype.value = "pdcform";
	document.EntryForm.submit();
	return false;
}


