/*
The isEmpty and isWhitespace functions were taken straight from Netscape's JavaScript development site, http://developer
.netscape.com.
*/
var numb = '0123456789';
var lwr = 'abcdefghijklmnopqrstuvwxyz';
var upr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';

function isValid(parm,val) {
        if (parm == "") return true;
        for (i=0; i<parm.length; i++) {
                if (val.indexOf(parm.charAt(i),0) == -1) return false;
        }
        return true;
}

function trim(s) {
        return s.replace(/^\s+|\s+$/g, "");
}

function isNum(parm) {return isValid(parm,numb);}

// whitespace characters
var whitespace = " \t\n\r";

/****************************************************************/
function leftpad(theItem, thePad, minSize) {
	newItem = new String(theItem);
	while (newItem.length < minSize) {
		newItem = thePad + newItem;
	}
	return newItem;
}

/****************************************************************/
function isEmpty(s) {
// Check whether string s is empty.
	return ((s == null) || (s.length == 0))
}

/****************************************************************/
function isWhitespace(s) {
	var i;

// Is s empty?
	if (isEmpty(s))
		return true;

// Search through string's characters one by one
// until we find a non-whitespace character.
// When we do, return false; if we don't, return true.

        for (i = 0; i < s.length; i++) {
// Check that current character isn't whitespace.
                var c = s.charAt(i);
                if (whitespace.indexOf(c) == -1)
                        return false;
        }

// All characters are whitespace.
        return true;
}

/****************************************************************/
function ForceEntry(val, str) {
        var strInput = new String(val.value);

        if (isWhitespace(strInput)) {
                alert(str);
                return false;
        }
 else
                return true;
}

/****************************************************************/
function ValidateCommonData(pronoun) {
USA="USA";
CANADA="CANADA";
        if (isEmpty(document.webform.Street_Address.value)) {
                alert("Please enter " + pronoun + " Street Address.");
                document.webform.Street_Address.focus();
                return false;
        }

        if (isEmpty(document.webform.Phone_Number.value)) {
                alert("Please enter " + pronoun + " Phone Number.");
                document.webform.Phone_Number.focus();
                return false;
        }

        if ((isEmpty(document.webform.City.value)) || (document.webform.State.selectedIndex == 0) || (isEmpty(document.webform.Zip_Code.value))) {
                alert("Please enter " + pronoun + " City, State/Province, Zip Code, and Country.");
                if (isEmpty(document.webform.City.value))
                        document.webform.City.focus();
                else if (document.webform.State.selectedIndex == 0)
                        document.webform.State.focus();
                else if (isEmpty(document.webform.Zip_Code.value))
                        document.webform.Zip_Code.focus();
                return false;
        }
	if ((document.webform.Country.value == USA) || (document.webform.Country.value == CANADA)) {
		if (document.webform.State.selectedIndex < 2) {
                	alert("Please enter " + pronoun + " State/Province.");
                        document.webform.State.focus();
                	return false;
        	}
        }
	return true;

}

/****************************************************************/
function CountWords(this_field, show_word_count, show_char_count) {
	if (show_word_count == null) {
		show_word_count = true;
	}
	if (show_char_count == null) {
		show_char_count = false;
	}
	var char_count = this_field.length;
	var fullStr = this_field + " ";
	var initial_whitespace_rExp = /^[^A-Za-z0-9]+/gi;
	var left_trimmedStr = fullStr.replace(initial_whitespace_rExp, "");
	var non_alphanumerics_rExp = rExp = /[^A-Za-z0-9]+/gi;
	var cleanedStr = left_trimmedStr.replace(non_alphanumerics_rExp, " ");
	var splitString = cleanedStr.split(" ");
	var word_count = splitString.length -1;
	if (fullStr.length < 2) {
		word_count = 0;
	}
	if (word_count == 1) {
		wordOrWords = " word";
	}
	else {
		wordOrWords = " words";
	}
	if (char_count == 1) {
		charOrChars = " character";
	} else {
		charOrChars = " characters";
	}
	if (show_word_count & show_char_count) {
		alert ("Word Count:\n" + "    " + word_count + wordOrWords + "\n" + "    " + char_count + charOrChars);
	}
	else {
		if (show_word_count) {
			alert ("Word Count:  " + word_count + wordOrWords);
		}
		else {
			if (show_char_count) {
				alert ("Character Count:  " + char_count + charOrChars);
      			}
   		}
	}
	return word_count;
}

