<!-- Begin
/****************************************************************************************
'* Javascript Validation                                                                *
'*--------------------------------------------------------------------------------------*
'* Abstract: Client-Side form validation scripts                                        *
'* Copyright (C) 2006-2010 Prosirius Technologies LLC                                   *
'* You may not download, install, run, use, view, share or modify this program or its   *
'* derivative works without a signed Software License Agreement from Prosirius          *
'* Technologies. US Federal and State Law prohibits these actions if you do not have    *
'* said License. Additional requirements exist. Please email Prosirius Technologies at: *
'* support@prosirius.com for more information.                                          *
'* Last Update: 02-07-10                                                                *
*****************************************************************************************/

function checklogin (msg) {
// Login Form
	if((document.login.password.value!='')&&(document.login.username.value!=''))
		{ return true }
	else {
		alert(msg);
		document.login.username.focus();
		return false
		}
}

function checkquizanswer (quizfield) {
// Verifies that user clicked on a radio button when answering a quiz question
	var inputs = document.quiz.getElementsByTagName ('input');
	if (inputs) { 
		var foundResponse=false; 
		for (var i = 0; i < inputs.length; ++i) {
			if (inputs[i].type == 'radio' && inputs[i].name == quizfield) {
				if (inputs[i].checked == true) { 
					foundResponse = true;
					}
				}
			}
		return foundResponse;
		}
}

function checkmessage (msg) {
// Forum Message Entry
if((document.addmessage.subjecttext.value!='')&&(document.addmessage.messagetext.value!=''))
	{ return true }
else {
	alert(msg);
	document.addmessage.subjecttext.focus();
	return false
	}
}

function checkprofile (msg) {
// Add Service Directory Entry (Service Profile) Form
	nme=document.addservice.longnametext.value;
	cit=document.addservice.citytext.value;
	sta=document.addservice.statetext.value;
	if((nme!='')&&(cit!='')&&(sta!=''))
		{ return true }
	else {
		alert(msg);
		document.addservice.longnametext.focus();
		return false
		}
}

function checkprofiletime (msg) {
// Add-Edit Project Time Entry from User Profile
	dte=document.savetime.activitydate.value;
	act=document.savetime.activitytext.value;
	hrs=document.savetime.activityhours.value;
	if((dte!='')&&(act!='')&&(hrs!=''))
		{ return true }
	else {
		alert(msg);
		document.savetime.activitydate.focus();
		return false
		}
}

function checksearch (msg) {
// Search Form
if(document.search.searchtext.value != '')
	{ return true }
else {
	alert(msg);
	document.search.searchtext.focus();
	return false
	}
}

function checkforgotpassword (msg) {
// Forgot Password Form
	eml=document.forgotpassword.emailtext.value;
	fnm=document.forgotpassword.firstnametext.value;
	lnm=document.forgotpassword.lastnametext.value;
	phn=document.forgotpassword.phonetext.value;
	act=document.forgotpassword.accountnumbertext.value;
	if((eml=='')&&(fnm=='')&&(lnm=='')&&(phn=='')&&(act=='')) {
		alert(msg);
		document.forgotpassword.emailtext.focus();
		return false
	} else { return true }
}

function checkchgpassword (msg) {
// Change Password Form
	if (document.chgpassword.strongpassword.value=true) {
		opwd=document.chgpassword.oldpassword.value;
		npwd=document.chgpassword.newpassword.value;
		vpwd=document.chgpassword.verifypassword.value;
	}
	else {
	opwd=document.chgpassword.oldpassword.value.toLowerCase();
	npwd=document.chgpassword.newpassword.value.toLowerCase();
	vpwd=document.chgpassword.verifypassword.value.toLowerCase();
	}
	if((opwd!='')&&(npwd!='')&&(vpwd!='')) {
		var iChars = "!@#$%^&*()_+-={}[]~`|:;'<>,.?/\\\" ";
		if(npwd!=vpwd) {
			alert("Password and Verify Password must match.");
			document.chgpassword.newpassword.focus(); 
			return false
			}
		for (var i = 0; i < npwd.length; i++) {
			if (iChars.indexOf(npwd.charAt(i)) != -1) {
				alert ("Password cannot have special characters.");
				document.chgpassword.newpassword.focus(); 
				return false;
				}
			}
		var imin=document.chgpassword.minpassword.value;
		var imax=document.chgpassword.maxpassword.value;
		if (npwd.length<imin) {
			alert ("Password must be at least " + imin + " characters long");
			document.chgpassword.newpassword.focus(); 
			return false;
			}
		if (npwd.length>imax) {
			alert ("Password must be less than " + imax + " characters long");
			document.chgpassword.newpassword.focus(); 
			return false;
			}
		return true
	}
else {
	alert(msg);
	document.chgpassword.oldpassword.focus(); 
	return false
	}
}

