
<!--

 var flagPickupIsBilling = false;
 var today;
 var errorMsg;

 // costs

 var totalCost ;                // cost without tax only MA residents get tax
 var taxCost;                  // MA sales tax .0625 aug 1 2009
 var completeCost;             // cost with tax
 var copyCost;  
 
 var bindless4Cost;
 var bindmore3Cost;
 var specialCosts;
 var foldoutCosts;
 var freightCost;

 // char counts
  var frontChCount;
  var spineChCount;
 
  var flagWindowOpened;
  
function initialize()
{
  today = new Date();
  read_cookie(); 
  hide_startingtables();
  
}

function MouseOverLinkButton(ButtonName)
{

  var buttonUp;
  var buttonDown; 
  var buttonUp1
  var buttonDown1; 
  
if (ButtonName=="priceNow") 
{ 
buttonup = new Image; buttonup.src = "getPriceNowInitial.png";
buttondown = new Image; buttondown.src = "getPriceNowMouseOver.png";
document.priceNow.src = buttondown.src;
}
else if (ButtonName=="orderNow")
{
buttonup1 = new Image; buttonup1.src = "iAmReadyToOrderInitial.png";
buttondown1 = new Image; buttondown1.src = "iAmReadToOrderMouseOver.png";
document.orderNow.src = buttondown1.src;
}

}

function MouseOutOfLinkButton(ButtonName)
{

  var buttonUp;
  var buttonDown; 
  var buttonUp1
  var buttonDown1; 

if (ButtonName=="priceNow") 
{
buttonup = new Image; buttonup.src = "getPriceNowInitial.png";
buttondown = new Image; buttondown.src = "getPriceNowMouseOver.png";
document.priceNow.src = buttonup.src;
}
else if (ButtonName=="orderNow")
{
buttonup1 = new Image; buttonup1.src = "IAmReadyToOrderInitial.png";
buttondown1 = new Image; buttondown1.src = "iAmReadToOrderMouseOver.png";
document.orderNow.src = buttonup1.src;

}

}

function hide_startingtables()
{

  document.getElementById("serviceTable").style.display="none";

  document.getElementById("priceSubmitTable_roughQt").style.display="none";

  document.getElementById("contactsTable").style.display="none";

  document.getElementById("printTable").style.display="none";
  document.getElementById("copiesTable").style.display="none";

  document.getElementById("bindingTable").style.display="none";

  document.getElementById("titleTable").style.display="none";

  document.getElementById("altFrontCoverStampSubTable").style.display="none";


  document.getElementById("titleExplanatoryTable").style.display="none";
 
  document.getElementById("pickupDeliveryTable").style.display="none";
  document.getElementById("altAddresses").style.display="none";
  document.getElementById("priceSubmitTable").style.display="none";


  sampleTitle_spine_thumb = new Image
  sampleTitle_spine_full = new Image

  sampleTitle_spine_thumb.src = "sampleTitle_spine_thumb"
  sampleTitle_spine_full.src = "sampleTitle_spine_thumb"


}




function showFrontCoverStampOptions()
{
 
 if (document.theForm.stampFrontCover.checked)
  { copyFrontToSpine();
 
    document.getElementById("altFrontCoverStampSubTable").style.display="block"; }
 else
  {  
     document.getElementById("altFrontCoverStampSubTable").style.display="none";
     document.theForm.title_front.value = "";
     document.theForm.author_front.value = "";
     document.theForm.year_front.value = "";
     document.theForm.degree_front.value = "";
     document.theForm.misc_front.value = "";
     frontChCount = 0;
  }
}



function setAltAddressVisibility()
{

 if (document.theForm.pickupType[2].checked == true || document.theForm.pickupType[3].checked == true)
  {
  document.getElementById("altAddresses").style.display="";
  }               

}

 function clearAltAddresses()
{

document.theForm.altname_1.value = ""
document.theForm.altstreet_1.value = ""
document.theForm.altcity_1.value = ""
document.theForm.altstate_1.value = ""
document.theForm.altzip_1.value = ""

document.theForm.altname_2.value = ""
document.theForm.altstreet_2.value = ""
document.theForm.altcity_2.value = ""
document.theForm.altstate_2.value = ""
document.theForm.altzip_2.value = ""

document.theForm.boundAltNumber_1.value = ""
document.theForm.unboundAltNumber_1.value = ""
document.theForm.boundAltNumber_2.value = ""
document.theForm.unboundAltNumber_2.value = ""

document.getElementById("altAddresses").style.display="none";


}


 function setupWrite_cookie()
 {
  var nameString;
  var cookieString;
  var expireString;
  var expireDate;

 expireDate = new Date;

 expireDate.setMonth(expireDate.getMonth()+6);
 expireString = ";expires=" +  expireDate.toGMTString();

 nameString = "AcmeThesisBindQuote"; 

		 <!-- parse on colons start used fields with colon then get formElementName = lastValue -->

cookieString += ':name' + '=' + document.theForm.name.value + ':'; 
cookieString += 'street' + '=' + document.theForm.street.value + ':'; 
cookieString += 'city' + '=' + document.theForm.city.value + ':'; 
cookieString += 'state' + '=' + document.theForm.state.value + ':'; 
cookieString += 'zip' + '=' + document.theForm.zip.value + ':'; 

cookieString += 'contactPhone' + '=' + document.theForm.contactPhone.value + ':'; 
cookieString += 'mobilePhone' + '=' + document.theForm.mobilePhone.value + ':'; 


cookieString += 'contactEmail' + '=' + document.theForm.contactEmail.value + ':'; 
cookieString += 'contactFax' + '=' + document.theForm.contactFax.value + ':'; 

cookieString += 'title_spine' + '=' + document.theForm.title_spine.value + ':'; 
cookieString += 'author_spine' + '=' + document.theForm.author_spine.value + ':'; 
cookieString += 'year_spine' + '=' + document.theForm.year_spine.value + ':';
cookieString += 'degree_spine' + '=' + document.theForm.degree_spine.value + ':'; 
cookieString += 'misc_spine' + '=' + document.theForm.misc_spine.value + ':';  

if ( document.theForm.stampFrontCover.checked)
 { cookieString += 'stampFrontCover=Yes:'; }
else
 {cookieString += 'stampFrontCover=No:';}     


cookieString += 'title_front' + '=' + document.theForm.title_front.value + ':'; 
cookieString += 'author_front' + '=' + document.theForm.author_front.value + ':'; 
cookieString += 'year_front' + '=' + document.theForm.year_front.value + ':';
cookieString += 'degree_front' + '=' + document.theForm.degree_front.value + ':'; 
cookieString += 'misc_front' + '=' + document.theForm.misc_front.value + ':';  


if ( document.theForm.lettering[0].checked)
 { cookieString += 'lettering=gold:'; }

if ( document.theForm.lettering[1].checked)
 { cookieString += 'lettering=white:'; }

if ( document.theForm.lettering[2].checked)
 { cookieString += 'lettering=black:'; }


if ( document.theForm.bindingType[0].checked)
 { cookieString += 'bindingType=adhesive:'; }

if ( document.theForm.bindingType[1].checked)
 { cookieString += 'bindingType=oversewn:'; }

           
 cookieString += 'coverColor' + '=' + document.theForm.coverColor.value + ':'; 


if ( document.theForm.typePaper[0].checked)
 { cookieString += 'typePaper=white 60#:'; }

if ( document.theForm.typePaper[1].checked)
 { cookieString += 'typePaper=archival:'; }


if ( document.theForm.printSrc[0].checked)
 { cookieString += 'printSrc=acmePrinted:'; }

if ( document.theForm.printSrc[1].checked)
 { cookieString += 'printSrc=prePrinted:'; }

cookieString += 'pageCount' + '=' + document.theForm.pageCount.value + ':'; 



if ( document.theForm.digitalInstructions.checked)
 { cookieString += 'digitalInstructions=yes:'; }


if ( document.theForm.duplex[0].checked)
 { cookieString += 'duplex=no:'; }

if ( document.theForm.duplex[1].checked)
 { cookieString += 'duplex=yes:'; }

if ( document.theForm.gsYes.checked)
 { cookieString += 'gsYes=yes:'; }

cookieString += 'gsCount' + '=' + document.theForm.gsCount.value + ':'; 

if ( document.theForm.colorYes.checked)
 { cookieString += 'colorYes=yes:'; }

cookieString += 'prePrintCount' + '=' + document.theForm.prePrintCount.value + ':'; 
cookieString += 'acmePrintCount' + '=' + document.theForm.acmePrintCount.value + ':';


cookieString += 'colorCount' + '=' + document.theForm.colorCount.value + ':'; 

cookieString += 'foBw' + '=' + document.theForm.foBw.value + ':'; 
cookieString += 'foGs' + '=' + document.theForm.foGs.value + ':'; 
cookieString += 'foCl' + '=' + document.theForm.foCl.value + ':'; 


// new pickup delivery section 3/1/01

if ( document.theForm.typeCustMaterial[0].checked)
 { cookieString += 'typeCustMaterial=prePrint:'; }

if ( document.theForm.typeCustMaterial[1].checked)
 { cookieString += 'typeCustMaterial=file:'; }
 
if ( document.theForm.dropOffType[0].checked)
 { cookieString += 'dropOffType=office drop off:'; }

if ( document.theForm.dropOffType[1].checked)
 { cookieString += 'dropOffType=mail in:'; }

if ( document.theForm.dropOffType[2].checked)
 { cookieString += 'dropOffType=ftp:'; }

if ( document.theForm.dropOffType[3].checked)
 { cookieString += 'dropOffType=email:'; } 

if ( document.theForm.pickupType[0].checked)
 { cookieString += 'pickupType=acme:'; }

if ( document.theForm.pickupType[1].checked)
 { cookieString += 'pickupType=home:'; }

if ( document.theForm.pickupType[2].checked)
 { cookieString += 'pickupType=alternate:'; }

if ( document.theForm.pickupType[3].checked)
 { cookieString += 'pickupType=both:'; } 


if ( document.theForm.shipping[0].checked)
 { cookieString += 'shipping=Ups:'; }

if ( document.theForm.shipping[1].checked)
 { cookieString += 'shipping=FedEx:'; }

if ( document.theForm.shipping[2].checked)
 { cookieString += 'shipping=Harvard:'; }


cookieString += ':boundHomeNumber' + '=' + document.theForm.boundHomeNumber.value + ':'; 
cookieString += 'unboundHomeNumber' + '=' + document.theForm.unboundHomeNumber.value + ':'; 
cookieString += 'boundAltNumber_1' + '=' + document.theForm.boundAltNumber_1.value + ':'; 
cookieString += 'unboundAltNumber_1' + '=' + document.theForm.unboundAltNumber_1.value + ':'; 

cookieString += ':altname_1' + '=' + document.theForm.altname_1.value + ':'; 
cookieString += 'altstreet_1' + '=' + document.theForm.altstreet_1.value + ':'; 
cookieString += 'altcity_1' + '=' + document.theForm.altcity_1.value + ':'; 
cookieString += 'altstate_1' + '=' + document.theForm.altstate_1.value + ':'; 
cookieString += 'altzip_1' + '=' + document.theForm.altzip_1.value + ':'; 


cookieString += 'boundAltNumber_2' + '=' + document.theForm.boundAltNumber_2.value + ':'; 
cookieString += 'unboundAltNumber_2' + '=' + document.theForm.unboundAltNumber_2.value + ':'; 
cookieString += ':altname_2' + '=' + document.theForm.altname_2.value + ':'; 
cookieString += 'altstreet_2' + '=' + document.theForm.altstreet_2.value + ':'; 
cookieString += 'altcity_2' + '=' + document.theForm.altcity_2.value + ':'; 
cookieString += 'altstate_2' + '=' + document.theForm.altstate_2.value + ':'; 
cookieString += 'altzip_2' + '=' + document.theForm.altzip_2.value + ':'; 

cookieString += 'fedExNumber' + '=' + document.theForm.fedExNumber.value + ':'; 

if ( document.theForm.payType[0].checked)
 { cookieString += 'payType=cash:'; }

if ( document.theForm.payType[1].checked)
 { cookieString += 'payType=check:'; }
 

 //////////////////////////////////////////////

if ( document.theForm.service[0].checked)
 { cookieString += 'service=2 week:'; }

if ( document.theForm.service[1].checked)
 { cookieString += 'service=1 week:'; }


cookieString += 'dateNeeded' + '=' + document.theForm.dateNeeded.value + ':'; 

cookieString += 'totalCopies' + '=' + document.theForm.totalCopies.value + ':'; 
cookieString += 'bindCopies' + '=' + document.theForm.bindCopies.value + ':'; 
cookieString += 'unboundCopies' + '=' + document.theForm.unboundCopies.value + ':'; 

if ( document.theForm.unboundOriginalReturn.checked)
 { cookieString += 'unboundOriginalReturn=yes:'; }

// cookieString += 'calcCost' + '=' + document.theForm.calcCost.value + ':'; 

cookieString += 'custComments' + '=' + document.theForm.custComments.value + ':'; 

cookieString += 'flagWindowOpened' + '=' + flagWindowOpened + ':'; 


 escape(cookieString);

 write_Cookie(nameString,cookieString,expireString,"","","");


 
}