/****************************************************************/
var selectedOptions = [];
function countSelected(select,maxNumber){
	for (var i=0; i<select.options.length; i++){
		if (select.options[i].selected && select.options[i].value != "" && !new RegExp(i,'g').test(selectedOptions.toString())){
			selectedOptions.push(i);
		}

		if (!select.options[i].selected && new RegExp(i,'g').test(selectedOptions.toString())){
			selectedOptions = selectedOptions.sort(function(a,b){return a-b});  
			for (var j=0; j<selectedOptions.length; j++){
				if (selectedOptions[j] == i){
					selectedOptions.splice(j,1);
				}
			}
		}

		if (select.options[i].value == "") {
			select.options[i].selected = false;
		}
		if (selectedOptions.length > maxNumber) {
			var throwAlert = true;
			select.options[i].selected = false;
			selectedOptions.pop();
		}
	}

	if (throwAlert == true){
		return false;
	}
	else
		return true;
}

/****************************************************************/
function ValidateBRData() {
//<input type=hidden name="required" value="realname,email,BookTitle,BookAuthor,Publisher,PublicationYear,ISBN,SCNBR_SentMeThisBook,AmazonLink,AmazonReviews,SCNBR_PersonalAssoc,YourReview,AuthorInfo">

max_word_count=1000;

        if (isEmpty(document.webform.realname.value)) {
                alert("Please enter your Name.");
                document.webform.realname.focus();
                return false;
        }
        if (isEmpty(document.webform.email.value)) {
		alert("Please enter your Email Address.");
                document.webform.email.focus();
                return false;
        }
	else {
		email=document.webform.email.value;
		if ((email.indexOf("@") == -1) || (email.indexOf(".") == -1)) {
			alert("Invalid email address: '" + email + "'");
			document.webform.email.focus();
			return false;
		}
        }
        if ((document.webform.SCN_member[0].checked == false) & (document.webform.SCN_member[1].checked == false)) {
		alert("Please indicate whether or not you are a dues-paying SCN member.");
                document.webform.SCN_member[0].focus();
                return false;
        }
	if ((document.webform.numreviews.selectedIndex == -1) || (document.webform.numreviews.value == "")) {
                alert("Please indicate the number of reviews you have written for SCBR");
                document.webform.numreviews.focus();
                return false;
        }
        if (document.webform.numreviews.selectedIndex == 1) {
        	if (isEmpty(document.webform.YourBio.value)) {
			alert("Please enter your brief bio.");
                	document.webform.YourBio.focus();
                	return false;
        	}
        }
	else {
        	if (!isEmpty(document.webform.YourBio.value)) {
			alert("If this is not your first review, please remove your brief bio from this form. If this IS your first review, please check the box above.");
                	document.webform.YourBio.focus();
                	return false;
        	}
        }
        if (isEmpty(document.webform.BookTitle.value)) {
		alert("Please enter the title of the book.");
                document.webform.BookTitle.focus();
                return false;
        }
	else {
        	document.webform.thisbooktitle.value=document.webform.BookTitle.value;
        }
        if (isEmpty(document.webform.BookAuthor.value)) {
		alert("Please enter the author's name.");
                document.webform.BookAuthor.focus();
                return false;
        }
        if (isEmpty(document.webform.Publisher.value)) {
		alert("Please enter the book publisher's name.");
                document.webform.Publisher.focus();
                return false;
        }
        if (isEmpty(document.webform.PublicationYear.value)) {
		alert("Please enter the year that the book was published.");
                document.webform.PublicationYear.focus();
                return false;
        }
        if (isEmpty(document.webform.ISBN.value)) {
		alert("Please enter the ISBN of the book.");
                document.webform.ISBN.focus();
                return false;
        }
        if ((document.webform.SCNBR_SentMeThisBook[0].checked == false) & (document.webform.SCNBR_SentMeThisBook[1].checked == false)) {
		alert("Please indicate whether or not SCN sent you this book to review.");
                document.webform.SCNBR_SentMeThisBook[0].focus();
                return false;
        }
       	if (isEmpty(document.webform.AmazonLink.value)) {
		alert("Please enter the amazon.com link to this book.");
               	document.webform.AmazonLink.focus();
               	return false;
       	}
	else {
		amazonlinkorig = document.webform.AmazonLink.value;
		amazonlink1 = amazonlinkorig;
		while (amazonlink1.indexOf(" ") != -1) {
			amazonlink2 = amazonlink1.replace(" ", "");
			amazonlink1 = amazonlink2;
       		}
		if (amazonlink1 != amazonlinkorig)
			document.webform.AmazonLink.value=amazonlink1;
       	}
	numrevs = document.webform.AmazonReviews.value;
	while (numrevs.indexOf(" ") != -1) {
		numrevs2 = numrevs.replace(" ", "");
		numrevs = numrevs2;
       	}
	document.webform.AmazonReviews.value=numrevs;
        if (isEmpty(document.webform.AmazonReviews.value)) {
		alert("Please enter the number of reviews of this book that are currently on amazon.com.");
                document.webform.AmazonReviews.focus();
                return false;
        }
	else {
		if (!isNum(document.webform.AmazonReviews.value)) {
                        alert("You entered a non-numeric value (" + document.webform.AmazonReviews.value + ") in the 'How many other reviews are currently posted on this title?' field; please correct.");
			document.webform.AmazonReviews.value="";
                	document.webform.AmazonReviews.focus();
                	return false;
        	}
        }
        if ((document.webform.SCNBR_PersonalAssoc[0].checked == false) & (document.webform.SCNBR_PersonalAssoc[1].checked == false)) {
		alert("Please indicate whether or not you have a personal association with the author or publisher of this book.");
                document.webform.SCNBR_PersonalAssoc[0].focus();
                return false;
        }
	else {
        	if ((document.webform.SCNBR_PersonalAssoc[0].checked == true) & (isEmpty(document.webform.SCNBR_PersonalAssocDesc.value))) {
			alert("Please describe your personal association with the author or publisher of this book.");
                	document.webform.SCNBR_PersonalAssocDesc.focus();
                	return false;
        	}
        }
	if ((document.webform.Category.selectedIndex == -1) || (document.webform.Category.value == "")) {
		if ((document.webform.Category.selectedIndex != -1) && (document.webform.Category.value == ""))
                	alert("Please select a valid subcategory");
		else
                	alert("Please select the book's category");
                document.webform.Category.focus();
                return false;
        }
	else {
		if (countSelected(document.webform.Category,3) == false) {
                	alert("No more than 3 categories may be selected; only the first 3 have been saved.");
                	document.webform.Category.focus();
                	return false;
        	}
        }
        if (isEmpty(document.webform.YourReview.value)) {
		alert("Please enter your review.");
                document.webform.YourReview.focus();
                return false;
        }
	else {
		YourReview=document.webform.YourReview.value;
		wordcount=CountWords(YourReview,0,0);
		if (wordcount > max_word_count) {
			alert("Your review must be no more than " + max_word_count + " words (it is currently " + wordcount + " words). Please shorten it and re-submit.");
                	document.webform.YourReview.focus();
                	return false;
        	}
		else {
//deal w/ accented "special" characters
			YourReview1 = YourReview;
			aacute="á";
			agrave="à";
			eacute="é";
			egrave="è";
			iacute="í";
			igrave="ì";
			oacute="ó";
			ograve="ò";
			ugrave="ù";
			uacute="ú";
			Aacute="Á";
			Agrave="À";
			Eacute="É";
			Egrave="È";
			Iacute="Í";
			Igrave="Ì";
			Oacute="Ó";
			Ograve="Ò";
			Uacute="Ú";
			Ugrave="Ù";
			while (YourReview1.indexOf(aacute) != -1) {
				YourReview2 = YourReview1.replace(aacute, "&aacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(agrave) != -1) {
				YourReview2 = YourReview1.replace(agrave, "&agrave;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(eacute) != -1) {
				YourReview2 = YourReview1.replace(eacute, "&eacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(egrave) != -1) {
				YourReview2 = YourReview1.replace(egrave, "&egrave;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(iacute) != -1) {
				YourReview2 = YourReview1.replace(iacute, "&iacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(igrave) != -1) {
				YourReview2 = YourReview1.replace(igrave, "&igrave;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(oacute) != -1) {
				YourReview2 = YourReview1.replace(oacute, "&oacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(ograve) != -1) {
				YourReview2 = YourReview1.replace(ograve, "&ograve;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(uacute) != -1) {
				YourReview2 = YourReview1.replace(uacute, "&uacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(ugrave) != -1) {
				YourReview2 = YourReview1.replace(ugrave, "&ugrave;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Aacute) != -1) {
				YourReview2 = YourReview1.replace(Aacute, "&Aacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Agrave) != -1) {
				YourReview2 = YourReview1.replace(Agrave, "&Agrave;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Eacute) != -1) {
				YourReview2 = YourReview1.replace(Eacute, "&Eacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Egrave) != -1) {
				YourReview2 = YourReview1.replace(Egrave, "&Egrave;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Iacute) != -1) {
				YourReview2 = YourReview1.replace(Iacute, "&Iacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Igrave) != -1) {
				YourReview2 = YourReview1.replace(Igrave, "&Igrave;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Oacute) != -1) {
				YourReview2 = YourReview1.replace(Oacute, "&Oacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Ograve) != -1) {
				YourReview2 = YourReview1.replace(Ograve, "&Ograve;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Uacute) != -1) {
				YourReview2 = YourReview1.replace(Uacute, "&Uacute;");
				YourReview1 = YourReview2;
        		}
			while (YourReview1.indexOf(Ugrave) != -1) {
				YourReview2 = YourReview1.replace(Ugrave, "&Ugrave;");
				YourReview1 = YourReview2;
        		}
			if (YourReview1 != YourReview)
				document.webform.YourReview.value=YourReview1;
        	}
        }
        if (isEmpty(document.webform.AuthorInfo.value)) {
		alert("Please enter some information about the author.");
                document.webform.AuthorInfo.focus();
                return false;
        }
        if (document.webform.DoNotPostOnAmazon.checked == false) {
        	if (isEmpty(document.webform.AmazonTitle.value)) {
			alert("Please enter the title of your review for posting on amazon.com.");
                	document.webform.AmazonTitle.focus();
                	return false;
        	}
        	if (isEmpty(document.webform.AmazonRanking.value)) {
			alert("Please indicate your ranking of this book for posting on amazon.com.");
                	document.webform.AmazonRanking.focus();
                	return false;
        	}
        }
	else {
        	document.webform.AmazonTitle.value="";
        	document.webform.AmazonRanking.selectedIndex=0;
        }
	thishii="scbr";
        if (isEmpty(document.webform.hii.value)) {
		alert("Please enter the answer to the Human Intelligence Identification Question.");
                document.webform.hii.focus();
                return false;
        }
	else {
		hii=document.webform.hii.value;
		if (hii != thishii) {
			alert("You entered an incorrect value: '" + hii + "'. Please provide the correct answer to the required 'Human Intelligence Identification Answer'. This field must be filled in correctly before you can successfully submit the form.");
                	document.webform.hii.focus();
                	return false;
        	}
        }
	document.webform.hiianswer.value=thishii;
}

/****************************************************************/
function ValidateBRQData() {
//<input type=hidden name="required" value="realname,email,BookTitle,BookAuthor,Publisher,ReleaseDate,ISBN,Format,AmazonLink,SCN_member">

        if (isEmpty(document.webform.realname.value)) {
                alert("Please enter your Name.");
                document.webform.realname.focus();
                return false;
        }
        if (isEmpty(document.webform.email.value)) {
		alert("Please enter your Email Address.");
                document.webform.email.focus();
                return false;
        }
	else {
		email=document.webform.email.value;
		if ((email.indexOf("@") == -1) || (email.indexOf(".") == -1)) {
			alert("Invalid email address: '" + email + "'");
			document.webform.email.focus();
			return false;
		}
        }
        if (isEmpty(document.webform.BookTitle.value)) {
		alert("Please enter the title of the book.");
                document.webform.BookTitle.focus();
                return false;
        }
	else {
        	document.webform.thisbooktitle.value=document.webform.BookTitle.value;
        }
        if (isEmpty(document.webform.BookAuthor.value)) {
		alert("Please enter the author's name.");
                document.webform.BookAuthor.focus();
                return false;
        }
        if (isEmpty(document.webform.Publisher.value)) {
		alert("Please enter the book publisher's name.");
                document.webform.Publisher.focus();
                return false;
        }
        if (isEmpty(document.webform.ReleaseDate.value)) {
		alert("Please enter the date that the book was (or will be) released.");
                document.webform.ReleaseDate.focus();
                return false;
        }
        if (isEmpty(document.webform.ISBN.value)) {
		alert("Please enter the ISBN of the book.");
                document.webform.ISBN.focus();
                return false;
        }
	if ((document.webform.Format.selectedIndex == -1) || (document.webform.Format.value == "")) {
		if ((document.webform.Format.selectedIndex != -1) && (document.webform.Format.value == ""))
                	alert("Please select a valid format");
		else
                	alert("Please select the book's format");
                document.webform.Format.focus();
                return false;
        }
        if (isEmpty(document.webform.AmazonLink.value)) {
		alert("Please enter the amazon.com link for the book.");
                document.webform.AmazonLink.focus();
                return false;
        }
        if ((document.webform.SCN_member[0].checked == false) & (document.webform.SCN_member[1].checked == false)) {
		alert("Please indicate whether or not you are a dues-paying SCN member.");
                document.webform.SCN_member[0].focus();
                return false;
        }
	thishii="scbr";
        if (isEmpty(document.webform.hii.value)) {
		alert("Please enter the answer to the Human Intelligence Identification Question.");
                document.webform.hii.focus();
                return false;
        }
	else {
		hii=document.webform.hii.value;
		if (hii != thishii) {
			alert("You entered an incorrect value: '" + hii + "'. Please provide the correct answer to the required 'Human Intelligence Identification Answer'. This field must be filled in correctly before you can successfully submit the form.");
                	document.webform.hii.focus();
                	return false;
        	}
        }
	document.webform.hiianswer.value=thishii;
}

/****************************************************************/
function TotalAdAmt() {
	intro_period=document.webform.intro_period.value;
	ad_months=parseFloat(document.webform.ad_months.value);
	ad_rate_member=parseFloat(document.webform.ad_rate_member.value);
	ad_rate_member5=parseFloat(document.webform.ad_rate_member5.value);
	ad_rate_memberintro=parseFloat(document.webform.ad_rate_memberintro.value);
	ad_rate_memberintro3=parseFloat(document.webform.ad_rate_memberintro3.value);
	ad_rate_nonmember=parseFloat(document.webform.ad_rate_nonmember.value);
	ad_rate_nonmember5=parseFloat(document.webform.ad_rate_nonmember5.value);
	ad_rate_nonmemberintro=parseFloat(document.webform.ad_rate_nonmemberintro.value);
	ad_rate_nonmemberintro3=parseFloat(document.webform.ad_rate_nonmemberintro3.value);

	ad_rate=ad_rate_nonmember;
	ad_rate5=ad_rate_nonmember5;
	ad_rateintro=ad_rate_nonmemberintro;
	ad_rateintro3=ad_rate_nonmemberintro3;
	ad_msg="";
	which_rate="regular ";
	memberornot="non-member ";

	if (document.webform.SCN_member[0].checked == true) {
		memberornot="member ";
		ad_rate=ad_rate_member;
		ad_rate5=ad_rate_member5;
		ad_rateintro=ad_rate_memberintro;
		ad_rateintro3=ad_rate_memberintro3;
	}
	if (intro_period == "yes") {
//special introductory rate: 1st month at special rate; 3 months at 3month special rate
		if ((ad_months != 1) && (ad_months != 3)) {
			alert("During the introductory period you can only sign up for 1 or 3 months.");
			ad_months=1;
			document.webform.ad_months.value=ad_months;
		}
		if (ad_months == 1)
			this_ad_rate=ad_rateintro;
		else
			this_ad_rate=ad_rateintro3;
		which_rate="introductory ";
		ad_amt=this_ad_rate;
		ad_msg="$" + this_ad_rate + " for " + ad_months + " months (" + memberornot + which_rate + "rate)";
	}
	else {
		this_ad_rate=ad_rate;
		if (ad_months > 4) {
			this_ad_rate=ad_rate5;
			which_rate="reduced ";
		}
		ad_amt=this_ad_rate*ad_months;
		ad_msg="$" + this_ad_rate + " * " + ad_months + " months (" + memberornot + which_rate + "rate)";
	}
//	regrate_months=ad_months-1;
//	ad_amt=this_ad_rate*(regrate_months) + ad_rateintro;
//	ad_msg="$" + this_ad_rate + " * " + regrate_months + " months (" + memberornot + which_rate + "rate) + $" + ad_rateintro + " (1st month " + memberornot + "introductory rate)";
//	ad_msg=ad_msg"$" + ad_rateintro + " (1st month " + memberornot + "introductory rate) + $" + this_ad_rate + " * " + regrate_months + " months (" + memberornot + which_rate + "rate)";
//	ad_msg="$" + ad_rateintro + " (1st month " + memberornot + "introductory rate)";
//	if (regrate_months > 0) {
//		ad_msg=ad_msg + " + $" + this_ad_rate + " * " + regrate_months + " months (" + memberornot + which_rate + "rate)";
//	}
	document.webform.ad_amount.value=ad_amt.toFixed(2);
	document.webform.ad_amountdue.value=ad_amt.toFixed(2);
	document.webform.ad_amountdue2.value=ad_amt.toFixed(2);
	document.webform.ad_msg.value=ad_msg;
	document.webform.ad_msg2.value=ad_msg;

}

/****************************************************************/
function ValidateAdvData() {
//<input type=hidden name="required" value="realname,email,phone,SCN_member,ad_months,ad_imagelocation,ad_link,ad_description">

	intro_period=document.webform.intro_period.value;
        if (isEmpty(document.webform.realname.value)) {
                alert("Please enter your Name.");
                document.webform.realname.focus();
                return false;
        }
        if (isEmpty(document.webform.email.value)) {
		alert("Please enter your Email Address.");
                document.webform.email.focus();
                return false;
        }
	else {
		email=document.webform.email.value;
		if ((email.indexOf("@") == -1) || (email.indexOf(".") == -1)) {
			alert("Invalid email address: '" + email + "'");
			document.webform.email.focus();
			return false;
		}
        }
        if (isEmpty(document.webform.phone.value)) {
		alert("Please enter your Phone Number.");
                document.webform.phone.focus();
                return false;
        }
	if ((document.webform.SCN_member[0].checked == false) & (document.webform.SCN_member[1].checked == false)) {
		alert("Please indicate your membership status");
		document.webform.SCN_member[0].focus();
		return false;
	}
        if (isEmpty(document.webform.ad_months.value)) {
		alert("Please enter the number of months to run your ad.");
                document.webform.ad_months.focus();
                return false;
        }
	else {
		ad_months=document.webform.ad_months.value;
		if (!isNum(document.webform.ad_months.value)) {
                        alert("You entered a non-numeric value (" + document.webform.ad_months.value + ") in the 'number of months to run your ad' field; please correct.");
                        document.webform.ad_months.value="";
                        document.webform.ad_months.focus();
                        return false;
                }
		else {
			if (intro_period == "yes") {
				if ((ad_months != 1) && (ad_months != 3)) {
					alert("During the introductory period you can only sign up for 1 or 3 months. Please adjust your number of months.");
                			document.webform.ad_months.focus();
                			return false;
        			}
			}
		}
        }
        if (isEmpty(document.webform.ad_imagelocation.value)) {
		alert("Please enter the url of the image (jpg/gif) to run with your ad.");
                document.webform.ad_imagelocation.focus();
                return false;
        }
        if (isEmpty(document.webform.ad_link.value)) {
		alert("Please enter the link (your website, blog, etc.) to use with your ad.");
                document.webform.ad_link.focus();
                return false;
        }
        if (isEmpty(document.webform.ad_description.value)) {
		alert("Please enter a description of what you are advertising.");
                document.webform.ad_description.focus();
                return false;
        }
	thishii="scbr";
        if (isEmpty(document.webform.hii.value)) {
		alert("Please enter the answer to the Human Intelligence Identification Question.");
                document.webform.hii.focus();
                return false;
        }
	else {
		hii=document.webform.hii.value;
		if (hii != thishii) {
			alert("You entered an incorrect value: '" + hii + "'. Please provide the correct answer to the required 'Human Intelligence Identification Answer'. This field must be filled in correctly before you can successfully submit the form.");
                	document.webform.hii.focus();
                	return false;
        	}
        }
	document.webform.hiianswer.value=thishii;

	TotalAdAmt();
}

/****************************************************************/
function ValidateBkRqData() {
//<input type=hidden name="required" value="realname,email,streetaddress,city,state,zipcode,BookTitle,SCNBR_PersonalAssoc,numbooks,when_send_reviews">

        if (isEmpty(document.webform.realname.value)) {
                alert("Please enter your Name.");
                document.webform.realname.focus();
                return false;
        }
        if (isEmpty(document.webform.email.value)) {
		alert("Please enter your Email Address.");
                document.webform.email.focus();
                return false;
        }
	else {
		email=document.webform.email.value;
		if ((email.indexOf("@") == -1) || (email.indexOf(".") == -1)) {
			alert("Invalid email address: '" + email + "'");
			document.webform.email.focus();
			return false;
		}
        }
        if (isEmpty(document.webform.streetaddress.value)) {
		alert("Please enter your street address.");
                document.webform.streetaddress.focus();
                return false;
        }
        if (isEmpty(document.webform.city.value)) {
		alert("Please enter your city.");
                document.webform.city.focus();
                return false;
        }
	if (document.webform.state.selectedIndex < 2) {
		alert("Please indicate your State/Province.");
		document.webform.state.focus();
		return false;
	}
        if (isEmpty(document.webform.zipcode.value)) {
		alert("Please enter your zipcode.");
                document.webform.zipcode.focus();
                return false;
        }
        if (isEmpty(document.webform.BookTitle.value)) {
		alert("Please enter the title of the book.");
                document.webform.BookTitle.focus();
                return false;
        }
	else {
        	document.webform.thisbooktitle.value=document.webform.BookTitle.value;
        }
        if ((document.webform.SCNBR_PersonalAssoc[0].checked == false) & (document.webform.SCNBR_PersonalAssoc[1].checked == false)) {
		alert("Please indicate whether or not you have a personal association with the author or publisher of this book.");
                document.webform.SCNBR_PersonalAssoc[0].focus();
                return false;
        }
	else {
        	if ((document.webform.SCNBR_PersonalAssoc[0].checked == true) & (isEmpty(document.webform.SCNBR_PersonalAssocDesc.value))) {
			alert("Please describe your personal association with the author or publisher of this book.");
                	document.webform.SCNBR_PersonalAssocDesc.focus();
                	return false;
        	}
        }
	if ((document.webform.numbooks.selectedIndex == -1) || (document.webform.numbooks.value == "")) {
                alert("Please indicate the number of books you currently have for review at SCN");
                document.webform.numbooks.focus();
                return false;
        }
	else {
		if (document.webform.numbooks.value == "zero")
			document.webform.when_send_reviews.value="n/a";
        }
	if ((document.webform.numreviews.selectedIndex == -1) || (document.webform.numreviews.value == "")) {
                alert("Please indicate the number of reviews you have written for SCN");
                document.webform.numreviews.focus();
                return false;
        }
	thishii="scbr";
        if (isEmpty(document.webform.hii.value)) {
		alert("Please enter the answer to the Human Intelligence Identification Question.");
                document.webform.hii.focus();
                return false;
        }
	else {
		hii=document.webform.hii.value;
		if (hii != thishii) {
			alert("You entered an incorrect value: '" + hii + "'. Please provide the correct answer to the required 'Human Intelligence Identification Answer'. This field must be filled in correctly before you can successfully submit the form.");
                	document.webform.hii.focus();
                	return false;
        	}
        }
	document.webform.hiianswer.value=thishii;
}


