<!--
function stripcommas() {
	document.getElementById("book_pg_title").value = document.getElementById("book_pg_title").value.replace(/,/g, "");
	document.getElementById("book_pg_toc").value = document.getElementById("book_pg_toc").value.replace(/,/g, "");
	document.getElementById("book_pg_dedication").value = document.getElementById("book_pg_dedication").value.replace(/,/g, "");
	document.getElementById("book_pg_body").value = document.getElementById("book_pg_body").value.replace(/,/g, "");
	document.getElementById("book_pg_preface").value = document.getElementById("book_pg_preface").value.replace(/,/g, "");
	document.getElementById("book_pg_foreword").value = document.getElementById("book_pg_foreword").value.replace(/,/g, "");
	document.getElementById("book_pg_illustration").value = document.getElementById("book_pg_illustration").value.replace(/,/g, "");
	document.getElementById("book_pg_bio").value = document.getElementById("book_pg_bio").value.replace(/,/g, "");
	document.getElementById("book_pg_other").value = document.getElementById("book_pg_other").value.replace(/,/g, "");
	document.getElementById("book_pg_colophon").value = document.getElementById("book_pg_colophon").value.replace(/,/g, "");
	document.getElementById("book_pg_wc").value = document.getElementById("book_pg_wc").value.replace(/,/g, "");
}

function verifyPages() {
stripcommas();
var x=0;
var invalids = new Array();
	if(document.getElementById("book_pg_title").value.length==0 || !IsNumeric(document.getElementById("book_pg_title").value)) {
		invalids[x]="TITLE PAGES";
		x++;
	}
	if(document.getElementById("book_pg_toc").value.length==0 || !IsNumeric(document.getElementById("book_pg_toc").value)) {
		invalids[x]="TABLE OF CONTENTS";
		x++;
	}
	if(document.getElementById("book_pg_dedication").value.length==0 || !IsNumeric(document.getElementById("book_pg_dedication").value)) {
		invalids[x]="DEDICATION";
		x++;
	}
	if(document.getElementById("book_pg_body").value.length==0 || !IsNumeric(document.getElementById("book_pg_body").value)) {
		invalids[x]="BODY";
		x++;
	}
	if(document.getElementById("book_pg_preface").value.length==0 || !IsNumeric(document.getElementById("book_pg_preface").value)) {
		invalids[x]="PREFACE";
		x++;
	}
	if(document.getElementById("book_pg_foreword").value.length==0 || !IsNumeric(document.getElementById("book_pg_foreword").value)) {
		invalids[x]="FOREWORD";
		x++;
	}
	if(document.getElementById("book_pg_illustration").value.length==0 || !IsNumeric(document.getElementById("book_pg_illustration").value)) {
		invalids[x]="ADDITIONAL ILLUSTRATION";
		x++;
	}
	if(document.getElementById("book_pg_bio").value.length==0 || !IsNumeric(document.getElementById("book_pg_bio").value)) {
		invalids[x]="BIO/CREDIT";
		x++;
	}
	if(document.getElementById("book_pg_other").value.length==0 || !IsNumeric(document.getElementById("book_pg_other").value)) {
		invalids[x]="OTHER PAGES";
		x++;
	}
	if(document.getElementById("book_pg_colophon").value.length==0 || !IsNumeric(document.getElementById("book_pg_colophon").value)) {
		invalids[x]="COLOPHON";
		x++;
	}
if(x==0) return null;	
else return invalids;
}

function calculatePages() {
	var err = verifyPages();
	if(err==null) {
		var i = Number(document.getElementById("book_pg_title").value);
		i += Number(document.getElementById("book_pg_toc").value);
		i += Number(document.getElementById("book_pg_dedication").value); 
		i += Number(document.getElementById("book_pg_body").value);
		i += Number(document.getElementById("book_pg_preface").value);
		i += Number(document.getElementById("book_pg_foreword").value);
		i += Number(document.getElementById("book_pg_illustration").value);
		i += Number(document.getElementById("book_pg_bio").value);
		i += Number(document.getElementById("book_pg_other").value);
		i += Number(document.getElementById("book_pg_colophon").value);
		document.getElementById("book_pg_total").value = i;
	}
	else {
		var str="Please fill in the following page estimates:\n";
		for(m in err) 
		str += err[m]+"\n";
		alert(str);
		return false;
	}
}