function checkphoto (msg) {
// Check Photo Form
	titl=document.uploadphoto.titletext.value;
	pdat=document.uploadphoto.photodate.value;
	filn=document.uploadphoto.filenametext.value;
	if((titl!='')&&(pdat!='')&&(filn!='')) {
		//drop to lowercase and get right 3 characters
		filx = LCase(RTrim(filn));
		if(Len(filx)>3) {
			filx=Mid(filx,Len(filx)-4,4)
		}
		if((filx!=".jpg")&&(filx!="jpeg")&&(filx!=".gif")) {
			//error if file type is wrong
			alert("File type must be GIF, JPG or JPEG.");
			return false
		}
	else {
		//Make sure they really want to do this
		var agree=confirm("You are about to upload a photo to the server. Upload time depends upon file size and connection speed. Click OK to continue.");
		if (agree)
			return true;
		else
			return false;
		}
	}
else
	{
	alert(msg);
	document.uploadphoto.titletext.focus();
	return false
	}
}

function checkquickphoto (msg) {
// Check Photo Form
	titl=document.uploadphoto.titletext.value;
	filn=document.uploadphoto.filenametext.value;
	if((titl!='')&&(filn!='')) {
		//drop to lowercase and get right 3 characters
		filx = LCase(RTrim(filn));
		if(Len(filx)>3) {
			filx=Mid(filx,Len(filx)-4,4)
		}
		if((filx!=".jpg")&&(filx!="jpeg")&&(filx!=".gif")) {
			//error if file type is wrong
			alert("File type must be GIF, JPG or JPEG.");
			return false
		}
	else {
		//Make sure they really want to do this
		var agree=confirm("You are about to upload a photo to the server. Upload time depends upon file size and connection speed. Click OK to continue.");
		if (agree)
			return true;
		else
			return false;
		}
	}
else
	{
	alert(msg);
	document.uploadphoto.titletext.focus();
	return false
	}
}

function checkUpload (msg) {
// Ask for Confirmation on Upload (in File Manager)
	filn=document.prepareupload.filenametext.value;
	if(filn!='') {
		//Make sure they really want to do this
		var agree=confirm("You are about to upload a file to the server. Upload time depends upon file size and connection speed. Click OK to continue.");
		if (agree)
			return true;
		else
			return false;
	}
	else {
		alert(msg);
		return false
	}
}

function checkpropertyupload (msg) {
// Check Photo Upload from property module
	if(sButton == 'Upload Photo') {
		filn=document.uploadphoto.filenametext.value;
		if(filn!='') {
			//drop to lowercase and get right 3 characters
			filx = LCase(RTrim(filn));
			if(Len(filx)>3) {
				filx=Mid(filx,Len(filx)-4,4)
			}
			if((filx!=".jpg")&&(filx!="jpeg")&&(filx!=".gif")) {
				//error if file type is wrong
				alert("File type must be GIF, JPG or JPEG.");
				return false
			}
		else {
			//Make sure they really want to do this
			var agree=confirm("You are about to upload a photo to the server. Upload time depends upon file size and connection speed. Click OK to continue.");
			if (agree)
				return true;
			else
				return false;
			}
		}
	else
		{
		alert(msg);
		document.uploadphoto.filenametext.focus();
		return false
		}
	}
}

function checkevent (msg) {
// Add Calendar Event Form
	if((document.addevent.summarytext.value!='')&&(document.addevent.startdate.value!=''))
		{ return true }
	else {
		alert(msg);
		document.addevent.summarytext.focus();
		return false
	}
}