function write_Cookie(name,value,expires,path,domain,secure) 
 {
   var cVal, cError;
   cVal = cError = "";
   if (!name) { cError = cError + "Name failure"; }
   if (!value) { cError = cError + "Value failure"; }
   if (!cError) 
    {
      cVal = cVal + escape(name) + "=";
      cVal = cVal + escape(value);
      if (expires) { cVal = cVal + "; expires=" + expires;}
      if (path)    { cVal = cVal + "; path=" + path; }
      if (domain)  { cVal = cVal + "; domain=" + domain; }
      if (secure)  { cVal = cVal + "; secure=" + secure; }
      document.cookie = cVal;
  
   }
   return cError;

  }

function Get_Cookie(name)
 {
    var start = document.cookie.indexOf(name+"=");
    var len = start+name.length+1;
    if ((!start) && (name != document.cookie.substring(0,name.length))) return null;
    if (start == -1) return null;
    var end = document.cookie.indexOf(";",len);
    if (end == -1) end = document.cookie.length;
    return unescape(document.cookie.substring(len,end));
 }


 function read_cookie()
 {
  baseArray = new Array();        
  formArray = new Array();       
  var intLoop;
  var cookieValue; 

  
  cookieValue = Get_Cookie("AcmeThesisBindQuote"); 
  
  if (cookieValue == null)               // for expired and first timers
     { return }

  baseArray = cookieValue.split(":");

for(intLoop = 1; intLoop < baseArray.length; intLoop++)
     {
      formArray = (baseArray[intLoop].split("=") ); 
    
 if ( formArray[1] == null)
	 { formArray[1] = ""; }

else if  ( formArray[0] == "name")
	  { document.theForm.name.value = unescape(formArray[1]); }

else if  (  formArray[0] == "street")
	  {  document.theForm.street.value = unescape(formArray[1]); }  

else if  (  formArray[0] == "city")
	  {   document.theForm.city.value = unescape(formArray[1]);}  

else if  (  formArray[0] == "state")
	  {   document.theForm.state.value = unescape(formArray[1]);
	     if (document.theForm.state.value == "")
		  {
		   document.theForm.state.options[28].selected = true;  
		  }
	  }

else if  (  formArray[0] == "zip")
	  {   document.theForm.zip.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "contactPhone")
	  {    document.theForm.contactPhone.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "mobilePhone")
	  {    document.theForm.mobilePhone.value = unescape(formArray[1]);}  


else if     (  formArray[0] == "contactEmail")
	  {    document.theForm.contactEmail.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "contactFax")
	  {    document.theForm.contactFax.value = unescape(formArray[1]);}  

 
else if     (   formArray[0] == "title_spine")
	  {    document.theForm.title_spine.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "author_spine")
	  {    document.theForm.author_spine.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "year_spine")
	  {    document.theForm.year_spine.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "degree_spine")
	  {    document.theForm.degree_spine.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "misc_spine")
	  {    document.theForm.misc_spine.value = unescape(formArray[1]);}  




else if     (   formArray[0] == "stampFrontCover")
	  {    document.theForm.stampFrontCover.value = unescape(formArray[1]);
	       if( document.theForm.stampFrontCover.value == "Yes")
		{  document.theForm.stampFrontCover.checked = true;
                   document.getElementById("altFrontCoverStampSubTable").style.display="block";
                   showFrontCoverStampOptions(true); }
	       else
		 { document.theForm.stampFrontCover.checked = false;
                   document.getElementById("altFrontCoverStampSubTable").style.display="none";}      
           } 
 

else if     (   formArray[0] == "title_front")
	  {    document.theForm.title_front.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "author_front")
	  {    document.theForm.author_front.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "year_front")
	  {    document.theForm.year_front.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "degree_front")
	  {    document.theForm.degree_front.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "misc_front")
	  {    document.theForm.misc_front.value = unescape(formArray[1]);}  

 
else if     (   formArray[0] == "lettering")
	  {    document.theForm.lettering.value = unescape(formArray[1]);
	     
	       if( document.theForm.lettering.value == "black")
		{  document.theForm.lettering[2].checked = true;}  
		else if ( document.theForm.lettering.value == "white" )
		 { document.theForm.lettering[1].checked = true; }
	       else
		 { document.theForm.lettering[0].checked = true; }
	  } 
 
 
else if     (  formArray[0] == "bindingType")
	  {    document.theForm.bindingType.value = unescape(formArray[1]);  

	      if( document.theForm.bindingType.value == "oversewn")
		{  document.theForm.bindingType[1].checked = true;}  
	       else
		 { document.theForm.bindingType[0].checked = true; }
	 }



else if     (   formArray[0] == "coverColor")
	  {    document.theForm.coverColor.value = unescape(formArray[1]); 

	      if( document.theForm.coverColor.value == "03 Crimson Red")
		{  document.theForm.coverColor[1].selected = true;}  
		else if ( document.theForm.coverColor.value == "38 Dark Green" )
		 { document.theForm.coverColor[2].selected = true; }
                else if ( document.theForm.coverColor.value == "44 Light Blue" )
		 { document.theForm.coverColor[3].selected = true; }
		else if ( document.theForm.coverColor.value == "48 Navy Blue" )
		 { document.theForm.coverColor[4].selected = true; }
		else if ( document.theForm.coverColor.value == "67 Brown" )
		 { document.theForm.coverColor[5].selected = true; }
	       else if ( document.theForm.coverColor.value == "75 Black" )
		 { document.theForm.coverColor[6].selected = true; }
	       else 
                 { document.theForm.coverColor[1].selected = true; }




	   }

else if     (   formArray[0] == "pageCount")
	  {    document.theForm.pageCount.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "typePaper")
	  {    document.theForm.typePaper.value = unescape(formArray[1]);
	     
  
              if ( document.theForm.typePaper.value == "white 60#" )
		 { document.theForm.typePaper[0].checked = true; }
	      else
		 { document.theForm.typePaper[1].checked = true; }
	       
	  } 


else if     (   formArray[0] == "printSrc")
	  {    document.theForm.printSrc.value = unescape(formArray[1]);
	     
  
              if ( document.theForm.printSrc.value == "acmePrinted" )
		 { document.theForm.printSrc[0].checked = true; }
	      else
		 { document.theForm.printSrc[1].checked = true; }
	       
	  } 

else if     (   formArray[0] == "digitalInstructions")
	  {    document.theForm.digitalInstructions.value = unescape(formArray[1]);
	       if( document.theForm.digitalInstructions.value == "yes")
		{  document.theForm.digitalInstructions.checked = true;}
	       else
		 {  document.theForm.digitalInstructions.checked = false;}      
	  }  


else if     (   formArray[0] == "duplex")
	  {    document.theForm.duplex.value = unescape(formArray[1]); 

	       if( document.theForm.duplex.value == "yes")
		{  document.theForm.duplex[1].checked = true;}  
		else
		 { document.theForm.duplex[0].checked = true; }
	  }

else if     (   formArray[0] == "gsYes")
	  {    document.theForm.gsYes.value = unescape(formArray[1]);
	       if( document.theForm.gsYes.value == "yes")
		{  document.theForm.gsYes.checked = true;}
	       else
		 {  document.theForm.gsYes.checked = false;}      
	  }  

else if     (   formArray[0] == "gsCount")
	  {    document.theForm.gsCount.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "colorYes")
	  {    document.theForm.colorYes.value = unescape(formArray[1]);
	       if( document.theForm.colorYes.value == "yes")
		{  document.theForm.colorYes.checked = true;}
	       else
		 {  document.theForm.colorYes.checked = false;}      
	  }  


else if     (   formArray[0] == "prePrintCount")
	  {    document.theForm.prePrintCount.value = unescape(formArray[1]);} 

else if     (   formArray[0] == "acmePrintCount")
	  {    document.theForm.acmePrintCount.value = unescape(formArray[1]);} 


else if     (   formArray[0] == "colorCount")
	  {    document.theForm.colorCount.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "foBw")
	  {    document.theForm.foBw.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "foGs")
	  {    document.theForm.foGs.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "foCl")
	  {    document.theForm.foCl.value = unescape(formArray[1]);}  


else if     (   formArray[0] == "service")
	  {    document.theForm.service.value = unescape(formArray[1]);
	     
	       if( document.theForm.service.value == "2 week")
		{  document.theForm.service[0].checked = true;}  
		else
		 { document.theForm.service[1].checked = true; }
		
	  } 

else if     (   formArray[0] == "dateNeeded")
	  {    document.theForm.dateNeeded.value = unescape(formArray[1]);}  

  /////////////// start new pickup delivery section 1/3/01

else if     (   formArray[0] == "typeCustMaterial")
	   {    document.theForm.typeCustMaterial.value = unescape(formArray[1]);

   //      alert("custMat=" +  unescape(formArray[1]));

       if( document.theForm.typeCustMaterial.value == "prePrint")
		{  document.theForm.typeCustMaterial[0].checked = true;}  
		else
		 { document.theForm.typeCustMaterial[1].checked = true; }

	   }

else if     (   formArray[0] == "dropOffType")
	   {    document.theForm.dropOffType.value = unescape(formArray[1]);

       if( document.theForm.dropOffType.value == "office drop off")
		{  document.theForm.dropOffType[0].checked = true;}  
		else if ( document.theForm.dropOffType.value == "mail in" )
		 { document.theForm.dropOffType[1].checked = true; }
		else if ( document.theForm.dropOffType.value == "ftp" )
		 { document.theForm.dropOffType[2].checked = true; }
	       else
		 { document.theForm.dropOffType[3].checked = true; }

	   }


else if     (   formArray[0] == "pickupType")
	   {    document.theForm.pickupType.value = unescape(formArray[1]);

       if( document.theForm.pickupType.value == "acme")
		{  document.theForm.pickupType[0].checked = true;}  
		else if ( document.theForm.pickupType.value == "home" )
		 { document.theForm.pickupType[1].checked = true; }
		else if ( document.theForm.pickupType.value == "alternate" )
		 { document.theForm.pickupType[2].checked = true;
                   document.getElementById("altAddresses").style.display=""; 
                 }
	       else
		 { document.theForm.pickupType[3].checked = true;
                   document.getElementById("altAddresses").style.display="";
                 }

	   }


else if     (   formArray[0] == "shipping")
	   {    document.theForm.shipping.value = unescape(formArray[1]);
       if( document.theForm.pickupType.value == "Ups")
           {  document.theForm.shipping[0].checked = true;} 
       else if( document.theForm.shipping.value == "FedEx")
           {  document.theForm.shipping[1].checked = true;} 
       else if( document.theForm.shipping.value == "Harvard")
           {  document.theForm.shipping[2].checked = true;} 
       else
           {  document.theForm.shipping[0].checked = true;} 

           }


else if     (   formArray[0] == "boundHomeNumber")
	   {    document.theForm.boundHomeNumber.value = unescape(formArray[1]); }

else if     (   formArray[0] == "unboundHomeNumber")
	   {    document.theForm.unboundHomeNumber.value = unescape(formArray[1]); }

else if     (   formArray[0] == "boundAltNumber_1")
	   {    document.theForm.boundAltNumber_1.value = unescape(formArray[1]);}

else if     (   formArray[0] == "unboundAltNumber_1")
	   {    document.theForm.unboundAltNumber_1.value = unescape(formArray[1]);}

else if     (   formArray[0] == "altname_1")
	   {    document.theForm.altname_1.value = unescape(formArray[1]); }

else if     (   formArray[0] == "altstreet_1")
	   {    document.theForm.altstreet_1.value = unescape(formArray[1]); }

else if     (   formArray[0] == "altcity_1")
	   {    document.theForm.altcity_1.value = unescape(formArray[1]);}

else if     (   formArray[0] == "altstate_1")
	   {    document.theForm.altstate_1.value = unescape(formArray[1]);}

else if     (   formArray[0] == "altzip_1")
	   {    document.theForm.altzip_1.value = unescape(formArray[1]); }

else if     (   formArray[0] == "boundAltNumber_2")
	   {    document.theForm.boundAltNumber_2.value = unescape(formArray[1]);}

else if     (   formArray[0] == "unboundAltNumber_2")
	   {    document.theForm.unboundAltNumber_2.value = unescape(formArray[1]);}


else if     (   formArray[0] == "altname_2")
	   {    document.theForm.altname_2.value = unescape(formArray[1]); }

else if     (   formArray[0] == "altstreet_2")
	   {    document.theForm.altstreet_2.value = unescape(formArray[1]); }

else if     (   formArray[0] == "altcity_2")
	   {    document.theForm.altcity_2.value = unescape(formArray[1]);}

else if     (   formArray[0] == "altstate_2")
	   {    document.theForm.altstate_2.value = unescape(formArray[1]);}

else if     (   formArray[0] == "altzip_2")
	   {    document.theForm.altzip_2.value = unescape(formArray[1]); }


else if     (   formArray[0] == "fedExNumber")
	   {    document.theForm.fedExNumber.value = unescape(formArray[1]);}

else if     (   formArray[0] == "payType")
	   {    document.theForm.payType.value = unescape(formArray[1]);


       if( document.theForm.payType.value == "cash")
		{  document.theForm.payType[0].checked = true;}  
		else
		 { document.theForm.payType[1].checked = true; }
	    
	   }




/////////////////////////////////////////////

else if     (   formArray[0] == "totalCopies")
	  {    document.theForm.totalCopies.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "bindCopies")
	  {    document.theForm.bindCopies.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "unboundCopies")
	  {    document.theForm.unboundCopies.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "unboundOriginalReturn")
	  {    document.theForm.unboundOriginalReturn.value = unescape(formArray[1]);
	       if( document.theForm.unboundOriginalReturn.value == "yes")
		{  document.theForm.unboundOriginalReturn.checked = true;}
	       else
		 {  document.theForm.unboundOriginalReturn.checked = false;}      
	  }  

// else if     (   formArray[0] == "calcCost")
//        { document.theForm.calcCost.value = unescape(formArray[1]);}  

else if     (   formArray[0] == "custComments")
	  {    document.theForm.custComments.value = unescape(formArray[1]);}  

else if   ( "flagWindowOpened")
	   { flagWindowOpened = unescape(formArray[1]); }

else
    { ; }

      }

 
 }


 function contactErrors(strTypeAddress)
 {
  errorMsg = "";

 setupWrite_cookie();


if (strTypeAddress == "home contact") 
 {

 if ( document.theForm.name.value == "" )
    { errorMsg += "Name is missing ! \n";}

 if ( document.theForm.street.value == "" )
   { errorMsg += "Street field is missing ! \n";}

 if ( document.theForm.city.value == "" )
   { errorMsg += "City field is missing ! \n";}

 if ( document.theForm.state.value == "" || document.theForm.state.value == "XX")
   { errorMsg += "State field is missing/invalid ! \n";}

 if ( document.theForm.zip.value == "" )
   { errorMsg += "Zip code is missing ! \n";}

 if ( document.theForm.contactPhone.value == "" )
   { errorMsg += "Phone number is missing ! \n";}

 if ( document.theForm.contactEmail.value == "") 
    { errorMsg += "Email address is empty ! \n"; }

 if ( document.theForm.contactEmail.value != "") 
    { errorMsg += validateEmail(document.theForm.contactEmail.value); }

 }

 else if (strTypeAddress == "alternate/multiple address 1") 
  {

 if ( document.theForm.altname_1.value == "" )
    { errorMsg += "Name is missing ! \n";}

 if ( document.theForm.altstreet_1.value == "" )
   { errorMsg += "Street field is missing ! \n";}

 if ( document.theForm.altcity_1.value == "" )
   { errorMsg += "City field is missing ! \n";}

 if ( document.theForm.altstate_1.value == "" || document.theForm.state.value == "XX")
   { errorMsg += "State field is missing/invalid ! \n";}

 if ( document.theForm.altzip_1.value == "" )
   { errorMsg += "Zip code is missing ! \n";}


  }

 else if (strTypeAddress == "alternate/multiple address 2") 
 {
 
 if ( document.theForm.altname_2.value == "" )
    { errorMsg += "Name is missing ! \n";}

 if ( document.theForm.altstreet_2.value == "" )
   { errorMsg += "Street field is missing ! \n";}

 if ( document.theForm.altcity_2.value == "" )
   { errorMsg += "City field is missing ! \n";}

 if ( document.theForm.altstate_2.value == "" || document.theForm.state.value == "XX")
   { errorMsg += "State field is missing/invalid ! \n";}

 if ( document.theForm.altzip_2.value == "" )
   { errorMsg += "Zip code is missing ! \n";}

 }


if (errorMsg != "" )
 { 
 alert("In " + strTypeAddress + " \n \n The Following Required Fields are Missing or in error... \n \n" + errorMsg); 
 errorMsg = "";
 return false;
 }
else
 { 
 errorMsg = "";


if (strTypeAddress == "home contact") 
  { document.getElementById("pickupDeliveryTable").style.display="block"; } 

 return true;
 } 

  }
 


  function bindingErrors()
   {



 errorMsg = "";
 setupWrite_cookie();

if( ! document.theForm.lettering[0].checked && ! document.theForm.lettering[1].checked && ! document.theForm.lettering[2].checked )
   {
    errorMsg += "You have forgotten to choose a title lettering color from our radio button list . \n";
   }  


if( ! document.theForm.bindingType[0].checked && ! document.theForm.bindingType[1].checked )
   {
    errorMsg += "You have forgotten to choose a binding choice from our radio button list . \n";
   }  

// error if unselected or index 0 which is empty string 
if ( document.theForm.coverColor.selectedIndex < 1 )  
   {
    errorMsg += "You have forgotten to choose a cover color from our drop down list box. \n";
   }


if (errorMsg != "" )
 { 
 alert("Following Required Fields are Missing or in error... \n \n" + errorMsg); 
 errorMsg = "";
 return false;

 }
else
 { 
 errorMsg = "";
 document.getElementById("copiesTable").style.display="block";
 window.location.href = "#totals";
 return true;
 } 
   }



  function serviceErrors()
   {


  errorMsg = "";
  setupWrite_cookie();


if( ! document.theForm.service[0].checked && ! document.theForm.service[1].checked )
   {
    errorMsg += "You have forgotten to choose a delivery date choice from our radio button list . \n";
   }  

       
if (errorMsg != "" )
 { 
 clearAcmeUseArea()
 alert("Following Required Fields are Missing or in error... \n \n" + errorMsg); 
 errorMsg = "";
 return false;
 }
else
 { 
 errorMsg = "";
 document.getElementById("bindingTable").style.display="block";
 window.location.href = "#bindingOptions";
 setAltAddressVisibility();
 return true;
 } 

 }


  function pickupDeliveryErrors()
  {
   errorMsg = "";
   setupWrite_cookie();


 if( ! document.theForm.dropOffType[0].checked && ! document.theForm.dropOffType[1].checked && ! document.theForm.dropOffType[2].checked && ! document.theForm.dropOffType[3].checked )
   {  errorMsg += "You have not choosen how Acme is too receive your work. ( Drop off at office, Mail in, electronic transfer...) ! \n" }

 if( ! document.theForm.pickupType[0].checked && ! document.theForm.pickupType[1].checked && ! document.theForm.pickupType[2].checked && ! document.theForm.pickupType[3].checked )
   {  errorMsg += "You have not choosen a pickup type for your finished work. (Pick up at office, ship to home, ship elsewhere...) ! \n" }

			    
// if any option for type split pickup other than at acme check totals


  if ( document.theForm.pickupType[2].checked || document.theForm.pickupType[3].checked )
 {
 NaNCheck(document.theForm.boundHomeNumber.value,"Value in bound Copies to Home in Pickup/Delivery Section");
 NaNCheck(document.theForm.boundAltNumber_1.value,"Value in bound Copies to alt address 1 in Pickup/Delivery Section");
 NaNCheck(document.theForm.boundAltNumber_2.value,"Value in bound Copies to alt address 2 in Pickup/Delivery Section");
 NaNCheck(document.theForm.unboundHomeNumber.value,"Value in unbound Copies to home in Pickup/Delivery Section");
 NaNCheck(document.theForm.unboundAltNumber_1.value,"Value in unbound Copies to alt address 1 to in Pickup/Delivery Section");
 NaNCheck(document.theForm.unboundAltNumber_2.value,"Value in unbound Copies to alt address 2 to in Pickup/Delivery Section");


 if (document.theForm.boundAltNumber_1.value != "" || document.theForm.unboundAltNumber_1.value != "")
  {
  if (! contactErrors("alternate/multiple address 1"))
    {        errorMsg += "You must completely fill in Alternate Address 1 as you chose 'Ship To Alternate Address' or 'Split Shipment' and have entered quantities for shipping to this address \n";}
  }

 if (document.theForm.boundAltNumber_2.value != "" || document.theForm.unboundAltNumber_2.value != "")
  {
  if (! contactErrors("alternate/multiple address 2"))
    {        errorMsg += "You must completely fill in Alternate Address 2 as you chose 'Ship To Alternate Address' or 'Split Shipment' and have entered quantities for shipping to this address \n";}
  }

 if (  (document.theForm.boundHomeNumber.value * 1)  + ( document.theForm.boundAltNumber_1.value * 1)   + ( document.theForm.boundAltNumber_2.value * 1)
     != document.theForm.bindCopies.value * 1 )
  {     
   errorMsg += "The number of bound copies you wish to ship does not match the total number of bound copies entered in the Number/Types Copies Options section ! \n"; 
  }


 if (  (document.theForm.unboundHomeNumber.value * 1)  + ( document.theForm.unboundAltNumber_1.value * 1)   + ( document.theForm.unboundAltNumber_2.value * 1)
     != document.theForm.unboundCopies.value * 1 )
  {     
   errorMsg += "The number of unbound copies you wish to ship does not match the total number of bound copies entered in the Number/Types Copies Options section ! \n"; 
  }

 }


// error if any of alt address filled in save state drop down and pickup is acme or ship to home


  if( document.theForm.pickupType[0].checked || document.theForm.pickupType[1].checked)
   {
      
      if (  
          document.theForm.altname_1.value != "" || document.theForm.altstreet_1.value != ""
          || document.theForm.altcity_1.value != "" || document.theForm.altzip_1.value != ""
          || document.theForm.altname_2.value != "" || document.theForm.altstreet_2.value != ""
          || document.theForm.altcity_2.value != "" || document.theForm.altzip_2.value != ""         
         ) 
        { errorMsg += "You have entered alternative addresses but have stated that you are either picking up at Acme or are taking delivery at your home address, please clear entered alternate address info or change radio button choice to what you want done. \n"; }

   }


  // if any quant in are entered warn
  if ( document.theForm.pickupType[0].checked && 
      (
       document.theForm.unboundHomeNumber.value != "" || document.theForm.unboundHomeNumber.value != "" ||        
       document.theForm.boundAltNumber_1.value != "" || document.theForm.unboundAltNumber_1.value != "" ||
       document.theForm.boundAltNumber_2.value != "" || document.theForm.unboundAltNumber_2.value != ""
       )        
     )
       {errorMsg += "You have entered quantities for shipping but have selected the 'I will pickup at Acme' choice button. Please clear unused quantities or select another shipping choice. \n" }  

  // if any ALT quants  are entered and user is Shipping to home warn
  if ( document.theForm.pickupType[1].checked && 
      (       
       document.theForm.boundAltNumber_1.value != "" || document.theForm.unboundAltNumber_1.value != "" ||
       document.theForm.boundAltNumber_2.value != "" || document.theForm.unboundAltNumber_2.value != ""
       )        
     )
       {errorMsg += "You have entered quantities for 'Alternate Address' shipping but have selected the 'Please ship to my home address' choice button. Please clear unused quantities or select another shipping choice. \n" }  

  // if any HOME quants  are entered and user is Shipping to ALT warn
  if ( document.theForm.pickupType[2].checked && 
      (       
       document.theForm.unboundHomeNumber.value != "" || document.theForm.unboundHomeNumber.value != ""
       )        
     )
       {errorMsg += "You have entered quantities for 'Ship to My Home' shipping but have selected the 'Please ship to my alternate address' choice button. Please clear unused quantities or select another shipping choice. \n" }  

   if ( (document.theForm.pickupType[2].checked) && (document.theForm.boundAltNumber_1.value == "" && document.theForm.unboundAltNumber_1.value == "" && document.theForm.boundAltNumber_2.value == "" && document.theForm.unboundAltNumber_2.value == "") )
    { errorMsg += "There are no quantities entered for alt address shipping \n" }

   if ((document.theForm.pickupType[3].checked) && (document.theForm.boundAltNumber_1.value == "" && document.theForm.unboundAltNumber_1.value == "" && document.theForm.boundAltNumber_1.value == "" && document.theForm.unboundAltNumber_1.value == ""))
    { errorMsg += "There are no quantities entered for alt address shipping. Do alt 1 then alt 2 (only if needed)  \n" }


 if ( (document.theForm.pickupType[2].checked) &&  (document.theForm.altname_1.value != "" && document.theForm.altname_2.value != "") )
      { errorMsg += "You have entered 2 alternative addresses but not indicated that you want SPLIT SHIPMENT, either clear address 2 or click the SPLIT SHIPMENT radio button and enter the quantities of books going to each address. \n";} 
  

 if ( document.theForm.fedExNumber.value != "" && ( !  document.theForm.pickupType[1].checked &&  ! document.theForm.pickupType[2].checked  &&  ! document.theForm.pickupType[3].checked)  )
   { errorMsg += "You have entered data for a Federal Express Account Number but have indicated you will be picking up at Acme ! \n";}

 if( ! document.theForm.payType[0].checked && ! document.theForm.payType[1].checked)
   {  errorMsg += "You have not choosen how you will be making your payment. (Cash, check, money order) ! \n" }




if (errorMsg != "" )
 { 
 alert("Following Required Fields are Missing or in error... \n \n" + errorMsg); 
 errorMsg = "";
 return false;
 }
else
 { 
 errorMsg = "";
 CalcCost(true);
 return true;
 } 



   }


 function totalsErrors()
 {
 errorMsg = "";
 setupWrite_cookie();

 NaNCheck( document.theForm.totalCopies.value, "Total copies in Copies Section" );
 NaNCheck( document.theForm.bindCopies.value, "# Copies to bind in Copies Section" );
 NaNCheck( document.theForm.unboundCopies.value, "# Copies UNBOUND in Copies Section" );

  if( ! document.theForm.printSrc[0].checked && ! document.theForm.printSrc[1].checked)
   {
    errorMsg += "You have forgotten to choose between Acme Printing vs. Customer Printing from our radio button list . \n";
   }  

if ( document.theForm.totalCopies.value == ""    )
   { errorMsg += "You have not entered the total number of copies you want!  \n";}
  
if ( document.theForm.totalCopies.value <= 0    )
   { errorMsg += "The Total Copies amount must be a number greater than 0!  \n";}

if ( (document.theForm.totalCopies.value * 1)  != ( (document.theForm.bindCopies.value * 1) + ( document.theForm.unboundCopies.value *1) )   )
   { errorMsg += "The Total Copies data does not match the sum of (# copies bind) + (# copies unbound)  \n";}


if (errorMsg != "" )
 { 
 clearAcmeUseArea()
 alert("Following Required Fields are Missing or in error... \n \n" + errorMsg); 
 errorMsg = "";
 return false;
 }
else
 { 
 errorMsg = "";
 if ( document.theForm.printSrc[0].checked )
  { document.getElementById("printTable").style.display="block"; 
    window.location.href = "#printOptions";
  }
 else  
  { document.getElementById("titleTable").style.display="block";
    document.getElementById("titleExplanatoryTable").style.display="block";
    showFrontCoverStampOptions();
    window.location.href = "#titleLayout";
  }
 
 return true;
 } 

 }

  function printErrors()
   {
  errorMsg = "";
  setupWrite_cookie();

if  (document.theForm.printSrc[1].checked)
 { 
 errorMsg = "";
 document.getElementById("titleTable").style.display="block";
 document.getElementById("titleExplanatoryTable").style.display="block";
 showFrontCoverStampOptions();
 window.location.href = "#titleLayout";
 return true;
 }  




  if( ! document.theForm.typePaper[0].checked && ! document.theForm.typePaper[1].checked)
   {
    errorMsg += "You have forgotten to choose a paper type from our radio button list . \n";
   }  


  if( ! document.theForm.duplex[0].checked && ! document.theForm.duplex[1].checked )
   {
    errorMsg += "You have forgotten to choose single (simplex) or double sided (duplex) printing from our radio button list . \n";
   }  

  NaNCheck( document.theForm.pageCount.value, "Page Count in Print Options Section" );           

  if ( document.theForm.pageCount.value <= 0 )
   { errorMsg += "Page count  " +  document.theForm.pageCount.value + " is invalid, please change page count in Section Print Options \n"; }



 NaNCheck( document.theForm.gsCount.value, "Gray Scale count in Print Section" );  

 NaNCheck( document.theForm.colorCount.value, "Color count in Print Section" );  


 NaNCheck(document.theForm.foBw.value,"Value in Black and White Foldouts in Print Section");
 NaNCheck(document.theForm.foGs.value,"Value in HalfTones And B&W photos Foldouts in Print Section");
 NaNCheck(document.theForm.foCl.value,"Value in Color Foldouts in Print Section");


if (errorMsg != "" )
 { 
 alert("Following Required Fields are Missing or in error... \n \n" + errorMsg); 
 errorMsg = "";
 return false;
 }
else
 { 
 errorMsg = "";
 document.getElementById("titleTable").style.display="block";
 document.getElementById("titleExplanatoryTable").style.display="block";
 showFrontCoverStampOptions();
 window.location.href = "#titleLayout";
 return true;
 } 


   }




  function titleErrors()
   {


  errorMsg = "";


 setupWrite_cookie();

                
 if (document.theForm.title_spine.value == "")
     { errorMsg += "Spine Title is missing! \n" }

 if (document.theForm.author_spine.value == "")
     { errorMsg += "Spine Author is missing! \n" }

 if (document.theForm.year_spine.value == "")
     { errorMsg += "Spine Year is missing! \n" }


 if ( document.theForm.stampFrontCover.checked == true)
    { 

  if (document.theForm.title_front.value == "")
     { errorMsg += "Front Title is missing! \n" }

  if (document.theForm.author_front.value == "")
     { errorMsg += "Front Author is missing! \n" }

  if (document.theForm.year_front.value == "")
     { errorMsg += "Front Year is missing! \n" }    

    }

  CalcCharCounts(false);
  if (frontChCount > 180)
     {    errorMsg += " Front cover title is greater than 180 stamping characters. No thesis cover can have  more than 180 characters. Please shorten.  \n"; }

  if (spineChCount > 180 )
     {    errorMsg += " Spine title is greater than 180 stamping characters. No thesis cover can have  more than 180 characters. Please shorten.  \n"; }

if (errorMsg != "" )
 { 
 alert("Following Required Fields are Missing or in error... \n \n" + errorMsg); 
 errorMsg = "";
 return false;
 }
else
 { 
 errorMsg = "";
 document.getElementById("contactsTable").style.display="block";
 return true;
 } 

   }



 function copyFrontToSpine()
 {

  document.theForm.title_front.value = document.theForm.title_spine.value;
  document.theForm.author_front.value = document.theForm.author_spine.value;
  document.theForm.year_front.value = document.theForm.year_spine.value;
  document.theForm.degree_front.value = document.theForm.degree_spine.value;
  document.theForm.misc_front.value = document.theForm.misc_spine.value;

  document.getElementById("altFrontCoverStampSubTable").style.display = "block";
 }


 function check_fields()
 {

 setupWrite_cookie();

  if (! contactErrors("home contact") )
   {  
   alert("Problems were in Contact section of form, please correct and resubmit.");
   return false; }

  if (! titleErrors() )
   { 
   alert("Problems were in Title Layout section of form, please correct and resubmit."); 
   return false; }

  if (! bindingErrors() )
   {  
   alert("Problems were in Binding Options section of form, please correct and resubmit.");
   return false; }

  if (! printErrors() )
   {  
    alert("Problems were in Print options section of form, please correct and resubmit.");
    return false; }

  if (! serviceErrors() )
   {  
   alert("Problems were in Service Options section of form, please correct and resubmit.");
   return false; }

 if (! pickupDeliveryErrors() )
   {  
   alert("Problems were in Dropoff and Delivery Options section of form, please correct and resubmit.");
   return false; }

  if (! totalsErrors() )
   {  
    alert("Problems were in Copies/Submission section of form, please correct and resubmit.");
    return false; }

    return true;    
 }

