
    var cp = parseFloat("0.0"); 
    var cost_lc = parseFloat("19.95"); 

    function findPayPalTotal(fldName, fromForm, targetForm) {
    	var addn = eval("document." + fromForm + "."+fldName+".value");
    	addn = parseFloat(addn);
    	if (eval("document." + fromForm + "."+fldName+".checked")) {
    	    cp = cp + addn;
    	} else if (!eval("document." + fromForm + "."+fldName+".checked")) {
    	    cp = cp - addn;
	}
	cp = parseFloat(cp.toFixed(2));
	eval("document." + targetForm + ".amount.value=" + cp);
	document.getElementById("charge_total").innerHTML = "<U>Total Charge</U>&nbsp;&nbsp;<B>" + cp + "</B>&nbsp;&nbsp;<I>(US $)</I>";
    }

    function findBookCost(fldName, fromForm, targetForm) {
    	var noOfCopies_lc = 0;
    	var bookCost_lc = parseFloat("0.0");
    	var totalCost = parseFloat("0.0");
    	noOfCopies_lc = eval("document." + fromForm + ".n_lc.value");
        bookCost_lc = parseFloat(cost_lc * parseInt(noOfCopies_lc));
        totalCost = cp + bookCost_lc;
	totalCost = parseFloat(totalCost.toFixed(2));

	eval("document." + targetForm + ".amount.value=" + cp);
	document.getElementById("charge_total").innerHTML = "<U>Total Charge</U>&nbsp;&nbsp;<B>" + totalCost + "</B>&nbsp;&nbsp;<I>(US $)</I>";
    }

    function findTotal(fldName, fromForm, targetForm) {
    	var addn = eval("document." + fromForm + "."+fldName+".value");
    	addn = parseFloat(addn);
    	if (eval("document." + fromForm + "."+fldName+".checked")) {
    	    cp = cp + addn;
    	} else if (!eval("document." + fromForm + "."+fldName+".checked")) {
    	    cp = cp - addn;
	}
        totalCost = cp + bookCost;
	totalCost = parseFloat(totalCost.toFixed(2));

	eval("document." + targetForm + ".amount.value=" + cp);
	document.getElementById("charge_total").innerHTML = "<U>Total Charge</U>&nbsp;&nbsp;<B>" + totalCost + "</B>&nbsp;&nbsp;<I>(US $)</I>";
    }

    function clearCheckBoxes() {
    	eval("document.input_form.media_mail.checked=false");
    	eval("document.input_form.priority_mail.checked=false");
    	eval("document.input_form.nyc_st.checked=false");
    	eval("document.input_form.ny_st.checked=false");
    }
    
    var newList  = "";
    var chapName = new Array(50);
    var chapTitle = new Array(50);
    var numbChaps  = 1;

    function addChapter(formName, divName) {
        newList = "";
        for (var n=1; n<=numbChaps; n++) {
	    chapName[n] = eval("document."+formName+ ".chap_numb_"+n+".value");
	    chapTitle[n] = eval("document."+formName+ ".chap_title_"+n+".value");

	    if (Text.trim(chapName[n]) == "" || Text.trim(chapTitle[n]) == "" ) {
	        alert('Chapter Number / Name Is Blank!');
	        return false;
	    }
        }
	
        newList += "<table width=\"100%\" border=\"0\" class=\"bgcccccc\" cellpadding=\"2\" cellspacing=\"1\">";

        for (var i=1; i<=numbChaps; i++) {
            showChapter(i);
        }
        numbChaps++;
	showOneMoreChapter();
	
        newList += "</table>"
        newList += "<input type=\"button\" class=\"button\" value=\"Add One Chapter\" onClick=\"javascript:addChapter(\'form_chapter\',\'div_chap\');\">"

        document.getElementById(divName).innerHTML = newList;
        eval("document."+formName+ ".no_chaps.value="+numbChaps);
        return true;
    } 

    function showChapter(i) {
        newList += "<TR>"
            + "<TD align=\"left\"> Chapter " + i 	
            + "</TD>"
            + "<TD align=\"left\" >"
            + "<INPUT type=\"text\" name=\"chap_numb_"+i+"\" value=\""+ chapName[i]+"\" size=\"10\">"
            + "</TD>"
            + "</TR>"
            + "<TR>"
            + "<TD align=\"left\">Title"  	
            + "</TD>"
            + "<TD align=\"left\" >"
            + "<INPUT type=\"text\" name=\"chap_title_"+i+"\" value=\""+ chapTitle[i]+"\" size=\"50\">"
            + "</TD>"
            + "</TR>"
    }
    
    function showOneMoreChapter() {
        newList += "<TR>"
            + "<TD align=\"left\"> Chapter " + parseInt(numbChaps) 	
            + "</TD>"
            + "<TD align=\"left\" >"
            + "<INPUT type=\"text\" name=\"chap_numb_"+numbChaps+"\" size=\"10\">"
            + "</TD>"
            + "</TR>"
            + "<TR>"
            + "<TD align=\"left\">Title"  	
            + "</TD>"
            + "<TD align=\"left\" >"
            + "<INPUT type=\"text\" name=\"chap_title_"+numbChaps+"\" size=\"50\">"
            + "</TD>"
            + "</TR>"
            + "<TR>"
            + "<TD colspan=\"2\">"
            + "<INPUT type=\"submit\" name=\"Save All\" value=\"Save All\">"
            + "</TD>"
            + "</TR>"
    }   

    function isEmailOk(formName, fldName) {
	var email = eval("document." + formName + "." + fldName + ".value");
	if (email == "") {
		alert ('Please enter your E-mail address.');
		eval("document." + formName + "." + fldName + ".focus()");
		eval("document." + formName + "." + fldName + ".select()");
		return false;
	}
	if((email.indexOf("@")==-1) ||(email.indexOf(".")==-1)) {
		alert ('Enter a vaild E-mail address!');
		eval("document." + formName + "." + fldName + ".focus()");
		eval("document." + formName + "." + fldName + ".select()");
		return false;
	}
	if (email.length < 8) {
		alert("Check your E-mail Id!");
		eval("document." + formName + "." + fldName + ".focus()");
		eval("document." + formName + "." + fldName + ".select()");
		return false;
      }
	return true;
    }
    
    function isNameOk(formName, fldName) {
	var str = eval("document." + formName + "." + fldName + ".value");
	if (str == "") {
		alert("Please enter your " + fldName);
		eval("document." + formName + "." + fldName + ".focus()");
		eval("document." + formName + "." + fldName + ".select()");
		return false;
	}
	if((str.substring(0,1)<"a" || str.substring(0,1)>"z") && (str.substring(0,1)<"A" || str.substring(0,1)>"Z")) {
		alert('Check your ' + field);
		eval("document." + formName + "." + fldName + ".focus()");
		eval("document." + formName + "." + fldName + ".select()");
		return false;
	}
	return true;
    }    

