//Declare form globally for use by all sub-routines; will be set in main checkForm() routinevar form;//text fields that need checked to ensure they aren't blank // "FaxNumber", var textfields = new Array("FirstName", "LastName", "EmailAddress","PhoneNumber", "CompanyName", "StreetAddress1", "City", "CU");	//'friendly' names of the above text fieldsvar textfieldsVisible = new Array("First Name", "Last Name", "Email Address","Phone Number","Organization Name", "Street Address", "City", "Concurrent User Licenses");//combo boxes that need checked to ensure the user chose somethingvar dropdown = new Array("State", "Country", "OrganizationType", "OrderProduct", "HearAbout", "ProfFunction");		// 'friendly' message for above unselected combobox fieldsvar dropdownVisible = new Array("Please select your State/Province.", "Please select your Country.","Please select an Organization Type.","Please select the library you wish to order.","Please select how you heard about Accounting Research Manager.","Please select your Professional Function.")/*=============================================Function Name:	checkForm()Parameters:		none	Description:	Called from the Submit button.  Is the main function toverify all data input from the enduser using the subroutines below=============================================*/function checkForm() {	form = document.forms[0];	var bReturn 		//Check text fields for blank values	bReturn = false;  //initialize	bReturn= checktextfields();	if (bReturn) {					//Checkthat CU field is a number		bReturn = false;  //initialize		bReturn= checkCU();		if (bReturn) {						//Check e-mail input			bReturn = false;  //initialize			bReturn = checkemail()					if (bReturn ) {									//Check phone/fax input				bReturn = false;  //initialize				bReturn = checkphone();				if (bReturn ) {									//Check combo boxes for valid selection					bReturn = false;  //initialize					bReturn = checkdropdowns();					if (bReturn ) {						return true;					} else {						return false;					}									} else { 	//phone/fax validation failed					return false;				}						} else { 	//e-mail validation failed				return false;			}				} else { 	//CU is not numeric			return false;		}	} else { 	//a text input is blank		return false;	}}/*=============================================Function Name:	checktextfields()Parameters:		none	Description:	takes the text input variables and verifies	that theyare not blank.  If all valid, calls the checkphone method and if okay,then calls the checkemail method.=============================================*/function checktextfields() 	{	var fieldvalue;		//loop thru textfields array and check for null	for (var counter=0; counter < textfields.length; counter++) {			if (eval('form.' + textfields[counter]) ) { //check that field exists			fieldvalue = eval('form.' + textfields[counter] + '.value');			if (fieldvalue.length=="0") {				alert("Please enter your " + textfieldsVisible[counter] + ".");				eval('form.' + textfields[counter] + '.focus()');				return false;			}			}		}	return true;}/*=============================================Function Name:	checkCU()Parameters:		none	Description:  Tests that the value of the CU input is numeric=============================================*/function checkCU() {	if (form.CU) {		if (isNumber(form.CU.value)==false) {			alert('Concurrent User Licenses must be a number.');			form.CU.focus();			return false;		}	}	return true;}/*=============================================Function Name:	checkemail()Parameters:		none	Description:  Takes the value of the e-mail address inputfield and checks for both valid characters and format=============================================*/function checkemail() 	{	var BadEmail = new Array();	BadEmail = document.forms[0].BadDomains.value.split( ', ' )	var Email = form.EmailAddress.value;	var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;	var check=/@[\w\-]+\./;	var checkend=/\.[a-zA-Z]{2,4}$/;		//Set support string	if (form.Support) {		var support =  "\n\nIf you have any questions, please contact : \n\n" + form.Support.value ;	} else {		var support =  "\n\nIf you have any questions, please contact Customer Support";	}		 if(((Email.search(exclude) != -1) || (Email.search(check))== -1) || (Email.search(checkend) == -1)) { //bad format for the email address		 alert("Please enter your E-mail Address in the format name@someplace.something\n\nexample: smith@myorganization.com");		 form.EmailAddress.focus();		 return false	 } else { //unsupported e-mail domains		for (var counter=0; counter < BadEmail.length; counter++) {			if((Email.toLowerCase().indexOf("@" + BadEmail[counter]) != -1) || (Email.toLowerCase().indexOf("." + BadEmail[counter]) != -1) ) {				alert("Your e-mail address '" + Email.toLowerCase() + "' is not supported. \n" +				"Our acceptance policies do not allow the use of \n" +				"personal e-mail addresses.\n\n" +				"Please provide your e-mail address with your \n" +				"organization's e-mail extension.\n" +				"Example: johnsmith@organization.com" + support)				form.EmailAddress.focus();				form.EmailAddress.select();				return false;			}					}		//legit email address	  	return true;	 }}/*=============================================Function Name:	checkphone()Parameters:		none	Description:  verifies that only legit characters are in the Phone and Faxinputs, and that its length is sufficient for a valid phone/fax number=============================================*/function checkphone() {	var ValidCharacters = "0123456789()-+ .";	var PhoneNumber = form.PhoneNumber.value	var FaxNumber = form.FaxNumber.value		if (PhoneNumber.length < 10) {		alert('Phone number must be at least ten digits.');		form.PhoneNumber.focus();		return false;	}	if (FaxNumber.length < 10 & FaxNumber.length > 0) {		alert('Fax number must be at least ten digits.');		form.FaxNumber.focus();		return false;	}	for (var counter=0; counter <= PhoneNumber.length - 1; counter++) {		if (ValidCharacters.indexOf(PhoneNumber.charAt(counter)) == -1) {			alert('Please enter your phone number using numeric values only.')			form.PhoneNumber.focus();			return false;		}	}	for (var counter=0; counter <= FaxNumber.length - 1; counter++) {		if (ValidCharacters.indexOf(FaxNumber.charAt(counter)) == -1) {			alert('Please enter your phone number using numeric values only.')			form.FaxNumber.focus();			return false;		}	}	return true;}	/*=============================================Function Name:	checkdropdowns()Parameters:		none	Description:  loops thru all defined dropdown combo boxes and verifies that the user has selected a value for each of them.	=============================================*/function checkdropdowns() 	{	var index;	//Loop thru defined combo fields	for (var counter=0; counter < dropdown.length; counter++) {			//check that field exists		if (eval('form.' + dropdown[counter]) ) { 			index = eval('form.' + dropdown[counter] + '.selectedIndex');			if (index == 0) 	{				alert(dropdownVisible[counter]); //return defined error message				eval('form.' + dropdown[counter] + '.focus()');				return false;			}			}		}	return true;	}/*=============================================Function Name:  getCookieData(labelName)	Parameters:  labelName (cookie label to retrieve, in case several exist)Description: Retrieves cookie value for passed-in lable. Called from JScript directly on form to retrieve any ARM referrer value in 'ARMRef'=============================================*/function getCookieData(labelName) {	var labelLen = labelName.length	//Read cookie property only once for speed	var cookieData = document.cookie	var cLen = cookieData.length	var i = 0	var cEnd	while (i < cLen) {		var j = i + labelLen		if (cookieData.substring(i,j) == labelName && cookieData.substring(j,j+1) == "=") {  // added cookieData.substring(j,j+1) to handle partial name matches			cEnd = cookieData.indexOf( ";", j)			if (cEnd == -1) {				cEnd = cookieData.length			}			return unescape(cookieData.substring(j + 1, cEnd))		}		i++	}	return null }/*=============================================Function Name:	isNumeric(sVal)Parameters:		sVal  (string to be validated for numeric chars)Description:	Called from the Submit button.  Is the main function toverify all data input from the enduser using the subroutines below=============================================*/function isNumber(sVal) {	var ValidChars = "01234567890"	var sChar		for (i = 0 ; i < sVal.length ; i++) {	sChar = sVal.charAt(i)		if (ValidChars.indexOf(sChar) == -1 ) {			return false;		}	}	return true;}/*====================================Open new browser window, centered over the parent====================================*/function openWindowCenter (vurl, vname, vfeatures, wd, ht) {	//screen info	var sw=screen.width; 	var sh=screen.height; 		//parent position info 	//===========	var isFail = false //flag in case params not retrieved as intended		//main window top and Left	if (window.top.window.screenX && navigator.appName != 'Opera') { //Mozilla/NS compatible		var wLeft = window.top.window.screenX		var wTop = window.top.window.screenY		var pTyp = 1	} else if (window.top.screenLeft) {  //IE-compatible		var wLeft = window.top.screenLeft		var wTop = window.top.screenTop - 80  //70 is to compensate for menu, toolbar, etc. chrome height not incl in screenTop		var pTyp = 2	} else {		var wLeft = 0		var wTop = 0		var pTyp = 3		isFail = true	}		//main window width and height	if (parent.top.window.outerWidth) { //Mozilla/NS compatible		var wWd = parent.top.window.outerWidth		var wHt = parent.top.window.outerHeight		pTyp += 'a'	} else if (parent.top.window.document.body) {   //IE-compatible		var wWd = parent.top.window.document.body.offsetWidth		var wHt = parent.top.window.document.body.offsetHeight		pTyp += 'b'	} else {		var wWd = 0		var wHt = 0		pTyp += 'c'		isFail = true	}		//alert('wLeft: ' + wLeft + '\nwTop: ' + wTop+ '\nwWd: ' + wWd + '\nwHt: ' + wHt + '\nType: ' + pTyp + '\nBrowser: ' + navigator.appName + '\nVersion: ' + bVersion)	//return false;		//Set final Top and Left positions	if (isFail) {  //simply load screen-center if any dimension failures occur		var left= Math.round( (sw - wd)/2 ); 		var top= Math.round( (sh - ht)/2 ); 	} else {		var left= wLeft + Math.round( (wWd - wd) / 2) ;		var top= wTop + Math.round( (wHt - ht) / 2);	}					var optsall='location,menubar,resizable,scrollbars,status,titlebar,title,toolbar,directories,width=' + wd +',height=' + ht + ',innerWidth=' + wd +',Height=' + ht + ",top=" + top + ",left=" + left	var opts= vfeatures + ',width=' + wd +',height=' + ht + ',innerWidth=' + wd +',innerHeight=' + ht + ",top=" + top + ",left=" + left	wprint = window.open(vurl,vname, opts, false ); 	wprint.window.focus();}