// email check below covers ...
// characters that should not be in the address
// characters that should not be at the start
// & d) characters that shouldn't be together
// there's not more than one '@'
// check' checks there's at least one '@', later followed by at least one '.'
// checkend' checks the address ends with a period followed by 2 or 3 alpha characters

 function validateEmail(emailad)
 {
var exclude=/[^@\-\.\w]|^[_@\.\-]|[\._\-]{2}|[@\.]{2}|(@)[^@]*\1/;
var check=/@[\w\-]+\./;
var checkend=/\.[a-zA-Z]{2,3}$/;

	if(((emailad.search(exclude) != -1)||(emailad.search(check)) == -1)||(emailad.search(checkend) == -1))
	  {
		return("\n Incorrectly formed email address! \n " + document.theForm.contactEmail.value + "\n");
	  }
		return("");        
 }


  function confirmSubmit()
  {
   var agree;
   
   agree = confirm("OK to send submission to Acme, Cancel if you wish to review costs in Totals area and perhaps make changes.");
   
   if (agree) 
    { 
     CalcCost(false);
     return true;
    }
   else
    { 
     CalcCost(true);    
     return false;
    } 


  }

  function confirmClearForm()
   {
   var agree;
   
   agree = confirm("All user entered info will be erased! Click OK to clear form.");
   
   if (agree) 
    {return true; }
   else
    {return false; }    

   }


 function CalcCost(display)
 {
 totalCost =0;                // cost without tax only MA residents get tax
 taxCost = 0;                  // MA sales tax .0625
 completeCost = 0;             // cost with tax
 copyCost = 0;  
 bindless4Cost = 0;
 bindmore3Cost = 0;
 specialCosts = 0;
 foldoutCosts = 0;
 freightCost = 0;


 clearAcmeUseArea();

 if ( ! document.theForm.stampFrontCover.checked) 
    { frontChCount = 0;}
 else   
    { CalcCharCounts(false);}

 // bindcopies must be accurate so we will force error check here before continuing
 if ( ! totalsErrors() )
     {
       alert("Error is in Number/Type Copies section, correct before continuing, without the number of copies we can't calculate price.");
       return;
      }  
// also need delivery time to calculate
 if ( ! serviceErrors() )
     {
       alert("Error is in service section, correct before continuing, without service times/types we can't calculate price.");
       return;
      }  



 if( NaNCheckForCalcCosts() )          // exit if any fields have bad input (if check function returns true)
   { return; }


 if ( document.theForm.printSrc[0].checked == false )
 { copyCost = 0; }
 else 
 {
   
  if (document.theForm.typePaper[1].checked == true)     // new 3/06 w other changes first price change since creation in '00
   { copyCost = document.theForm.pageCount.value * .30 *  document.theForm.totalCopies.value;} 
  else
   {  copyCost = document.theForm.pageCount.value * .10 *  document.theForm.totalCopies.value;}  
  
  copyCost = copyCost + document.theForm.gsCount.value * 1 * document.theForm.totalCopies.value;        
  copyCost = copyCost + document.theForm.colorCount.value * 1.5 * document.theForm.totalCopies.value;        
   }
 


 
   if ( document.theForm.bindCopies.value > 0 && document.theForm.bindCopies.value < 4)
      {    
   if ( document.theForm.service[0].checked == true )
      { bindless4Cost = document.theForm.bindCopies.value * 30;             // cost calulated 
	document.theForm.AcLess3BindCountPrice.value = "$" + 30;           // variable prices written here to bottom pg summary    
      }        
   if ( document.theForm.service[1].checked == true )
      {  bindless4Cost = document.theForm.bindCopies.value * 45; 
	 document.theForm.AcLess3BindCountPrice.value = "$" +  45;
      }        

	// totals 
	document.theForm.AcLess3BindCount.value = document.theForm.bindCopies.value;
	document.theForm.AcLess3BindCountCost.value = "$" +  bindless4Cost;
	document.theForm.H_AcLess3BindCount.value = document.theForm.AcLess3BindCount.value;
	document.theForm.H_AcLess3BindCountCost.value = document.theForm.AcLess3BindCountCost.value;
	document.theForm.H_AcLess3BindCountPrice.value = document.theForm.AcLess3BindCountPrice.value;
   
    }
   
  else               // more than 3 copies changing binding price
     {
   
   if ( document.theForm.service[0].checked == true )
      { bindmore3Cost = (document.theForm.bindCopies.value - 3 ) * 25; 
	document.theForm.AcGreater3BindCountPrice.value =  "$" + 25;
        bindless4Cost = 90;   
	document.theForm.AcLess3BindCountPrice.value =  "$" + 30;           // variable prices written here to bottom pg summary     
	   

      }        
   if ( document.theForm.service[1].checked == true )
      {  bindmore3Cost = (document.theForm.bindCopies.value  - 3 )  * 40; 
	 document.theForm.AcGreater3BindCountPrice.value =  "$" + 40;
         bindless4Cost = 135;   
	 document.theForm.AcLess3BindCountPrice.value = "$" +  45;
      }        

     // Freight cost ** begun for the first time 11/13/06
       
	// totals 
	document.theForm.AcGreater3BindCount.value = document.theForm.bindCopies.value - 3;
	document.theForm.AcGreater3BindCountCost.value = "$" +  bindmore3Cost;
	document.theForm.H_AcGreater3BindCount.value = document.theForm.AcGreater3BindCount.value; 
	document.theForm.H_AcGreater3BindCountCost.value = document.theForm.AcGreater3BindCountCost.value
	document.theForm.H_AcGreater3BindCountPrice.value = document.theForm.AcGreater3BindCountPrice.value;
   
	
	document.theForm.AcLess3BindCount.value = 3;
	document.theForm.AcLess3BindCountCost.value = "$" +  bindless4Cost;
	document.theForm.H_AcLess3BindCount.value = document.theForm.AcLess3BindCount.value; 
	document.theForm.H_AcLess3BindCountCost.value = document.theForm.AcLess3BindCountCost.value;
	document.theForm.H_AcLess3BindCountPrice.value = document.theForm.AcLess3BindCountPrice.value;
      

  }


    // here calculating special costs Accents long titles for covers, etc
       var accentCheckLine = new String( document.theForm.title_spine.value + document.theForm.author_spine.value + document.theForm.year_spine.value + document.theForm.degree_spine.value + document.theForm.misc_spine.value
                                       + document.theForm.title_front.value + document.theForm.author_front.value + document.theForm.year_front.value + document.theForm.degree_front.value + document.theForm.misc_front.value
                                       )      


    if ( accentCheckLine.indexOf("'") != -1 ||  accentCheckLine.indexOf("`") != -1  ||  accentCheckLine.indexOf("~") != -1  )    
       {   
	specialCosts = specialCosts + ( document.theForm.bindCopies.value * 5);
	document.theForm.AcAccentCount.value = document.theForm.bindCopies.value;
	document.theForm.AcAccentCost.value = formatCurrency(document.theForm.bindCopies.value * 5 );     
	document.theForm.H_AcAccentCount.value = document.theForm.AcAccentCount.value;
	document.theForm.H_AcAccentCost.value = document.theForm.AcAccentCost.value;
       } 





   if ( document.theForm.bindingType[0].checked == true )
       { specialCosts = specialCosts + ( document.theForm.bindCopies.value * 6); } 


    // now setting for long titles 75 to 180 
//      CalcCharCounts(false);
	
      if ( frontChCount > 0   )
      {
       if ( frontChCount > 75 )
      { specialCosts = specialCosts + ( document.theForm.bindCopies.value * 15); }
       else
      { specialCosts = specialCosts + ( document.theForm.bindCopies.value * 10); }
      }

     if ( document.theForm.printSrc[0].checked == true) // we are printing            
     {     
      foldoutCosts = ( (document.theForm.foBw.value * 5) + (document.theForm.foGs.value * 8) + (document.theForm.foCl.value * 10) ) *  document.theForm.totalCopies.value;
     }

       // calc total costs 
       totalCost = copyCost +  bindmore3Cost + bindless4Cost + specialCosts + foldoutCosts;    


      loadFreightCost();


       if ( document.theForm.state[document.theForm.state.selectedIndex].value == "MA" )
	{ 
	  taxCost = totalCost * .0625; 
	  completeCost = totalCost + taxCost + freightCost;
	} 
       else
	{ completeCost = totalCost + freightCost; }

       completeCost = formatCurrency( completeCost);      
       taxCost = formatCurrency(taxCost);
       totalCost =  formatCurrency(totalCost);


       writeCosts();             // writing to green read only form and hidden form fields need both as visible must be disabled
 

       if (display) 
       {
       alert("Estimated Cost = " + completeCost + "\n\n" + "You may click the 'Place Order' button that will appear at bottom or keep changing settings and click 'Reprice Order' till satisfied." + "\n\n" + "Submit only 1 order, send in only 1 digital file, first received is what will be printed." ); 
       document.getElementById("priceSubmitTable").style.display="block";
       window.location.href =  "#placeOrderBtns";
       } 
 


 }



  function loadFreightCost()
  {

    
 if (document.theForm.pickupType[0].checked)
        { freightCost = 0;}
     
 else if (document.theForm.pickupType[1].checked || document.theForm.pickupType[2].checked)
        {freightCost = 30;}
     
 else if (document.theForm.pickupType[3].checked)
  {
         if (document.theForm.boundHomeNumber.value != "" || document.theForm.unboundHomeNumber.value != "" )
          { freightCost = 30;}

         if (document.theForm.boundAltNumber_1.value != "" || document.theForm.unboundAltNumber_1.value != "" )
          { freightCost += 30;}
         
         if (document.theForm.boundAltNumber_2.value != "" || document.theForm.unboundAltNumber_2.value != "" )
          { freightCost += 30;} 
                           
  }

   
        if (document.theForm.shipping[2].checked )
         { freightCost += 15;}
 
         if ( document.theForm.fedExNumber.value != "" )
          { freightCost += 10;}  


  }


  function writeCosts()
 {
  // *** NOTICE the accents and binding H_Ac hidden items are assigned values directly in calc costs all other hidden fields below


 // write rest of pricing data to screen bind cost data dealt with above where calculated
 //    document.theForm.calcCost.value = totalCost;
    


   if( document.theForm.service[0].checked == true || document.theForm.service[1].checked == true && document.theForm.typePaper[0].checked == false )
     {
       document.theForm.AcPageCount.value = document.theForm.pageCount.value  *  document.theForm.totalCopies.value; 
       document.theForm.AcPageCountCost.value = formatCurrency(copyCost);
       document.theForm.H_AcPageCount.value = document.theForm.AcPageCount.value;  
       document.theForm.H_AcPageCountCost.value = document.theForm.AcPageCountCost.value; 
     }   

    
   // binding costs next 3 adhesive is default cost oversew adds and velo/gbc subtract

   if( document.theForm.bindingType[0].checked == true)
    {
     document.theForm.AcoverSewCount.value = document.theForm.bindCopies.value;
     document.theForm.AcOversewCost.value =  formatCurrency(document.theForm.bindCopies.value * 6);
     document.theForm.H_AcoverSewCount.value = document.theForm.AcoverSewCount.value;
     document.theForm.H_AcOversewCost.value = document.theForm.AcOversewCost.value;
    }


  if( frontChCount > 75 )  // do 15$ long cover line
   {
    document.theForm.AcFrontCoverCountLongTitle.value = document.theForm.bindCopies.value;  
    document.theForm.AcFrontCoverCostLongTitle.value = formatCurrency(document.theForm.bindCopies.value * 15);         
    document.theForm.H_AcFrontCoverCountLongTitle.value = document.theForm.AcFrontCoverCountLongTitle.value;
    document.theForm.H_AcFrontCoverCostLongTitle.value = document.theForm.AcFrontCoverCostLongTitle.value; 
   }
   
  
  if( (frontChCount > 0)  && ( frontChCount <= 75 ) )  // do 10$ long cover line        
   {
    document.theForm.AcFrontCoverCount.value = document.theForm.bindCopies.value;     
    document.theForm.AcFrontCoverCost.value = formatCurrency(document.theForm.bindCopies.value * 10);         
    document.theForm.H_AcFrontCoverCount.value = document.theForm.AcFrontCoverCount.value;
    document.theForm.H_AcFrontCoverCost.value = document.theForm.AcFrontCoverCost.value;
   }

       if ( document.theForm.printSrc[0].checked == true) // we are printing   
	  { 
	  document.theForm.AcBwFoCount.value = document.theForm.foBw.value *  document.theForm.totalCopies.value;
	  document.theForm.AcBwFoCost.value = formatCurrency(document.theForm.foBw.value * 5  *  document.theForm.totalCopies.value );
	  document.theForm.H_AcBwFoCost.value = document.theForm.AcBwFoCost.value;     
	  document.theForm.H_AcBwFoCount.value = document.theForm.AcBwFoCount.value;       
	  }


     // Freight cost ** begun for the first time 11/13/06
    // Totals   
	 
	  document.theForm.AcSubTotal.value = totalCost;
	  document.theForm.H_AcSubTotal.value = totalCost;
	  document.theForm.AcTaxCost.value = taxCost; 
	  document.theForm.H_AcTaxCost.value = taxCost; 
	  document.theForm.AcTotalCost.value = completeCost; 
	  document.theForm.H_AcTotalCost.value = completeCost;
   
          document.theForm.AcFreightCost.value = "$" + freightCost;        
	  document.theForm.H_AcFreightCost.value = "$" + freightCost;    


 }



 function formatCurrency(currency)
 {
     // put in $##.## form
    var Ncurrency;
    var decPos;

    currency = "$" + currency;
    Ncurrency = currency; 
	      

    if( (decPos = currency.indexOf(".") )  != -1 ) 
     { 
     if( (decPos + 3) < (currency.length ) )
      { Ncurrency = currency.substring(0,decPos + 3); }
      }
	  

     return(Ncurrency);
 }
 

 function CalcCharCounts(display)
 {
 var subEx = /<.*>/g;
 var msgString;

  spineChCount = document.theForm.title_spine.value.length + document.theForm.author_spine.value.length + document.theForm.year_spine.value.length + document.theForm.degree_spine.value.length + document.theForm.misc_spine.value.length;
  frontChCount = document.theForm.title_front.value.length + document.theForm.author_front.value.length + document.theForm.year_front.value.length + document.theForm.degree_front.value.length + document.theForm.misc_front.value.length;
  
    if ( ! document.theForm.stampFrontCover.checked) 
    { frontChCount = 0 }
  

  if (display)
  { 
    
     msgString = "Spine character count is: " + spineChCount + "\n";
     if ( document.theForm.stampFrontCover.checked)
        { msgString = msgString + "Front character count is: " + frontChCount + "\n"; } 
      alert (msgString);

  }

     return
 }


 // below makes sure of numeric input return value builds error string
 
 function NaNCheck(elemValue, elem)
  {
  var numValue;           // will be zero if NaN else value we sometimes need to track the sums returned ex cover quantity check

  var subEx = /^\d*\d$/;

  if( elemValue == "")   // blanks are OK except in required fields ASP will handle apropriately
    {return (0);}
  

  if( ! subEx.test(elemValue) )
   { 
     errorMsg += elem + " with VALUE of '" + elemValue + "' is not a valid number \n"; 
     numValue = 0; 
   }

  numValue = parseInt(elemValue);


  if( numValue < 0 )
   { 
      errorMsg += elem + " with value of '" + elemValue + "' is not a valid number \n";
      numValue = 0;
   }

  return(numValue);

  }


   function NaNCheckForCalcCosts()
    {
 NaNCheck(document.theForm.foBw.value,"Value in Black and White Foldouts in Paper Section");
 NaNCheck(document.theForm.foGs.value,"Value in HalfTones And B&W photos Foldouts in Paper Section");
 NaNCheck(document.theForm.foCl.value,"Value in Color Foldouts in Paper Section");
 NaNCheck( document.theForm.totalCopies.value, "Total copies in Copies Section" );
 NaNCheck( document.theForm.bindCopies.value, "# Copies to bind in Copies Section" );
 NaNCheck( document.theForm.unboundCopies.value, "# Copies UNBOUND in Copies Section" );
 

     if (errorMsg)
      {
       alert(errorMsg);
       errorMsg = "";     
       return(true);
     }
     else    
     { return(false); }

    }


   function clearAcmeUseArea()
    {
       // doing visible display area
    

       document.theForm.AcPageCount.value = ""; 
       document.theForm.AcPageCountCost.value = ""; 
       document.theForm.AcoverSewCount.value = ""; 
       document.theForm.AcOversewCost.value = ""; 

       document.theForm.AcAccentCount.value = ""; 
       document.theForm.AcAccentCost.value = ""; 


       document.theForm.AcSubTotal.value = ""; 
       document.theForm.AcFreightCost.value = "";
       document.theForm.AcTotalCost.value = ""; 
       document.theForm.AcTaxCost.value = ""; 

       document.theForm.AcFrontCoverCountLongTitle.value = ""; 
       document.theForm.AcFrontCoverCostLongTitle.value = "";      
       document.theForm.AcFrontCoverCount.value = "";  
       document.theForm.AcFrontCoverCost.value = ""; 

       document.theForm.AcBwFoCount.value = ""
       document.theForm.AcBwFoCost.value = ""
       document.theForm.AcGsFoCount.value = ""
       document.theForm.AcGsFoCost.value = ""
       document.theForm.AcClFoCount.value = ""
       document.theForm.AcClFoCost.value = ""  

       // binding stuff

	document.theForm.AcGreater3BindCount.value = "";
	document.theForm.AcGreater3BindCountCost.value = "";
	document.theForm.AcLess3BindCount.value = "";
	document.theForm.AcLess3BindCountCost.value = "";

	// doing hidden fields area


       document.theForm.H_AcPageCount.value = ""; 
       document.theForm.H_AcPageCountCost.value = ""; 
       document.theForm.H_AcoverSewCount.value = ""; 
       document.theForm.H_AcOversewCost.value = ""; 



       document.theForm.H_AcSubTotal.value = ""; 
       document.theForm.H_AcFreightCost.value = "";
       document.theForm.H_AcTotalCost.value = ""; 
       document.theForm.H_AcTaxCost.value = ""; 

       document.theForm.H_AcFrontCoverCountLongTitle.value = ""; 
       document.theForm.H_AcFrontCoverCostLongTitle.value = "";      
       document.theForm.H_AcFrontCoverCount.value = "";  
       document.theForm.H_AcFrontCoverCost.value = ""; 

       document.theForm.H_AcBwFoCount.value = ""
       document.theForm.H_AcBwFoCost.value = ""
       document.theForm.H_AcGsFoCount.value = ""
       document.theForm.H_AcGsFoCost.value = ""
       document.theForm.H_AcClFoCount.value = ""
       document.theForm.H_AcClFoCost.value = ""  
      
       // binding stuff

	document.theForm.H_AcGreater3BindCount.value = "";
	document.theForm.H_AcGreater3BindCountCost.value = "";
	document.theForm.H_AcLess3BindCount.value = "";
	document.theForm.H_AcLess3BindCountCost.value = "";


    }