//
// Browser Detection
//
    function sniffBrowser() {
	isMac = (navigator.appVersion.indexOf("Mac")!=-1) ? true : false;
	NS4 = (document.layers) ? true : false;
	IEmac = ((document.all)&&(isMac)) ? true : false;
	IE4plus = (document.all) ? true : false;
	IE4 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1)) ? true : false;
	IE5 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 5.")!=-1)) ? true : false;
	IE6 = ((document.all)&&(navigator.appVersion.indexOf("MSIE 6.")!=-1)) ? true : false;
	ver4 = (NS4 || IE4plus) ? true : false;
	NS6 = (!document.layers) && (navigator.userAgent.indexOf('Netscape')!=-1)?true:false;

	IE5plus = IE5 || IE6;
	IEMajor = 0;

	if (IE4plus) {
		var start = navigator.appVersion.indexOf("MSIE");
		var end = navigator.appVersion.indexOf(".",start);
		IEMajor = parseInt(navigator.appVersion.substring(start+5,end));
		IE5plus = (IEMajor>=5) ? true : false;
        }
        if (!(IE5plus || NS6 || IE4plus)) {
            alert('This site is optimized for IE 5+, NS 6+ browsers. Please upgrade your browser to use this site.');
        }
    }

    function isFieldOk(formName, fieldName) {
        var fld  = "";
        eval("fld = document."+formName+ "." +fieldName+".value");
        if (Text.trim(fld) == "") {
            var alrt = "Please Enter "+fieldName;
	    alert(alrt);
	    eval("document."+formName+"."+fieldName+".focus()");
	    return false;
	} else {
	    return true;
	}
    }
    
    function isAddressOk(formName, fieldName) {
        var fld  = "";
        var fiel = "";
        eval("fld = document."+formName+ "." +fieldName+".value");
        if (Text.trim(fld) == "") {
	    fieldNa = fieldName.split("_");
	    for (num = 0; num < fieldNa.length; num++) {
	      fiel=fiel+" "+fieldNa[num];
	    }
            var alrt = "Please Enter"+fiel;	    
            alert(alrt);
	    eval("document."+formName+"."+fieldName+".focus()");
	    return false;
	} else {
	    return true;
	}
    }    
    