function checkregister0 (msg) {
// Registration Form Step 0
	nme=document.register.username.value;
	if (document.register.strongpassword.value=true) {
		pwd=document.register.password.value;
		vpd=document.register.verifypassword.value;
	}
	else {
		pwd=document.register.password.value.toLowerCase();
		vpd=document.register.verifypassword.value.toLowerCase();
	}

	if((pwd!='')&&(vpd!='')&&(nme!='')) {
		if(nme.length<2) {
			alert("User Name must be at least 2 characters long.");
			document.register.username.focus();
			return false
		}
	else {
		if(pwd!=vpd) {
			alert("Password and Verify Password must match.");
			document.register.password.focus();
			return false
			}
		else {
			var iChars = "!@#$%^&*()_+-={}[]~`|:;'<>,.?/\\\" ";
			for (var i = 0; i < pwd.length; i++) 
				{
				if (iChars.indexOf(pwd.charAt(i)) != -1) {
					alert ("Password cannot have special characters.");
					document.register.password.focus(); 
					return false;
					}
				}
			for (i = 0; i < nme.length; i++) 
				{
				if (iChars.indexOf(nme.charAt(i)) != -1) {
					alert ("User Name cannot have special characters.");
					document.register.username.focus();
					return false;
					}
				}
			var imin=document.register.minpassword.value;
			var imax=document.register.maxpassword.value;
			if (pwd.length<imin) {
				alert ("Password must be at least " + imin + " characters long");
				document.register.password.focus();  
				return false;
				}
			if (pwd.length>imax) {
				alert ("Password must be less than " + imax + " characters long");
				document.register.password.focus();  
				return false;
				}
			return true
			}
		}
	}
else {
	alert(msg);
	document.register.username.focus();
	return false
	}
}


function checkregister1 () {
// Registration Form Step 1
	rrn=document.register.lastname.value;
	cit=document.register.city.value;
	sta=document.register.state.value;
	rem=document.register.email.value;
	if ((document.register.requirerealname.value == 1) && (rrn == '')) {
		alert ("Name is required.");
		document.register.lastname.focus();
		return false;
		}
	if ((document.register.requireemail.value == 1) && (rem.length < 7)) {
		alert ("Email address is required and should be in name@domain.com format.");
		document.register.email.focus();
		return false;
		}
	if (document.register.requireaddress.value > 0) {
		if ((cit == '')||(sta == '')) {
			alert ("City and State/Prov is required.");
			document.register.city.focus();
			return false;
			}
		if (document.register.useraddress.value == 2) {
			if (document.register.address.value == '') {
				alert ("Postal address is required.");
				document.register.address.focus();
				return false;
				}
			}
		}
	return true
}

function checkregister4 () {
// Registration Form Step 4 - Bot Stopper
	cwd=document.register.cwordtext.value.toLowerCase();
	if ((cwd<"a")||(cwd>"f")) {
		alert ("You didn't enter the correct letter. Use A - F.");
		document.register.cwordtext.focus();
		return false;
		}
	return true
}

function checktrip (msg) {
// Trip Report (without Templates)
	tdt=document.savetrip.tripdate.value;
	sdt=document.savetrip.shortdesctext.value;
	lon=document.savetrip.locationname.value;
	pit=document.savetrip.starttext.value;
	trt=document.savetrip.tripreporttext.value;
	if((tdt!='')&&(lon!='')&&(sdt!='')&&(pit!='')&&(trt!=''))
		{ return true }
	else {
		alert(msg);
		document.savetrip.tripdate.focus();
		return false
	}
}

function checkpropertysave (msg) {
// Property Save
	pnt=document.saveproperty.propertynametext.value;
	adt=document.saveproperty.addresstext.value;
	cit=document.saveproperty.citytext.value;
	pct=document.saveproperty.postalcodetext.value;
	rnt=document.saveproperty.realnametext.value;
	if((pnt!='')&&(adt!='')&&(cit!='')&&(pct!='')&&(rnt!=''))
		{
		if ((document.saveproperty.waiver.checked == true)||(document.saveproperty.waiver.value == "1"))
			{ return true }
		else {
			alert("To continue, you must agree to the property listing waiver.");
			document.saveproperty.waiver.focus();
			return false
			}
		}
	else {
		alert(msg);
		document.saveproperty.propertynametext.focus();
		return false
	}
}

function checkreportdate (msg) {
// Trip Report (used with Templates)
	tdt=document.savetrip.tripdate.value;
	sdt=document.savetrip.shortdesctext.value;
	pit=document.savetrip.starttext.value;
	if(tdt!=''&&(sdt!='')&&(pit!=''))
		{ return true }
	else {
		alert(msg);
		document.savetrip.tripdate.focus();
		return false
	}
}