///////// new 2/19/2010 new quick/rough quotes area not saved and intended to just allow a handful of checks and numeric entries to get
//        an idea of the pricing


  function confirmClearForm_roughQt()
   {
   var agree;
   
   agree = confirm("All user entered info will be erased! Click OK to clear form.");
   
   if (agree) 
    {
     document.theForm.service_roughQt[0].checked = false;
     document.theForm.service_roughQt[1].checked = false;
     document.theForm.service_roughQt[2].checked = false;
     document.theForm.service_roughQt[3].checked = false;

     document.theForm.AcLess3BindCount_roughQt.value = "";
     document.theForm.AcLess3BindCountPrice_roughQt.value = "";
     document.theForm.AcLess3BindCountCost.value = "";

     document.theForm.AcGreater3BindCount_roughQt.value = "";
     document.theForm.AcGreater3BindCountPrice_roughQt.value = "";
     document.theForm.AcGreater3BindCountCost.value = "";

     document.theForm.AcoverIsSewn_roughQt.checked = false;
     document.theForm.AcOversewCost_roughQt.value = "";

     document.theForm.accentMarksUsed_roughQt.checked = false;
     document.theForm.AcAccentCost_roughQt.value = "";

     document.theForm.titleLengthType_roughQt[0].checked = true;
     document.theForm.AcFrontCoverCost_roughQt.value = "";
     document.theForm.AcFrontCoverCostLongTitle_roughQt.value = "";


     document.theForm.AcPageCount_roughQt.value = "";
     document.theForm.AcPageCountCost_roughQt.value = "";

     document.theForm.AcPageCountClr_roughQt.value = "";
     document.theForm.AcPageCountClrCost_roughQt.value = ""

     document.theForm.AcBwFoCount_roughQt.value = "";
     document.theForm.AcBwFoCost_roughQt.value = "";

     document.theForm.AcTotalCost_roughQt.value = "";  
     return true; 
    }
   else
    {return false; }    

   }


  function CalcCost_roughQt()
  {
   numCopies = 0;
   sumTotal = 0; 

   if (! errCheck_roughQt() )
      { alert("Could not total, please correct and retry.");
        return;}

   numCopies = (document.theForm.AcLess3BindCount_roughQt.value * 1 ) + ( document.theForm.AcGreater3BindCount_roughQt.value * 1);  
     
 
   document.theForm.AcLess3BindCountCost_roughQt.value = ( document.theForm.AcLess3BindCountPrice_roughQt.value * 1 ) * (document.theForm.AcLess3BindCount_roughQt.value * 1); 
   document.theForm.AcGreater3BindCountCost_roughQt.value = (document.theForm.AcGreater3BindCountPrice_roughQt.value * 1) * (document.theForm.AcGreater3BindCount_roughQt.value * 1);

   if (document.theForm.AcoverIsSewn_roughQt.checked == true)
    { document.theForm.AcOversewCost_roughQt.value = numCopies * 6.00;}
   else
    { document.theForm.AcOversewCost_roughQt.value = ""; }
   
   if (document.theForm.accentMarksUsed_roughQt.checked == true)
    {document.theForm.AcAccentCost_roughQt.value = numCopies * 5;}
   else
    {document.theForm.AcAccentCost_roughQt.value = "";}


     document.theForm.AcPageCountCost_roughQt.value = ( document.theForm.AcPageCount_roughQt.value * numCopies) * .10;  
     document.theForm.AcPageCountClrCost_roughQt.value = ( document.theForm.AcPageCountClr_roughQt.value * numCopies) * 1.50;  
     document.theForm.AcBwFoCost_roughQt.value = ( document.theForm.AcBwFoCount_roughQt.value * numCopies) * 5.00;  

  if(document.theForm.titleLengthType_roughQt[1].checked == true)                    // short
     {
     document.theForm.AcFrontCoverCostLongTitle_roughQt.value = "";
     document.theForm.AcFrontCoverCost_roughQt.value = numCopies * 10; 
     }
    else if (document.theForm.titleLengthType_roughQt[2].checked == true)           // long 
     {
     document.theForm.AcFrontCoverCostLongTitle_roughQt.value = numCopies * 15; 
     document.theForm.AcFrontCoverCost_roughQt.value = "";
     }
    else                                                                             // none [0]
     {
     document.theForm.AcFrontCoverCostLongTitle_roughQt.value = ""; 
     document.theForm.AcFrontCoverCost_roughQt.value = "";
     } 

    sumTotal = (document.theForm.AcLess3BindCountCost_roughQt.value * 1) + (document.theForm.AcGreater3BindCountCost_roughQt.value * 1);  
    sumTotal =  sumTotal + (document.theForm.AcOversewCost_roughQt.value * 1) + (document.theForm.AcAccentCost_roughQt.value * 1);
    sumTotal =  sumTotal + (document.theForm.AcPageCountCost_roughQt.value * 1) + (document.theForm.AcPageCountClrCost_roughQt.value * 1) + (document.theForm.AcBwFoCost_roughQt.value * 1); 
    sumTotal =  sumTotal + ( document.theForm.AcFrontCoverCostLongTitle_roughQt.value * 1) + (document.theForm.AcFrontCoverCost_roughQt.value * 1);

    document.theForm.AcTotalCost_roughQt.value = "$ " + sumTotal;
    alert("Estimated Cost = $ " + sumTotal);

   }


  function errCheck_roughQt()
  {
  
 errorMsg = ""; 

 if (document.theForm.service_roughQt[0].checked == false && document.theForm.service_roughQt[1].checked == false && document.theForm.service_roughQt[2].checked == false && document.theForm.service_roughQt[3].checked == false)
  {
   errorMsg = "A service choice must be made at top group of radio buttons"; 
  }
 
 NaNCheck(document.theForm.AcLess3BindCount_roughQt.value,"Value in bind quantities less than 3  in Quick Quotes");
 NaNCheck(document.theForm.AcGreater3BindCount_roughQt.value,"Value in bind quantities greater than 3  in Quick Quotes");

 NaNCheck( document.theForm.AcPageCount_roughQt.value,"Value in bw page count in Quick Qoutes");  
 NaNCheck(document.theForm.AcPageCountClr_roughQt.value,"Value in Color page count in Quick Quotes");   
 NaNCheck(document.theForm.AcBwFoCount_roughQt.value,"Value in Foldouts count in Quick Quotes");    

 
 if (errorMsg != "" )
  { 
    alert(errorMsg);
    errorMsg = ""; 
    return false;
  }
 else 
  { return true} 

   
  }



  function loadPerBookPrice_roughQt(price1,price2)
  {

    document.theForm.AcLess3BindCountPrice_roughQt.value = price1;
    document.theForm.AcGreater3BindCountPrice_roughQt.value = price2; 
  }



  function beginOrder()
   {
    document.getElementById("serviceTable").style.display="block";
    window.location.href = "#bindingOptions";
    setAltAddressVisibility(); 
    document.getElementById("priceSubmitTable_roughQt").style.display="none";
   }

  function beginQuickQuote()
   {
    hide_startingtables();
    document.getElementById("priceSubmitTable_roughQt").style.display="block";
    window.location.href = "#quickQuote";
    setAltAddressVisibility(); 
   }

  function exit_roughQt()
  {
   document.getElementById("priceSubmitTable_roughQt").style.display="none";
   window.location.href = "#topOfForm";
   setAltAddressVisibility();     
  }