function verifyTitleForm() {
var n=0;
var errors = new Array();
if(document.getElementById("RA_name").value=="") {
	errors[n]="-your name";
	n++;
}
if(document.getElementById("RA_email").value=="") {
	errors[n]="-your login email";
	n++;
}
if(document.getElementById("PP_password").value=="") {
	errors[n]="-private press password";
	n++;
}
if(document.getElementById("act_password").value=="") {
	errors[n]="-publication activity password";
	n++;
}
if(document.getElementById("book_author").value=="") {
	errors[n]="-book author";
	n++;
}
if(document.getElementById("book_title").value=="") {
	errors[n]="-book title";
	n++;
}
if(document.getElementById("book_genre").selectedIndex==0) {
	errors[n]="-book genre";
	n++;
}

if(verifyPages()==null) calculatePages();
else	{
	errors[n]="-page estimates";
	n++;
}
if(document.getElementById("book_pg_wc").value=="" || !IsNumeric(document.getElementById("book_pg_wc").value)) {
	errors[n]="-estimated word count";
	n++;
}
if(Number(document.getElementById("book_pg_other").value) > 0 && document.getElementById("book_pg_other_description").value=="") {
	errors[n]="-description for other pages";
	n++;
}
if(document.getElementById("book_shortblurb").value=="") {
	errors[n]="-short blurb";
	n++;
}
if(document.getElementById("ISBN_true").checked && document.getElementById("book_longblurb").value=="") {
	errors[n]="-long blurb";
	n++;
}
if(n>0) {
	var str="Please fill in the following:\n";
	for(m in errors) 
		str += errors[m]+"\n";
	alert(str);
	return false;
}	
else return true;
}

function verifyRegForm() {
var n=0;
var errors = new Array();
//check interests
	var none = true;
	var checkboxes = document.getElementsByName("author_interests[]");
	for(var i=0; i<checkboxes.length; i++) {
		if(checkboxes[i].checked) {
			none=false;
			break;
		}
	}
	if(none) {
		errors[n]="-your interests";
		n++;
	}
//check other form values
if(document.getElementById("author_title").selectedIndex==0) {
	errors[n]="-your title";
	n++;
}
if(document.getElementById("author_first").value=="") {
	errors[n]="-first name";
	n++;
}
if(document.getElementById("author_last").value=="") {
	errors[n]="-last name";
	n++;
}
if(document.getElementById("author_password1").value=="") {
	errors[n]="-desired password";
	n++;
}
if(!IsAlphaNum(document.getElementById("author_password1").value.toLowerCase())) {
	errors[n]="-desired password (use only letters a-z and/or numbers 0-9)";
	n++;
}
if(document.getElementById("author_password1").value.toLowerCase()!=document.getElementById("author_password2").value.toLowerCase()) {
	errors[n]="-confirm password";
	n++;
}
if(document.getElementById("author_street").value=="" && document.getElementById("author_PObox").value=="") {
	errors[n]="-primary street address or P.O. box";
	n++;
}
if(document.getElementById("author_PObox").value!="" && document.getElementById("mail_street").value=="") {
	errors[n]="-delivery street address (in addition to your primary P.O. box)";
	n++;
}
if(document.getElementById("author_country").value=="USA" && document.getElementById("author_city").value=="") {
	errors[n]="-primary city";
	n++;
}
if(document.getElementById("author_country").value=="USA" && document.getElementById("author_state").value=="") {
	errors[n]="-primary state";
	n++;
}
if(document.getElementById("author_country").value=="") {
	errors[n]="-primary country";
	n++;
}
if(document.getElementById("author_phone").value=="") {
	errors[n]="-phone number";
	n++;
}
if(document.getElementById("author_email").value=="") {
	errors[n]="-email";
	n++;
}
if(document.getElementById("bg_occupationtoday").value=="") {
	errors[n]="-your current occupation(s)";
	n++;
}
if(document.getElementById("bg_occupationpast").value=="") {
	errors[n]="-your occupation(s) in the past";
	n++;
}
if(document.getElementById("author_bio").value=="") {
	errors[n]="-your brief biography";
	n++;
}
if(n>0) {
	var str="Please make sure the following are filled in properly:\n\n";
	for(m in errors) 
		str += errors[m]+"\n";
	alert(str);
	return false;
}	
else return true;
}

