
function a_plus_b(form)
{
var cases,exchange,caf,interest,bs,days
var exw,road,pd,stuff,ocean,other,lc,lc2, disb,inter,sub,marine,bank,agent,margin
var tempexw,temproad,temppd,tempstuff,freight,tempfreight,tempother,templc
var tempdisb,tempinter,tempsub,total
    
   
     cases=eval(form.cases.value)
     if (eval(form.totalexw.value) > 0)
     {
     exw=eval(form.totalexw.value)
     tempexw=exw / cases
     form.exw.value= round(tempexw)
     }
     else
     { 
     tempexw=eval(form.exw.value)
     exw=tempexw * cases
     form.totalexw.value = round(exw)
     }
     
     if (eval(form.totalroad.value) > 0)
     {
     road=eval(form.totalroad.value)
     temproad= road / cases
     form.road.value = round(temproad)
     }
     else
     {
     temproad=eval(form.road.value)
     road=temproad * cases
     form.totalroad.value= round(road)
     }
      
     if (eval(form.totalpd.value) > 0)
     {
     pd=eval(form.totalpd.value)
     temppd= pd / cases
     form.pd.value = round(temppd)
     }
     else
     {
     temppd=eval(form.pd.value)     
     pd= temppd * cases
     form.totalpd.value = round(pd)
     }
     
     if (eval(form.totalstuff.value) > 0)
     {
     stuff=eval(form.totalstuff.value)
     tempstuff= stuff / cases
     form.stuff.value = round(tempstuff)
     }
      else
     {
     tempstuff=eval(form.stuff.value)     
     stuff= tempstuff * cases
     form.totalstuff.value = round(stuff)
     }

     ocean=eval(form.ocean.value)
     bs=eval(form.bs.value)
     caf=eval(form.caf.value)
     freight= (ocean * ((100 + caf)/100) + bs)
     form.totalfreight.value = round(freight)
     tempfreight= freight / cases
     form.freight.value = round(tempfreight)
     
     if (eval(form.totalother.value) > 0)
     {
     other=eval(form.totalother.value)
     tempother= other / cases
     form.other.value = round(tempother)
     }
     else
     {
     tempother=eval(form.other.value)
     other= tempother * cases
     form.totalother.value = round(other)
     }
     
     
      if (eval(form.totallc.value) > 0)
     {
     lc=eval(form.totallc.value) 
     templc = lc / cases
     form.lc.value = round(templc)
 		}
		else
		{
     		if (eval(form.lc.value) > 0)   
     		  {
   			  templc=eval(form.lc.value)
   			  lc= templc * cases
   			  form.totallc.value = round(lc)
             }
            else
            	{
            	lc2=eval(form.percent.value)
            	templc= lc2 * tempexw /100
            	form.lc.value = round(templc)
            	lc = templc * cases
            	form.totallc.value= round(lc)
            	}
         }
            	    
     disb= exw+road+pd+stuff+freight+other+lc 
     form.totaldisb.value = round(disb)
     tempdisb = disb / cases
     form.disb.value= round(tempdisb)
     
     days=eval(form.days.value)
     interest=eval(form.interest.value)
     inter= disb * (interest/100) * (days/365)
     form.totalinter.value= round(inter)
     tempinter= inter / cases
     form.inter.value= round(tempinter)
        
     sub= disb + inter
     form.totalsub.value= round(sub)
     tempsub= sub / cases
     form.sub.value = round(tempsub)
     
     marine= form.marine.value
     bank= form.bank.value
     agent= form.agent.value
     margin= form.margin.value		
    	
   	  	
   	 total= sub/((100-marine-bank-agent-margin)/100)
   	 form.totalmarine.value= round(marine * total /100)
    form.totalbank.value= round(bank * total /100)
    form.totalagent.value= round(agent * total /100)
    form.totalmargin.value= round(margin * total /100)
			
    form.sellingbox.value = round(total)
    form.sellingcase.value = round(total / cases)
			
	 currcalc.amount.value= round(total);
}