function checktriptmp (msg) {
// Trip Templates
	if(document.template.templatetype.value!='')
		{ return true }
	else {
		alert(msg);
		document.template.templatetype.focus();
		return false
	}
}

function checktripregion (msg) {
// Trip Regions
	rnt=document.region.regionnametext.value;
	des=document.region.desctext.value;
	if(sButton == 'Save') {
		if(rnt!=''&&(des!=''))
			{ return true }
		else {
			alert(msg);
			document.region.regionnametext.focus();
			return false
		}
	}
}

function checkpropertyarea (msg) {
// PS-Realty Areas
	ant=document.area.areanametext.value;
	des=document.area.areadesctext.value;
	cit=document.area.areacitiestext.value;
	if(sButton == 'Save') {
		if(ant!=''&&(des!='')&&(cit!=''))
			{ return true }
		else {
			alert(msg);
			document.area.areanametext.focus();
			return false
		}
	}
}

function checkproptype(msg) {
// Property Type
	if(sButton == 'Save') {
		if(document.type.typetext.value != '')
			{ return true }
		else {
			alert(msg);
			document.type.typetext.focus();
			return false
		}
	}
}

function checkprivateemail (msg) {
// Send Private Email Form
	// Use text property instead of value for IE6
	var s = document.getElementById("subjecttext");
	sut=s.options[s.selectedIndex].text;
	if(sut == '-Pick-') { sut = "" }
	//
	mst=document.sendemail.msgtext.value;
	ynt=document.sendemail.yournametext.value;
	yxt=document.sendemail.youremailtext.value;
	if((sut!='')&&(mst!='')&&(ynt!='')&&(yxt!=''))
		{ return true }
	else {
		alert(msg);
		document.sendemail.subjecttext.focus();
		return false
	}
}

function checkfriendemail (msg) {
// Send Email to Friend (from Micro Toolbar)
	fet=document.sendemail.friendemailtext.value;
	sut=document.sendemail.subjecttext.value;
	mst=document.sendemail.msgtext.value;
	ynt=document.sendemail.yournametext.value;
	yxt=document.sendemail.youremailtext.value;
	if((fet!='')&&(sut!='')&&(mst!='')&&(ynt!='')&&(yxt!=''))
		{ return true }
	else {
		alert(msg);
		document.sendemail.friendemailtext.focus();
		return false
	}
}

function checklocation(msg) {
// Trip Location Form
	if((document.addlocation.locationname.value!='')&&(document.addlocation.locationdesc.value!=''))
		{ return true }
	else {
		alert(msg);
		document.addlocation.locationname.focus();
		return false
	}
}

function checkcomment(msg) {
// Comment Form
	if(document.addcomment.commenttext.value != '')
		{ return true }
	else {
		alert(msg);
		document.addcomment.commenttext.focus();
		return false
	}
}

function checkcartcat(msg) {
// Cart Category Form (for Premium Edition)
	if((document.cartcat.cartcatname.value == '') && (sButton == 'Save')) {
		alert(msg);
		document.cartcat.cartcatname.focus();
		return false
	}
	else { 
		return true
	}
}

function checkquizcat(msg) {
// Quiz Category Form
	if((document.quizcat.quizcatname.value == '') && (sButton == 'Save')) {
		alert(msg);
		document.quizcat.quizcatname.focus();
		return false
	}
	else { 
		return true
	}
}

function checkcartprod (msg) {
// Cart Product Form (for Premium Edition)
	psn=document.cartprod.shortnametext.value;
	pln=document.cartprod.longnametext.value;
	pup=document.cartprod.unitprice.value;
	if(((psn=='')||(pln=='')||(pup=='')) && (sButton == 'Save')) {
		alert(msg);
		document.cartprod.shortnametext.focus();
		return false
	}
	else {
		return true
	}
}

function checkcartinv (msg) {
// Cart Inventory Form (for Premium Edition)
	psk=document.cartinv.sku.value;
	pin=document.cartinv.inventorynametext.value;
	if(((psk=='')||(pin=='')) && (sButton == 'Save')) {
		alert(msg);
		document.cartinv.sku.focus();
		return false
	}
	else {
		return true
	}
}

