// JavaScript Document
// Client Side Scripting for form validation

var oType = "";
var myString = ""
var ttypestring = ""
var good;


function verifyinputNew(form)

{
var f = document.mainformNew;
if (f.fullname.value == "") {
alert('Full Name Required!');
f.fullname.focus();
return false;
}

if (f.accsubtype.value == "OTGT-Help") {
alert('Invalid Form Entry');
f.fullname.focus();
return false;
}

good = false
if (f.email.value == "") {
alert('Please enter a valid e-mail address.');
f.email.focus();
return false;
}

else
{
var goodEmail = f.email.value.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi);
if (goodEmail){
   good = true
} else {
   alert('Please enter a valid e-mail address.')
   f.email.focus()
   good = false
   return false;
   }
   }

   
var goodZip = f.zip.value
var valid = "0123456789-";
var hyphencount = 0;

if (goodZip.length!=5 && goodZip.length!=10) {
alert("Please enter a valid zip code.");
return false;
}
for (var i=0; i < goodZip.length; i++) {
temp = "" + goodZip.substring(i, i+1);
if (temp == "-") hyphencount++;
if (valid.indexOf(temp) == "-1") {
alert("Please enter a valid zip code.");
return false;
}
if ((hyphencount > 1) || ((goodZip.length==10) && ""+goodZip.charAt(5)!="-")) {
alert("Please enter a valid zip code.");
return false;
   }
   
if (f.detect.value != "onetouch") {
alert('Error. Please re-enter the word you see');
f.detect.focus();
return false;
}

}
return true;

}
function winstatus() {
	window.status = "Welcome to One Touch Global Technologies LeadCapture";
}

// GDL 5/15/04 - this function concatenates the OS checkboxes to one value
// the result will be added to Contact.Userfield4
// GDL 8/3/04 - changed function to check for day of week to be contacted

 
function testfieldlength() {

//GDL 11/15/05 - this function will test the field length of the input box and ensure that it is less than 200 characters

	var d = document.mainformNew
	if (d.comments.value.length > 200) {
		d.comments.value = d.comments.value.substring(0,200);}
	else {
		d.remLen.value = d.comments.value.length
	}
}