function verifyRegTerms() {
	if(document.getElementById("author_agree").checked == false) {
		alert("Please check the box that certifies you have read and agree to the terms of use before proceeding.");
		return false;
	}
	return true;
}

function warnRegDuplicate() {
	alert("The email you have inputted is already in the system! Please change this.");
	return false;
}

function verifyEditorialForm() {
var n=0;
var errors = new Array();
if(document.getElementById("RA_name").value=="") {
	errors[n]="-your name";
	n++;
}
if(document.getElementById("RA_email").value=="") {
	errors[n]="-your name";
	n++;
}
if(document.getElementById("PP_password").value=="") {
	errors[n]="-private press password";
	n++;
}
if(document.getElementById("act_password").value=="") {
	errors[n]="-publication activity password";
	n++;
}
if(document.getElementById("book_author").value=="") {
	errors[n]="-book author";
	n++;
}
if(document.getElementById("book_title").value=="") {
	errors[n]="-book title";
	n++;
}
if(document.getElementById("book_genre").selectedIndex==0) {
	errors[n]="-book genre";
	n++;
}
if(verifyPages()==null)	calculatePages();
else	{
	errors[n]="-page estimates";
	n++;
}
if(document.getElementById("book_pg_wc").value=="" || !IsNumeric(document.getElementById("book_pg_wc").value)) {
	errors[n]="-estimated word count";
	n++;
}
if(Number(document.getElementById("book_pg_other").value) > 0 && document.getElementById("book_pg_other_description").value=="") {
	errors[n]="-description for other pages";
	n++;
}
if(document.getElementById("book_shortblurb").value=="") {
	errors[n]="-short blurb";
	n++;
}
if(document.getElementById("book_file").value=="") {
	errors[n]="-upload file";
	n++;
}
else if(!isValidFileType(document.getElementById("book_file").value, "text")) {
	errors[n]="-file (invalid type)";
	n++;
}

if(n>0) {
	var str="Please fill in the following:\n";
	for(m in errors) 
		str += errors[m]+"\n";
	alert(str);
	return false;
}	
else return true;
}

function verifyGraphicForm() {
var n=0;
var errors = new Array();

if(document.getElementById("RA_name").value=="") {
	errors[n]="-your name";
	n++;
}
if(document.getElementById("RA_email").value=="") {
	errors[n]="-your email";
	n++;
}
if(document.getElementById("PP_password").value=="") {
	errors[n]="-private press password";
	n++;
}

if(document.getElementById("act_password").value=="") {
	errors[n]="-publication activity password";
	n++;
}
if(document.getElementById("book_author").value=="") {
	errors[n]="-book author";
	n++;
}
if(document.getElementById("book_title").value=="") {
	errors[n]="-book title";
	n++;
}
if(document.getElementById("book_genre").selectedIndex==0) {
	errors[n]="-book genre";
	n++;
}
if(verifyPages()==null)	calculatePages();
else	{
	errors[n]="-page estimates";
	n++;
}
if(document.getElementById("book_pg_wc").value=="" || !IsNumeric(document.getElementById("book_pg_wc").value)) {
	errors[n]="-estimated word count";
	n++;
}
if(Number(document.getElementById("book_pg_other").value) > 0 && document.getElementById("book_pg_other_description").value=="") {
	errors[n]="-description for other pages";
	n++;
}
if(document.getElementById("book_shortblurb").value=="") {
	errors[n]="-short blurb";
	n++;
}

if(document.getElementById("book_file").value=="") {
	errors[n]="-upload file";
	n++;
}
else if(!isValidFileType(document.getElementById("book_file").value, "text")) {
	errors[n]="-file (invalid type)";
	n++;
}
/**
if(document.getElementById("art_file").value=="") {
	errors[n]="-upload file";
	n++;
}
else if(!isValidFileType(document.getElementById("art_file").value, "zip")) {
	errors[n]="-file (invalid type)";
	n++;
}
**/
if(n>0) {
	var str="Please fill in the following:\n";
	for(m in errors) 
		str += errors[m]+"\n";
	alert(str);
	return false;
}	
else return true;
}
-->