function checkcartemail (msg) {
// Send Email from Cart Transactions Form (for Premium Edition)
	emt=document.cartemail.emailtotext.value;
	sut=document.cartemail.subjecttext.value;
	mst=document.cartemail.msgtext.value;
	yem=document.cartemail.youremailtext.value;
	if(((emt=='')||(sut=='')||(mst=='')||(yem==''))) {
		alert(msg);
		document.cartemail.emailtotext.focus();
		return false
	}
	else {
		return true
	}
}

function checkcartquantity (msg) {
// Make sure Cart Quantity field is at least 1
	var bGood = true;
	var bQty = true;

	try
		{ //Get Regular Quantity fields
		qty=parseInt(document.cartjump.quantity.value);
		}
	catch (e) 
		{ //Check to see if this is a matrix type product
		bQty = false;
		qty = 0;
		iMXcol=document.cartjump.mxcol.value-0;
		iMXrow=document.cartjump.mxrow.value-0;
		for (var i = 0; i < iMXrow ; ++i) {
			for (var j = 0; j < iMXcol ; ++j) {
				try {
					nqty = parseInt(document.getElementById("mx" + i + "_" + j).value);
					if(isNaN(nqty)==true) { nqty = 0; }
					}
				catch (e)
					{ nqty = 0; }
				qty = qty + nqty;
				}
			}
		}
	if(qty<1) 
		bGood = false;
	else
		if(isNumberString(qty) == false)
			bGood = false;
		else
			if(qty-0 == 0)
				bGood = false;
	try
		{ 
		OOS = document.cartjump.OOS.value-0;
		QOH = document.cartjump.QuantityOnHand.value-0;
		}
	catch (e) 
		{
		OOS = 1
		QOH = 0;
		}

	if(bGood==true)
		qty=qty-0;
		if((OOS==2||OOS==3)&&(qty>QOH)) {
			msg = "Quantity entered " + qty + " exceeds stock of " + QOH + "."
			bGood = false;
		}

	if(bGood==false) {
		alert(msg);
		if(bQty==true)
			document.cartjump.quantity.focus();
	}

	return bGood;
}


function checkcartdownload(msg) {
// Cart Download Form (for Premium Edition)
	if(((document.cartdownload.versiontext.value == '')||(document.cartdownload.filesizetext.value == '')||(document.cartdownload.originalurltext.value == '')) && (sButton == 'Save')) {
		alert(msg);
		document.cartdownload.versiontext.focus();
		return false
	}
	else { 
		return true
	}
}

function checkcarttrans(msg) {
// Cart Transaction Entry Form (for Premium Edition)
	if(((document.carttrans.purchasedate.value == '')||(document.carttrans.transactionidtext.value == '')||(document.carttrans.amountreceived.value == '')) && (sButton == 'Save')) {
		alert(msg);
		document.carttrans.purchasedate.focus();
		return false
	}
	else {
		if ((document.carttrans.makedownloaddir.checked) && (document.carttrans.downloaddirtext.value == '')) {
			alert ("Download Directory Name required.");
			document.carttrans.downloaddirtext.focus();
			return false;
			}
		else { 
			return true
		}
	}
}

function checkfreedownload (msg) {
// Free Downloads (for Premium Edition)
	rnm=document.freedownload.RealNameText.value;
	ema=document.freedownload.EmailText.value;
	cit=document.freedownload.CityText.value;
	sta=document.freedownload.StateText.value;
	if((rnm!='')&&(ema!='')&&(cit!='')&&(sta!='')) {
		return true
	}
	else {
		alert(msg);
		document.freedownload.RealNameText.focus();
		return false
	}
}

function checkmempayments (msg) {
// Member Payment Form
	if((document.memberpayments.paymentdate.value == '')||(document.memberpayments.paymentamount.value == '')||(document.memberpayments.paymentmethod.value == '')) {
		alert(msg);
		document.memberpayments.paymentdate.focus();
		return false
	}
	else { 
		return true
	}
}

function checkmembersetup (msg) {
// Member Setup
	if((document.membersetup.membersingular.value == '')||(document.membersetup.memberplural.value == '')||(document.membersetup.groupsingular.value == '')||(document.membersetup.groupplural.value == '')||(document.membersetup.roster.value == '')) {
		alert(msg);
		document.membersetup.membersingular.focus();
		return false
	}
	else { 
		return true
	}
}

function checknewsletter (msg) {
// Subscribe Newsletter Form
if(document.newsletter.emailtext.value != '')
	{ return true }
else {
	alert(msg);
	document.newsletter.emailtext.focus();
	return false
	}
}


// End -->