// Phone Number (nnn-nnn-nnnn) validation.    
    function isPhoneNumber(formName,phone_number,ph1,ph2,ph3) {
	str1 = eval("document."+ formName +"."+ph1+".value");
	str2 = eval("document."+ formName +"."+ph2+".value");
	str3 = eval("document."+ formName +"."+ph3+".value");
	
	if (str1 == "") {
	    alert("Please enter area code in phone number.");
	    eval("document."+ formName +"."+ph1+".focus()");
	    eval("document."+ formName +"."+ph1+".select()");
	    return false;
	}
	if (str2 == "" || str3 == "") {
	    alert("Please check the phone number.");
	    eval("document."+ formName +"."+ph2+".focus()");
	    eval("document."+ formName +"."+ph2+".select()");
	    return false;
	}
	var str = str1 + str2 + str3;
	for (var i = 0; i < str.length; i++) {
	    var ch = str.substring(i, i + 1);
	    if (ch < "0" || "9" < ch) {
		alert('Phone number should be numeric.');
		eval("document."+ formName +"."+ph2+".focus()");
	    	eval("document."+ formName +"."+ph2+".select()");
		return false;
	    }
	}
	if (str.length != 10) {
	    alert("The phone number should have 10 digits.");
	    eval("document."+ formName +"."+ph2+".focus()");
	    eval("document."+ formName +"."+ph2+".select()");
	    return false;
	}
	eval("document."+ formName +"."+phone_number+".value="+str);
	return true;
    }
    

    function CheckNum(formName,fieldName) {
	var fld = "";
	eval("fld = document."+formName+ "." +fieldName+".value");
        if  (isNaN(fld)) {
            alert ("Check the "+fieldName+" values");
            eval("document."+formName+"."+fieldName+".focus()");
            return false;
        } else {
            return true;
        }
    }
    
    function NumOk(formName,fieldName) {
	var fld = "";
        var fiel = "";	
	eval("fld = document."+formName+ "." +fieldName+".value");
        if  (isNaN(fld)) {
	    fieldNa = fieldName.split("_");
	    for (num = 0; num < fieldNa.length; num++) {
	      fiel=fiel+" "+fieldNa[num];
	    }
            alert ("Check the"+fiel+" values");
            eval("document."+formName+"."+fieldName+".focus()");
            return false;
        } else {
            return true;
        }
    } 
    
    function popUp(URL, width, height) {
        day = new Date();
        id = day.getTime();
        eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width='+width+',height='+height+',left=60,top=150');");
    }
    

    function isBlank(formName, fieldName) {
        var fld  = "";
        eval("fld = document."+formName+ "." +fieldName+".value");
        if (fld == "") {
            var alrt = "Please Enter "+fieldName;
	    alert(alrt);
	    return false;
	} else {
	    return true;
	}
    }

   function CheckNum(formName,fieldName) {
       var fld = "";
	   eval("fld = document."+formName+ "." +fieldName+".value");
	       if  (isNaN(fld)) {
	           alert ("Please Check "+fieldName);
	           eval("document."+formName+"."+fieldName+".focus()");
	           return false;
	       } else {
	           return true;
	         }
   }
    
